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

Mandy Chung mandy.chung at oracle.com
Tue Oct 2 19:33:16 UTC 2018


Class::newInstance maintains its separate cache of the caller
class after access check.  This leak has been there for a long
time and unnoticed.

This patch changes Class::newInstance to use the code path
for Constructor::newInstance doing the access check and
caching the caller class.  It will also get the illegal
access check in effect when Class::newInstance is called
consistent with Constructor::newInstance.

Webrev at:
http://cr.openjdk.java.net/~mchung/jdk12/webrevs/8206240/webrev.00

Alan raises a question whether the cache is still needed
given that we have improved the performance of slow
path of access check with Class::getPackageName.  It's a
good investigation to follow up.

Mandy


More information about the core-libs-dev mailing list