Proposed API for JEP 259: Stack-Walking API

Mandy Chung mandy.chung at oracle.com
Tue Nov 17 21:57:52 UTC 2015


> On Nov 17, 2015, at 1:13 PM, Peter Levart <peter.levart at gmail.com> wrote:
> 
> But (as described in my other message), Runnable::run is not an entry point. Thread::run is. And Thread::run (a Java method) delegates to Runnable::run. So in this case Thread.class will be returned as a normal caller (which it really is). Are you thinking of detecting this situation and special-casing it?

Thanks for the feedback.   I am in the process of clarifying that the javadoc and I see the confusion there.  This is the CallerFromMain.java test (some comments need to be cleaned up) but it shows what the getCallerClass is intended to return.  

1) call from main - throw UOE

// StackWalker::getCallerClass
// CallerFromMain::main
// no caller

2) return Runnable anonymous class

// StackWalker::getCallerClass
// Runnable::run
// Thread::run

3) return MyRunnable

// StackWalker::getCallerClass
// MyRunnable::run
// Thread::run

4) return MyThread::run 

// StackWalker::getCallerClass
// Runnable::run
// MyThread::run

5) return CallerFromMain

// StackWalker::getCallerClass
// CallerFromMain::doit
// Thread::run


More information about the core-libs-dev mailing list