Olaf Gottschalk
02/18/2026, 7:23 AM2.3.20-Beta2 and running my tests, I hit hard errors when the script compiler compiles my code - it does not work at all and fails with these kinds of error messages:
ERROR Cannot access built-in declaration 'kotlin.Any'. Ensure that you have a dependency on the Kotlin standard library.
ERROR Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library.
ERROR Cannot access class 'kotlin.Pair'. Check your module classpath for missing or conflicting dependencies.
ERROR Unresolved reference 'run'.
and many more of the same kind. Something is wrong with the standard library.
Plus: my tests with deliberate compile errors show problems with the generated ScriptDiagnostic s which do not contain the correct location anymore, just null.
Is there any quick tip for me on what might be going wrong? THANKS!ilya.chernikov
03/10/2026, 10:04 AM-Xuse-fir-lt=false).
But I do not understand yet, how it might lead to the problems that you're seeing.
Could you please, show me how you're compiling and running your custom scripts in your tests?Olaf Gottschalk
03/10/2026, 11:30 AM2.3.10 to 2.3.20-RX2 - and sadly: it does not work. I get the same errors as mentioned, e.g. Cannot access built-in declaration 'kotlin.Any'. Ensure that you have a dependency on the Kotlin standard library.Olaf Gottschalk
03/10/2026, 11:31 AMfun evalTransformation(sourceCode: SourceCode): ResultWithDiagnostics<EvaluationResult> {
val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<TraLaScript>()
return BasicJvmScriptingHost().eval(sourceCode, compilationConfiguration, null)
}Olaf Gottschalk
03/10/2026, 11:32 AMTraLaScript annotation class:
@KotlinScript(
displayName = "TraLa Script",
fileExtension = TRALA_FILE_EXTENSION,
compilationConfiguration = TraLaScriptConfiguration::class
)
abstract class TraLaScriptOlaf Gottschalk
03/10/2026, 11:34 AMcompilationConfiguration I do some magic with the classpath that is restricted to only a few allowed classes:
object TraLaScriptConfiguration : ScriptCompilationConfiguration(
{
defaultImports(traLaDefaultImports)
ide {
acceptedLocations(ScriptAcceptedLocation.Everywhere)
}
refineConfiguration {
beforeCompiling {
it.script.scanForbiddenConstructs(blackListRegex)?.let { found ->
makeFailureResult(
found.map { (location, what) ->
"Do not use '$what': forbidden in TraLa".asErrorDiagnostics(locationWithId = location)
})
} ?: it.compilationConfiguration.asSuccess()
}
}
jvm {
jvmTarget("17")
compilerOptions(
"-jvm-default=no-compatibility",
"-Xcontext-parameters",
"-Xreturn-value-checker=full",
)
fun List<*>?.log(msg: String) = msg + this?.joinToString("\n", prefix = "\n")
val classPath =
scriptCompilationClasspathFromContextOrNull(*requiredClasspath)?.also {
logger.debug { it.log("Using restricted transformation script classpath: ") }
} ?: scriptCompilationClasspathFromContextOrNull(wholeClasspath = true).also {
logger.error { it.log("Unable to restrict transformation scripting classpath. Using whole classpath: ") }
}
updateClasspath(classPath)
}
}
)Olaf Gottschalk
03/10/2026, 11:35 AMOlaf Gottschalk
03/10/2026, 11:37 AMprivate val requiredClasspath = arrayOf(
"transformation-dsl",
"jackson-annotations",
"kotlin-xml-builder",
)
When I comment out this restriction, it works again...Olaf Gottschalk
03/10/2026, 11:45 AMrestrictedClasspath key names and adds KotlinJars.kotlinScriptStandardJars.map { it.name } to it, et voila: works!
val kotlinJars = KotlinJars.kotlinScriptStandardJars
val keyNames = requiredClasspath + kotlinJars.map { it.name }
val classPath =
scriptCompilationClasspathFromContextOrNull(*keyNames)?.also {
logger.debug { it.log("Using restricted transformation script classpath: ") }
} ?:
scriptCompilationClasspathFromContextOrNull(wholeClasspath = true).also {
logger.error { it.log("Unable to restrict transformation scripting classpath. Using whole classpath: ") }
}
updateClasspath(classPath)
So, my question boils down to: WHY do I explicitly have to add the Kotlin Standard jars names to the keyNames in version 2.3.20? Why is that not needed in 2.3.10?Olaf Gottschalk
03/10/2026, 11:49 AMlocation... one of my very basic tests put an unknown identifier straight into the code and uses the `ScriptDiagnostic`s location property to highlight the error visually... but. In 2.3.20 the location remains null... 😞Olaf Gottschalk
03/10/2026, 11:56 AMfoobar
So, there is just this ONE token, completely unknown. When I compile this with 2.3.10 the ScriptDiagnostic shows a location of Location(start=Position(line=1, col=1, absolutePos=null), end=Position(line=1, col=7, absolutePos=null)) - the same compilation with 2.3.20-RC2 has a location of simply null!Olaf Gottschalk
03/10/2026, 11:57 AMilya.chernikov
03/10/2026, 1:05 PMSo, my question boils down to: WHY do I explicitly have to add the Kotlin Standard jars names to the keyNames in version 2.3.20? Why is that not needed in 2.3.10?Oh, I see. I need to investigate, why exactly it happened, but I can imagine. The classloader structure and classpath extraction scheme are changed indeed. I created an issue to investigate it. Thanks for pointing out!
ilya.chernikov
03/10/2026, 1:08 PM-Xuse-fir-lt=false and -Xuse-fir-lt=true?Olaf Gottschalk
03/10/2026, 1:09 PMOlaf Gottschalk
03/10/2026, 1:10 PM2.4.0-dev cannot be found...Olaf Gottschalk
03/10/2026, 1:13 PM-Xuse-fir-lt=false and -Xuse-fir-lt=true with 2.3.20-RC2 does not change anything regarding the error location. It stays null.ilya.chernikov
03/10/2026, 1:28 PMWhat's the correct version to use? 2.4.0-dev cannot be found...You'll need to add the maven repo "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev", and then use e.g. "2.4.0-dev-5881".
Olaf Gottschalk
03/16/2026, 12:59 PMrepositories like this:
repositories {
maven { url = uri("<https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev>") }
mavenCentral()
}
But still, it cannot use version 2.4.0-dev-5881: Plugin [id: 'org.jetbrains.kotlin.jvm', version: '2.4.0-dev-5881'] was not found in any of the following sources:Olaf Gottschalk
03/17/2026, 5:38 AMnull in the field location?Olaf Gottschalk
03/17/2026, 6:05 AMilya.chernikov
03/17/2026, 10:43 AMOlaf Gottschalk
03/17/2026, 12:32 PMilya.chernikov
03/20/2026, 9:54 AM-no-stdlib in compiler options, the stdlib is picked up automatically, and compilation will fail if it is not found. And this is the behavior I observe in my tests too.
My testbed is the libraries/scripting/jvm-simple-script test project in the kotlin repo. The org.jetbrains.kotlin.script.examples.jvm.simple.host.evalFile contains the code that calls
dependenciesFromCurrentContext(
"scripting-jvm-simple-script" /* script library jar name */
)
which is basically the same as your use of requiredClasspath. If I debug it, I see that after this part is executed, the configuration's dependencies property contains only a single scripting-jvm-simple-script.jar, which is expected. Kotlin stdlib is added in the background, much like with the regular kotlin files compilation.
And test passes, of course.
I also tried to modify this project to resemble your definition more precisely, and the result is the same.
So, I'm out of ideas for now. If you can make some repro project, that would be very helpful.Olaf Gottschalk
03/20/2026, 4:17 PMupdateClasspath(KotlinJars.kotlinScriptStandardJars) , it will show the problem with the missing stdlib. In Kotlin 2.3.10 (and before), you never needed to explicitly add the Kotlin StdLib...Olaf Gottschalk
03/25/2026, 10:17 AMilya.chernikov
03/25/2026, 1:57 PMilya.chernikov
03/25/2026, 1:59 PMOlaf Gottschalk
04/16/2026, 12:59 PM$b45e718d. Does that make any sense to you? Cheers!ilya.chernikov
04/17/2026, 9:04 AMOlaf Gottschalk
04/17/2026, 9:05 AM