Skip to content

Commit

Permalink
Revert "Isolate Kotlin compiler instances for Multiplex workers. (#515)…
Browse files Browse the repository at this point in the history
…" (#559)

This reverts commit b300cd8.

Introduces issues with multiplex, but the core issue is a bigger problem.
  • Loading branch information
rockwotj authored Jul 22, 2021
1 parent ece04e8 commit e619932
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,16 @@ class KotlinToolchain private constructor(
toolchain: KotlinToolchain,
clazz: String
) {
private val compiler: Any
private val execMethod: Method
private val getCodeMethod: Method
private val compilerClass = toolchain.classLoader.loadClass(clazz)

init {
// Disables disposing of the environment which is required when running parallel builds. This
// follows the behavior of the Kotlin compiler daemon.
System.setProperty("kotlin.environment.keepalive", "true")

val compilerClass = toolchain.classLoader.loadClass(clazz)
val exitCodeClass =
toolchain.classLoader.loadClass("org.jetbrains.kotlin.cli.common.ExitCode")

compiler = compilerClass.getConstructor().newInstance()
execMethod =
compilerClass.getMethod("exec", PrintStream::class.java, Array<String>::class.java)
getCodeMethod = exitCodeClass.getMethod("getCode")
Expand All @@ -185,7 +183,6 @@ class KotlinToolchain private constructor(
// 2 is an internal error
// 3 is the script execution error
fun compile(args: Array<String>, out: PrintStream): Int {
val compiler = compilerClass.getConstructor().newInstance()
val exitCodeInstance = execMethod.invoke(compiler, out, args)
return getCodeMethod.invoke(exitCodeInstance, *NO_ARGS) as Int
}
Expand Down

0 comments on commit e619932

Please sign in to comment.