Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use GraalVM instead of Nashorn, which is deprecated in Java 11 #23

Open
cxbrooks opened this issue Jun 17, 2019 · 3 comments
Open

Comments

@cxbrooks
Copy link
Member

Nashorn is deprecated as of Java 11

InfoWorld states: Oracle: Switch now from Nashorn JavaScript engine to GraalVM:

"Oracle cited multiple advantages GraalVM has over Nashorn:"

  • "A more complete implementation of JavaScript standards, with support for the ECMAScript 2016 and ECMAScript 2017 editions and some support for ECMAScript 2018."
  • "Full support for the Node.js server-side JavaScript platform, which is compatibie with almost all Node.js modules."
  • "The ability to execute additional languages including Python, R, and Ruby."
  • "Better performance than existing JVM-based engines and ability to use the GraalVM compiler’s advanced optimizations."

"To help developers migrate from Nashorn to GraalVM, Oracle Labs has added a compatibility flag (—nashorn-compat) that removes the need for tedious rewrites to move a Nashorn application to GraalVM"

@edwardalee
Copy link
Collaborator

edwardalee commented Jun 21, 2019 via email

@cxbrooks
Copy link
Member Author

cxbrooks commented Sep 4, 2021

Nashorn has been released as a standalone jar file. I have changes in my tree that support the standalone Nashorn and the few models I checked seem to work OK. The reason to go with the Nashorn standalone jar is because the standalone jar is likely to be closest to whatever Oracle shipped built in to the JDKs before Oracle removed builtin Nashorn support.

The primary change is that the imports needed to change in a few files.

The issue is that the standalone Nashorn jar is not supported in JDK 8-10. Currently, in theory, Ptolemy II builds and runs with JDK 8. When I try to compile a small test program under JDK 8 with the standalone Nashorn, I get:

import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
                                        ^
  bad class file: /Users/cxh/src/ptII11.1.devel/lib/nashorn-core-15.3.jar(org/openjdk/nashorn/ap\
i/scripting/ScriptObjectMirror.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

https://github.com/szegedi/nashorn/wiki/Using-Nashorn-with-different-Java-versions indicates that the standalone Nashorn jar works with JDK 11 and later. We are using JDK 11 in the Travis build.

So, I see the following options:

  1. Do nothing and compiling Ptolemy II with JDKs after 14 will not support Nashorn and CapeCode. I believe that I have changes checked in that allow Ptolemy II to compile without Nashorn, but I have not tested the results.
  2. Move to the standalone Nashorn jar and if JDK 8-10 is used, don't try to use the standalone Nashorn jar, which means CapeCode would not work with JDK 8-10. Configure would print a message. I'm inclined to follow this path. It would mean updating the docs.
  3. If JDK8-10 is used, then run sed on the jar files that need to be changed and patch them to use the builtin JDK. This seems like work for very old versions of the JDK and likely to cause problems if someone accidentally checks the files in.
  4. Use GraalVM. This seems like real work in that GraalVM is not likely to be as backward compatible as the standalone Nashorn jar file.

@cxbrooks
Copy link
Member Author

cxbrooks commented Sep 8, 2021

I checked in changes for #2 above, where CapeCode no longer works with JDK8-10. I'm working on getting another allotment of Travis credits so that the build will complete. I checked that Eclipse and Maven work. It will be necessary to rerun configure to get the updated paths.

This issue can remain open because the issue is about supporting GraalVM.

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

No branches or pull requests

2 participants