JDK-8068524 : NashornScriptEngineFactory.getParameter() throws IAE for an unknown key, doesn't conform to the general spec
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-01-06
  • Updated: 2015-09-29
  • Resolved: 2015-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b46Fixed
Description
The spec
http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-
says:
"Returns null if no value is assigned to the key."
and doesn't mention any IAEs.

However the following line executed on Oracle's JDK.

new ScriptEngineManager().getEngineFactories().forEach(f -> f.getParameter("no value assigned to this key"));

will throw

java.lang.IllegalArgumentException: Invalid key
	at jdk.nashorn.api.scripting.NashornScriptEngineFactory.getParameter(NashornScriptEngineFactory.java:123)

which doesn't conform to the current spec and the corresponding JCK9(b05) test will fail on JDK9:

api/javax_script/ScriptEngineFactory/index.html#GetParameter[noValue]

The specification or the Nashorn implementation needs to be corrected.



Comments
Cross checked with jsr-223 pdf spec. doc ( http://download.oracle.com/otn-pub/jcp/java_scripting-1.0-fr-eval-oth-JSpec/java_scripting-1_0-fr-spec.pdf ) as well. There is no mention of IAE for unknown key. So, null value should be returned in unknown key cases. It is an implementation bug then (i.e., not a spec issue - but confirmation issue with implementations).
07-01-2015