Proposed API for JEP 259: Stack-Walking API

Jason Mehrens jason_mehrens at
Mon Nov 2 14:42:53 UTC 2015


Thread.dumpStack should generate the stacktrace elements then capture System.err into a local var and lock it while writing the output.  That would be compatible with what was done before.


From: core-libs-dev <core-libs-dev-bounces at> on behalf of Mandy Chung <mandy.chung at>
Sent: Friday, October 30, 2015 2:04 PM
To: core-libs-dev
Subject: Proposed API for JEP 259: Stack-Walking API

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