Proposed API for JEP 259: Stack-Walking API
Mandy Chung
mandy.chung at oracle.com
Mon Nov 16 19:16:40 UTC 2015
> On Nov 15, 2015, at 10:59 AM, Peter Levart <peter.levart at gmail.com> wrote:
>
> OTOH in the described cases, a caller of walker.getCallerClass() is actually expecting to be called by a Java method, right? So what would it be if such "caller-sensitive" method demanded to be called by a Java method and throw IllegalArgumentException("Not called by Java method") otherwise?
>
> Have you thought of that possibility?
Are you thinking about a JNI method calling getCallerClass? Or refer getCallerClass being the bottom of the stack?
I don’t see any issue for a JNI method calling getCallerClass and it’s doing:
* Class<?> caller = walker.walk(s ->
* s.map(StackFrame::getDeclaringClass)
* .skip(2)
* .findFirst());
Mandy
More information about the core-libs-dev
mailing list