[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:
Aleksei.Cherepanov
2021-11-29 16:42:57 +03:00
committed by Nikita Bobko
parent ea9422fedd
commit b3f6b78fbe
2 changed files with 29 additions and 10 deletions
@@ -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 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
get() = ClassCondition { className ->
className.startsWith("org.jetbrains.kotlin.load.kotlin.incremental.components.")
|| className.startsWith("org.jetbrains.kotlin.incremental.components.")
|| className.startsWith("org.jetbrains.kotlin.incremental.js")
|| className == "org.jetbrains.kotlin.config.Services"
|| className.startsWith("org.apache.log4j.") // For logging from compiler
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledStatus"
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledException"
|| className == "org.jetbrains.kotlin.modules.TargetId"
|| className == "org.jetbrains.kotlin.cli.common.ExitCode"
val prefixes = listOf(
"org.apache.log4j.", // For logging from compiler
"org.jetbrains.kotlin.incremental.components.",
"org.jetbrains.kotlin.incremental.js",
"org.jetbrains.kotlin.load.kotlin.incremental.components."
) + classPrefixesToLoadByParentFromRegistry
val classes = listOf(
"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
}
}