< prev index next >

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

Print this page
rev 52800 : 8214858: Improve module graph archiving
Reviewed-by: alanb

*** 170,191 **** 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); if (archivedModuleGraph != null && !haveModulePath && addModules.isEmpty() && limitModules.isEmpty() && !isPatched) { - systemModules = archivedModuleGraph.systemModules(); systemModuleFinder = archivedModuleGraph.finder(); needResolution = (traceOutput != null); } else { if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) { systemModules = SystemModuleFinders.systemModules(mainModule); if (systemModules != null && !isPatched) { --- 170,194 ---- ModuleFinder systemModuleFinder; boolean haveModulePath = (appModulePath != null || upgradeModulePath != null); boolean needResolution = true; boolean canArchive = false; + boolean hasSplitPackages; + boolean hasIncubatorModules; // 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); if (archivedModuleGraph != null && !haveModulePath && addModules.isEmpty() && limitModules.isEmpty() && !isPatched) { systemModuleFinder = archivedModuleGraph.finder(); + hasSplitPackages = archivedModuleGraph.hasSplitPackages(); + hasIncubatorModules = archivedModuleGraph.hasIncubatorModules(); needResolution = (traceOutput != null); } else { if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) { systemModules = SystemModuleFinders.systemModules(mainModule); if (systemModules != null && !isPatched) {
*** 203,212 **** --- 206,220 ---- } else { // exploded build or testing systemModules = new ExplodedSystemModules(); systemModuleFinder = SystemModuleFinders.ofSystem(); } + + hasSplitPackages = systemModules.hasSplitPackages(); + hasIncubatorModules = systemModules.hasIncubatorModules(); + // not using the archived module graph - avoid accidental use + archivedModuleGraph = null; } Counters.add("jdk.module.boot.1.systemModulesTime", t1);
*** 393,403 **** } } } // check for split packages in the modules mapped to the built-in loaders ! if (systemModules.hasSplitPackages() || isPatched || haveModulePath) { checkSplitPackages(cf, clf); } // load/register the modules with the built-in class loaders loadModules(cf, clf); --- 401,411 ---- } } } // check for split packages in the modules mapped to the built-in loaders ! if (hasSplitPackages || isPatched || haveModulePath) { checkSplitPackages(cf, clf); } // load/register the modules with the built-in class loaders loadModules(cf, clf);
*** 413,431 **** // Step 7: Miscellaneous // check incubating status ! if (systemModules.hasIncubatorModules() || haveModulePath) { checkIncubatingStatus(cf); } // --add-reads, --add-exports/--add-opens, and --illegal-access long t7 = System.nanoTime(); addExtraReads(bootLayer); boolean extraExportsOrOpens = addExtraExportsAndOpens(bootLayer); ! addIllegalAccess(upgradeModulePath, systemModules, bootLayer, extraExportsOrOpens); Counters.add("jdk.module.boot.7.adjustModulesTime", t7); // save module finders for later use if (savedModuleFinder != null) { unlimitedFinder = new SafeModuleFinder(savedModuleFinder); --- 421,453 ---- // Step 7: Miscellaneous // check incubating status ! if (hasIncubatorModules || haveModulePath) { checkIncubatingStatus(cf); } // --add-reads, --add-exports/--add-opens, and --illegal-access long t7 = System.nanoTime(); addExtraReads(bootLayer); boolean extraExportsOrOpens = addExtraExportsAndOpens(bootLayer); ! ! Map<String, Set<String>> concealedPackagesToOpen; ! Map<String, Set<String>> exportedPackagesToOpen; ! if (archivedModuleGraph != null) { ! concealedPackagesToOpen = archivedModuleGraph.concealedPackagesToOpen(); ! exportedPackagesToOpen = archivedModuleGraph.exportedPackagesToOpen(); ! } else { ! concealedPackagesToOpen = systemModules.concealedPackagesToOpen(); ! exportedPackagesToOpen = systemModules.exportedPackagesToOpen(); ! } ! addIllegalAccess(upgradeModulePath, ! concealedPackagesToOpen, ! exportedPackagesToOpen, ! bootLayer, ! extraExportsOrOpens); Counters.add("jdk.module.boot.7.adjustModulesTime", t7); // save module finders for later use if (savedModuleFinder != null) { unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
*** 434,445 **** } // 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(); --- 456,472 ---- } // Module graph can be archived at CDS dump time. Only allow the // unnamed module case for now. if (canArchive && (mainModule == null)) { ! ArchivedModuleGraph.archive(mainModule, ! hasSplitPackages, ! hasIncubatorModules, ! systemModuleFinder, ! cf, ! concealedPackagesToOpen, ! exportedPackagesToOpen); } // total time to initialize Counters.add("jdk.module.boot.totalTime", t0); Counters.publish();
*** 736,746 **** /** * Process the --illegal-access option (and its default) to open packages * of system modules in the boot layer to code in unnamed modules. */ private static void addIllegalAccess(ModuleFinder upgradeModulePath, ! SystemModules systemModules, ModuleLayer bootLayer, boolean extraExportsOrOpens) { String value = getAndRemoveProperty("jdk.module.illegalAccess"); IllegalAccessLogger.Mode mode = IllegalAccessLogger.Mode.ONESHOT; if (value != null) { --- 763,774 ---- /** * Process the --illegal-access option (and its default) to open packages * of system modules in the boot layer to code in unnamed modules. */ private static void addIllegalAccess(ModuleFinder upgradeModulePath, ! Map<String, Set<String>> concealedPackagesToOpen, ! Map<String, Set<String>> exportedPackagesToOpen, ModuleLayer bootLayer, boolean extraExportsOrOpens) { String value = getAndRemoveProperty("jdk.module.illegalAccess"); IllegalAccessLogger.Mode mode = IllegalAccessLogger.Mode.ONESHOT; if (value != null) {
*** 762,778 **** } } IllegalAccessLogger.Builder builder = new IllegalAccessLogger.Builder(mode, System.err); ! Map<String, Set<String>> map1 = systemModules.concealedPackagesToOpen(); ! Map<String, Set<String>> map2 = systemModules.exportedPackagesToOpen(); ! if (map1.isEmpty() && map2.isEmpty()) { // need to generate (exploded build) IllegalAccessMaps maps = IllegalAccessMaps.generate(limitedFinder()); ! map1 = maps.concealedPackagesToOpen(); ! map2 = maps.exportedPackagesToOpen(); } // open specific packages in the system modules for (Module m : bootLayer.modules()) { ModuleDescriptor descriptor = m.getDescriptor(); --- 790,804 ---- } } IllegalAccessLogger.Builder builder = new IllegalAccessLogger.Builder(mode, System.err); ! if (concealedPackagesToOpen.isEmpty() && exportedPackagesToOpen.isEmpty()) { // need to generate (exploded build) IllegalAccessMaps maps = IllegalAccessMaps.generate(limitedFinder()); ! concealedPackagesToOpen = maps.concealedPackagesToOpen(); ! exportedPackagesToOpen = maps.exportedPackagesToOpen(); } // open specific packages in the system modules for (Module m : bootLayer.modules()) { ModuleDescriptor descriptor = m.getDescriptor();
*** 787,798 **** if (upgradeModulePath != null && upgradeModulePath.find(name).isPresent()) { continue; } ! Set<String> concealedPackages = map1.getOrDefault(name, Set.of()); ! Set<String> exportedPackages = map2.getOrDefault(name, Set.of()); // refresh the set of concealed and exported packages if needed if (extraExportsOrOpens) { concealedPackages = new HashSet<>(concealedPackages); exportedPackages = new HashSet<>(exportedPackages); --- 813,824 ---- if (upgradeModulePath != null && upgradeModulePath.find(name).isPresent()) { continue; } ! Set<String> concealedPackages = concealedPackagesToOpen.getOrDefault(name, Set.of()); ! Set<String> exportedPackages = exportedPackagesToOpen.getOrDefault(name, Set.of()); // refresh the set of concealed and exported packages if needed if (extraExportsOrOpens) { concealedPackages = new HashSet<>(concealedPackages); exportedPackages = new HashSet<>(exportedPackages);
< prev index next >