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.
| Type Params | Return Type | Name and description |
|---|---|---|
|
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 Constructor<?>[] |
getDeclaredConstructorsSorted(Class<?> type)Returns the declared constructors of a class in a deterministic order. |
|
static Method[] |
getDeclaredMethodsSorted(Class<?> type)Returns the declared methods of a class in a deterministic order. |
|
static boolean |
isCallingClassReflectionAvailable()Determine whether or not the getCallingClass methods will return any sensible results. |
Get the immediate calling class, ignoring MOP frames.
Get the called that is matchLevel stack frames before the call, ignoring MOP frames.
matchLevel - how may call stacks down to look.
If it is less than 1 it is treated as though it was 1.Get the called that is matchLevel stack frames before the call, ignoring MOP frames and desired exclude packages.
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 declared constructors of a class in a deterministic order.
Class.getDeclaredConstructors does not guarantee an order, and a nondeterministic order can flow into generated bytecode; see getDeclaredMethodsSorted(Class).
type - the class to introspectReturns the declared methods of a class in a deterministic order.
Class.getDeclaredMethods does not guarantee an order, and
HotSpot's varies between JVM runs. When members of a precompiled class
are enumerated at compile time (annotation members copied to generated
code, trait methods woven into implementing classes, MOP super$
bridge methods, etc.), that order flows into the generated bytecode, so
a nondeterministic order produces byte-different class files from
identical sources. Callers whose output depends on member order should
use this variant so builds are reproducible.
type - the class to introspectDetermine whether or not 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.