I try to use JSR223 Scripting with the following code:
package kotlinLab
import javax.script.ScriptEngineManager
class kotlinLab {
companion object {
@JvmStatic
fun main(args: Array) {
val script = "3 + 5"
val engine = ScriptEngineManager().getEngineByName("kotlin")!!
val result = engine.eval(script)
println("The result of the '$script' is '$result'")
}
}
}
However the result is disappointed:
WARNING: Using incubator modules: jdk.incubator.vector
Exception in thread “main” javax.script.ScriptException: ERROR Unable to initialize repl compiler:
DEBUG Using JVM IR backend
WARNING Using new faster version of JAR FS: it should make your build faster, but the new implementation is experimental
ERROR @NotNull method org/jetbrains/kotlin/config/CompilerConfiguration.getNotNull must not return null: java.lang.IllegalStateException: @NotNull method org/jetbrains/kotlin/config/CompilerConfiguration.getNotNull must not return null: java.lang.IllegalStateException: Unable to initialize repl compiler:
DEBUG Using JVM IR backend
WARNING Using new faster version of JAR FS: it should make your build faster, but the new implementation is experimental
ERROR @NotNull method org/jetbrains/kotlin/config/CompilerConfiguration.getNotNull must not return null: java.lang.IllegalStateException: @NotNull method org/jetbrains/kotlin/config/CompilerConfiguration.getNotNull must not return null
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.asJsr223EvalResult(KotlinJsr223JvmScriptEngineBase.kt:104)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:63)
at kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl.compileAndEval(KotlinJsr223ScriptEngineImpl.kt:95)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
at kotlinLab.kotlinLab$Companion.main(KotlinLab.kt:19)
at kotlinLab.kotlinLab.main(KotlinLab.kt)
JSR223 worked well on previous Kotlin releases, but fails in recent ones.
Which is the problem?