RFR: 8350550: Preload classes from AOT cache during VM bootstrap [v7]
Ashutosh Mehra
asmehra at openjdk.org
Wed Sep 10 14:52:31 UTC 2025
On Wed, 10 Sep 2025 04:16:03 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> This PR loads the classes for the boot/platform/app loaders with `AOTLinkedClassBulkLoader::preload_classes()`. This happens at the very beginning of `vmClasses::resolve_all()`, before any Java code is executed.
>>
>> - We essentially iterate over all the classes inside the `AOTLinkedClassTable` and adds them into the system dictionary using the new method `SystemDictionary::preload_class()`.
>> - `SystemDictionary::preload_class(..., k)` is lightweight because it's called in a single thread after all super types of `k` have been loaded. So most of the complicated work (such as place holders, circularity detection, etc) in `SystemDictionary::resolve_or_null(..., k)` can be skipped. We also don't need to call into `ClassLoader::load_class()` as the boot/platform/app loaders are well-behaved.
>> - In the assembly phase, we record the mirror, package, protection domain, code source, etc, of these classes. So there's no need to programmatically create them in the production run. See `HeapShared::copy_java_mirror()` and also changes in ClassLoader.java and SecureClassLoader.java.
>
> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits:
>
> - @ashu-mehra review comments
> - Merge branch 'master' into 8350550-preload-aot-classes-during-vm-bootstrap
> - Merge branch 'master' into 8350550-preload-aot-classes-during-vm-bootstrap
> - @DanHeidinga comments -- added comments and asserts about the handling of enums
> - @DanHeidinga comment - add test: user enum types are not initialized in assembly phase
> - @DanHeidinga comment -- assembly phase should check if URLStreamHandler might be overridden in the production run
> - @DanHeidinga comments
> - tightened SystemDictionary::preload_class()
> - Fixed bugs found in JCK
> - added entry in ProblemList-AotJdk.txt due to 8323727
> - ... and 12 more: https://git.openjdk.org/jdk/compare/8cd4e7d8...959a2c91
src/hotspot/share/cds/filemap.cpp line 1861:
> 1859: const char* archive_type = CDSConfig::type_of_archive_being_loaded();
> 1860: CDSConfig::set_has_aot_linked_classes(true);
> 1861: if (is_static()) {
`CDSConfig` is a global configuration, not specific to static or dynamic archive, and IIUC it is not possible to just load a dynamic archive, without loading a static archive. So it seems `is_static()` check is redundant here.
Continuing with this line of thought, it seems if `has_aot_linked_classes` is true then `is_using_preloaded_classes` will also be true. Then why do we even need this additional flag to indicate preloading of classes? This is going to be the default behavior when `has_aot_linked_classes` is true.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26375#discussion_r2337020552
More information about the core-libs-dev
mailing list