Proposed API for JEP 259: Stack-Walking API

Mandy Chung mandy.chung at
Fri Oct 30 19:04:33 UTC 2015

JEP 259:

Javadoc for the proposed StackWalker API:

A simple way to walk the stack:

   StackWalker walker = new StackWalker(StackWalker.Option.CLASS_REFERENCE);
   walker.walk((s) ->  s.filter(f -> interestingClasses.contains(f.getDeclaringClass())).findFirst());

The current usage of sun.reflect.Reflection.getCallerClass(int depth) can be replaced with this StackWalker API.

Any feedback on the proposed API is appreciated.


P.S. webrev of the current implementation:

More information about the core-libs-dev mailing list