Fri, 11 Oct 2013 11:15:59 +0200
8026302: source representation of getter and setter methods is wrong
Reviewed-by: lagergren, hannesw, jlaskey
1.1 --- a/src/jdk/nashorn/internal/parser/Parser.java Fri Oct 11 10:56:08 2013 +0200 1.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java Fri Oct 11 11:15:59 2013 +0200 1.3 @@ -2107,7 +2107,7 @@ 1.4 final String ident = (String)expectValue(IDENT); 1.5 1.6 if (type != COLON) { 1.7 - final long getSetToken = token; 1.8 + final long getSetToken = propertyToken; 1.9 1.10 switch (ident) { 1.11 case "get":
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/script/basic/JDK-8026302.js Fri Oct 11 11:15:59 2013 +0200 2.3 @@ -0,0 +1,48 @@ 2.4 +/* 2.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/** 2.28 + * JDK-8026302: source representation of getter and setter methods is wrong 2.29 + * 2.30 + * @test 2.31 + * @run 2.32 + */ 2.33 + 2.34 +var obj = { 2.35 + get "foo"() {}, 2.36 + set "foo"(x) {}, 2.37 + get bar() {}, 2.38 + set bar(x) {}, 2.39 + get ":"() {}, 2.40 + set ":"(x) {}, 2.41 + get 12() {}, 2.42 + set 12(x) {}, 2.43 + get 1.8e-8() {}, 2.44 + set 1.8e-8(x) {} 2.45 +} 2.46 + 2.47 +for (var prop in obj) { 2.48 + var desc = Object.getOwnPropertyDescriptor(obj, prop); 2.49 + print(desc.get); 2.50 + print(desc.set); 2.51 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/script/basic/JDK-8026302.js.EXPECTED Fri Oct 11 11:15:59 2013 +0200 3.3 @@ -0,0 +1,10 @@ 3.4 +get "foo"() {} 3.5 +set "foo"(x) {} 3.6 +get bar() {} 3.7 +set bar(x) {} 3.8 +get ":"() {} 3.9 +set ":"(x) {} 3.10 +get 12() {} 3.11 +set 12(x) {} 3.12 +get 1.8e-8() {} 3.13 +set 1.8e-8(x) {}
4.1 --- a/test/script/basic/objects.js.EXPECTED Fri Oct 11 10:56:08 2013 +0200 4.2 +++ b/test/script/basic/objects.js.EXPECTED Fri Oct 11 11:15:59 2013 +0200 4.3 @@ -29,18 +29,18 @@ 4.4 abc is configurable? true 4.5 abc is enumerable? true 4.6 abc's value = undefined 4.7 -abc's get = abc() { return "abc"; } 4.8 +abc's get = get abc() { return "abc"; } 4.9 abc's set = undefined 4.10 xyz is writable? undefined 4.11 xyz is configurable? true 4.12 xyz is enumerable? true 4.13 xyz's value = undefined 4.14 xyz's get = undefined 4.15 -xyz's set = xyz(val) { print(val); } 4.16 +xyz's set = set xyz(val) { print(val); } 4.17 hey is writable? undefined 4.18 hey is configurable? true 4.19 hey is enumerable? true 4.20 hey's value = undefined 4.21 -hey's get = hey() { return "hey"; } 4.22 -hey's set = hey(val) { print(val); } 4.23 +hey's get = get hey() { return "hey"; } 4.24 +hey's set = set hey(val) { print(val); } 4.25 undefined