From 4b949ef30361b8b240b27d17a231988c2ee05551 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Tue, 15 May 2018 18:39:07 +0200 Subject: [PATCH] Fix order of jars for the scripting plugin: if gradle project is being built with JPS, the gradle scripting plugin is passed in the plugin classpath. Since it is rebased on the embeddable compiler, it hides expected plugin registrar signature, which leads to the AbstractMethodError on attempt to load the plugin. Putting incoming classpath at the end of the resulting one fixes the issue. Fixes #KT-24448 --- .../cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index b1b2ed60c6b..1cf116b6088 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -216,7 +216,7 @@ class K2JVMCompiler : CLICompiler() { override fun getPerformanceManager(): CommonCompilerPerformanceManager = performanceManager private fun loadPlugins(paths: KotlinPaths?, arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode { - val pluginClasspaths = arguments.pluginClasspaths?.toMutableList() ?: ArrayList() + var pluginClasspaths = arguments.pluginClasspaths?.asIterable() ?: emptyArray() val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList() if (!arguments.disableDefaultScriptingPlugin) { @@ -236,7 +236,7 @@ class K2JVMCompiler : CLICompiler() { val jars = arrayOf(KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR, KOTLIN_SCRIPTING_COMMON_JAR, KOTLIN_SCRIPTING_JVM_JAR) .mapNotNull { File(libPath, it).takeIf { it.exists() }?.canonicalPath } if (jars.size == 3) { - pluginClasspaths.addAll(jars) + pluginClasspaths = jars + pluginClasspaths } } }