8338747: hasIncubatorModules needs to be generated when module resolution required at startup
Reviewed-by: iklam, ccheung
This commit is contained in:
parent
3c40afa59c
commit
1b17e0b133
@ -205,12 +205,11 @@ public final class ModuleBootstrap {
|
||||
|
||||
boolean haveModulePath = (appModulePath != null || upgradeModulePath != null);
|
||||
boolean needResolution = true;
|
||||
boolean canArchive = false;
|
||||
boolean hasSplitPackages;
|
||||
boolean hasIncubatorModules;
|
||||
boolean mayContainSplitPackages = true;
|
||||
boolean mayContainIncubatorModules = true;
|
||||
|
||||
// If the java heap was archived at CDS dump time and the environment
|
||||
// at dump time matches the current environment then use the archived
|
||||
// If the java heap was archived at CDS dump time, and the environment
|
||||
// at dump time matches the current environment, then use the archived
|
||||
// system modules and finder.
|
||||
ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule);
|
||||
if (archivedModuleGraph != null
|
||||
@ -219,18 +218,20 @@ public final class ModuleBootstrap {
|
||||
&& limitModules.isEmpty()
|
||||
&& !isPatched) {
|
||||
systemModuleFinder = archivedModuleGraph.finder();
|
||||
hasSplitPackages = archivedModuleGraph.hasSplitPackages();
|
||||
hasIncubatorModules = archivedModuleGraph.hasIncubatorModules();
|
||||
mayContainSplitPackages = archivedModuleGraph.hasSplitPackages();
|
||||
mayContainIncubatorModules = archivedModuleGraph.hasIncubatorModules();
|
||||
needResolution = (traceOutput != null);
|
||||
} else {
|
||||
if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) {
|
||||
systemModules = SystemModuleFinders.systemModules(mainModule);
|
||||
if (systemModules != null && !isPatched) {
|
||||
needResolution = (traceOutput != null);
|
||||
if (CDS.isDumpingStaticArchive())
|
||||
canArchive = true;
|
||||
if (systemModules != null && !isPatched && traceOutput == null) {
|
||||
// use pre-generated configuration
|
||||
needResolution = false;
|
||||
mayContainSplitPackages = systemModules.hasSplitPackages();
|
||||
mayContainIncubatorModules = systemModules.hasIncubatorModules();
|
||||
}
|
||||
}
|
||||
|
||||
if (systemModules == null) {
|
||||
// all system modules are observable
|
||||
systemModules = SystemModuleFinders.allSystemModules();
|
||||
@ -244,8 +245,6 @@ public final class ModuleBootstrap {
|
||||
systemModuleFinder = SystemModuleFinders.ofSystem();
|
||||
}
|
||||
|
||||
hasSplitPackages = systemModules.hasSplitPackages();
|
||||
hasIncubatorModules = systemModules.hasIncubatorModules();
|
||||
// not using the archived module graph - avoid accidental use
|
||||
archivedModuleGraph = null;
|
||||
}
|
||||
@ -433,7 +432,7 @@ public final class ModuleBootstrap {
|
||||
}
|
||||
|
||||
// check for split packages in the modules mapped to the built-in loaders
|
||||
if (hasSplitPackages || isPatched || haveModulePath) {
|
||||
if (mayContainSplitPackages) {
|
||||
checkSplitPackages(cf, clf);
|
||||
}
|
||||
|
||||
@ -449,7 +448,7 @@ public final class ModuleBootstrap {
|
||||
// Step 7: Miscellaneous
|
||||
|
||||
// check incubating status
|
||||
if (hasIncubatorModules || haveModulePath) {
|
||||
if (mayContainIncubatorModules) {
|
||||
checkIncubatingStatus(cf);
|
||||
}
|
||||
|
||||
@ -462,31 +461,14 @@ public final class ModuleBootstrap {
|
||||
|
||||
Counters.add("jdk.module.boot.7.adjustModulesTime");
|
||||
|
||||
// save module finders for later use
|
||||
if (savedModuleFinder != null) {
|
||||
unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
|
||||
if (savedModuleFinder != finder)
|
||||
limitedFinder = new SafeModuleFinder(finder);
|
||||
}
|
||||
// Step 8: CDS dump phase
|
||||
|
||||
// If -Xshare:dump and mainModule are specified, check if the mainModule
|
||||
// is in the runtime image and not on the upgrade module path. If so,
|
||||
// set canArchive to true so that the module graph can be archived.
|
||||
if (CDS.isDumpingStaticArchive() && mainModule != null) {
|
||||
String scheme = systemModuleFinder.find(mainModule)
|
||||
.stream()
|
||||
.map(ModuleReference::location)
|
||||
.flatMap(Optional::stream)
|
||||
.findAny()
|
||||
.map(URI::getScheme)
|
||||
.orElse(null);
|
||||
if ("jrt".equalsIgnoreCase(scheme)) {
|
||||
canArchive = true;
|
||||
}
|
||||
}
|
||||
if (CDS.isDumpingStaticArchive() && !haveModulePath && addModules.isEmpty()) {
|
||||
assert !isPatched;
|
||||
|
||||
// Archive module graph and boot layer can be archived at CDS dump time.
|
||||
if (canArchive) {
|
||||
// Archive module graph and maybe boot layer
|
||||
boolean hasSplitPackages = containsSplitPackages(cf);
|
||||
boolean hasIncubatorModules = containsIncubatorModule(cf);
|
||||
ArchivedModuleGraph.archive(hasSplitPackages,
|
||||
hasIncubatorModules,
|
||||
systemModuleFinder,
|
||||
@ -498,6 +480,13 @@ public final class ModuleBootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
// save module finders for later use
|
||||
if (savedModuleFinder != null) {
|
||||
unlimitedFinder = new SafeModuleFinder(savedModuleFinder);
|
||||
if (savedModuleFinder != finder)
|
||||
limitedFinder = new SafeModuleFinder(finder);
|
||||
}
|
||||
|
||||
return bootLayer;
|
||||
}
|
||||
|
||||
@ -522,8 +511,18 @@ public final class ModuleBootstrap {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for split packages between modules defined to the built-in class
|
||||
* loaders.
|
||||
* Returns true if the configuration contains modules with overlapping packages.
|
||||
*/
|
||||
private static boolean containsSplitPackages(Configuration cf) {
|
||||
boolean found = cf.modules().stream()
|
||||
.map(m -> m.reference().descriptor().packages())
|
||||
.flatMap(Set::stream)
|
||||
.allMatch(new HashSet<>()::add);
|
||||
return !found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for split packages between modules defined to the built-in class loaders.
|
||||
*/
|
||||
private static void checkSplitPackages(Configuration cf,
|
||||
Function<String, ClassLoader> clf) {
|
||||
@ -820,7 +819,9 @@ public final class ModuleBootstrap {
|
||||
* Grants native access for the given modules in the given layer.
|
||||
* Warns optionally about modules that were specified, but not present in the layer.
|
||||
*/
|
||||
private static void addEnableNativeAccess(ModuleLayer layer, Set<String> moduleNames, boolean shouldWarn) {
|
||||
private static void addEnableNativeAccess(ModuleLayer layer,
|
||||
Set<String> moduleNames,
|
||||
boolean shouldWarn) {
|
||||
for (String name : moduleNames) {
|
||||
if (name.equals("ALL-UNNAMED")) {
|
||||
JLA.addEnableNativeAccessToAllUnnamed();
|
||||
@ -951,6 +952,15 @@ public final class ModuleBootstrap {
|
||||
return (String) System.getProperties().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the configuration contains an incubator module.
|
||||
*/
|
||||
private static boolean containsIncubatorModule(Configuration cf) {
|
||||
return cf.modules().stream()
|
||||
.map(ResolvedModule::reference)
|
||||
.anyMatch(ModuleResolution::hasIncubatingWarning);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks incubating status of modules in the configuration
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user