RFR [9]: 8177036: Class.checkMemberAccess throws NPE when calling Class methods via JNI

Daniel Fuchs daniel.fuchs at oracle.com
Mon Mar 20 12:15:30 UTC 2017

Hi Peter,

On 20/03/2017 12:01, Peter Levart wrote:
> Perhaps the best way to rectify those problems in one place would be for
> Reflection.getCallerClass() to return a special internal class in its
> own package, such as:
> jdk.internal.solitary.NoCaller
> ...when there is no caller. This would work correctly for class loader
> checks and would only allow invoking public exported members by core
> reflection if invoked with no caller...

I believe this might be dangerous as it would probably hide bugs
in places where 'null' results in NPE being thrown in today's

Allowing the code to succeed is not always the right thing to
do, and I don't believe it can be fixed in one place.
It's probably better to let the caller of Reflection.getCallerClass()
decide what to do when null is returned, even if this means
we might have to analyze all places where @CallerSensitive is

best regards,

-- daniel

> What do you think?
> Regards, Peter

More information about the core-libs-dev mailing list