RFR: 8263399: CDS should archive only classes allowed by module system [v2]
Calvin Cheung
ccheung at openjdk.java.net
Thu Mar 11 20:50:10 UTC 2021
On Thu, 11 Mar 2021 20:16:50 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> src/hotspot/share/memory/metaspaceShared.cpp line 703:
>>
>>> 701: // print a warning only when the pending exception is class not found
>>> 702: log_warning(cds)("Preload Warning: Cannot find %s", parser.current_class_name());
>>> 703: }
>>
>> It seems the other code path which would print the "Preload Warning: Cannot find..." message is as follows:
>> ClassLoaderExt::load_class(Symbol *, const char *, Thread *) : InstanceKlass *
>> ClassListParser::load_class_from_source(Symbol *, Thread *) : InstanceKlass *
>> ClassListParser::load_current_class(Thread *) : Klass *
>> MetaspaceShared::preload_classes(const char *, Thread *) : int
>> MetaspaceShared::preload_and_dump(Thread *) : void (2 matches)
>> which is for custom class loaders and your change in classListParser.cpp did not touch.
>>
>> Anyway, if the added condition is necessary, the comment should be adjusted to mention the condition.
>
> Hi Calvin, thanks for checking this. I traced the code and found out what happened:
>
> Before this patch, when loading an old class unsupported by CDS, `JavaCalls::call_virtual()` inside `ClassListParser::load_current_class()` will throw `java.lang.UnsupportedClassVersionError`. This exception is caught and discarded.
>
> The code will then call `SystemDictionary::resolve_or_null()`, which returns `NULL` because the class is not found inside the boot loader. At this point, `load_current_class()` throws `java_lang_ClassNotFoundException`. `MetaspaceShared::preload_and_dump()` sees this and prints the "Preload Warning: Cannot find..." message.
>
> After this patch, the `UnsupportedClassVersionError` is not caught anymore, so it will be seen inside `MetaspaceShared::preload_and_dump()`.
>
> I updated the comments to mention the condition. I also created a new RFE (https://bugs.openjdk.java.net/browse/JDK-8263469) to improve the warning messages.
Thanks for the explanations.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2929
More information about the hotspot-runtime-dev
mailing list