RFR: 8263399: CDS should archive only classes allowed by module system
Calvin Cheung
ccheung at openjdk.java.net
Thu Mar 11 02:35:08 UTC 2021
On Thu, 11 Mar 2021 01:08:16 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> `ClassListParser::load_current_class()` tries to archive a boot class from `-Xbootclasspath/a` into the unnamed package, even if the module system forbids this class from being defined in the unnamed package.
>
> Such classes, even if archived, won't be usable at runtime anyway. The only test case affected by this code is test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java, which asserts that such class must be archived, but also asserts that such archived classes cannot be used at runtime. So the first assert seems unnecessary and should be removed.
>
> The main change is in classListParser.cpp.
>
> The change in metaspaceShared.cpp is necessary because the `Preload Warning: Cannot find %s"` message was sometimes printed only in the code path that I've deleted.
Looks good. I've one comment below...
thanks,
Calvin
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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2929
More information about the hotspot-runtime-dev
mailing list