JDK-8066407 : Function with same body not reparsed after SyntaxError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-12-02
  • Updated: 2015-09-29
  • Resolved: 2015-04-27
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 b63Fixed
Related Reports
Relates :  
Description
First time: parser throws SyntaxError
jjs> Function("/a/r")
<shell>:1 SyntaxError: <function>:1:4 Unsupported RegExp flag: r
/a/r
    ^

Second time: silently succeeds
jjs> Function("/a/r")
function () {
/a/r
}

Third time also silently succeeds; trying to invoke it now throws the error during invocation:

jjs> var x = Function("/a/r")
jjs> x()
<function>:2 SyntaxError: Unsupported RegExp flag: r

This seems inconsistent.

Comments
Fixed in http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/b93949f9e5fd
27-04-2015

The problem is with the regexp validation cache in RegExpFactory which adds the regexp before compiling it.
21-04-2015