RFR: 8367387: Add @AOTInitialize annotation [v2]
Andrew Dinn
adinn at openjdk.org
Tue Sep 16 09:28:24 UTC 2025
On Mon, 15 Sep 2025 23:20:47 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> This PR adds a new annotation, `@AOTInitialize` that forces a class to be (a) initialized in the AOT assembly phase, and (b) stored in the AOT cache in an already initialized state. This means that all the static fields in this class will be immediately available upon JVM bootstrap when the AOT cache is used in an application's production run.
>>
>> This PR annotates a single class, `jdk.internal.math.MathUtils`. More classes will be added in future PRs.
>>
>> If a class `K` has the `@AOTInitialize` annotation, the same annotation must be also added to
>> - All of `K`'s super classes
>> - All of `K`'s super interfaces that require to be initialized when `K` is initialized (see JVMS 5.5. Initialization, step 7; also C++ function `InstanceKlass::interface_needs_clinit_execution_as_super()`
>>
>> Note, the check of the above requirement has been moved to `AOTClassInitializer::check_aot_annotations()`. The previous check in `ClassFileParser` was not executed because the class is loaded in the AOT training run, where `CDSConfig::is_initing_classes_at_dump_time()` returns `false` (this function returns `true` only in the AOT assembly phase).
>>
>> This annotation is awfully similar to `@AOTSafeAnnotation`, and I am not sure if we need both. Please see the javadoc in `@AOTInitialize` to see the difference between the two annotations.
>
> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>
> Exclude more GC heap size tests as AOT cache size has increased for "make test JTREG=AOT_JDK=onestep ..."
src/hotspot/share/cds/aotMetaspace.cpp line 806:
> 804: AOTClassInitializer::init_test_class(CHECK);
> 805:
> 806: if (CDSConfig::is_dumping_final_static_archive()) {
What is the reason for moving this earlier to before link_all_loaded_classes?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27024#discussion_r2351659530
More information about the core-libs-dev
mailing list