Review Request: JDK-8206240: java.lang.Class.newInstance() is causing caller to leak

Mandy Chung mandy.chung at oracle.com
Wed Oct 3 17:28:40 UTC 2018


On 10/3/18 9:30 AM, Peter Levart wrote:
> Hi Mandy,
>
> I don't know if this matters though, but should 
> Reflection.getCallerClass() ever return null, previous behavior was to 
> throw NPE (from Reflection.verifyMemberAccess(...)), now the checks 
> are skipped. This should only be observable if [Class, 
> Constructor].newInstance() was called from JNI's newly attached thread 
> I believe. 

Yes that's the case.   Such case never works as it will get NPE.  I 
didn't worry too much about it.  Since you mentioned it, I should keep 
the existing behavior (throwing NPE):

http://cr.openjdk.java.net/~mchung/jdk12/webrevs/8206240/webrev.01

Mandy



More information about the core-libs-dev mailing list