Proposed API for JEP 259: Stack-Walking API
Mandy Chung
mandy.chung at oracle.com
Tue Nov 3 03:38:45 UTC 2015
> On Nov 2, 2015, at 6:42 AM, Jason Mehrens <jason_mehrens at hotmail.com> wrote:
>
> Mandy,
>
> 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.
>
Good catch. Will fix that. Thread.dumpStack can be further improved to avoid constructing StackTraceElement (that’s something for the future).
Mandy
> Jason
>
> ________________________________________
> From: core-libs-dev <core-libs-dev-bounces at openjdk.java.net> on behalf of Mandy Chung <mandy.chung at oracle.com>
> Sent: Friday, October 30, 2015 2:04 PM
> To: core-libs-dev
> Subject: Proposed API for JEP 259: Stack-Walking API
>
> JEP 259: http://openjdk.java.net/jeps/259
>
> Javadoc for the proposed StackWalker API:
> http://cr.openjdk.java.net/~mchung/jdk9/jep259/api/java/lang/StackWalker.html
>
> 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.
>
> Mandy
>
> P.S. webrev of the current implementation:
> http://cr.openjdk.java.net/~mchung/jdk9/jep259/webrev.00/
>
>
>
>
>
>
>
More information about the core-libs-dev
mailing list