JDK-8265091 : Use Module API to export JVMCI packages at runtime
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2021-04-12
  • Updated: 2021-06-29
  • Resolved: 2021-06-29
Related Reports
Relates :  
Relates :  
Description
JDK-8264806 (Remove Graal from JDK) changes did not remove two Graal-related module-info.java files so that the JVMCI module (jdk.internal.vm.ci, JEP 243) continues to build:
src/jdk.internal.vm.compiler/share/classes/module-info.java
src/jdk.internal.vm.compiler.management/share/classes/module-info.java

Alan Bateman suggested that we can remove these files by using Module API to export packages at runtime. It requires changes in GraalVM's upstream JVMCI too so this followup RFE is filed.
Comments
I am closing this RFE. Based on JDK-8267112 we need to keep these files. Note, exports in module-info.java files were significantly reduced.
29-06-2021

[~alanb] What do you think about Doug's proposal? For me it seems reasonable.
02-05-2021

As far as I can see, the jdk.internal.vm.compiler and jdk.internal.vm.compiler.management modules must be preserved as empty and upgradeable modules to allow for an external implementation to be used (via --upgrade-module-path or jlinking a new image). Like this: https://github.com/dougxc/jdk/commit/4af230896090b55e33daf1aef94cc5e1a32207e2 https://github.com/dougxc/jdk/commit/4af230896090b55e33daf1aef94cc5e1a32207e2.patch
02-05-2021

The above error is due to HotSpotGraalJVMCIServiceLocator providing an implementation of the JVMCIServiceLocator service[1]. This is required for JVMCI to find Graal and use it as the JVMCI compiler. JVMCI then opens[2] the rest of its packages to Graal. So if these exports are removed from src/jdk.internal.vm.ci/share/classes/module-info.java, it will be impossible to use a standard JDK binary with Graal as far as I understand. [1] https://github.com/oracle/graal/blob/89e4cfc7aeea69970b60c64cd075ceb2a104e864/compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalJVMCIServiceLocator.java#L34-L35 [2] https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java#L121
01-05-2021

[~dnsimon] Here is draft PR: https://github.com/openjdk/jdk/pull/3728
27-04-2021

I tried to build fresh Graal locally with `mx build` and JAVA_HOME pointing to locally built JDK16u with JVMCI module-info.java modified as I suggested. I got next error: Error: Module jdk.internal.vm.compiler does not read a module that exports jdk.vm.ci.services The message is from java/lang/module/Resolver.java but I don't see call stack - only this one line.
27-04-2021

I suggest you put up the PR for the change and I can test it locally in the GraalVM build process.
27-04-2021

Note, JVMCI already opens all its packages to Graal by using Module API: https://github.com/openjdk/jdk/blob/master/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java#L140 The issue is how GraalVM builds Graal JIT compiler. Can it still be built if I remove all `exports` from JVMCI's module-info.java (link in previous comment)? I did local experiments and I was not able (obviously) to build Graal module in JDK with this change. [~dnsimon] Is it safe (for GraalVM) to modify JVMCI's module-info.java in JDK after we remove Graal? Does building Graal compiler (Java and libgraal) in GraalVM depend on these files? Or your `mx` script builds Graal jar and does not need module-info.java files in JDK?
27-04-2021

JVMCI module-info.java: https://github.com/openjdk/jdk/blob/master/src/jdk.internal.vm.ci/share/classes/module-info.java
12-04-2021