Package org.codehaus.groovy.reflection
Class ReflectionUtils
java.lang.Object
org.codehaus.groovy.reflection.ReflectionUtils
This class contains utility methods to determine which class called the
 current class to multiple levels of depth.  Calls used to handle the
 groovy MOP are excluded from the level counting.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleancheckAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess) static booleancheckCanSetAccessible(AccessibleObject accessibleObject, Class<?> caller) static ClassGets the immediate calling class, ignoring MOP frames.static ClassgetCallingClass(int matchLevel) Gets the called that is matchLevel stack frames before the call, ignoring MOP frames.static ClassgetCallingClass(int matchLevel, Collection<String> extraIgnoredPackages) Gets the called that is matchLevel stack frames before the call, ignoring MOP frames and desired exclude packages.getDeclaredMethods(Class<?> type, String name, Class<?>... parameterTypes) getMethods(Class<?> type, String name, Class<?>... parameterTypes) static Class<?>[]getPermittedSubclasses(Class<?> clazz) static booleanDetermines whether the getCallingClass methods will return any sensible results.static booleanstatic Optional<AccessibleObject>static AccessibleObject[]makeAccessible(AccessibleObject[] aoa) static Optional<AccessibleObject>static booleanparameterTypeMatches(Class<?>[] parameterTypes, Class<?>[] argTypes) static boolean
- 
Constructor Details- 
ReflectionUtilspublic ReflectionUtils()
 
- 
- 
Method Details- 
isCallingClassReflectionAvailablepublic static boolean isCallingClassReflectionAvailable()Determines whether the getCallingClass methods will return any sensible results. On JVMs that are not Sun derived i.e. (gcj, Harmony) this will likely return false. When not available all getCallingClass methods will return null.- Returns:
- true if getCallingClass can return anything but null, false if it will only return null.
 
- 
getCallingClassGets the immediate calling class, ignoring MOP frames.- Returns:
- The Class of the caller
 
- 
getCallingClassGets the called that is matchLevel stack frames before the call, ignoring MOP frames.- Parameters:
- matchLevel- how may call stacks down to look. If it is less than 1 it is treated as though it was 1.
- Returns:
- The Class of the matched caller, or null if there aren't enough stackframes to satisfy matchLevel
 
- 
getCallingClassGets the called that is matchLevel stack frames before the call, ignoring MOP frames and desired exclude packages.- Parameters:
- 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.
- Returns:
- The Class of the matched caller, or null if there aren't enough stackframes to satisfy matchLevel
 
- 
getDeclaredMethods
- 
getMethods
- 
parameterTypeMatches
- 
checkCanSetAccessible
- 
checkAccessible
- 
trySetAccessible
- 
makeAccessibleInPrivilegedAction
- 
makeAccessible
- 
makeAccessible
- 
isSealed
- 
getPermittedSubclasses
 
-