366 if (isPatched) {
367 patcher.patchedModules()
368 .stream()
369 .filter(mn -> !cf.findModule(mn).isPresent())
370 .forEach(mn -> warnUnknownModule(PATCH_MODULE, mn));
371 }
372
373 Counters.add("jdk.module.boot.4.resolveTime", t4);
374
375
376 // Step 5: Map the modules in the configuration to class loaders.
377 // The static configuration provides the mapping of standard and JDK
378 // modules to the boot and platform loaders. All other modules (JDK
379 // tool modules, and both explicit and automatic modules on the
380 // application module path) are defined to the application class
381 // loader.
382
383 long t5 = System.nanoTime();
384
385 // mapping of modules to class loaders
386 Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf);
387
388 // check that all modules to be mapped to the boot loader will be
389 // loaded from the runtime image
390 if (haveModulePath) {
391 for (ResolvedModule resolvedModule : cf.modules()) {
392 ModuleReference mref = resolvedModule.reference();
393 String name = mref.descriptor().name();
394 ClassLoader cl = clf.apply(name);
395 if (cl == null) {
396 if (upgradeModulePath != null
397 && upgradeModulePath.find(name).isPresent())
398 fail(name + ": cannot be loaded from upgrade module path");
399 if (!systemModuleFinder.find(name).isPresent())
400 fail(name + ": cannot be loaded from application module path");
401 }
402 }
403 }
404
405 // check for split packages in the modules mapped to the built-in loaders
406 if (hasSplitPackages || isPatched || haveModulePath) {
441 concealedPackagesToOpen = systemModules.concealedPackagesToOpen();
442 exportedPackagesToOpen = systemModules.exportedPackagesToOpen();
443 }
444 addIllegalAccess(upgradeModulePath,
445 concealedPackagesToOpen,
446 exportedPackagesToOpen,
447 bootLayer,
448 extraExportsOrOpens);
449 Counters.add("jdk.module.boot.7.adjustModulesTime", t7);
450
451 // save module finders for later use
452 if (savedModuleFinder != null) {
453 unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
454 if (savedModuleFinder != finder)
455 limitedFinder = new SafeModuleFinder(finder);
456 }
457
458 // Module graph can be archived at CDS dump time. Only allow the
459 // unnamed module case for now.
460 if (canArchive && (mainModule == null)) {
461 ArchivedModuleGraph.archive(mainModule,
462 hasSplitPackages,
463 hasIncubatorModules,
464 systemModuleFinder,
465 cf,
466 concealedPackagesToOpen,
467 exportedPackagesToOpen);
468 }
469
470 // total time to initialize
471 Counters.add("jdk.module.boot.totalTime", t0);
472 Counters.publish();
473
474 return bootLayer;
475 }
476
477 /**
478 * Load/register the modules to the built-in class loaders.
479 */
480 private static void loadModules(Configuration cf,
481 Function<String, ClassLoader> clf) {
482 for (ResolvedModule resolvedModule : cf.modules()) {
483 ModuleReference mref = resolvedModule.reference();
484 String name = resolvedModule.name();
485 ClassLoader loader = clf.apply(name);
486 if (loader == null) {
487 // skip java.base as it is already loaded
739 if (om.isPresent()) {
740 other = om.get();
741 } else {
742 warnUnknownModule(option, name);
743 continue;
744 }
745 }
746 if (allUnnamed) {
747 if (opens) {
748 Modules.addOpensToAllUnnamed(m, pn);
749 } else {
750 Modules.addExportsToAllUnnamed(m, pn);
751 }
752 } else {
753 if (opens) {
754 Modules.addOpens(m, pn, other);
755 } else {
756 Modules.addExports(m, pn, other);
757 }
758 }
759
760 }
761 }
762 }
763
764 /**
765 * Process the --illegal-access option (and its default) to open packages
766 * of system modules in the boot layer to code in unnamed modules.
767 */
768 private static void addIllegalAccess(ModuleFinder upgradeModulePath,
769 Map<String, Set<String>> concealedPackagesToOpen,
770 Map<String, Set<String>> exportedPackagesToOpen,
771 ModuleLayer bootLayer,
772 boolean extraExportsOrOpens) {
773 String value = getAndRemoveProperty("jdk.module.illegalAccess");
774 IllegalAccessLogger.Mode mode = IllegalAccessLogger.Mode.ONESHOT;
775 if (value != null) {
776 switch (value) {
777 case "deny":
778 return;
779 case "permit":
|
366 if (isPatched) {
367 patcher.patchedModules()
368 .stream()
369 .filter(mn -> !cf.findModule(mn).isPresent())
370 .forEach(mn -> warnUnknownModule(PATCH_MODULE, mn));
371 }
372
373 Counters.add("jdk.module.boot.4.resolveTime", t4);
374
375
376 // Step 5: Map the modules in the configuration to class loaders.
377 // The static configuration provides the mapping of standard and JDK
378 // modules to the boot and platform loaders. All other modules (JDK
379 // tool modules, and both explicit and automatic modules on the
380 // application module path) are defined to the application class
381 // loader.
382
383 long t5 = System.nanoTime();
384
385 // mapping of modules to class loaders
386 ModuleLoaderMap.Mapper clf;
387 if (archivedModuleGraph != null) {
388 clf = archivedModuleGraph.classLoaderFunction();
389 } else {
390 clf = ModuleLoaderMap.mappingFunction(cf);
391 }
392
393 // check that all modules to be mapped to the boot loader will be
394 // loaded from the runtime image
395 if (haveModulePath) {
396 for (ResolvedModule resolvedModule : cf.modules()) {
397 ModuleReference mref = resolvedModule.reference();
398 String name = mref.descriptor().name();
399 ClassLoader cl = clf.apply(name);
400 if (cl == null) {
401 if (upgradeModulePath != null
402 && upgradeModulePath.find(name).isPresent())
403 fail(name + ": cannot be loaded from upgrade module path");
404 if (!systemModuleFinder.find(name).isPresent())
405 fail(name + ": cannot be loaded from application module path");
406 }
407 }
408 }
409
410 // check for split packages in the modules mapped to the built-in loaders
411 if (hasSplitPackages || isPatched || haveModulePath) {
446 concealedPackagesToOpen = systemModules.concealedPackagesToOpen();
447 exportedPackagesToOpen = systemModules.exportedPackagesToOpen();
448 }
449 addIllegalAccess(upgradeModulePath,
450 concealedPackagesToOpen,
451 exportedPackagesToOpen,
452 bootLayer,
453 extraExportsOrOpens);
454 Counters.add("jdk.module.boot.7.adjustModulesTime", t7);
455
456 // save module finders for later use
457 if (savedModuleFinder != null) {
458 unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
459 if (savedModuleFinder != finder)
460 limitedFinder = new SafeModuleFinder(finder);
461 }
462
463 // Module graph can be archived at CDS dump time. Only allow the
464 // unnamed module case for now.
465 if (canArchive && (mainModule == null)) {
466 ArchivedModuleGraph.archive(
467 new ArchivedModuleGraph(hasSplitPackages,
468 hasIncubatorModules,
469 systemModuleFinder,
470 cf,
471 clf,
472 concealedPackagesToOpen,
473 exportedPackagesToOpen));
474 }
475
476 // total time to initialize
477 Counters.add("jdk.module.boot.totalTime", t0);
478 Counters.publish();
479
480 return bootLayer;
481 }
482
483 /**
484 * Load/register the modules to the built-in class loaders.
485 */
486 private static void loadModules(Configuration cf,
487 Function<String, ClassLoader> clf) {
488 for (ResolvedModule resolvedModule : cf.modules()) {
489 ModuleReference mref = resolvedModule.reference();
490 String name = resolvedModule.name();
491 ClassLoader loader = clf.apply(name);
492 if (loader == null) {
493 // skip java.base as it is already loaded
745 if (om.isPresent()) {
746 other = om.get();
747 } else {
748 warnUnknownModule(option, name);
749 continue;
750 }
751 }
752 if (allUnnamed) {
753 if (opens) {
754 Modules.addOpensToAllUnnamed(m, pn);
755 } else {
756 Modules.addExportsToAllUnnamed(m, pn);
757 }
758 } else {
759 if (opens) {
760 Modules.addOpens(m, pn, other);
761 } else {
762 Modules.addExports(m, pn, other);
763 }
764 }
765 }
766 }
767 }
768
769 /**
770 * Process the --illegal-access option (and its default) to open packages
771 * of system modules in the boot layer to code in unnamed modules.
772 */
773 private static void addIllegalAccess(ModuleFinder upgradeModulePath,
774 Map<String, Set<String>> concealedPackagesToOpen,
775 Map<String, Set<String>> exportedPackagesToOpen,
776 ModuleLayer bootLayer,
777 boolean extraExportsOrOpens) {
778 String value = getAndRemoveProperty("jdk.module.illegalAccess");
779 IllegalAccessLogger.Mode mode = IllegalAccessLogger.Mode.ONESHOT;
780 if (value != null) {
781 switch (value) {
782 case "deny":
783 return;
784 case "permit":
|