hannesw@1368: /* hannesw@1368: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1368: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1368: * hannesw@1368: * This code is free software; you can redistribute it and/or modify it hannesw@1368: * under the terms of the GNU General Public License version 2 only, as hannesw@1368: * published by the Free Software Foundation. hannesw@1368: * hannesw@1368: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1368: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1368: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1368: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1368: * accompanied this code). hannesw@1368: * hannesw@1368: * You should have received a copy of the GNU General Public License version hannesw@1368: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1368: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1368: * hannesw@1368: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1368: * or visit www.oracle.com if you need additional information or have any hannesw@1368: * questions. hannesw@1368: */ hannesw@1368: hannesw@1368: /** hannesw@1368: * JDK-8071928: Instance properties with getters returning wrong values hannesw@1368: * hannesw@1368: * @test hannesw@1368: * @run hannesw@1368: */ hannesw@1368: hannesw@1368: hannesw@1368: var types = {}; hannesw@1368: hannesw@1368: function Type() {} hannesw@1368: hannesw@1368: Type.prototype.getName = function() { hannesw@1368: return this._name; hannesw@1368: }; hannesw@1368: hannesw@1368: function defineType(init) { hannesw@1368: return Object.create(Type.prototype, { hannesw@1368: _name: { get: function() { return init.name; } } hannesw@1368: }); hannesw@1368: } hannesw@1368: hannesw@1368: types.A = defineType({ name: 'A' }); hannesw@1368: types.B = defineType({ name: 'B' }); hannesw@1368: types.C = defineType({ name: 'C' }); hannesw@1368: types.D = defineType({ name: 'D' }); hannesw@1368: hannesw@1368: var keys = Object.keys(types); hannesw@1368: for (var i = 0; i < keys.length; i++) { hannesw@1368: var t = types[keys[i]]; hannesw@1368: if (t.getName() != keys[i]) { hannesw@1368: throw 'wrong name for ' + keys[i] + ': ' + t.getName(); hannesw@1368: } hannesw@1368: }