public class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkAccessible(Class<?> callerClass,
Class<?> declaringClass,
int memberModifiers,
boolean allowIllegalAccess) |
static boolean |
checkCanSetAccessible(AccessibleObject accessibleObject,
Class<?> caller) |
static Class |
getCallingClass()
Get the immediate calling class, ignoring MOP frames.
|
static Class |
getCallingClass(int matchLevel)
Get the called that is matchLevel stack frames before the call,
ignoring MOP frames.
|
static Class |
getCallingClass(int matchLevel,
Collection<String> extraIgnoredPackages)
Get the called that is matchLevel stack frames before the call,
ignoring MOP frames and desired exclude packages.
|
static List<Method> |
getDeclaredMethods(Class<?> type,
String name,
Class<?>... parameterTypes) |
static List<Method> |
getMethods(Class<?> type,
String name,
Class<?>... parameterTypes) |
static boolean |
isCallingClassReflectionAvailable()
Determine whether or not the getCallingClass methods will return
any sensible results.
|
static Optional<AccessibleObject> |
makeAccessible(AccessibleObject ao) |
static AccessibleObject[] |
makeAccessible(AccessibleObject[] aoa) |
static Optional<AccessibleObject> |
makeAccessibleInPrivilegedAction(AccessibleObject ao) |
static boolean |
trySetAccessible(AccessibleObject ao) |
public static boolean isCallingClassReflectionAvailable()
public static Class getCallingClass()
public static Class getCallingClass(int matchLevel)
matchLevel
- how may call stacks down to look.
If it is less than 1 it is treated as though it was 1.public static Class getCallingClass(int matchLevel, Collection<String> extraIgnoredPackages)
matchLevel
- how may call stacks down to look.
If it is less than 1 it is treated as though it was 1.extraIgnoredPackages
- A collection of string names of packages to exclude
in addition to the MOP packages when counting stack frames.public static List<Method> getDeclaredMethods(Class<?> type, String name, Class<?>... parameterTypes)
public static List<Method> getMethods(Class<?> type, String name, Class<?>... parameterTypes)
public static boolean checkCanSetAccessible(AccessibleObject accessibleObject, Class<?> caller)
public static boolean checkAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess)
public static boolean trySetAccessible(AccessibleObject ao)
public static Optional<AccessibleObject> makeAccessibleInPrivilegedAction(AccessibleObject ao)
public static Optional<AccessibleObject> makeAccessible(AccessibleObject ao)
public static AccessibleObject[] makeAccessible(AccessibleObject[] aoa)