Replacing nashorn with GraalVM - jira compatiblity issue

Hi Community,

We have a jira plugin, that was using nashorn but now it’s incompatible with latest jira version.

Here is what we have:

  • We are using jdk8 for our jira plugin on jira server/DC,
  • And, we were using nashorn, but now we have to use graalVM instead. We are trying to migrate Nashorn to Graal ScriptEngine

And here is what we have tried:
Option #1
We have followed this guide:

Just to give you a little context: the code is part of a Jira app. So, this is running on top of the Atlassian Jira. Should this be related to the root cause of the issue I’m sharing below?

Regarding compatibility: this should run on Java 8, 11, 15 and 17.

Code:
Builder jsBuilder = Context.newBuilder(“js”).allowIO(true)
.allowExperimentalOptions(true)
.option(“js.nashorn-compat”, “true”)
.allowHostAccess(HostAccess.ALL)
.option(“js.ecmascript-version”, “2021”);
scriptEngine = GraalJSScriptEngine.create(null, jsBuilder);

When initializing the engine we are getting following exception:

java.lang.IllegalArgumentException: Could not find option with name js.ecmascript-version.
at com.oracle.truffle.polyglot.PolyglotEngineException.illegalArgument(PolyglotEngineException.java:125)
at com.oracle.truffle.polyglot.OptionValuesImpl.failNotFound(OptionValuesImpl.java:274)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.parseOptions(PolyglotEngineImpl.java:738)
at com.oracle.truffle.polyglot.PolyglotEngineImpl.(PolyglotEngineImpl.java:303)
at com.oracle.truffle.polyglot.PolyglotImpl.buildEngine(PolyglotImpl.java:276)
at org.graalvm.polyglot.Engine$Builder.build(Engine.java:620)
at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.createDefaultEngine(GraalJSEngineFactory.java:122)
at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.getPolyglotEngine(GraalJSEngineFactory.java:134)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.(GraalJSScriptEngine.java:292)
at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.getScriptEngine(GraalJSEngineFactory.java:196)
at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.getScriptEngine(GraalJSEngineFactory.java:58)
at com.xpandit.jiraxporter.commons.document.builder.api.javascript.JavaScriptExecutorService.(JavaScriptExecutorService.java:89)
at com.xpandit.jiraxporter.utils.DocumentBuildLookup.lookup(DocumentBuildLookup.java:342)
at com.xpandit.jiraxporter.component.service.XporterServiceImpl.exportIssue(XporterServiceImpl.java:605)
at com.xpandit.jiraxporter.component.service.XporterServiceImpl.generateBulkExportReport(XporterServiceImpl.java:321)
at com.xpandit.jiraxporter.component.bulkexport.BulkExportProcess.run(BulkExportProcess.java:203)
at java.lang.Thread.run(Thread.java:750)

Dependencies we are using on pom.xml:

org.graalvm.js js-scriptengine 22.0.0.2 org.graalvm.js js 22.0.0.2 org.graalvm.sdk graal-sdk 22.0.0.2 org.graalvm.truffle truffle-api 22.0.0.2

Option #2 (as suggested by you)
Tried with dependency as suggested by atlassian team, here is dependency in pom.xml

org.graalvm.polyglot
polyglot
${graalvm.version}


org.graalvm.polyglot
js
${graalvm.version}
pom

We have got the compilation error. That said, suggested dependency is not working for graal injecting into our Xporter application

We tried in multiple dev machine and running into the same error, here is the error snapshot
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[14,42] package com.oracle.truffle.js.scriptengine does not exist
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[30,28] cannot access org.graalvm.polyglot.Context
bad class file: /Users/rui.rodrigues/.m2/repository/org/graalvm/polyglot/polyglot/23.1.1/polyglot-23.1.1.jar(org/graalvm/polyglot/Context.class)
class file has wrong version 61.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[12,1] cannot find symbol
symbol: static correctQuotes
location: class
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.806 s
[INFO] Finished at: 2023-12-12T17:10:16Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xporter-engine: Compilation failure: Compilation failure:
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[14,42] package com.oracle.truffle.js.scriptengine does not exist
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[30,28] cannot access org.graalvm.polyglot.Context
[ERROR] bad class file: /Users/rui.rodrigues/.m2/repository/org/graalvm/polyglot/polyglot/23.1.1/polyglot-23.1.1.jar(org/graalvm/polyglot/Context.class)
[ERROR] class file has wrong version 61.0, should be 52.0
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] /Users/rui.rodrigues/Downloads/xporter-engine /src/main/java/com/xpandit/jiraxporter/commons/document/builder/api/javascript/JavaScriptExecutorService.java:[12,1] cannot find symbol
[ERROR] symbol: static correctQuotes
[ERROR] location: class
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoFailureException - Apache Maven - Apache Software Foundation
rui.rodrigues@Y4R30XDY6V xporter-engine %

Also, there are 2 different version in repo https://mvnrepository.com/artifact/org.graalvm.polyglot/polyglot, and for both version is giving the build/compiler error.

I appreciate any help/suggestions from you.

Thanks,
Nikhil Diwan