JDK-8326588 : Setting of nashorn.args has changed (and does not work)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 17.0.10
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-02-22
  • Updated: 2024-02-23
Description
A DESCRIPTION OF THE PROBLEM :
Customer reported (https://shibboleth.atlassian.net/browse/JSCRIPTING-19) that whereas in JDK11 the following worked and supressed deprecations warnings

-Dnashorn.args=--no-deprecation-warning)

In JDK17 with nashorn-core-15.4.1 (inserted onto the classpath) this doesn't work.  Instead the scripting engine SILENTLY fails to load.

Spelunking the code shows me that the property setting paradigm has changed to 

-Dnashorn.args=-D--no-deprecation-warning

or even 

-D--no-deprecation-warning

this appears to make the property available to the Nashorn scripting engine.  Customer additionally reports that even with this set the warnings are still emitted.

1) Why does the engine silently fail to load (rather than throw an exception or print a log message)?
2) Is this change documented (so I can reflect it in our documentation)
3) Why, even with that parameterization, does the engine still warn?
[2024-02-22 08:29:26] [info] Warning: Nashorn engine is planned to be removed from a future JDK release

REGRESSION : Last worked in version 11.0.22

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) add nashorn to you class path
2) Run this code segment

System.setProperty("nashorn.args","-no-deprecation-warning");
final ScriptEngineManager engineManager = new ScriptEngineManager();
final ScriptEngine scriptEngine = engineManager.getEngineByName("javascript");
assert scriptEngine != null;
nothing happens because the engine fails to load


---------- BEGIN SOURCE ----------
https://git.shibboleth.net/view/?p=java-idp-plugin-scripting.git;a=blob;f=nashorn-jdk-impl/src/test/java/net/shibboleth/idp/plugin/scripting/nashorn/EngineTests.java;h=abab340b30e211d7ec9e026a4f99704a781ba4a4;hb=HEAD

Has the test but with the problem fixed.
---------- END SOURCE ----------

FREQUENCY : always



Comments
The scripting engine not working on JDK 17 due to NashornScriptEngineFactory itself is deprecated. we getting below error in jdk17 Exception in thread "main" java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.eval(String)" because "scriptEngine" is null (edited) however in jdk 11, giving below warming : Warning: Nashorn engine is planned to be removed from a future JDK release
22-02-2024