On Mon, 1 Jun 2026 21:58:42 GMT, Ioi Lam <[email protected]> wrote:
> Before this PR, you cannot use -XX:AOTCache in the training run:
>
>
> $ java -XX:AOTCache=foo.aot -cp HelloWorld.jar \
> -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig \
> HelloWorld
> [...] AOTCache must not be specified when using -XX:AOTMode=record
>
>
> However, in some cases, it may be desirable to train the AOT cache in two or
> more steps. For example:
>
> ## Separate Training for Framework and Application:
>
> - First perform a training run to exercise commonly-used areas of the
> framework.
> - Second, perform a training run of a specific application.
>
> The idea is that important parts of the framework may not be covered by a
> single application training run, but they may still be used in the production
> run due to runtime-specific input.
>
>
> # Train the framework
> java -XX:AOTCacheOutput=first.aot -cp FrameWork.jar FrameWorkTraningHelper
>
> # Train the app
> java -XX:AOTCache=first.aot -XX:AOTCacheOutput=second.aot -cp
> FrameWork.jar:App.jar MyApp
>
> # Production run using second.aot, which contains artifacts from
> # the first and second training runs
> java -XX:AOTCache=second.aot -cp FrameWork.jar:App.jar MyApp
>
> Note that the classpaths of the training runs must be compatible. I.e., the
> classpath of an earlier training run must be the same as, or the prefix of,
> the classpath of a later training run.
>
> ## Train the Same Application in Multiple Runs:
>
> An application may perform 3 different operations. It's not easy to perform
> all 3 operations in a single training run, as the 3 operations are
> represented by 3 separate main classes (`WalkDog`, `FeedCat`, and
> `WaterPlants`). So, we perform 3 separate training runs and combine the
> results into a single AOT cache.
>
>
> # Training
> java -XX:AOTCacheOutput=tmp1.aot -cp MyApp.jar WalkDog
> java -XX:AOTCache=tmp1.aot -XX:AOTCacheOutput=tmp2.aot -cp MyApp.jar FeedCat
> java -XX:AOTCache=tmp2.aot -XX:AOTCacheOutput=final.aot -cp MyApp.jar
> WaterPlants
>
> # Production: final.aot contains artifacts for optimizing all 3 operations:
> java -XX:AOTCache=final.aot -cp MyApp.jar WalkDog
> java -XX:AOTCache=final.aot -cp MyApp.jar FeedCat
> java -XX:AOTCache=final.aot -cp MyApp.jar WaterPlants
>
>
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK
> Interim AI Policy](https://openjdk.org/legal/ai).
src/hotspot/share/cds/aotMetaspace.cpp line 768:
> 766:
> 767: if (!CDSConfig::is_dumping_final_static_archive()) {
> 768: //guarantee(!CDSConfig::is_using_archive(), "We should not be using
> an archive when we dump");
Should this be removed?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31344#discussion_r3616622359