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. The Java engine needs a global scope: resetForReuse always keeps one, while resetContext(true) removes it, after which evalScript fails.
Variable declarations use fully-qualified type names, so they need no imports. A value whose runtime class cannot be named, such as the private list class behind listOf(1, 2), is declared as its nearest public class or interface.
Common literal JVM-termination calls (System.exit, 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 Java engine holds no resources to release.
See also
Properties
Functions
Sets the isolation level for the underlying JavaScriptEngine.
Evaluates a raw Java script string, prepending any registered import declarations.
Resets the context and also clears the imports and restores the default isolation, so the next borrower from a pool starts clean.