Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6902

When using Nashorn 15.3 as a module, script engine is undefined in plugins

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • CraftBukkit version 3405-Spigot-f4ff00f-d10c35e (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
    • Yes

      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)

      https://github.com/wwlib/docker-minecraft/blob/master/minecraft-server-1.18.1-openjdk17/plugins/nashorn-test/NashornTest.java

      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:

      https://github.com/wwlib/docker-minecraft/blob/master/minecraft-server-1.18.1-openjdk17/plugins/plugin-javascript/plugin/org/wwlib/spigotmc/HelloJavaScript/Main.java

      Produces the error: "No JavaScript Engine available."

       

      Is this related to:

      https://hub.spigotmc.org/jira/browse/SPIGOT-6822

        1. NashornTest.java
          1 kB
          wwlib

            Unassigned Unassigned
            raptoron wwlib
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: