Olaf Gottschalk
04/20/2023, 3:31 PMeval
on the script engine.
After the update to Kotlin 1.8.20 when my scripts contain String
operations such as
val x = "Hello"
x.uppercase()
I get this horrible exception:
error: cannot access '<http://java.io|java.io>.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies
The point is: I did not change anything there. I am using good old JVM 11 (due to some 3rd party libs that are very slow to upgrade, thanks go out to to SAP and IBM)
Looking at the Gradle dependency tree reveals nothing out of the ordinary, every Kotlin dependency is at 1.8.20. I do not see any conflicts there. And of course, my static code compiles just fine, it is just the dynamic code compiled at runtime that now complains.
Does anybody have any hints for me on how to check & proceed?
THANKS!ilya.chernikov
04/24/2023, 10:08 AMOlaf Gottschalk
04/24/2023, 10:40 AMilya.chernikov
04/24/2023, 11:06 AMjava.home
system properties is not processed properly. I just need to understand which path is missing the action. So if you'll show me the relevant part of the stacktrace and/or the code that set up script compilation, I might already be able to guess the reason and maybe offer a workaround.Olaf Gottschalk
04/24/2023, 11:30 AMilya.chernikov
04/24/2023, 2:52 PM-jdk-home
to the compiler instead.
But how to do it, depends on how you're launching scripts.Olaf Gottschalk
04/24/2023, 3:05 PMilya.chernikov
04/24/2023, 3:16 PMOlaf Gottschalk
04/24/2023, 3:27 PMilya.chernikov
04/25/2023, 6:37 AMBasicJvmScriptingHost
or maybe something else?Olaf Gottschalk
04/25/2023, 2:39 PMilya.chernikov
04/26/2023, 2:41 PMkotlin-scripting-jsr223
jar, you may try to set experimental kotlin.jsr223.experimental.resolve.dependencies.from.context.classloader
system property to "true", before requesting an engine. It changes the way how the context dependencies are processed in the engine, and it may help.Olaf Gottschalk
04/26/2023, 3:21 PMilya.chernikov
04/27/2023, 10:07 AMOlaf Gottschalk
04/27/2023, 10:08 AMkotlin-script-util
jar. In order to register this per config, I had a META-INF/services/javax.script.ScriptEngineFactory
file which references this engine factory.
Up until Kotlin 1.8.10 this obsolete engine factory still worked properly, so I in fact never noticed (nor knew) anything about it.
Since Kotlin 1.8.20 it should NOT be used anymore. The new implementation is automatically registered when depending on kotlin-scripting-compiler-embeddable
and kotlin-scripting-jsr233
.
So, removing the obsolete dependency and removing the META-INF
file solved my issue!
Thanks again, Ilya!ilya.chernikov
05/02/2023, 3:34 PMkotlin-script-util
should have been replaced with other APIs and jars quite long ago, but in 1.8.20 we accidentally broke it, and since it is long obsolete - have no intention to fix. We will remove it from publishing instead in one of the next versions.