Skip to content

Commit 6189016

Browse files
hex539austrin
authored andcommitted
Stub support for kotlin (jvm) target
Code is compiled into a monolithic jar including all dependencies and run using the kotlin command (/usr/bin/java can't see the kotlin runtime libraries). File extensions: - *.kt (kotlin) - *.ktm (kotlin module) - *.kts (kotlin script) mainclass for kotlin is FilenameKt. This could also be retrieved from the jar file with a command like: unzip -c binary.jar META-INF/MANIFEST.MF \ | dos2unix \ | egrep ^Main-Class: \ | cut -d: \ --complement -f1
1 parent caeefd0 commit 6189016

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fun main(args: Array<String>) {
2+
val words = if (args.size == 0) arrayOf("Hello", "World!") else args
3+
System.`out`.println(words.joinToString(separator = " "))
4+
}

problemtools/languages.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ javascript:
141141
compile: '/usr/bin/js24 -c {files}'
142142
run: '/usr/bin/js24 "{mainfile}"'
143143

144+
kotlin:
145+
name: 'Kotlin'
146+
priority: 250
147+
files: '*.kt *.ktm *.kts'
148+
compile: '/usr/bin/kotlinc -jvm-target 1.8 -d {path}/ -- {files}'
149+
run: '/usr/bin/kotlin -J-XX:+UseSerialGC -J-Xss64m -J-Xms{memlim}m -J-Xmx{memlim}m -cp {path}/ {mainclass}'
150+
144151
objectivec:
145152
name: 'Objective C'
146153
priority: 300

problemtools/run/source.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ def __init__(self, path, language, work_dir=None, include_dir=None):
6969
re.IGNORECASE)), None)
7070
if self.mainfile is None:
7171
self.mainfile = self.src[0]
72+
7273
self.mainclass = os.path.splitext(os.path.basename(self.mainfile))[0]
74+
if self.language.name == 'Kotlin':
75+
self.mainclass = self.mainclass.capitalize() + 'Kt'
76+
7377
self.binary = os.path.join(self.path, 'run')
7478

7579

@@ -123,7 +127,7 @@ def get_runcmd(self, cwd=None, memlim=1024):
123127

124128
def should_skip_memory_rlimit(self):
125129
"""Ugly hack (see program.py for details)."""
126-
return self.language.name in ['Java', 'Scala']
130+
return self.language.name in ['Java', 'Scala', 'Kotlin']
127131

128132

129133
def __str__(self):

0 commit comments

Comments
 (0)