RFR: 8267189: Remove duplicated unregistered classes from dynamic archive
Calvin Cheung
ccheung at openjdk.java.net
Thu Jun 17 20:32:30 UTC 2021
On Thu, 17 Jun 2021 04:03:09 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> In the CDS archive, "unregistered" classes are those to be loaded by custom loaders.
>
> When doing a CDS dynamic dump (with -XX:ArchiveClassesAtExit=foo.jsa), a class of the same name may be loaded by several custom class loaders. Currently we write all of these unregistered classes into the archive. However, only one copy of them will be usable at runtime.
>
> For size saving, we should avoid writing such duplicated classes into the archive.
>
> (Note that this problem does not affect the CDS static dump, which is driven by a classlist file. We already disallow duplicate unregistered classes in the classlist.)
>
> Testing: mach5 tiers 1-4. Also tested locally with Eclipse IDE.
Looks good. Just some minor suggestions.
src/hotspot/share/classfile/systemDictionaryShared.cpp line 1321:
> 1319: MutexLocker ml(Thread::current(), UnregisteredClassesTable_lock);
> 1320: Symbol* name = klass->name();
> 1321: InstanceKlass** v = _unregistered_classes_table->get(name);
`name` is used only once. Maybe just pass `klass->name()` to `get()`?
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DuplicatedCustomTest.java line 88:
> 86: .assertNormalExit(output -> {
> 87: output.shouldContain("DuplicatedCustomApp source: shared objects file")
> 88: .shouldContain("CustomLoadee source: shared objects file")
Since the classes will be loaded from dynamic CDS archive. Maybe add " (top)" to the end of the strings?
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/DuplicatedCustomApp.java line 88:
> 86: System.out.println("Loader = " + c.getClassLoader());
> 87:
> 88: // [1] Check that CustomLoadee is defined by the correct loader
The comment may not be accurate since different classes are being passed into this method.
Perhaps change it to the following?
// Check that the loaded class is defined by the correct loader
-------------
Changes requested by ccheung (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/4515
More information about the hotspot-runtime-dev
mailing list