Class ReflectionEngine

java.lang.Object
py4j.reflection.ReflectionEngine

public class ReflectionEngine extends Object

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

Author:
Barthelemy Dagenais
  • Field Details

  • Constructor Details

    • ReflectionEngine

      public ReflectionEngine()
  • Method Details

    • createArray

      public Object createArray(String fqn, int[] dimensions)
    • getClass

      public Class<?> getClass(Class<?> clazz, String name)
    • getClassParameters

      public Class<?>[] getClassParameters(Object[] parameters)
    • getConstructor

      public MethodInvoker getConstructor(Class<?> clazz, Class<?>[] parameters)
    • getConstructor

      public MethodInvoker getConstructor(String classFQN, Object[] parameters)
    • getField

      public Field getField(Class<?> clazz, 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 Field getField(Object obj, 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 Field getField(String classFQN, String name)
    • getFieldValue

      public Object getFieldValue(Object obj, Field field)

      Wrapper around Field.get

      Parameters:
      obj -
      field -
      Returns:
    • getMethod

      public Method getMethod(Class<?> clazz, String name)
    • getMethod

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

      public MethodInvoker getMethod(Object object, String name, Object[] parameters)
    • getMethod

      public MethodInvoker getMethod(String classFQN, String name, Object[] parameters)
    • invoke

      public Object invoke(Object object, MethodInvoker invoker, Object[] parameters)
    • setFieldValue

      public void setFieldValue(Object obj, Field field, Object value)

      Wrapper around Field.set

      Parameters:
      obj -
      field -
      value -
    • getPublicMethodNames

      public String[] getPublicMethodNames(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 String[] getPublicFieldNames(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 String[] getPublicStaticFieldNames(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 String[] getPublicStaticMethodNames(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 String[] getPublicStaticClassNames(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 String[] getPublicStaticNames(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