RFR: 8259839 SystemDictionary exports too much implementation [v3]
Coleen Phillimore
coleenp at openjdk.java.net
Thu Jan 28 15:41:41 UTC 2021
On Thu, 28 Jan 2021 05:32:48 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Coleen Phillimore has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Fix comments and verify_placeholder
>> - Fix handle_resolution_exception to make more sense.
>
> src/hotspot/share/classfile/systemDictionary.cpp line 269:
>
>> 267: if (HAS_PENDING_EXCEPTION || klass == NULL) {
>> 268: handle_resolution_exception(class_name, throw_error, CHECK_NULL);
>> 269: }
>
> I find the logic for this very confusing. If klass == NULL then isn't it the case that there must be a pending exception?
> Also, looking inside handle_resolution_exception, if the pending exception is not a ClassNotFoundException then we completely ignore it and throw either ClassNotFoundException or NoClassDefFoundError. I would have expected to at least chain the original exception.
No, a klass can be NULL if load_instance_class returns NULL in a user-defined class loader.
ClassLoader.loadClass() can return NULL.
// Class is not found or has the wrong name, return NULL
return NULL;
There's also a NULL return from the bootclasspath.
For instance when loading sun/launcher/resources/spi/launcherProvider, this package isn't yet in the bootloader's list of packages, so there's a NULL return from load_instance_class, which is returned by resolve_instance_class_or_null.
It is sort of confusing that resolve_instance_class_or_null can return an exception OR null. if it returns an exception, the exception and throw_error is true, the exception is wrapped in the NoClassDefFoundError. It's in the JVMS 5.3:
If the Java Virtual Machine ever attempts to load a class C during verification (§5.4.1) or resolution (§5.4.3) (but not initialization (§5.5)), and the class loader that is used to initiate loading of C throws an instance of ClassNotFoundException, then the Java Virtual Machine must throw an instance of NoClassDefFoundError whose cause is the instance of ClassNotFoundException.
We don't ignore the exception if it's not ClassNotFoundException, we don't clear the exception so it's returned by handle_resolution_exception.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2247
More information about the hotspot-runtime-dev
mailing list