< prev index next >

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

Print this page

        

*** 304,313 **** --- 304,320 ---- if (!systemModules.find(name).isPresent()) fail(name + ": cannot be loaded from application module path"); } } + + // check if module specified in --patch-module is present + for (String mn: patcher.patchedModules()) { + if (!cf.findModule(mn).isPresent()) { + warnUnknownModule(PATCH_MODULE, mn); + } + } } long t4 = System.nanoTime();
*** 462,472 **** // the key is $MODULE String mn = e.getKey(); Optional<Module> om = bootLayer.findModule(mn); if (!om.isPresent()) { ! warn("Unknown module: " + mn); continue; } Module m = om.get(); // the value is the set of other modules (by name) --- 469,479 ---- // the key is $MODULE String mn = e.getKey(); Optional<Module> om = bootLayer.findModule(mn); if (!om.isPresent()) { ! warnUnknownModule(ADD_READS, mn); continue; } Module m = om.get(); // the value is the set of other modules (by name)
*** 476,486 **** } else { om = bootLayer.findModule(name); if (om.isPresent()) { Modules.addReads(m, om.get()); } else { ! warn("Unknown module: " + name); } } } } } --- 483,493 ---- } else { om = bootLayer.findModule(name); if (om.isPresent()) { Modules.addReads(m, om.get()); } else { ! warnUnknownModule(ADD_READS, name); } } } } }
*** 508,535 **** private static void addExtraExportsOrOpens(Layer bootLayer, Map<String, List<String>> map, boolean opens) { for (Map.Entry<String, List<String>> e : map.entrySet()) { // the key is $MODULE/$PACKAGE String key = e.getKey(); String[] s = key.split("/"); if (s.length != 2) ! fail("Unable to parse as <module>/<package>: " + key); String mn = s[0]; String pn = s[1]; if (mn.isEmpty() || pn.isEmpty()) ! fail("Module and package name must be specified: " + key); // The exporting module is in the boot layer Module m; Optional<Module> om = bootLayer.findModule(mn); if (!om.isPresent()) { ! warn("Unknown module: " + mn); continue; } m = om.get(); --- 515,543 ---- private static void addExtraExportsOrOpens(Layer bootLayer, Map<String, List<String>> map, boolean opens) { + String option = opens ? ADD_OPENS : ADD_EXPORTS; for (Map.Entry<String, List<String>> e : map.entrySet()) { // the key is $MODULE/$PACKAGE String key = e.getKey(); String[] s = key.split("/"); if (s.length != 2) ! fail(unableToParse(option, "<module>/<package>", key)); String mn = s[0]; String pn = s[1]; if (mn.isEmpty() || pn.isEmpty()) ! fail(unableToParse(option, "<module>/<package>", key)); // The exporting module is in the boot layer Module m; Optional<Module> om = bootLayer.findModule(mn); if (!om.isPresent()) { ! warnUnknownModule(option, mn); continue; } m = om.get();
*** 547,557 **** } else { om = bootLayer.findModule(name); if (om.isPresent()) { other = om.get(); } else { ! warn("Unknown module: " + name); continue; } } if (allUnnamed) { if (opens) { --- 555,565 ---- } else { om = bootLayer.findModule(name); if (om.isPresent()) { other = om.get(); } else { ! warnUnknownModule(option, name); continue; } } if (allUnnamed) { if (opens) {
*** 591,618 **** while (value != null) { int pos = value.indexOf('='); if (pos == -1) ! fail("Unable to parse as <module>=<value>: " + value); if (pos == 0) ! fail("Missing module name in: " + value); // key is <module> or <module>/<package> String key = value.substring(0, pos); String rhs = value.substring(pos+1); if (rhs.isEmpty()) ! fail("Unable to parse as <module>=<value>: " + value); // value is <module>(,<module>)* or <file>(<pathsep><file>)* if (!allowDuplicates && map.containsKey(key)) ! fail(key + " specified more than once"); List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>()); for (String s : rhs.split(regex)) { ! if (s.length() > 0) values.add(s); } index++; value = getAndRemoveProperty(prefix + index); } --- 599,632 ---- while (value != null) { int pos = value.indexOf('='); if (pos == -1) ! fail(unableToParse(option(prefix), "<module>=<value>", value)); if (pos == 0) ! fail(unableToParse(option(prefix), "<module>=<value>", value)); // key is <module> or <module>/<package> String key = value.substring(0, pos); String rhs = value.substring(pos+1); if (rhs.isEmpty()) ! fail(unableToParse(option(prefix), "<module>=<value>", value)); // value is <module>(,<module>)* or <file>(<pathsep><file>)* if (!allowDuplicates && map.containsKey(key)) ! fail(key + " specified more than once in " + option(prefix)); List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>()); + int ntargets = 0; for (String s : rhs.split(regex)) { ! if (s.length() > 0) { ! values.add(s); ! ntargets++; } + } + if (ntargets == 0) + fail("Target must be specified: " + option(prefix) + " " + value); index++; value = getAndRemoveProperty(prefix + index); }
*** 670,679 **** --- 684,729 ---- static void warn(String m) { System.err.println("WARNING: " + m); } + static void warnUnknownModule(String option, String mn) { + warn("Unknown module: " + mn + " specified in " + option); + } + + static String unableToParse(String option, String text, String value) { + return "Unable to parse " + option + " " + text + ": " + value; + } + + private static final String ADD_MODULES = "--add-modules"; + private static final String ADD_EXPORTS = "--add-exports"; + private static final String ADD_OPENS = "--add-opens"; + private static final String ADD_READS = "--add-reads"; + private static final String PATCH_MODULE = "--patch-module"; + + + /* + * Returns the command-line option name corresponds to the specified + * system property prefix. + */ + static String option(String prefix) { + switch (prefix) { + case "jdk.module.addexports.": + return ADD_EXPORTS; + case "jdk.module.addopens.": + return ADD_OPENS; + case "jdk.module.addreads.": + return ADD_READS; + case "jdk.module.patch.": + return PATCH_MODULE; + case "jdk.module.addmods.": + return ADD_MODULES; + default: + throw new IllegalArgumentException(prefix); + } + } + static class PerfCounters { static PerfCounter systemModulesTime = PerfCounter.newPerfCounter("jdk.module.bootstrap.systemModulesTime"); static PerfCounter defineBaseTime
< prev index next >