test/script/basic/JDK-8058179.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1007
39ba6d257e4c
permissions
-rw-r--r--

Merge

hannesw@1007 1 /*
hannesw@1007 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
hannesw@1007 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1007 4 *
hannesw@1007 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1007 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1007 7 * published by the Free Software Foundation.
hannesw@1007 8 *
hannesw@1007 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1007 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1007 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1007 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1007 13 * accompanied this code).
hannesw@1007 14 *
hannesw@1007 15 * You should have received a copy of the GNU General Public License version
hannesw@1007 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1007 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1007 18 *
hannesw@1007 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1007 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1007 21 * questions.
hannesw@1007 22 */
hannesw@1007 23
hannesw@1007 24 /**
hannesw@1007 25 * JDK-8058179: Global constants get in the way of self-modifying properties
hannesw@1007 26 *
hannesw@1007 27 * @test
hannesw@1007 28 * @run
hannesw@1007 29 */
hannesw@1007 30
hannesw@1007 31 var global = this;
hannesw@1007 32
hannesw@1007 33 Object.defineProperty(global, "value", {
hannesw@1007 34 get: function() {
hannesw@1007 35 print("getting value");
hannesw@1007 36 global["value"] = "value 2";
hannesw@1007 37 return "value 1";
hannesw@1007 38 },
hannesw@1007 39 set: function(value) {
hannesw@1007 40 print("setting value: " + value);
hannesw@1007 41 delete global["value"];
hannesw@1007 42 global["value"] = value;
hannesw@1007 43 },
hannesw@1007 44 configurable: true
hannesw@1007 45 });
hannesw@1007 46
hannesw@1007 47 print(value);
hannesw@1007 48 print(value);

mercurial