Parser API for Nashorn [JEP-236]
The focus of JEP 236 was to create an API for Nashorn's EMCAScript abstract syntax tree. In this section, we will individually look at Nashorn, EMCAScript and then the Parser API.
Nashorn
Oracle Nashorn is a JavaScript engine for the JVM developed in Java by Oracle. It was released with Java 8. It was created to provide developers with a highly efficiently and lightweight JavaScript runtime engine. Using this engine, developers were able to embed JavaScript code in their Java applications. Prior to Java 8, developers had access to the JavaScript engine created by Netscape. That engine, introduced in 1997, was maintained by Mozilla.
Nashorn can be used both as a command-line tool and as an embedded interpreter in Java applications. Let's look at examples of both.
Note
Nashorn is the German word for rhinoceros. The name spawned from the Rhino-named JavaScript engine from the Mozilla Foundation. Rhino is said to have originated from the picture of the animal on a...