Package io.servicetalk.utils.internal
Class ReflectionUtils
java.lang.Object
io.servicetalk.utils.internal.ReflectionUtils
Provide utilities to assist reflective access.
This class is forked from the netty project and modified to suit our needs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodretrieveMethod(Class<?> clazz, String name, Class<?>... parameterTypes) static ThrowabletrySetAccessible(AccessibleObject object, boolean checkAccessible) Try to callAccessibleObject.setAccessible(boolean)but will catch anySecurityExceptionandjava.lang.reflect.InaccessibleObjectException(for JDK 9) and return it.
-
Method Details
-
retrieveMethod
Retrieves the specificMethodfrom theClasswithout checked exception.Throws
IllegalArgumentExceptionifNoSuchMethodExceptionis thrown. -
trySetAccessible
@Nullable public static Throwable trySetAccessible(AccessibleObject object, boolean checkAccessible) Try to callAccessibleObject.setAccessible(boolean)but will catch anySecurityExceptionandjava.lang.reflect.InaccessibleObjectException(for JDK 9) and return it. The caller must check if it returnsnulland if not handle the returned exception.- Parameters:
object- The object to attempt to make accessible.checkAccessible-trueto respect system property configuration which may limitAccessibleObject.setAccessible(boolean)attempts.falseto try regardless of system property configuration.- Returns:
- a
Throwableindicating the exception that occurred while attempting to makeobjectaccessible, ornullif the operation was successful.
-