8186145: tools/launcher/modules/validate/ValidateModulesTest.java fails when launched with -XX:+EnableJVMCI

--validate-modules runs with a boot layer resolving all system modules rather than only java.base

Reviewed-by: alanb
This commit is contained in:
Mandy Chung 2017-08-25 10:52:17 -07:00
parent d5f19a429a
commit 496b798b66
2 changed files with 14 additions and 7 deletions

View File

@ -215,10 +215,10 @@ public final class ModuleBootstrap {
// Step 2a: If --validate-modules is specified then the VM needs to // Step 2a: If --validate-modules is specified then the VM needs to
// start with only java.base, all other options are ignored. // start with only system modules, all other options are ignored.
if (getAndRemoveProperty("jdk.module.minimumBoot") != null) { if (getAndRemoveProperty("jdk.module.validation") != null) {
return createMinimalBootLayer(); return createBootLayerForValidation();
} }
@ -421,12 +421,19 @@ public final class ModuleBootstrap {
} }
/** /**
* Create a "minimal" boot module layer that only contains java.base. * Create a boot module layer for validation that resolves all
* system modules.
*/ */
private static ModuleLayer createMinimalBootLayer() { private static ModuleLayer createBootLayerForValidation() {
Set<String> allSystem = ModuleFinder.ofSystem().findAll()
.stream()
.map(ModuleReference::descriptor)
.map(ModuleDescriptor::name)
.collect(Collectors.toSet());
Configuration cf = SharedSecrets.getJavaLangModuleAccess() Configuration cf = SharedSecrets.getJavaLangModuleAccess()
.resolveAndBind(ModuleFinder.ofSystem(), .resolveAndBind(ModuleFinder.ofSystem(),
Set.of(JAVA_BASE), allSystem,
null); null);
Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf); Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf);

View File

@ -1296,7 +1296,7 @@ ParseArguments(int *pargc, char ***pargv,
} else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) { } else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) {
showResolvedModules = JNI_TRUE; showResolvedModules = JNI_TRUE;
} else if (JLI_StrCmp(arg, "--validate-modules") == 0) { } else if (JLI_StrCmp(arg, "--validate-modules") == 0) {
AddOption("-Djdk.module.minimumBoot=true", NULL); AddOption("-Djdk.module.validation=true", NULL);
validateModules = JNI_TRUE; validateModules = JNI_TRUE;
} else if (JLI_StrCmp(arg, "--describe-module") == 0 || } else if (JLI_StrCmp(arg, "--describe-module") == 0 ||
JLI_StrCCmp(arg, "--describe-module=") == 0 || JLI_StrCCmp(arg, "--describe-module=") == 0 ||