[SPIGOT-6902] When using Nashorn 15.3 as a module, script engine is undefined in plugins Created: 18/Jan/22 Updated: 20/Jan/22 |
|
Status: | Reopened |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | wwlib | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | Nashorn, plugins | ||
Environment: |
Server running on Oraclelinux8 Docker: FROM openjdk:17-oraclelinux8 Dockerfile: https://github.com/wwlib/docker-minecraft/blob/master/minecraft-server-1.18.1-openjdk17/Dockerfile.openjdk17 README: https://github.com/wwlib/docker-minecraft/blob/master/minecraft-server-1.18.1-openjdk17/README.md
java --version openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-39) OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)
Nashorn 15.3 (JavaScript engine) is loaded as a module via: java -Xms512M -Xmx1G -cp /minecraft/nashorn --module-path /minecraft/nashorn --add-modules org.openjdk.nashorn -jar spigot-1.18.1.jar
|
Attachments: |
![]() ![]() |
Version: | CraftBukkit version 3405-Spigot-f4ff00f-d10c35e (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
Previously in 1.17.1 on openjdk16 & openjdk17 the Nashorn JavaScript engine was found and worked as expected. Now in 1.18.1 on openjdk17 the Nashorn engine is undefined. Again, Nashorn 15.3 is NOT included in openjdk17 and is loaded as a module via: java -Xms512M -Xmx1G -cp /minecraft/nashorn --module-path /minecraft/nashorn --add-modules org.openjdk.nashorn -jar spigot-1.18.1.jar
It seems plugin behavior has changed between 1.17.1 and 1.18.1.
Outside of Spigot, the referenced NashornTest.java CAN access the Nashorn engine and produces this output:
java -cp /minecraft/nashorn -cp . --module-path /minecraft/nashorn --add-modules org.openjdk.nashorn NashornTest VM Details: OpenJDK 64-Bit Server VM 17.0.1+12-39 mixed mode, sharing Nashorn engine found! ECMAScript OpenJDK Nashorn [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript] Note: /minecraft/nashorn contains the Nashorn 15.3 jars (https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.3/jar) As noted above, previously from within a plugin loaded by 1.17.1 the Nashorn engine CAN be accessed. (java16 and java17) However, from within a plugin loaded by 1.18.1 the Nashorn engine CANNOT be accessed. (java17) Example plugin: Produces the error: "No JavaScript Engine available."
Is this related to: https://hub.spigotmc.org/jira/browse/SPIGOT-6822 |
Comments |
Comment by wwlib [ 19/Jan/22 ] |
Update re: Grakkit Just an FYI unrelated to the original issue (but interesting) It turns out that Grakkit DOES work in 1.18.1 when using openjdk17 WITHOUT GraalVM: i.e. openjdk:17-oraclelinux8 It turns out that Grakkit does not use ScriptEngine. It packages and shades the GraalJS library and uses those classes. What does not work is the combo of GraalVM CE 21.3.0 (ghcr.io/graalvm/graalvm-ce:java17-21.3) + 1.18.1 + Grakkit. |
Comment by wwlib [ 19/Jan/22 ] |
Great. Thanks, again. |
Comment by md_5 [ 18/Jan/22 ] |
|
Comment by wwlib [ 18/Jan/22 ] |
Checking to see if I understand:
Do any of these describe the script engine included in the GraalVM openjdk 17 distribution? "Module loaded script engine is now fixed" this sounds promising, though maybe temporary. |
Comment by md_5 [ 18/Jan/22 ] |
I dug into this for you, and the situation is:
|
Comment by wwlib [ 18/Jan/22 ] |
(Cross-posted. Just seeing your previous reply.) "The main spigot-1.18.jar is now a bootstrap jar which contains all libraries." etc. "I suggest you ask the forums for help" OK, will do. Thanks for the help. |
Comment by wwlib [ 18/Jan/22 ] |
FYI: I just tested another plugin (grakkit) that uses JavaScript by including GraalVM dependencies in its plugin jar (grakkit-5.0.4.paper.jar). https://github.com/grakkit/grakkit Same issue. Grakkit works in spigot-1.17.1 but fails in spigot-1.18.1 (also fails using paper-1.18.1-155.jar)
[21:32:21] [Server thread/WARN]: [grakkit] Task #2 for grakkit v5.0.4 generated an exception |
Comment by md_5 [ 18/Jan/22 ] |
Bootstrap Jar Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163 I suggest you ask the forums for help, as I do not believe there to be any Spigot bug. If you believe there is a bug with how Spigot loads classes (unlikely), then please create a minimal test case using one of the supported methods (shaded jar, library loader). It is outside the scope of a bug report here to debug the entirety of Nashorn (especially when loaded in an unsupported manner). |
Comment by wwlib [ 18/Jan/22 ] |
For reference (completeness) the same issue happens when running spigot-1.18.1 using GraalVM (openjdk17 + Graal Script Engine) java --version openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing) When running GraalVM (openjdk17) Minecraft 1.17.1 CAN access the JavaScript script engine. 1.17.1 java -Xms512M -Xmx1G -jar spigot-1.17.1.jar [19:20:06] [Worker-Main-10/INFO]: Preparing spawn area: 91% When running GraalVM (openjdk17) Minecraft 1.18.1 CANNOT access the JavaScript script engine. 1.18.1 java -Xms512M -Xmx1G -jar spigot-1.18.1.jar [19:29:50] [Worker-Main-8/INFO]: Preparing spawn area: 97% |
Comment by wwlib [ 18/Jan/22 ] |
OK. Can you confirm that this is a change from 1.17.1 since it worked there. I will look into loading Nashorn using the library loader, as you suggest. And just to make sure I am seeing all the release notes, I have reviewed the notes here: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/ And looked at the diff here: Are there other notes? I did not see a mention of a plugin loading change - at least not a breaking change. (But I am new to this) Thanks. |
Comment by md_5 [ 18/Jan/22 ] |
As per the release notes, the Spigot jars are not loaded into the system classloader, but rather their own classloader. Your code (which is manipulating classloaders) needs to be modified accordingly. Based on the information you have provided there does not appear to be any Spigot bug. Consider using the library loader. |