Skip to content

GraalJS Compatibility #425 - #426

Draft
rymsha wants to merge 1 commit into
masterfrom
issue-425
Draft

GraalJS Compatibility #425#426
rymsha wants to merge 1 commit into
masterfrom
issue-425

Conversation

@rymsha

@rymsha rymsha commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #425

Java package globals

smartRequest.ts matched connection errors with the Nashorn java.* package
globals (java.net.ConnectException, java.net.SocketTimeoutException,
java.lang.NullPointerException). Those globals are a Nashorn feature that
GraalJS only exposes under nashorn-compat, so the instanceof checks break once
that escape hatch is gone. They are now hoisted, constant Java.type(...)
lookups (standard GraalJS interop — XP configures allowHostClassLookup),
exactly as the issue prescribes. app-explorer reaches this same file through
its symlinks/lib-explorer symlink, so it is fixed there too.

Tests on both engines

Added the dual-engine wiring from the issue (mirroring enonic/lib-sql#154):
testRuntimeOnly org.graalvm.polyglot:js and a testGraalJs task that runs
alongside the Nashorn test task via check. The new SmartRequestTest
(ScriptRunnerSupport) loads the compiled smartRequest bundle and drives
every catch branch — ConnectException / SocketTimeoutException /
NullPointerException / unhandled — plus the happy path.

Verified locally with the platform built from
enonic/xp@claude/graaljs-support-limitations-pzu6z8 to mavenLocal (GraalVM CE 25):

  • :test (Nashorn) — 5/5 green
  • :testGraalJs (GraalJS) — 5/5 green
  • npm test (Jest) — 542/542 green; tsc --noEmit clean

Draft

Needs the ScriptRunnerSupport fix from enonic/xp#12198, hence
xpVersion=8.1.0-SNAPSHOT. CI testGraalJs stays red until #12198 is merged
and a fresh 8.1.0-SNAPSHOT is published
— on the currently published snapshot
ScriptRunnerSupport.findTestNames() tears down the shared script executor
during test discovery, so the GraalJS run fails with
IllegalStateException / PolyglotEngineException before the assertions run
(the Nashorn :test run is unaffected). Kept as a draft until then.

Replace the Nashorn java.* package globals in smartRequest.ts with
hoisted Java.type(...) lookups so the HTTP error-handling branches
resolve under GraalJS, which does not expose java.* without the
nashorn-compat escape hatch.

Add dual-engine test wiring (testRuntimeOnly org.graalvm.polyglot:js
and a testGraalJs task wired into check, mirroring enonic/lib-sql#154)
plus a ScriptRunnerSupport test that loads the compiled smartRequest
bundle and exercises every catch branch on both Nashorn and GraalJS.
Requires xpVersion=8.1.0-SNAPSHOT (ScriptRunnerSupport fix from
enonic/xp#12198).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.28%. Comparing base (79ab638) to head (3517922).

Files with missing lines Patch % Lines
...resources/lib/explorer/http/client/smartRequest.ts 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #426      +/-   ##
==========================================
- Coverage   17.28%   17.28%   -0.01%     
==========================================
  Files         322      322              
  Lines       18741    18744       +3     
  Branches      697      741      +44     
==========================================
  Hits         3240     3240              
- Misses      15207    15208       +1     
- Partials      294      296       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rymsha

rymsha commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 3517922 (branch issue-425).

CI status (Gradle Build run):

Check Result
Coverage (Jest) + codecov ✅ pass
:npmCheck (tsc --noEmit) ✅ pass
:compileTestJava ✅ pass
:npmTest (Jest, 542) ✅ pass
:test (Nashorn, SmartRequestTest 5/5) ✅ pass
:testGraalJs (GraalJS, SmartRequestTest 5/5) ❌ fail — expected

:testGraalJs fails with java.lang.IllegalStateException at PolyglotEngineException.java:141 on all 5 tests — this is the ScriptRunnerSupport.findTestNames() executor-teardown bug fixed by enonic/xp#12198, triggered during test discovery (before any assertion runs), not a problem with this change. The dev-repo 8.1.0-SNAPSHOT resolves and the Nashorn :test runs the same 5 tests green.

Verified locally against the platform built from enonic/xp@claude/graaljs-support-limitations-pzu6z8 → mavenLocal (GraalVM CE 25): :test and :testGraalJs both 5/5 green. CI :testGraalJs will go green once #12198 is merged and a fresh 8.1.0-SNAPSHOT is published. Keeping this as a draft until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraalJS Compatibility

1 participant