I’ve configured the JSR-223 embedding and been able to run simple scripts. But the following script was surprising:
System.err.println("Hello from SLIME Kotlin!")
System.err.println("bindings.message = ${bindings["message"]}")
System.err.println("kotlin.Any() = " + kotlin.Any())
//kotlin.io.println("foo")
This produces the expected output for the first three lines, but the fourth line fails with:
Wrapped javax.script.ScriptException: error: unresolved reference: io kotlin.io.println("foo")
(println
by itself doesn’t work either.)
Is there some quirk of my embedding that could explain this, or is this a bug?
I had to build my own kotlin.script.classpath
in this environment, for example, and I might not have it right for all cases. It currently includes:
"kotlin-compiler.jar",
"kotlin-scripting-jvm.jar",
"kotlin-scripting-compiler.jar",
"kotlin-scripting-impl.jar",
"kotlin-script-util.jar",
"kotlin-script-runtime.jar"
Those JARs are also loaded into the JSR-223-invoking ClassLoader
. The default JSR-223 instantiation method is not used; the Kotlin JSR223 factory is instantiated via its constructor.