lucko / helper

A collection of utilities and extended APIs to support the rapid and easy development of Bukkit plugins.
MIT License
456 stars 87 forks source link

Switch to different Javascript engine #65

Closed Andre601 closed 3 years ago

Andre601 commented 4 years ago

Considering that Nashorn is deprecated now with Java 11 and may get removed in the future would I suggest to switch to a different engine.

noahcoetsee commented 4 years ago

And what would you advise? There aren't many competitors from what I know.

jwpjrdev commented 3 years ago

@FeaturedSpace GraalVM.

mdcfe commented 3 years ago

Related: https://github.com/graalvm/graaljs/blob/master/docs/user/RunOnJDK.md

Ristovski commented 3 years ago

Nashorn has been removed as of Java 15 - https://openjdk.java.net/jeps/372. This makes running helper-js on 1.17 (which requires Java 16) impossible.

However, it appears Nashorn can be used standalone: https://mail.openjdk.java.net/pipermail/nashorn-dev/2020-October/007557.html

I will edit this issue as I try to get it working. Log:

Edit: It works, tested on OpenJDK16-OpenJ9:

[12:02:41 INFO]: [helper-js] Enabling helper-js v2.0.0
[12:02:41 INFO]: [helper-js] Loading configuration...
[12:02:41 INFO]: [helper-js] Scanning the classpath to resolve default package imports...
[12:02:41 INFO]: [helper-js] Initialising script controller...
[12:02:41 INFO]: [helper-js] Creating new script environment at plugins/helper-js/scripts (dir/plugins/helper-js/scripts)
[12:02:41 INFO]: [helper-js] [LOADER] Loaded script: init.js
[12:02:42 INFO]: [helper-js] [init] It works!
[12:02:42 INFO]: [helper-js] Done!

@lucko thoughts? The easiest way to support Java 15+ would be to create a separate build artifact which has Nashorn built-in.

It would also be nice if we could load Nashorn like this:

ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");

instead of explicitly using jdk.nashorn.*. This would allow helper-js to work by just dropping Nashorn into the classpath.