ScriptRunnerBridge

class ScriptRunnerBridge @JvmOverloads constructor(classpathFilter: (File) -> Boolean? = null)(source)

Evaluates Kotlin scripts with the Kotlin scripting host, keeping the state of a session across calls so that successive snippets share declarations.

Unlike JSR-223 (deprecated in Kotlin 2.2.0), this drives the REPL API of the scripting host ([JvmReplCompiler] and [JvmReplEvaluator]). Every [eval] compiles a snippet against the declarations of the previous snippets and evaluates it on top of them. The script classpath is derived from the current context, so snippets can reference the SMILE libraries and any other dependency of the hosting application.

This class is not thread safe; callers must serialize access.

Author

Haifeng Li

Constructors

Link copied to clipboard
constructor(classpathFilter: (File) -> Boolean? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun close()

Shuts down the session and frees the compiler resources.

Link copied to clipboard

Evaluates a snippet of Kotlin code.

Link copied to clipboard
fun reset()

Discards all previously defined variables, keeping the session usable. It is equivalent to restart.

Link copied to clipboard
fun restart()

(Re)starts the session, discarding all previously defined variables.

Link copied to clipboard

Returns the variables defined by the evaluated snippets so far.