JDK-8345826 : Do not automatically resolve jdk.internal.vm.ci when libgraal is used
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23,24
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-12-09
  • Updated: 2025-06-21
  • Resolved: 2025-05-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b24Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
In JDK-8298099, we have decoupled libgraal from jdk.internal.vm.ci.

However, since JDK 23, with the Oracle JDK, you can enable libgraal with one of the following:

java  -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct ...
java  -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler ...

Both EnableJVMCIProduct and UseJVMCICompiler set EnableJVMCI to true:

https://github.com/openjdk/jdk/blob/cc628a133e471e7edf07831ff386f0eaf57e9bff/src/hotspot/share/jvmci/jvmci_globals.cpp#L65
https://github.com/openjdk/jdk/blob/cc628a133e471e7edf07831ff386f0eaf57e9bff/src/hotspot/share/jvmci/jvmci_globals.cpp#L89

This causes the following code to be executed in arguments.cpp to add the jdk.internal.vm.ci module.

  if (status && EnableJVMCI) {
    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;
      }
    }
  }

Since libgraal doesn't require the jdk.internal.vm.ci module, it should not be resolved implicitly when -XX:+UseGraalJIT is specified.

The primary motivation is to make use of libgraal compatible with -XX:+AOTClassLinking. The latter relies on an archive of the root module set created in a separate JVM execution. If the root module set is different than what's in the archive at runtime, the AOTClassLinking optimizations are disabled. As jdk.internal.vm.ci is not resolved when creating the archive, it must not be resolved in the runtime using the archive. As such, -XX:+EnableJVMCI must not cause resolution of jdk.internal.vm.ci for libgraal to have the startup advantages of AOTClassLinking.

Basically the ability to use JVMCI should be decoupled from the resolution of the JVMCI module.
Comments
Graal PR: https://github.com/oracle/graal/pull/11239
21-05-2025

Changeset: 81536830 Branch: master Author: Doug Simon <dnsimon@openjdk.org> Date: 2025-05-21 19:21:20 +0000 URL: https://git.openjdk.org/jdk/commit/81536830ed096005c4f09ab446238ce50989cea9
21-05-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25240 Date: 2025-05-14 22:00:30 +0000
15-05-2025

In offline discussion between Ioi and the Graal compiler team, we think it makes sense to remove all use of EnableJVMCI in the VM code. This will mean -XX:+EnableJVMCI only applies to the Java code (i.e. jdk.internal.vm.ci). https://github.com/openjdk/jdk/pull/23408
25-04-2025

Given the implications of adding a new flag (e.g. EnableNativeJVMCI) or requiring Truffle users to explicitly use an additional option (i.e. `--add-modules=jdk.internal.vm.ci`) are non-trivial, I don't think anything should be done until some determination is made about JDK-8345969. Until then, we should make sure future AOTCache changes don't break libgraal tests.
12-12-2024

As seen in comments in JDK-8345969, we are not yet sure whether to go forward with it. I still think the current issue should be fixed, as we shouldn't be adding jdk.internal.vm.ci when it's not actually required.
12-12-2024

[~chumer] made the interesting suggestion of introducing a -XX:+EnableNativeJVMCI flag which will only enable the JVMCI support in the VM (i.e. the C++ JVMCI code). This flag would be implicitly enabled by -XX:+UseGraalJIT instead of -XX:+EnableJVMCI. This mean the latter can remain with its current semantics. However, I'm not sure it's worth pursuing this path given JDK-8345969. After all, wouldn't we expect use of CDS to be the common case? Or does using CDS always require explicit opt-in via some flag(s)?
11-12-2024

Doug, this is being considered: JDK-8345969 AOTCache should always include internal modules required for optional JVM features (Note that AOTCache is just "rebranding" of CDS) Anyway, I think it's worth fixing the current issue as well, so that when CDS is *not* used, we add jdk.internal.vm.ci only when it's necessary (i.e., when using a JVMCI implementation that actually requires this module).
11-12-2024

Ioi, what are the pros/cons of always including jdk.internal.vm.ci in the archived module graph. That seems like another way to solve this problem.
10-12-2024