Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8071928

Instance properties with getters returning wrong values

    Details

    • Subcomponent:
    • Resolved In Build:
      b62
    • CPU:
      x86
    • OS:
      os_x
    • Verification:
      Not verified

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hannesw Hannes Wallnoefer
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: