diff options
author | Mats Larsen <me@supergrecko.com> | 2021-12-03 21:59:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-03 22:59:08 +0100 |
commit | 560d18c410f6da78b5d0d79374436355c0de60b0 (patch) | |
tree | 2d2f08179bbea25ad4383ac9f4a14b0597d27cf5 /lib/compilers/kotlin.js | |
parent | 5fcef92d38cfeb23e3f5b450677244536960175c (diff) | |
download | compiler-explorer-560d18c410f6da78b5d0d79374436355c0de60b0.tar.gz compiler-explorer-560d18c410f6da78b5d0d79374436355c0de60b0.zip |
Temporarily patch Kotlin runtime execution (#3151)gh-1325
Fixes the problem where any (reasonable) Kotlin JVM execution would fail with a NoClassDefFound error with kotlin.jvm.internal.Intrinsics.
The Kotlin execution is now packed into a jar with the Kotlin Standard Library and executed with java -jar.
Diffstat (limited to 'lib/compilers/kotlin.js')
-rw-r--r-- | lib/compilers/kotlin.js | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/lib/compilers/kotlin.js b/lib/compilers/kotlin.js index 6b95a4c7d..0871dfcab 100644 --- a/lib/compilers/kotlin.js +++ b/lib/compilers/kotlin.js @@ -54,9 +54,6 @@ export class KotlinCompiler extends JavaCompiler { option !== '-script' && option !== '-progressive' && !option.startsWith('-Xjavac')); const oneArgForbiddenList = new Set([ - // -d directory - // Destination for generated class files - '-d', // -jdk-home path // Include a custom JDK from the specified location // into the classpath instead of the default JAVA_HOME @@ -80,6 +77,44 @@ export class KotlinCompiler extends JavaCompiler { ]; } + /** + * Handle Kotlin execution. + * + * Kotlin execution differs in the way that Kotlin requires its standard + * standard library because that's where the runtime libraries such as + * kotlin.jvm.internal.Intrinsics is. + * + * Therefore, we append the -include-runtime and -d flags to specify where + * to output the jarfile which we will run using `java -jar` + * + * TODO(supergrecko): Find a better fix than this bandaid for execution + */ + async handleInterpreting(key, executeParameters) { + const alteredKey = { + ...key, + options: ['-include-runtime', '-d', 'example.jar'], + }; + const compileResult = await this.getOrBuildExecutable(alteredKey); + executeParameters.args = [ + '-Xss136K', // Reduce thread stack size + '-XX:CICompilerCount=2', // Reduce JIT compilation threads. 2 is minimum + '-XX:-UseDynamicNumberOfCompilerThreads', + '-XX:-UseDynamicNumberOfGCThreads', + '-XX:+UseSerialGC', // Disable parallell/concurrent garbage collector + '-cp', + compileResult.dirPath, + '-jar', + 'example.jar', + // -jar <jar> has to be the last java parameter, otherwise it will use + // our java parameters as program parameters + ...executeParameters.args, + ]; + const result = await this.runExecutable(this.javaRuntime, executeParameters, compileResult.dirPath); + result.didExecute = true; + result.buildResult = compileResult; + return result; + } + getArgumentParser() { return KotlinParser; } |