RFR: 8212117 : Class.forName may return a reference to a loaded but not linked Class

Mandy Chung mandy.chung at oracle.com
Fri Sep 6 01:03:40 UTC 2019



On 9/5/19 5:09 PM, Brent Christian wrote:
> Updated webrev:
> http://cr.openjdk.java.net/~bchristi/8212117/webrev10/

jvm.h

  349  * Link the 'arg' class (unless ClassForNameDeferLinking is set)

I suggest to drop "(unless ...)" phrase because the flag is temporary.

jni.cpp

The implementation of JNI FindClass has the same behavior as 1-arg
Class.forName(name).  The JNI spec needs fixing but it's a separate
issue.

find_class_from_class_loader
   I like David's suggestion to assert that if init == true, link
   must be true.  Alternatively, pass an enum instead of two booleans
   clearly tell linking or initializing.

Lookup::findClass:

"In particular, the method first attempts to load the requested class"

I think this sentence is no longer needed together with your change.  What about:

          /**
-         * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static
-         * initializer of the class is not run.
+         * Looks up a class by name from the lookup context defined by this {@code Lookup} object.
+         * This method attempts to locate, load, and link the class, and then determines whether
+         * the class is accessible to this {@code Lookup} object.
+         * The static initializer of the class is not run.
           * <p>
           * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class
-         * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to
-         * load the requested class, and then determines whether the class is accessible to this lookup object.
+         * loader, and the {@linkplain #lookupModes() lookup modes}.


The note you added in this method should also be added to 2-arg
Class::forName for consistency.

Otherwise, the fix looks good.

Mandy



More information about the hotspot-dev mailing list