Friends of Eclipse,
Eclipse is an open source community that benefits millions of developers around the world each and every day! During the month of September, we are asking you to give back to our wonderful open source community. All donations will be used to improve Eclipse technology. Your contribution counts!
We thank you for this gesture, and for giving back to our community.
You’ve probably read or heard about some of the key features of the upcoming Java SE 8 and JDK 8 already:
By late 2012, there was a Nashorn Project in the OpenJDK community, and the code making up the implementation was open source. It attracted early adopters and rapidly improved to the point of passing all of ECMAScript compliance tests. Nashorn eventually replaced Rhino during the development of the upcoming JDK 8 release in 2013, and has evolved into one of the key features of that release.
The open source code that Nashorn is composed of can be found in the OpenJDK Project Nashorn Mercurial repositories.
Compatibility matters, as Java developers know very well. The ECMAScript 5.1 standard has a corresponding test suite, available at http://test262.ecmascript.org. Nashorn passes all the compliance tests, as compatibility has been a primary goal of the implementation from the beginning.
Under the hood, Nashorn uses the invokedynamic JVM instruction to implement all of its invocations. That is a major component of the comparative improvement of performance and memory usage regarding Mozilla Rhino.
You can use string interpolation
to use the values of variables or expressions to construct strings
within double quotation marks. You can also use a here document
(heredoc) to specify strings that preserve line breaks and
indentation. Environment variables, command line arguments, output
and error strings are available as global objects, as well as the
script’s exit code and a global function to run commands.
Additionally, Nashorn provides several built-in functions to exit the script, print and read lines from standard output and input, read files, load scripts, and bind properties of objects.
Finally, access to the JavaFX primary stage is provided through a global property.
Back to the top