Using JSR223, I have code that worked well in 1.4....
# scripting
t
Using JSR223, I have code that worked well in 1.4. Now with 1.6.10 I'm getting: javax.script.ScriptException: ERROR Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option (ScriptingHost6cabebe2_Line_0.kts51)
I've now trying to figure out some way to either put
Xjvm-default=all
into the ScriptEngine returned by
ScriptEngineManager().getEngineByExtension("kts")
and failing miserably. I've also tried to make sure the class I use do not have any default jvm methods, but the main purpose of the script is returning a
Comparator
(which is an interface with default methods). Code is something similar to this: Main.kt
Copy code
interface Sorter {
    val comparator: Comparator<Foobar>
}

fun getSorter() {
     ScriptEngineManager().getEngineByExtension("kts")!!.eval("script.kts") as Sorter
}
script.kts
Copy code
object : Sorter {
    override val comparator: Comparator<Foobar>
        get() = compareByDescending<Foobar> { it.foo }
}
I've also tried (without success) to try to add
@file:CompilerOptions("-Xjvm-default=all")
in the script. What am I missing?
i
Can you file an issue, please - https://kotl.in/issue?
t
Sure, so it's a probable issue and not just me configuring it poorly?
i
We’ll investigate.
🙇 1
TIA
🙏 1
For anyone following this conversation: The bug was updated. It has nothing to do with
Comparator
and everything to do with
-Xjvm-default=all
that we compile our Kotlin code with