JavaScript

A script engine wrapper for dynamically compiling and evaluating Java source code.

Supports adding named variables with type parameters, import declarations, and configurable isolation levels. Note that Java cannot have a null global context.

Note: Java cannot have a null global context.

See also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Generates Java import statements for all registered import classes.

Link copied to clipboard

Generates Java-style public field declarations for all registered variables.

Functions

Link copied to clipboard
open fun add(name: String, value: Any, vararg types: KType)
Link copied to clipboard
fun assignIsolation(isolation: Isolation)

Sets the isolation level for the underlying JavaScriptEngine.

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun eval(expr: String, action: String = "", verbose: Boolean = false): Any
Link copied to clipboard
fun evalScript(script: String, verbose: Boolean = false): Any

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

Link copied to clipboard
fun <T> import(clazz: Class<T>)

Registers a Java class to be imported in generated scripts.

Link copied to clipboard
open override fun params(name: String, types: Array<out KType>): String
Link copied to clipboard
fun resetContext(nullGlobalContext: Boolean)