evalScript

fun evalScript(script: String, verbose: Boolean = false): Any?

Evaluates a raw Java script string, prepending any registered import declarations.

Each variable added with add is assigned to the public field of the same name in the script's class, so that class must declare a public, assignable field of a compatible type for every added variable.

Return

the result of the script evaluation, or null if the script evaluates to null

Parameters

script

the Java source code to evaluate

verbose

if true, logs the generated script before evaluation

Throws

if script contains a literal JVM-termination call, fails to compile or run, or a variable cannot be assigned to its field