|
FlexDoc/Javadoc 2.0 Demo Java Doc |
The walk method opens a sequential stream of StackFrames for the current thread and then applies the given function to walk the StackFrame stream. The stream reports stack frame elements in order, from the top most frame that represents the execution point at which the stack was generated to the bottom most frame. The StackFrame stream is closed when the walk method returns. If an attempt is made to reuse the closed stream, IllegalStateException will be thrown.
The stack walking options of a StackWalker determines the information of StackFrame objects to be returned. By default, stack frames of the reflection API and implementation classes are hidden and StackFrames have the class name and method name available but not the Class reference.
StackWalker is thread-safe. Multiple threads can share a single StackWalker object to traverse its own stack. A permission check is performed when a StackWalker is created, according to the options it requests. No further permission check is done at stack walking time.
Nested Class Summary |
||
static enum |
Stack walker option to configure the stack frame
information obtained by a StackWalker.
|
|
static interface |
A StackFrame object represents a method invocation returned by
StackWalker.
|
Method Summary |
||
void |
Performs the given action on each element of StackFrame stream
of the current thread, traversing from the top frame of the stack,
which is the method calling this forEach method.
|
|
Class<?> |
Gets the Class object of the caller who invoked the method
that invoked getCallerClass.
|
|
static StackWalker |
Returns a StackWalker instance.
|
|
static StackWalker |
Returns a StackWalker instance with the given options specifying
the stack frame information it can access.
|
|
static StackWalker |
Returns a StackWalker instance with the given options specifying
the stack frame information it can access.
|
|
static StackWalker |
getInstance(StackWalker.Option option)
Returns a StackWalker instance with the given option specifying
the stack frame information it can access.
|
|
Applies the given function to the stream of StackFrames
for the current thread, traversing from the top frame of the stack,
which is the method calling this walk method.
|
Methods inherited from class java.lang.Object |
public static StackWalker getInstance |
() |
This StackWalker is configured to skip all hidden frames and no class reference is retained.
public static StackWalker getInstance |
(StackWalker.Option option) |
If a security manager is present and the given option is Option.RETAIN_CLASS_REFERENCE, it calls its checkPermission method for RuntimePermission("getStackWalkerWithClassReference").
public static StackWalker getInstance |
(Set<StackWalker.Option> options) |
If a security manager is present and the given options contains Option.RETAIN_CLASS_REFERENCE, it calls its checkPermission method for RuntimePermission("getStackWalkerWithClassReference").
public static StackWalker getInstance |
If a security manager is present and the given options contains Option.RETAIN_CLASS_REFERENCE, it calls its checkPermission method for RuntimePermission("getStackWalkerWithClassReference").
The estimateDepth specifies the estimate number of stack frames this StackWalker will traverse that the StackWalker could use as a hint for the buffer size.
The StackFrame stream will be closed when this method returns. When a closed Stream<StackFrame> object is reused, IllegalStateException will be thrown.
public void forEach |
(Consumer<? super StackWalker.StackFrame> action) |
This method is equivalent to calling
walk(s -> { s.forEach(action); return null; });
public Class<?> getCallerClass |
() |
This method filters reflection frames, MethodHandle, and hidden frames regardless of the SHOW_REFLECT_FRAMES and SHOW_HIDDEN_FRAMES options this StackWalker has been configured with.
This method should be called when a caller frame is present. If it is called from the bottom most frame on the stack, IllegalCallerException will be thrown.
This method throws UnsupportedOperationException if this StackWalker is not configured with the RETAIN_CLASS_REFERENCE option.
|
FlexDoc/Javadoc 2.0 Demo Java Doc |