Merge

Fri, 11 Oct 2013 03:09:54 -0700

author
lana
date
Fri, 11 Oct 2013 03:09:54 -0700
changeset 598
b48b719c5efc
parent 580
fc2b6885e60e
parent 597
3551855c4f40
child 600
6a4fdb3bb4e3
child 618
1b0a71a9920a

Merge

make/java.security.override file | annotate | diff | comparison | revisions
     1.1 --- a/make/build.xml	Thu Oct 10 10:09:30 2013 -0700
     1.2 +++ b/make/build.xml	Fri Oct 11 03:09:54 2013 -0700
     1.3 @@ -236,6 +236,10 @@
     1.4         <fileset dir="${test.src.dir}/META-INF/services/"/>
     1.5      </copy>
     1.6  
     1.7 +    <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/resources">
     1.8 +       <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/resources"/>
     1.9 +    </copy>
    1.10 +
    1.11      <!-- tests that check nashorn internals and internal API -->
    1.12      <jar jarfile="${nashorn.internal.tests.jar}">
    1.13        <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
    1.14 @@ -245,6 +249,7 @@
    1.15      <jar jarfile="${nashorn.api.tests.jar}">
    1.16        <fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
    1.17        <fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/>
    1.18 +      <fileset dir="${build.test.classes.dir}" includes="**/resources/*.js"/>
    1.19      </jar>
    1.20  
    1.21    </target>
     2.1 --- a/make/java.security.override	Thu Oct 10 10:09:30 2013 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,14 +0,0 @@
     2.4 -# We would like to avoid references from anywhere outside nashorn
     2.5 -# to codegen, IR and parser packages, in particular script generated classes.
     2.6 -# We ensure that by overriding "package.access" security property.
     2.7 -
     2.8 -# The following "package.access" value was copied from  default java.security 
     2.9 -# of jre/lib/security and appended with nashorn sensitive packages.
    2.10 -
    2.11 -#
    2.12 -# List of comma-separated packages that start with or equal this string
    2.13 -# will cause a security exception to be thrown when
    2.14 -# passed to checkPackageAccess unless the
    2.15 -# corresponding RuntimePermission ("accessClassInPackage."+package) has
    2.16 -# been granted.
    2.17 -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.
     3.1 --- a/make/project.properties	Thu Oct 10 10:09:30 2013 -0700
     3.2 +++ b/make/project.properties	Fri Oct 11 03:09:54 2013 -0700
     3.3 @@ -234,7 +234,7 @@
     3.4  #-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M  
     3.5  run.test.jvmargs.octane.main=${run.test.jvmargs.common}
     3.6  
     3.7 -run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
     3.8 +run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
     3.9  
    3.10  # VM options for script tests with @fork option
    3.11  test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
     4.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Oct 10 10:09:30 2013 -0700
     4.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Fri Oct 11 03:09:54 2013 -0700
     4.3 @@ -313,7 +313,7 @@
     4.4              if (! Modifier.isPublic(clazz.getModifiers())) {
     4.5                  throw new SecurityException(getMessage("implementing.non.public.interface", clazz.getName()));
     4.6              }
     4.7 -            Context.checkPackageAccess(clazz.getName());
     4.8 +            Context.checkPackageAccess(clazz);
     4.9          }
    4.10  
    4.11          ScriptObject realSelf = null;
     5.1 --- a/src/jdk/nashorn/internal/codegen/Attr.java	Thu Oct 10 10:09:30 2013 -0700
     5.2 +++ b/src/jdk/nashorn/internal/codegen/Attr.java	Fri Oct 11 03:09:54 2013 -0700
     5.3 @@ -1082,24 +1082,6 @@
     5.4      private boolean enterAssignmentNode(final BinaryNode binaryNode) {
     5.5          start(binaryNode);
     5.6  
     5.7 -        final Node lhs = binaryNode.lhs();
     5.8 -
     5.9 -        if (lhs instanceof IdentNode) {
    5.10 -            final Block     block = lc.getCurrentBlock();
    5.11 -            final IdentNode ident = (IdentNode)lhs;
    5.12 -            final String    name  = ident.getName();
    5.13 -
    5.14 -            Symbol symbol = findSymbol(block, name);
    5.15 -
    5.16 -            if (symbol == null) {
    5.17 -                symbol = defineSymbol(block, name, IS_GLOBAL);
    5.18 -            } else {
    5.19 -                maybeForceScope(symbol);
    5.20 -            }
    5.21 -
    5.22 -            addLocalDef(name);
    5.23 -        }
    5.24 -
    5.25          return true;
    5.26      }
    5.27  
    5.28 @@ -1112,20 +1094,33 @@
    5.29       * @param binaryNode assignment node
    5.30       */
    5.31      private Node leaveAssignmentNode(final BinaryNode binaryNode) {
    5.32 -        BinaryNode newBinaryNode = binaryNode;
    5.33 -
    5.34          final Expression lhs = binaryNode.lhs();
    5.35          final Expression rhs = binaryNode.rhs();
    5.36          final Type type;
    5.37  
    5.38 +        if (lhs instanceof IdentNode) {
    5.39 +            final Block     block = lc.getCurrentBlock();
    5.40 +            final IdentNode ident = (IdentNode)lhs;
    5.41 +            final String    name  = ident.getName();
    5.42 +            final Symbol symbol = findSymbol(block, name);
    5.43 +
    5.44 +            if (symbol == null) {
    5.45 +                defineSymbol(block, name, IS_GLOBAL);
    5.46 +            } else {
    5.47 +                maybeForceScope(symbol);
    5.48 +            }
    5.49 +
    5.50 +            addLocalDef(name);
    5.51 +        }
    5.52 +
    5.53          if (rhs.getType().isNumeric()) {
    5.54 -            type = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType());
    5.55 +            type = Type.widest(lhs.getType(), rhs.getType());
    5.56          } else {
    5.57              type = Type.OBJECT; //force lhs to be an object if not numeric assignment, e.g. strings too.
    5.58          }
    5.59  
    5.60          newType(lhs.getSymbol(), type);
    5.61 -        return end(ensureSymbol(type, newBinaryNode));
    5.62 +        return end(ensureSymbol(type, binaryNode));
    5.63      }
    5.64  
    5.65      private boolean isLocal(FunctionNode function, Symbol symbol) {
     6.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Oct 10 10:09:30 2013 -0700
     6.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Oct 11 03:09:54 2013 -0700
     6.3 @@ -1827,6 +1827,8 @@
     6.4          }
     6.5  
     6.6          if (cases.isEmpty()) {
     6.7 +            // still evaluate expression for side-effects.
     6.8 +            load(expression).pop();
     6.9              method.label(breakLabel);
    6.10              return false;
    6.11          }
    6.12 @@ -1956,7 +1958,7 @@
    6.13  
    6.14          final Expression expression = throwNode.getExpression();
    6.15          final int        position   = throwNode.position();
    6.16 -        final int        line       = source.getLine(position);
    6.17 +        final int        line       = throwNode.getLineNumber();
    6.18          final int        column     = source.getColumn(position);
    6.19  
    6.20          load(expression);
     7.1 --- a/src/jdk/nashorn/internal/codegen/FoldConstants.java	Thu Oct 10 10:09:30 2013 -0700
     7.2 +++ b/src/jdk/nashorn/internal/codegen/FoldConstants.java	Fri Oct 11 03:09:54 2013 -0700
     7.3 @@ -88,8 +88,8 @@
     7.4      @Override
     7.5      public Node leaveIfNode(final IfNode ifNode) {
     7.6          final Node test = ifNode.getTest();
     7.7 -        if (test instanceof LiteralNode) {
     7.8 -            final Block shortCut = ((LiteralNode<?>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
     7.9 +        if (test instanceof LiteralNode.PrimitiveLiteralNode) {
    7.10 +            final Block shortCut = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
    7.11              if (shortCut != null) {
    7.12                  return new BlockStatement(ifNode.getLineNumber(), shortCut);
    7.13              }
    7.14 @@ -101,8 +101,8 @@
    7.15      @Override
    7.16      public Node leaveTernaryNode(final TernaryNode ternaryNode) {
    7.17          final Node test = ternaryNode.getTest();
    7.18 -        if (test instanceof LiteralNode) {
    7.19 -            return ((LiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
    7.20 +        if (test instanceof LiteralNode.PrimitiveLiteralNode) {
    7.21 +            return ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
    7.22          }
    7.23          return ternaryNode;
    7.24      }
     8.1 --- a/src/jdk/nashorn/internal/ir/IdentNode.java	Thu Oct 10 10:09:30 2013 -0700
     8.2 +++ b/src/jdk/nashorn/internal/ir/IdentNode.java	Fri Oct 11 03:09:54 2013 -0700
     8.3 @@ -40,9 +40,10 @@
     8.4   */
     8.5  @Immutable
     8.6  public final class IdentNode extends Expression implements PropertyKey, TypeOverride<IdentNode>, FunctionCall {
     8.7 -    private static final int PROPERTY_NAME    = 1 << 0;
     8.8 -    private static final int INITIALIZED_HERE = 1 << 1;
     8.9 -    private static final int FUNCTION         = 1 << 2;
    8.10 +    private static final int PROPERTY_NAME     = 1 << 0;
    8.11 +    private static final int INITIALIZED_HERE  = 1 << 1;
    8.12 +    private static final int FUNCTION          = 1 << 2;
    8.13 +    private static final int FUTURESTRICT_NAME = 1 << 3;
    8.14  
    8.15      /** Identifier. */
    8.16      private final String name;
    8.17 @@ -197,6 +198,25 @@
    8.18      }
    8.19  
    8.20      /**
    8.21 +     * Check if this IdentNode is a future strict name
    8.22 +     * @return true if this is a future strict name
    8.23 +     */
    8.24 +    public boolean isFutureStrictName() {
    8.25 +        return (flags & FUTURESTRICT_NAME) != 0;
    8.26 +    }
    8.27 +
    8.28 +    /**
    8.29 +     * Flag this IdentNode as a future strict name
    8.30 +     * @return a node equivalent to this one except for the requested change.
    8.31 +     */
    8.32 +    public IdentNode setIsFutureStrictName() {
    8.33 +        if (isFutureStrictName()) {
    8.34 +            return this;
    8.35 +        }
    8.36 +        return new IdentNode(this, name, callSiteType, flags | FUTURESTRICT_NAME);
    8.37 +    }
    8.38 +
    8.39 +    /**
    8.40       * Helper function for local def analysis.
    8.41       * @return true if IdentNode is initialized on creation
    8.42       */
     9.1 --- a/src/jdk/nashorn/internal/ir/LexicalContext.java	Thu Oct 10 10:09:30 2013 -0700
     9.2 +++ b/src/jdk/nashorn/internal/ir/LexicalContext.java	Fri Oct 11 03:09:54 2013 -0700
     9.3 @@ -587,11 +587,11 @@
     9.4                  final FunctionNode fn = (FunctionNode)node;
     9.5                  final Source source = fn.getSource();
     9.6                  String src = source.toString();
     9.7 -                if (src.indexOf(File.pathSeparator) != -1) {
     9.8 +                if (src.contains(File.pathSeparator)) {
     9.9                      src = src.substring(src.lastIndexOf(File.pathSeparator));
    9.10                  }
    9.11                  src += ' ';
    9.12 -                src += source.getLine(fn.getStart());
    9.13 +                src += fn.getLineNumber();
    9.14                  sb.append(src);
    9.15              }
    9.16              sb.append(' ');
    10.1 --- a/src/jdk/nashorn/internal/ir/LiteralNode.java	Thu Oct 10 10:09:30 2013 -0700
    10.2 +++ b/src/jdk/nashorn/internal/ir/LiteralNode.java	Fri Oct 11 03:09:54 2013 -0700
    10.3 @@ -96,14 +96,6 @@
    10.4          return value == null;
    10.5      }
    10.6  
    10.7 -    /**
    10.8 -     * Check if the literal value is boolean true
    10.9 -     * @return true if literal value is boolean true
   10.10 -     */
   10.11 -    public boolean isTrue() {
   10.12 -        return JSType.toBoolean(value);
   10.13 -    }
   10.14 -
   10.15      @Override
   10.16      public Type getType() {
   10.17          return Type.typeFor(value.getClass());
   10.18 @@ -259,8 +251,31 @@
   10.19          return new NullLiteralNode(parent.getToken(), parent.getFinish());
   10.20      }
   10.21  
   10.22 +    /**
   10.23 +     * Super class for primitive (side-effect free) literals.
   10.24 +     *
   10.25 +     * @param <T> the literal type
   10.26 +     */
   10.27 +    public static class PrimitiveLiteralNode<T> extends LiteralNode<T> {
   10.28 +        private PrimitiveLiteralNode(final long token, final int finish, final T value) {
   10.29 +            super(token, finish, value);
   10.30 +        }
   10.31 +
   10.32 +        private PrimitiveLiteralNode(final PrimitiveLiteralNode<T> literalNode) {
   10.33 +            super(literalNode);
   10.34 +        }
   10.35 +
   10.36 +        /**
   10.37 +         * Check if the literal value is boolean true
   10.38 +         * @return true if literal value is boolean true
   10.39 +         */
   10.40 +        public boolean isTrue() {
   10.41 +            return JSType.toBoolean(value);
   10.42 +        }
   10.43 +    }
   10.44 +
   10.45      @Immutable
   10.46 -    private static final class BooleanLiteralNode extends LiteralNode<Boolean> {
   10.47 +    private static final class BooleanLiteralNode extends PrimitiveLiteralNode<Boolean> {
   10.48  
   10.49          private BooleanLiteralNode(final long token, final int finish, final boolean value) {
   10.50              super(Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
   10.51 @@ -312,7 +327,7 @@
   10.52      }
   10.53  
   10.54      @Immutable
   10.55 -    private static final class NumberLiteralNode extends LiteralNode<Number> {
   10.56 +    private static final class NumberLiteralNode extends PrimitiveLiteralNode<Number> {
   10.57  
   10.58          private final Type type = numberGetType(value);
   10.59  
   10.60 @@ -374,7 +389,7 @@
   10.61          return new NumberLiteralNode(parent.getToken(), parent.getFinish(), value);
   10.62      }
   10.63  
   10.64 -    private static class UndefinedLiteralNode extends LiteralNode<Undefined> {
   10.65 +    private static class UndefinedLiteralNode extends PrimitiveLiteralNode<Undefined> {
   10.66          private UndefinedLiteralNode(final long token, final int finish) {
   10.67              super(Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
   10.68          }
   10.69 @@ -410,7 +425,7 @@
   10.70      }
   10.71  
   10.72      @Immutable
   10.73 -    private static class StringLiteralNode extends LiteralNode<String> {
   10.74 +    private static class StringLiteralNode extends PrimitiveLiteralNode<String> {
   10.75          private StringLiteralNode(final long token, final int finish, final String value) {
   10.76              super(Token.recast(token, TokenType.STRING), finish, value);
   10.77          }
   10.78 @@ -522,7 +537,7 @@
   10.79          return POSTSET_MARKER;
   10.80      }
   10.81  
   10.82 -    private static final class NullLiteralNode extends LiteralNode<Object> {
   10.83 +    private static final class NullLiteralNode extends PrimitiveLiteralNode<Object> {
   10.84  
   10.85          private NullLiteralNode(final long token, final int finish) {
   10.86              super(Token.recast(token, TokenType.OBJECT), finish, null);
    11.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java	Thu Oct 10 10:09:30 2013 -0700
    11.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java	Fri Oct 11 03:09:54 2013 -0700
    11.3 @@ -819,8 +819,15 @@
    11.4              if (bulkable(sobj)) {
    11.5                  sobj.getArray().shiftLeft(1);
    11.6              } else {
    11.7 +                boolean hasPrevious = true;
    11.8                  for (long k = 1; k < len; k++) {
    11.9 -                    sobj.set(k - 1, sobj.get(k), true);
   11.10 +                    boolean hasCurrent = sobj.has(k);
   11.11 +                    if (hasCurrent) {
   11.12 +                        sobj.set(k - 1, sobj.get(k), true);
   11.13 +                    } else if (hasPrevious) {
   11.14 +                        sobj.delete(k - 1, true);
   11.15 +                    }
   11.16 +                    hasPrevious = hasCurrent;
   11.17                  }
   11.18              }
   11.19              sobj.delete(--len, true);
   11.20 @@ -860,9 +867,12 @@
   11.21              return new NativeArray(sobj.getArray().slice(k, finale));
   11.22          }
   11.23  
   11.24 -        final NativeArray copy = new NativeArray(0);
   11.25 +        // Construct array with proper length to have a deleted filter on undefined elements
   11.26 +        final NativeArray copy = new NativeArray(finale - k);
   11.27          for (long n = 0; k < finale; n++, k++) {
   11.28 -            copy.defineOwnProperty(ArrayIndex.getArrayIndex(n), sobj.get(k));
   11.29 +            if (sobj.has(k)) {
   11.30 +                copy.defineOwnProperty(ArrayIndex.getArrayIndex(n), sobj.get(k));
   11.31 +            }
   11.32          }
   11.33  
   11.34          return copy;
    12.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java	Thu Oct 10 10:09:30 2013 -0700
    12.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java	Fri Oct 11 03:09:54 2013 -0700
    12.3 @@ -37,10 +37,12 @@
    12.4  import jdk.nashorn.internal.objects.annotations.Property;
    12.5  import jdk.nashorn.internal.objects.annotations.ScriptClass;
    12.6  import jdk.nashorn.internal.objects.annotations.Where;
    12.7 +import jdk.nashorn.internal.objects.ScriptFunctionImpl;
    12.8  import jdk.nashorn.internal.runtime.ECMAException;
    12.9  import jdk.nashorn.internal.runtime.JSType;
   12.10  import jdk.nashorn.internal.runtime.PropertyMap;
   12.11  import jdk.nashorn.internal.runtime.ScriptObject;
   12.12 +import jdk.nashorn.internal.runtime.ScriptFunction;
   12.13  import jdk.nashorn.internal.runtime.ScriptRuntime;
   12.14  
   12.15  /**
   12.16 @@ -138,7 +140,10 @@
   12.17          Global.checkObject(errorObj);
   12.18          final ScriptObject sobj = (ScriptObject)errorObj;
   12.19          final ECMAException exp = new ECMAException(sobj, null);
   12.20 -        sobj.set("stack", getScriptStackString(sobj, exp), false);
   12.21 +        sobj.delete("stack", false);
   12.22 +        final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", GET_STACK);
   12.23 +        final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", SET_STACK);
   12.24 +        sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
   12.25          return UNDEFINED;
   12.26      }
   12.27  
    13.1 --- a/src/jdk/nashorn/internal/objects/NativeFunction.java	Thu Oct 10 10:09:30 2013 -0700
    13.2 +++ b/src/jdk/nashorn/internal/objects/NativeFunction.java	Fri Oct 11 03:09:54 2013 -0700
    13.3 @@ -221,6 +221,7 @@
    13.4          final StringBuilder sb = new StringBuilder();
    13.5  
    13.6          sb.append("(function (");
    13.7 +        final String funcBody;
    13.8          if (args.length > 0) {
    13.9              final StringBuilder paramListBuf = new StringBuilder();
   13.10              for (int i = 0; i < args.length - 1; i++) {
   13.11 @@ -230,15 +231,20 @@
   13.12                  }
   13.13              }
   13.14  
   13.15 +            // now convert function body to a string
   13.16 +            funcBody = JSType.toString(args[args.length - 1]);
   13.17 +
   13.18              final String paramList = paramListBuf.toString();
   13.19              if (! paramList.isEmpty()) {
   13.20                  checkFunctionParameters(paramList);
   13.21                  sb.append(paramList);
   13.22              }
   13.23 +        } else {
   13.24 +            funcBody = null;
   13.25          }
   13.26 +
   13.27          sb.append(") {\n");
   13.28          if (args.length > 0) {
   13.29 -            final String funcBody = JSType.toString(args[args.length - 1]);
   13.30              checkFunctionBody(funcBody);
   13.31              sb.append(funcBody);
   13.32              sb.append('\n');
    14.1 --- a/src/jdk/nashorn/internal/parser/AbstractParser.java	Thu Oct 10 10:09:30 2013 -0700
    14.2 +++ b/src/jdk/nashorn/internal/parser/AbstractParser.java	Fri Oct 11 03:09:54 2013 -0700
    14.3 @@ -378,7 +378,7 @@
    14.4              next();
    14.5  
    14.6              // Create IDENT node.
    14.7 -            return new IdentNode(identToken, finish, ident);
    14.8 +            return new IdentNode(identToken, finish, ident).setIsFutureStrictName();
    14.9          }
   14.10  
   14.11          // Get IDENT.
    15.1 --- a/src/jdk/nashorn/internal/parser/Parser.java	Thu Oct 10 10:09:30 2013 -0700
    15.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java	Fri Oct 11 03:09:54 2013 -0700
    15.3 @@ -909,6 +909,10 @@
    15.4              default:
    15.5                  break;
    15.6              }
    15.7 +
    15.8 +            if (ident.isFutureStrictName()) {
    15.9 +                throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
   15.10 +            }
   15.11          }
   15.12      }
   15.13  
   15.14 @@ -2436,7 +2440,7 @@
   15.15          // name is null, generate anonymous name
   15.16          boolean isAnonymous = false;
   15.17          if (name == null) {
   15.18 -            final String tmpName = "_L" + source.getLine(Token.descPosition(token));
   15.19 +            final String tmpName = "_L" + functionLine;
   15.20              name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
   15.21              isAnonymous = true;
   15.22          }
    16.1 --- a/src/jdk/nashorn/internal/runtime/CompiledFunction.java	Thu Oct 10 10:09:30 2013 -0700
    16.2 +++ b/src/jdk/nashorn/internal/runtime/CompiledFunction.java	Fri Oct 11 03:09:54 2013 -0700
    16.3 @@ -48,6 +48,7 @@
    16.4      }
    16.5  
    16.6      CompiledFunction(final MethodType type, final MethodHandle invoker, final MethodHandle constructor) {
    16.7 +        assert type != null;
    16.8          this.type        = type;
    16.9          this.invoker     = invoker;
   16.10          this.constructor = constructor;
   16.11 @@ -80,7 +81,37 @@
   16.12  
   16.13      @Override
   16.14      public int compareTo(final CompiledFunction o) {
   16.15 -        return weight() - o.weight();
   16.16 +        return compareMethodTypes(type(), o.type());
   16.17 +    }
   16.18 +
   16.19 +    private static int compareMethodTypes(final MethodType ownType, final MethodType otherType) {
   16.20 +        // Comparable interface demands that compareTo() should only return 0 if objects are equal.
   16.21 +        // Failing to meet this requirement causes same weight functions to replace each other in TreeSet,
   16.22 +        // so we go some lengths to come up with an ordering between same weight functions,
   16.23 +        // first falling back to parameter count and then to hash code.
   16.24 +        if (ownType.equals(otherType)) {
   16.25 +            return 0;
   16.26 +        }
   16.27 +
   16.28 +        final int diff = weight(ownType) - weight(otherType);
   16.29 +        if (diff != 0) {
   16.30 +            return diff;
   16.31 +        }
   16.32 +        if (ownType.parameterCount() != otherType.parameterCount()) {
   16.33 +            return ownType.parameterCount() - otherType.parameterCount();
   16.34 +        }
   16.35 +        // We're just interested in not returning 0 here, not correct ordering
   16.36 +        return ownType.hashCode() - otherType.hashCode();
   16.37 +    }
   16.38 +
   16.39 +    @Override
   16.40 +    public boolean equals(Object obj) {
   16.41 +        return obj instanceof CompiledFunction && type().equals(((CompiledFunction)obj).type());
   16.42 +    }
   16.43 +
   16.44 +    @Override
   16.45 +    public int hashCode() {
   16.46 +        return type().hashCode();
   16.47      }
   16.48  
   16.49      private int weight() {
   16.50 @@ -119,14 +150,14 @@
   16.51       * a semantically equivalent linkage can be performed.
   16.52       *
   16.53       * @param mt type to check against
   16.54 -     * @return
   16.55 +     * @return true if types are compatible
   16.56       */
   16.57      boolean typeCompatible(final MethodType mt) {
   16.58 -        final Class<?>[] wantedParams   = mt.parameterArray();
   16.59 -        final Class<?>[] existingParams = type().parameterArray();
   16.60 +        final int wantedParamCount   = mt.parameterCount();
   16.61 +        final int existingParamCount = type.parameterCount();
   16.62  
   16.63          //if we are not examining a varargs type, the number of parameters must be the same
   16.64 -        if (wantedParams.length != existingParams.length && !isVarArgsType(mt)) {
   16.65 +        if (wantedParamCount != existingParamCount && !isVarArgsType(mt)) {
   16.66              return false;
   16.67          }
   16.68  
   16.69 @@ -134,10 +165,10 @@
   16.70          //parameters lengths do not match is if our type ends with a varargs argument.
   16.71          //then every trailing parameter in the given callsite can be folded into it, making
   16.72          //us compatible (albeit slower than a direct specialization)
   16.73 -        final int lastParamIndex = Math.min(wantedParams.length, existingParams.length);
   16.74 +        final int lastParamIndex = Math.min(wantedParamCount, existingParamCount);
   16.75          for (int i = 0; i < lastParamIndex; i++) {
   16.76 -            final Type w = Type.typeFor(wantedParams[i]);
   16.77 -            final Type e = Type.typeFor(existingParams[i]);
   16.78 +            final Type w = Type.typeFor(mt.parameterType(i));
   16.79 +            final Type e = Type.typeFor(type.parameterType(i));
   16.80  
   16.81              //don't specialize on booleans, we have the "true" vs int 1 ambiguity in resolution
   16.82              //we also currently don't support boolean as a javascript function callsite type.
    17.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Thu Oct 10 10:09:30 2013 -0700
    17.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Fri Oct 11 03:09:54 2013 -0700
    17.3 @@ -91,6 +91,11 @@
    17.4       */
    17.5      public static final String NASHORN_JAVA_REFLECTION = "nashorn.JavaReflection";
    17.6  
    17.7 +    // nashorn load psuedo URL prefixes
    17.8 +    private static final String LOAD_CLASSPATH = "classpath:";
    17.9 +    private static final String LOAD_FX = "fx:";
   17.10 +    private static final String LOAD_NASHORN = "nashorn:";
   17.11 +
   17.12      /* Force DebuggerSupport to be loaded. */
   17.13      static {
   17.14          DebuggerSupport.FORCELOAD = true;
   17.15 @@ -501,21 +506,26 @@
   17.16          // or a ScriptObject that has "name" and "source" (string valued) properties.
   17.17          if (src instanceof String) {
   17.18              final String srcStr = (String)src;
   17.19 -            final File file = new File(srcStr);
   17.20 -            if (srcStr.indexOf(':') != -1) {
   17.21 -                if ((source = loadInternal(srcStr, "nashorn:", "resources/")) == null &&
   17.22 -                    (source = loadInternal(srcStr, "fx:", "resources/fx/")) == null) {
   17.23 -                    URL url;
   17.24 -                    try {
   17.25 -                        //check for malformed url. if malformed, it may still be a valid file
   17.26 -                        url = new URL(srcStr);
   17.27 -                    } catch (final MalformedURLException e) {
   17.28 -                        url = file.toURI().toURL();
   17.29 +            if (srcStr.startsWith(LOAD_CLASSPATH)) {
   17.30 +                URL url = getResourceURL(srcStr.substring(LOAD_CLASSPATH.length()));
   17.31 +                source = (url != null)? new Source(url.toString(), url) : null;
   17.32 +            } else {
   17.33 +                final File file = new File(srcStr);
   17.34 +                if (srcStr.indexOf(':') != -1) {
   17.35 +                    if ((source = loadInternal(srcStr, LOAD_NASHORN, "resources/")) == null &&
   17.36 +                        (source = loadInternal(srcStr, LOAD_FX, "resources/fx/")) == null) {
   17.37 +                        URL url;
   17.38 +                        try {
   17.39 +                            //check for malformed url. if malformed, it may still be a valid file
   17.40 +                            url = new URL(srcStr);
   17.41 +                        } catch (final MalformedURLException e) {
   17.42 +                            url = file.toURI().toURL();
   17.43 +                        }
   17.44 +                        source = new Source(url.toString(), url);
   17.45                      }
   17.46 -                    source = new Source(url.toString(), url);
   17.47 +                } else if (file.isFile()) {
   17.48 +                    source = new Source(srcStr, file);
   17.49                  }
   17.50 -            } else if (file.isFile()) {
   17.51 -                source = new Source(srcStr, file);
   17.52              }
   17.53          } else if (src instanceof File && ((File)src).isFile()) {
   17.54              final File file = (File)src;
   17.55 @@ -610,36 +620,53 @@
   17.56      }
   17.57  
   17.58      /**
   17.59 -     * Checks that the given package can be accessed from no permissions context.
   17.60 +     * Checks that the given Class can be accessed from no permissions context.
   17.61       *
   17.62 -     * @param fullName fully qualified package name
   17.63 +     * @param clazz Class object
   17.64       * @throw SecurityException if not accessible
   17.65       */
   17.66 -    public static void checkPackageAccess(final String fullName) {
   17.67 -        final int index = fullName.lastIndexOf('.');
   17.68 -        if (index != -1) {
   17.69 -            final SecurityManager sm = System.getSecurityManager();
   17.70 -            if (sm != null) {
   17.71 -                AccessController.doPrivileged(new PrivilegedAction<Void>() {
   17.72 -                    @Override
   17.73 -                    public Void run() {
   17.74 -                        sm.checkPackageAccess(fullName.substring(0, index));
   17.75 -                        return null;
   17.76 -                    }
   17.77 -                }, NO_PERMISSIONS_ACC_CTXT);
   17.78 +    public static void checkPackageAccess(final Class clazz) {
   17.79 +        final SecurityManager sm = System.getSecurityManager();
   17.80 +        if (sm != null) {
   17.81 +            Class bottomClazz = clazz;
   17.82 +            while(bottomClazz.isArray()) {
   17.83 +                bottomClazz = bottomClazz.getComponentType();
   17.84              }
   17.85 +            checkPackageAccess(sm, bottomClazz.getName());
   17.86          }
   17.87      }
   17.88  
   17.89      /**
   17.90       * Checks that the given package can be accessed from no permissions context.
   17.91       *
   17.92 +     * @param sm current security manager instance
   17.93       * @param fullName fully qualified package name
   17.94 +     * @throw SecurityException if not accessible
   17.95 +     */
   17.96 +    private static void checkPackageAccess(final SecurityManager sm, final String fullName) {
   17.97 +        sm.getClass(); // null check
   17.98 +        final int index = fullName.lastIndexOf('.');
   17.99 +        if (index != -1) {
  17.100 +            final String pkgName = fullName.substring(0, index);
  17.101 +            AccessController.doPrivileged(new PrivilegedAction<Void>() {
  17.102 +                @Override
  17.103 +                public Void run() {
  17.104 +                    sm.checkPackageAccess(pkgName);
  17.105 +                    return null;
  17.106 +                }
  17.107 +            }, NO_PERMISSIONS_ACC_CTXT);
  17.108 +        }
  17.109 +    }
  17.110 +
  17.111 +    /**
  17.112 +     * Checks that the given Class can be accessed from no permissions context.
  17.113 +     *
  17.114 +     * @param clazz Class object
  17.115       * @return true if package is accessible, false otherwise
  17.116       */
  17.117 -    public static boolean isAccessiblePackage(final String fullName) {
  17.118 +    private static boolean isAccessiblePackage(final Class clazz) {
  17.119          try {
  17.120 -            checkPackageAccess(fullName);
  17.121 +            checkPackageAccess(clazz);
  17.122              return true;
  17.123          } catch (final SecurityException se) {
  17.124              return false;
  17.125 @@ -653,7 +680,7 @@
  17.126       * @return true if Class is accessible, false otherwise
  17.127       */
  17.128      public static boolean isAccessibleClass(final Class<?> clazz) {
  17.129 -        return Modifier.isPublic(clazz.getModifiers()) && Context.isAccessiblePackage(clazz.getName());
  17.130 +        return Modifier.isPublic(clazz.getModifiers()) && Context.isAccessiblePackage(clazz);
  17.131      }
  17.132  
  17.133      /**
  17.134 @@ -667,8 +694,16 @@
  17.135       * @throws ClassNotFoundException if class cannot be resolved
  17.136       */
  17.137      public Class<?> findClass(final String fullName) throws ClassNotFoundException {
  17.138 +        if (fullName.indexOf('[') != -1 || fullName.indexOf('/') != -1) {
  17.139 +            // don't allow array class names or internal names.
  17.140 +            throw new ClassNotFoundException(fullName);
  17.141 +        }
  17.142 +
  17.143          // check package access as soon as possible!
  17.144 -        checkPackageAccess(fullName);
  17.145 +        final SecurityManager sm = System.getSecurityManager();
  17.146 +        if (sm != null) {
  17.147 +            checkPackageAccess(sm, fullName);
  17.148 +        }
  17.149  
  17.150          // try the script -classpath loader, if that is set
  17.151          if (classPathLoader != null) {
  17.152 @@ -803,6 +838,18 @@
  17.153          return Context.getContextTrusted();
  17.154      }
  17.155  
  17.156 +    private URL getResourceURL(final String resName) throws IOException {
  17.157 +        // try the classPathLoader if we have and then
  17.158 +        // try the appLoader if non-null.
  17.159 +        if (classPathLoader != null) {
  17.160 +            return classPathLoader.getResource(resName);
  17.161 +        } else if (appLoader != null) {
  17.162 +            return appLoader.getResource(resName);
  17.163 +        }
  17.164 +
  17.165 +        return null;
  17.166 +    }
  17.167 +
  17.168      private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) {
  17.169          ScriptFunction script = null;
  17.170  
    18.1 --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Thu Oct 10 10:09:30 2013 -0700
    18.2 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Fri Oct 11 03:09:54 2013 -0700
    18.3 @@ -132,7 +132,7 @@
    18.4          if (source != null) {
    18.5              sb.append(source.getName())
    18.6                  .append(':')
    18.7 -                .append(source.getLine(Token.descPosition(token)))
    18.8 +                .append(functionNode.getLineNumber())
    18.9                  .append(' ');
   18.10          }
   18.11  
    19.1 --- a/src/jdk/nashorn/internal/runtime/Source.java	Thu Oct 10 10:09:30 2013 -0700
    19.2 +++ b/src/jdk/nashorn/internal/runtime/Source.java	Fri Oct 11 03:09:54 2013 -0700
    19.3 @@ -272,6 +272,10 @@
    19.4  
    19.5      /**
    19.6       * Return line number of character position.
    19.7 +     *
    19.8 +     * <p>This method can be expensive for large sources as it iterates through
    19.9 +     * all characters up to {@code position}.</p>
   19.10 +     *
   19.11       * @param position Position of character in source content.
   19.12       * @return Line number.
   19.13       */
    20.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Thu Oct 10 10:09:30 2013 -0700
    20.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Fri Oct 11 03:09:54 2013 -0700
    20.3 @@ -109,7 +109,7 @@
    20.4          if (sm != null) {
    20.5              for (Class<?> type : types) {
    20.6                  // check for restricted package access
    20.7 -                Context.checkPackageAccess(type.getName());
    20.8 +                Context.checkPackageAccess(type);
    20.9              }
   20.10          }
   20.11          return getAdapterInfo(types).getAdapterClassFor(classOverrides);
    21.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Thu Oct 10 10:09:30 2013 -0700
    21.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Fri Oct 11 03:09:54 2013 -0700
    21.3 @@ -70,7 +70,7 @@
    21.4          // We intercept "new" on StaticClass instances to provide additional capabilities
    21.5          if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) {
    21.6              // make sure new is on accessible Class
    21.7 -            Context.checkPackageAccess(receiverClass.getName());
    21.8 +            Context.checkPackageAccess(receiverClass);
    21.9  
   21.10              // Is the class abstract? (This includes interfaces.)
   21.11              if (NashornLinker.isAbstractClass(receiverClass)) {
    22.1 --- a/src/jdk/nashorn/internal/runtime/resources/fx/base.js	Thu Oct 10 10:09:30 2013 -0700
    22.2 +++ b/src/jdk/nashorn/internal/runtime/resources/fx/base.js	Fri Oct 11 03:09:54 2013 -0700
    22.3 @@ -33,7 +33,6 @@
    22.4  var JFX_SWT_CLASSES      = [];
    22.5  
    22.6  function LOAD_FX_CLASSES(clsList) {
    22.7 -
    22.8      for each (var cls in clsList) {
    22.9          // Ex. Stage = Java.type("javafx.stage.Stage");
   22.10          this[cls[cls.length - 1]] = Java.type(cls.join("."));
   22.11 @@ -146,3 +145,5 @@
   22.12          }
   22.13      }
   22.14  })();
   22.15 +
   22.16 +LOAD_FX_CLASSES(JFX_BASE_CLASSES);
    23.1 --- a/test/script/basic/JDK-8023026.js	Thu Oct 10 10:09:30 2013 -0700
    23.2 +++ b/test/script/basic/JDK-8023026.js	Fri Oct 11 03:09:54 2013 -0700
    23.3 @@ -48,7 +48,7 @@
    23.4          function(x) x*x));
    23.5  }
    23.6  
    23.7 -var array = new (Java.type("[I"))(4);
    23.8 +var array = new (Java.type("int[]"))(4);
    23.9  for (var i in array) {
   23.10      array[i] = i;
   23.11  }
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/script/basic/JDK-8025213.js	Fri Oct 11 03:09:54 2013 -0700
    24.3 @@ -0,0 +1,39 @@
    24.4 +/*
    24.5 + * Copyright (c) 2010, 2013, 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-8025213: Assignment marks variable as defined too early
   24.29 + *
   24.30 + * @test
   24.31 + * @run
   24.32 + */
   24.33 +
   24.34 +function test() {
   24.35 +    if (String("")) {
   24.36 +        var foo = 42;
   24.37 +    }
   24.38 +    foo = foo + 1;
   24.39 +    print(foo);
   24.40 +}
   24.41 +
   24.42 +test();
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/script/basic/JDK-8025213.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    25.3 @@ -0,0 +1,1 @@
    25.4 +NaN
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/script/basic/JDK-8025488.js	Fri Oct 11 03:09:54 2013 -0700
    26.3 @@ -0,0 +1,43 @@
    26.4 +/*
    26.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + * 
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + * 
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + * 
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + * 
   26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 + * or visit www.oracle.com if you need additional information or have any
   26.24 + * questions.
   26.25 + */
   26.26 +
   26.27 +/**
   26.28 + * JDK-8025488: Error.captureStackTrace should not format error stack
   26.29 + *
   26.30 + * @test
   26.31 + * @run
   26.32 + */
   26.33 +
   26.34 +
   26.35 +function MyError () {
   26.36 +    Error.call(this);
   26.37 +    Error.captureStackTrace(this);
   26.38 +    this.arr = {};
   26.39 +};
   26.40 +
   26.41 +MyError.prototype.toString = function() {
   26.42 +    return this.arr.toString();
   26.43 +}
   26.44 +
   26.45 +var e = new MyError(); 
   26.46 +print(e.stack);
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/script/basic/JDK-8025488.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    27.3 @@ -0,0 +1,3 @@
    27.4 +[object Object]
    27.5 +	at MyError (test/script/basic/JDK-8025488.js:34)
    27.6 +	at <program> (test/script/basic/JDK-8025488.js:42)
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/script/basic/JDK-8025515.js	Fri Oct 11 03:09:54 2013 -0700
    28.3 @@ -0,0 +1,58 @@
    28.4 +/*
    28.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 + * 
    28.8 + * This code is free software; you can redistribute it and/or modify it
    28.9 + * under the terms of the GNU General Public License version 2 only, as
   28.10 + * published by the Free Software Foundation.
   28.11 + * 
   28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.15 + * version 2 for more details (a copy is included in the LICENSE file that
   28.16 + * accompanied this code).
   28.17 + * 
   28.18 + * You should have received a copy of the GNU General Public License version
   28.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.21 + * 
   28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.23 + * or visit www.oracle.com if you need additional information or have any
   28.24 + * questions.
   28.25 + */
   28.26 +
   28.27 +/**
   28.28 + * JDK-8025515: Performance issues with Source.getLine()
   28.29 + *
   28.30 + * @test
   28.31 + * @run
   28.32 + */
   28.33 +
   28.34 +// Make sure synthetic names of anonymous functions have correct line numbers
   28.35 +
   28.36 +function testMethodName(f, expected) {
   28.37 +    try {
   28.38 +        f();
   28.39 +        fail("expected error");
   28.40 +    } catch (e) {
   28.41 +        var stack = e.getStackTrace();
   28.42 +        if (stack[0].methodName !== expected) {
   28.43 +            fail("got " + stack[0].methodName + ", expected " + expected);
   28.44 +        }
   28.45 +    }
   28.46 +}
   28.47 +
   28.48 +testMethodName(function() {
   28.49 +    return a.b.c;
   28.50 +}, "_L45");
   28.51 +
   28.52 +testMethodName(function() { throw new Error() }, "_L49");
   28.53 +
   28.54 +var f = (function() {
   28.55 +    return function() { a.b.c; };
   28.56 +})();
   28.57 +testMethodName(f, "_L51$_L52");
   28.58 +
   28.59 +testMethodName((function() {
   28.60 +    return function() { return a.b.c; };
   28.61 +})(), "_L56$_L57");
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/script/basic/JDK-8025520.js	Fri Oct 11 03:09:54 2013 -0700
    29.3 @@ -0,0 +1,50 @@
    29.4 +/*
    29.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 + * 
    29.8 + * This code is free software; you can redistribute it and/or modify it
    29.9 + * under the terms of the GNU General Public License version 2 only, as
   29.10 + * published by the Free Software Foundation.
   29.11 + * 
   29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 + * version 2 for more details (a copy is included in the LICENSE file that
   29.16 + * accompanied this code).
   29.17 + * 
   29.18 + * You should have received a copy of the GNU General Public License version
   29.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 + * 
   29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 + * or visit www.oracle.com if you need additional information or have any
   29.24 + * questions.
   29.25 + */
   29.26 +
   29.27 +/**
   29.28 + * JDK-8025520: Array.prototype.slice should only copy defined elements
   29.29 + *
   29.30 + * @test
   29.31 + * @run
   29.32 + */
   29.33 +
   29.34 +var s = Array.prototype.slice.call({length: 6, 3: 1}, 2, 5);
   29.35 +
   29.36 +if (s.length != 3) {
   29.37 +    fail("s.length != 3");
   29.38 +}
   29.39 +if (0 in s) {
   29.40 +    fail("0 in s");
   29.41 +}
   29.42 +if (s.hasOwnProperty(0)) {
   29.43 +    fail("s.hasOwnProperty(0)");
   29.44 +}
   29.45 +if (s[1] !== 1) {
   29.46 +    fail("s[1] !== 1");
   29.47 +}
   29.48 +if (2 in s) {
   29.49 +    fail("2 in s");
   29.50 +}
   29.51 +if (s.hasOwnProperty(2)) {
   29.52 +    fail("s.hasOwnProperty(2)");
   29.53 +}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/script/basic/JDK-8025589.js	Fri Oct 11 03:09:54 2013 -0700
    30.3 @@ -0,0 +1,51 @@
    30.4 +/*
    30.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + * 
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.
   30.11 + * 
   30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 + * version 2 for more details (a copy is included in the LICENSE file that
   30.16 + * accompanied this code).
   30.17 + * 
   30.18 + * You should have received a copy of the GNU General Public License version
   30.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 + * 
   30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 + * or visit www.oracle.com if you need additional information or have any
   30.24 + * questions.
   30.25 + */
   30.26 +
   30.27 +/**
   30.28 + * JDK-8025589:  Array.prototype.shift should only copy defined elements in generic mode
   30.29 + *
   30.30 + * @test
   30.31 + * @run
   30.32 + */
   30.33 +
   30.34 +var s = {length: 4, 2: 1};
   30.35 +Array.prototype.shift.call(s);
   30.36 +
   30.37 +if (s.length != 3) {
   30.38 +    fail("s.length != 3");
   30.39 +}
   30.40 +if (0 in s) {
   30.41 +    fail("0 in s");
   30.42 +}
   30.43 +if (s.hasOwnProperty(0)) {
   30.44 +    fail("s.hasOwnProperty(0)");
   30.45 +}
   30.46 +if (s[1] !== 1) {
   30.47 +    fail("s[1] !== 1");
   30.48 +}
   30.49 +if (2 in s) {
   30.50 +    fail("2 in s");
   30.51 +}
   30.52 +if (s.hasOwnProperty(2)) {
   30.53 +    fail("s.hasOwnProperty(2)");
   30.54 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/script/basic/JDK-8026033.js	Fri Oct 11 03:09:54 2013 -0700
    31.3 @@ -0,0 +1,39 @@
    31.4 +/*
    31.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.7 + * 
    31.8 + * This code is free software; you can redistribute it and/or modify it
    31.9 + * under the terms of the GNU General Public License version 2 only, as
   31.10 + * published by the Free Software Foundation.
   31.11 + * 
   31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   31.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   31.15 + * version 2 for more details (a copy is included in the LICENSE file that
   31.16 + * accompanied this code).
   31.17 + * 
   31.18 + * You should have received a copy of the GNU General Public License version
   31.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   31.21 + * 
   31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   31.23 + * or visit www.oracle.com if you need additional information or have any
   31.24 + * questions.
   31.25 + */
   31.26 +
   31.27 +/**
   31.28 + * JDK-8026033: Switch should load expression even when there are no cases in it
   31.29 + *
   31.30 + * @test
   31.31 + * @run
   31.32 + */
   31.33 +
   31.34 +try {
   31.35 +    (function() { switch(x) {} })();
   31.36 +    fail("Should have thrown ReferenceError");
   31.37 +} catch (e) {
   31.38 +    if (! (e instanceof ReferenceError)) {
   31.39 +        fail("ReferenceError expected, got " + e);
   31.40 +    }
   31.41 +    print(e);
   31.42 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/script/basic/JDK-8026033.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    32.3 @@ -0,0 +1,1 @@
    32.4 +ReferenceError: "x" is not defined
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/script/basic/JDK-8026042.js	Fri Oct 11 03:09:54 2013 -0700
    33.3 @@ -0,0 +1,43 @@
    33.4 +/*
    33.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + * 
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.
   33.11 + * 
   33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.15 + * version 2 for more details (a copy is included in the LICENSE file that
   33.16 + * accompanied this code).
   33.17 + * 
   33.18 + * You should have received a copy of the GNU General Public License version
   33.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.21 + * 
   33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.23 + * or visit www.oracle.com if you need additional information or have any
   33.24 + * questions.
   33.25 + */
   33.26 +
   33.27 +/**
   33.28 + * JDK-8026042: FoldConstants need to guard against ArrayLiteralNode
   33.29 + *
   33.30 + * @test
   33.31 + * @run
   33.32 + */
   33.33 +
   33.34 +try {
   33.35 +    if ([a]) {
   33.36 +        print("fail");
   33.37 +    }
   33.38 +} catch (e) {
   33.39 +    print(e);
   33.40 +}
   33.41 +
   33.42 +try {
   33.43 +    [a] ? print(1) : print(2);
   33.44 +} catch (e) {
   33.45 +    print(e);
   33.46 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/script/basic/JDK-8026042.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    34.3 @@ -0,0 +1,2 @@
    34.4 +ReferenceError: "a" is not defined
    34.5 +ReferenceError: "a" is not defined
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/test/script/basic/JDK-8026048.js	Fri Oct 11 03:09:54 2013 -0700
    35.3 @@ -0,0 +1,37 @@
    35.4 +/*
    35.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    35.7 + * 
    35.8 + * This code is free software; you can redistribute it and/or modify it
    35.9 + * under the terms of the GNU General Public License version 2 only, as
   35.10 + * published by the Free Software Foundation.
   35.11 + * 
   35.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   35.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   35.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   35.15 + * version 2 for more details (a copy is included in the LICENSE file that
   35.16 + * accompanied this code).
   35.17 + * 
   35.18 + * You should have received a copy of the GNU General Public License version
   35.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   35.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   35.21 + * 
   35.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   35.23 + * or visit www.oracle.com if you need additional information or have any
   35.24 + * questions.
   35.25 + */
   35.26 +
   35.27 +/**
   35.28 + * JDK-8026048: Function constructor should convert arguments to String before performing any syntax checks
   35.29 + *
   35.30 + * @test
   35.31 + * @run
   35.32 + */
   35.33 +
   35.34 +try {
   35.35 +    Function("-", {toString:function(){throw "err"}})
   35.36 +} catch (e) {
   35.37 +    if (e !== "err") {
   35.38 +        fail("err xpected, got " + e);
   35.39 +    }
   35.40 +}
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/script/error/JDK-8026039.js	Fri Oct 11 03:09:54 2013 -0700
    36.3 @@ -0,0 +1,32 @@
    36.4 +/*
    36.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.7 + * 
    36.8 + * This code is free software; you can redistribute it and/or modify it
    36.9 + * under the terms of the GNU General Public License version 2 only, as
   36.10 + * published by the Free Software Foundation.
   36.11 + * 
   36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   36.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   36.15 + * version 2 for more details (a copy is included in the LICENSE file that
   36.16 + * accompanied this code).
   36.17 + * 
   36.18 + * You should have received a copy of the GNU General Public License version
   36.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   36.21 + * 
   36.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   36.23 + * or visit www.oracle.com if you need additional information or have any
   36.24 + * questions.
   36.25 + */
   36.26 +
   36.27 +/**
   36.28 + * JDK-8026039: future strict names are allowed as function name and argument name of a strict function
   36.29 + *
   36.30 + * @test/compile-error
   36.31 + */
   36.32 +
   36.33 +function public() {"use strict"}
   36.34 +
   36.35 +function f(public) {"use strict"} 
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/script/error/JDK-8026039.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    37.3 @@ -0,0 +1,9 @@
    37.4 +test/script/error/JDK-8026039.js:30:9 "public" cannot be used as function name in strict mode
    37.5 +function public() {"use strict"}
    37.6 +         ^
    37.7 +test/script/error/JDK-8026039.js:32:11 Expected ident but found public
    37.8 +function f(public) {"use strict"} 
    37.9 +           ^
   37.10 +test/script/error/JDK-8026039.js:33:0 Expected } but found eof
   37.11 +
   37.12 +^
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/script/sandbox/arrayclass.js	Fri Oct 11 03:09:54 2013 -0700
    38.3 @@ -0,0 +1,37 @@
    38.4 +/*
    38.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.7 + * 
    38.8 + * This code is free software; you can redistribute it and/or modify it
    38.9 + * under the terms of the GNU General Public License version 2 only, as
   38.10 + * published by the Free Software Foundation.
   38.11 + * 
   38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   38.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   38.15 + * version 2 for more details (a copy is included in the LICENSE file that
   38.16 + * accompanied this code).
   38.17 + * 
   38.18 + * You should have received a copy of the GNU General Public License version
   38.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   38.21 + * 
   38.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   38.23 + * or visit www.oracle.com if you need additional information or have any
   38.24 + * questions.
   38.25 + */
   38.26 +
   38.27 +/**
   38.28 + * Try to access array class of a sensitive class like Unsafe.
   38.29 + *
   38.30 + * @test
   38.31 + * @security
   38.32 + * @run
   38.33 + */
   38.34 +
   38.35 +try {
   38.36 +    var unsafeArr = Java.type("[Lsun.misc.Unsafe;");
   38.37 +    fail("No Exception for [Lsun.misc.Unsafe;");
   38.38 +} catch (e) {
   38.39 +    print(e);
   38.40 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/script/sandbox/arrayclass.js.EXPECTED	Fri Oct 11 03:09:54 2013 -0700
    39.3 @@ -0,0 +1,1 @@
    39.4 +java.lang.ClassNotFoundException: [Lsun.misc.Unsafe;
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/script/trusted/JDK-8025629.js	Fri Oct 11 03:09:54 2013 -0700
    40.3 @@ -0,0 +1,33 @@
    40.4 +/*
    40.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + * 
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.
   40.11 + * 
   40.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.15 + * version 2 for more details (a copy is included in the LICENSE file that
   40.16 + * accompanied this code).
   40.17 + * 
   40.18 + * You should have received a copy of the GNU General Public License version
   40.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.21 + * 
   40.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   40.23 + * or visit www.oracle.com if you need additional information or have any
   40.24 + * questions.
   40.25 + */
   40.26 +
   40.27 +/**
   40.28 + * JDK-8025629: load function should support a way to load scripts from classpath
   40.29 + *
   40.30 + * @test
   40.31 + * @run
   40.32 + */
   40.33 +
   40.34 +load("classpath:jdk/nashorn/internal/runtime/resources/load_test.js")
   40.35 +
   40.36 +Assert.assertEquals(loadedFunc("hello"), "HELLO");
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/src/jdk/nashorn/internal/runtime/resources/load_test.js	Fri Oct 11 03:09:54 2013 -0700
    41.3 @@ -0,0 +1,28 @@
    41.4 +/*
    41.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + *
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.  Oracle designates this
   41.11 + * particular file as subject to the "Classpath" exception as provided
   41.12 + * by Oracle in the LICENSE file that accompanied this code.
   41.13 + *
   41.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.17 + * version 2 for more details (a copy is included in the LICENSE file that
   41.18 + * accompanied this code).
   41.19 + *
   41.20 + * You should have received a copy of the GNU General Public License version
   41.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.23 + *
   41.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.25 + * or visit www.oracle.com if you need additional information or have any
   41.26 + * questions.
   41.27 + */
   41.28 +
   41.29 +function loadedFunc(arg) {
   41.30 +    return arg.toUpperCase();
   41.31 +}

mercurial