JDK-8205594 : Add deprecation annotation to Nashorn APIs and warning to nashorn, jjs
  • Type: CSR
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Submitted: 2018-06-25
  • Updated: 2018-06-27
  • Resolved: 2018-06-27
Related Reports
CSR :  
Description
Summary
-------
Nashorn script engine along with its exported APIs and nashorn shell command line tool "jjs" are deprecated for removal.

Problem
-------

The Nashorn JavaScript engine was first incorporated into JDK 8 via JEP 174 as a replacement for the Rhino scripting engine. When it was released, it was a complete implementation of the ECMAScript-262 5.1 standard.

With the rapid pace at which ECMAScript language constructs, along with APIs, are adapted and modified, we have found Nashorn challenging to maintain.

See also: http://openjdk.java.net/jeps/335

Solution
--------

Deprecate the Nashorn JavaScript script engine and APIs, and the jjs tool, with the intent to remove them in a future release.

Specification
-------------

Deprecated annotation:

Nashorn module 'jdk.scripting.nashorn' exports two API packages:

jdk.nashorn.api.scripting;

jdk.nashorn.api.tree;

@Deprecated(forRemoval=true) annotation will be added to the module-info.java file for jdk.scripting.nashorn module and its exported packages mentioned above as well as all the public Java types of those exported API packages.

Both jjs shell and nashorn programmatic use via javax.script API will result in a warning about deprecation being printed at the standard error.

"Warning: The jjs tool is planned to be removed from a future JDK release"

"Warning: Nashorn engine is planned to be removed from a future JDK release"

To minimize compatibility issues for the third-party tools, libraries which may be depend on nashorn engine/shell output, the warning message can be suppressed using a new command line option.

The specification for the new command line option is as follows:

--no-deprecation-warning (Do not show nashorn deprecation warning.)
		param: [true|false]   default: false

Comments
Attached updated webrev (webrev.01.zip) that incorporates suggested comments in approval.
27-06-2018

Voting to approve with the following amendments: * Remove the @Deprecated annotations from the package-info files. Per the spec for the java.lang.Deprecated annotation type "Use of the @Deprecated annotation on a local variable declaration or on a parameter declaration or a package declaration has no effect on the warnings issued by a compiler. " * Add @deprecated javadoc for the nested type Tree.kind. Please attach a follow-up webrev reflecting these changes.
27-06-2018

Hi [~darcy] Added @deprecated to javadoc comments. Attached webrev.zip
26-06-2018

Besides the @Deprecated annotation, deprecating an API involves adding @deprecated javadoc tags. Please prepare for the CSR a version of this change with the @deprecated javadoc tags included. Attaching a webrev of the set of changes would be one way to provide that information.
25-06-2018