RFR 8233091 : Backout JDK-8212117: Class.forName loads a class but not linked if class is not initialized

Brent Christian brent.christian at oracle.com
Thu Oct 31 22:50:01 UTC 2019


Hi,

Please review my change to backout JDK-8212117:
http://cr.openjdk.java.net/~bchristi/8233091/webrev-revert-01/

Background:

A couple months ago, JDK-8212117[1] was fixed[2].  It changed the 
behavior of the 2-arg and 3-arg Class.forName methods to ensure that 
linking is performed.  This conforms to the specification[3], which 
states that the method "attempts to locate, load, and link the class". 
In the process, 8181144[7] was also resolved.

It was acknowledged that new LinkageErrors could be introduced as a 
result - for instance, in cases where Class.forName() loads, but never 
uses, an unlinkable class.  Such uncovered errors would need to be fixed.

Well, after a few promoted builds with the JDK-8212117 change, it looks 
like new LinkageErrors will be more widespread than anticipated 
(JDK-8231924[4], for example).  This change to long-standing behavior 
would cause too great an incompatibility.  (See Mandy's comment[5] for 
more.)

So the proposal is to revert the JDK-8212117 change, along with a couple 
follow-up tasks:

* Update the Class::forName API spec to match the long-standing behavior 
(i.e. no linking if initialize=false) - JDK-8233272 [6]

* Reopen JDK-8181144[7] for further investigation of JDI 
VirtualMachine::allClasses and JVM TI AllLoadedClasses

Thanks,
-Brent

==============
1. https://bugs.openjdk.java.net/browse/JDK-8212117

2. 
http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-September/062142.html

3. 
https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/Class.html#forName(java.lang.String,boolean,java.lang.ClassLoader)

4. https://bugs.openjdk.java.net/browse/JDK-8231924

5. 
https://bugs.openjdk.java.net/browse/JDK-8212117?focusedCommentId=14297501&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14297501

6. https://bugs.openjdk.java.net/browse/JDK-8233272

7. https://bugs.openjdk.java.net/browse/JDK-8181144




More information about the core-libs-dev mailing list