One of the most recent changes to the Java platform was to provide specific support for Nashorn's ECMAScript abstract syntax tree. The goals of the new API are to provide the following:
- Interfaces to represent Nashorn syntax tree nodes
- The ability to create parser instances that can be configured with command-line options
- A visitor pattern API for interfacing with AST nodes
- Test programs to use the API
The new API, jdk.nashorn.api.tree, was created to permit future changes to the Nashorn classes. Prior to the new Parser API, IDEs used Nashorn's internal AST representations for code analysis. According to Oracle, use of the jdk.nashorn.internal.ir package prevented the modernization of Nashorn's internal classes.
Here is a look at the class hierarchy of the new jdk.nashorn.api.tree package:
The following graphic illustrates the complexity of the new API, featuring a full interface hierarchy:
The last component of the jdk.nashorn.api.tree package is the enum hierarchy, which is shown here: