Class ReflectionEngine


  • public class ReflectionEngine
    extends java.lang.Object

    The reflection engine is responsible for accessing the classes, the instances and members in a JVM.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int cacheSize  
      static java.lang.Object RETURN_VOID  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object createArray​(java.lang.String fqn, int[] dimensions)  
      java.lang.Class<?> getClass​(java.lang.Class<?> clazz, java.lang.String name)  
      java.lang.Class<?>[] getClassParameters​(java.lang.Object[] parameters)  
      MethodInvoker getConstructor​(java.lang.Class<?> clazz, java.lang.Class<?>[] parameters)  
      MethodInvoker getConstructor​(java.lang.String classFQN, java.lang.Object[] parameters)  
      java.lang.reflect.Field getField​(java.lang.Class<?> clazz, java.lang.String name)  
      java.lang.reflect.Field getField​(java.lang.Object obj, java.lang.String name)  
      java.lang.reflect.Field getField​(java.lang.String classFQN, java.lang.String name)  
      java.lang.Object getFieldValue​(java.lang.Object obj, java.lang.reflect.Field field)
      Wrapper around Field.get
      java.lang.reflect.Method getMethod​(java.lang.Class<?> clazz, java.lang.String name)  
      MethodInvoker getMethod​(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>[] parameters)  
      MethodInvoker getMethod​(java.lang.Object object, java.lang.String name, java.lang.Object[] parameters)  
      MethodInvoker getMethod​(java.lang.String classFQN, java.lang.String name, java.lang.Object[] parameters)  
      java.lang.String[] getPublicFieldNames​(java.lang.Object obj)
      Retrieve the names of all the public fields in the obj
      java.lang.String[] getPublicMethodNames​(java.lang.Object obj)
      Retrieve the names of all the public methods in the obj
      java.lang.String[] getPublicStaticClassNames​(java.lang.Class<?> clazz)
      Retrieve the names of all the public static classes in the clazz
      java.lang.String[] getPublicStaticFieldNames​(java.lang.Class<?> clazz)
      Retrieve the names of all the public static fields in the clazz
      java.lang.String[] getPublicStaticMethodNames​(java.lang.Class<?> clazz)
      Retrieve the names of all the public static methods in the clazz
      java.lang.String[] getPublicStaticNames​(java.lang.Class<?> clazz)
      Retrieve the names of all the public static fields, methods and classes in the clazz
      java.lang.Object invoke​(java.lang.Object object, MethodInvoker invoker, java.lang.Object[] parameters)  
      void setFieldValue​(java.lang.Object obj, java.lang.reflect.Field field, java.lang.Object value)
      Wrapper around Field.set
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RETURN_VOID

        public static final java.lang.Object RETURN_VOID
    • Constructor Detail

      • ReflectionEngine

        public ReflectionEngine()
    • Method Detail

      • createArray

        public java.lang.Object createArray​(java.lang.String fqn,
                                            int[] dimensions)
      • getClass

        public java.lang.Class<?> getClass​(java.lang.Class<?> clazz,
                                           java.lang.String name)
      • getClassParameters

        public java.lang.Class<?>[] getClassParameters​(java.lang.Object[] parameters)
      • getConstructor

        public MethodInvoker getConstructor​(java.lang.Class<?> clazz,
                                            java.lang.Class<?>[] parameters)
      • getConstructor

        public MethodInvoker getConstructor​(java.lang.String classFQN,
                                            java.lang.Object[] parameters)
      • getField

        public java.lang.reflect.Field getField​(java.lang.Class<?> clazz,
                                                java.lang.String name)
        Parameters:
        clazz -
        name -
        Returns:
        The field or null if a field with this name does not exist in this class or in its hierarchy.
      • getField

        public java.lang.reflect.Field getField​(java.lang.Object obj,
                                                java.lang.String name)
        Parameters:
        obj -
        name -
        Returns:
        The field or null if a field with this name does not exist in the class of this object or in its hierarchy.
      • getField

        public java.lang.reflect.Field getField​(java.lang.String classFQN,
                                                java.lang.String name)
      • getFieldValue

        public java.lang.Object getFieldValue​(java.lang.Object obj,
                                              java.lang.reflect.Field field)

        Wrapper around Field.get

        Parameters:
        obj -
        field -
        Returns:
      • getMethod

        public java.lang.reflect.Method getMethod​(java.lang.Class<?> clazz,
                                                  java.lang.String name)
      • getMethod

        public MethodInvoker getMethod​(java.lang.Class<?> clazz,
                                       java.lang.String name,
                                       java.lang.Class<?>[] parameters)
      • getMethod

        public MethodInvoker getMethod​(java.lang.Object object,
                                       java.lang.String name,
                                       java.lang.Object[] parameters)
      • getMethod

        public MethodInvoker getMethod​(java.lang.String classFQN,
                                       java.lang.String name,
                                       java.lang.Object[] parameters)
      • invoke

        public java.lang.Object invoke​(java.lang.Object object,
                                       MethodInvoker invoker,
                                       java.lang.Object[] parameters)
      • setFieldValue

        public void setFieldValue​(java.lang.Object obj,
                                  java.lang.reflect.Field field,
                                  java.lang.Object value)

        Wrapper around Field.set

        Parameters:
        obj -
        field -
        value -
      • getPublicMethodNames

        public java.lang.String[] getPublicMethodNames​(java.lang.Object obj)
        Retrieve the names of all the public methods in the obj
        Parameters:
        obj - the object to inspect
        Returns:
        list of all the names of public methods in obj
      • getPublicFieldNames

        public java.lang.String[] getPublicFieldNames​(java.lang.Object obj)
        Retrieve the names of all the public fields in the obj
        Parameters:
        obj - the object to inspect
        Returns:
        list of all the names of public fields in obj
      • getPublicStaticFieldNames

        public java.lang.String[] getPublicStaticFieldNames​(java.lang.Class<?> clazz)
        Retrieve the names of all the public static fields in the clazz
        Parameters:
        clazz - the object to inspect
        Returns:
        list of all the names of public statics
      • getPublicStaticMethodNames

        public java.lang.String[] getPublicStaticMethodNames​(java.lang.Class<?> clazz)
        Retrieve the names of all the public static methods in the clazz
        Parameters:
        clazz - the object to inspect
        Returns:
        list of all the names of public statics
      • getPublicStaticClassNames

        public java.lang.String[] getPublicStaticClassNames​(java.lang.Class<?> clazz)
        Retrieve the names of all the public static classes in the clazz
        Parameters:
        clazz - the object to inspect
        Returns:
        list of all the names of public statics
      • getPublicStaticNames

        public java.lang.String[] getPublicStaticNames​(java.lang.Class<?> clazz)
        Retrieve the names of all the public static fields, methods and classes in the clazz
        Parameters:
        clazz - the object to inspect
        Returns:
        list of all the names of public statics