RFR: 8338747: hasIncubatorModules needs to be generated when module resolution required at startup

Ioi Lam iklam at openjdk.org
Wed Sep 11 19:09:04 UTC 2024


On Mon, 2 Sep 2024 12:27:21 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> This PR proposes changes to the ModuleBootstrap code that is used with CDS (Ahead-of-Time Class Loading & Linking in the future). At things stand, the module graph and boot layer can be archived at dump time (-Xshare:dump) when the initial module is the class path or the initial module is in the run-time image. Future work will extend this to deployments with an application module path or where additional root modules are specified with --add-modules. To get there we need the code that determines whether to archive is in one place, and it needs to know if the module graph contains incubator modules or split packages. 
> 
> Testing: tier1-tier6. There are no new tests, the changes don't expand or change what can be archived. Calvin has done some some testing with the change as it is needed for [JDK-8328313](https://bugs.openjdk.org/browse/JDK-8328313).

I can confirm that the problem reported in the bug has been fixed. I added the following prints:


        // Step 8: CDS dump phase

+       if (CDS.isDumpingStaticArchive()) {
+           boolean hasSplitPackages = containsSplitPackages(cf);
+           boolean hasIncubatorModules = containsIncubatorModule(cf);
+           System.out.println("hasSplitPackages    = " + hasSplitPackages);
+           System.out.println("hasIncubatorModules = " + hasIncubatorModules);
+       }

        if (CDS.isDumpingStaticArchive() && !haveModulePath && addModules.isEmpty()) {
            assert !isPatched;
=====
$ ls -l d
-rw-rw-r-- 1 iklam iklam 1349 Jul 26 15:31 com.greetings.jar
-rw-rw-r-- 1 iklam iklam 1136 Jul 26 15:31 org.astro.jar
$ java -p d -m com.greetings
Greetings world!
$ java -Xshare:dump -XX:SharedArchiveFile=hw.jsa --module-path=d
hasSplitPackages    = false
hasIncubatorModules = false


`hasIncubatorModules` was `true` in the bug report, but with the patch, both of these two values are `false`. This fix will unblock the following code when Calvin adds support for `--module-path` for the archived FMG.


        if (!hasSplitPackages && !hasIncubatorModules) {
            ArchivedBootLayer.archive(bootLayer);
        }

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20818#issuecomment-2344470480


More information about the core-libs-dev mailing list