< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java

Print this page

        

@@ -170,10 +170,11 @@
         SystemModules systemModules = null;
         ModuleFinder systemModuleFinder;
 
         boolean haveModulePath = (appModulePath != null || upgradeModulePath != null);
         boolean needResolution = true;
+        boolean canArchive = false;
 
         // If the java heap was archived at CDS dump time and the environment
         // at dump time matches the current environment then use the archived
         // system modules and finder.
         ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule);

@@ -184,11 +185,10 @@
                 && !isPatched) {
             systemModules = archivedModuleGraph.systemModules();
             systemModuleFinder = archivedModuleGraph.finder();
             needResolution = (traceOutput != null);
         } else {
-            boolean canArchive = false;
             if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) {
                 systemModules = SystemModuleFinders.systemModules(mainModule);
                 if (systemModules != null && !isPatched) {
                     needResolution = (traceOutput != null);
                     canArchive = true;

@@ -204,16 +204,10 @@
             } else {
                 // exploded build or testing
                 systemModules = new ExplodedSystemModules();
                 systemModuleFinder = SystemModuleFinders.ofSystem();
             }
-
-            // Module graph can be archived at CDS dump time. Only allow the
-            // unnamed module case for now.
-            if (canArchive && (mainModule == null)) {
-                ArchivedModuleGraph.archive(mainModule, systemModules, systemModuleFinder);
-            }
         }
 
         Counters.add("jdk.module.boot.1.systemModulesTime", t1);
 
 

@@ -351,13 +345,17 @@
 
         Configuration cf;
         if (needResolution) {
             cf = JLMA.resolveAndBind(finder, roots, traceOutput);
         } else {
+            if (archivedModuleGraph != null) {
+                cf = archivedModuleGraph.configuration();
+            } else {
             Map<String, Set<String>> map = systemModules.moduleReads();
             cf = JLMA.newConfiguration(systemModuleFinder, map);
         }
+        }
 
         // check that modules specified to --patch-module are resolved
         if (isPatched) {
             patcher.patchedModules()
                     .stream()

@@ -434,10 +432,17 @@
             unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
             if (savedModuleFinder != finder)
                 limitedFinder = new SafeModuleFinder(finder);
         }
 
+        // Module graph can be archived at CDS dump time. Only allow the
+        // unnamed module case for now.
+        if (canArchive && (mainModule == null)) {
+            ArchivedModuleGraph.archive(mainModule, systemModules,
+                                        systemModuleFinder, cf);
+        }
+
         // total time to initialize
         Counters.add("jdk.module.boot.totalTime", t0);
         Counters.publish();
 
         return bootLayer;
< prev index next >