StackWalker.getInstance(Option): This method is available in the java.lang.StackWalker class of Java.
Syntax:
StackWalker java.lang.StackWalker.getInstance(Option option)
This method takes one argument. This method returns a StackWalker instance with the given option specifying the stack frame information it can access.
Parameters: One parameter is required for this method.
option: stack walking option.
Returns: a StackWalker configured with the given option.
Throws:
1. SecurityException - if a security manager exists and its checkPermission method denies access.
Approach
Java
package com.StackWalker;import java.lang.StackWalker.Option;public class StackWalkergetInstance3 {public static void main(String[] args) {Option option = Option.SHOW_HIDDEN_FRAMES;StackWalker stackWalker =StackWalker.getInstance(option);System.out.println(stackWalker);}}
Output:
java.lang.StackWalker@39ed3c8d
Some other methods of StackWalker
forEach(Consumer): This method performs the given action on each element of the StackFrame stream of the current thread, traversing from the top frame of the stack, which is the method calling this forEach method.
getCallerClass(): This method gets the Class object of the caller who invoked the method that invoked getCallerClass.
StackWalker.getInstance(): This method returns a StackWalker instance.
StackWalker.getInstance(Set): This method returns a StackWalker instance with the given options specifying the stack frame information it can access.
StackWalker.getInstance(Option): This method returns a StackWalker instance with the given option specifying the stack frame information it can access.
StackWalker.getInstance(Set, int): This method returns a StackWalker instance with the given options specifying the stack frame information it can access.
walk(Function): This method applies the given function to the stream of StackFramesfor the current thread, traversing from the top frame of the stack, which is the method calling this walk method.
No comments:
Post a Comment