Package com.yourkit.probes
Class ReflectionUtil
java.lang.Object
com.yourkit.probes.ReflectionUtil
Provide reflection utility methods for probes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
callMethod0
(Class<?> aClass, Object object, String methodName, CallStatus callStatus) Invokes instance or static method with no parameters and any return type.static Object
callMethod0
(Object object, String methodName) Invokes instance method with no parameters and any return type.static Object
callMethod0
(Object object, String methodName, CallStatus callStatus) Invokes instance method with no parameters and any return type.static Object
callMethod1
(Class<?> aClass, Object object, String methodNameAndSignature, Object arg1, CallStatus callStatus) Invokes a method with one parameter and any return type.static long
getFieldPrimValue
(Class<?> aClass, Object object, String fieldName) Gets the value of a field of primitive type, either instance or static.static long
getFieldPrimValue
(Object object, String fieldName) Gets the value of an instance field of primitive type.static <T> T
getFieldValue
(Class<?> aClass, Object object, String fieldName) Gets value of a reference field, either instance or staticstatic <T> T
getFieldValue
(Class<?> aClass, Object object, String fieldName, CallStatus callStatus) Gets value of a reference field, either instance or staticstatic <T> T
getFieldValue
(Object object, String fieldName) static void
setFieldObjectValue
(Class<?> aClass, Object object, String fieldName, Object value) Sets value to a reference field, either instance or static
-
Field Details
-
SIG_SEP
- See Also:
-
OBJECT_SIG
- See Also:
-
STRING_SIG
- See Also:
-
-
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 beNULL
for static methodcallStatus
- 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
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 beNULL
for static method
-
getFieldValue
-
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
Gets the value of an instance field of primitive type.
-