Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

For Project Terminus (#12236), we need to move from core reflection to JVMCI reflection. This pull request introduces JVMCI analogs for Java modules and packages to replace the direct use of java.lang.Module, java.lang.ModuleLayer, and java.lang.Package.

Key Changes:

  • Introduces interfaces: ResolvedJavaModule, ResolvedJavaModuleLayer, and ResolvedJavaPackage. Their current implementation is just a wrapper around the JDK classes. Once the surface of the interfaces is complete, we want to add an independent implementation, potentially in JVMCI.
  • Introduce HostModuleUtil for allowing hosted code (e.g., an internal Feature) to read a runtime module. This is only needed until we fully transitioned to Terminus, but until then, we want to mark such usages of the module system. See https://ol-bitbucket.us.oracle.com/projects/G/repos/graal/pull-requests/22534/overview?commentId=1330454 for discussion.

Refactoring:

  • Add JVMCIReflectionUtilFallback for implementing features of JVMCIReflectionUtil that still need core reflection due to missing features in JVMCI. Currently this is mainly for module/package lookups and origin/location queries. Having this separate allows us to keep JVMCIReflectionUtil clean and JVMCIReflectionUtilFallback serves as a list of action items we need to fix eventually.

Migrations:

  • Updated some of the current usages of Module and Package in features to use the new alternatives. (Mainly for distilling an initial list of methods that we need to support.)
  • Updates invocations across the codebase to use ResolvedJavaModuleLayer.boot().findModule(), replacing the direct use of ModuleLayer.boot().findModule(). Usually used to enable feature code based on module availability.
  • Use HostModuleUtil.addReads() instead of Module.addReads().

Additional Notes:

  • Reviewers are encouraged to review the names of all newly introduced classes (ResolvedJavaModule, HostModuleUtil, etc.).
  • Reviewing commit by commit is suggested.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 18, 2025
@graalvmbot graalvmbot merged commit 2c7c747 into master Nov 18, 2025
13 checks passed
@graalvmbot graalvmbot deleted the je/svm-jvmci-modules-packages-GR-71065 branch November 18, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants