JSR 223 seems to be problematic in recent Kotlin versions while it worked on 1.6.
In particular when I try to execute this code:
package kotlinLab
import javax.script.ScriptEngineManager
class kotlinLab {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val script = "3 + 5"
val engine = ScriptEngineManager().getEngineByName("kotlin")!!
val result = engine.eval(script)
println("The result of the '$script' is '$result'")
}
}
}
I get the following error:
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
WARNING Lombok Kotlin compiler plugin is an experimental feature. See: Stability of Kotlin components | Kotlin.
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
WARNING Lombok Kotlin compiler plugin is an experimental feature. See: Stability of Kotlin components | Kotlin.
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)
Can anyone understand what happens?