Proposed API for JEP 259: Stack-Walking API
brian.goetz at oracle.com
Sat Nov 14 00:07:47 UTC 2015
> I considered Optional<Class<?>>. I believe it is rare to have a JNI attached thread calling StackWalker::getCallerClass from native. Most common cases will find a caller class. Returning an Optional will force most common uses to handle the case if it’s absent. It’s a tradeoff that I think it’s better to return Thread.class for the JNI attached thread calling getCallerClass in native which would rarely happen.
+1 on returning Thread.class in these cases. Its a pragmatic compromise.
More information about the core-libs-dev