Registers GraalJS as a scripting
language with Strange Eons through the org.strangeeons.scripts.ScriptLanguage
SPI, giving plug-in authors current ECMAScript (classes with private fields,
optional chaining, ??, ES modules, Intl, etc.) alongside the built-in
Strange Rhino engine.
When a plug-in's eons-plugin manifest declares script-language = ecmascript,
SE looks up this implementation via ServiceLoader and runs the plug-in's
script in a GraalJSSession (one polyglot Context per plug-in, all sharing
one process-wide Engine).
The id is not javascript because SE reserves that value (any case), along
with a missing script-language, for Strange Rhino.
Pre-release. Depends on the unreleased script-language SPI,
org.strangeeons:strange-eons-script-api, published as a snapshot.
org.strangeeons.graaljs.GraalJSLanguage—ScriptLanguagewith idecmascript(display name "JavaScript"), extension.mjs.org.strangeeons.graaljs.GraalJSSession—ScriptSessionover a GraalJSContext..mjssources are evaluated as ES modules and their exports are callable; other sources are classic scripts whose global functions are callable..selibrarypackaging via strange-eons-gradle-plugin (GraalJS/Truffle merged in, not relocated;META-INF/servicesmerged).
In the plug-in bundle's eons-plugin:
script-language = ecmascript
res://mygame/plugin.mjsThe res:// prefix is required for .mjs entries: SE only auto-detects
.js names as scripts. A .js entry also works and is evaluated as a
classic script.
plugin.mjs:
const JOptionPane = Java.type('javax.swing.JOptionPane');
export const getName = () => 'Hello GraalJS';
export const getDescription = () => 'Minimal modern-JS plug-in';
export const getVersion = () => 1.0;
export function run() {
JOptionPane.showMessageDialog(null, `Hi from ${getName()}`);
}The host resolves the same lifecycle names as for Rhino plug-ins
(initialize, getName, getDescription, getVersion, getPluginType,
run, hide, isShowing, isUsable, getDefaultAcceleratorKey,
unload). PluginContext is bound as a global.
- No SE script library.
useLibrary,Eons,Editor,sprintf, the$/@/#settings syntax and everything else in SE's Rhinolibraries/are Rhino-specific and are not loaded. Scripts use Java interop (Java.type) directly. - Bundled modules only.
import "strange-eons/ui"loadsstrange-eons/ui.mjsfrom the classpath of this plug-in, and those modules can import each other relatively. Other specifiers use the file system, soimport './util.mjs'in a plug-in's own script still fails. - Host classes come from this plug-in's classloader chain (the plug-in
bundle → SE library tier → application). Classes in other plug-ins'
isolated bundles are not visible to
Java.type.
Requires JDK 25. The SPI resolves from the Central Portal snapshot repository:
./gradlew test # unit tests against GraalJS on the classpath
./gradlew bundleTest # loads the built .selibrary in an isolated classloader
./gradlew check # both
./gradlew sePlugin # build build/libs/GraalJSLanguage.selibrary
./gradlew assemble copies the bundle into the Strange Eons user plug-ins
folder if it exists (~/.StrangeEons3/plug-ins, %APPDATA%\StrangeEons3\plug-ins,
or $STRANGE_EONS_USER_DIR/plug-ins). Otherwise copy
build/libs/GraalJSLanguage.selibrary there by hand and restart SE.
GraalJS runs inside SE with no launch changes, but on JDK 25 the JVM prints warnings, and two of them are about access that a future JDK will deny by default. SE's launcher should pass:
| Option | Why | Without it |
|---|---|---|
--enable-native-access=ALL-UNNAMED |
Truffle calls System.load for its native support library (JEP 472). |
Warning today; a future JDK blocks the call and the engine fails to start. |
--sun-misc-unsafe-memory-access=allow |
Truffle uses sun.misc.Unsafe memory access (JEP 498). |
Warning today; the default moves to deny in a later JDK. |
-Dpolyglot.engine.WarnInterpreterOnly=false |
Silences Truffle's "fallback runtime" notice. | Cosmetic stderr warning on first use. |
These are the same options ./gradlew test and bundleTest run with, and
both suites run warning-free with them.
ALL-UNNAMED is broad: it grants native access to everything on the class
path and in plug-in classloaders, not just Truffle. It is the only form that
works while SE and its plug-ins run in unnamed modules.
On OpenJDK or Oracle JDK 25, Truffle uses its fallback runtime: JavaScript is interpreted and never JIT-compiled, so CPU-heavy scripts will be slower than on Strange Rhino. No launch flag changes this. Per GraalVM's embedding guide, the optimizing runtime is available only:
- On a GraalVM JDK 25 (Community or Oracle). SE would ship or launch on a GraalVM JDK instead of a stock one. Untested here: whether Truffle still picks the optimizing runtime when it is loaded from a plug-in classloader rather than the module path.
- Through polyglot isolates on a stock JDK: the engine runs in a separate
Native Image isolate with its own JIT and GC. This needs platform-specific
js-isolate*artifacts (js-isolate-communityexists only from 25.1), so the plug-in would need one bundle per OS and architecture.
The engine logs GraalJS <version> on <runtime> runtime once at INFO;
Interpreted means the fallback runtime.
- Bundle size. The fat JAR carries Truffle, the JS language, regex engine and ICU4J; expect tens of MB. Excluding the optimizing-runtime jars would shrink it but rule out JIT permanently.
- Version string.
Engine.getVersion()reports "Development Build" rather than 25.0.5 in this packaging.
The bundle is published only through the
Strange Eons registry,
not to Maven. CI keeps GraalJSLanguage.selibrary as a workflow artifact on
every build, building the script API from the default branch of
strange-eons/strange-eons.
To release, run ./gradlew release on a clean, pushed main: it sets the
release version in gradle.properties, tags it (e.g. 1.0.0) and bumps to the
next snapshot. Nothing is pushed; review, then git push --follow-tags. The
tag push attaches the bundle to a GitHub Release, and the registry picks it up
from the latest release.
TBD. GraalJS is UPL-1.0 / MIT; the Groovy plug-in uses Apache-2.0; SE core is MIT.