Merge jdk8-b110

Thu, 26 Sep 2013 17:23:22 -0700

author
lana
date
Thu, 26 Sep 2013 17:23:22 -0700
changeset 578
d49a8c2173f5
parent 558
d1e2050e575e
parent 577
f1f027907a69
child 579
75fd3486e584

Merge

     1.1 --- a/make/build-benchmark.xml	Thu Sep 26 10:43:59 2013 -0700
     1.2 +++ b/make/build-benchmark.xml	Thu Sep 26 17:23:22 2013 -0700
     1.3 @@ -329,7 +329,7 @@
     1.4            fork="true"
     1.5            dir=".">
     1.6        <jvmarg line="${ext.class.path}"/>
     1.7 -      <jvmarg line="${run.test.jvmargs.octane}"/>
     1.8 +      <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
     1.9        <arg value="${octane-test-sys-prop.test.js.framework}"/>
    1.10        <arg value="--"/>
    1.11        <arg value="${octane-tests}"/>
    1.12 @@ -357,7 +357,7 @@
    1.13            classpath="${run.test.classpath}"
    1.14            fork="true"
    1.15            dir=".">
    1.16 -      <jvmarg line="${run.test.jvmargs.octane}"/>
    1.17 +      <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
    1.18        <arg value="${octane-test-sys-prop.test.js.framework}"/>
    1.19        <arg value="${octane-tests}"/>
    1.20        <arg value="--runtime"/>
    1.21 @@ -391,7 +391,7 @@
    1.22            fork="true"
    1.23            dir=".">
    1.24        <jvmarg line="${ext.class.path}"/>
    1.25 -      <jvmarg line="${run.test.jvmargs}"/>
    1.26 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
    1.27        <arg value="-timezone=PST"/>
    1.28        <arg value="--class-cache-size=50"/>
    1.29        <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
    1.30 @@ -415,7 +415,7 @@
    1.31            classpath="${run.test.classpath}"
    1.32            fork="true"
    1.33            dir=".">
    1.34 -      <jvmarg line="${run.test.jvmargs}"/>
    1.35 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
    1.36        <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
    1.37        <arg value="${sunspider-tests}/"/>
    1.38      </java>
     2.1 --- a/make/build.xml	Thu Sep 26 10:43:59 2013 -0700
     2.2 +++ b/make/build.xml	Thu Sep 26 17:23:22 2013 -0700
     2.3 @@ -66,6 +66,8 @@
     2.4  
     2.5      <echo message="run.test.jvmargs=${run.test.jvmargs}"/>
     2.6      <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
     2.7 +    <echo message="run.test.xms=${run.test.xms}"/>
     2.8 +    <echo message="run.test.xmx=${run.test.xmx}"/>
     2.9  
    2.10    </target>
    2.11  
    2.12 @@ -320,7 +322,7 @@
    2.13      <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
    2.14         verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
    2.15        <jvmarg line="${ext.class.path}"/>
    2.16 -      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
    2.17 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
    2.18        <propertyset>
    2.19          <propertyref prefix="test-sys-prop."/>
    2.20          <mapper from="test-sys-prop.*" to="*" type="glob"/>
    2.21 @@ -336,7 +338,7 @@
    2.22        <!-- use just build.test.classes.dir to avoid referring to TestNG -->
    2.23        <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
    2.24        <jvmarg line="${ext.class.path}"/>
    2.25 -      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
    2.26 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
    2.27        <syspropertyset>
    2.28            <propertyref prefix="test-sys-prop."/>
    2.29            <mapper type="glob" from="test-sys-prop.*" to="*"/>
    2.30 @@ -352,7 +354,7 @@
    2.31      <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
    2.32         verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
    2.33        <jvmarg line="${ext.class.path}"/>
    2.34 -      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
    2.35 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
    2.36        <propertyset>
    2.37          <propertyref prefix="test262-test-sys-prop."/>
    2.38          <mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
    2.39 @@ -369,7 +371,7 @@
    2.40      <!-- use just build.test.classes.dir to avoid referring to TestNG -->
    2.41      <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
    2.42        <jvmarg line="${ext.class.path}"/>
    2.43 -      <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
    2.44 +      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
    2.45        <classpath>
    2.46            <pathelement path="${run.test.classpath}"/>
    2.47        </classpath>
    2.48 @@ -387,7 +389,7 @@
    2.49        description="Run the shell with a sample script">
    2.50      <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
    2.51          <jvmarg line="${ext.class.path}"/>
    2.52 -        <jvmarg line="${run.test.jvmargs}"/>
    2.53 +        <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
    2.54          <arg value="-dump-on-error"/>
    2.55          <arg value="test.js"/>
    2.56      </java>
    2.57 @@ -397,7 +399,7 @@
    2.58        description="Debug the shell with a sample script">
    2.59      <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
    2.60          <jvmarg line="${ext.class.path}"/>
    2.61 -        <jvmarg line="${run.test.jvmargs}"/>
    2.62 +        <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
    2.63          <arg value="--print-code"/>
    2.64          <arg value="--verify-code"/>
    2.65          <arg value="--print-symbols"/>
     3.1 --- a/make/project.properties	Thu Sep 26 10:43:59 2013 -0700
     3.2 +++ b/make/project.properties	Thu Sep 26 17:23:22 2013 -0700
     3.3 @@ -216,13 +216,14 @@
     3.4  src.dir=src
     3.5  test.src.dir=test/src
     3.6  
     3.7 +# -Xmx is used for all tests, -Xms only for octane benchmark
     3.8  run.test.xmx=3G
     3.9  run.test.xms=2G
    3.10  
    3.11  run.test.user.language=tr
    3.12  run.test.user.country=TR
    3.13  
    3.14 -run.test.jvmargs.common=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
    3.15 +run.test.jvmargs.common=-server -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
    3.16  
    3.17  #-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
    3.18  # -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
    3.19 @@ -231,12 +232,12 @@
    3.20  run.test.jvmargs.main=${run.test.jvmargs.common} -ea
    3.21  
    3.22  #-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M  
    3.23 -run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.common}
    3.24 +run.test.jvmargs.octane.main=${run.test.jvmargs.common}
    3.25  
    3.26  run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
    3.27  
    3.28  # VM options for script tests with @fork option
    3.29 -test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} ${run.test.jvmsecurityargs}
    3.30 +test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
    3.31  
    3.32  # path of rhino.jar for benchmarks
    3.33  rhino.jar=
     4.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Sep 26 10:43:59 2013 -0700
     4.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Sep 26 17:23:22 2013 -0700
     4.3 @@ -185,21 +185,12 @@
     4.4  
     4.5      @Override
     4.6      public Object eval(final Reader reader, final ScriptContext ctxt) throws ScriptException {
     4.7 -        try {
     4.8 -            if (reader instanceof URLReader) {
     4.9 -                final URL url = ((URLReader)reader).getURL();
    4.10 -                final Charset cs = ((URLReader)reader).getCharset();
    4.11 -                return evalImpl(compileImpl(new Source(url.toString(), url, cs), ctxt), ctxt);
    4.12 -            }
    4.13 -            return evalImpl(Source.readFully(reader), ctxt);
    4.14 -        } catch (final IOException e) {
    4.15 -            throw new ScriptException(e);
    4.16 -        }
    4.17 +        return evalImpl(makeSource(reader, ctxt), ctxt);
    4.18      }
    4.19  
    4.20      @Override
    4.21      public Object eval(final String script, final ScriptContext ctxt) throws ScriptException {
    4.22 -        return evalImpl(script.toCharArray(), ctxt);
    4.23 +        return evalImpl(makeSource(script, ctxt), ctxt);
    4.24      }
    4.25  
    4.26      @Override
    4.27 @@ -221,16 +212,12 @@
    4.28  
    4.29      @Override
    4.30      public CompiledScript compile(final Reader reader) throws ScriptException {
    4.31 -        try {
    4.32 -            return asCompiledScript(compileImpl(Source.readFully(reader), context));
    4.33 -        } catch (final IOException e) {
    4.34 -            throw new ScriptException(e);
    4.35 -        }
    4.36 +        return asCompiledScript(makeSource(reader, context));
    4.37      }
    4.38  
    4.39      @Override
    4.40      public CompiledScript compile(final String str) throws ScriptException {
    4.41 -        return asCompiledScript(compileImpl(str.toCharArray(), context));
    4.42 +        return asCompiledScript(makeSource(str, context));
    4.43      }
    4.44  
    4.45      // Invocable methods
    4.46 @@ -292,6 +279,29 @@
    4.47  
    4.48      // Implementation only below this point
    4.49  
    4.50 +    private static Source makeSource(final Reader reader, final ScriptContext ctxt) throws ScriptException {
    4.51 +        try {
    4.52 +            if (reader instanceof URLReader) {
    4.53 +                final URL url = ((URLReader)reader).getURL();
    4.54 +                final Charset cs = ((URLReader)reader).getCharset();
    4.55 +                return new Source(url.toString(), url, cs);
    4.56 +            } else {
    4.57 +                return new Source(getScriptName(ctxt), Source.readFully(reader));
    4.58 +            }
    4.59 +        } catch (final IOException ioExp) {
    4.60 +            throw new ScriptException(ioExp);
    4.61 +        }
    4.62 +    }
    4.63 +
    4.64 +    private static Source makeSource(final String src, final ScriptContext ctxt) {
    4.65 +        return new Source(getScriptName(ctxt), src);
    4.66 +    }
    4.67 +
    4.68 +    private static String getScriptName(final ScriptContext ctxt) {
    4.69 +        final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
    4.70 +        return (val != null) ? val.toString() : "<eval>";
    4.71 +    }
    4.72 +
    4.73      private <T> T getInterfaceInner(final Object thiz, final Class<T> clazz) {
    4.74          if (clazz == null || !clazz.isInterface()) {
    4.75              throw new IllegalArgumentException(getMessage("interface.class.expected"));
    4.76 @@ -429,7 +439,7 @@
    4.77          // current ScriptContext exposed as "context"
    4.78          // "context" is non-writable from script - but script engine still
    4.79          // needs to set it and so save the context Property object
    4.80 -        contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, null);
    4.81 +        contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, ctxt);
    4.82          // current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as
    4.83          // NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property
    4.84          // in the Global of a Context we just created - both the Context and the Global were just created and can not be
    4.85 @@ -509,8 +519,8 @@
    4.86          throw new IllegalArgumentException(getMessage("interface.on.non.script.object"));
    4.87      }
    4.88  
    4.89 -    private Object evalImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
    4.90 -        return evalImpl(compileImpl(buf, ctxt), ctxt);
    4.91 +    private Object evalImpl(final Source src, final ScriptContext ctxt) throws ScriptException {
    4.92 +        return evalImpl(compileImpl(src, ctxt), ctxt);
    4.93      }
    4.94  
    4.95      private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt) throws ScriptException {
    4.96 @@ -561,11 +571,20 @@
    4.97          }
    4.98      }
    4.99  
   4.100 -    private CompiledScript asCompiledScript(final ScriptFunction script) {
   4.101 +    private CompiledScript asCompiledScript(final Source source) throws ScriptException {
   4.102 +        final ScriptFunction func = compileImpl(source, context);
   4.103          return new CompiledScript() {
   4.104              @Override
   4.105              public Object eval(final ScriptContext ctxt) throws ScriptException {
   4.106 -                return evalImpl(script, ctxt);
   4.107 +                final ScriptObject global = getNashornGlobalFrom(ctxt);
   4.108 +                // Are we running the script in the correct global?
   4.109 +                if (func.getScope() == global) {
   4.110 +                    return evalImpl(func, ctxt, global);
   4.111 +                } else {
   4.112 +                    // ScriptContext with a different global. Compile again!
   4.113 +                    // Note that we may still hit per-global compilation cache.
   4.114 +                    return evalImpl(compileImpl(source, ctxt), ctxt, global);
   4.115 +                }
   4.116              }
   4.117              @Override
   4.118              public ScriptEngine getEngine() {
   4.119 @@ -574,12 +593,6 @@
   4.120          };
   4.121      }
   4.122  
   4.123 -    private ScriptFunction compileImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
   4.124 -        final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
   4.125 -        final String fileName = (val != null) ? val.toString() : "<eval>";
   4.126 -        return compileImpl(new Source(fileName, buf), ctxt);
   4.127 -    }
   4.128 -
   4.129      private ScriptFunction compileImpl(final Source source, final ScriptContext ctxt) throws ScriptException {
   4.130          return compileImpl(source, getNashornGlobalFrom(ctxt));
   4.131      }
     5.1 --- a/src/jdk/nashorn/internal/codegen/Attr.java	Thu Sep 26 10:43:59 2013 -0700
     5.2 +++ b/src/jdk/nashorn/internal/codegen/Attr.java	Thu Sep 26 17:23:22 2013 -0700
     5.3 @@ -807,9 +807,11 @@
     5.4                      type = Type.OBJECT;
     5.5                  }
     5.6  
     5.7 -                type = Type.widest(type, newCaseNode.getTest().getType());
     5.8 -                if (type.isBoolean()) {
     5.9 +                final Type newCaseType = newCaseNode.getTest().getType();
    5.10 +                if (newCaseType.isBoolean()) {
    5.11                      type = Type.OBJECT; //booleans and integers aren't assignment compatible
    5.12 +                } else {
    5.13 +                    type = Type.widest(type, newCaseType);
    5.14                  }
    5.15              }
    5.16  
     6.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Sep 26 10:43:59 2013 -0700
     6.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Sep 26 17:23:22 2013 -0700
     6.3 @@ -852,7 +852,6 @@
     6.4          final Label  loopLabel = new Label("loop");
     6.5  
     6.6          final Expression init = forNode.getInit();
     6.7 -        assert init instanceof IdentNode;
     6.8  
     6.9          load(modify);
    6.10          assert modify.getType().isObject();
    6.11 @@ -2175,8 +2174,9 @@
    6.12              method.invoke(ScriptRuntime.OPEN_WITH);
    6.13              method.storeCompilerConstant(SCOPE);
    6.14          } else {
    6.15 -            // We just loaded the expression for its side effect; discard it
    6.16 -            method.pop();
    6.17 +            // We just loaded the expression for its side effect and to check
    6.18 +            // for null or undefined value.
    6.19 +            globalCheckObjectCoercible();
    6.20          }
    6.21  
    6.22  
    6.23 @@ -3258,6 +3258,10 @@
    6.24          return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
    6.25      }
    6.26  
    6.27 +    private MethodEmitter globalCheckObjectCoercible() {
    6.28 +        return method.invokestatic(GLOBAL_OBJECT, "checkObjectCoercible", methodDescriptor(void.class, Object.class));
    6.29 +    }
    6.30 +
    6.31      private MethodEmitter globalDirectEval() {
    6.32          return method.invokestatic(GLOBAL_OBJECT, "directEval",
    6.33                  methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class));
     7.1 --- a/src/jdk/nashorn/internal/ir/WhileNode.java	Thu Sep 26 10:43:59 2013 -0700
     7.2 +++ b/src/jdk/nashorn/internal/ir/WhileNode.java	Thu Sep 26 17:23:22 2013 -0700
     7.3 @@ -79,13 +79,12 @@
     7.4          if (visitor.enterWhileNode(this)) {
     7.5              if (isDoWhile()) {
     7.6                  return visitor.leaveWhileNode(
     7.7 -                        setTest(lc, (Expression)test.accept(visitor)).
     7.8 -                        setBody(lc, (Block)body.accept(visitor)));
     7.9 +                        setBody(lc, (Block)body.accept(visitor)).
    7.10 +                        setTest(lc, (Expression)test.accept(visitor)));
    7.11              }
    7.12              return visitor.leaveWhileNode(
    7.13 -                    setBody(lc, (Block)body.accept(visitor)).
    7.14 -                    setTest(lc, (Expression)test.accept(visitor)));
    7.15 -
    7.16 +                    setTest(lc, (Expression)test.accept(visitor)).
    7.17 +                    setBody(lc, (Block)body.accept(visitor)));
    7.18          }
    7.19          return this;
    7.20      }
     8.1 --- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Thu Sep 26 10:43:59 2013 -0700
     8.2 +++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Thu Sep 26 17:23:22 2013 -0700
     8.3 @@ -410,7 +410,8 @@
     8.4          comma();
     8.5  
     8.6          property("id");
     8.7 -        if (functionNode.isAnonymous()) {
     8.8 +        final FunctionNode.Kind kind = functionNode.getKind();
     8.9 +        if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
    8.10              nullValue();
    8.11          } else {
    8.12              functionNode.getIdent().accept(this);
     9.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Thu Sep 26 10:43:59 2013 -0700
     9.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Thu Sep 26 17:23:22 2013 -0700
     9.3 @@ -33,6 +33,7 @@
     9.4  import java.io.PrintWriter;
     9.5  import java.lang.invoke.MethodHandle;
     9.6  import java.lang.invoke.MethodHandles;
     9.7 +import java.lang.ref.ReferenceQueue;
     9.8  import java.lang.ref.SoftReference;
     9.9  import java.lang.reflect.Field;
    9.10  import java.util.Arrays;
    9.11 @@ -691,17 +692,41 @@
    9.12       * Cache for compiled script classes.
    9.13       */
    9.14      @SuppressWarnings("serial")
    9.15 -    private static class ClassCache extends LinkedHashMap<Source, SoftReference<Class<?>>> {
    9.16 +    private static class ClassCache extends LinkedHashMap<Source, ClassReference> {
    9.17          private final int size;
    9.18 +        private final ReferenceQueue<Class<?>> queue;
    9.19  
    9.20          ClassCache(int size) {
    9.21              super(size, 0.75f, true);
    9.22              this.size = size;
    9.23 +            this.queue = new ReferenceQueue<>();
    9.24 +        }
    9.25 +
    9.26 +        void cache(final Source source, final Class<?> clazz) {
    9.27 +            put(source, new ClassReference(clazz, queue, source));
    9.28          }
    9.29  
    9.30          @Override
    9.31 -        protected boolean removeEldestEntry(final Map.Entry<Source, SoftReference<Class<?>>> eldest) {
    9.32 -            return size() >= size;
    9.33 +        protected boolean removeEldestEntry(final Map.Entry<Source, ClassReference> eldest) {
    9.34 +            return size() > size;
    9.35 +        }
    9.36 +
    9.37 +        @Override
    9.38 +        public ClassReference get(Object key) {
    9.39 +            for (ClassReference ref; (ref = (ClassReference)queue.poll()) != null; ) {
    9.40 +                remove(ref.source);
    9.41 +            }
    9.42 +            return super.get(key);
    9.43 +        }
    9.44 +
    9.45 +    }
    9.46 +
    9.47 +    private static class ClassReference extends SoftReference<Class<?>> {
    9.48 +        private final Source source;
    9.49 +
    9.50 +        ClassReference(final Class<?> clazz, final ReferenceQueue<Class<?>> queue, final Source source) {
    9.51 +            super(clazz, queue);
    9.52 +            this.source = source;
    9.53          }
    9.54      }
    9.55  
    9.56 @@ -709,22 +734,14 @@
    9.57      @Override
    9.58      public Class<?> findCachedClass(final Source source) {
    9.59          assert classCache != null : "Class cache used without being initialized";
    9.60 -        SoftReference<Class<?>> ref = classCache.get(source);
    9.61 -        if (ref != null) {
    9.62 -            final Class<?> clazz = ref.get();
    9.63 -            if (clazz == null) {
    9.64 -                classCache.remove(source);
    9.65 -            }
    9.66 -            return clazz;
    9.67 -        }
    9.68 -
    9.69 -        return null;
    9.70 +        ClassReference ref = classCache.get(source);
    9.71 +        return ref != null ? ref.get() : null;
    9.72      }
    9.73  
    9.74      @Override
    9.75      public void cacheClass(final Source source, final Class<?> clazz) {
    9.76          assert classCache != null : "Class cache used without being initialized";
    9.77 -        classCache.put(source, new SoftReference<Class<?>>(clazz));
    9.78 +        classCache.cache(source, clazz);
    9.79      }
    9.80  
    9.81      private static <T> T getLazilyCreatedValue(final Object key, final Callable<T> creator, final Map<Object, T> map) {
    10.1 --- a/src/jdk/nashorn/internal/objects/NativeDate.java	Thu Sep 26 10:43:59 2013 -0700
    10.2 +++ b/src/jdk/nashorn/internal/objects/NativeDate.java	Thu Sep 26 17:23:22 2013 -0700
    10.3 @@ -75,11 +75,11 @@
    10.4      private static final int FORMAT_LOCAL_TIME      = 5;
    10.5  
    10.6      // Constants defined in ECMA 15.9.1.10
    10.7 -    private static final double hoursPerDay      = 24;
    10.8 -    private static final double minutesPerHour   = 60;
    10.9 -    private static final double secondsPerMinute = 60;
   10.10 -    private static final double msPerSecond   = 1_000;
   10.11 -    private static final double msPerMinute  = 60_000;
   10.12 +    private static final int    hoursPerDay      = 24;
   10.13 +    private static final int    minutesPerHour   = 60;
   10.14 +    private static final int    secondsPerMinute = 60;
   10.15 +    private static final int    msPerSecond   = 1_000;
   10.16 +    private static final int    msPerMinute  = 60_000;
   10.17      private static final double msPerHour = 3_600_000;
   10.18      private static final double msPerDay = 86_400_000;
   10.19  
   10.20 @@ -926,13 +926,13 @@
   10.21                  case FORMAT_DATE :
   10.22                  case FORMAT_LOCAL_DATE_TIME:
   10.23                      // EEE MMM dd yyyy
   10.24 -                    sb.append(weekDays[(int) weekDay(t)])
   10.25 +                    sb.append(weekDays[weekDay(t)])
   10.26                              .append(' ')
   10.27 -                            .append(months[(int) monthFromTime(t)])
   10.28 +                            .append(months[monthFromTime(t)])
   10.29                              .append(' ');
   10.30 -                    zeroPad(sb, (int) dayFromTime(t), 2);
   10.31 +                    zeroPad(sb, dayFromTime(t), 2);
   10.32                      sb.append(' ');
   10.33 -                    zeroPad(sb, (int) yearFromTime(t), 4);
   10.34 +                    zeroPad(sb, yearFromTime(t), 4);
   10.35                      if (format == FORMAT_DATE) {
   10.36                          break;
   10.37                      }
   10.38 @@ -948,11 +948,11 @@
   10.39                      offset = (offset / 60) * 100 + offset % 60;
   10.40  
   10.41                      // HH:mm:ss GMT+HHmm
   10.42 -                    zeroPad(sb, (int) hourFromTime(t), 2);
   10.43 +                    zeroPad(sb, hourFromTime(t), 2);
   10.44                      sb.append(':');
   10.45 -                    zeroPad(sb, (int) minFromTime(t), 2);
   10.46 +                    zeroPad(sb, minFromTime(t), 2);
   10.47                      sb.append(':');
   10.48 -                    zeroPad(sb, (int) secFromTime(t), 2);
   10.49 +                    zeroPad(sb, secFromTime(t), 2);
   10.50                      sb.append(" GMT")
   10.51                              .append(offset < 0 ? '-' : '+');
   10.52                      zeroPad(sb, Math.abs(offset), 4);
   10.53 @@ -963,20 +963,20 @@
   10.54  
   10.55                  case FORMAT_LOCAL_DATE:
   10.56                      // yyyy-MM-dd
   10.57 -                    zeroPad(sb, (int) yearFromTime(t), 4);
   10.58 +                    zeroPad(sb, yearFromTime(t), 4);
   10.59                      sb.append('-');
   10.60 -                    zeroPad(sb, (int) monthFromTime(t) + 1, 2);
   10.61 +                    zeroPad(sb, monthFromTime(t) + 1, 2);
   10.62                      sb.append('-');
   10.63 -                    zeroPad(sb, (int) dayFromTime(t), 2);
   10.64 +                    zeroPad(sb, dayFromTime(t), 2);
   10.65                      break;
   10.66  
   10.67                  case FORMAT_LOCAL_TIME:
   10.68                      // HH:mm:ss
   10.69 -                    zeroPad(sb, (int) hourFromTime(t), 2);
   10.70 +                    zeroPad(sb, hourFromTime(t), 2);
   10.71                      sb.append(':');
   10.72 -                    zeroPad(sb, (int) minFromTime(t), 2);
   10.73 +                    zeroPad(sb, minFromTime(t), 2);
   10.74                      sb.append(':');
   10.75 -                    zeroPad(sb, (int) secFromTime(t), 2);
   10.76 +                    zeroPad(sb, secFromTime(t), 2);
   10.77                      break;
   10.78  
   10.79                  default:
   10.80 @@ -996,19 +996,19 @@
   10.81              final StringBuilder sb = new StringBuilder(29);
   10.82              final double t = nd.getTime();
   10.83              // EEE, dd MMM yyyy HH:mm:ss z
   10.84 -            sb.append(weekDays[(int) weekDay(t)])
   10.85 +            sb.append(weekDays[weekDay(t)])
   10.86                      .append(", ");
   10.87 -            zeroPad(sb, (int) dayFromTime(t), 2);
   10.88 +            zeroPad(sb, dayFromTime(t), 2);
   10.89              sb.append(' ')
   10.90 -                    .append(months[(int) monthFromTime(t)])
   10.91 +                    .append(months[monthFromTime(t)])
   10.92                      .append(' ');
   10.93 -            zeroPad(sb, (int) yearFromTime(t), 4);
   10.94 +            zeroPad(sb, yearFromTime(t), 4);
   10.95              sb.append(' ');
   10.96 -            zeroPad(sb, (int) hourFromTime(t), 2);
   10.97 +            zeroPad(sb, hourFromTime(t), 2);
   10.98              sb.append(':');
   10.99 -            zeroPad(sb, (int) minFromTime(t), 2);
  10.100 +            zeroPad(sb, minFromTime(t), 2);
  10.101              sb.append(':');
  10.102 -            zeroPad(sb, (int) secFromTime(t), 2);
  10.103 +            zeroPad(sb, secFromTime(t), 2);
  10.104              sb.append(" GMT");
  10.105              return sb.toString();
  10.106          }
  10.107 @@ -1023,19 +1023,19 @@
  10.108              final StringBuilder sb = new StringBuilder(24);
  10.109              final double t = nd.getTime();
  10.110              // yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
  10.111 -            zeroPad(sb, (int) yearFromTime(t), 4);
  10.112 +            zeroPad(sb, yearFromTime(t), 4);
  10.113              sb.append('-');
  10.114 -            zeroPad(sb, (int) monthFromTime(t) + 1, 2);
  10.115 +            zeroPad(sb, monthFromTime(t) + 1, 2);
  10.116              sb.append('-');
  10.117 -            zeroPad(sb, (int) dayFromTime(t), 2);
  10.118 +            zeroPad(sb, dayFromTime(t), 2);
  10.119              sb.append('T');
  10.120 -            zeroPad(sb, (int) hourFromTime(t), 2);
  10.121 +            zeroPad(sb, hourFromTime(t), 2);
  10.122              sb.append(':');
  10.123 -            zeroPad(sb, (int) minFromTime(t), 2);
  10.124 +            zeroPad(sb, minFromTime(t), 2);
  10.125              sb.append(':');
  10.126 -            zeroPad(sb, (int) secFromTime(t), 2);
  10.127 +            zeroPad(sb, secFromTime(t), 2);
  10.128              sb.append('.');
  10.129 -            zeroPad(sb, (int) msFromTime(t), 3);
  10.130 +            zeroPad(sb, msFromTime(t), 3);
  10.131              sb.append("Z");
  10.132              return sb.toString();
  10.133          }
  10.134 @@ -1072,29 +1072,30 @@
  10.135      }
  10.136  
  10.137      // ECMA 15.9.1.3 Year Number
  10.138 -    private static double timeFromYear(final double y) {
  10.139 +    private static double timeFromYear(final int y) {
  10.140          return dayFromYear(y) * msPerDay;
  10.141      }
  10.142  
  10.143 -    private static double yearFromTime(final double t) {
  10.144 -        double y = Math.floor(t / (msPerDay * 365.2425)) + 1970;
  10.145 +    // ECMA 15.9.1.3 Year Number
  10.146 +    private static int yearFromTime(final double t) {
  10.147 +        int y = (int) Math.floor(t / (msPerDay * 365.2425)) + 1970;
  10.148          final double t2 = timeFromYear(y);
  10.149          if (t2 > t) {
  10.150              y--;
  10.151 -        } else if (t2 + msPerDay * daysInYear((int) y) <= t) {
  10.152 +        } else if (t2 + msPerDay * daysInYear(y) <= t) {
  10.153              y++;
  10.154          }
  10.155          return y;
  10.156      }
  10.157  
  10.158 -    private static double dayWithinYear(final double t, final double year) {
  10.159 -        return day(t) - dayFromYear(year);
  10.160 +    private static int dayWithinYear(final double t, final int year) {
  10.161 +        return (int) (day(t) - dayFromYear(year));
  10.162      }
  10.163  
  10.164 -    private static double monthFromTime(final double t) {
  10.165 -        final double year = yearFromTime(t);
  10.166 -        final double day = dayWithinYear(t, year);
  10.167 -        final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
  10.168 +    private static int monthFromTime(final double t) {
  10.169 +        final int year = yearFromTime(t);
  10.170 +        final int day = dayWithinYear(t, year);
  10.171 +        final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
  10.172          int month = 0;
  10.173  
  10.174          while (month < 11 && firstDay[month + 1] <= day) {
  10.175 @@ -1103,10 +1104,10 @@
  10.176          return month;
  10.177      }
  10.178  
  10.179 -    private static double dayFromTime(final double t)  {
  10.180 -        final double year = yearFromTime(t);
  10.181 -        final double day = dayWithinYear(t, year);
  10.182 -        final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
  10.183 +    private static int dayFromTime(final double t)  {
  10.184 +        final int year = yearFromTime(t);
  10.185 +        final int day = dayWithinYear(t, year);
  10.186 +        final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
  10.187          int month = 0;
  10.188  
  10.189          while (month < 11 && firstDay[month + 1] <= day) {
  10.190 @@ -1121,11 +1122,8 @@
  10.191          return firstDay[month];
  10.192      }
  10.193  
  10.194 -    private static double weekDay(final double time) {
  10.195 -        if (isNaN(time)) {
  10.196 -            return NaN;
  10.197 -        }
  10.198 -        final double day = (day(time) + 4) % 7;
  10.199 +    private static int weekDay(final double time) {
  10.200 +        final int day = (int) (day(time) + 4) % 7;
  10.201          return day < 0 ? day + 7 : day;
  10.202      }
  10.203  
  10.204 @@ -1140,26 +1138,26 @@
  10.205      }
  10.206  
  10.207      // ECMA 15.9.1.10 Hours, Minutes, Second, and Milliseconds
  10.208 -    private static double hourFromTime(final double t) {
  10.209 -        final double h = Math.floor(t / msPerHour) % hoursPerDay;
  10.210 +    private static int hourFromTime(final double t) {
  10.211 +        final int h = (int) (Math.floor(t / msPerHour) % hoursPerDay);
  10.212          return h < 0 ? h + hoursPerDay: h;
  10.213      }
  10.214 -    private static double minFromTime(final double t) {
  10.215 -        final double m = Math.floor(t / msPerMinute) % minutesPerHour;
  10.216 +    private static int minFromTime(final double t) {
  10.217 +        final int m = (int) (Math.floor(t / msPerMinute) % minutesPerHour);
  10.218          return m < 0 ? m + minutesPerHour : m;
  10.219      }
  10.220  
  10.221 -    private static double secFromTime(final double t) {
  10.222 -        final double s = Math.floor(t / msPerSecond) % secondsPerMinute;
  10.223 +    private static int secFromTime(final double t) {
  10.224 +        final int s = (int) (Math.floor(t / msPerSecond) % secondsPerMinute);
  10.225          return s < 0 ? s + secondsPerMinute : s;
  10.226      }
  10.227  
  10.228 -    private static double msFromTime(final double t) {
  10.229 -        final double m = t % msPerSecond;
  10.230 +    private static int msFromTime(final double t) {
  10.231 +        final int m = (int) (t % msPerSecond);
  10.232          return m < 0 ? m + msPerSecond : m;
  10.233      }
  10.234  
  10.235 -    private static double valueFromTime(final int unit, final double t) {
  10.236 +    private static int valueFromTime(final int unit, final double t) {
  10.237          switch (unit) {
  10.238              case YEAR: return yearFromTime(t);
  10.239              case MONTH: return monthFromTime(t);
  10.240 @@ -1180,12 +1178,12 @@
  10.241      // ECMA 15.9.1.12 MakeDay (year, month, date)
  10.242      private static double makeDay(final double year, final double month, final double date) {
  10.243          final double y = year + Math.floor(month / 12);
  10.244 -        double m = month % 12;
  10.245 +        int m = (int) (month % 12);
  10.246          if (m < 0) {
  10.247              m += 12;
  10.248          }
  10.249 -        double d = Math.floor(dayFromYear(y));
  10.250 -        d += dayFromMonth((int) m, (int) y);
  10.251 +        double d = dayFromYear(y);
  10.252 +        d += dayFromMonth(m, (int) y);
  10.253  
  10.254          return d + date - 1;
  10.255      }
  10.256 @@ -1257,13 +1255,13 @@
  10.257                      nullReturn = true;
  10.258                  }
  10.259  
  10.260 -                if (! nullReturn) {
  10.261 +                if (!nullReturn && !isNaN(time)) {
  10.262                      d[i - start] = valueFromTime(i, time);
  10.263                  }
  10.264              }
  10.265          }
  10.266  
  10.267 -        return nullReturn? null : d;
  10.268 +        return nullReturn ? null : d;
  10.269      }
  10.270  
  10.271      // ECMA 15.9.1.14 TimeClip (time)
    11.1 --- a/src/jdk/nashorn/internal/objects/NativeJSON.java	Thu Sep 26 10:43:59 2013 -0700
    11.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSON.java	Thu Sep 26 17:23:22 2013 -0700
    11.3 @@ -162,22 +162,27 @@
    11.4  
    11.5          String gap;
    11.6  
    11.7 -        if (space instanceof Number || space instanceof NativeNumber) {
    11.8 -            int indent;
    11.9 -            if (space instanceof NativeNumber) {
   11.10 -                indent = ((NativeNumber)space).intValue();
   11.11 +        // modifiable 'space' - parameter is final
   11.12 +        Object modSpace = space;
   11.13 +        if (modSpace instanceof NativeNumber) {
   11.14 +            modSpace = JSType.toNumber(JSType.toPrimitive(modSpace, Number.class));
   11.15 +        } else if (modSpace instanceof NativeString) {
   11.16 +            modSpace = JSType.toString(JSType.toPrimitive(modSpace, String.class));
   11.17 +        }
   11.18 +
   11.19 +        if (modSpace instanceof Number) {
   11.20 +            int indent = Math.min(10, JSType.toInteger(modSpace));
   11.21 +            if (indent < 1) {
   11.22 +                gap = "";
   11.23              } else {
   11.24 -                indent = ((Number)space).intValue();
   11.25 +                final StringBuilder sb = new StringBuilder();
   11.26 +                for (int i = 0; i < indent; i++) {
   11.27 +                    sb.append(' ');
   11.28 +                }
   11.29 +                gap = sb.toString();
   11.30              }
   11.31 -
   11.32 -            final StringBuilder sb = new StringBuilder();
   11.33 -            for (int i = 0; i < Math.min(10, indent); i++) {
   11.34 -                sb.append(' ');
   11.35 -            }
   11.36 -            gap = sb.toString();
   11.37 -
   11.38 -        } else if (space instanceof String || space instanceof ConsString || space instanceof NativeString) {
   11.39 -            final String str = (space instanceof String) ? (String)space : space.toString();
   11.40 +        } else if (modSpace instanceof String || modSpace instanceof ConsString) {
   11.41 +            final String str = modSpace.toString();
   11.42              gap = str.substring(0, Math.min(10, str.length()));
   11.43          } else {
   11.44              gap = "";
    12.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Sep 26 10:43:59 2013 -0700
    12.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Sep 26 17:23:22 2013 -0700
    12.3 @@ -191,23 +191,21 @@
    12.4      public static NativeRegExp newRegExp(final Object regexp, final Object flags) {
    12.5          String  patternString = "";
    12.6          String  flagString    = "";
    12.7 -        boolean flagsDefined  = false;
    12.8 -
    12.9 -        if (flags != UNDEFINED) {
   12.10 -            flagsDefined = true;
   12.11 -            flagString = JSType.toString(flags);
   12.12 -        }
   12.13  
   12.14          if (regexp != UNDEFINED) {
   12.15              if (regexp instanceof NativeRegExp) {
   12.16 -                if (!flagsDefined) {
   12.17 -                    return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
   12.18 +                if (flags != UNDEFINED) {
   12.19 +                    throw typeError("regex.cant.supply.flags");
   12.20                  }
   12.21 -                throw typeError("regex.cant.supply.flags");
   12.22 +                return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
   12.23              }
   12.24              patternString = JSType.toString(regexp);
   12.25          }
   12.26  
   12.27 +        if (flags != UNDEFINED) {
   12.28 +            flagString = JSType.toString(flags);
   12.29 +        }
   12.30 +
   12.31          return new NativeRegExp(patternString, flagString);
   12.32      }
   12.33  
   12.34 @@ -697,8 +695,13 @@
   12.35                  appendReplacement(matcher, string, replacement, sb);
   12.36              }
   12.37  
   12.38 +            thisIndex = matcher.end();
   12.39 +            if (thisIndex == string.length() && matcher.start() == matcher.end()) {
   12.40 +                // Avoid getting empty match at end of string twice
   12.41 +                break;
   12.42 +            }
   12.43 +
   12.44              // ECMA 15.5.4.10 String.prototype.match(regexp)
   12.45 -            thisIndex = matcher.end();
   12.46              if (thisIndex == previousLastIndex) {
   12.47                  setLastIndex(thisIndex + 1);
   12.48                  previousLastIndex = thisIndex + 1;
   12.49 @@ -883,7 +886,7 @@
   12.50       * @return last index property as int
   12.51       */
   12.52      public int getLastIndex() {
   12.53 -        return JSType.toInt32(lastIndex);
   12.54 +        return JSType.toInteger(lastIndex);
   12.55      }
   12.56  
   12.57      /**
    13.1 --- a/src/jdk/nashorn/internal/parser/JSONParser.java	Thu Sep 26 10:43:59 2013 -0700
    13.2 +++ b/src/jdk/nashorn/internal/parser/JSONParser.java	Thu Sep 26 17:23:22 2013 -0700
    13.3 @@ -349,6 +349,10 @@
    13.4  
    13.5              case COMMARIGHT:
    13.6                  next();
    13.7 +                // check for trailing comma - not allowed in JSON
    13.8 +                if (type == RBRACKET) {
    13.9 +                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
   13.10 +                }
   13.11                  break;
   13.12  
   13.13              default:
   13.14 @@ -388,6 +392,10 @@
   13.15  
   13.16              case COMMARIGHT:
   13.17                  next();
   13.18 +                // check for trailing comma - not allowed in JSON
   13.19 +                if (type == RBRACE) {
   13.20 +                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
   13.21 +                }
   13.22                  break;
   13.23  
   13.24              default:
    14.1 --- a/src/jdk/nashorn/internal/parser/Parser.java	Thu Sep 26 10:43:59 2013 -0700
    14.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java	Thu Sep 26 17:23:22 2013 -0700
    14.3 @@ -59,6 +59,7 @@
    14.4  import java.util.Iterator;
    14.5  import java.util.List;
    14.6  import java.util.Map;
    14.7 +import jdk.internal.dynalink.support.NameCodec;
    14.8  import jdk.nashorn.internal.codegen.CompilerConstants;
    14.9  import jdk.nashorn.internal.codegen.Namespace;
   14.10  import jdk.nashorn.internal.ir.AccessNode;
   14.11 @@ -2108,7 +2109,7 @@
   14.12                  case "get":
   14.13                      final PropertyKey getIdent = propertyName();
   14.14                      final String getterName = getIdent.getPropertyName();
   14.15 -                    final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName);
   14.16 +                    final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + NameCodec.encode(getterName));
   14.17                      expect(LPAREN);
   14.18                      expect(RPAREN);
   14.19                      functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER);
   14.20 @@ -2117,7 +2118,7 @@
   14.21                  case "set":
   14.22                      final PropertyKey setIdent = propertyName();
   14.23                      final String setterName = setIdent.getPropertyName();
   14.24 -                    final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName);
   14.25 +                    final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + NameCodec.encode(setterName));
   14.26                      expect(LPAREN);
   14.27                      final IdentNode argIdent = getIdent();
   14.28                      verifyStrictIdent(argIdent, "setter argument");
    15.1 --- a/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Thu Sep 26 10:43:59 2013 -0700
    15.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Thu Sep 26 17:23:22 2013 -0700
    15.3 @@ -90,6 +90,7 @@
    15.4      public static double parseInt(final Object self, final Object string, final Object rad) {
    15.5          final String str    = JSType.trimLeft(JSType.toString(string));
    15.6          final int    length = str.length();
    15.7 +        int          radix  = JSType.toInt32(rad);
    15.8  
    15.9          // empty string is not valid
   15.10          if (length == 0) {
   15.11 @@ -113,7 +114,6 @@
   15.12          }
   15.13  
   15.14          boolean stripPrefix = true;
   15.15 -        int     radix = JSType.toInt32(rad);
   15.16  
   15.17          if (radix != 0) {
   15.18              if (radix < 2 || radix > 36) {
   15.19 @@ -211,7 +211,7 @@
   15.20              switch (ch) {
   15.21              case '.':
   15.22                  // dot allowed only once
   15.23 -                if (dotSeen) {
   15.24 +                if (exponentOffset != -1 || dotSeen) {
   15.25                      break loop;
   15.26                  }
   15.27                  dotSeen = true;
    16.1 --- a/src/jdk/nashorn/internal/runtime/Source.java	Thu Sep 26 10:43:59 2013 -0700
    16.2 +++ b/src/jdk/nashorn/internal/runtime/Source.java	Thu Sep 26 17:23:22 2013 -0700
    16.3 @@ -169,7 +169,7 @@
    16.4  
    16.5          final Source src = (Source)obj;
    16.6          // Only compare content as a last resort measure
    16.7 -        return length == src.length && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
    16.8 +        return length == src.length && Objects.equals(url, src.url) && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
    16.9      }
   16.10  
   16.11      @Override
    17.1 --- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu Sep 26 10:43:59 2013 -0700
    17.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu Sep 26 17:23:22 2013 -0700
    17.3 @@ -57,6 +57,7 @@
    17.4  parser.error.regex.unsupported.flag=Unsupported RegExp flag: {0}
    17.5  parser.error.regex.repeated.flag=Repeated RegExp flag: {0}
    17.6  parser.error.regex.syntax={0}
    17.7 +parser.error.trailing.comma.in.json=Trailing comma is not allowed in JSON
    17.8  
    17.9  # strict mode error messages
   17.10  parser.error.strict.no.with="with" statement cannot be used in strict mode
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/script/basic/JDK-8024972.js	Thu Sep 26 17:23:22 2013 -0700
    18.3 @@ -0,0 +1,43 @@
    18.4 +/*
    18.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + * 
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + * 
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + * 
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + * 
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +/**
   18.28 + * JDK-8024972: for (LeftHandSideExpression in Expression) crashes the compiler
   18.29 + *
   18.30 + * @test
   18.31 + * @run
   18.32 + */
   18.33 +
   18.34 +var obj = {};
   18.35 +
   18.36 +var arr = [2, 45, -1, 445];
   18.37 +for (obj.x in arr) {
   18.38 +    print(obj.x + "->"+ arr[obj.x]);
   18.39 +}
   18.40 +
   18.41 +var abc = { foo: 'bar', hello: 'world' };
   18.42 +for (obj.x in abc) {
   18.43 +    print(obj.x + "->" + abc[obj.x]);
   18.44 +}
   18.45 +
   18.46 +for (obj.x in 0) {}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/script/basic/JDK-8024972.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    19.3 @@ -0,0 +1,6 @@
    19.4 +0->2
    19.5 +1->45
    19.6 +2->-1
    19.7 +3->445
    19.8 +foo->bar
    19.9 +hello->world
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/script/basic/JDK-8025048-2.js	Thu Sep 26 17:23:22 2013 -0700
    20.3 @@ -0,0 +1,36 @@
    20.4 +/*
    20.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + * 
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + * 
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + * 
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + * 
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +/**
   20.28 + * JDK-8025048: true as case label results in ClassCastException
   20.29 + *
   20.30 + * @test
   20.31 + * @run
   20.32 + */
   20.33 +
   20.34 +function func(x) {
   20.35 +    switch(x) { 
   20.36 +        case 8: break; case false:
   20.37 +    }
   20.38 +}
   20.39 +
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/script/basic/JDK-8025048.js	Thu Sep 26 17:23:22 2013 -0700
    21.3 @@ -0,0 +1,36 @@
    21.4 +/*
    21.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + * 
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + * 
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + * 
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + * 
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + */
   21.26 +
   21.27 +/**
   21.28 + * JDK-8025048: true as case label results in ClassCastException
   21.29 + *
   21.30 + * @test
   21.31 + * @run
   21.32 + */
   21.33 +
   21.34 +function func(x) {
   21.35 +    switch(x) { 
   21.36 +        case 8: break; case true:
   21.37 +    }
   21.38 +}
   21.39 +
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/script/basic/JDK-8025080.js	Thu Sep 26 17:23:22 2013 -0700
    22.3 @@ -0,0 +1,43 @@
    22.4 +/*
    22.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + * 
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + * 
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + * 
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + * 
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +/**
   22.28 + * JDK-8025080: Object literal getter, setter function with number format property name results in ClassFormatError
   22.29 + *
   22.30 + * @test
   22.31 + * @run
   22.32 + */
   22.33 +
   22.34 +var obj = {
   22.35 +    get 1e81() { print("1e81 getter"); },
   22.36 +    set 1e81(x) { print("1e81 setter"); },
   22.37 +    get 3.14e-2() { print("3.14e-2 getter");},
   22.38 +    set 3.14e-2(x) { print("3.14e-2 setter"); }
   22.39 +};
   22.40 +
   22.41 +obj[1e81];
   22.42 +obj[1e81] = 23;
   22.43 +
   22.44 +obj[3.14e-2];
   22.45 +obj[3.14e-2] = 42;
   22.46 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/script/basic/JDK-8025080.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    23.3 @@ -0,0 +1,4 @@
    23.4 +1e81 getter
    23.5 +1e81 setter
    23.6 +3.14e-2 getter
    23.7 +3.14e-2 setter
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/script/basic/JDK-8025090.js	Thu Sep 26 17:23:22 2013 -0700
    24.3 @@ -0,0 +1,35 @@
    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-8025090: 'while' statement with 'test' using var before being declared in body results in VerifyError
   24.29 + *
   24.30 + * @test
   24.31 + * @run
   24.32 + */
   24.33 +
   24.34 +// The following used to result in VerifyError
   24.35 +function f() {
   24.36 +   while (x += 2) { var x = 44 }
   24.37 +}
   24.38 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/script/basic/JDK-8025111.js	Thu Sep 26 17:23:22 2013 -0700
    25.3 @@ -0,0 +1,48 @@
    25.4 +/*
    25.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + * 
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + * 
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + * 
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + * 
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + */
   25.26 +
   25.27 +/**
   25.28 + * JDK-8025111: undefined or null 'with' expression in empty with block should throw TypeError
   25.29 + *
   25.30 + * @test
   25.31 + * @run
   25.32 + */
   25.33 +
   25.34 +function check(callback, arg) {
   25.35 +    try {
   25.36 +        callback(arg);
   25.37 +        fail("should have thrown TypeError: " + callback + " on " + arg);
   25.38 +    } catch (e) {
   25.39 +        if (! (e instanceof TypeError)) {
   25.40 +            fail("Expected TypeError, got " + e);
   25.41 +        }
   25.42 +    }
   25.43 +}
   25.44 +
   25.45 +function func(obj) {
   25.46 +    with(obj) {}
   25.47 +}
   25.48 +
   25.49 +check(func);
   25.50 +check(func, undefined);
   25.51 +check(func, null);
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/script/basic/JDK-8025147.js	Thu Sep 26 17:23:22 2013 -0700
    26.3 @@ -0,0 +1,41 @@
    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-8025147: Trailing comma is not allowed in JSONArray and JSONObject
   26.29 + *
   26.30 + * @test
   26.31 + * @run
   26.32 + */
   26.33 +
   26.34 +function check(str) {
   26.35 +    try {
   26.36 +        JSON.parse(str);
   26.37 +        fail("should have thrown SyntaxError for " + str);
   26.38 +    } catch (e) {
   26.39 +        print(e);
   26.40 +    }
   26.41 +}
   26.42 +
   26.43 +check("{ \"a\": 333, }");
   26.44 +check("[ 4343, ]");
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/script/basic/JDK-8025147.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    27.3 @@ -0,0 +1,6 @@
    27.4 +SyntaxError: Invalid JSON: <json>:1:12 Trailing comma is not allowed in JSON
    27.5 +{ "a": 333, }
    27.6 +            ^
    27.7 +SyntaxError: Invalid JSON: <json>:1:8 Trailing comma is not allowed in JSON
    27.8 +[ 4343, ]
    27.9 +        ^
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/script/basic/JDK-8025149.js	Thu Sep 26 17:23:22 2013 -0700
    28.3 @@ -0,0 +1,47 @@
    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-8025149: JSON.stringify does not handle 'space' argument as per the spec.
   28.29 + *
   28.30 + * @test
   28.31 + * @run
   28.32 + */
   28.33 +
   28.34 +print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(Infinity)));
   28.35 +
   28.36 +print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(-Infinity)));
   28.37 +
   28.38 +try {
   28.39 +    JSON.stringify({},[],
   28.40 +    (n = new Number(0), n.valueOf = function() { throw ("inside n.valueOf") }, n));
   28.41 +} catch (e) {
   28.42 +    print(e);
   28.43 +}
   28.44 +
   28.45 +try {
   28.46 +    JSON.stringify({},[],
   28.47 +    (s = new String(""), s.toString = function() { throw ("inside s.toString") }, s));
   28.48 +} catch (e) {
   28.49 +    print(e);
   28.50 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/script/basic/JDK-8025149.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    29.3 @@ -0,0 +1,9 @@
    29.4 +{
    29.5 +          "foo": 23,
    29.6 +          "bar": {
    29.7 +                    "x": 22
    29.8 +          }
    29.9 +}
   29.10 +{"foo":23,"bar":{"x":22}}
   29.11 +inside n.valueOf
   29.12 +inside s.toString
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/script/basic/JDK-8025163.js	Thu Sep 26 17:23:22 2013 -0700
    30.3 @@ -0,0 +1,39 @@
    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-8025163: Date methods should not return -0
   30.29 + *
   30.30 + * @test
   30.31 + * @run
   30.32 + */
   30.33 +
   30.34 +print(1 / (new Date(0, 0, 1)).getYear());
   30.35 +print(1 / (new Date(1969, 1, 2)).getDay());
   30.36 +print(1 / (new Date(1969, 0, 1)).getHours());
   30.37 +print(1 / (new Date(1969, 0, 1)).getHours());
   30.38 +print(1 / (new Date(1969, 0, 1)).getMinutes());
   30.39 +print(1 / (new Date(1969, 0, 1)).getSeconds());
   30.40 +print(1 / (new Date(1969, 0, 1)).getMilliseconds());
   30.41 +print(1 / (new Date(1969, 0, 1)).getMilliseconds());
   30.42 +
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/script/basic/JDK-8025163.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    31.3 @@ -0,0 +1,8 @@
    31.4 +Infinity
    31.5 +Infinity
    31.6 +Infinity
    31.7 +Infinity
    31.8 +Infinity
    31.9 +Infinity
   31.10 +Infinity
   31.11 +Infinity
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/script/basic/JDK-8025197.js	Thu Sep 26 17:23:22 2013 -0700
    32.3 @@ -0,0 +1,37 @@
    32.4 +/*
    32.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.7 + * 
    32.8 + * This code is free software; you can redistribute it and/or modify it
    32.9 + * under the terms of the GNU General Public License version 2 only, as
   32.10 + * published by the Free Software Foundation.
   32.11 + * 
   32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   32.15 + * version 2 for more details (a copy is included in the LICENSE file that
   32.16 + * accompanied this code).
   32.17 + * 
   32.18 + * You should have received a copy of the GNU General Public License version
   32.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   32.21 + * 
   32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   32.23 + * or visit www.oracle.com if you need additional information or have any
   32.24 + * questions.
   32.25 + */
   32.26 +
   32.27 +/**
   32.28 + * JDK-8025197: String replace method fails with regexp /$/gi
   32.29 + *
   32.30 + * @test
   32.31 + * @run
   32.32 + */
   32.33 +
   32.34 +print('dog'.replace(/$/gi, 's'));
   32.35 +print('dog'.replace(/(?:g)$/gi, 's'));
   32.36 +print('dog'.replace(/(?:a)$/gi, 's'));
   32.37 +print('dog'.replace(/(?!g)$/gi, 's'));
   32.38 +print('dog'.replace(/(?!a)$/gi, 's'));
   32.39 +print('dog'.replace(/g?$/gi, 's'));
   32.40 +print('dog'.replace(/.?$/gi, 's'));
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/script/basic/JDK-8025197.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    33.3 @@ -0,0 +1,7 @@
    33.4 +dogs
    33.5 +dos
    33.6 +dog
    33.7 +dogs
    33.8 +dogs
    33.9 +doss
   33.10 +doss
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/script/basic/JDK-8025312.js	Thu Sep 26 17:23:22 2013 -0700
    34.3 @@ -0,0 +1,35 @@
    34.4 +/*
    34.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 + * 
    34.8 + * This code is free software; you can redistribute it and/or modify it
    34.9 + * under the terms of the GNU General Public License version 2 only, as
   34.10 + * published by the Free Software Foundation.
   34.11 + * 
   34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.15 + * version 2 for more details (a copy is included in the LICENSE file that
   34.16 + * accompanied this code).
   34.17 + * 
   34.18 + * You should have received a copy of the GNU General Public License version
   34.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.21 + * 
   34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.23 + * or visit www.oracle.com if you need additional information or have any
   34.24 + * questions.
   34.25 + */
   34.26 +
   34.27 +/**
   34.28 + * JDK-8025312: parseInt should convert 'radix' argument to ToInt32 even if empty string is parsed
   34.29 + *
   34.30 + * @test
   34.31 + * @run
   34.32 + */
   34.33 +
   34.34 +parseInt("", {
   34.35 +    valueOf: function() {
   34.36 +        print("inside valueOf of 'radix'");
   34.37 +    }
   34.38 +});
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/test/script/basic/JDK-8025312.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    35.3 @@ -0,0 +1,1 @@
    35.4 +inside valueOf of 'radix'
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/script/basic/JDK-8025325.js	Thu Sep 26 17:23:22 2013 -0700
    36.3 @@ -0,0 +1,35 @@
    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-8025325: parseFloat does not handle '.' in exponent part
   36.29 + *
   36.30 + * @test
   36.31 + * @run
   36.32 + */
   36.33 +
   36.34 +print(parseFloat("2e2."));
   36.35 +print(parseFloat("2e2.3"));
   36.36 +print(parseFloat("2e2.fdgdf"));
   36.37 +print(parseFloat("2e2.   gdfgdf"));
   36.38 +print(parseFloat("2e2.  "));
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/script/basic/JDK-8025325.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    37.3 @@ -0,0 +1,5 @@
    37.4 +200
    37.5 +200
    37.6 +200
    37.7 +200
    37.8 +200
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/script/basic/JDK-8025434.js	Thu Sep 26 17:23:22 2013 -0700
    38.3 @@ -0,0 +1,66 @@
    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 + * JDK-8025434: RegExp lastIndex can exceed int range
   38.29 + *
   38.30 + * @test
   38.31 + * @run
   38.32 + */
   38.33 +
   38.34 +var r = /a/g;
   38.35 +
   38.36 +r.lastIndex = 0x100000000;
   38.37 +if (r.test("a")) {
   38.38 +    throw new Error("Expected no match");
   38.39 +}
   38.40 +
   38.41 +r.lastIndex = 0x100000000000000;
   38.42 +if (r.test("a")) {
   38.43 +    throw new Error("Expected no match");
   38.44 +}
   38.45 +
   38.46 +r.lastIndex = -0x100000000;
   38.47 +if (r.test("a")) {
   38.48 +    throw new Error("Expected match");
   38.49 +}
   38.50 +
   38.51 +r.lastIndex = -0x100000000000000;
   38.52 +if (r.test("a")) {
   38.53 +    throw new Error("Expected no match");
   38.54 +}
   38.55 +
   38.56 +r.lastIndex = 1;
   38.57 +if (r.test("a")) {
   38.58 +    throw new Error("Expected no match");
   38.59 +}
   38.60 +
   38.61 +r.lastIndex = -1;
   38.62 +if (r.test("a")) {
   38.63 +    throw new Error("Expected no match");
   38.64 +}
   38.65 +
   38.66 +r.lastIndex = 0;
   38.67 +if (!r.test("a")) {
   38.68 +    throw new Error("Expected match");
   38.69 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/script/basic/JDK-8025486.js	Thu Sep 26 17:23:22 2013 -0700
    39.3 @@ -0,0 +1,55 @@
    39.4 +/*
    39.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + * 
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.
   39.11 + * 
   39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 + * version 2 for more details (a copy is included in the LICENSE file that
   39.16 + * accompanied this code).
   39.17 + * 
   39.18 + * You should have received a copy of the GNU General Public License version
   39.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 + * 
   39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 + * or visit www.oracle.com if you need additional information or have any
   39.24 + * questions.
   39.25 + */
   39.26 +
   39.27 +/**
   39.28 + * JDK-8025486: RegExp constructor arguments are not evaluated in right order
   39.29 + *
   39.30 + * @test
   39.31 + * @run
   39.32 + */
   39.33 +
   39.34 +new RegExp({
   39.35 +    toString: function() {
   39.36 +        print("source");
   39.37 +        return "a";
   39.38 +    }
   39.39 +}, {
   39.40 +    toString: function() {
   39.41 +        print("flags");
   39.42 +        return "g";
   39.43 +    }
   39.44 +});
   39.45 +
   39.46 +try {
   39.47 +    new RegExp(/asdf/, {
   39.48 +        toString: function() {
   39.49 +            fail("toString should not be called");
   39.50 +        }
   39.51 +    });
   39.52 +    fail("expected TypeError");
   39.53 +} catch (e) {
   39.54 +    if (!(e instanceof TypeError)) {
   39.55 +        fail("expected TypeError");
   39.56 +    }
   39.57 +    print(e);
   39.58 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/script/basic/JDK-8025486.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    40.3 @@ -0,0 +1,3 @@
    40.4 +source
    40.5 +flags
    40.6 +TypeError: Cannot supply flags when constructing one RegExp from another
    41.1 --- a/test/script/basic/parser/objectLitExpr.js.EXPECTED	Thu Sep 26 10:43:59 2013 -0700
    41.2 +++ b/test/script/basic/parser/objectLitExpr.js.EXPECTED	Thu Sep 26 17:23:22 2013 -0700
    41.3 @@ -126,10 +126,7 @@
    41.4                              },
    41.5                              "value": {
    41.6                                  "type": "FunctionExpression",
    41.7 -                                "id": {
    41.8 -                                    "type": "Identifier",
    41.9 -                                    "name": "get x"
   41.10 -                                },
   41.11 +                                "id": null,
   41.12                                  "params": [],
   41.13                                  "defaults": [],
   41.14                                  "rest": null,
   41.15 @@ -157,10 +154,7 @@
   41.16                              },
   41.17                              "value": {
   41.18                                  "type": "FunctionExpression",
   41.19 -                                "id": {
   41.20 -                                    "type": "Identifier",
   41.21 -                                    "name": "get y"
   41.22 -                                },
   41.23 +                                "id": null,
   41.24                                  "params": [],
   41.25                                  "defaults": [],
   41.26                                  "rest": null,
    42.1 --- a/test/script/trusted/JDK-8008305.js	Thu Sep 26 10:43:59 2013 -0700
    42.2 +++ b/test/script/trusted/JDK-8008305.js	Thu Sep 26 17:23:22 2013 -0700
    42.3 @@ -54,6 +54,6 @@
    42.4      fail("Expected SecurityException from script!");
    42.5  } catch (e) {
    42.6      if (! (e instanceof SecurityException)) {
    42.7 -        faile("Expected SecurityException, but got " + e);
    42.8 +        fail("Expected SecurityException, but got " + e);
    42.9      }
   42.10  }
    43.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Sep 26 10:43:59 2013 -0700
    43.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Sep 26 17:23:22 2013 -0700
    43.3 @@ -37,10 +37,12 @@
    43.4  import java.util.concurrent.Callable;
    43.5  import javax.script.Compilable;
    43.6  import javax.script.CompiledScript;
    43.7 +import javax.script.ScriptContext;
    43.8  import javax.script.ScriptEngine;
    43.9  import javax.script.ScriptEngineFactory;
   43.10  import javax.script.ScriptEngineManager;
   43.11  import javax.script.ScriptException;
   43.12 +import javax.script.SimpleScriptContext;
   43.13  import org.testng.annotations.Test;
   43.14  
   43.15  /**
   43.16 @@ -231,6 +233,17 @@
   43.17      }
   43.18  
   43.19      @Test
   43.20 +    public void compileAndEvalInDiffContextTest() throws ScriptException {
   43.21 +        final ScriptEngineManager m = new ScriptEngineManager();
   43.22 +        final ScriptEngine engine = m.getEngineByName("js");
   43.23 +        final Compilable compilable = (Compilable) engine;
   43.24 +        final CompiledScript compiledScript = compilable.compile("foo");
   43.25 +        final ScriptContext ctxt = new SimpleScriptContext();
   43.26 +        ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
   43.27 +        assertEquals(compiledScript.eval(ctxt), "hello");
   43.28 +    }
   43.29 +
   43.30 +    @Test
   43.31      public void accessGlobalTest() {
   43.32          final ScriptEngineManager m = new ScriptEngineManager();
   43.33          final ScriptEngine e = m.getEngineByName("nashorn");

mercurial