< prev index next >

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

Print this page
rev 50671 : [mq]: validate-modules

*** 134,144 **** } /** * Initialize the module system, returning the boot layer. * ! * @see java.lang.System#initPhase2() */ public static ModuleLayer boot() throws Exception { // Step 0: Command line options --- 134,144 ---- } /** * Initialize the module system, returning the boot layer. * ! * @see java.lang.System#initPhase2(boolean, boolean) */ public static ModuleLayer boot() throws Exception { // Step 0: Command line options
*** 211,225 **** Modules.defineModule(null, base.descriptor(), baseUri); 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. if (getAndRemoveProperty("jdk.module.validation") != null) { ! return createBootLayerForValidation(); } // Step 3: If resolution is needed then create the module finder and // the set of root modules to resolve. --- 211,227 ---- Modules.defineModule(null, base.descriptor(), baseUri); Counters.add("jdk.module.boot.2.defineBaseTime", t2); ! // Step 2a: Scan all modules when --validate-modules specified if (getAndRemoveProperty("jdk.module.validation") != null) { ! int errors = ModulePathValidator.scanAllModules(System.out); ! if (errors > 0) { ! fail("Validation of module path failed"); ! } } // Step 3: If resolution is needed then create the module finder and // the set of root modules to resolve.
*** 418,447 **** return bootLayer; } /** - * 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, Function<String, ClassLoader> clf) { for (ResolvedModule resolvedModule : cf.modules()) { --- 420,429 ----
< prev index next >