RFR: 8367366: Do not support -XX:+AOTClassLinking for dynamic CDS archive [v2]
Ioi Lam
iklam at openjdk.org
Tue Sep 16 20:34:43 UTC 2025
On Tue, 16 Sep 2025 20:09:26 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:
>>> Here AOTClassLinking is set and checked in check_vm_args_consistency()
>> https://github.com/openjdk/leyden/blob/master/src/hotspot/share/cds/cdsConfig.cpp#L636
>>
>> Hmm, for convoluted cases like this, we will actually turn on AOTClassLinking ergomomically for dynamic dump
>>
>> java -XX:ArchiveClassesAtExit=foo.jsa -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
>>
>>
>> I've removed the assert and print the warning only if `FLAG_IS_CMDLINE(AOTClassLinking)`
>
> @iklam
>> java -XX:ArchiveClassesAtExit=foo.jsa -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
>
> What would this command do? Generate `hw.aot` or `foo.jsa`? I think this is, as you said, a convoluted case and it is best to not allow the user to mix the two workflows.
Here's a more elaborate example. It works today as `base.aot` is essentially a static CDS archive.
$ java -XX:AOTCacheOutput=base.aot --version
$ java -cp HelloWorld.jar -XX:AOTCache=base.aot -XX:ArchiveClassesAtExit=dyn.jsa HelloWorld
$ java -Xlog:cds -cp HelloWorld.jar -XX:SharedArchiveFile=dyn.jsa HelloWorld
...
[0.003s][info][cds] Opened shared archive file base.aot.
...
[0.003s][info][cds] Opened shared archive file dyn.jsa.
...
Hello World
I agree that we should disallow this combination. In JEP 483 we explicitly disallowed mixing `-XX:AOTxxx` with classical CDS flags such as `-XX:SharedArchiveFile`. We should have also disallowed `-XX:ArchiveClassesAtExit` and other flags used by the dynamic archive.
This will simplify AOT implementation and also will avoid future incompatibility -- there's no guarantee that the above would work when more optimizations are added to AOT.
Maybe I should do it in a follow-up PR? I want to make this PR simple in order to unblock #26375
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27242#discussion_r2353589244
More information about the hotspot-dev
mailing list