aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlana <none@none>2013-10-11 03:09:54 -0700
committerlana <none@none>2013-10-11 03:09:54 -0700
commitaf21fad02d19ba6f84b9e4a20640f97936ef48f5 (patch)
treed5b3a2d6872b2715bad6f03e8785f297ffa32654
parent8833efa23ae626680af756123a447281b35d29a0 (diff)
parentca2f988e2010ba047f7fe6bff7c48e052a4efef9 (diff)
Merge
-rw-r--r--make/build.xml5
-rw-r--r--make/java.security.override14
-rw-r--r--make/project.properties2
-rw-r--r--src/jdk/nashorn/api/scripting/NashornScriptEngine.java2
-rw-r--r--src/jdk/nashorn/internal/codegen/Attr.java39
-rw-r--r--src/jdk/nashorn/internal/codegen/CodeGenerator.java4
-rw-r--r--src/jdk/nashorn/internal/codegen/FoldConstants.java8
-rw-r--r--src/jdk/nashorn/internal/ir/IdentNode.java26
-rw-r--r--src/jdk/nashorn/internal/ir/LexicalContext.java4
-rw-r--r--src/jdk/nashorn/internal/ir/LiteralNode.java41
-rw-r--r--src/jdk/nashorn/internal/objects/NativeArray.java16
-rw-r--r--src/jdk/nashorn/internal/objects/NativeError.java7
-rw-r--r--src/jdk/nashorn/internal/objects/NativeFunction.java8
-rw-r--r--src/jdk/nashorn/internal/parser/AbstractParser.java2
-rw-r--r--src/jdk/nashorn/internal/parser/Parser.java6
-rw-r--r--src/jdk/nashorn/internal/runtime/CompiledFunction.java47
-rw-r--r--src/jdk/nashorn/internal/runtime/Context.java107
-rw-r--r--src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java2
-rw-r--r--src/jdk/nashorn/internal/runtime/Source.java4
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java2
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java2
-rw-r--r--src/jdk/nashorn/internal/runtime/resources/fx/base.js3
-rw-r--r--test/script/basic/JDK-8023026.js2
-rw-r--r--test/script/basic/JDK-8025213.js39
-rw-r--r--test/script/basic/JDK-8025213.js.EXPECTED1
-rw-r--r--test/script/basic/JDK-8025488.js43
-rw-r--r--test/script/basic/JDK-8025488.js.EXPECTED3
-rw-r--r--test/script/basic/JDK-8025515.js58
-rw-r--r--test/script/basic/JDK-8025520.js50
-rw-r--r--test/script/basic/JDK-8025589.js51
-rw-r--r--test/script/basic/JDK-8026033.js39
-rw-r--r--test/script/basic/JDK-8026033.js.EXPECTED1
-rw-r--r--test/script/basic/JDK-8026042.js43
-rw-r--r--test/script/basic/JDK-8026042.js.EXPECTED2
-rw-r--r--test/script/basic/JDK-8026048.js37
-rw-r--r--test/script/error/JDK-8026039.js32
-rw-r--r--test/script/error/JDK-8026039.js.EXPECTED9
-rw-r--r--test/script/sandbox/arrayclass.js37
-rw-r--r--test/script/sandbox/arrayclass.js.EXPECTED1
-rw-r--r--test/script/trusted/JDK-8025629.js33
-rw-r--r--test/src/jdk/nashorn/internal/runtime/resources/load_test.js28
41 files changed, 749 insertions, 111 deletions
diff --git a/make/build.xml b/make/build.xml
index 4bc1a398..01410947 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -236,6 +236,10 @@
<fileset dir="${test.src.dir}/META-INF/services/"/>
</copy>
+ <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/resources">
+ <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/resources"/>
+ </copy>
+
<!-- tests that check nashorn internals and internal API -->
<jar jarfile="${nashorn.internal.tests.jar}">
<fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
@@ -245,6 +249,7 @@
<jar jarfile="${nashorn.api.tests.jar}">
<fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
<fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/>
+ <fileset dir="${build.test.classes.dir}" includes="**/resources/*.js"/>
</jar>
</target>
diff --git a/make/java.security.override b/make/java.security.override
deleted file mode 100644
index a7edf33b..00000000
--- a/make/java.security.override
+++ /dev/null
@@ -1,14 +0,0 @@
-# We would like to avoid references from anywhere outside nashorn
-# to codegen, IR and parser packages, in particular script generated classes.
-# We ensure that by overriding "package.access" security property.
-
-# The following "package.access" value was copied from default java.security
-# of jre/lib/security and appended with nashorn sensitive packages.
-
-#
-# List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageAccess unless the
-# corresponding RuntimePermission ("accessClassInPackage."+package) has
-# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.,jdk.internal.,jdk.nashorn.internal.,jdk.nashorn.tools.
diff --git a/make/project.properties b/make/project.properties
index e6eea02e..2ad619be 100644
--- a/make/project.properties
+++ b/make/project.properties
@@ -234,7 +234,7 @@ run.test.jvmargs.main=${run.test.jvmargs.common} -ea
#-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
run.test.jvmargs.octane.main=${run.test.jvmargs.common}
-run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
+run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
# VM options for script tests with @fork option
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
diff --git a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
index 4629665f..36e79b54 100644
--- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
+++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
@@ -313,7 +313,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
if (! Modifier.isPublic(clazz.getModifiers())) {
throw new SecurityException(getMessage("implementing.non.public.interface", clazz.getName()));
}
- Context.checkPackageAccess(clazz.getName());
+ Context.checkPackageAccess(clazz);
}
ScriptObject realSelf = null;
diff --git a/src/jdk/nashorn/internal/codegen/Attr.java b/src/jdk/nashorn/internal/codegen/Attr.java
index 55355c3e..7aef4603 100644
--- a/src/jdk/nashorn/internal/codegen/Attr.java
+++ b/src/jdk/nashorn/internal/codegen/Attr.java
@@ -1082,24 +1082,6 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> {
private boolean enterAssignmentNode(final BinaryNode binaryNode) {
start(binaryNode);
- final Node lhs = binaryNode.lhs();
-
- if (lhs instanceof IdentNode) {
- final Block block = lc.getCurrentBlock();
- final IdentNode ident = (IdentNode)lhs;
- final String name = ident.getName();
-
- Symbol symbol = findSymbol(block, name);
-
- if (symbol == null) {
- symbol = defineSymbol(block, name, IS_GLOBAL);
- } else {
- maybeForceScope(symbol);
- }
-
- addLocalDef(name);
- }
-
return true;
}
@@ -1112,20 +1094,33 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> {
* @param binaryNode assignment node
*/
private Node leaveAssignmentNode(final BinaryNode binaryNode) {
- BinaryNode newBinaryNode = binaryNode;
-
final Expression lhs = binaryNode.lhs();
final Expression rhs = binaryNode.rhs();
final Type type;
+ if (lhs instanceof IdentNode) {
+ final Block block = lc.getCurrentBlock();
+ final IdentNode ident = (IdentNode)lhs;
+ final String name = ident.getName();
+ final Symbol symbol = findSymbol(block, name);
+
+ if (symbol == null) {
+ defineSymbol(block, name, IS_GLOBAL);
+ } else {
+ maybeForceScope(symbol);
+ }
+
+ addLocalDef(name);
+ }
+
if (rhs.getType().isNumeric()) {
- type = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType());
+ type = Type.widest(lhs.getType(), rhs.getType());
} else {
type = Type.OBJECT; //force lhs to be an object if not numeric assignment, e.g. strings too.
}
newType(lhs.getSymbol(), type);
- return end(ensureSymbol(type, newBinaryNode));
+ return end(ensureSymbol(type, binaryNode));
}
private boolean isLocal(FunctionNode function, Symbol symbol) {
diff --git a/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/src/jdk/nashorn/internal/codegen/CodeGenerator.java
index d16a1e5b..5f7f596d 100644
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java
+++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java
@@ -1827,6 +1827,8 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
}
if (cases.isEmpty()) {
+ // still evaluate expression for side-effects.
+ load(expression).pop();
method.label(breakLabel);
return false;
}
@@ -1956,7 +1958,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
final Expression expression = throwNode.getExpression();
final int position = throwNode.position();
- final int line = source.getLine(position);
+ final int line = throwNode.getLineNumber();
final int column = source.getColumn(position);
load(expression);
diff --git a/src/jdk/nashorn/internal/codegen/FoldConstants.java b/src/jdk/nashorn/internal/codegen/FoldConstants.java
index 49dfbb32..9a2aafa0 100644
--- a/src/jdk/nashorn/internal/codegen/FoldConstants.java
+++ b/src/jdk/nashorn/internal/codegen/FoldConstants.java
@@ -88,8 +88,8 @@ final class FoldConstants extends NodeVisitor<LexicalContext> {
@Override
public Node leaveIfNode(final IfNode ifNode) {
final Node test = ifNode.getTest();
- if (test instanceof LiteralNode) {
- final Block shortCut = ((LiteralNode<?>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
+ if (test instanceof LiteralNode.PrimitiveLiteralNode) {
+ final Block shortCut = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
if (shortCut != null) {
return new BlockStatement(ifNode.getLineNumber(), shortCut);
}
@@ -101,8 +101,8 @@ final class FoldConstants extends NodeVisitor<LexicalContext> {
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
final Node test = ternaryNode.getTest();
- if (test instanceof LiteralNode) {
- return ((LiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
+ if (test instanceof LiteralNode.PrimitiveLiteralNode) {
+ return ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
}
return ternaryNode;
}
diff --git a/src/jdk/nashorn/internal/ir/IdentNode.java b/src/jdk/nashorn/internal/ir/IdentNode.java
index 4b139b25..6060899d 100644
--- a/src/jdk/nashorn/internal/ir/IdentNode.java
+++ b/src/jdk/nashorn/internal/ir/IdentNode.java
@@ -40,9 +40,10 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
*/
@Immutable
public final class IdentNode extends Expression implements PropertyKey, TypeOverride<IdentNode>, FunctionCall {
- private static final int PROPERTY_NAME = 1 << 0;
- private static final int INITIALIZED_HERE = 1 << 1;
- private static final int FUNCTION = 1 << 2;
+ private static final int PROPERTY_NAME = 1 << 0;
+ private static final int INITIALIZED_HERE = 1 << 1;
+ private static final int FUNCTION = 1 << 2;
+ private static final int FUTURESTRICT_NAME = 1 << 3;
/** Identifier. */
private final String name;
@@ -197,6 +198,25 @@ public final class IdentNode extends Expression implements PropertyKey, TypeOver
}
/**
+ * Check if this IdentNode is a future strict name
+ * @return true if this is a future strict name
+ */
+ public boolean isFutureStrictName() {
+ return (flags & FUTURESTRICT_NAME) != 0;
+ }
+
+ /**
+ * Flag this IdentNode as a future strict name
+ * @return a node equivalent to this one except for the requested change.
+ */
+ public IdentNode setIsFutureStrictName() {
+ if (isFutureStrictName()) {
+ return this;
+ }
+ return new IdentNode(this, name, callSiteType, flags | FUTURESTRICT_NAME);
+ }
+
+ /**
* Helper function for local def analysis.
* @return true if IdentNode is initialized on creation
*/
diff --git a/src/jdk/nashorn/internal/ir/LexicalContext.java b/src/jdk/nashorn/internal/ir/LexicalContext.java
index 666be7e3..1b380d38 100644
--- a/src/jdk/nashorn/internal/ir/LexicalContext.java
+++ b/src/jdk/nashorn/internal/ir/LexicalContext.java
@@ -587,11 +587,11 @@ public class LexicalContext {
final FunctionNode fn = (FunctionNode)node;
final Source source = fn.getSource();
String src = source.toString();
- if (src.indexOf(File.pathSeparator) != -1) {
+ if (src.contains(File.pathSeparator)) {
src = src.substring(src.lastIndexOf(File.pathSeparator));
}
src += ' ';
- src += source.getLine(fn.getStart());
+ src += fn.getLineNumber();
sb.append(src);
}
sb.append(' ');
diff --git a/src/jdk/nashorn/internal/ir/LiteralNode.java b/src/jdk/nashorn/internal/ir/LiteralNode.java
index b2d9e9fa..618182c8 100644
--- a/src/jdk/nashorn/internal/ir/LiteralNode.java
+++ b/src/jdk/nashorn/internal/ir/LiteralNode.java
@@ -96,14 +96,6 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
return value == null;
}
- /**
- * Check if the literal value is boolean true
- * @return true if literal value is boolean true
- */
- public boolean isTrue() {
- return JSType.toBoolean(value);
- }
-
@Override
public Type getType() {
return Type.typeFor(value.getClass());
@@ -259,8 +251,31 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
return new NullLiteralNode(parent.getToken(), parent.getFinish());
}
+ /**
+ * Super class for primitive (side-effect free) literals.
+ *
+ * @param <T> the literal type
+ */
+ public static class PrimitiveLiteralNode<T> extends LiteralNode<T> {
+ private PrimitiveLiteralNode(final long token, final int finish, final T value) {
+ super(token, finish, value);
+ }
+
+ private PrimitiveLiteralNode(final PrimitiveLiteralNode<T> literalNode) {
+ super(literalNode);
+ }
+
+ /**
+ * Check if the literal value is boolean true
+ * @return true if literal value is boolean true
+ */
+ public boolean isTrue() {
+ return JSType.toBoolean(value);
+ }
+ }
+
@Immutable
- private static final class BooleanLiteralNode extends LiteralNode<Boolean> {
+ private static final class BooleanLiteralNode extends PrimitiveLiteralNode<Boolean> {
private BooleanLiteralNode(final long token, final int finish, final boolean value) {
super(Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
@@ -312,7 +327,7 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
}
@Immutable
- private static final class NumberLiteralNode extends LiteralNode<Number> {
+ private static final class NumberLiteralNode extends PrimitiveLiteralNode<Number> {
private final Type type = numberGetType(value);
@@ -374,7 +389,7 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
return new NumberLiteralNode(parent.getToken(), parent.getFinish(), value);
}
- private static class UndefinedLiteralNode extends LiteralNode<Undefined> {
+ private static class UndefinedLiteralNode extends PrimitiveLiteralNode<Undefined> {
private UndefinedLiteralNode(final long token, final int finish) {
super(Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
}
@@ -410,7 +425,7 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
}
@Immutable
- private static class StringLiteralNode extends LiteralNode<String> {
+ private static class StringLiteralNode extends PrimitiveLiteralNode<String> {
private StringLiteralNode(final long token, final int finish, final String value) {
super(Token.recast(token, TokenType.STRING), finish, value);
}
@@ -522,7 +537,7 @@ public abstract class LiteralNode<T> extends Expression implements PropertyKey {
return POSTSET_MARKER;
}
- private static final class NullLiteralNode extends LiteralNode<Object> {
+ private static final class NullLiteralNode extends PrimitiveLiteralNode<Object> {
private NullLiteralNode(final long token, final int finish) {
super(Token.recast(token, TokenType.OBJECT), finish, null);
diff --git a/src/jdk/nashorn/internal/objects/NativeArray.java b/src/jdk/nashorn/internal/objects/NativeArray.java
index 8cb1ded9..fa325753 100644
--- a/src/jdk/nashorn/internal/objects/NativeArray.java
+++ b/src/jdk/nashorn/internal/objects/NativeArray.java
@@ -819,8 +819,15 @@ public final class NativeArray extends ScriptObject {
if (bulkable(sobj)) {
sobj.getArray().shiftLeft(1);
} else {
+ boolean hasPrevious = true;
for (long k = 1; k < len; k++) {
- sobj.set(k - 1, sobj.get(k), true);
+ boolean hasCurrent = sobj.has(k);
+ if (hasCurrent) {
+ sobj.set(k - 1, sobj.get(k), true);
+ } else if (hasPrevious) {
+ sobj.delete(k - 1, true);
+ }
+ hasPrevious = hasCurrent;
}
}
sobj.delete(--len, true);
@@ -860,9 +867,12 @@ public final class NativeArray extends ScriptObject {
return new NativeArray(sobj.getArray().slice(k, finale));
}
- final NativeArray copy = new NativeArray(0);
+ // Construct array with proper length to have a deleted filter on undefined elements
+ final NativeArray copy = new NativeArray(finale - k);
for (long n = 0; k < finale; n++, k++) {
- copy.defineOwnProperty(ArrayIndex.getArrayIndex(n), sobj.get(k));
+ if (sobj.has(k)) {
+ copy.defineOwnProperty(ArrayIndex.getArrayIndex(n), sobj.get(k));
+ }
}
return copy;
diff --git a/src/jdk/nashorn/internal/objects/NativeError.java b/src/jdk/nashorn/internal/objects/NativeError.java
index dc6aef90..194c6d8f 100644
--- a/src/jdk/nashorn/internal/objects/NativeError.java
+++ b/src/jdk/nashorn/internal/objects/NativeError.java
@@ -37,10 +37,12 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.objects.ScriptFunctionImpl;
import jdk.nashorn.internal.runtime.ECMAException;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject;
+import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptRuntime;
/**
@@ -138,7 +140,10 @@ public final class NativeError extends ScriptObject {
Global.checkObject(errorObj);
final ScriptObject sobj = (ScriptObject)errorObj;
final ECMAException exp = new ECMAException(sobj, null);
- sobj.set("stack", getScriptStackString(sobj, exp), false);
+ sobj.delete("stack", false);
+ final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", GET_STACK);
+ final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", SET_STACK);
+ sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
return UNDEFINED;
}
diff --git a/src/jdk/nashorn/internal/objects/NativeFunction.java b/src/jdk/nashorn/internal/objects/NativeFunction.java
index c77002e3..d092cfb6 100644
--- a/src/jdk/nashorn/internal/objects/NativeFunction.java
+++ b/src/jdk/nashorn/internal/objects/NativeFunction.java
@@ -221,6 +221,7 @@ public final class NativeFunction {
final StringBuilder sb = new StringBuilder();
sb.append("(function (");
+ final String funcBody;
if (args.length > 0) {
final StringBuilder paramListBuf = new StringBuilder();
for (int i = 0; i < args.length - 1; i++) {
@@ -230,15 +231,20 @@ public final class NativeFunction {
}
}
+ // now convert function body to a string
+ funcBody = JSType.toString(args[args.length - 1]);
+
final String paramList = paramListBuf.toString();
if (! paramList.isEmpty()) {
checkFunctionParameters(paramList);
sb.append(paramList);
}
+ } else {
+ funcBody = null;
}
+
sb.append(") {\n");
if (args.length > 0) {
- final String funcBody = JSType.toString(args[args.length - 1]);
checkFunctionBody(funcBody);
sb.append(funcBody);
sb.append('\n');
diff --git a/src/jdk/nashorn/internal/parser/AbstractParser.java b/src/jdk/nashorn/internal/parser/AbstractParser.java
index 80f7ce07..587ae869 100644
--- a/src/jdk/nashorn/internal/parser/AbstractParser.java
+++ b/src/jdk/nashorn/internal/parser/AbstractParser.java
@@ -378,7 +378,7 @@ public abstract class AbstractParser {
next();
// Create IDENT node.
- return new IdentNode(identToken, finish, ident);
+ return new IdentNode(identToken, finish, ident).setIsFutureStrictName();
}
// Get IDENT.
diff --git a/src/jdk/nashorn/internal/parser/Parser.java b/src/jdk/nashorn/internal/parser/Parser.java
index 9663401f..61c70d95 100644
--- a/src/jdk/nashorn/internal/parser/Parser.java
+++ b/src/jdk/nashorn/internal/parser/Parser.java
@@ -909,6 +909,10 @@ loop:
default:
break;
}
+
+ if (ident.isFutureStrictName()) {
+ throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
+ }
}
}
@@ -2436,7 +2440,7 @@ loop:
// name is null, generate anonymous name
boolean isAnonymous = false;
if (name == null) {
- final String tmpName = "_L" + source.getLine(Token.descPosition(token));
+ final String tmpName = "_L" + functionLine;
name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
isAnonymous = true;
}
diff --git a/src/jdk/nashorn/internal/runtime/CompiledFunction.java b/src/jdk/nashorn/internal/runtime/CompiledFunction.java
index afa3657c..18b20a3d 100644
--- a/src/jdk/nashorn/internal/runtime/CompiledFunction.java
+++ b/src/jdk/nashorn/internal/runtime/CompiledFunction.java
@@ -48,6 +48,7 @@ final class CompiledFunction implements Comparable<CompiledFunction> {
}
CompiledFunction(final MethodType type, final MethodHandle invoker, final MethodHandle constructor) {
+ assert type != null;
this.type = type;
this.invoker = invoker;
this.constructor = constructor;
@@ -80,7 +81,37 @@ final class CompiledFunction implements Comparable<CompiledFunction> {
@Override
public int compareTo(final CompiledFunction o) {
- return weight() - o.weight();
+ return compareMethodTypes(type(), o.type());
+ }
+
+ private static int compareMethodTypes(final MethodType ownType, final MethodType otherType) {
+ // Comparable interface demands that compareTo() should only return 0 if objects are equal.
+ // Failing to meet this requirement causes same weight functions to replace each other in TreeSet,
+ // so we go some lengths to come up with an ordering between same weight functions,
+ // first falling back to parameter count and then to hash code.
+ if (ownType.equals(otherType)) {
+ return 0;
+ }
+
+ final int diff = weight(ownType) - weight(otherType);
+ if (diff != 0) {
+ return diff;
+ }
+ if (ownType.parameterCount() != otherType.parameterCount()) {
+ return ownType.parameterCount() - otherType.parameterCount();
+ }
+ // We're just interested in not returning 0 here, not correct ordering
+ return ownType.hashCode() - otherType.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof CompiledFunction && type().equals(((CompiledFunction)obj).type());
+ }
+
+ @Override
+ public int hashCode() {
+ return type().hashCode();
}
private int weight() {
@@ -119,14 +150,14 @@ final class CompiledFunction implements Comparable<CompiledFunction> {
* a semantically equivalent linkage can be performed.
*
* @param mt type to check against
- * @return
+ * @return true if types are compatible
*/
boolean typeCompatible(final MethodType mt) {
- final Class<?>[] wantedParams = mt.parameterArray();
- final Class<?>[] existingParams = type().parameterArray();
+ final int wantedParamCount = mt.parameterCount();
+ final int existingParamCount = type.parameterCount();
//if we are not examining a varargs type, the number of parameters must be the same
- if (wantedParams.length != existingParams.length && !isVarArgsType(mt)) {
+ if (wantedParamCount != existingParamCount && !isVarArgsType(mt)) {
return false;
}
@@ -134,10 +165,10 @@ final class CompiledFunction implements Comparable<CompiledFunction> {
//parameters lengths do not match is if our type ends with a varargs argument.
//then every trailing parameter in the given callsite can be folded into it, making
//us compatible (albeit slower than a direct specialization)
- final int lastParamIndex = Math.min(wantedParams.length, existingParams.length);
+ final int lastParamIndex = Math.min(wantedParamCount, existingParamCount);
for (int i = 0; i < lastParamIndex; i++) {
- final Type w = Type.typeFor(wantedParams[i]);
- final Type e = Type.typeFor(existingParams[i]);
+ final Type w = Type.typeFor(mt.parameterType(i));
+ final Type e = Type.typeFor(type.parameterType(i));
//don't specialize on booleans, we have the "true" vs int 1 ambiguity in resolution
//we also currently don't support boolean as a javascript function callsite type.
diff --git a/src/jdk/nashorn/internal/runtime/Context.java b/src/jdk/nashorn/internal/runtime/Context.java
index 7c69eb52..91a905a3 100644
--- a/src/jdk/nashorn/internal/runtime/Context.java
+++ b/src/jdk/nashorn/internal/runtime/Context.java
@@ -91,6 +91,11 @@ public final class Context {
*/
public static final String NASHORN_JAVA_REFLECTION = "nashorn.JavaReflection";
+ // nashorn load psuedo URL prefixes
+ private static final String LOAD_CLASSPATH = "classpath:";
+ private static final String LOAD_FX = "fx:";
+ private static final String LOAD_NASHORN = "nashorn:";
+
/* Force DebuggerSupport to be loaded. */
static {
DebuggerSupport.FORCELOAD = true;
@@ -501,21 +506,26 @@ public final class Context {
// or a ScriptObject that has "name" and "source" (string valued) properties.
if (src instanceof String) {
final String srcStr = (String)src;
- final File file = new File(srcStr);
- if (srcStr.indexOf(':') != -1) {
- if ((source = loadInternal(srcStr, "nashorn:", "resources/")) == null &&
- (source = loadInternal(srcStr, "fx:", "resources/fx/")) == null) {
- URL url;
- try {
- //check for malformed url. if malformed, it may still be a valid file
- url = new URL(srcStr);
- } catch (final MalformedURLException e) {
- url = file.toURI().toURL();
+ if (srcStr.startsWith(LOAD_CLASSPATH)) {
+ URL url = getResourceURL(srcStr.substring(LOAD_CLASSPATH.length()));
+ source = (url != null)? new Source(url.toString(), url) : null;
+ } else {
+ final File file = new File(srcStr);
+ if (srcStr.indexOf(':') != -1) {
+ if ((source = loadInternal(srcStr, LOAD_NASHORN, "resources/")) == null &&
+ (source = loadInternal(srcStr, LOAD_FX, "resources/fx/")) == null) {
+ URL url;
+ try {
+ //check for malformed url. if malformed, it may still be a valid file
+ url = new URL(srcStr);
+ } catch (final MalformedURLException e) {
+ url = file.toURI().toURL();
+ }
+ source = new Source(url.toString(), url);
}
- source = new Source(url.toString(), url);
+ } else if (file.isFile()) {
+ source = new Source(srcStr, file);
}
- } else if (file.isFile()) {
- source = new Source(srcStr, file);
}
} else if (src instanceof File && ((File)src).isFile()) {
final File file = (File)src;
@@ -610,36 +620,53 @@ public final class Context {
}
/**
+ * Checks that the given Class can be accessed from no permissions context.
+ *
+ * @param clazz Class object
+ * @throw SecurityException if not accessible
+ */
+ public static void checkPackageAccess(final Class clazz) {
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ Class bottomClazz = clazz;
+ while(bottomClazz.isArray()) {
+ bottomClazz = bottomClazz.getComponentType();
+ }
+ checkPackageAccess(sm, bottomClazz.getName());
+ }
+ }
+
+ /**
* Checks that the given package can be accessed from no permissions context.
*
+ * @param sm current security manager instance
* @param fullName fully qualified package name
* @throw SecurityException if not accessible
*/
- public static void checkPackageAccess(final String fullName) {
+ private static void checkPackageAccess(final SecurityManager sm, final String fullName) {
+ sm.getClass(); // null check
final int index = fullName.lastIndexOf('.');
if (index != -1) {
- final SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- sm.checkPackageAccess(fullName.substring(0, index));
- return null;
- }
- }, NO_PERMISSIONS_ACC_CTXT);
- }
+ final String pkgName = fullName.substring(0, index);
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ sm.checkPackageAccess(pkgName);
+ return null;
+ }
+ }, NO_PERMISSIONS_ACC_CTXT);
}
}
/**
- * Checks that the given package can be accessed from no permissions context.
+ * Checks that the given Class can be accessed from no permissions context.
*
- * @param fullName fully qualified package name
+ * @param clazz Class object
* @return true if package is accessible, false otherwise
*/
- public static boolean isAccessiblePackage(final String fullName) {
+ private static boolean isAccessiblePackage(final Class clazz) {
try {
- checkPackageAccess(fullName);
+ checkPackageAccess(clazz);
return true;
} catch (final SecurityException se) {
return false;
@@ -653,7 +680,7 @@ public final class Context {
* @return true if Class is accessible, false otherwise
*/
public static boolean isAccessibleClass(final Class<?> clazz) {
- return Modifier.isPublic(clazz.getModifiers()) && Context.isAccessiblePackage(clazz.getName());
+ return Modifier.isPublic(clazz.getModifiers()) && Context.isAccessiblePackage(clazz);
}
/**
@@ -667,8 +694,16 @@ public final class Context {
* @throws ClassNotFoundException if class cannot be resolved
*/
public Class<?> findClass(final String fullName) throws ClassNotFoundException {
+ if (fullName.indexOf('[') != -1 || fullName.indexOf('/') != -1) {
+ // don't allow array class names or internal names.
+ throw new ClassNotFoundException(fullName);
+ }
+
// check package access as soon as possible!
- checkPackageAccess(fullName);
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ checkPackageAccess(sm, fullName);
+ }
// try the script -classpath loader, if that is set
if (classPathLoader != null) {
@@ -803,6 +838,18 @@ public final class Context {
return Context.getContextTrusted();
}
+ private URL getResourceURL(final String resName) throws IOException {
+ // try the classPathLoader if we have and then
+ // try the appLoader if non-null.
+ if (classPathLoader != null) {
+ return classPathLoader.getResource(resName);
+ } else if (appLoader != null) {
+ return appLoader.getResource(resName);
+ }
+
+ return null;
+ }
+
private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) {
ScriptFunction script = null;
diff --git a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
index a64479a5..fee04970 100644
--- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
+++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
@@ -132,7 +132,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData {
if (source != null) {
sb.append(source.getName())
.append(':')
- .append(source.getLine(Token.descPosition(token)))
+ .append(functionNode.getLineNumber())
.append(' ');
}
diff --git a/src/jdk/nashorn/internal/runtime/Source.java b/src/jdk/nashorn/internal/runtime/Source.java
index 9273e7a8..0455a86c 100644
--- a/src/jdk/nashorn/internal/runtime/Source.java
+++ b/src/jdk/nashorn/internal/runtime/Source.java
@@ -272,6 +272,10 @@ public final class Source {
/**
* Return line number of character position.
+ *
+ * <p>This method can be expensive for large sources as it iterates through
+ * all characters up to {@code position}.</p>
+ *
* @param position Position of character in source content.
* @return Line number.
*/
diff --git a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
index 5130f3d6..b221d000 100644
--- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
@@ -109,7 +109,7 @@ public final class JavaAdapterFactory {
if (sm != null) {
for (Class<?> type : types) {
// check for restricted package access
- Context.checkPackageAccess(type.getName());
+ Context.checkPackageAccess(type);
}
}
return getAdapterInfo(types).getAdapterClassFor(classOverrides);
diff --git a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
index 9c9f5283..ce60d790 100644
--- a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
@@ -70,7 +70,7 @@ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker {
// We intercept "new" on StaticClass instances to provide additional capabilities
if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) {
// make sure new is on accessible Class
- Context.checkPackageAccess(receiverClass.getName());
+ Context.checkPackageAccess(receiverClass);
// Is the class abstract? (This includes interfaces.)
if (NashornLinker.isAbstractClass(receiverClass)) {
diff --git a/src/jdk/nashorn/internal/runtime/resources/fx/base.js b/src/jdk/nashorn/internal/runtime/resources/fx/base.js
index b0bfc3fb..382eabb2 100644
--- a/src/jdk/nashorn/internal/runtime/resources/fx/base.js
+++ b/src/jdk/nashorn/internal/runtime/resources/fx/base.js
@@ -33,7 +33,6 @@ var JFX_SWING_CLASSES = [];
var JFX_SWT_CLASSES = [];
function LOAD_FX_CLASSES(clsList) {
-
for each (var cls in clsList) {
// Ex. Stage = Java.type("javafx.stage.Stage");
this[cls[cls.length - 1]] = Java.type(cls.join("."));
@@ -146,3 +145,5 @@ function LOAD_FX_CLASSES(clsList) {
}
}
})();
+
+LOAD_FX_CLASSES(JFX_BASE_CLASSES);
diff --git a/test/script/basic/JDK-8023026.js b/test/script/basic/JDK-8023026.js
index 9080ec8c..0a6f0272 100644
--- a/test/script/basic/JDK-8023026.js
+++ b/test/script/basic/JDK-8023026.js
@@ -48,7 +48,7 @@ function checkIterations(obj) {
function(x) x*x));
}
-var array = new (Java.type("[I"))(4);
+var array = new (Java.type("int[]"))(4);
for (var i in array) {
array[i] = i;
}
diff --git a/test/script/basic/JDK-8025213.js b/test/script/basic/JDK-8025213.js
new file mode 100644
index 00000000..062a389e
--- /dev/null
+++ b/test/script/basic/JDK-8025213.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025213: Assignment marks variable as defined too early
+ *
+ * @test
+ * @run
+ */
+
+function test() {
+ if (String("")) {
+ var foo = 42;
+ }
+ foo = foo + 1;
+ print(foo);
+}
+
+test();
diff --git a/test/script/basic/JDK-8025213.js.EXPECTED b/test/script/basic/JDK-8025213.js.EXPECTED
new file mode 100644
index 00000000..736991a1
--- /dev/null
+++ b/test/script/basic/JDK-8025213.js.EXPECTED
@@ -0,0 +1 @@
+NaN
diff --git a/test/script/basic/JDK-8025488.js b/test/script/basic/JDK-8025488.js
new file mode 100644
index 00000000..a3697f41
--- /dev/null
+++ b/test/script/basic/JDK-8025488.js
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025488: Error.captureStackTrace should not format error stack
+ *
+ * @test
+ * @run
+ */
+
+
+function MyError () {
+ Error.call(this);
+ Error.captureStackTrace(this);
+ this.arr = {};
+};
+
+MyError.prototype.toString = function() {
+ return this.arr.toString();
+}
+
+var e = new MyError();
+print(e.stack);
diff --git a/test/script/basic/JDK-8025488.js.EXPECTED b/test/script/basic/JDK-8025488.js.EXPECTED
new file mode 100644
index 00000000..40b244a9
--- /dev/null
+++ b/test/script/basic/JDK-8025488.js.EXPECTED
@@ -0,0 +1,3 @@
+[object Object]
+ at MyError (test/script/basic/JDK-8025488.js:34)
+ at <program> (test/script/basic/JDK-8025488.js:42)
diff --git a/test/script/basic/JDK-8025515.js b/test/script/basic/JDK-8025515.js
new file mode 100644
index 00000000..f3d7cee4
--- /dev/null
+++ b/test/script/basic/JDK-8025515.js
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025515: Performance issues with Source.getLine()
+ *
+ * @test
+ * @run
+ */
+
+// Make sure synthetic names of anonymous functions have correct line numbers
+
+function testMethodName(f, expected) {
+ try {
+ f();
+ fail("expected error");
+ } catch (e) {
+ var stack = e.getStackTrace();
+ if (stack[0].methodName !== expected) {
+ fail("got " + stack[0].methodName + ", expected " + expected);
+ }
+ }
+}
+
+testMethodName(function() {
+ return a.b.c;
+}, "_L45");
+
+testMethodName(function() { throw new Error() }, "_L49");
+
+var f = (function() {
+ return function() { a.b.c; };
+})();
+testMethodName(f, "_L51$_L52");
+
+testMethodName((function() {
+ return function() { return a.b.c; };
+})(), "_L56$_L57");
diff --git a/test/script/basic/JDK-8025520.js b/test/script/basic/JDK-8025520.js
new file mode 100644
index 00000000..773a30ab
--- /dev/null
+++ b/test/script/basic/JDK-8025520.js
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025520: Array.prototype.slice should only copy defined elements
+ *
+ * @test
+ * @run
+ */
+
+var s = Array.prototype.slice.call({length: 6, 3: 1}, 2, 5);
+
+if (s.length != 3) {
+ fail("s.length != 3");
+}
+if (0 in s) {
+ fail("0 in s");
+}
+if (s.hasOwnProperty(0)) {
+ fail("s.hasOwnProperty(0)");
+}
+if (s[1] !== 1) {
+ fail("s[1] !== 1");
+}
+if (2 in s) {
+ fail("2 in s");
+}
+if (s.hasOwnProperty(2)) {
+ fail("s.hasOwnProperty(2)");
+}
diff --git a/test/script/basic/JDK-8025589.js b/test/script/basic/JDK-8025589.js
new file mode 100644
index 00000000..a74261c1
--- /dev/null
+++ b/test/script/basic/JDK-8025589.js
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025589: Array.prototype.shift should only copy defined elements in generic mode
+ *
+ * @test
+ * @run
+ */
+
+var s = {length: 4, 2: 1};
+Array.prototype.shift.call(s);
+
+if (s.length != 3) {
+ fail("s.length != 3");
+}
+if (0 in s) {
+ fail("0 in s");
+}
+if (s.hasOwnProperty(0)) {
+ fail("s.hasOwnProperty(0)");
+}
+if (s[1] !== 1) {
+ fail("s[1] !== 1");
+}
+if (2 in s) {
+ fail("2 in s");
+}
+if (s.hasOwnProperty(2)) {
+ fail("s.hasOwnProperty(2)");
+}
diff --git a/test/script/basic/JDK-8026033.js b/test/script/basic/JDK-8026033.js
new file mode 100644
index 00000000..4a5d8594
--- /dev/null
+++ b/test/script/basic/JDK-8026033.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8026033: Switch should load expression even when there are no cases in it
+ *
+ * @test
+ * @run
+ */
+
+try {
+ (function() { switch(x) {} })();
+ fail("Should have thrown ReferenceError");
+} catch (e) {
+ if (! (e instanceof ReferenceError)) {
+ fail("ReferenceError expected, got " + e);
+ }
+ print(e);
+}
diff --git a/test/script/basic/JDK-8026033.js.EXPECTED b/test/script/basic/JDK-8026033.js.EXPECTED
new file mode 100644
index 00000000..c007ed7b
--- /dev/null
+++ b/test/script/basic/JDK-8026033.js.EXPECTED
@@ -0,0 +1 @@
+ReferenceError: "x" is not defined
diff --git a/test/script/basic/JDK-8026042.js b/test/script/basic/JDK-8026042.js
new file mode 100644
index 00000000..a853626f
--- /dev/null
+++ b/test/script/basic/JDK-8026042.js
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8026042: FoldConstants need to guard against ArrayLiteralNode
+ *
+ * @test
+ * @run
+ */
+
+try {
+ if ([a]) {
+ print("fail");
+ }
+} catch (e) {
+ print(e);
+}
+
+try {
+ [a] ? print(1) : print(2);
+} catch (e) {
+ print(e);
+}
diff --git a/test/script/basic/JDK-8026042.js.EXPECTED b/test/script/basic/JDK-8026042.js.EXPECTED
new file mode 100644
index 00000000..aae23d09
--- /dev/null
+++ b/test/script/basic/JDK-8026042.js.EXPECTED
@@ -0,0 +1,2 @@
+ReferenceError: "a" is not defined
+ReferenceError: "a" is not defined
diff --git a/test/script/basic/JDK-8026048.js b/test/script/basic/JDK-8026048.js
new file mode 100644
index 00000000..33789fea
--- /dev/null
+++ b/test/script/basic/JDK-8026048.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8026048: Function constructor should convert arguments to String before performing any syntax checks
+ *
+ * @test
+ * @run
+ */
+
+try {
+ Function("-", {toString:function(){throw "err"}})
+} catch (e) {
+ if (e !== "err") {
+ fail("err xpected, got " + e);
+ }
+}
diff --git a/test/script/error/JDK-8026039.js b/test/script/error/JDK-8026039.js
new file mode 100644
index 00000000..f37d9bdd
--- /dev/null
+++ b/test/script/error/JDK-8026039.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8026039: future strict names are allowed as function name and argument name of a strict function
+ *
+ * @test/compile-error
+ */
+
+function public() {"use strict"}
+
+function f(public) {"use strict"}
diff --git a/test/script/error/JDK-8026039.js.EXPECTED b/test/script/error/JDK-8026039.js.EXPECTED
new file mode 100644
index 00000000..cde398f3
--- /dev/null
+++ b/test/script/error/JDK-8026039.js.EXPECTED
@@ -0,0 +1,9 @@
+test/script/error/JDK-8026039.js:30:9 "public" cannot be used as function name in strict mode
+function public() {"use strict"}
+ ^
+test/script/error/JDK-8026039.js:32:11 Expected ident but found public
+function f(public) {"use strict"}
+ ^
+test/script/error/JDK-8026039.js:33:0 Expected } but found eof
+
+^
diff --git a/test/script/sandbox/arrayclass.js b/test/script/sandbox/arrayclass.js
new file mode 100644
index 00000000..c29c86bd
--- /dev/null
+++ b/test/script/sandbox/arrayclass.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ */
+
+/**
+ * Try to access array class of a sensitive class like Unsafe.
+ *
+ * @test
+ * @security
+ * @run
+ */
+
+try {
+ var unsafeArr = Java.type("[Lsun.misc.Unsafe;");
+ fail("No Exception for [Lsun.misc.Unsafe;");
+} catch (e) {
+ print(e);
+}
diff --git a/test/script/sandbox/arrayclass.js.EXPECTED b/test/script/sandbox/arrayclass.js.EXPECTED
new file mode 100644
index 00000000..d66d77f0
--- /dev/null
+++ b/test/script/sandbox/arrayclass.js.EXPECTED
@@ -0,0 +1 @@
+java.lang.ClassNotFoundException: [Lsun.misc.Unsafe;
diff --git a/test/script/trusted/JDK-8025629.js b/test/script/trusted/JDK-8025629.js
new file mode 100644
index 00000000..7dda8465
--- /dev/null
+++ b/test/script/trusted/JDK-8025629.js
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, 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-8025629: load function should support a way to load scripts from classpath
+ *
+ * @test
+ * @run
+ */
+
+load("classpath:jdk/nashorn/internal/runtime/resources/load_test.js")
+
+Assert.assertEquals(loadedFunc("hello"), "HELLO");
diff --git a/test/src/jdk/nashorn/internal/runtime/resources/load_test.js b/test/src/jdk/nashorn/internal/runtime/resources/load_test.js
new file mode 100644
index 00000000..21672d61
--- /dev/null
+++ b/test/src/jdk/nashorn/internal/runtime/resources/load_test.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+function loadedFunc(arg) {
+ return arg.toUpperCase();
+}