Package io.helidon.common
Class StackWalker
- java.lang.Object
-
- io.helidon.common.StackWalker
-
public final class StackWalker extends Object
A dummy replicate of Java9's StackWalker.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StackWalker.Option
Option for future partial compatibility with Java9.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>
getCallerClass()
Gets theClass
object of the caller who invoked the method that invokedgetCallerClass
.static StackWalker
getInstance()
Returns aStackWalker
instance with default options.static StackWalker
getInstance(StackWalker.Option option)
Returns aStackWalker
instance with the givenoption
specifying the stack frame information it can access.static StackWalker
getInstance(Set<StackWalker.Option> options)
Returns aStackWalker
instance with the givenoptions
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 ofStackFrame
s for the current thread, traversing from the top frame of the stack, which is the method calling thiswalk
method.
-
-
-
Method Detail
-
getInstance
public static StackWalker getInstance()
Returns aStackWalker
instance with default options.- Returns:
- a
StackWalker
configured with the default options
-
getInstance
public static StackWalker getInstance(StackWalker.Option option)
Returns aStackWalker
instance with the givenoption
specifying the stack frame information it can access.- Parameters:
option
- ignored (used by java9 forward)- Returns:
- a
StackWalker
configured with the given options
-
getInstance
public static StackWalker getInstance(Set<StackWalker.Option> options)
Returns aStackWalker
instance with the givenoptions
specifying the stack frame information it can access.- Parameters:
options
- ignored (used by java9 forward)- Returns:
- a
StackWalker
configured with the given options
-
getCallerClass
public Class<?> getCallerClass()
Gets theClass
object of the caller who invoked the method that invokedgetCallerClass
.- Returns:
Class
object of the caller's caller invoking this method.
-
walk
public Optional<StackTraceElement> walk(Function<? super Stream<StackTraceElement>,Optional<StackTraceElement>> function)
Applies the given function to the stream ofStackFrame
s for the current thread, traversing from the top frame of the stack, which is the method calling thiswalk
method.- Parameters:
function
- a function that takes a stream of stack frames and returns a result.- Returns:
- the result of applying the function to the stream of stack frame.
-
-