JDK-8060011 : Concatenating an array and converting it to Java gives wrong result
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-10-08
  • Updated: 2015-06-04
  • Resolved: 2014-10-13
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 b36Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_20"11:44:58 on console
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
OS X 10.9.5

A DESCRIPTION OF THE PROBLEM :
Concatenating two arrays in JavaScript on Nashorn and translating it to Java returns an array that is too long and is filled with nulls at the end.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following JavaScript using Nashorn:
head = [0]
tail = [1, 2, 3];
list = head.concat(tail)
print(java.util.Arrays.toString(Java.to(list)));

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected Output:
[0, 1, 2, 3]
ACTUAL -
Actual Output:
[0, 1, 2, 3, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]

REPRODUCIBILITY :
This bug can be reproduced always.