public final class StackWalker extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StackWalker.Option
Option for future partial compatibility with Java9.
|
| Modifier and Type | Method and Description |
|---|---|
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(Set<StackWalker.Option> options)
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. |
Optional<StackTraceElement> |
walk(Function<? super Stream<StackTraceElement>,Optional<StackTraceElement>> function)
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. |
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(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 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 Optional<StackTraceElement> walk(Function<? super Stream<StackTraceElement>,Optional<StackTraceElement>> function)
StackFrames
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 and/or its affiliates. All Rights Reserved. Use is subject to license terms.