JDK-8230780 : Release Note: Classes are now loaded and linked by Class.forName()
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang:class_loading
  • Affected Version: 14
  • Priority: P4
  • Status: Resolved
  • Resolution: Withdrawn
  • Submitted: 2019-09-09
  • Updated: 2019-11-04
  • Resolved: 2019-11-04
Description
The specification for `java.lang.Class.forName(String name, boolean initialize, ClassLoader loader)` has long stated, "this method attempts to locate, load, and link the class or interface."

However, the class has not been linked when passing an `initialize` value of `false`.  The following methods now ensure that linking is performed, conforming to the specification:
* `java.lang.Class.forName(String, boolean, ClassLoader)`
* `java.lang.Class.forName(Module, String)`
* `java.lang.invoke.MethodHandles.Lookup.findClass(String)`

These methods are declared to throw `LinkageError`.  With this change, such errors may be thrown earlier (or perhaps they weren't thrown at all, e.g. for classes that are loaded but never used).  For now, there is a VM flag, `-XX:+ClassForNameDeferLinking`, which can be used to revert to the previous behavior, in order to allow code to be fixed to account for undiscovered LinkageErrors.

Comments
JDK-8212117 has been backed out, so this release note is defunct. I will make updates to reflect this.
04-11-2019

Applied minor edits. This seems fine to me. Thanks.
10-09-2019