KotlinScript
A script engine wrapper for dynamically evaluating Kotlin source code using the kts extension.
Stores the variables in a single ScriptVariables holder, the only JSR 223 binding, and generates Kotlin val declarations that read each one back and cast it to a type the script can name. bindings and __variables are reserved names. A value whose runtime class cannot be named, such as the private list class behind listOf(1, 2), is cast to its nearest public class or interface.
Common literal JVM-termination calls (System.exit, exitProcess, Runtime.getRuntime().exit/halt) are rejected on a best-effort basis via ScriptGuards. This is a convenience against accidental termination, not a security sandbox (see ScriptGuards) — run untrusted scripts in an isolated process or JVM.
close does nothing, because the Kotlin engine holds no resources to release.
Parameters
if true, sets the global scope bindings to null on initialization
See also
Properties
Generates Kotlin val declarations that retrieve every bound variable from the ScriptVariables holder and cast it to a type the script can name, with its type arguments.