Minor, return a set in JavaModuleGraph.getAllDependencies

To prevent duplicate roots to be added
This commit is contained in:
Alexander Udalov
2017-07-05 16:38:21 +03:00
parent ec6e4f2469
commit 3808ecbd1e
2 changed files with 4 additions and 5 deletions
@@ -191,8 +191,7 @@ internal class ClasspathRootsResolver(
else -> computeDefaultRootModules() + additionalModules
}
val allDependencies = javaModuleGraph.getAllDependencies(rootModules).toMutableList()
val allDependencies = javaModuleGraph.getAllDependencies(rootModules)
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.
@@ -22,8 +22,8 @@ class JavaModuleGraph(finder: JavaModuleFinder) {
private val module: (String) -> JavaModule? =
LockBasedStorageManager.NO_LOCKS.createMemoizedFunctionWithNullableValues(finder::findModule)
fun getAllDependencies(moduleNames: List<String>): List<String> {
val visited = moduleNames.toMutableSet()
fun getAllDependencies(moduleNames: List<String>): LinkedHashSet<String> {
val visited = LinkedHashSet(moduleNames)
// Every module implicitly depends on java.base
visited += "java.base"
@@ -55,7 +55,7 @@ class JavaModuleGraph(finder: JavaModuleFinder) {
}
}
return visited.toList()
return visited
}
fun reads(moduleName: String, dependencyName: String): Boolean {