< prev index next >

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

Print this page

        

*** 54,65 **** * Initializes/boots the module system. * * The {@link #boot() boot} method is called early in the startup to initialize * the module system. In summary, the boot method creates a Configuration by * resolving a set of module names specified via the launcher (or equivalent) ! * -m and -addmods options. The modules are located on a module path that is ! * constructed from the upgrade module path, system modules, and application * module path. The Configuration is instantiated as the boot Layer with each * module in the the configuration defined to one of the built-in class loaders. */ public final class ModuleBootstrap { --- 54,65 ---- * Initializes/boots the module system. * * The {@link #boot() boot} method is called early in the startup to initialize * the module system. In summary, the boot method creates a Configuration by * resolving a set of module names specified via the launcher (or equivalent) ! * -m and --add-modules options. The modules are located on a module path that ! * is constructed from the upgrade module path, system modules, and application * module path. The Configuration is instantiated as the boot Layer with each * module in the the configuration defined to one of the built-in class loaders. */ public final class ModuleBootstrap {
*** 125,144 **** PerfCounters.defineBaseTime.addElapsedTimeFrom(t1); long t2 = System.nanoTime(); ! // -upgrademodulepath option specified to launcher ModuleFinder upgradeModulePath ! = createModulePathFinder("jdk.upgrade.module.path"); if (upgradeModulePath != null) systemModules = ModuleFinder.compose(upgradeModulePath, systemModules); ! // -modulepath option specified to the launcher ModuleFinder appModulePath = createModulePathFinder("jdk.module.path"); ! // The module finder: [-upgrademodulepath] system [-modulepath] ModuleFinder finder = systemModules; if (appModulePath != null) finder = ModuleFinder.compose(finder, appModulePath); // The root modules to resolve --- 125,144 ---- PerfCounters.defineBaseTime.addElapsedTimeFrom(t1); long t2 = System.nanoTime(); ! // --upgrade-module-path option specified to launcher ModuleFinder upgradeModulePath ! = createModulePathFinder("jdk.module.upgrade.path"); if (upgradeModulePath != null) systemModules = ModuleFinder.compose(upgradeModulePath, systemModules); ! // --module-path option specified to the launcher ModuleFinder appModulePath = createModulePathFinder("jdk.module.path"); ! // The module finder: [--upgrade-module-path] system [--module-path] ModuleFinder finder = systemModules; if (appModulePath != null) finder = ModuleFinder.compose(finder, appModulePath); // The root modules to resolve
*** 147,161 **** // launcher -m option to specify the main/initial module String mainModule = System.getProperty("jdk.module.main"); if (mainModule != null) roots.add(mainModule); ! // additional module(s) specified by -addmods boolean addAllDefaultModules = false; boolean addAllSystemModules = false; boolean addAllApplicationModules = false; ! String propValue = System.getProperty("jdk.launcher.addmods"); if (propValue != null) { for (String mod: propValue.split(",")) { switch (mod) { case ALL_DEFAULT: addAllDefaultModules = true; --- 147,161 ---- // launcher -m option to specify the main/initial module String mainModule = System.getProperty("jdk.module.main"); if (mainModule != null) roots.add(mainModule); ! // additional module(s) specified by --add-modules boolean addAllDefaultModules = false; boolean addAllSystemModules = false; boolean addAllApplicationModules = false; ! String propValue = getAndRemoveProperty("jdk.module.addmods"); if (propValue != null) { for (String mod: propValue.split(",")) { switch (mod) { case ALL_DEFAULT: addAllDefaultModules = true;
*** 170,181 **** roots.add(mod); } } } ! // -limitmods ! propValue = System.getProperty("jdk.launcher.limitmods"); if (propValue != null) { Set<String> mods = new HashSet<>(); for (String mod: propValue.split(",")) { mods.add(mod); } --- 170,181 ---- roots.add(mod); } } } ! // --limit-modules ! propValue = getAndRemoveProperty("jdk.module.limitmods"); if (propValue != null) { Set<String> mods = new HashSet<>(); for (String mod: propValue.split(",")) { mods.add(mod); }
*** 214,224 **** } } } } ! // If `-addmods ALL-SYSTEM` is specified then all observable system // modules will be resolved. if (addAllSystemModules) { ModuleFinder f = finder; // observable modules systemModules.findAll() .stream() --- 214,224 ---- } } } } ! // If `--add-modules ALL-SYSTEM` is specified then all observable system // modules will be resolved. if (addAllSystemModules) { ModuleFinder f = finder; // observable modules systemModules.findAll() .stream()
*** 226,236 **** .map(ModuleDescriptor::name) .filter(mn -> f.find(mn).isPresent()) // observable .forEach(mn -> roots.add(mn)); } ! // If `-addmods ALL-MODULE-PATH` is specified then all observable // modules on the application module path will be resolved. if (appModulePath != null && addAllApplicationModules) { ModuleFinder f = finder; // observable modules appModulePath.findAll() .stream() --- 226,236 ---- .map(ModuleDescriptor::name) .filter(mn -> f.find(mn).isPresent()) // observable .forEach(mn -> roots.add(mn)); } ! // If `--add-modules ALL-MODULE-PATH` is specified then all observable // modules on the application module path will be resolved. if (appModulePath != null && addAllApplicationModules) { ModuleFinder f = finder; // observable modules appModulePath.findAll() .stream()
*** 248,258 **** // determine if post resolution checks are needed boolean needPostResolutionChecks = true; if (baseUri.getScheme().equals("jrt") // toLowerCase not needed here && (upgradeModulePath == null) && (appModulePath == null) ! && (System.getProperty("jdk.launcher.patch.0") == null)) { needPostResolutionChecks = false; } PrintStream traceOutput = null; if (Boolean.getBoolean("jdk.launcher.traceResolver")) --- 248,258 ---- // determine if post resolution checks are needed boolean needPostResolutionChecks = true; if (baseUri.getScheme().equals("jrt") // toLowerCase not needed here && (upgradeModulePath == null) && (appModulePath == null) ! && (!ModulePatcher.isBootLayerPatched())) { needPostResolutionChecks = false; } PrintStream traceOutput = null; if (Boolean.getBoolean("jdk.launcher.traceResolver"))
*** 315,325 **** } PerfCounters.loadModulesTime.addElapsedTimeFrom(t5); ! // -XaddReads and -XaddExports addExtraReads(bootLayer); addExtraExports(bootLayer); // total time to initialize PerfCounters.bootstrapTime.addElapsedTimeFrom(t0); --- 315,325 ---- } PerfCounters.loadModulesTime.addElapsedTimeFrom(t5); ! // --add-reads and --add-exports addExtraReads(bootLayer); addExtraExports(bootLayer); // total time to initialize PerfCounters.bootstrapTime.addElapsedTimeFrom(t0);
*** 392,408 **** } } /** ! * Process the -XaddReads options to add any additional read edges that * are specified on the command-line. */ private static void addExtraReads(Layer bootLayer) { // decode the command line options ! Map<String, Set<String>> map = decode("jdk.launcher.addreads."); for (Map.Entry<String, Set<String>> e : map.entrySet()) { // the key is $MODULE String mn = e.getKey(); --- 392,408 ---- } } /** ! * Process the --add-reads options to add any additional read edges that * are specified on the command-line. */ private static void addExtraReads(Layer bootLayer) { // decode the command line options ! Map<String, Set<String>> map = decode("jdk.module.addreads."); for (Map.Entry<String, Set<String>> e : map.entrySet()) { // the key is $MODULE String mn = e.getKey();
*** 429,445 **** } } /** ! * Process the -XaddExports options to add any additional read edges that * are specified on the command-line. */ private static void addExtraExports(Layer bootLayer) { // decode the command line options ! Map<String, Set<String>> map = decode("jdk.launcher.addexports."); for (Map.Entry<String, Set<String>> e : map.entrySet()) { // the key is $MODULE/$PACKAGE String key = e.getKey(); --- 429,445 ---- } } /** ! * Process the --add-exports options to add any additional read edges that * are specified on the command-line. */ private static void addExtraExports(Layer bootLayer) { // decode the command line options ! Map<String, Set<String>> map = decode("jdk.module.addexports."); for (Map.Entry<String, Set<String>> e : map.entrySet()) { // the key is $MODULE/$PACKAGE String key = e.getKey();
*** 481,497 **** } } /** ! * Decodes the values of -XaddReads or -XaddExports options * * The format of the options is: $KEY=$MODULE(,$MODULE)* */ private static Map<String, Set<String>> decode(String prefix) { int index = 0; ! String value = System.getProperty(prefix + index); if (value == null) return Collections.emptyMap(); Map<String, Set<String>> map = new HashMap<>(); --- 481,498 ---- } } /** ! * Decodes the values of --add-reads or --add-exports options * * The format of the options is: $KEY=$MODULE(,$MODULE)* */ private static Map<String, Set<String>> decode(String prefix) { int index = 0; ! // the system property is removed after decoding ! String value = getAndRemoveProperty(prefix + index); if (value == null) return Collections.emptyMap(); Map<String, Set<String>> map = new HashMap<>();
*** 520,535 **** for (String s : rhs.split(",")) { if (s.length() > 0) values.add(s); } index++; ! value = System.getProperty(prefix + index); } return map; } /** * Throws a RuntimeException with the given message */ static void fail(String m) { --- 521,542 ---- for (String s : rhs.split(",")) { if (s.length() > 0) values.add(s); } index++; ! value = getAndRemoveProperty(prefix + index); } return map; } + /** + * Gets and remove the named system property + */ + private static String getAndRemoveProperty(String key) { + return (String)System.getProperties().remove(key); + } /** * Throws a RuntimeException with the given message */ static void fail(String m) {
< prev index next >