JDK-8338747 : hasIncubatorModules needs to be generated when module resolution required at startup
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.module
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-08-21
  • Updated: 2024-09-23
  • Resolved: 2024-09-12
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 24
24 b16Fixed
Related Reports
Blocks :  
Description
See
https://github.com/openjdk/jdk/blob/918cf114548d0098cf6a8a50032b78ee04d453db/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java#L248

With this patch:

diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
index b97b0a2de40..55dccf03c1c 100644
--- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
@@ -246,6 +246,9 @@ private static ModuleLayer boot2() {
 
             hasSplitPackages = systemModules.hasSplitPackages();
             hasIncubatorModules = systemModules.hasIncubatorModules();
+            if (System.getProperty("debug") != null) {
+                System.out.println("hasIncubatorModules = " + hasIncubatorModules);
+            }
             // not using the archived module graph - avoid accidental use
             archivedModuleGraph = null;
         }


$ java -Xshare:off -Ddebug=1 --version
hasIncubatorModules = false
[...]

$ rm -rf empty
$ mkdir empty
$ tava -Xshare:off -Ddebug=1 -p empty --version
hasIncubatorModules = true
[...]
Comments
Changeset: 1b17e0b1 Branch: master Author: Alan Bateman <alanb@openjdk.org> Date: 2024-09-12 08:48:17 +0000 URL: https://git.openjdk.org/jdk/commit/1b17e0b133cab44029333c832bd046b338ede581
12-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20818 Date: 2024-09-02 12:27:21 +0000
10-09-2024

Just a quick summary on this. The value of hasIncubatorModules is true in the SystemModules class generated for "all modules" as it includes the jdk.incubator.vector API. The issue that the CDS changes are running into is when the CLI options require resolution to run at startup, this scenario needs to generate values for hasSplitPackages or hasIncubatorModules . The CDS work to add support for module path will need to know if there are incubator modules in the generated graph. (I've changed the title on this JBS to make it clearer what this issue is about)
02-09-2024

Discussed briefly with Ioi and Calvin as JVMLS. I'll write up a summary on what this is about.
21-08-2024

This bug blocks JDK-8328313: if --module-path has been set, it causes hasIncubatorModules to be always true, blocking the CDS archival of the full module graph: https://github.com/openjdk/jdk/blob/918cf114548d0098cf6a8a50032b78ee04d453db/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java#L496 if (!hasSplitPackages && !hasIncubatorModules) { ArchivedBootLayer.archive(bootLayer); }
21-08-2024