JDK-8056123 : Anonymous function statements leak internal function names into global scope
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-08-26
  • Updated: 2015-06-04
  • Resolved: 2014-08-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
8u40Fixed 9 b29Fixed
Description
{code}
function () { // line 1
  print("hello from nashorn");
}

print(this["L:1"]); // print function on line 1
{code}

expected:
undefined

actual:
function () { // line 1
  print("hello from nashorn");
}

{code:title=--print-parse}
[<unknown>] function :program() {
    [|1|];
    var L:1 = [<unknown>] function L:1() {
        [|2|];
        print("hello from nashorn");
    }
    [|5|];
    print(this["L:1"]);
}
{code}

Note that this is a Nashorn syntax extension, and it does not happen if function is assigned to a variable.
Comments
The function name is different in <=8u11, but otherwise it behaves the same.
27-08-2014

Reproduced with jdk1.8.0_20. But works fine with jdk1.8.0_11 and also reproduced with jdk8u-dev and jdk9. So, regression introduced between 8u11 and 8u20.
27-08-2014