Thu, 19 Sep 2013 21:20:47 +0530
8025080: Object literal getter, setter function with number format property name results in ClassFormatError
Reviewed-by: lagergren, hannesw
1.1 --- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Thu Sep 19 15:39:01 2013 +0200 1.2 +++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Thu Sep 19 21:20:47 2013 +0530 1.3 @@ -410,7 +410,8 @@ 1.4 comma(); 1.5 1.6 property("id"); 1.7 - if (functionNode.isAnonymous()) { 1.8 + final FunctionNode.Kind kind = functionNode.getKind(); 1.9 + if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) { 1.10 nullValue(); 1.11 } else { 1.12 functionNode.getIdent().accept(this);
2.1 --- a/src/jdk/nashorn/internal/parser/Parser.java Thu Sep 19 15:39:01 2013 +0200 2.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java Thu Sep 19 21:20:47 2013 +0530 2.3 @@ -59,6 +59,7 @@ 2.4 import java.util.Iterator; 2.5 import java.util.List; 2.6 import java.util.Map; 2.7 +import jdk.internal.dynalink.support.NameCodec; 2.8 import jdk.nashorn.internal.codegen.CompilerConstants; 2.9 import jdk.nashorn.internal.codegen.Namespace; 2.10 import jdk.nashorn.internal.ir.AccessNode; 2.11 @@ -2108,7 +2109,7 @@ 2.12 case "get": 2.13 final PropertyKey getIdent = propertyName(); 2.14 final String getterName = getIdent.getPropertyName(); 2.15 - final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName); 2.16 + final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + NameCodec.encode(getterName)); 2.17 expect(LPAREN); 2.18 expect(RPAREN); 2.19 functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER); 2.20 @@ -2117,7 +2118,7 @@ 2.21 case "set": 2.22 final PropertyKey setIdent = propertyName(); 2.23 final String setterName = setIdent.getPropertyName(); 2.24 - final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName); 2.25 + final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + NameCodec.encode(setterName)); 2.26 expect(LPAREN); 2.27 final IdentNode argIdent = getIdent(); 2.28 verifyStrictIdent(argIdent, "setter argument");
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/script/basic/JDK-8025080.js Thu Sep 19 21:20:47 2013 +0530 3.3 @@ -0,0 +1,43 @@ 3.4 +/* 3.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * JDK-8025080: Object literal getter, setter function with number format property name results in ClassFormatError 3.29 + * 3.30 + * @test 3.31 + * @run 3.32 + */ 3.33 + 3.34 +var obj = { 3.35 + get 1e81() { print("1e81 getter"); }, 3.36 + set 1e81(x) { print("1e81 setter"); }, 3.37 + get 3.14e-2() { print("3.14e-2 getter");}, 3.38 + set 3.14e-2(x) { print("3.14e-2 setter"); } 3.39 +}; 3.40 + 3.41 +obj[1e81]; 3.42 +obj[1e81] = 23; 3.43 + 3.44 +obj[3.14e-2]; 3.45 +obj[3.14e-2] = 42; 3.46 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/script/basic/JDK-8025080.js.EXPECTED Thu Sep 19 21:20:47 2013 +0530 4.3 @@ -0,0 +1,4 @@ 4.4 +1e81 getter 4.5 +1e81 setter 4.6 +3.14e-2 getter 4.7 +3.14e-2 setter
5.1 --- a/test/script/basic/parser/objectLitExpr.js.EXPECTED Thu Sep 19 15:39:01 2013 +0200 5.2 +++ b/test/script/basic/parser/objectLitExpr.js.EXPECTED Thu Sep 19 21:20:47 2013 +0530 5.3 @@ -126,10 +126,7 @@ 5.4 }, 5.5 "value": { 5.6 "type": "FunctionExpression", 5.7 - "id": { 5.8 - "type": "Identifier", 5.9 - "name": "get x" 5.10 - }, 5.11 + "id": null, 5.12 "params": [], 5.13 "defaults": [], 5.14 "rest": null, 5.15 @@ -157,10 +154,7 @@ 5.16 }, 5.17 "value": { 5.18 "type": "FunctionExpression", 5.19 - "id": { 5.20 - "type": "Identifier", 5.21 - "name": "get y" 5.22 - }, 5.23 + "id": null, 5.24 "params": [], 5.25 "defaults": [], 5.26 "rest": null,