JDK-8085802 : Nashorn -nse option causes parse error on anonymous function definition
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u25,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2015-05-27
  • Updated: 2015-10-29
  • Resolved: 2015-06-08
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 b69Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux metacanvas-dev01 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
Start interactive nashorn shell with -nse option. Execute anonymous function: (function(){})()

This is standard JavaScript, not a nashorn extension, but it will not compile.

REGRESSION.  Last worked in version 8u20

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start interactive nashorn shell with -nse option.
Execute anonymous function: (function(){})()

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jjs -nse
jjs> (function(){})()
jjs> 

ACTUAL -
jjs -nse
jjs> (function(){})()
jdk.nashorn.internal.runtime.ParserException: <shell>:1:9 Expected ident but found (
(function(){})()
         ^

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
1) Checked this with JDK 8u20, 8u25, 8u45, 8u60 ea b17 and 9 ea b66. Result: 8u20: OK 8u25: FAIL 8u45: FAIL 8u60 ea b17: FAIL 9 ea b66: FAIL 2) Output with (JDK 8u20): > jjs -nse jjs> (function(){})() jjs> 3) Output with JDK 8u45: > jjs -nse jjs> (function){})() ECMAScript Exception: SyntaxError: <shell>:1:9 Expected ( but found ) (function){})() ^ 4) This runtime exception is reproducible with JDK 8u25 and onwards including 9 ea b66.
04-06-2015