--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Aug 06 11:20:39 2015 -0700
@@ -1480,7 +1480,7 @@
}
@Override
void consumeStack() {
- dynamicCall(2 + argsCount, flags);
+ dynamicCall(2 + argsCount, flags, ident.getName());
}
}.emit();
}
@@ -1538,7 +1538,7 @@
@Override
void consumeStack() {
// Ordinary call
- dynamicCall(2 + argsCount, flags);
+ dynamicCall(2 + argsCount, flags, "eval");
method._goto(eval_done);
method.label(invoke_direct_eval);
@@ -1610,7 +1610,7 @@
}
@Override
void consumeStack() {
- dynamicCall(2 + argCount, flags);
+ dynamicCall(2 + argCount, flags, node.toString(false));
}
}.emit();
@@ -1635,9 +1635,7 @@
@Override
void consumeStack() {
- final int flags = getCallSiteFlags();
- //assert callNodeType.equals(callee.getReturnType()) : callNodeType + " != " + callee.getReturnType();
- dynamicCall(2 + argsCount, flags);
+ dynamicCall(2 + argsCount, getCallSiteFlags(), origCallee.getName());
}
}.emit();
return false;
@@ -1666,8 +1664,7 @@
}
@Override
void consumeStack() {
- final int flags = getCallSiteFlags();
- dynamicCall(2 + argsCount, flags);
+ dynamicCall(2 + argsCount, getCallSiteFlags(), node.toString(false));
}
}.emit();
return false;
@@ -1687,7 +1684,7 @@
@Override
void consumeStack() {
final int flags = getCallSiteFlags() | CALLSITE_SCOPE;
- dynamicCall(2 + argsCount, flags);
+ dynamicCall(2 + argsCount, flags, node.toString(false));
}
}.emit();
return false;
@@ -3707,10 +3704,11 @@
final CallNode callNode = (CallNode)unaryNode.getExpression();
final List<Expression> args = callNode.getArgs();
+ final Expression func = callNode.getFunction();
// Load function reference.
- loadExpressionAsObject(callNode.getFunction()); // must detect type error
-
- method.dynamicNew(1 + loadArgs(args), getCallSiteFlags());
+ loadExpressionAsObject(func); // must detect type error
+
+ method.dynamicNew(1 + loadArgs(args), getCallSiteFlags(), func.toString(false));
}
private void loadNOT(final UnaryNode unaryNode) {
@@ -4818,11 +4816,11 @@
return method.dynamicGetIndex(resultBounds.within(expression.getType()), nonOptimisticFlags(flags), isMethod);
}
- MethodEmitter dynamicCall(final int argCount, final int flags) {
+ MethodEmitter dynamicCall(final int argCount, final int flags, final String msg) {
if (isOptimistic) {
- return method.dynamicCall(getOptimisticCoercedType(), argCount, getOptimisticFlags(flags));
- }
- return method.dynamicCall(resultBounds.within(expression.getType()), argCount, nonOptimisticFlags(flags));
+ return method.dynamicCall(getOptimisticCoercedType(), argCount, getOptimisticFlags(flags), msg);
+ }
+ return method.dynamicCall(resultBounds.within(expression.getType()), argCount, nonOptimisticFlags(flags), msg);
}
int getOptimisticFlags(final int flags) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Thu Aug 06 11:20:39 2015 -0700
@@ -2132,10 +2132,25 @@
* @return the method emitter
*/
MethodEmitter dynamicNew(final int argCount, final int flags) {
+ return dynamicNew(argCount, flags, null);
+ }
+
+ /**
+ * Generate a dynamic new
+ *
+ * @param argCount number of arguments
+ * @param flags callsite flags
+ * @param msg additional message to be used when reporting error
+ *
+ * @return the method emitter
+ */
+ MethodEmitter dynamicNew(final int argCount, final int flags, final String msg) {
assert !isOptimistic(flags);
debug("dynamic_new", "argcount=", argCount);
final String signature = getDynamicSignature(Type.OBJECT, argCount);
- method.visitInvokeDynamicInsn("dyn:new", signature, LINKERBOOTSTRAP, flags);
+ method.visitInvokeDynamicInsn(
+ msg != null && msg.length() < LARGE_STRING_THRESHOLD? "dyn:new:" + NameCodec.encode(msg) : "dyn:new",
+ signature, LINKERBOOTSTRAP, flags);
pushType(Type.OBJECT); //TODO fix result type
return this;
}
@@ -2150,10 +2165,26 @@
* @return the method emitter
*/
MethodEmitter dynamicCall(final Type returnType, final int argCount, final int flags) {
+ return dynamicCall(returnType, argCount, flags, null);
+ }
+
+ /**
+ * Generate a dynamic call
+ *
+ * @param returnType return type
+ * @param argCount number of arguments
+ * @param flags callsite flags
+ * @param msg additional message to be used when reporting error
+ *
+ * @return the method emitter
+ */
+ MethodEmitter dynamicCall(final Type returnType, final int argCount, final int flags, final String msg) {
debug("dynamic_call", "args=", argCount, "returnType=", returnType);
final String signature = getDynamicSignature(returnType, argCount); // +1 because the function itself is the 1st parameter for dynamic calls (what you call - call target)
debug(" signature", signature);
- method.visitInvokeDynamicInsn("dyn:call", signature, LINKERBOOTSTRAP, flags);
+ method.visitInvokeDynamicInsn(
+ msg != null && msg.length() < LARGE_STRING_THRESHOLD? "dyn:call:" + NameCodec.encode(msg) : "dyn:call",
+ signature, LINKERBOOTSTRAP, flags);
pushType(returnType);
return this;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java Thu Aug 06 11:20:39 2015 -0700
@@ -169,7 +169,7 @@
slot += type.getSlots();
}
// Shared scope calls disabled in optimistic world. TODO is this right?
- method.dynamicCall(returnType, 2 + paramTypes.length, flags);
+ method.dynamicCall(returnType, 2 + paramTypes.length, flags, symbol.getName());
}
method._return(returnType);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Node.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Node.java Thu Aug 06 11:20:39 2015 -0700
@@ -141,9 +141,17 @@
public abstract Node accept(NodeVisitor<? extends LexicalContext> visitor);
@Override
- public String toString() {
+ public final String toString() {
+ return toString(true);
+ }
+
+ /*
+ * Return String representation of this Node.
+ * @param includeTypeInfo include type information or not
+ */
+ public final String toString(final boolean includeTypeInfo) {
final StringBuilder sb = new StringBuilder();
- toString(sb);
+ toString(sb, includeTypeInfo);
return sb.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Thu Aug 06 11:20:39 2015 -0700
@@ -1859,7 +1859,7 @@
* @return GuardedInvocation to be invoked at call site.
*/
protected GuardedInvocation findNewMethod(final CallSiteDescriptor desc, final LinkRequest request) {
- return notAFunction();
+ return notAFunction(desc);
}
/**
@@ -1872,11 +1872,11 @@
* @return GuardedInvocation to be invoked at call site.
*/
protected GuardedInvocation findCallMethod(final CallSiteDescriptor desc, final LinkRequest request) {
- return notAFunction();
+ return notAFunction(desc);
}
- private GuardedInvocation notAFunction() {
- throw typeError("not.a.function", ScriptRuntime.safeToString(this));
+ private GuardedInvocation notAFunction(final CallSiteDescriptor desc) {
+ throw typeError("not.a.function", NashornCallSiteDescriptor.getFunctionErrorMessage(desc, this));
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java Thu Aug 06 11:20:39 2015 -0700
@@ -96,8 +96,12 @@
switch (operator) {
case "new":
- case "call":
- throw lookupTypeError("cant.call.undefined", desc);
+ case "call": {
+ final String name = NashornCallSiteDescriptor.getFunctionDescription(desc);
+ final String msg = name != null? "not.a.function" : "cant.call.undefined";
+ throw typeError(msg, name);
+ }
+
case "callMethod":
throw lookupTypeError("cant.read.property.of.undefined", desc);
// NOTE: we support getElem and setItem as JavaScript doesn't distinguish items from properties. Nashorn itself
@@ -125,7 +129,8 @@
}
private static ECMAException lookupTypeError(final String msg, final CallSiteDescriptor desc) {
- return typeError(msg, desc.getNameTokenCount() > 2 ? desc.getNameToken(2) : null);
+ final String name = desc.getNameToken(2);
+ return typeError(msg, name != null && !name.isEmpty()? name : null);
}
private static final MethodHandle GET_METHOD = findOwnMH("get", Object.class, Object.class);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Thu Aug 06 11:20:39 2015 -0700
@@ -27,6 +27,8 @@
import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+import static jdk.nashorn.internal.runtime.JSType.GET_UNDEFINED;
+import static jdk.nashorn.internal.runtime.JSType.TYPE_OBJECT_INDEX;
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
import java.lang.invoke.MethodHandle;
@@ -92,7 +94,7 @@
if(BeansLinker.isDynamicMethod(self)) {
throw typeError("method.not.constructor", ScriptRuntime.safeToString(self));
}
- throw typeError("not.a.function", ScriptRuntime.safeToString(self));
+ throw typeError("not.a.function", desc.getFunctionErrorMessage(self));
case "call":
if(BeansLinker.isDynamicConstructor(self)) {
throw typeError("constructor.requires.new", ScriptRuntime.safeToString(self));
@@ -100,10 +102,12 @@
if(BeansLinker.isDynamicMethod(self)) {
throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self));
}
- throw typeError("not.a.function", ScriptRuntime.safeToString(self));
+ throw typeError("not.a.function", desc.getFunctionErrorMessage(self));
case "callMethod":
+ throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self));
case "getMethod":
- throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self));
+ // evaluate to undefined, later on Undefined will take care of throwing TypeError
+ return getInvocation(MH.dropArguments(GET_UNDEFINED.get(TYPE_OBJECT_INDEX), 0, Object.class), self, linkerServices, desc);
case "getProp":
case "getElem":
if(NashornCallSiteDescriptor.isOptimistic(desc)) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Thu Aug 06 11:20:39 2015 -0700
@@ -34,6 +34,7 @@
import jdk.internal.dynalink.support.AbstractCallSiteDescriptor;
import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
import jdk.nashorn.internal.ir.debug.NashornTextifier;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
/**
* Nashorn-specific implementation of Dynalink's {@link CallSiteDescriptor}. The reason we have our own subclass is that
@@ -150,7 +151,7 @@
public static NashornCallSiteDescriptor get(final MethodHandles.Lookup lookup, final String name,
final MethodType methodType, final int flags) {
final String[] tokenizedName = CallSiteDescriptorFactory.tokenizeName(name);
- assert tokenizedName.length == 2 || tokenizedName.length == 3;
+ assert tokenizedName.length >= 2;
assert "dyn".equals(tokenizedName[0]);
assert tokenizedName[1] != null;
// TODO: see if we can move mangling/unmangling into Dynalink
@@ -248,6 +249,54 @@
}
/**
+ * If this is a dyn:call or dyn:new, this returns function description from callsite.
+ * Caller has to make sure this is a dyn:call or dyn:new call site.
+ *
+ * @return function description if available (or null)
+ */
+ public String getFunctionDescription() {
+ assert getFirstOperator().equals("call") || getFirstOperator().equals("new");
+ return getNameTokenCount() > 2? getNameToken(2) : null;
+ }
+
+ /**
+ * If this is a dyn:call or dyn:new, this returns function description from callsite.
+ * Caller has to make sure this is a dyn:call or dyn:new call site.
+ *
+ * @param desc call site descriptor
+ * @return function description if available (or null)
+ */
+ public static String getFunctionDescription(final CallSiteDescriptor desc) {
+ return desc instanceof NashornCallSiteDescriptor ?
+ ((NashornCallSiteDescriptor)desc).getFunctionDescription() : null;
+ }
+
+
+ /**
+ * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
+ *
+ * @param obj object on which dyn:call or dyn:new is used
+ * @return error message
+ */
+ public String getFunctionErrorMessage(final Object obj) {
+ final String funcDesc = getFunctionDescription();
+ return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
+ }
+
+ /**
+ * Returns the error message to be used when dyn:call or dyn:new is used on a non-function.
+ *
+ * @param desc call site descriptor
+ * @param obj object on which dyn:call or dyn:new is used
+ * @return error message
+ */
+ public static String getFunctionErrorMessage(final CallSiteDescriptor desc, final Object obj) {
+ return desc instanceof NashornCallSiteDescriptor ?
+ ((NashornCallSiteDescriptor)desc).getFunctionErrorMessage(obj) :
+ ScriptRuntime.safeToString(obj);
+ }
+
+ /**
* Returns the Nashorn-specific flags for this call site descriptor.
* @param desc the descriptor. It can be any kind of a call site descriptor, not necessarily a
* {@code NashornCallSiteDescriptor}. This allows for graceful interoperability when linking Nashorn with code
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties Thu Aug 06 11:20:39 2015 -0700
@@ -78,6 +78,7 @@
type.error.not.a.regexp={0} is not a RegExp
type.error.not.a.string={0} is not a String
type.error.not.a.function={0} is not a function
+type.error.not.a.function.value={0}, which has value {1}, is not a function
type.error.not.a.constructor={0} is not a constructor function
type.error.not.a.file={0} is not a File
type.error.not.a.numeric.array={0} is not a numeric array
--- a/nashorn/test/script/basic/JDK-8026016.js.EXPECTED Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/JDK-8026016.js.EXPECTED Thu Aug 06 11:20:39 2015 -0700
@@ -1,182 +1,182 @@
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-TypeError: Cannot call undefined
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such method _,0
-no such method _,1
-no such method _,2
-no such method _,3
-no such method _,4
-no such method _,5
-no such method _,6
-no such method _,7
-no such method _,8
-no such method _,9
-no such method _,10
-no such method _,11
-no such method _,12
-no such method _,13
-no such method _,14
-no such method _,15
-no such method _,16
-no such method _,17
-no such method _,18
-no such method _,19
-no such method _,20
-no such method _,21
-no such method _,22
-no such method _,23
-no such method _,24
-no such method _,25
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-TypeError: Cannot call undefined
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
-no such property _
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+TypeError: o._ is not a function
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such method _,0
+no such method _,1
+no such method _,2
+no such method _,3
+no such method _,4
+no such method _,5
+no such method _,6
+no such method _,7
+no such method _,8
+no such method _,9
+no such method _,10
+no such method _,11
+no such method _,12
+no such method _,13
+no such method _,14
+no such method _,15
+no such method _,16
+no such method _,17
+no such method _,18
+no such method _,19
+no such method _,20
+no such method _,21
+no such method _,22
+no such method _,23
+no such method _,24
+no such method _,25
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+TypeError: o._ is not a function
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
+no such property _
--- a/nashorn/test/script/basic/JDK-8036743.js Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/JDK-8036743.js Thu Aug 06 11:20:39 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8073733.js Thu Aug 06 11:20:39 2015 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8073733: TypeError messages with "call" and "new" could be improved
+ *
+ * @test
+ * @run
+ */
+
+var func = undefined;
+try {
+ func();
+} catch (e) {
+ print(e);
+}
+
+var obj = {};
+try {
+ obj.foo();
+} catch (e) {
+ print(e);
+}
+
+try {
+ new func();
+} catch (e) {
+ print(e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8073733.js.EXPECTED Thu Aug 06 11:20:39 2015 -0700
@@ -0,0 +1,3 @@
+TypeError: func is not a function
+TypeError: obj.foo is not a function
+TypeError: func is not a function
--- a/nashorn/test/script/basic/JDK-8114838.js Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/JDK-8114838.js Thu Aug 06 11:20:39 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/nashorn/test/script/basic/JDK-8130853.js Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/JDK-8130853.js Thu Aug 06 11:20:39 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/nashorn/test/script/basic/JDK-8131039.js Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/JDK-8131039.js Thu Aug 06 11:20:39 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8133119.js Thu Aug 06 11:20:39 2015 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8133119: Error message associated with TypeError for call and new should include stringified Node
+ *
+ * @test
+ * @run
+ */
+
+var obj = {}
+try {
+ obj.func();
+} catch (e) {
+ print(e);
+}
+
+var arr = [33];
+try {
+ arr[0].func();
+} catch (e) {
+ print(e);
+}
+
+try {
+ new obj.func();
+} catch (e) {
+ print(e);
+}
+
+try {
+ new arr[0].func();
+} catch (e) {
+ print(e);
+}
+
+obj.foo = {}
+try {
+ new obj.foo();
+} catch (e) {
+ print(e);
+}
+
+try {
+ obj.foo();
+} catch (e) {
+ print(e);
+}
+
+var v = new java.util.Vector();
+try {
+ v();
+} catch (e) {
+ print(e);
+}
+
+try {
+ new v();
+} catch (e) {
+ print(e);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8133119.js.EXPECTED Thu Aug 06 11:20:39 2015 -0700
@@ -0,0 +1,8 @@
+TypeError: obj.func is not a function
+TypeError: arr[0].func is not a function
+TypeError: obj.func is not a function
+TypeError: arr[0].func is not a function
+TypeError: obj.foo is not a function
+TypeError: obj.foo is not a function
+TypeError: v is not a function
+TypeError: v is not a function
--- a/nashorn/test/script/basic/NASHORN-75.js.EXPECTED Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/NASHORN-75.js.EXPECTED Thu Aug 06 11:20:39 2015 -0700
@@ -1,3 +1,3 @@
-TypeError: [RegExp /a|b/g] is not a function
-TypeError: [String hello] is not a function
-TypeError: [object Object] is not a function
+TypeError: RegExp("a|b", "g") is not a function
+TypeError: new String("hello") is not a function
+TypeError: new Object() is not a function
--- a/nashorn/test/script/basic/errors.js.EXPECTED Thu Aug 06 08:07:42 2015 -0700
+++ b/nashorn/test/script/basic/errors.js.EXPECTED Thu Aug 06 11:20:39 2015 -0700
@@ -1,31 +1,31 @@
-Error is a function
-EvalError is a function
-RangeError is a function
-ReferenceError is a function
-SyntaxError is a function
-TypeError is a function
-URIError is a function
-Error.arity 1
-EvalError.arity 1
-RangeError.arity 1
-ReferenceError.arity 1
-SyntaxError.arity 1
-TypeError.arity 1
-URIError.arity 1
-true
-my error
-Error
-thrown @ 49
-true
-ReferenceError
-"foo" is not defined
-true
-TypeError
-Cannot call undefined
-Error
-EvalError
-RangeError
-ReferenceError
-SyntaxError
-TypeError
-URIError
+Error is a function
+EvalError is a function
+RangeError is a function
+ReferenceError is a function
+SyntaxError is a function
+TypeError is a function
+URIError is a function
+Error.arity 1
+EvalError.arity 1
+RangeError.arity 1
+ReferenceError.arity 1
+SyntaxError.arity 1
+TypeError.arity 1
+URIError.arity 1
+true
+my error
+Error
+thrown @ 49
+true
+ReferenceError
+"foo" is not defined
+true
+TypeError
+Object.foo_method is not a function
+Error
+EvalError
+RangeError
+ReferenceError
+SyntaxError
+TypeError
+URIError