--- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Jun 21 10:54:07 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Jun 21 18:56:35 2018 +0100
@@ -136,7 +136,7 @@
/**
* Initialize the module system, returning the boot layer.
*
- * @see java.lang.System#initPhase2()
+ * @see java.lang.System#initPhase2(boolean, boolean)
*/
public static ModuleLayer boot() throws Exception {
@@ -213,11 +213,13 @@
Counters.add("jdk.module.boot.2.defineBaseTime", t2);
- // Step 2a: If --validate-modules is specified then the VM needs to
- // start with only system modules, all other options are ignored.
+ // Step 2a: Scan all modules when --validate-modules specified
if (getAndRemoveProperty("jdk.module.validation") != null) {
- return createBootLayerForValidation();
+ int errors = ModulePathValidator.scanAllModules(System.out);
+ if (errors > 0) {
+ fail("Validation of module path failed");
+ }
}
@@ -420,26 +422,6 @@
}
/**
- * Create a boot module layer for validation that resolves all
- * system modules.
- */
- private static ModuleLayer createBootLayerForValidation() {
- Set<String> allSystem = ModuleFinder.ofSystem().findAll()
- .stream()
- .map(ModuleReference::descriptor)
- .map(ModuleDescriptor::name)
- .collect(Collectors.toSet());
-
- Configuration cf = SharedSecrets.getJavaLangModuleAccess()
- .resolveAndBind(ModuleFinder.ofSystem(),
- allSystem,
- null);
-
- Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf);
- return ModuleLayer.empty().defineModules(cf, clf);
- }
-
- /**
* Load/register the modules to the built-in class loaders.
*/
private static void loadModules(Configuration cf,