On Fri, 19 Sep 2025 02:10:15 GMT, Ioi Lam <[email protected]> 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` (also the 
>> object hierarchy root class, `Object.class`, which has no associated AOT 
>> initialization but is required for completeness). 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 `@AOTSafeClassInitializer`, 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 with a new target base due to a merge or 
> a rebase. The pull request now contains 23 commits:
> 
>  - Updated requirements for annotations on supertypes for AOTInitialize and 
> AOTSafeClassInitializer
>  - Merge branch 'master' into aot-initialize-math-utils
>  - Added logging about @AOTSafeClassInitializer classes that have not been 
> initialized
>  - Added comment about the order of FinalImageRecipes::apply_recipes() vs 
> link_all_loaded_classes()
>  - Exclude more GC heap size tests as AOT cache size has increased for "make 
> test JTREG=AOT_JDK=onestep ..."
>  - Added javadoc; added test case; code clean up
>  - Merge branch 'master' into aot-initialize-math-utils
>  - cleanup
>  - Merge branch 'master' into aot-initialize-math-utils
>  - Merge branch '8366477-refactor-aot-related-flag-bits-in-klass-hpp' into 
> aot-initialize-math-utils
>  - ... and 13 more: https://git.openjdk.org/jdk/compare/7ec3fa5f...d21bfb12

src/hotspot/share/cds/aotMetaspace.cpp line 1266:

> 1264:     if (HAS_PENDING_EXCEPTION) {
> 1265:       ResourceMark rm;
> 1266:       log_error(aot, init)("class %s has @AOTForceInitialize but failed 
> to initialize",

Suggestion:

      log_error(aot, init)("class %s has @AOTInitialize but failed to 
initialize",

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27024#discussion_r2363651802

Reply via email to