JDK-8148403 : Preverifier needs API similar to Class.forName() that loads and links a class
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:class_loading
  • Priority: P3
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2016-01-27
  • Updated: 2017-02-01
  • Resolved: 2017-02-01
Related Reports
Relates :  
Description
Jigsaw preverification needs an API similar to forName() that loads and links a class but does not initialize it.  Loading and linking a class ensures that the class gets verified, as long as verification is enabled.
Comments
Preverification has been dropped from JDK 9 and so drop fixVersion = 9.
16-06-2016

The spec of Class:forName says: This method attempts to locate, load, and link the class or interface. It means that the existing 3-arg Class.forName method does not link the class if the boolean initializer parameter is set to false. The spec of the new Class::forName(Module module, String cn) static method says: This method attempts to locate, load, and link the class or interface. It does not run the class initializer. We should change the new Class::forName(Module module, String cn) static method to call the new JVM entry point to ensure the class is loaded and linked which is what this method intends to do. The existing Class::forName methods remain as it is today. Existing code that does not want the class initializer to be invoked could migrate to the new Class::forName method taking the Module parameter.
11-04-2016

Doesn't Class.forName always load and link, and then optionally runs the initializer?
11-04-2016

Preverification needs an API that loads and links the specified class. Class.forName() either just loads the specified class or loads, links, and initializes the class. There is no version of Class.forName() that just does a load and link.
11-04-2016

Does Class.forName(Module m, String className) satisfy what preverification needs?
08-04-2016

javap is also interested in using this API (talk to Brian Goetz).
04-04-2016

This needs discussion as to whether this is a JDK-specific API that the tool can use or whether it would make sense to have a standard API for this.
11-02-2016