--- old/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2018-06-20 19:31:11.000000000 +0100 +++ new/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2018-06-20 19:31:11.000000000 +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 allSystem = ModuleFinder.ofSystem().findAll() - .stream() - .map(ModuleReference::descriptor) - .map(ModuleDescriptor::name) - .collect(Collectors.toSet()); - - Configuration cf = SharedSecrets.getJavaLangModuleAccess() - .resolveAndBind(ModuleFinder.ofSystem(), - allSystem, - null); - - Function 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,