Repository navigation
Releases
2026.0.0
2026.0.0 (2026.09.16)
Java access is a library too, and --no-java is gone. Java, JavaImporter, Packages and the package roots java/javax/javafx/com/org/edu are org.monflabs.nashorn.libs.JavaLibrary. An engine that was not given it has no way for a script to name a Java class.
--no-java, its-njalias,ScriptEnvironment._no_javaand the builder'sjava(boolean)are removed. The option deleted those properties again after nasgen had written them into every global's map, which is the wrong way round: not installing them is the answer, and saying nothing is now the safe outcome rather than the dangerous one.ClassFilteris unaffected and still decides class by class whatJava.typemay resolve. The two compose: the library decides whether a script can name Java classes at all, the filter decides which. Leaving the library out is not a sandbox on its own - a Java object the embedder puts in the bindings is still a Java object, with its methods reachable.- The repair for an engine that relied on the default is
.library(new JavaLibrary()). The repair for a--no-javaengine is to delete the option.
Nashorn's own globals are a library now. print, load, loadWithNewGlobal, readLine, readFully, JSAdapter and __FILE__/__DIR__/__LINE__ are no longer installed on every realm. They are org.monflabs.nashorn.libs.NashornLibrary, contributed to the builder like fetch and the timers, and a bare engine has none of them. This breaks a script that calls print on an engine built as before; the repair is one line, .library(new NashornLibrary()).
- An embedder hands a script engine to code it does not control, and every global is surface. Every realm used to carry
load, which reads files and URLs, whether or not the embedder had a use for it, and taking it away meant deleting properties after the fact. An engine now starts with what ECMAScript defines, and the rest is a decision. exitandquitare not in the library. They callSystem.exit, which is no business of a script embedded in an application, soGlobal.addExitBuiltinsholds them and only the shell installs them - on any run, a script file as much as the prompt, since choosing an exit code is what a command line does.input/evalinputstay the prompt's alone.- Java access is unchanged.
Java,Packages,JavaImporterand the package roots are still installed by default and still removed by--no-java, a switch that predates this and that embedders already use. Putting them behind the library as well would have given one job two answers. - The shell and the playground install the library themselves - a command line without
printis not a command line - and so do the script-test harness and the test262 runner, which needsprintbecause the suite's owndoneprintHandle.jsreports through it.
fetch has a response timeout. A request in flight is a pending operation on the realm's event loop, so eval returns only when it finishes - and nothing could make it finish. There is no AbortSignal, and racing the promise against a timer settles the promise while leaving the request, and the loop, exactly where they were. A server that accepted a connection and then said nothing kept an embedder waiting indefinitely.
FetchLibrarynow bounds every request atDEFAULT_RESPONSE_TIMEOUT, 30 seconds, matching the client's existing connect timeout. On expiry the promise rejects with aTypeErrorlike any other network failure, and the pending operation ends.new FetchLibrary(Duration)sets a ceiling of your own;new FetchLibrary(null)removes it, which is what the WHATWG specification describes and is reasonable for a host that supervises its own requests. The value is bound into the installed builtin, so two engines configured differently do not share one.FetchLibraryTest.aStalledServerDoesNotPinTheEventLooppins it against a local server that accepts and never answers - without the ceiling that test does not fail an assertion, it never returns.
Scripting mode and jjs are gone. The -scripting option and every syntax and global that hung off it are removed. The backquote exec syntax had already gone to template literals in 2026.0.0, and ECMAScript covers the rest: a template literal is a heredoc with interpolation, String.raw is one without, and // is a comment everywhere.
- Removed syntax: heredocs (
<<EOF,<<<EOF),#line comments, and${expr}interpolation inside double-quoted strings. - Removed globals:
$EXECwith its$OUT/$ERR/$EXITresult globals and theCommandExecutorbehind them,$ENV,$OPTIONS,$ARG, andecho. - Removed API:
NashornScriptEngineBuilder.scripting(boolean)and the parser API's"-scripting"option. readLineandreadFullywere the two genuinely useful pieces and survive as unconditional globals on every realm (IOFunctions, installed byGlobal.initIOFunctions), so a shell script need not reach for Java to read a file or a line.samples/exec.jsshows how to run a process overProcessBuilder.- The
shellmodule - thejjsREPL, never published, and the one piece that reached into JDK-internaljdk.internal.le/jdk.internal.edand so constrained which JDKs could build the reactor - is deleted.org.monflabs.nashorn.tools.Shellinnashorn-coreruns scripts, reads standard input and has a prompt of its own, and carries the--std-librariesswitch jjs used to own. The reactor is six modules.
Optimistic types are on by default. --optimistic-types shipped off through 2026.0.0, inherited from upstream 15.x, where the ES2026 engine runs Octane's crypto and navier-stokes about five times and richards about three times slower than it does with them on. With the conformance suite passing in that mode - every execution, the eight Annex B indirect-eval cases the pessimistic run still lists included - the default is flipped. An embedder gets the deoptimising, narrow-typed code without asking, and a run-once script that never gets hot can pass --optimistic-types=false (optimisticTypes(false) on the builder) to skip the recompiles.
Two things follow the flip:
- Eager compilation needs pessimistic code, so
--lazy-compilation=falsealone now turns optimistic types off rather than failing. Named together with an explicit--optimistic-types=trueit is still the error it was (Options.isSettells a named option from a defaulted one). Test262Runnerruns the default mode by default, againsttest262-expectations.txt, which lists nothing.-Dnashorn.test262.optimistic=falseruns the pessimistic slice againsttest262-expectations-pessimistic.txt, where the eight live. CI runs both.
The flip also showed that the core suite's test-optimistic execution had only ever run the engine default - TestFinder adds an explicit --optimistic-types=false for the pessimistic execution and nothing for the other - so it had been a second pessimistic run. It is a real optimistic run now, and its first real run found three more optimistic-only defects, fixed here:
- A
constbound anew in each turn of a for-of's per-iteration scope could not widen its storage type (a const is neither writable nor configurable, which is what the dual-field type change asked), so a closure over the second turn read0for"x". ++/--on aletread in its temporal dead zone typed the operationundefined, which no local can hold (an assertion), where ToNumber makes it a number.- A value of a hidden class - a Java lambda - answering an optimistic call site was given a
Typewhose name is not a descriptor the JVM accepts.
Performance. A profile of Octane on the ES2026 engine put a quarter of all samples in the generic arithmetic path - the ES2020 BigInt-aware ScriptRuntime operators coerced each Object-typed operand through the whole ToPrimitive chain and boxed a Double twice - and most allocated bytes in the char[] the Joni regexp backend copied from the subject string on every exec. Both are fixed: the operators and relationals take a number-box fast path, and a compiled regexp reuses one char[] per subject.
Alongside them:
- A lock-free regexp cache keyed by a structured key; the old weak-keyed one mostly missed.
- Geometric spill growth for wide objects, and
useDualFieldsresolved once per class. - String- and symbol-keyed
getwithout a doubleToPrimitive, and no string key built for an array miss. - One copy fewer per
sort, and a for-of loop that steps a built-in array iterator directly. Promise.prototype.thenreading the intrinsic%Promise%rather than the global property.- Shared (copy-on-write) block symbol tables across the compilation phases, substring-and-intern identifiers in the lexer, and lock-free named-operation interning in the linker.
Eight perf-gate scripts were added so the gate sees these paths at all. The measured gains, against the previous revision and against OpenJDK Nashorn 15.7, are in doc/nashorn/internals/performance.md.
Optimistic types: two fixes, and test262 in that mode. A deoptimising recompilation that threw left every thread that then called the function waiting forever on CompiledFunction's monitor: the switch point it had invalidated was never replaced, and notifyAll was only reached on success. A failed recompile now installs a fresh switch point, always notifies, and the waiters use a bounded wait that honours interruption.
What was throwing: the rest-of method of a function with a block-scoped for…of variable was rejected by the JVM ("Invalid index N in LocalVariableTable"). A continuation enters through a jump to its continuation point, so the body before it is dead code that the classfile library patches out, computing max_locals from wha...