New better way to walk the stack

The StackWalker class has four getInstance() static factory methods:

  • getInstance(): This returns a StackWalker class instance configured to skip all hidden frames and the caller class reference
  • getInstance(StackWalker.Option option): This creates a StackWalker class instance with the given option specifying the stack frame information it can access
  • getInstance(Set<StackWalker.Option> options): This creates a StackWalker class instance with the given set of options
  • getInstance(Set<StackWalker.Option> options, int estimatedDepth): This allows you to pass in the estimatedDepth parameter that specifies the estimated number of stack frames this instance will traverse so that the Java machine can allocate the appropriate ...

Get Java 9 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.