[CHERRY PICKED FROM IJ] Fix debug of incremental JPS tests in intellij repo
Create extension of "load classes by parent classloader" logic to bypass clash of the same classes with different versions, loaded by different classloaders in case of running in-process compilation in debug configuration. #KT-49786 Fixed GitOrigin-RevId: 173749ef1a36fdb1df44e98f3d373941e00f29ad Original commit: https://github.com/JetBrains/intellij-community/commit/16e76333d4163c3772fa6e6ef3c1c7667a4c12f9
This commit is contained in:
committed by
Nikita Bobko
parent
ea9422fedd
commit
b3f6b78fbe
+5
-1
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.util.Disposer
|
import com.intellij.openapi.util.Disposer
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
@@ -101,6 +102,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
protected lateinit var workDir: File
|
protected lateinit var workDir: File
|
||||||
protected lateinit var projectDescriptor: ProjectDescriptor
|
protected lateinit var projectDescriptor: ProjectDescriptor
|
||||||
protected lateinit var additionalCommandLineArguments: List<String>
|
protected lateinit var additionalCommandLineArguments: List<String>
|
||||||
|
|
||||||
// is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage)
|
// is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage)
|
||||||
protected lateinit var lookupsDuringTest: MutableSet<LookupSymbol>
|
protected lateinit var lookupsDuringTest: MutableSet<LookupSymbol>
|
||||||
private var isJvmICEnabledBackup: Boolean = false
|
private var isJvmICEnabledBackup: Boolean = false
|
||||||
@@ -150,6 +152,8 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
if (DEBUG_LOGGING_ENABLED) {
|
if (DEBUG_LOGGING_ENABLED) {
|
||||||
enableDebugLogging()
|
enableDebugLogging()
|
||||||
}
|
}
|
||||||
|
System.getProperties()
|
||||||
|
.setProperty("kotlin.jps.classPrefixesToLoadByParent", "kotlin.") // for debugging tests with in-process compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() {
|
||||||
@@ -402,7 +406,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
// null means one module
|
// null means one module
|
||||||
private fun configureModules(): ModulesTxt? {
|
private fun configureModules(): ModulesTxt? {
|
||||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl =
|
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl =
|
||||||
JpsPathUtil.pathToUrl(getAbsolutePath("out"))
|
JpsPathUtil.pathToUrl(getAbsolutePath("out"))
|
||||||
|
|
||||||
val jdk = addJdk("my jdk")
|
val jdk = addJdk("my jdk")
|
||||||
val modulesTxt = readModulesTxt()
|
val modulesTxt = readModulesTxt()
|
||||||
|
|||||||
@@ -71,17 +71,32 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
const val SKIP_CACHE_VERSION_CHECK_PROPERTY = "kotlin.jps.skip.cache.version.check"
|
const val SKIP_CACHE_VERSION_CHECK_PROPERTY = "kotlin.jps.skip.cache.version.check"
|
||||||
const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home"
|
const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home"
|
||||||
|
|
||||||
|
private val classesToLoadByParentFromRegistry =
|
||||||
|
System.getProperty("kotlin.jps.classesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList()
|
||||||
|
private val classPrefixesToLoadByParentFromRegistry =
|
||||||
|
System.getProperty("kotlin.jps.classPrefixesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList()
|
||||||
|
|
||||||
val classesToLoadByParent: ClassCondition
|
val classesToLoadByParent: ClassCondition
|
||||||
get() = ClassCondition { className ->
|
get() = ClassCondition { className ->
|
||||||
className.startsWith("org.jetbrains.kotlin.load.kotlin.incremental.components.")
|
val prefixes = listOf(
|
||||||
|| className.startsWith("org.jetbrains.kotlin.incremental.components.")
|
"org.apache.log4j.", // For logging from compiler
|
||||||
|| className.startsWith("org.jetbrains.kotlin.incremental.js")
|
"org.jetbrains.kotlin.incremental.components.",
|
||||||
|| className == "org.jetbrains.kotlin.config.Services"
|
"org.jetbrains.kotlin.incremental.js",
|
||||||
|| className.startsWith("org.apache.log4j.") // For logging from compiler
|
"org.jetbrains.kotlin.load.kotlin.incremental.components."
|
||||||
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledStatus"
|
) + classPrefixesToLoadByParentFromRegistry
|
||||||
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledException"
|
|
||||||
|| className == "org.jetbrains.kotlin.modules.TargetId"
|
val classes = listOf(
|
||||||
|| className == "org.jetbrains.kotlin.cli.common.ExitCode"
|
"org.jetbrains.kotlin.config.Services",
|
||||||
|
"org.jetbrains.kotlin.progress.CompilationCanceledStatus",
|
||||||
|
"org.jetbrains.kotlin.progress.CompilationCanceledException",
|
||||||
|
"org.jetbrains.kotlin.modules.TargetId",
|
||||||
|
"org.jetbrains.kotlin.cli.common.ExitCode"
|
||||||
|
) + classesToLoadByParentFromRegistry
|
||||||
|
|
||||||
|
prefixes.forEach { if (className.startsWith(it)) return@ClassCondition true }
|
||||||
|
classes.forEach { if (className == it) return@ClassCondition true }
|
||||||
|
|
||||||
|
return@ClassCondition false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user