Tue, 02 Apr 2013 11:38:04 -0300
Merge
1.1 --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Tue Apr 02 11:37:22 2013 -0300 1.2 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Tue Apr 02 11:38:04 2013 -0300 1.3 @@ -125,10 +125,13 @@ 1.4 // function object representing TypeErrorThrower 1.5 private static ScriptFunction typeErrorThrower; 1.6 1.7 + /* 1.8 + * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object 1.9 + */ 1.10 static synchronized ScriptFunction getTypeErrorThrower() { 1.11 if (typeErrorThrower == null) { 1.12 - //name handle 1.13 - final ScriptFunctionImpl func = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_SETTER, null, null, false, false, false); 1.14 + // use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3 1.15 + final ScriptFunctionImpl func = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_GETTER, null, null, false, false, false); 1.16 func.setPrototype(UNDEFINED); 1.17 typeErrorThrower = func; 1.18 }
2.1 --- a/src/jdk/nashorn/internal/runtime/PropertyMap.java Tue Apr 02 11:37:22 2013 -0300 2.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java Tue Apr 02 11:38:04 2013 -0300 2.3 @@ -526,13 +526,11 @@ 2.4 * @param newMap {@link PropertyMap} associated with prototype. 2.5 */ 2.6 private void addToProtoHistory(final ScriptObject newProto, final PropertyMap newMap) { 2.7 - if (!properties.isEmpty()) { 2.8 - if (protoHistory == null) { 2.9 - protoHistory = new WeakHashMap<>(); 2.10 - } 2.11 + if (protoHistory == null) { 2.12 + protoHistory = new WeakHashMap<>(); 2.13 + } 2.14 2.15 - protoHistory.put(newProto, new WeakReference<>(newMap)); 2.16 - } 2.17 + protoHistory.put(newProto, new WeakReference<>(newMap)); 2.18 } 2.19 2.20 /** 2.21 @@ -542,13 +540,11 @@ 2.22 * @param newMap Modified {@link PropertyMap}. 2.23 */ 2.24 private void addToHistory(final Property property, final PropertyMap newMap) { 2.25 - if (!properties.isEmpty()) { 2.26 - if (history == null) { 2.27 - history = new LinkedHashMap<>(); 2.28 - } 2.29 + if (history == null) { 2.30 + history = new LinkedHashMap<>(); 2.31 + } 2.32 2.33 - history.put(property, newMap); 2.34 - } 2.35 + history.put(property, newMap); 2.36 } 2.37 2.38 /**
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/script/basic/JDK-8011209.js Tue Apr 02 11:38:04 2013 -0300 3.3 @@ -0,0 +1,76 @@ 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-8011209: Object.getOwnPropertyDescriptor(function(){"use strict"},"caller").get.length is not 0 3.29 + * 3.30 + * @test 3.31 + * @run 3.32 + */ 3.33 + 3.34 +var callerPropDesc = Object.getOwnPropertyDescriptor(function(){"use strict"},"caller"); 3.35 + 3.36 +var getterLen = callerPropDesc.get.length; 3.37 +if (getterLen != 0) { 3.38 + fail("caller's get.length != 0"); 3.39 +} 3.40 + 3.41 +var setterLen = callerPropDesc.set.length; 3.42 +if (setterLen != 0) { 3.43 + fail("caller's set.length != 1"); 3.44 +} 3.45 + 3.46 +var argumentsPropDesc = Object.getOwnPropertyDescriptor(function(){"use strict"},"arguments"); 3.47 + 3.48 +getterLen = argumentsPropDesc.get.length; 3.49 +if (getterLen != 0) { 3.50 + fail("arguments's get.length != 0"); 3.51 +} 3.52 + 3.53 +setterLen = argumentsPropDesc.set.length; 3.54 +if (setterLen != 0) { 3.55 + fail("arguments's set.length != 1"); 3.56 +} 3.57 + 3.58 +var strictArgs = (function() { 'use strict'; return arguments; })(); 3.59 +callerPropDesc = Object.getOwnPropertyDescriptor(strictArgs,"caller"); 3.60 +getterLen = callerPropDesc.get.length; 3.61 +if (getterLen != 0) { 3.62 + fail("argument.caller's get.length != 0"); 3.63 +} 3.64 + 3.65 +setterLen = callerPropDesc.set.length; 3.66 +if (setterLen != 0) { 3.67 + fail("argument.caller's set.length != 1"); 3.68 +} 3.69 + 3.70 +calleePropDesc = Object.getOwnPropertyDescriptor(strictArgs,"callee"); 3.71 +getterLen = calleePropDesc.get.length; 3.72 +if (getterLen != 0) { 3.73 + fail("argument.callee's get.length != 0"); 3.74 +} 3.75 + 3.76 +setterLen = calleePropDesc.set.length; 3.77 +if (setterLen != 0) { 3.78 + fail("argument.callee's set.length != 1"); 3.79 +}