You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't set jvm-target option on Kotlin Compiler #84
[kscript] [ERROR] compilation of './MyScript.kt' failed
MyScript.kt:53:68: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
...
As far as I can tell, there's currently no way to override the JVM target. Am I missing a configuration option? If not, could it be added (ability to set -jvm-target specifically or maybe a hook to kotlinc_opts)?
#!/usr/bin/env kscript
@file:DependsOn("org.jetbrains.kotlin:kotlin-reflect:1.1.60")
@file:DependsOn("com.github.kittinunf.fuel:fuel-jackson:1.12.0")
importcom.fasterxml.jackson.databind.DeserializationFeatureimportcom.fasterxml.jackson.databind.ObjectMapperimportcom.fasterxml.jackson.module.kotlin.jacksonObjectMapperimportcom.github.kittinunf.fuel.Fuelimportcom.github.kittinunf.fuel.jackson.responseObjectval mapper:ObjectMapper= jacksonObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
data classUser(valid:String, valname:String)
funmain(args:Array<String>) {
val (_, _, result) =Fuel.get("https://jsonplaceholder.typicode.com/users").responseObject<User>()
}
running ./MyScript.kt produces:
[kscript] [ERROR] compilation of './MyScript.kt' failed
MyScript.kt:18:81: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
val (_, _, result) = Fuel.get("https://jsonplaceholder.typicode.com/users").responseObject<User>()
^
The kotlinc default is 1.6 for a reason (I guess/hope), so simply using 1.8 as kscript default feels a bit inconsistent. However, the main motivation for using 1.6 is most likely android compatibility, which does not matter with respect to kscript, so maybe using 1.8 is not so wrong after all.
At the moment compiler flags used by kscript can't be adjusted. We could add another directive (e.g. named @CompilerOpts) to allow the user to adjust compiler behavior if needed.
@holgerbrandl I think that makes sense. There's @KotlinOpts to configure runtime flags, so something like @CompilerOpts or @KotlincOpts would be nice to configure compiler flags
Activity
holgerbrandl commentedon Jan 6, 2018
Could you attach an example?
jmmk commentedon Jan 6, 2018
MyScript.kt:running
./MyScript.ktproduces:holgerbrandl commentedon Jan 8, 2018
Same for me.
The
kotlincdefault is 1.6 for a reason (I guess/hope), so simply using 1.8 askscriptdefault feels a bit inconsistent. However, the main motivation for using 1.6 is most likely android compatibility, which does not matter with respect tokscript, so maybe using 1.8 is not so wrong after all.At the moment compiler flags used by kscript can't be adjusted. We could add another directive (e.g. named
@CompilerOpts) to allow the user to adjust compiler behavior if needed.What do you think?
jmmk commentedon Jan 8, 2018
@holgerbrandl I think that makes sense. There's
@KotlinOptsto configure runtime flags, so something like@CompilerOptsor@KotlincOptswould be nice to configure compiler flagsjasoet commentedon Feb 1, 2018
+1
sail-y commentedon Feb 7, 2018
+1