public final class StackWalker
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
StackWalker.Option |
Option for future partial compatibility with Java9.
|
Modifier and Type | Method | Description |
---|---|---|
java.lang.Class<?> |
getCallerClass() |
Gets the
Class object of the caller who invoked the method
that invoked getCallerClass . |
static StackWalker |
getInstance() |
Returns a
StackWalker instance with default options. |
static StackWalker |
getInstance(StackWalker.Option option) |
Returns a
StackWalker instance with the given option specifying
the stack frame information it can access. |
static StackWalker |
getInstance(java.util.Set<StackWalker.Option> options) |
Returns a
StackWalker instance with the given options specifying
the stack frame information it can access. |
java.util.Optional<java.lang.StackTraceElement> |
walk(java.util.function.Function<? super java.util.stream.Stream<java.lang.StackTraceElement>,java.util.Optional<java.lang.StackTraceElement>> function) |
Applies the given function to the stream of
StackFrame s
for the current thread, traversing from the top frame of the stack,
which is the method calling this walk method. |
public static StackWalker getInstance()
StackWalker
instance with default options.StackWalker
configured with the default optionspublic static StackWalker getInstance(StackWalker.Option option)
StackWalker
instance with the given option
specifying
the stack frame information it can access.option
- ignored (used by java9 forward)StackWalker
configured with the given optionspublic static StackWalker getInstance(java.util.Set<StackWalker.Option> options)
StackWalker
instance with the given options
specifying
the stack frame information it can access.options
- ignored (used by java9 forward)StackWalker
configured with the given optionspublic java.lang.Class<?> getCallerClass()
Class
object of the caller who invoked the method
that invoked getCallerClass
.Class
object of the caller's caller invoking this method.public java.util.Optional<java.lang.StackTraceElement> walk(java.util.function.Function<? super java.util.stream.Stream<java.lang.StackTraceElement>,java.util.Optional<java.lang.StackTraceElement>> function)
StackFrame
s
for the current thread, traversing from the top frame of the stack,
which is the method calling this walk
method.function
- a function that takes a stream of
stack frames and returns a result.Copyright © 2018 Oracle Corporation. All rights reserved.