JDK-8043232 : Index selection of overloaded java new constructors
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-05-15
  • Updated: 2015-01-21
  • Resolved: 2014-07-02
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 b22Fixed
Description
Currently there is no way to reliably predict which overloaded constructor will be used.

var x = 1;
print(new java.awt.Color(x, x, x)) // creates Color[r=1,g=1,b=1]

var y = 1;
y = y + 0;
print(new java.awt.Color(y, y, y)) // creates Color[r=1,g=1,b=1]

var z = 1;
z = z * 1;
print(new java.awt.Color(z, z, z)) // creates Color[r=255,g=255,b=255]

Need to be able to new (java.awt["Color(int,int,int)"])(3,3, 4)