JDK-8071928 : Instance properties with getters returning wrong values
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 8u40
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-01-27
  • Updated: 2016-07-08
  • Resolved: 2015-04-20
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 b62Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b09, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin jcoker-mac.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64


A DESCRIPTION OF THE PROBLEM :
JavaScript instances constructed using Object.create with properties implemented with get functions returning pass-in values seem to lose the correct values.  The first two instances work fine, but the third and further instances seem to get corrupted with the second initializer literal's values.

Sorry, it's hard to describe exactly; please see the code snippet that reproduces the problem.

This works as expected in 1.8.0_25 (as well as V8, tested in Node.js and Chrone), but returns the wrong names in 1.8.0_40-ea.

REGRESSION.  Last worked in version 8u25

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


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
jjs test.js

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
(no output)
ACTUAL -
C3.type.Henry has wrong name: got "Frank" (expected "Henry")
C3.type.James has wrong name: got "Frank" (expected "James")


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// john.coker@c3-energy.com
C3 = {
  typesys: {},
  type: {},
};
C3.typesys.Type = function() {};
C3.typesys.Type.prototype.typeName = function() {
  return this._name;
};
C3.typesys.Type.define = function(init) {
  return Object.create(C3.typesys.Type.prototype, {
    _name: { get: function() { return init.name; } }
  });
};

C3.type.David = C3.typesys.Type.define({ name: 'David' });
C3.type.Frank = C3.typesys.Type.define({ name: 'Frank' });
C3.type.Henry = C3.typesys.Type.define({ name: 'Henry' });
C3.type.James = C3.typesys.Type.define({ name: 'James' });

var keys, t, i;
keys = Object.keys(C3.type);
for (i = 0; i < keys.length; i++) {
  t = C3.type[keys[i]];
  if (t.typeName() != keys[i])
    print('C3.type.' + keys[i] + ' has wrong name: got "' + t.typeName() + '" (expected "' + keys[i] + '")');
}
---------- END SOURCE ----------