When the -XX:+EnableJVMCI flag is specified, the JVM should automatically load the jdk.internal.vm.ci module
$ java --version
java 24 2025-03-18
Java(TM) SE Runtime Environment (build 24+36-3646)
Java HotSpot(TM) 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load --version | egrep '(jdk.internal.vm.ci)|(java.base)'
[0.013s][info][module,load] java.base location: jrt:/java.base
[0.022s][info][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
However, when running with -XX:AOTMode=create, this module is NOT added:
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig HelloWorld | egrep '(jdk.internal.vm.ci)|(java.base)'
[0.021s][info][module,load] java.base location: jrt:/java.base
[0.040s][info][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=create -Xlog:cds -XX:AOTCache=hw.aot -XX:AOTConfiguration=hw.aotconfig | egrep '(jdk.internal.vm.ci)|(java.base)'
Java HotSpot(TM) 64-Bit Server VM warning: JVMCI Compiler disabled due to -Xint.
[0.027s][info][module,load] java.base location: jrt:/java.base
As a result, the set of modules recorded in the AOT cache is different than what expected, and the AOT cache cannot be used:
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=auto -Xlog:cds -XX:AOTCache=hw.aot HelloWorld | egrep '(jdk.internal.vm.ci)|(java.base)|(linked)'
[0.006s][info][cds] Mismatched values for property jdk.module.addmods: jdk.internal.vm.ci specified during runtime but not during dump time
[0.006s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
[0.031s][info ][module,load] java.base location: jrt:/java.base
[0.054s][info ][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
=====================
Cause:
-XX:AOTMode=create needs to run with -Xint, but this has the effect of disabling the JIT, which has the side effect of setting EnableJVMCI to false.
https://github.com/openjdk/jdk/blob/1501a5e41e59162a374cf5b8cfc37faced48a6ed/src/hotspot/share/cds/cdsConfig.cpp#L526-L531
=====================
Proposed fix:
Around here:
https://github.com/openjdk/jdk/blob/1501a5e41e59162a374cf5b8cfc37faced48a6ed/src/hotspot/share/runtime/arguments.cpp#L1800-L1807
- if (status && EnableJVMCI) {
+ if (status && (EnableJVMCI || (EnableJVMCI was enabled before calling CDSConfig::check_vm_args_consistency()))) {
PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true",
AddProperty, UnwriteableProperty, InternalProperty);
if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) {
if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) {
return false;
}
}
}
$ java --version
java 24 2025-03-18
Java(TM) SE Runtime Environment (build 24+36-3646)
Java HotSpot(TM) 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load --version | egrep '(jdk.internal.vm.ci)|(java.base)'
[0.013s][info][module,load] java.base location: jrt:/java.base
[0.022s][info][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
However, when running with -XX:AOTMode=create, this module is NOT added:
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig HelloWorld | egrep '(jdk.internal.vm.ci)|(java.base)'
[0.021s][info][module,load] java.base location: jrt:/java.base
[0.040s][info][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=create -Xlog:cds -XX:AOTCache=hw.aot -XX:AOTConfiguration=hw.aotconfig | egrep '(jdk.internal.vm.ci)|(java.base)'
Java HotSpot(TM) 64-Bit Server VM warning: JVMCI Compiler disabled due to -Xint.
[0.027s][info][module,load] java.base location: jrt:/java.base
As a result, the set of modules recorded in the AOT cache is different than what expected, and the AOT cache cannot be used:
$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xlog:module+load -cp HelloWorld.jar -XX:AOTMode=auto -Xlog:cds -XX:AOTCache=hw.aot HelloWorld | egrep '(jdk.internal.vm.ci)|(java.base)|(linked)'
[0.006s][info][cds] Mismatched values for property jdk.module.addmods: jdk.internal.vm.ci specified during runtime but not during dump time
[0.006s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
[0.031s][info ][module,load] java.base location: jrt:/java.base
[0.054s][info ][module,load] jdk.internal.vm.ci location: jrt:/jdk.internal.vm.ci
=====================
Cause:
-XX:AOTMode=create needs to run with -Xint, but this has the effect of disabling the JIT, which has the side effect of setting EnableJVMCI to false.
https://github.com/openjdk/jdk/blob/1501a5e41e59162a374cf5b8cfc37faced48a6ed/src/hotspot/share/cds/cdsConfig.cpp#L526-L531
=====================
Proposed fix:
Around here:
https://github.com/openjdk/jdk/blob/1501a5e41e59162a374cf5b8cfc37faced48a6ed/src/hotspot/share/runtime/arguments.cpp#L1800-L1807
- if (status && EnableJVMCI) {
+ if (status && (EnableJVMCI || (EnableJVMCI was enabled before calling CDSConfig::check_vm_args_consistency()))) {
PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true",
AddProperty, UnwriteableProperty, InternalProperty);
if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) {
if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) {
return false;
}
}
}