Sat, 27 Jun 2015 23:21:08 -0700
Merge
1.1 --- a/THIRD_PARTY_README Wed Jun 24 10:41:26 2015 -0700 1.2 +++ b/THIRD_PARTY_README Sat Jun 27 23:21:08 2015 -0700 1.3 @@ -1140,37 +1140,6 @@ 1.4 1.5 -------------------------------------------------------------------------------- 1.6 1.7 -%% This notice is provided with respect to JSON, which may be included 1.8 -with JRE 8 & JDK 8. 1.9 - 1.10 ---- begin of LICENSE --- 1.11 - 1.12 -Copyright (c) 2002 JSON.org 1.13 - 1.14 -Permission is hereby granted, free of charge, to any person obtaining a copy 1.15 -of this software and associated documentation files (the "Software"), to deal 1.16 -in the Software without restriction, including without limitation the rights 1.17 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1.18 -copies of the Software, and to permit persons to whom the Software is 1.19 -furnished to do so, subject to the following conditions: 1.20 - 1.21 -The above copyright notice and this permission notice shall be included in all 1.22 -copies or substantial portions of the Software. 1.23 - 1.24 -The Software shall be used for Good, not Evil. 1.25 - 1.26 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.27 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.28 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1.29 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.30 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1.31 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1.32 -SOFTWARE. 1.33 - 1.34 ---- end of LICENSE --- 1.35 - 1.36 -------------------------------------------------------------------------------- 1.37 - 1.38 %% This notice is provided with respect to Kerberos functionality, which 1.39 which may be included with JRE 8, JDK 8, and OpenJDK 8. 1.40 1.41 @@ -1250,7 +1219,7 @@ 1.42 1.43 ------------------------------------------------------------------------------- 1.44 1.45 -%% This notice is provided with respect to libpng 1.6.16, which may be 1.46 +%% This notice is provided with respect to libpng 1.6.16, which may be 1.47 included with JRE 8, JDK 8, and OpenJDK 8. 1.48 1.49 --- begin of LICENSE --- 1.50 @@ -1370,7 +1339,7 @@ 1.51 1.52 ------------------------------------------------------------------------------- 1.53 1.54 -%% This notice is provided with respect to libungif 4.1.3, which may be 1.55 +%% This notice is provided with respect to GIFLIB 5.1.1 & libungif 4.1.3, which may be 1.56 included with JRE 8, JDK 8, and OpenJDK 8. 1.57 1.58 --- begin of LICENSE --- 1.59 @@ -1399,13 +1368,13 @@ 1.60 1.61 ------------------------------------------------------------------------------- 1.62 1.63 -%% This notice is provided with respect to Little CMS 2.5, which may be 1.64 +%% This notice is provided with respect to Little CMS 2.7, which may be 1.65 included with JRE 8, JDK 8, and OpenJDK 8. 1.66 1.67 --- begin of LICENSE --- 1.68 1.69 Little CMS 1.70 -Copyright (c) 1998-2011 Marti Maria Saguer 1.71 +Copyright (c) 1998-2015 Marti Maria Saguer 1.72 1.73 Permission is hereby granted, free of charge, to any person obtaining a copy 1.74 of this software and associated documentation files (the "Software"), to deal
2.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Wed Jun 24 10:41:26 2015 -0700 2.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Sat Jun 27 23:21:08 2015 -0700 2.3 @@ -152,6 +152,7 @@ 2.4 } 2.5 2.6 if (constructor != null) { 2.7 + initPrototype(mi); 2.8 final int arity = constructor.getArity(); 2.9 if (arity != MemberInfo.DEFAULT_ARITY) { 2.10 mi.loadThis(); 2.11 @@ -193,6 +194,7 @@ 2.12 } 2.13 2.14 private void initFunctionFields(final MethodGenerator mi) { 2.15 + assert memberCount > 0; 2.16 for (final MemberInfo memInfo : scriptClassInfo.getMembers()) { 2.17 if (!memInfo.isConstructorFunction()) { 2.18 continue; 2.19 @@ -204,37 +206,39 @@ 2.20 } 2.21 2.22 private void initDataFields(final MethodGenerator mi) { 2.23 - for (final MemberInfo memInfo : scriptClassInfo.getMembers()) { 2.24 - if (!memInfo.isConstructorProperty() || memInfo.isFinal()) { 2.25 - continue; 2.26 - } 2.27 - final Object value = memInfo.getValue(); 2.28 - if (value != null) { 2.29 - mi.loadThis(); 2.30 - mi.loadLiteral(value); 2.31 - mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); 2.32 - } else if (!memInfo.getInitClass().isEmpty()) { 2.33 - final String clazz = memInfo.getInitClass(); 2.34 - mi.loadThis(); 2.35 - mi.newObject(clazz); 2.36 - mi.dup(); 2.37 - mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC); 2.38 - mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); 2.39 - } 2.40 + assert memberCount > 0; 2.41 + for (final MemberInfo memInfo : scriptClassInfo.getMembers()) { 2.42 + if (!memInfo.isConstructorProperty() || memInfo.isFinal()) { 2.43 + continue; 2.44 + } 2.45 + final Object value = memInfo.getValue(); 2.46 + if (value != null) { 2.47 + mi.loadThis(); 2.48 + mi.loadLiteral(value); 2.49 + mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); 2.50 + } else if (!memInfo.getInitClass().isEmpty()) { 2.51 + final String clazz = memInfo.getInitClass(); 2.52 + mi.loadThis(); 2.53 + mi.newObject(clazz); 2.54 + mi.dup(); 2.55 + mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC); 2.56 + mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); 2.57 + } 2.58 } 2.59 + } 2.60 2.61 - if (constructor != null) { 2.62 - mi.loadThis(); 2.63 - final String protoName = scriptClassInfo.getPrototypeClassName(); 2.64 - mi.newObject(protoName); 2.65 - mi.dup(); 2.66 - mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC); 2.67 - mi.dup(); 2.68 - mi.loadThis(); 2.69 - mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR, 2.70 - PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC); 2.71 - mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC); 2.72 - } 2.73 + private void initPrototype(final MethodGenerator mi) { 2.74 + assert constructor != null; 2.75 + mi.loadThis(); 2.76 + final String protoName = scriptClassInfo.getPrototypeClassName(); 2.77 + mi.newObject(protoName); 2.78 + mi.dup(); 2.79 + mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC); 2.80 + mi.dup(); 2.81 + mi.loadThis(); 2.82 + mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR, 2.83 + PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC); 2.84 + mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC); 2.85 } 2.86 2.87 /**
3.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java Wed Jun 24 10:41:26 2015 -0700 3.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java Sat Jun 27 23:21:08 2015 -0700 3.3 @@ -134,7 +134,7 @@ 3.4 String simpleName = inFile.getName(); 3.5 simpleName = simpleName.substring(0, simpleName.indexOf(".class")); 3.6 3.7 - if (sci.getPrototypeMemberCount() > 0) { 3.8 + if (sci.isPrototypeNeeded()) { 3.9 // generate prototype class 3.10 final PrototypeGenerator protGen = new PrototypeGenerator(sci); 3.11 buf = protGen.getClassBytes(); 3.12 @@ -146,7 +146,7 @@ 3.13 } 3.14 } 3.15 3.16 - if (sci.getConstructorMemberCount() > 0 || sci.getConstructor() != null) { 3.17 + if (sci.isConstructorNeeded()) { 3.18 // generate constructor class 3.19 final ConstructorGenerator consGen = new ConstructorGenerator(sci); 3.20 buf = consGen.getClassBytes();
4.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Wed Jun 24 10:41:26 2015 -0700 4.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Sat Jun 27 23:21:08 2015 -0700 4.3 @@ -126,10 +126,42 @@ 4.4 return Collections.unmodifiableList(res); 4.5 } 4.6 4.7 + boolean isConstructorNeeded() { 4.8 + // Constructor class generation is needed if we one or 4.9 + // more constructor properties are defined or @Constructor 4.10 + // is defined in the class. 4.11 + for (final MemberInfo memInfo : members) { 4.12 + if (memInfo.getKind() == Kind.CONSTRUCTOR || 4.13 + memInfo.getWhere() == Where.CONSTRUCTOR) { 4.14 + return true; 4.15 + } 4.16 + } 4.17 + return false; 4.18 + } 4.19 + 4.20 + boolean isPrototypeNeeded() { 4.21 + // Prototype class generation is needed if we have atleast one 4.22 + // prototype property or @Constructor defined in the class. 4.23 + for (final MemberInfo memInfo : members) { 4.24 + if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) { 4.25 + return true; 4.26 + } 4.27 + } 4.28 + return false; 4.29 + } 4.30 + 4.31 int getPrototypeMemberCount() { 4.32 int count = 0; 4.33 for (final MemberInfo memInfo : members) { 4.34 - if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) { 4.35 + switch (memInfo.getKind()) { 4.36 + case SETTER: 4.37 + case SPECIALIZED_FUNCTION: 4.38 + // SETTER was counted when GETTER was encountered. 4.39 + // SPECIALIZED_FUNCTION was counted as FUNCTION already. 4.40 + continue; 4.41 + } 4.42 + 4.43 + if (memInfo.getWhere() == Where.PROTOTYPE) { 4.44 count++; 4.45 } 4.46 } 4.47 @@ -139,6 +171,16 @@ 4.48 int getConstructorMemberCount() { 4.49 int count = 0; 4.50 for (final MemberInfo memInfo : members) { 4.51 + switch (memInfo.getKind()) { 4.52 + case CONSTRUCTOR: 4.53 + case SETTER: 4.54 + case SPECIALIZED_FUNCTION: 4.55 + // SETTER was counted when GETTER was encountered. 4.56 + // Constructor and constructor SpecializedFunctions 4.57 + // are not added as members and so not counted. 4.58 + continue; 4.59 + } 4.60 + 4.61 if (memInfo.getWhere() == Where.CONSTRUCTOR) { 4.62 count++; 4.63 } 4.64 @@ -149,6 +191,14 @@ 4.65 int getInstancePropertyCount() { 4.66 int count = 0; 4.67 for (final MemberInfo memInfo : members) { 4.68 + switch (memInfo.getKind()) { 4.69 + case SETTER: 4.70 + case SPECIALIZED_FUNCTION: 4.71 + // SETTER was counted when GETTER was encountered. 4.72 + // SPECIALIZED_FUNCTION was counted as FUNCTION already. 4.73 + continue; 4.74 + } 4.75 + 4.76 if (memInfo.getWhere() == Where.INSTANCE) { 4.77 count++; 4.78 }
5.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java Wed Jun 24 10:41:26 2015 -0700 5.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java Sat Jun 27 23:21:08 2015 -0700 5.3 @@ -288,9 +288,7 @@ 5.4 where = Where.PROTOTYPE; 5.5 break; 5.6 case SPECIALIZED_FUNCTION: 5.7 - if (isSpecializedConstructor) { 5.8 - where = Where.CONSTRUCTOR; 5.9 - } 5.10 + where = isSpecializedConstructor? Where.CONSTRUCTOR : Where.PROTOTYPE; 5.11 //fallthru 5.12 default: 5.13 break;
6.1 --- a/src/jdk/nashorn/internal/codegen/Compiler.java Wed Jun 24 10:41:26 2015 -0700 6.2 +++ b/src/jdk/nashorn/internal/codegen/Compiler.java Sat Jun 27 23:21:08 2015 -0700 6.3 @@ -103,7 +103,7 @@ 6.4 6.5 private final CodeInstaller<ScriptEnvironment> installer; 6.6 6.7 - /** logger for compiler, trampolines, splits and related code generation events 6.8 + /** logger for compiler, trampolines and related code generation events 6.9 * that affect classes */ 6.10 private final DebugLogger log; 6.11
7.1 --- a/src/jdk/nashorn/internal/codegen/Splitter.java Wed Jun 24 10:41:26 2015 -0700 7.2 +++ b/src/jdk/nashorn/internal/codegen/Splitter.java Sat Jun 27 23:21:08 2015 -0700 7.3 @@ -42,13 +42,17 @@ 7.4 import jdk.nashorn.internal.ir.SplitNode; 7.5 import jdk.nashorn.internal.ir.Statement; 7.6 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 7.7 +import jdk.nashorn.internal.runtime.Context; 7.8 import jdk.nashorn.internal.runtime.logging.DebugLogger; 7.9 +import jdk.nashorn.internal.runtime.logging.Loggable; 7.10 +import jdk.nashorn.internal.runtime.logging.Logger; 7.11 import jdk.nashorn.internal.runtime.options.Options; 7.12 7.13 /** 7.14 * Split the IR into smaller compile units. 7.15 */ 7.16 -final class Splitter extends NodeVisitor<LexicalContext> { 7.17 +@Logger(name="splitter") 7.18 +final class Splitter extends NodeVisitor<LexicalContext> implements Loggable { 7.19 /** Current compiler. */ 7.20 private final Compiler compiler; 7.21 7.22 @@ -78,7 +82,17 @@ 7.23 this.compiler = compiler; 7.24 this.outermost = functionNode; 7.25 this.outermostCompileUnit = outermostCompileUnit; 7.26 - this.log = compiler.getLogger(); 7.27 + this.log = initLogger(compiler.getContext()); 7.28 + } 7.29 + 7.30 + @Override 7.31 + public DebugLogger initLogger(final Context context) { 7.32 + return context.getLogger(this.getClass()); 7.33 + } 7.34 + 7.35 + @Override 7.36 + public DebugLogger getLogger() { 7.37 + return log; 7.38 } 7.39 7.40 /** 7.41 @@ -89,7 +103,7 @@ 7.42 FunctionNode split(final FunctionNode fn, final boolean top) { 7.43 FunctionNode functionNode = fn; 7.44 7.45 - log.finest("Initiating split of '", functionNode.getName(), "'"); 7.46 + log.fine("Initiating split of '", functionNode.getName(), "'"); 7.47 7.48 long weight = WeighNodes.weigh(functionNode); 7.49 7.50 @@ -98,7 +112,7 @@ 7.51 assert lc.isEmpty() : "LexicalContext not empty"; 7.52 7.53 if (weight >= SPLIT_THRESHOLD) { 7.54 - log.finest("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); 7.55 + log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); 7.56 functionNode = (FunctionNode)functionNode.accept(this); 7.57 7.58 if (functionNode.isSplit()) {
8.1 --- a/src/jdk/nashorn/internal/codegen/types/BooleanType.java Wed Jun 24 10:41:26 2015 -0700 8.2 +++ b/src/jdk/nashorn/internal/codegen/types/BooleanType.java Sat Jun 27 23:21:08 2015 -0700 8.3 @@ -1,28 +1,3 @@ 8.4 -/* 8.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 8.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 - * 8.8 - * This code is free software; you can redistribute it and/or modify it 8.9 - * under the terms of the GNU General Public License version 2 only, as 8.10 - * published by the Free Software Foundation. Oracle designates this 8.11 - * particular file as subject to the "Classpath" exception as provided 8.12 - * by Oracle in the LICENSE file that accompanied this code. 8.13 - * 8.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 8.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.17 - * version 2 for more details (a copy is included in the LICENSE file that 8.18 - * accompanied this code). 8.19 - * 8.20 - * You should have received a copy of the GNU General Public License version 8.21 - * 2 along with this work; if not, write to the Free Software Foundation, 8.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.23 - * 8.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.25 - * or visit www.oracle.com if you need additional information or have any 8.26 - * questions. 8.27 - */ 8.28 - 8.29 /* 8.30 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 8.31 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9.1 --- a/src/jdk/nashorn/internal/objects/Global.java Wed Jun 24 10:41:26 2015 -0700 9.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Sat Jun 27 23:21:08 2015 -0700 9.3 @@ -87,7 +87,7 @@ 9.4 * Representation of global scope. 9.5 */ 9.6 @ScriptClass("Global") 9.7 -public final class Global extends ScriptObject implements Scope { 9.8 +public final class Global extends Scope { 9.9 // Placeholder value used in place of a location property (__FILE__, __DIR__, __LINE__) 9.10 private static final Object LOCATION_PROPERTY_PLACEHOLDER = new Object(); 9.11 private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class); 9.12 @@ -906,9 +906,6 @@ 9.13 */ 9.14 private ScriptFunction typeErrorThrower; 9.15 9.16 - // Flag to indicate that a split method issued a return statement 9.17 - private int splitState = -1; 9.18 - 9.19 // Used to store the last RegExp result to support deprecated RegExp constructor properties 9.20 private RegExpResult lastRegExpResult; 9.21 9.22 @@ -995,7 +992,6 @@ 9.23 public Global(final Context context) { 9.24 super(checkAndGetMap(context)); 9.25 this.context = context; 9.26 - this.setIsScope(); 9.27 this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null; 9.28 } 9.29 9.30 @@ -1502,26 +1498,53 @@ 9.31 } 9.32 9.33 /** 9.34 - * Global load implementation - Nashorn extension 9.35 + * Global load implementation - Nashorn extension. 9.36 * 9.37 - * @param self scope 9.38 - * @param source source to load 9.39 + * <p> 9.40 + * load builtin loads the given script. Script source can be a URL or a File 9.41 + * or a script object with name and script properties. Evaluated code gets 9.42 + * global object "this" and uses global object as scope for evaluation. 9.43 + * </p> 9.44 + * <p> 9.45 + * If self is undefined or null or global, then global object is used 9.46 + * as scope as well as "this" for the evaluated code. If self is any other 9.47 + * object, then it is indirect load call. With indirect load call, the 9.48 + * properties of scope are available to evaluated script as variables. Also, 9.49 + * global scope properties are accessible. Any var, function definition in 9.50 + * evaluated script goes into an object that is not accessible to user scripts. 9.51 + * </p> 9.52 + * Thus the indirect load call is equivalent to the following: 9.53 + * <pre> 9.54 + * <code> 9.55 + * (function (scope, source) { 9.56 + * with(scope) { 9.57 + * eval(<script_from_source>); 9.58 + * } 9.59 + * })(self, source); 9.60 + * </code> 9.61 + * </pre> 9.62 * 9.63 - * @return result of load (undefined) 9.64 + * @param self scope to use for the script evaluation 9.65 + * @param source script source 9.66 + * 9.67 + * @return result of load (may be undefined) 9.68 * 9.69 * @throws IOException if source could not be read 9.70 */ 9.71 public static Object load(final Object self, final Object source) throws IOException { 9.72 final Global global = Global.instanceFrom(self); 9.73 - final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global; 9.74 - return global.getContext().load(scope, source); 9.75 + return global.getContext().load(self, source); 9.76 } 9.77 9.78 /** 9.79 - * Global loadWithNewGlobal implementation - Nashorn extension 9.80 + * Global loadWithNewGlobal implementation - Nashorn extension. 9.81 * 9.82 - * @param self scope 9.83 - * @param args from plus (optional) arguments to be passed to the loaded script 9.84 + * loadWithNewGlobal builtin loads the given script from a URL or a File 9.85 + * or a script object with name and script properties. Evaluated code gets 9.86 + * new global object "this" and uses that new global object as scope for evaluation. 9.87 + * 9.88 + * @param self self This value is ignored by this function 9.89 + * @param args optional arguments to be passed to the loaded script 9.90 * 9.91 * @return result of load (may be undefined) 9.92 * 9.93 @@ -2328,26 +2351,6 @@ 9.94 } 9.95 9.96 /** 9.97 - * Get the current split state. 9.98 - * 9.99 - * @return current split state 9.100 - */ 9.101 - @Override 9.102 - public int getSplitState() { 9.103 - return splitState; 9.104 - } 9.105 - 9.106 - /** 9.107 - * Set the current split state. 9.108 - * 9.109 - * @param state current split state 9.110 - */ 9.111 - @Override 9.112 - public void setSplitState(final int state) { 9.113 - splitState = state; 9.114 - } 9.115 - 9.116 - /** 9.117 * Return the ES6 global scope for lexically declared bindings. 9.118 * @return the ES6 lexical global scope. 9.119 */
10.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Wed Jun 24 10:41:26 2015 -0700 10.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Sat Jun 27 23:21:08 2015 -0700 10.3 @@ -37,6 +37,7 @@ 10.4 import jdk.nashorn.internal.runtime.JSType; 10.5 import jdk.nashorn.internal.runtime.PropertyListeners; 10.6 import jdk.nashorn.internal.runtime.PropertyMap; 10.7 +import jdk.nashorn.internal.runtime.Scope; 10.8 import jdk.nashorn.internal.runtime.ScriptFunction; 10.9 import jdk.nashorn.internal.runtime.ScriptObject; 10.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 10.11 @@ -245,7 +246,7 @@ 10.12 final PrintWriter out = Context.getCurrentErr(); 10.13 10.14 out.println("ScriptObject count " + ScriptObject.getCount()); 10.15 - out.println("Scope count " + ScriptObject.getScopeCount()); 10.16 + out.println("Scope count " + Scope.getCount()); 10.17 out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded()); 10.18 out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved()); 10.19 out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
11.1 --- a/src/jdk/nashorn/internal/parser/AbstractParser.java Wed Jun 24 10:41:26 2015 -0700 11.2 +++ b/src/jdk/nashorn/internal/parser/AbstractParser.java Sat Jun 27 23:21:08 2015 -0700 11.3 @@ -459,6 +459,19 @@ 11.4 if (kind == TokenKind.KEYWORD || kind == TokenKind.FUTURE || kind == TokenKind.FUTURESTRICT) { 11.5 return true; 11.6 } 11.7 + 11.8 + // only literals allowed are null, false and true 11.9 + if (kind == TokenKind.LITERAL) { 11.10 + switch (type) { 11.11 + case FALSE: 11.12 + case NULL: 11.13 + case TRUE: 11.14 + return true; 11.15 + default: 11.16 + return false; 11.17 + } 11.18 + } 11.19 + 11.20 // Fake out identifier. 11.21 final long identToken = Token.recast(token, IDENT); 11.22 // Get IDENT.
12.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Wed Jun 24 10:41:26 2015 -0700 12.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Sat Jun 27 23:21:08 2015 -0700 12.3 @@ -724,16 +724,8 @@ 12.4 // In strict mode, eval does not instantiate variables and functions 12.5 // in the caller's environment. A new environment is created! 12.6 if (strictFlag) { 12.7 - // Create a new scope object 12.8 - final ScriptObject strictEvalScope = global.newObject(); 12.9 - 12.10 - // bless it as a "scope" 12.11 - strictEvalScope.setIsScope(); 12.12 - 12.13 - // set given scope to be it's proto so that eval can still 12.14 - // access caller environment vars in the new environment. 12.15 - strictEvalScope.setProto(scope); 12.16 - scope = strictEvalScope; 12.17 + // Create a new scope object with given scope as its prototype 12.18 + scope = newScope(scope); 12.19 } 12.20 12.21 final ScriptFunction func = getProgramFunction(clazz, scope); 12.22 @@ -748,6 +740,10 @@ 12.23 return ScriptRuntime.apply(func, evalThis); 12.24 } 12.25 12.26 + private static ScriptObject newScope(final ScriptObject callerScope) { 12.27 + return new Scope(callerScope, PropertyMap.newMap(Scope.class)); 12.28 + } 12.29 + 12.30 private static Source loadInternal(final String srcStr, final String prefix, final String resourcePath) { 12.31 if (srcStr.startsWith(prefix)) { 12.32 final String resource = resourcePath + srcStr.substring(prefix.length()); 12.33 @@ -781,7 +777,7 @@ 12.34 * 12.35 * @throws IOException if source cannot be found or loaded 12.36 */ 12.37 - public Object load(final ScriptObject scope, final Object from) throws IOException { 12.38 + public Object load(final Object scope, final Object from) throws IOException { 12.39 final Object src = from instanceof ConsString ? from.toString() : from; 12.40 Source source = null; 12.41 12.42 @@ -833,7 +829,42 @@ 12.43 } 12.44 12.45 if (source != null) { 12.46 - return evaluateSource(source, scope, scope); 12.47 + if (scope instanceof ScriptObject && ((ScriptObject)scope).isScope()) { 12.48 + final ScriptObject sobj = (ScriptObject)scope; 12.49 + // passed object is a script object 12.50 + // Global is the only user accessible scope ScriptObject 12.51 + assert sobj.isGlobal() : "non-Global scope object!!"; 12.52 + return evaluateSource(source, sobj, sobj); 12.53 + } else if (scope == null || scope == UNDEFINED) { 12.54 + // undefined or null scope. Use current global instance. 12.55 + final Global global = getGlobal(); 12.56 + return evaluateSource(source, global, global); 12.57 + } else { 12.58 + /* 12.59 + * Arbitrary object passed for scope. 12.60 + * Indirect load that is equivalent to: 12.61 + * 12.62 + * (function(scope, source) { 12.63 + * with (scope) { 12.64 + * eval(<script_from_source>); 12.65 + * } 12.66 + * })(scope, source); 12.67 + */ 12.68 + final Global global = getGlobal(); 12.69 + // Create a new object. This is where all declarations 12.70 + // (var, function) from the evaluated code go. 12.71 + // make global to be its __proto__ so that global 12.72 + // definitions are accessible to the evaluated code. 12.73 + final ScriptObject evalScope = newScope(global); 12.74 + 12.75 + // finally, make a WithObject around user supplied scope object 12.76 + // so that it's properties are accessible as variables. 12.77 + final ScriptObject withObj = ScriptRuntime.openWith(evalScope, scope); 12.78 + 12.79 + // evaluate given source with 'withObj' as scope 12.80 + // but use global object as "this". 12.81 + return evaluateSource(source, withObj, global); 12.82 + } 12.83 } 12.84 12.85 throw typeError("cant.load.script", ScriptRuntime.safeToString(from));
13.1 --- a/src/jdk/nashorn/internal/runtime/FunctionScope.java Wed Jun 24 10:41:26 2015 -0700 13.2 +++ b/src/jdk/nashorn/internal/runtime/FunctionScope.java Sat Jun 27 23:21:08 2015 -0700 13.3 @@ -35,17 +35,12 @@ 13.4 * 13.5 * The constructor of this class is responsible for any function prologue 13.6 * involving the scope. 13.7 - * 13.8 - * TODO see NASHORN-715. 13.9 */ 13.10 -public class FunctionScope extends ScriptObject implements Scope { 13.11 +public class FunctionScope extends Scope { 13.12 13.13 /** Area to store scope arguments. (public for access from scripts.) */ 13.14 public final ScriptObject arguments; 13.15 13.16 - /** Flag to indicate that a split method issued a return statement */ 13.17 - private int splitState = -1; 13.18 - 13.19 /** 13.20 * Constructor 13.21 * 13.22 @@ -56,7 +51,6 @@ 13.23 public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final ScriptObject arguments) { 13.24 super(callerScope, map); 13.25 this.arguments = arguments; 13.26 - setIsScope(); 13.27 } 13.28 13.29 /** 13.30 @@ -68,7 +62,6 @@ 13.31 public FunctionScope(final PropertyMap map, final ScriptObject callerScope) { 13.32 super(callerScope, map); 13.33 this.arguments = null; 13.34 - setIsScope(); 13.35 } 13.36 13.37 /** 13.38 @@ -82,23 +75,4 @@ 13.39 super(map, primitiveSpill, objectSpill); 13.40 this.arguments = null; 13.41 } 13.42 - 13.43 - 13.44 - /** 13.45 - * Get the current split state. 13.46 - * @return current split state 13.47 - */ 13.48 - @Override 13.49 - public int getSplitState() { 13.50 - return splitState; 13.51 - } 13.52 - 13.53 - /** 13.54 - * Set the current split state. 13.55 - * @param state current split state 13.56 - */ 13.57 - @Override 13.58 - public void setSplitState(final int state) { 13.59 - splitState = state; 13.60 - } 13.61 }
14.1 --- a/src/jdk/nashorn/internal/runtime/Scope.java Wed Jun 24 10:41:26 2015 -0700 14.2 +++ b/src/jdk/nashorn/internal/runtime/Scope.java Sat Jun 27 23:21:08 2015 -0700 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -25,30 +25,105 @@ 14.11 14.12 package jdk.nashorn.internal.runtime; 14.13 14.14 -import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup; 14.15 +import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; 14.16 14.17 import jdk.nashorn.internal.codegen.CompilerConstants; 14.18 14.19 /** 14.20 - * Interface implemented by {@link ScriptObject}s that act as scope. 14.21 + * A {@link ScriptObject} subclass for objects that act as scope. 14.22 */ 14.23 -public interface Scope { 14.24 +public class Scope extends ScriptObject { 14.25 + 14.26 + /* This is used to store return state of split functions. */ 14.27 + private int splitState = -1; 14.28 + 14.29 + /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */ 14.30 + private static int count; 14.31 14.32 /** Method handle that points to {@link Scope#getSplitState}. */ 14.33 - public static final CompilerConstants.Call GET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "getSplitState", int.class); 14.34 + public static final CompilerConstants.Call GET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "getSplitState", int.class); 14.35 + /** Method handle that points to {@link Scope#setSplitState(int)}. */ 14.36 + public static final CompilerConstants.Call SET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "setSplitState", void.class, int.class); 14.37 14.38 - /** Method handle that points to {@link Scope#setSplitState(int)}. */ 14.39 - public static final CompilerConstants.Call SET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "setSplitState", void.class, int.class); 14.40 + /** 14.41 + * Constructor 14.42 + * 14.43 + * @param map initial property map 14.44 + */ 14.45 + public Scope(final PropertyMap map) { 14.46 + super(map); 14.47 + if (Context.DEBUG) { 14.48 + count++; 14.49 + } 14.50 + } 14.51 + 14.52 + /** 14.53 + * Constructor 14.54 + * 14.55 + * @param proto parent scope 14.56 + * @param map initial property map 14.57 + */ 14.58 + public Scope(final ScriptObject proto, final PropertyMap map) { 14.59 + super(proto, map); 14.60 + if (Context.DEBUG) { 14.61 + count++; 14.62 + } 14.63 + } 14.64 + 14.65 + /** 14.66 + * Constructor 14.67 + * 14.68 + * @param map property map 14.69 + * @param primitiveSpill primitive spill array 14.70 + * @param objectSpill reference spill array 14.71 + */ 14.72 + public Scope(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) { 14.73 + super(map, primitiveSpill, objectSpill); 14.74 + if (Context.DEBUG) { 14.75 + count++; 14.76 + } 14.77 + } 14.78 + 14.79 + @Override 14.80 + public boolean isScope() { 14.81 + return true; 14.82 + } 14.83 + 14.84 + @Override 14.85 + boolean hasWithScope() { 14.86 + for (ScriptObject obj = this; obj != null; obj = obj.getProto()) { 14.87 + if (obj instanceof WithObject) { 14.88 + return true; 14.89 + } 14.90 + } 14.91 + return false; 14.92 + } 14.93 14.94 /** 14.95 * Get the scope's split method state. 14.96 - * @return the current state 14.97 + * 14.98 + * @return current split state 14.99 */ 14.100 - public int getSplitState(); 14.101 + public int getSplitState() { 14.102 + return splitState; 14.103 + } 14.104 14.105 /** 14.106 * Set the scope's split method state. 14.107 - * @param state the new state. 14.108 + * 14.109 + * @param state current split state 14.110 */ 14.111 - public void setSplitState(int state); 14.112 + public void setSplitState(final int state) { 14.113 + splitState = state; 14.114 + } 14.115 + 14.116 + /** 14.117 + * Get number of {@code Scope} instances created. If not running in debug 14.118 + * mode this is always 0. 14.119 + * 14.120 + * @return number of scope ScriptObjects created 14.121 + */ 14.122 + public static int getScopeCount() { 14.123 + return count; 14.124 + } 14.125 }
15.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Wed Jun 24 10:41:26 2015 -0700 15.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Sat Jun 27 23:21:08 2015 -0700 15.3 @@ -109,20 +109,17 @@ 15.4 /** Search fall back routine name for "no such property" */ 15.5 public static final String NO_SUCH_PROPERTY_NAME = "__noSuchProperty__"; 15.6 15.7 - /** Per ScriptObject flag - is this a scope object? */ 15.8 - public static final int IS_SCOPE = 1 << 0; 15.9 - 15.10 /** Per ScriptObject flag - is this an array object? */ 15.11 - public static final int IS_ARRAY = 1 << 1; 15.12 + public static final int IS_ARRAY = 1 << 0; 15.13 15.14 /** Per ScriptObject flag - is this an arguments object? */ 15.15 - public static final int IS_ARGUMENTS = 1 << 2; 15.16 + public static final int IS_ARGUMENTS = 1 << 1; 15.17 15.18 /** Is length property not-writable? */ 15.19 - public static final int IS_LENGTH_NOT_WRITABLE = 1 << 3; 15.20 + public static final int IS_LENGTH_NOT_WRITABLE = 1 << 2; 15.21 15.22 /** Is this a builtin object? */ 15.23 - public static final int IS_BUILTIN = 1 << 4; 15.24 + public static final int IS_BUILTIN = 1 << 3; 15.25 15.26 /** 15.27 * Spill growth rate - by how many elements does {@link ScriptObject#primitiveSpill} and 15.28 @@ -396,14 +393,6 @@ 15.29 } 15.30 15.31 /** 15.32 - * ECMA 8.10.3 IsGenericDescriptor ( Desc ) 15.33 - * @return true if this has a descriptor describing an {@link AccessorPropertyDescriptor} or {@link DataPropertyDescriptor} 15.34 - */ 15.35 - public final boolean isGenericDescriptor() { 15.36 - return isAccessorDescriptor() || isDataDescriptor(); 15.37 - } 15.38 - 15.39 - /** 15.40 * ECMA 8.10.5 ToPropertyDescriptor ( Obj ) 15.41 * 15.42 * @return property descriptor 15.43 @@ -1630,23 +1619,12 @@ 15.44 return getMap().isFrozen(); 15.45 } 15.46 15.47 - 15.48 - /** 15.49 - * Flag this ScriptObject as scope 15.50 - */ 15.51 - public final void setIsScope() { 15.52 - if (Context.DEBUG) { 15.53 - scopeCount++; 15.54 - } 15.55 - flags |= IS_SCOPE; 15.56 - } 15.57 - 15.58 /** 15.59 * Check whether this ScriptObject is scope 15.60 * @return true if scope 15.61 */ 15.62 - public final boolean isScope() { 15.63 - return (flags & IS_SCOPE) != 0; 15.64 + public boolean isScope() { 15.65 + return false; 15.66 } 15.67 15.68 /** 15.69 @@ -1921,14 +1899,7 @@ 15.70 * Test whether this object contains in its prototype chain or is itself a with-object. 15.71 * @return true if a with-object was found 15.72 */ 15.73 - final boolean hasWithScope() { 15.74 - if (isScope()) { 15.75 - for (ScriptObject obj = this; obj != null; obj = obj.getProto()) { 15.76 - if (obj instanceof WithObject) { 15.77 - return true; 15.78 - } 15.79 - } 15.80 - } 15.81 + boolean hasWithScope() { 15.82 return false; 15.83 } 15.84 15.85 @@ -3817,9 +3788,6 @@ 15.86 /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created */ 15.87 private static int count; 15.88 15.89 - /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */ 15.90 - private static int scopeCount; 15.91 - 15.92 /** 15.93 * Get number of {@code ScriptObject} instances created. If not running in debug 15.94 * mode this is always 0 15.95 @@ -3829,15 +3797,4 @@ 15.96 public static int getCount() { 15.97 return count; 15.98 } 15.99 - 15.100 - /** 15.101 - * Get number of scope {@code ScriptObject} instances created. If not running in debug 15.102 - * mode this is always 0 15.103 - * 15.104 - * @return number of scope ScriptObjects created 15.105 - */ 15.106 - public static int getScopeCount() { 15.107 - return scopeCount; 15.108 - } 15.109 - 15.110 }
16.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Wed Jun 24 10:41:26 2015 -0700 16.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Sat Jun 27 23:21:08 2015 -0700 16.3 @@ -373,9 +373,9 @@ 16.4 * @return prototype object after merge 16.5 */ 16.6 public static ScriptObject mergeScope(final ScriptObject scope) { 16.7 - final ScriptObject global = scope.getProto(); 16.8 - global.addBoundProperties(scope); 16.9 - return global; 16.10 + final ScriptObject parentScope = scope.getProto(); 16.11 + parentScope.addBoundProperties(scope); 16.12 + return parentScope; 16.13 } 16.14 16.15 /**
17.1 --- a/src/jdk/nashorn/internal/runtime/WithObject.java Wed Jun 24 10:41:26 2015 -0700 17.2 +++ b/src/jdk/nashorn/internal/runtime/WithObject.java Sat Jun 27 23:21:08 2015 -0700 17.3 @@ -44,7 +44,7 @@ 17.4 * This class supports the handling of scope in a with body. 17.5 * 17.6 */ 17.7 -public final class WithObject extends ScriptObject implements Scope { 17.8 +public final class WithObject extends Scope { 17.9 private static final MethodHandle WITHEXPRESSIONGUARD = findOwnMH("withExpressionGuard", boolean.class, Object.class, PropertyMap.class, SwitchPoint.class); 17.10 private static final MethodHandle WITHEXPRESSIONFILTER = findOwnMH("withFilterExpression", Object.class, Object.class); 17.11 private static final MethodHandle WITHSCOPEFILTER = findOwnMH("withFilterScope", Object.class, Object.class); 17.12 @@ -62,7 +62,6 @@ 17.13 */ 17.14 WithObject(final ScriptObject scope, final ScriptObject expression) { 17.15 super(scope, null); 17.16 - setIsScope(); 17.17 this.expression = expression; 17.18 } 17.19 17.20 @@ -224,29 +223,33 @@ 17.21 17.22 @Override 17.23 public void setSplitState(final int state) { 17.24 - getNonWithParent().setSplitState(state); 17.25 + ((Scope) getNonWithParent()).setSplitState(state); 17.26 } 17.27 17.28 @Override 17.29 public int getSplitState() { 17.30 - return getNonWithParent().getSplitState(); 17.31 + return ((Scope) getNonWithParent()).getSplitState(); 17.32 + } 17.33 + 17.34 + @Override 17.35 + public void addBoundProperties(final ScriptObject source, final Property[] properties) { 17.36 + // Declared variables in nested eval go to first normal (non-with) parent scope. 17.37 + getNonWithParent().addBoundProperties(source, properties); 17.38 } 17.39 17.40 /** 17.41 * Get first parent scope that is not an instance of WithObject. 17.42 */ 17.43 - private Scope getNonWithParent() { 17.44 - ScriptObject proto = getParentScope(); 17.45 + private ScriptObject getNonWithParent() { 17.46 + ScriptObject proto = getProto(); 17.47 17.48 while (proto != null && proto instanceof WithObject) { 17.49 - proto = ((WithObject)proto).getParentScope(); 17.50 + proto = proto.getProto(); 17.51 } 17.52 17.53 - assert proto instanceof Scope : "with scope without parent scope"; 17.54 - return (Scope) proto; 17.55 + return proto; 17.56 } 17.57 17.58 - 17.59 private static GuardedInvocation fixReceiverType(final GuardedInvocation link, final MethodHandle filter) { 17.60 // The receiver may be an Object or a ScriptObject. 17.61 final MethodType invType = link.getInvocation().type(); 17.62 @@ -380,14 +383,6 @@ 17.63 return expression; 17.64 } 17.65 17.66 - /** 17.67 - * Get the parent scope for this {@code WithObject} 17.68 - * @return the parent scope 17.69 - */ 17.70 - public ScriptObject getParentScope() { 17.71 - return getProto(); 17.72 - } 17.73 - 17.74 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 17.75 return MH.findStatic(MethodHandles.lookup(), WithObject.class, name, MH.type(rtype, types)); 17.76 }
18.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Wed Jun 24 10:41:26 2015 -0700 18.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Sat Jun 27 23:21:08 2015 -0700 18.3 @@ -106,7 +106,9 @@ 18.4 * <li> 18.5 * If the adapter being generated can have class-level overrides, constructors taking same arguments as the superclass 18.6 * constructors are created. These constructors simply delegate to the superclass constructor. They are simply used to 18.7 - * create instances of the adapter class, with no instance-level overrides, as they don't have them. 18.8 + * create instances of the adapter class, with no instance-level overrides, as they don't have them. If the original 18.9 + * class' constructor was variable arity, the adapter constructor will also be variable arity. Protected constructors 18.10 + * are exposed as public. 18.11 * </li> 18.12 * </ul> 18.13 * </p><p> 18.14 @@ -190,7 +192,6 @@ 18.15 private static final int MAX_GENERATED_TYPE_NAME_LENGTH = 255; 18.16 18.17 private static final String CLASS_INIT = "<clinit>"; 18.18 - static final String CONVERTER_INIT = "<converter-init>"; 18.19 18.20 // Method name prefix for invoking super-methods 18.21 static final String SUPER_PREFIX = "super$"; 18.22 @@ -494,7 +495,8 @@ 18.23 final Type[] argTypes = originalCtorType.getArgumentTypes(); 18.24 18.25 // All constructors must be public, even if in the superclass they were protected. 18.26 - final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT, 18.27 + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC | 18.28 + (ctor.isVarArgs() ? ACC_VARARGS : 0), INIT, 18.29 Type.getMethodDescriptor(originalCtorType.getReturnType(), argTypes), null, null)); 18.30 18.31 mv.visitCode(); 18.32 @@ -543,7 +545,8 @@ 18.33 System.arraycopy(originalArgTypes, 0, newArgTypes, 0, argLen); 18.34 18.35 // All constructors must be public, even if in the superclass they were protected. 18.36 - // Existing super constructor <init>(this, args...) triggers generating <init>(this, scriptObj, args...). 18.37 + // Existing super constructor <init>(this, args...) triggers generating <init>(this, args..., scriptObj). 18.38 + // Any variable arity constructors become fixed-arity with explicit array arguments. 18.39 final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT, 18.40 Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null)); 18.41 18.42 @@ -593,7 +596,7 @@ 18.43 if (! fromFunction) { 18.44 newArgTypes[argLen] = OBJECT_TYPE; 18.45 final InstructionAdapter mv2 = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT, 18.46 - Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null)); 18.47 + Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null)); 18.48 generateOverridingConstructorWithObjectParam(mv2, ctor, originalCtorType.getDescriptor()); 18.49 } 18.50 }
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/script/basic/JDK-8098546.js Sat Jun 27 23:21:08 2015 -0700 19.3 @@ -0,0 +1,44 @@ 19.4 +/* 19.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.7 + * 19.8 + * This code is free software; you can redistribute it and/or modify it 19.9 + * under the terms of the GNU General Public License version 2 only, as 19.10 + * published by the Free Software Foundation. 19.11 + * 19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.15 + * version 2 for more details (a copy is included in the LICENSE file that 19.16 + * accompanied this code). 19.17 + * 19.18 + * You should have received a copy of the GNU General Public License version 19.19 + * 2 along with this work; if not, write to the Free Software Foundation, 19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.21 + * 19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19.23 + * or visit www.oracle.com if you need additional information or have any 19.24 + * questions. 19.25 + */ 19.26 + 19.27 +/** 19.28 + * JDK-8098546: eval within a 'with' leaks definitions into global scope 19.29 + * 19.30 + * @test 19.31 + * @run 19.32 + */ 19.33 + 19.34 +function func() { 19.35 + var obj = { foo: 344 }; 19.36 + with (obj) { 19.37 + eval("var x = foo + 3"); 19.38 + } 19.39 + Assert.assertTrue(obj.x === undefined); 19.40 + Assert.assertTrue(x === 347); 19.41 +} 19.42 + 19.43 +func(); 19.44 + 19.45 +// x should be undefined here 19.46 +Assert.assertTrue(typeof x === "undefined"); 19.47 +
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/script/basic/JDK-8098578.js Sat Jun 27 23:21:08 2015 -0700 20.3 @@ -0,0 +1,107 @@ 20.4 +/* 20.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 + * 20.8 + * This code is free software; you can redistribute it and/or modify it 20.9 + * under the terms of the GNU General Public License version 2 only, as 20.10 + * published by the Free Software Foundation. 20.11 + * 20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.15 + * version 2 for more details (a copy is included in the LICENSE file that 20.16 + * accompanied this code). 20.17 + * 20.18 + * You should have received a copy of the GNU General Public License version 20.19 + * 2 along with this work; if not, write to the Free Software Foundation, 20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.21 + * 20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20.23 + * or visit www.oracle.com if you need additional information or have any 20.24 + * questions. 20.25 + */ 20.26 + 20.27 +/** 20.28 + * JDK-8098578: Global scope is not accessible with indirect load call 20.29 + * 20.30 + * @test 20.31 + * @run 20.32 + */ 20.33 + 20.34 +var obj = { foo: 343 }; 20.35 +var global = this; 20.36 +var x = 434; 20.37 + 20.38 +// indirect load call 20.39 +var res = load.call(obj, { 20.40 + name: "t.js", 20.41 + // global is accessible. All declarations go into 20.42 + // intermediate inaccessible scope. "this" is global 20.43 + // User's passed object's properties are accessible 20.44 + // as variables. 20.45 + script: "foo -= 300; var bar = x; Assert.assertTrue(bar == 434); function func() {}; this" 20.46 +}) 20.47 + 20.48 +// 'this' for the evaluated code is global 20.49 +Assert.assertTrue(res === global); 20.50 + 20.51 +// properties of passed object are accessible in evaluated code 20.52 +Assert.assertTrue(obj.foo == 43); 20.53 + 20.54 +// vars, functions definined in evaluated code don't go into passed object 20.55 +Assert.assertTrue(typeof obj.bar == "undefined"); 20.56 +Assert.assertTrue(typeof obj.func == "undefined"); 20.57 + 20.58 +// vars, functions definined in evaluated code don't go leak into global 20.59 +Assert.assertTrue(typeof bar == "undefined"); 20.60 +Assert.assertTrue(typeof func == "undefined"); 20.61 +Assert.assertTrue(typeof foo == "undefined"); 20.62 + 20.63 +var res = load.call(undefined, { 20.64 + name: "t1.js", 20.65 + // still global is accessible and 'this' is global 20.66 + script: "Assert.assertTrue(x == 434); this" 20.67 +}); 20.68 + 20.69 +// indirect load with 'undefined' this is same as as direct load 20.70 +// or load on global itself. 20.71 +Assert.assertTrue(res === global); 20.72 + 20.73 +// indirect load with 'undefined' this is same as as direct load 20.74 +// or load on global itself. 20.75 +var res = load.call(null, { 20.76 + name: "t2.js", 20.77 + // still global is accessible and 'this' is global 20.78 + script: "Assert.assertTrue(x == 434); this" 20.79 +}); 20.80 +Assert.assertTrue(res === global); 20.81 + 20.82 +// indirect load with mirror object 20.83 +var mirror = loadWithNewGlobal({ 20.84 + name: "t3.js", 20.85 + script: "({ foo: 'hello', x: Math.PI })" 20.86 +}); 20.87 + 20.88 +var res = load.call(mirror, { 20.89 + name: "t4.js", 20.90 + script: "Assert.assertTrue(foo == 'hello'); Assert.assertTrue(x == Math.PI); this" 20.91 +}); 20.92 +Assert.assertTrue(res === global); 20.93 + 20.94 +// indirect load on non-script object, non-mirror results in TypeError 20.95 +function tryLoad(obj) { 20.96 + try { 20.97 + load.call(obj, { 20.98 + name: "t5.js", script: "this" 20.99 + }); 20.100 + throw new Error("should thrown TypeError for: " + obj); 20.101 + } catch (e if TypeError) {} 20.102 +} 20.103 + 20.104 +tryLoad("hello"); 20.105 +tryLoad(Math.E); 20.106 +tryLoad(true); 20.107 +tryLoad(false); 20.108 + 20.109 +// indirect load of a large script 20.110 +load.call({}, __DIR__ + "JDK-8098807-payload.js");
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/script/basic/JDK-8098807-payload.js Sat Jun 27 23:21:08 2015 -0700 21.3 @@ -0,0 +1,157 @@ 21.4 +/* 21.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.7 + * 21.8 + * This code is free software; you can redistribute it and/or modify it 21.9 + * under the terms of the GNU General Public License version 2 only, as 21.10 + * published by the Free Software Foundation. 21.11 + * 21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.15 + * version 2 for more details (a copy is included in the LICENSE file that 21.16 + * accompanied this code). 21.17 + * 21.18 + * You should have received a copy of the GNU General Public License version 21.19 + * 2 along with this work; if not, write to the Free Software Foundation, 21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.21 + * 21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21.23 + * or visit www.oracle.com if you need additional information or have any 21.24 + * questions. 21.25 + */ 21.26 + 21.27 +/** 21.28 + * JDK-8098807: Strict eval throws ClassCastException with large scripts 21.29 + * 21.30 + * @subtest 21.31 + */ 21.32 + 21.33 +function f() {} 21.34 + 21.35 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.36 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.37 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.38 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.39 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.40 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.41 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.42 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.43 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.44 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.45 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.46 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.47 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.48 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.49 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.50 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.51 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.52 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.53 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.54 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.55 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.56 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.57 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.58 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.59 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.60 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.61 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.62 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.63 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.64 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.65 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.66 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.67 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.68 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.69 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.70 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.71 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.72 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.73 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.74 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.75 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.76 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.77 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.78 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.79 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.80 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.81 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.82 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.83 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.84 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.85 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.86 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.87 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.88 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.89 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.90 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.91 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.92 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.93 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.94 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.95 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.96 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.97 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.98 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.99 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.100 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.101 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.102 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.103 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.104 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.105 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.106 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.107 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.108 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.109 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.110 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.111 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.112 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.113 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.114 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.115 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.116 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.117 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.118 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.119 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.120 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.121 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.122 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.123 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.124 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.125 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.126 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.127 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.128 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.129 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.130 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.131 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.132 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.133 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.134 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.135 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.136 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.137 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.138 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.139 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.140 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.141 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.142 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.143 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.144 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.145 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.146 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.147 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.148 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.149 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.150 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.151 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.152 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.153 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.154 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.155 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.156 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.157 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.158 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.159 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); 21.160 +f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/script/basic/JDK-8098807.js Sat Jun 27 23:21:08 2015 -0700 22.3 @@ -0,0 +1,36 @@ 22.4 +/* 22.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22.23 + * or visit www.oracle.com if you need additional information or have any 22.24 + * questions. 22.25 + */ 22.26 + 22.27 +/** 22.28 + * JDK-8098807: Strict eval throws ClassCastException with large scripts 22.29 + * 22.30 + * @test 22.31 + * @run 22.32 + * @option -scripting 22.33 + */ 22.34 + 22.35 +"use strict"; 22.36 + 22.37 +var path = __DIR__ + "JDK-8098807-payload.js" 22.38 +var source = readFully(path); 22.39 +eval(source);
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/script/basic/JDK-8129410.js Sat Jun 27 23:21:08 2015 -0700 23.3 @@ -0,0 +1,39 @@ 23.4 +/* 23.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.7 + * 23.8 + * This code is free software; you can redistribute it and/or modify it 23.9 + * under the terms of the GNU General Public License version 2 only, as 23.10 + * published by the Free Software Foundation. 23.11 + * 23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23.15 + * version 2 for more details (a copy is included in the LICENSE file that 23.16 + * accompanied this code). 23.17 + * 23.18 + * You should have received a copy of the GNU General Public License version 23.19 + * 2 along with this work; if not, write to the Free Software Foundation, 23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23.21 + * 23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23.23 + * or visit www.oracle.com if you need additional information or have any 23.24 + * questions. 23.25 + */ 23.26 + 23.27 +/** 23.28 + * JDK-8129410: Java adapters with class-level overrides should preserve variable arity constructors 23.29 + * 23.30 + * @test 23.31 + * @run 23.32 + */ 23.33 + 23.34 +var VarArgConstructor = Java.type("jdk.nashorn.test.models.VarArgConstructor"); 23.35 +var VarArgConstructorExtended = Java.extend(VarArgConstructor, {}); 23.36 + 23.37 +// If the fix didn't work we wouldn't even get past the constructor invocation 23.38 +// as it'd complain there's no matching arity constructor. 23.39 +var newExtended = new VarArgConstructorExtended(1, true, "a", "b"); 23.40 + 23.41 +// Assert the expected constructor was invoked. 23.42 +Assert.assertEquals("vararg", newExtended.indicator);
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/script/error/JDK-8098847.js Sat Jun 27 23:21:08 2015 -0700 24.3 @@ -0,0 +1,33 @@ 24.4 +/* 24.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.7 + * 24.8 + * This code is free software; you can redistribute it and/or modify it 24.9 + * under the terms of the GNU General Public License version 2 only, as 24.10 + * published by the Free Software Foundation. 24.11 + * 24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 24.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 24.15 + * version 2 for more details (a copy is included in the LICENSE file that 24.16 + * accompanied this code). 24.17 + * 24.18 + * You should have received a copy of the GNU General Public License version 24.19 + * 2 along with this work; if not, write to the Free Software Foundation, 24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24.21 + * 24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24.23 + * or visit www.oracle.com if you need additional information or have any 24.24 + * questions. 24.25 + */ 24.26 + 24.27 +/** 24.28 + * JDK-8098847: obj."prop" and obj.'prop' should result in SyntaxError 24.29 + * 24.30 + * @test/compile-error 24.31 + */ 24.32 + 24.33 +var obj = { "prop": 45 }; 24.34 + 24.35 +obj."prop" = "hello"; 24.36 +obj.'prop' = "hello";
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/script/error/JDK-8098847.js.EXPECTED Sat Jun 27 23:21:08 2015 -0700 25.3 @@ -0,0 +1,6 @@ 25.4 +test/script/error/JDK-8098847.js:32:5 Expected ident but found prop 25.5 +obj."prop" = "hello"; 25.6 + ^ 25.7 +test/script/error/JDK-8098847.js:33:5 Expected ident but found prop 25.8 +obj.'prop' = "hello"; 25.9 + ^