aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers')
-rw-r--r--lib/compilers/kotlin.js41
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;
}