eval

fun eval(expr: String, action: String = "", verbose: Boolean = false): Any?

Evaluates a Java expr (optionally preceded by an action statement block) inside a generated Main.getValue() method, prepending any registered imports and variable declarations.

Variables added with add are bound first, including any added after an earlier evaluation.

Return

the result of evaluating expr, or null if it evaluates to null

Parameters

expr

the Java expression whose value is returned

action

optional Java statements executed before expr is evaluated

verbose

if true, logs the generated script before evaluation

Throws

if expr or action contains a literal JVM-termination call, or fails to compile or run