Package org.wildfly.security.manager
Class StackInspector
- java.lang.Object
-
- org.wildfly.security.manager.StackInspector
-
public final class StackInspector extends Object
A utility class which is useful for inspecting the call stack.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description private static StackInspector
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
StackInspector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
callStackContains(Class<?> clazz)
Determine whether the call stack contains a given class.Class<?>
getCallerClass(int skipFrames)
Get the caller class.Class<?>[]
getCallStack()
Get the call stack.Class<?>[]
getCallStack(int skipFrames)
Get all or a portion of the call stack.Class<?>[]
getCallStack(int skipFrames, int numFrames)
Get all or a portion of the call stack.static StackInspector
getInstance()
Get the singletonStackInspector
instance.
-
-
-
Field Detail
-
INSTANCE
private static final StackInspector INSTANCE
-
-
Method Detail
-
getInstance
public static StackInspector getInstance()
Get the singletonStackInspector
instance. The caller must have thegetStackInspector
RuntimePermission
. If the security manager is enabled, requiresgetStackInspector
WildFlySecurityManagerPermission
.- Returns:
- the singleton
StackInspector
instance
-
getCallerClass
public Class<?> getCallerClass(int skipFrames)
Get the caller class. TheskipFrames
argument specifies how many spots to go back on the call stack; 0 indicates the immediate caller.- Parameters:
skipFrames
- the number of frames to skip over before the immediate caller- Returns:
- the caller class
-
getCallStack
public Class<?>[] getCallStack(int skipFrames, int numFrames)
Get all or a portion of the call stack. ThenumFrames
argument specifies how many frames should be returned.- Parameters:
skipFrames
- the number of frames to skip; 0 will include the immediate caller at index 0numFrames
- the maximum number of frames to return- Returns:
- the partial call stack
-
getCallStack
public Class<?>[] getCallStack(int skipFrames)
Get all or a portion of the call stack. ThenumFrames
argument specifies how many frames should be returned.- Parameters:
skipFrames
- the number of frames to skip; 0 will include the immediate caller at index 0- Returns:
- the partial call stack
-
getCallStack
public Class<?>[] getCallStack()
Get the call stack.- Returns:
- the call stack
-
callStackContains
public boolean callStackContains(Class<?> clazz)
Determine whether the call stack contains a given class. Useful for assertions.- Parameters:
clazz
- the class to test- Returns:
true
if the call stack contains the class
-
-