Rework Tune module graph dependencies building
#KT-50701 In progress
This commit is contained in:
@@ -127,7 +127,7 @@ class CliJavaModuleFinder(
|
||||
useSig -> createModuleFromSignature(moduleInfo)
|
||||
else -> error("Can't find ${moduleRoot.path} module")
|
||||
},
|
||||
file, true
|
||||
file, !useLastJdkApi && useSig
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,15 @@ class JavaModuleGraph(finder: JavaModuleFinder) {
|
||||
// Every module implicitly depends on java.base
|
||||
visited += "java.base"
|
||||
|
||||
fun dfs(moduleName: String) {
|
||||
fun dfs(moduleName: String): Boolean {
|
||||
// Automatic modules have no transitive exports, so we only consider explicit modules here
|
||||
val moduleInfo = (module(moduleName) as? JavaModule.Explicit)?.moduleInfo ?: return
|
||||
val moduleInfo = (module(moduleName) as? JavaModule.Explicit)?.moduleInfo ?: return false
|
||||
for ((dependencyModuleName, isTransitive) in moduleInfo.requires) {
|
||||
if (isTransitive && visited.add(dependencyModuleName)) {
|
||||
dfs(dependencyModuleName)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
for (moduleName in moduleNames) {
|
||||
@@ -47,14 +48,11 @@ class JavaModuleGraph(finder: JavaModuleFinder) {
|
||||
// Do nothing; all automatic modules should be added to compilation roots at call site as per java.lang.module javadoc
|
||||
}
|
||||
is JavaModule.Explicit -> {
|
||||
if (module.isJdkModule) {
|
||||
//ct.sym can miss some internal modules from non-transitive dependencies
|
||||
dfs(moduleName)
|
||||
} else {
|
||||
for ((dependencyModuleName) in module.moduleInfo.requires) {
|
||||
if (visited.add(dependencyModuleName)) {
|
||||
dfs(dependencyModuleName)
|
||||
}
|
||||
for ((dependencyModuleName, isTransitive) in module.moduleInfo.requires) {
|
||||
if (visited.add(dependencyModuleName)) {
|
||||
val moduleExists = dfs(dependencyModuleName)
|
||||
//ct.sym can miss some internal modules from non-transitive dependencies
|
||||
if (!moduleExists && !isTransitive && module.isJdkModuleFromCtSym) visited.remove(dependencyModuleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ interface JavaModule {
|
||||
}
|
||||
|
||||
class Explicit(
|
||||
val moduleInfo: JavaModuleInfo,
|
||||
override val moduleRoots: List<Root>,
|
||||
override val moduleInfoFile: VirtualFile,
|
||||
val isJdkModule: Boolean = false
|
||||
val moduleInfo: JavaModuleInfo,
|
||||
override val moduleRoots: List<Root>,
|
||||
override val moduleInfoFile: VirtualFile,
|
||||
val isJdkModuleFromCtSym: Boolean = false
|
||||
) : JavaModule {
|
||||
override val name: String
|
||||
get() = moduleInfo.moduleName
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
compiler/testData/javaModules/automaticModuleInternalJdkPackageUsage/jvmStatUsage/Test.kt:1:28: error: symbol is declared in module 'jdk.internal.jvmstat' which does not export package 'sun.jvmstat.monitor'
|
||||
val z: sun.jvmstat.monitor.Monitor? = null
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+1
@@ -0,0 +1 @@
|
||||
val z: sun.jvmstat.monitor.Monitor? = null
|
||||
@@ -160,6 +160,10 @@ abstract class JavaModulesIntegrationTest(private val jdkVersion: Int, private v
|
||||
}
|
||||
}
|
||||
|
||||
fun testAutomaticModuleInternalJdkPackageUsage() {
|
||||
module("jvmStatUsage")
|
||||
}
|
||||
|
||||
fun testReleaseFlag() {
|
||||
module("module")
|
||||
module("module9", additionalKotlinArguments = listOf("-Xjdk-release=9"))
|
||||
|
||||
Reference in New Issue
Block a user