Class ReflectionUtil

java.lang.Object
com.yourkit.probes.ReflectionUtil

public class ReflectionUtil extends Object
Provide reflection utility methods for probes.
  • Field Details

  • Constructor Details

    • ReflectionUtil

      public ReflectionUtil()
  • Method Details

    • callMethod0

      @Nullable public static Object callMethod0(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String methodName, @Nullable CallStatus callStatus)
      Invokes instance or static method with no parameters and any return type.
      Parameters:
      object - should be NULL for static method
      callStatus - if specified, allows to retrieve thrown exception if the call fails
      Returns:
      the method return value, or NULL if the method has thrown an exception or cannot be called (e.g. does not exist)
    • callMethod0

      @Nullable public static Object callMethod0(@NotNull Object object, @NotNull String methodName, @Nullable CallStatus callStatus)
      Invokes instance method with no parameters and any return type.
      Parameters:
      callStatus - if specified, allows to retrieve thrown exception if the call fails
      Returns:
      the method return value, or NULL if the method has thrown an exception or cannot be called (e.g. does not exist)
    • callMethod0

      @Nullable public static Object callMethod0(@NotNull Object object, @NotNull String methodName)
      Invokes instance method with no parameters and any return type.
      Returns:
      the method return value, or NULL if the method has thrown an exception or cannot be called (e.g. does not exist)
    • callMethod1

      @Nullable public static Object callMethod1(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String methodNameAndSignature, @Nullable Object arg1, @Nullable CallStatus callStatus)
      Invokes a method with one parameter and any return type.
      Parameters:
      object - should be NULL for static method
    • getFieldValue

      @Nullable public static <T> T getFieldValue(@NotNull Object object, @NotNull String fieldName)
    • getFieldValue

      @Nullable public static <T> T getFieldValue(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String fieldName, @Nullable CallStatus callStatus)
      Gets value of a reference field, either instance or static
    • getFieldValue

      @Nullable public static <T> T getFieldValue(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String fieldName)
      Gets value of a reference field, either instance or static
    • setFieldObjectValue

      public static void setFieldObjectValue(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String fieldName, @Nullable Object value)
      Sets value to a reference field, either instance or static
    • getFieldPrimValue

      public static long getFieldPrimValue(@NotNull Class<?> aClass, @Nullable Object object, @NotNull String fieldName)
      Gets the value of a field of primitive type, either instance or static.
    • getFieldPrimValue

      public static long getFieldPrimValue(@NotNull Object object, @NotNull String fieldName)
      Gets the value of an instance field of primitive type.