--- old/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2018-07-20 13:34:21.025698232 -0400 +++ new/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2018-07-20 13:34:19.665619154 -0400 @@ -172,6 +172,7 @@ 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 @@ -186,12 +187,11 @@ 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; + canArchive = true; } } if (systemModules == null) { @@ -206,12 +206,6 @@ 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); @@ -353,8 +347,12 @@ if (needResolution) { cf = JLMA.resolveAndBind(finder, roots, traceOutput); } else { - Map> map = systemModules.moduleReads(); - cf = JLMA.newConfiguration(systemModuleFinder, map); + if (archivedModuleGraph != null) { + cf = archivedModuleGraph.configuration(); + } else { + Map> map = systemModules.moduleReads(); + cf = JLMA.newConfiguration(systemModuleFinder, map); + } } // check that modules specified to --patch-module are resolved @@ -436,6 +434,13 @@ 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();