Improve automatic module handling in module graph construction

Add all automatic modules to roots if at least one automatic module is
added, as per
http://cr.openjdk.java.net/~mr/jigsaw/spec/api/java/lang/module/package-summary.html
This commit is contained in:
Alexander Udalov
2017-06-30 18:03:17 +03:00
parent c428505d4d
commit 9199023952
11 changed files with 57 additions and 3 deletions
@@ -172,11 +172,21 @@ internal class ClasspathRootsResolver(
else -> computeDefaultRootModules() + additionalModules
}
// TODO: if at least one automatic module is added, add all automatic modules as per java.lang.module javadoc
val allDependencies = javaModuleGraph.getAllDependencies(rootModules).also { loadedModules ->
report(LOGGING, "Loading modules: $loadedModules")
val allDependencies = javaModuleGraph.getAllDependencies(rootModules).toMutableList()
if (allDependencies.any { moduleName -> javaModuleFinder.findModule(moduleName) is JavaModule.Automatic }) {
// According to java.lang.module javadoc, if at least one automatic module is added to the module graph,
// all observable automatic modules should be added.
// There are no automatic modules in the JDK, so we select all automatic modules out of user modules
for (module in modules) {
if (module is JavaModule.Automatic) {
allDependencies += module.name
}
}
}
report(LOGGING, "Loading modules: $allDependencies")
for (moduleName in allDependencies) {
val module = javaModuleFinder.findModule(moduleName)
if (module == null) {