sundar@513: /* sundar@513: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@513: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@513: * sundar@513: * This code is free software; you can redistribute it and/or modify it sundar@513: * under the terms of the GNU General Public License version 2 only, as sundar@513: * published by the Free Software Foundation. sundar@513: * sundar@513: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@513: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@513: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@513: * version 2 for more details (a copy is included in the LICENSE file that sundar@513: * accompanied this code). sundar@513: * sundar@513: * You should have received a copy of the GNU General Public License version sundar@513: * 2 along with this work; if not, write to the Free Software Foundation, sundar@513: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@513: * sundar@513: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@513: * or visit www.oracle.com if you need additional information or have any sundar@513: * questions. sundar@513: */ sundar@513: sundar@513: /** sundar@513: * JDK-8023368: Instance __proto__ property should exist and be writable. sundar@513: * sundar@513: * @test sundar@513: * @run sundar@513: */ sundar@513: sundar@513: // function to force same callsites sundar@513: function check(obj) { sundar@513: print(obj.func()); sundar@513: print(obj.x); sundar@513: print(obj.toString()); sundar@513: } sundar@513: sundar@513: function Func() { sundar@513: } sundar@513: sundar@513: Func.prototype.func = function() { sundar@513: return "Func.prototype.func"; sundar@513: } sundar@513: sundar@513: Func.prototype.x = "hello"; sundar@513: sundar@513: var obj = new Func(); sundar@513: var obj2 = Object.create(obj); sundar@513: sundar@513: // check direct and indirect __proto__ change sundar@513: check(obj); sundar@513: check(obj2); sundar@513: obj.__proto__ = { sundar@513: func: function() { sundar@513: return "obj.__proto__.func @ " + __LINE__; sundar@513: }, sundar@513: x: 344 sundar@513: }; sundar@513: sundar@513: check(obj); sundar@513: check(obj2); sundar@513: sundar@513: // check indirect (1 and 2 levels) __proto__ function change sundar@513: obj.__proto__.__proto__ = { sundar@513: toString: function() { sundar@513: return "new object.toString"; sundar@513: } sundar@513: }; sundar@513: sundar@513: check(obj); sundar@513: check(obj2);