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 classStackWalker.OptionOption for future partial compatibility with Java9.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>getCallerClass()Gets theClassobject of the caller who invoked the method that invokedgetCallerClass.static StackWalkergetInstance()Returns aStackWalkerinstance with default options.static StackWalkergetInstance(StackWalker.Option option)Returns aStackWalkerinstance with the givenoptionspecifying the stack frame information it can access.static StackWalkergetInstance(Set<StackWalker.Option> options)Returns aStackWalkerinstance with the givenoptionsspecifying the stack frame information it can access.Optional<StackTraceElement>walk(Function<? super Stream<StackTraceElement>,Optional<StackTraceElement>> function)Applies the given function to the stream ofStackFrames for the current thread, traversing from the top frame of the stack, which is the method calling thiswalkmethod.
-
-
-
Method Detail
-
getInstance
public static StackWalker getInstance()
Returns aStackWalkerinstance with default options.- Returns:
- a
StackWalkerconfigured with the default options
-
getInstance
public static StackWalker getInstance(StackWalker.Option option)
Returns aStackWalkerinstance with the givenoptionspecifying the stack frame information it can access.- Parameters:
option- ignored (used by java9 forward)- Returns:
- a
StackWalkerconfigured with the given options
-
getInstance
public static StackWalker getInstance(Set<StackWalker.Option> options)
Returns aStackWalkerinstance with the givenoptionsspecifying the stack frame information it can access.- Parameters:
options- ignored (used by java9 forward)- Returns:
- a
StackWalkerconfigured with the given options
-
getCallerClass
public Class<?> getCallerClass()
Gets theClassobject of the caller who invoked the method that invokedgetCallerClass.- Returns:
Classobject 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 ofStackFrames for the current thread, traversing from the top frame of the stack, which is the method calling thiswalkmethod.- 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.
-
-