changeset 1731:a33c509181ce jdk8u66-b34

Merge
author asaha
date Fri, 13 Nov 2015 15:38:44 -0800
parents 95050a90c845 (diff) 5bbb4858350b (current diff)
children dbdadc4378e8
files .hgtags
diffstat 442 files changed, 27651 insertions(+), 13405 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Nov 11 20:47:37 2015 -0800
+++ b/.hgtags	Fri Nov 13 15:38:44 2015 -0800
@@ -416,3 +416,70 @@
 009644f58d73263eec2582a84a1e9b63975c5387 jdk8u51-b32
 eac4b87f86dde817023a07dcb701dc5d986b705f jdk8u51-b33
 bd915e4b7a4a8ddffec5c54829bde3cf9579f9d0 jdk8u51-b34
+6ec61d2494283fbaca6df227f1a5b45487dc1ca7 jdk8u60-b00
+af290f203369ecf8e67b89c4a3a8df0bf535230e jdk8u60-b01
+39e0c14d45c3fee93a29993f1415b3393d03483f jdk8u60-b02
+323f54e277dfcea814a32fa4b6b36876db18181f jdk8u60-b03
+b0b90d6c5265f45cee7fde968e15f8f272b5b24b jdk8u60-b04
+6f44964fbab316de02d58436be846b5e92813426 jdk8u60-b05
+4b7613f08fd3a6e738bc048d280630756d3593cd jdk8u60-b06
+80966e5cc384fb8c67938c0e05e2b990116d3f4c jdk8u60-b07
+e024db176497a3655f7c9d1d86571df74707ba62 jdk8u60-b08
+1f73439a45bf9cdb73ece75b2c935980657b10d4 jdk8u60-b09
+7aaa64363e1a632ab113b459c46a8ce0c32e4738 jdk8u60-b10
+f6f2d944a863be7d22ca7eac904b6d967abb6b39 jdk8u60-b11
+d03eb34e4b84296f4ce98a78f6c75c07218a678d jdk8u60-b12
+3628ab9fdbc0c58b9d97bc3cd5f3f7680d9785ff jdk8u60-b13
+24e7c53c5716bb52a3f33614b47b72cc134823c9 jdk8u60-b14
+78fcf7f0eac8ffa474518b315bdf84a1dbd6e76d jdk8u60-b15
+bf44ade6c2c2e697ccbc1e57f3eac870908614e6 jdk8u60-b16
+ff7052ce0f6b655d726cd0f77e9a5f8313361889 jdk8u60-b17
+0b5c0f02a0b79ae0aa97520d65e5b520af8f1b2a jdk8u60-b18
+3780124b6dbb100c2c4af2759b8f0e12a8bf1c4c jdk8u60-b19
+46a3d8588ad227dc390d84dfc0f89b9291395a36 jdk8u60-b20
+7475a2bd3c012f7dfd0532a344eb7efca56ac6e6 jdk8u60-b21
+9ed906919b5d92067edcdd966a3f413fca0f70ab jdk8u60-b22
+23165e806566f01cdc56421ea82c7e74a6fd85d5 jdk8u60-b23
+68107693248469f7b4fdcc35c53e4206a0d55087 jdk8u60-b24
+371f3f83f773ec97491d994bbcce834f0a2cca74 jdk8u60-b25
+58791cd01bc9aa973d8845ce63403b90d357b5ac jdk8u60-b26
+72a33aed7dccf570f4e05ea1121522a88ac190b2 jdk8u60-b27
+fc0045a6aaeee45f5d2505a2f7a07ec6cd6f56bc jdk8u60-b31
+2d161c9248ca7bf5779cf33c45768e26c1161eb4 jdk8u60-b32
+afc8b472a5f3d54734be29aa9c4f617191fc9246 jdk8u52-b06
+8cd2d9bea168694db5f090b30ba5973e1656385b jdk8u52-b07
+afc8b472a5f3d54734be29aa9c4f617191fc9246 jdk8u65-b00
+c9f36bcde982f8713c2767d1c882da85b1b9fb44 jdk8u65-b01
+398c895674d0f27711a52d442c1d1b471101f44b jdk8u65-b02
+db15ac4eff75c9b2b6535789d73f7fc8f84be70e jdk8u65-b03
+121f4183eff871ae9d3311781d5fbaf0e7dbe6e4 jdk8u65-b04
+3198826d0a96fa74c9e464de2fa2a2a45a08b9be jdk8u65-b05
+0709198e5515f5caa965f0b0603e367db3ed1160 jdk8u65-b06
+7f88899c78f96be2c0550b4e5a0576a98f45a96e jdk8u65-b07
+ed247f904308f124558a332f86dc9ee70698accb jdk8u65-b08
+45e0dbcb50591fa7dcb787dae7a4ab32ff1c1c1a jdk8u65-b09
+be2856f5c3e4ced88259759201fbb3d5c0e4db94 jdk8u65-b10
+6a809be8e2057b290871707aeaadf79679afbf90 jdk8u65-b11
+b9bc29802d24cf3e82f0b435c82d567e27373aa6 jdk8u65-b12
+5ad3832ac8d01656ec28d03f81042f2672360219 jdk8u65-b13
+1448629ede5316a04b15f66667a8cfc4bd1b5009 jdk8u65-b14
+7077dc107e60e994b599b103e6611c77fc37c0ea jdk8u65-b15
+0353cddbbf4e911a54cb6a8546f7df395a349e8b jdk8u65-b16
+df0218bcade38354fd70ae980aaa33088b8016dd jdk8u65-b17
+9ed906919b5d92067edcdd966a3f413fca0f70ab jdk8u66-b00
+c0f0613d1b1119afc9446eb187a2a7b5f534f050 jdk8u66-b01
+16220ab541af04fe79d9143fb62854f7acf46eca jdk8u66-b02
+3cd98cdbca8be17acd1eb3aed902303188b7e5f8 jdk8u66-b07
+a1436c975c531200de5133990886c1bac851a29f jdk8u66-b08
+d9eb8e3f1388b43f0e9c5ba2fdd91bf69295360a jdk8u66-b09
+998d6b5b976ba8db410b9f8cccf1cc927280b542 jdk8u66-b10
+46022f24d619e56ff41a432a5211bd9560d3e237 jdk8u66-b11
+2bdd08a9cc8ca594723e412cc9479f4f7351959f jdk8u66-b12
+cd562acc692c5ea4d5e3ea5164757f1b7e00e274 jdk8u66-b13
+165ed6982da8dc7dc5562d5b4a8f07dba55c7448 jdk8u66-b14
+9a3b86240761e602469c41bd720c7791997253e6 jdk8u66-b15
+c0ce5c308f5e2c42ac0d2e7367355663312a3128 jdk8u66-b16
+3cc16ff2735c6818b68fdf161ddbcc89a5b4db1a jdk8u66-b17
+3e08bc604b2166b251833e522892ffcfd22b4b88 jdk8u66-b31
+52d1be12498e2390cf0581040ce6f4ab7258b498 jdk8u66-b32
+3629a9cd6627e0b9e1a0735be214b20fd2f9a743 jdk8u66-b33
--- a/README	Wed Nov 11 20:47:37 2015 -0800
+++ b/README	Fri Nov 13 15:38:44 2015 -0800
@@ -72,14 +72,11 @@
 - Running tests
 
 Nashorn tests are TestNG based. Running tests requires downloading the
-TestNG library and placing its jar file into the lib subdirectory:
+TestNG library and placing its jar file into the test/lib subdirectory. This is
+done automatically when executing the "ant externals" command to get external
+test suites (see below).
 
-    # download and install TestNG
-    wget http://testng.org/testng-x.y.z.zip
-    unzip testng-x.y.z.zip
-    cp testng-x.y.z/testng-x.y.z.jar test/lib/testng.jar
-    
-After that, you can run the tests using:
+Once TestNG is properly installed, you can run the tests using:
     cd make
     ant clean test
     
--- a/THIRD_PARTY_README	Wed Nov 11 20:47:37 2015 -0800
+++ b/THIRD_PARTY_README	Fri Nov 13 15:38:44 2015 -0800
@@ -1140,37 +1140,6 @@
 
 --------------------------------------------------------------------------------
 
-%% This notice is provided with respect to JSON, which may be included 
-with JRE 8 & JDK 8.
-
---- begin of LICENSE ---
-
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
---- end of LICENSE ---
-
--------------------------------------------------------------------------------
-
 %% This notice is provided with respect to Kerberos functionality, which 
 which may be included with JRE 8, JDK 8, and OpenJDK 8.
 
@@ -1250,7 +1219,7 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libpng 1.6.16, which may be
+%% This notice is provided with respect to libpng 1.6.16, which may be 
 included with JRE 8, JDK 8, and OpenJDK 8.
 
 --- begin of LICENSE ---
@@ -1370,7 +1339,7 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libungif 4.1.3, which may be 
+%% This notice is provided with respect to GIFLIB 5.1.1 & libungif 4.1.3, which may be 
 included with JRE 8, JDK 8, and OpenJDK 8.
 
 --- begin of LICENSE ---
@@ -1399,13 +1368,13 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to Little CMS 2.5, which may be 
+%% This notice is provided with respect to Little CMS 2.7, which may be 
 included with JRE 8, JDK 8, and OpenJDK 8.
 
 --- begin of LICENSE ---
 
 Little CMS
-Copyright (c) 1998-2011 Marti Maria Saguer
+Copyright (c) 1998-2015 Marti Maria Saguer
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -152,6 +152,7 @@
         }
 
         if (constructor != null) {
+            initPrototype(mi);
             final int arity = constructor.getArity();
             if (arity != MemberInfo.DEFAULT_ARITY) {
                 mi.loadThis();
@@ -193,6 +194,7 @@
     }
 
     private void initFunctionFields(final MethodGenerator mi) {
+        assert memberCount > 0;
         for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
             if (!memInfo.isConstructorFunction()) {
                 continue;
@@ -204,37 +206,39 @@
     }
 
     private void initDataFields(final MethodGenerator mi) {
-         for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
-            if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
-                continue;
-            }
-            final Object value = memInfo.getValue();
-            if (value != null) {
-                mi.loadThis();
-                mi.loadLiteral(value);
-                mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
-            } else if (!memInfo.getInitClass().isEmpty()) {
-                final String clazz = memInfo.getInitClass();
-                mi.loadThis();
-                mi.newObject(clazz);
-                mi.dup();
-                mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
-                mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
-            }
+        assert memberCount > 0;
+        for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
+           if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
+               continue;
+           }
+           final Object value = memInfo.getValue();
+           if (value != null) {
+               mi.loadThis();
+               mi.loadLiteral(value);
+               mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+           } else if (!memInfo.getInitClass().isEmpty()) {
+               final String clazz = memInfo.getInitClass();
+               mi.loadThis();
+               mi.newObject(clazz);
+               mi.dup();
+               mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
+               mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+           }
         }
+    }
 
-        if (constructor != null) {
-            mi.loadThis();
-            final String protoName = scriptClassInfo.getPrototypeClassName();
-            mi.newObject(protoName);
-            mi.dup();
-            mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
-            mi.dup();
-            mi.loadThis();
-            mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
-                    PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
-            mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
-        }
+    private void initPrototype(final MethodGenerator mi) {
+        assert constructor != null;
+        mi.loadThis();
+        final String protoName = scriptClassInfo.getPrototypeClassName();
+        mi.newObject(protoName);
+        mi.dup();
+        mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
+        mi.dup();
+        mi.loadThis();
+        mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
+                PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
+        mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
     }
 
     /**
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java	Fri Nov 13 15:38:44 2015 -0800
@@ -134,7 +134,7 @@
                 String simpleName = inFile.getName();
                 simpleName = simpleName.substring(0, simpleName.indexOf(".class"));
 
-                if (sci.getPrototypeMemberCount() > 0) {
+                if (sci.isPrototypeNeeded()) {
                     // generate prototype class
                     final PrototypeGenerator protGen = new PrototypeGenerator(sci);
                     buf = protGen.getClassBytes();
@@ -146,7 +146,7 @@
                     }
                 }
 
-                if (sci.getConstructorMemberCount() > 0 || sci.getConstructor() != null) {
+                if (sci.isConstructorNeeded()) {
                     // generate constructor class
                     final ConstructorGenerator consGen = new ConstructorGenerator(sci);
                     buf = consGen.getClassBytes();
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -124,8 +124,6 @@
         if (memberCount > 0) {
             // call "super(map$)"
             mi.getStatic(className, PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC);
-            // make sure we use duplicated PropertyMap so that original map
-            // stays intact and so can be used for many global.
             mi.invokeSpecial(PROTOTYPEOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC);
             // initialize Function type fields
             initFunctionFields(mi);
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java	Fri Nov 13 15:38:44 2015 -0800
@@ -126,10 +126,42 @@
         return Collections.unmodifiableList(res);
     }
 
+    boolean isConstructorNeeded() {
+        // Constructor class generation is needed if we one or
+        // more constructor properties are defined or @Constructor
+        // is defined in the class.
+        for (final MemberInfo memInfo : members) {
+            if (memInfo.getKind() == Kind.CONSTRUCTOR ||
+                memInfo.getWhere() == Where.CONSTRUCTOR) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    boolean isPrototypeNeeded() {
+        // Prototype class generation is needed if we have atleast one
+        // prototype property or @Constructor defined in the class.
+        for (final MemberInfo memInfo : members) {
+            if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     int getPrototypeMemberCount() {
         int count = 0;
         for (final MemberInfo memInfo : members) {
-            if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+            switch (memInfo.getKind()) {
+                case SETTER:
+                case SPECIALIZED_FUNCTION:
+                    // SETTER was counted when GETTER was encountered.
+                    // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+                    continue;
+            }
+
+            if (memInfo.getWhere() == Where.PROTOTYPE) {
                 count++;
             }
         }
@@ -139,6 +171,16 @@
     int getConstructorMemberCount() {
         int count = 0;
         for (final MemberInfo memInfo : members) {
+            switch (memInfo.getKind()) {
+                case CONSTRUCTOR:
+                case SETTER:
+                case SPECIALIZED_FUNCTION:
+                    // SETTER was counted when GETTER was encountered.
+                    // Constructor and constructor SpecializedFunctions
+                    // are not added as members and so not counted.
+                    continue;
+            }
+
             if (memInfo.getWhere() == Where.CONSTRUCTOR) {
                 count++;
             }
@@ -149,6 +191,14 @@
     int getInstancePropertyCount() {
         int count = 0;
         for (final MemberInfo memInfo : members) {
+            switch (memInfo.getKind()) {
+                case SETTER:
+                case SPECIALIZED_FUNCTION:
+                    // SETTER was counted when GETTER was encountered.
+                    // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+                    continue;
+            }
+
             if (memInfo.getWhere() == Where.INSTANCE) {
                 count++;
             }
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java	Fri Nov 13 15:38:44 2015 -0800
@@ -288,9 +288,7 @@
                                         where = Where.PROTOTYPE;
                                         break;
                                     case SPECIALIZED_FUNCTION:
-                                        if (isSpecializedConstructor) {
-                                            where = Where.CONSTRUCTOR;
-                                        }
+                                        where = isSpecializedConstructor? Where.CONSTRUCTOR : Where.PROTOTYPE;
                                         //fallthru
                                     default:
                                         break;
--- a/docs/DEVELOPER_README	Wed Nov 11 20:47:37 2015 -0800
+++ b/docs/DEVELOPER_README	Fri Nov 13 15:38:44 2015 -0800
@@ -63,16 +63,19 @@
 See the description of the codegen logger below.
 
 
-SYSTEM PROPERTY: -Dnashorn.fields.objects
+SYSTEM PROPERTY: -Dnashorn.fields.objects, -Dnashorn.fields.dual
 
-When this property is true, Nashorn will only use object fields for
-AccessorProperties. This means that primitive values must be boxed
-when stored in a field, which is significantly slower than using
-primitive fields.
+When the nashorn.fields.objects property is true, Nashorn will always
+use object fields for AccessorProperties, requiring boxing for all
+primitive property values. When nashorn.fields.dual is set, Nashorn
+will always use dual long/object fields, which allows primitives to be
+stored without boxing. When neither system property is set, Nashorn
+chooses a setting depending on the optimistic types setting (dual
+fields when optimistic types are enabled, object-only fields otherwise).
 
-By default, Nashorn uses dual object and long fields. Ints are
-represented as the 32 low bits of the long fields. Doubles are
-represented as the doubleToLongBits of their value. This way a
+With dual fields, Nashorn uses long fields to store primitive values.
+Ints are represented as the 32 low bits of the long fields. Doubles
+are represented as the doubleToLongBits of their value. This way a
 single field can be used for all primitive types. Packing and
 unpacking doubles to their bit representation is intrinsified by
 the JVM and extremely fast.
--- a/make/build.xml	Wed Nov 11 20:47:37 2015 -0800
+++ b/make/build.xml	Fri Nov 13 15:38:44 2015 -0800
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
- Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -189,7 +189,7 @@
     <mkdir dir="${fxshell.classes.dir}"/>
     <javac srcdir="${fxshell.dir}"
            destdir="${fxshell.classes.dir}"
-           classpath="${dist.jar}:${javac.classpath}"
+           classpath="${dist.jar}${path.separator}${javac.classpath}"
            debug="${javac.debug}"
            encoding="${javac.encoding}"
            includeantruntime="false">
@@ -210,7 +210,7 @@
   </target>
 
   <target name="javadoc" depends="jar">
-    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" 
+    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html" 
         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true">
       <classpath>
@@ -282,12 +282,12 @@
        <fileset dir="${test.src.dir}/META-INF/services/"/>
     </copy>
 
-    <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/resources">
-       <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/resources"/>
+    <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/test/resources">
+       <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/test/resources"/>
     </copy>
 
-    <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/resources">
-       <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/resources"/>
+    <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/test/resources">
+       <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/test/resources"/>
     </copy>
 
     <!-- tests that check nashorn internals and internal API -->
@@ -388,19 +388,19 @@
   </target>
 
   <target name="check-testng" unless="testng.available">
-    <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/>
+    <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under ${test.lib} directory."/>
   </target>
 
   <!-- only to be invoked as dependency of "test" target -->
   <target name="-test-classes-all" depends="jar" unless="test.class">
       <fileset id="test.classes" dir="${build.test.classes.dir}">
-          <include name="**/api/javaaccess/*Test.class"/>
-          <include name="**/api/scripting/*Test.class"/>
-          <include name="**/codegen/*Test.class"/>
-          <include name="**/parser/*Test.class"/>
-          <include name="**/runtime/*Test.class"/>
-          <include name="**/runtime/regexp/*Test.class"/>
-          <include name="**/runtime/regexp/joni/*Test.class"/>
+          <include name="**/api/javaaccess/test/*Test.class"/>
+          <include name="**/api/scripting/test/*Test.class"/>
+          <include name="**/codegen/test/*Test.class"/>
+          <include name="**/parser/test/*Test.class"/>
+          <include name="**/runtime/test/*Test.class"/>
+          <include name="**/runtime/regexp/test/*Test.class"/>
+          <include name="**/runtime/regexp/joni/test/*Test.class"/>
           <include name="**/framework/*Test.class"/>
      </fileset>
   </target>
@@ -460,7 +460,7 @@
     </testng>
   </target>
 
-  <target name="test" depends="test-pessimistic, test-optimistic"/>
+  <target name="test" depends="get-testng, javadoc, test-pessimistic, test-optimistic"/>
 
   <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <echo message="Running test suite in OPTIMISTIC mode..."/>
@@ -490,7 +490,7 @@
     <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy testng.jar, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar under test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
   </target>
 
-  <target name="testjfx" depends="jar, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
+  <target name="testjfx" depends="jar, get-testng, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
     </fileset>
@@ -518,7 +518,7 @@
     </testng>
   </target>
 
-  <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="testmarkdown" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
     </fileset>
@@ -537,7 +537,7 @@
     </testng>
   </target>
 
-  <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test262" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
     </fileset>
@@ -561,7 +561,7 @@
 
   <target name="test262parallel" depends="test262-parallel"/>
 
-  <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test262-parallel" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <!-- use just build.test.classes.dir to avoid referring to TestNG -->
     <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
       <jvmarg line="${ext.class.path}"/>
@@ -580,7 +580,7 @@
 
   <target name="testparallel" depends="test-parallel"/>
 
-  <target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test-parallel" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
       <!-- use just build.test.classes.dir to avoid referring to TestNG -->
       <java classname="${parallel.test.runner}" dir="${basedir}"
         failonerror="true"
@@ -685,7 +685,7 @@
   </target>
 
   <!-- get all external test scripts -->
-  <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider">
+  <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider, get-testng">
     <!-- make external test dir -->
     <mkdir dir="${test.external.dir}"/>
 
@@ -710,8 +710,8 @@
 
     <!-- showdown -->
     <mkdir dir="${test.external.dir}/showdown"/>
-    <get src="https://raw.github.com/coreyti/showdown/master/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
-    <get src="https://raw.github.com/coreyti/showdown/master/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
+    <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
+    <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
 
   </target>
 
@@ -721,12 +721,20 @@
   <!-- run all perf tests -->
   <target name="perf" depends="externals, update-externals, sunspider, octane"/>
 
-  <!-- run all tests -->
-  <target name="exit-if-no-testng" depends="init, check-testng" unless="${testng.available}">
-     <fail message="Exiting.."/>
+  <!-- download and install testng.jar -->
+  <target name="get-testng" depends="prepare" unless="testng.available">
+    <get src="http://testng.org/testng-6.8.zip" dest="${test.lib}" skipexisting="true" ignoreerrors="true"/>
+    <unzip src="${test.lib}${file.separator}testng-6.8.zip" dest="${test.lib}">
+      <patternset>
+        <include name="testng-6.8/testng-6.8.jar"/>
+      </patternset>
+    </unzip>
+    <move file="${test.lib}${file.separator}testng-6.8${file.separator}testng-6.8.jar" tofile="${test.lib}${file.separator}testng.jar"/>
+    <delete dir="${test.lib}${file.separator}testng-6.8"/>
   </target>
 
-  <target name="alltests" depends="exit-if-no-testng, externals, update-externals, test, test262parallel, perf"/>
+  <!-- run all tests -->
+  <target name="alltests" depends="get-testng, externals, update-externals, test, test262parallel, testmarkdown, perf"/>
 
   <import file="build-benchmark.xml"/>
 
--- a/make/project.properties	Wed Nov 11 20:47:37 2015 -0800
+++ b/make/project.properties	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 # 
 # This code is free software; you can redistribute it and/or modify it
@@ -77,8 +77,11 @@
 # configuration for java flight recorder
 run.test.jvmargs.jfr=-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=${build.dir},stackdepth=128
 
+# test library location
+test.lib=${basedir}${file.separator}test${file.separator}lib
+
 # jars refererred
-file.reference.testng.jar=test/lib/testng.jar
+file.reference.testng.jar=${test.lib}${file.separator}testng.jar
 
 # Set testng verbose level
 # From TestNG docs: "the verbosity level (0 to 10 where 10 is most detailed) 
@@ -105,8 +108,8 @@
 javac.classpath=\
     ${build.classes.dir}
 javac.test.classpath=\
-    ${build.classes.dir}:\
-    ${build.test.classes.dir}:\
+    ${build.classes.dir}${path.separator}\
+    ${build.test.classes.dir}${path.separator}\
     ${file.reference.testng.jar}
 
 meta.inf.dir=${src.dir}/META-INF
@@ -237,9 +240,9 @@
     -fx \
     ${test.script.dir}${file.separator}jfx.js
 
-file.reference.jemmyfx.jar=test${file.separator}lib${file.separator}JemmyFX.jar
-file.reference.jemmycore.jar=test${file.separator}lib${file.separator}JemmyCore.jar
-file.reference.jemmyawtinput.jar=test${file.separator}lib${file.separator}JemmyAWTInput.jar
+file.reference.jemmyfx.jar=${test.lib}${file.separator}JemmyFX.jar
+file.reference.jemmycore.jar=${test.lib}${file.separator}JemmyCore.jar
+file.reference.jemmyawtinput.jar=${test.lib}${file.separator}JemmyAWTInput.jar
 file.reference.jfxrt.jar=${java.home}${file.separator}lib${file.separator}ext${file.separator}jfxrt.jar
 testjfx.run.test.classpath=\
     ${file.reference.jemmyfx.jar}${path.separator}\
@@ -253,8 +256,8 @@
 testjfx-test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${testjfx.run.test.classpath}
 
 run.test.classpath=\
-    ${file.reference.testng.jar}:\
-    ${nashorn.internal.tests.jar}:\
+    ${file.reference.testng.jar}${path.separator}\
+    ${nashorn.internal.tests.jar}${path.separator}\
     ${nashorn.api.tests.jar}
 
 src.dir=src
@@ -330,6 +333,8 @@
 
 # VM options for script tests with @fork option
 test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath}
+# VM options for no-security script tests with @fork option - same as above but without jvmsecurityargs
+test-sys-prop-no-security.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${run.test.classpath}
 
 # path of rhino.jar for benchmarks
 rhino.dir=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/autoimports.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,163 @@
+# autoimports script requires -scripting mode
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * It is tedious to import Java classes used in a script. Sometimes it is easier
+ * use simple names of java classes and have a script auto import Java classes. 
+ * You can load this script at the start of an interactive jjs session or at the
+ * start of your script. This script defines a __noSuchProperty__ hook to auto 
+ * import Java classes as needed and when they are referred to for the first time
+ * in your script. You can also call the "autoimports" function to print script 
+ * statements that you need to use in your script, i.e., have the function generate
+ * a script to import Java classes used by your script so far. After running your
+ * script, you can call autoimports to get the exact Java imports you need and replace
+ * the autoimports load with the generated import statements (to avoid costly init of
+ * the autoimports script).
+ */
+
+(function() {
+    var ArrayList = Java.type("java.util.ArrayList");
+    var HashMap = Java.type("java.util.HashMap");
+    var JarFile = Java.type("java.util.jar.JarFile");
+    var File = Java.type("java.io.File");
+    var Files = Java.type("java.nio.file.Files");
+    var FileSystems = Java.type("java.nio.file.FileSystems");
+    var System = Java.type("java.lang.System");
+    var URI = Java.type("java.net.URI");
+
+    // initialize a class to package map by iterating all
+    // classes available in the system by walking through "jrt fs"
+
+    var clsToPkg = new HashMap();
+
+    // locate rt.jar from sun.boot.class.path
+    function findRtJar() {
+        var paths = System.getProperty("sun.boot.class.path").split(File.pathSeparator);
+        for each (var p in paths) {
+            if (p.endsWith("rt.jar") && new File(p).exists()) {
+                return p;
+            }
+        }
+    }
+
+
+    function addToClsToPkg(c, p) {
+        if (clsToPkg.containsKey(c)) {
+            var val = clsToPkg.get(c);
+            if (val instanceof ArrayList) {
+                val.add(p);
+            } else {
+                var al = new ArrayList();
+                al.add(val);
+                al.add(p);
+                clsToPkg.put(c, al);
+            }
+        } else {
+            clsToPkg.put(c, p);
+        }
+    }
+
+    // handle collision and allow user to choose package
+    function getPkgOfCls(c) {
+        var val = clsToPkg.get(c);
+        if (val instanceof ArrayList) {
+            var count = 1;
+            print("Multiple matches for " + c + ", choose package:");
+            for each (var v in val) {
+                print(count + ". " + v);
+                count++;
+            }
+            var choice = parseInt(readLine());
+            if (isNaN(choice) || choice < 1 || choice > val.size()) {
+                print("invalid choice: " + choice);
+                return undefined;
+            }
+            return val.get(choice - 1);
+        } else {
+            return val;
+        }
+    }
+
+    var rtJar = findRtJar();
+    var stream = new JarFile(rtJar).stream();
+    try {
+        stream.forEach(
+            function(entry) {
+                var str = entry.name;
+                if (str.endsWith(".class")) {
+                    if (str.startsWith("java") ||
+                        str.startsWith("javax") ||
+                        str.startsWith("org")) {
+                        var lastIdx = str.lastIndexOf('/');
+                        if (lastIdx != -1) {
+                            var pkg = str.substring(0, lastIdx).replaceAll('/', '.');
+                            var cls = str.substring(lastIdx + 1, str.lastIndexOf(".class"));
+                            addToClsToPkg(cls, pkg);
+                        }
+                    }
+                }
+            });
+    } finally {
+        stream.close();
+    }
+
+    var imports = new ArrayList();
+    var global = this;
+    var oldNoSuchProp = global.__noSuchProperty__;
+    this.__noSuchProperty__ = function(name) {
+        'use strict';
+
+        if (clsToPkg.containsKey(name)) {
+            var pkg = getPkgOfCls(name);
+            if (pkg) {
+                var clsName = pkg + "." + name;
+                imports.add("var " + name + " = Java.type('" + clsName + "');");
+                return global[name] = Java.type(clsName);
+            }
+        } else if (typeof oldNoSuchProp == 'function') {
+            return oldNoSuchProp.call(this, name);
+        }
+
+        if (typeof this == 'undefined') {
+            throw new ReferenceError(name);
+        } else {
+            return undefined;
+        }
+    }
+
+    this.autoimports = function() {
+        for each (var im in imports) {
+            print(im);
+        }
+    }
+})();
--- a/samples/browser_dom.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/samples/browser_dom.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,4 +1,4 @@
-#// Usage: jjs -fx browser.js
+#// Usage: jjs -fx browser_dom.js
 
 /*
  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 if (!$OPTIONS._fx) {
-    print("Usage: jjs -fx browser.js");
+    print("Usage: jjs -fx browser_dom.js");
     exit(1);
 }
 
@@ -40,7 +40,6 @@
 var ChangeListener = Java.type("javafx.beans.value.ChangeListener");
 var Scene     = Java.type("javafx.scene.Scene");
 var WebView   = Java.type("javafx.scene.web.WebView");
-var EventListener = Java.type("org.w3c.dom.events.EventListener");
 
 // JavaFX start method
 function start(stage) {
@@ -74,10 +73,10 @@
                var btn = document.createElement("button");
                var n = 0;
                // attach a button handler - nashorn function!
-               btn.onclick = new EventListener(function() {
+               btn.onclick = function() {
                    n++; print("You clicked " + n + " time(s)");
                    print("you clicked OK " + wv.engine.executeScript("okCount"));
-               });
+               };
                // attach text to button
                var t = document.createTextNode("Click Me!"); 
                btn.appendChild(t);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/console.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Simple Web Console-like support for Nashorn. In addition to
+ * Web console object methods, this console add methods of
+ * java.io.Console as well. Note:not all web console methods are 
+ * implemented but useful subset is implemented.
+ *
+ * See also: https://developer.mozilla.org/en/docs/Web/API/console
+ */
+
+
+if (typeof console == 'undefined') {
+
+(function() {
+    var LocalDateTime = Java.type("java.time.LocalDateTime");
+    var System = Java.type("java.lang.System");
+    var jconsole = System.console();
+
+    // add a new global variable called "console"
+    this.console = {
+    };
+
+    function addConsoleMethods() {
+        // expose methods of java.io.Console as an extension
+        var placeholder = "-*-";
+        // put a placeholder for each name from java.lang.Object
+        var objMethods = Object.bindProperties({}, new java.lang.Object());
+        for (var m in objMethods) {
+            console[m] = placeholder;
+        }
+
+        // bind only the methods of java.io.Console
+        // This bind will skip java.lang.Object methods as console
+        // has properties of same name.
+        Object.bindProperties(console, jconsole);
+
+        // Now, delete java.lang.Object methods
+        for (var m in console) {
+            if (console[m] == placeholder) {
+                delete console[m];
+            }
+        }
+    }
+
+    addConsoleMethods();
+
+    function consoleLog(type, msg) {
+        // print type of message, then time.
+        jconsole.format("%s [%s] ", type, LocalDateTime.now().toString());
+        if (typeof msg == 'string') {
+            jconsole.format(msg + "\n", Array.prototype.slice.call(arguments, 2));
+        } else {
+            // simple space separated values and newline at the end
+            var arr = Array.prototype.slice.call(arguments, 1);
+            jconsole.format("%s\n", arr.join(" "));
+        }
+    }
+
+    console.toString = function() "[object Console]";
+
+    // web console functions
+
+    console.assert = function(expr) {
+        if (! expr) {
+            arguments[0] = "Assertion Failed:"; 
+            consoleLog.apply(console, arguments);
+            // now, stack trace at the end
+            jconsole.format("%s\n", new Error().stack);
+        }
+    };
+
+    // dummy clear to avoid error!
+    console.clear = function() {};
+
+    var counter = {
+        get: function(label) {
+            if (! this[label]) {
+                return this[label] = 1;
+            } else {
+                return ++this[label];
+            }
+        }
+    };
+   
+    // counter 
+    console.count = function(label) {
+        label = label? String(label) : "<no label>";
+        jconsole.format("%s: %d\n",label, counter.get(label).intValue());
+    }
+
+    // logging
+    console.error = consoleLog.bind(jconsole, "ERROR");
+    console.info = consoleLog.bind(jconsole, "INFO");
+    console.log = console.info;
+    console.debug = console.log;
+    console.warn = consoleLog.bind(jconsole, "WARNING");
+
+    // print stack trace
+    console.trace = function() {
+        jconsole.format("%s\n", new Error().stack);
+    };
+})();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/consoleuse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+load(__DIR__ + "console.js");
+
+console.log("consoleuse.js started!");
+
+function func() {
+    console.count("func");
+}
+
+
+func();
+func();
+func();
+func();
+
+// java.io.Console method
+console.readPassword("passworld please: ");
+console.error("Big error: %s!", "you revealed your password!");
+console.warn("You've done this %d times", 345);
+console.assert(arguments.length != 0, "no arguments!");
+
+// java.io.Console methods
+var str = console.readLine("enter something: ");
+console.printf("you entered: %s\n", str);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/dateconversion.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Converting between #javascript Date and #java8 LocalDateTime with #nashorn
+
+// JavaScript Date with current time
+var d = new Date();
+print(d);
+ 
+// Java 8 java.time classes used
+var Instant = java.time.Instant;
+var LocalDateTime = java.time.LocalDateTime;
+var ZoneId = java.time.ZoneId;
+ 
+// Date.prototype.getTime
+
+// getTime() method returns the numeric value corresponding to the time
+// for the specified date according to universal time. The value returned
+// by the getTime() method is the number of milliseconds since 1 January 1970 00:00:00 UTC.
+// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
+ 
+// Java Instant.ofEpochMilli to convert time in milliseconds to Instant object
+// https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html#ofEpochMilli-long-
+ 
+var instant = Instant.ofEpochMilli(d.getTime());
+ 
+// Instant to LocalDateTime using LocalDateTime.ofInstant
+// https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html#ofInstant-java.time.Instant-java.time.ZoneId-
+ 
+var ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+print(ldt);
+ 
+// converting a LocalDateTime to JavaScript Date
+// convert LocalDateTime to Instant first
+// https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html#atZone-java.time.ZoneId-
+ 
+var instant = ldt.atZone(ZoneId.systemDefault()).toInstant();
+ 
+// instant to to epoch milliseconds
+// https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html#toEpochMilli--
+// and then to JavaScript Date from time in milliseconds
+// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date
+
+var d1 = new Date(instant.toEpochMilli());
+print(d1); 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/exec.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,50 @@
+# exec script requires -scripting mode
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// The $EXEC builtin function can be used to run external commands:
+$EXEC("ls")
+$EXEC("ls -la")
+
+// It can also be given a string to use as stdin:
+$EXEC("cat", "Hello, world!")
+
+// Additional arguments can be passed after the stdin argument, as an array of
+// strings, or a sequence of varargs:
+$EXEC("ls", "" /* no stdin */, "-l", "-a")
+$EXEC("ls", "" /* no stdin */, ["-l", "-a"])
+
+// Output of running external commands is returned from $EXEC:
+print($EXEC("ls"))
+
+// apply on $EXEC
+print($EXEC.apply(this, ["ls"]));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/getclassnpe.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,122 @@
+#// Usage: jjs getclassnpe.js -- <directory>
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * java.lang.Object.getClass() is sometimes used to do null check. This
+ * obfuscating Object.getClass() check relies on non-related intrinsic
+ * performance, which is potentially not available everywhere.
+ * See also http://cr.openjdk.java.net/~shade/scratch/NullChecks.java
+ * This nashorn script checks for such uses in your .java files in the
+ * given directory (recursively).
+ */
+
+if (arguments.length == 0) {
+    print("Usage: jjs getclassnpe.js -- <directory>");
+    exit(1);
+}
+
+// Java types used
+var File = Java.type("java.io.File");
+var Files = Java.type("java.nio.file.Files");
+var StringArray = Java.type("java.lang.String[]");
+var ToolProvider = Java.type("javax.tools.ToolProvider");
+var MethodInvocationTree = Java.type("com.sun.source.tree.MethodInvocationTree");
+var TreeScanner = Java.type("com.sun.source.util.TreeScanner");
+
+// parse a specific .java file to check if it uses
+// Object.getClass() for null check.
+function checkGetClassNPE() {
+    // get the system compiler tool
+    var compiler = ToolProvider.systemJavaCompiler;
+    // get standard file manager
+    var fileMgr = compiler.getStandardFileManager(null, null, null);
+    // Using Java.to convert script array (arguments) to a Java String[]
+    var compUnits = fileMgr.getJavaFileObjects(
+        Java.to(arguments, StringArray));
+    // create a new compilation task
+    var task = compiler.getTask(null, fileMgr, null, null, null, compUnits);
+    // subclass SimpleTreeVisitor - to check for obj.getClass(); statements
+    var GetClassNPEChecker = Java.extend(TreeScanner);
+
+    var visitor = new GetClassNPEChecker() {
+        lineMap: null,
+        sourceFile: null,
+
+        // save compilation unit details for reporting
+        visitCompilationUnit: function(node, p) {
+           this.sourceFile = node.sourceFile;
+           this.lineMap = node.lineMap;
+           return Java.super(visitor).visitCompilationUnit(node, p);
+        },
+
+        // look for "foo.getClass();" expression statements
+        visitExpressionStatement: function(node, p) {
+            var expr = node.expression;
+            if (expr instanceof MethodInvocationTree) {
+                var name = String(expr.methodSelect.identifier);
+
+                // will match any "getClass" call with zero arguments!
+                if (name == "getClass" && expr.arguments.size() == 0) {
+                    print(this.sourceFile.getName()
+                     + " @ "
+                     + this.lineMap.getLineNumber(node.pos)
+                     + ":"
+                     + this.lineMap.getColumnNumber(node.pos));
+
+                    print("\t", node);
+                }
+            }
+        }
+    }
+
+    for each (var cu in task.parse()) {
+        cu.accept(visitor, null);
+    }
+}
+
+// for each ".java" file in the directory (recursively)
+function main(dir) {
+    Files.walk(dir.toPath()).
+      forEach(function(p) {
+          var name = p.toFile().absolutePath;
+          if (name.endsWith(".java")) {
+              try {
+                  checkGetClassNPE(p.toFile().getAbsolutePath());
+              } catch (e) {
+                  print(e);
+              }
+          }
+      });
+}
+
+main(new File(arguments[0]));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/javahelp.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// script helpers to print meta info on Java instances and classes
+
+// print instance methods info on a Java object or static methods info of a Java class
+function methods(jobj) {
+    if (! Java.isJavaObject(jobj)) {
+        throw new TypeError("not a Java object");
+    }
+
+    var isStatic = Java.isType(jobj);
+    var obj = Object.bindProperties({}, jobj);
+    for each (var i in obj) {
+        if (Java.isJavaMethod(i)) {
+            var str = String(i);
+            var idx = str.indexOf(' ');
+            var overloaded = str.substring(0, idx).endsWith("OverloadedDynamicMethod");
+            var lastIdx = isStatic? str.lastIndexOf('] on') : str.lastIndexOf(']');
+            print(str.substring(idx + 1, lastIdx) + (overloaded? "*" : ""))
+        }
+    }
+}
+
+// print instance field names of a Java object or static field names of a Java class
+function fields(jobj) {
+    if (! Java.isJavaObject(jobj)) {
+        throw new TypeError("not a Java object");
+    }
+
+    var obj = Object.bindProperties({}, jobj);
+    for (var i in obj) {
+        if (! Java.isJavaMethod(obj[i])) {
+            print(i);
+        }
+    }
+}
+
+undefined;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/jd.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,94 @@
+#// Usage: jjs -cp <asmtools.jar> jd.js -- <classname> [jdis|jdec]
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// javap-like disassembler/decoder tool that disassembles/decodes 
+// java classes but with OpenJDK AsmTools disassembler/decoder syntax.
+// You need to build asmtool.jar from OpenJDK codetools project
+// specify it with -cp option.
+
+// See also https://wiki.openjdk.java.net/display/CodeTools/AsmTools
+
+function usage() {
+    print("Usage: jjs -cp <asmtools.jar> jd.js -- <classname> [jdis|jdec]");
+    exit(1);
+}
+
+if (arguments.length == 0) {
+    usage();
+}
+
+// argument handling
+// convert to internal class name
+var className = arguments[0].replaceAll('\\.', '/');
+var tool;
+if (arguments.length > 1) {
+    tool = arguments[1];
+    switch (tool) {
+        case 'jdis':
+        case 'jdec':
+            break;
+        default:
+            usage();
+    }
+} else {
+    tool = "jdis"; // default tool
+}
+
+// Java classes used
+var AsmTools = Java.type("org.openjdk.asmtools.Main");
+var Files = Java.type("java.nio.file.Files");
+var StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
+
+// retrive input stream for .class bytes
+var cl = AsmTools.class.classLoader;
+var res = cl.getResource(className + ".class");
+
+if (res) {
+    var is = res.openStream();
+    var tmpPath;
+    try {
+        // copy the content of the .class to a temp file
+        tmpPath = Files.createTempFile("asmtools-", ".class");
+        // mark as delete-on-exit
+        tmpPath.toFile().deleteOnExit();
+        Files.copy(is, tmpPath, [ StandardCopyOption.REPLACE_EXISTING ]);
+    } finally {
+        is.close();
+    } 
+
+    // invoke asmtools Main
+    AsmTools.main([ tool, tmpPath.toString() ]);
+} else {
+    print("no such class: " + arguments[0]);
+    exit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/secondssince.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,43 @@
+# usage: jjs secondssince.js
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Number of seconds elapsed since the specified Instance #nashorn #javascript #java
+// Input date and time in ISO 8601 format
+// Example: 2001-01-01T00:00:00Z for 1 Jan 2001, 0 GMT
+
+var Instant = java.time.Instant;
+var ChronoUnit = java.time.temporal.ChronoUnit;
+print("Enter date time:");
+var sec = Instant.parse(readLine()).
+      until(Instant.now(), ChronoUnit.SECONDS);
+print(sec);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/showenv.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,82 @@
+#// Usage: jjs -fx showenv.js
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+if (!$OPTIONS._fx) {
+    print("Usage: jjs -fx showenv.js");
+    exit(1);
+}
+
+// This script displays environment entries as a HTML table.
+// Demonstrates heredoc to generate HTML content and display
+// using JavaFX WebView.
+
+// JavaFX classes used
+var Scene     = Java.type("javafx.scene.Scene");
+var WebView   = Java.type("javafx.scene.web.WebView");
+
+// JavaFX start method
+function start(stage) {
+    start.title = "Your Environment";
+    var wv = new WebView();
+    var envrows = "";
+    for (var i in $ENV) {
+        envrows += <<TBL
+<tr>
+<td>
+${i}
+</td>
+<td>
+${$ENV[i]}
+</td>
+</tr>
+TBL
+    }
+
+    wv.engine.loadContent(<<EOF
+<html>
+<head>
+<title>
+Your Environment
+</title>
+</head>
+<body>
+<h1>Your Environment</h1>
+<table border="1">
+${envrows}
+</table>
+</body>
+</html>
+EOF, "text/html");
+    stage.scene = new Scene(wv, 750, 500);
+    stage.show();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/showsysprops.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,84 @@
+#// Usage: jjs -fx showsysprops.js
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+if (!$OPTIONS._fx) {
+    print("Usage: jjs -fx showsysprops.js");
+    exit(1);
+}
+
+// This script displays System properties as a HTML table.
+// Demonstrates heredoc to generate HTML content and display
+// using JavaFX WebView.
+
+// JavaFX, Java classes used
+var Scene     = Java.type("javafx.scene.Scene");
+var System    = Java.type("java.lang.System");
+var WebView   = Java.type("javafx.scene.web.WebView");
+
+// JavaFX start method
+function start(stage) {
+    start.title = "Your System Properties";
+    var wv = new WebView();
+    var sysproprows = "";
+    var sysprops = System.properties;
+    for (var i in sysprops) {
+        sysproprows += <<TBL
+<tr>
+<td>
+${i}
+</td>
+<td>
+${sysprops[i]}
+</td>
+</tr>
+TBL
+    }
+
+    wv.engine.loadContent(<<EOF
+<html>
+<head>
+<title>
+Your System Properties
+</title>
+</head>
+<body>
+<h1>Your System Properties</h1>
+<table border="1">
+${sysproprows}
+</table>
+</body>
+</html>
+EOF, "text/html");
+    stage.scene = new Scene(wv, 750, 500);
+    stage.show();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/time_color.fx	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,89 @@
+#// Usage: jjs -fx time_color.js [-- true/false]
+
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// A simple javafx program that changes background color
+// of scene based on current time value (once per sec).
+// inspired by http://whatcolourisit.scn9a.org/
+
+if (!$OPTIONS._fx) {
+    print("Usage: jjs -fx time_color.js");
+    print("       jjs -fx time_color.js -- true");
+    exit(1);
+}
+
+// JavaFX classes used
+var Color = Java.type("javafx.scene.paint.Color");
+var Group = Java.type("javafx.scene.Group");
+var Label = Java.type("javafx.scene.control.Label");
+var Platform = Java.type("javafx.application.Platform");
+var Scene = Java.type("javafx.scene.Scene");
+var Timer = Java.type("java.util.Timer");
+
+// execute function periodically once per given time in millisec
+function setInterval(func, ms) {
+    // New timer, run as daemon so the application can quit
+    var timer = new Timer("setInterval", true);
+    timer.schedule(function() Platform.runLater(func), ms, ms);	
+    return timer;
+}
+
+// do you want to flip hour/min/sec for RGB?
+var flip = arguments.length > 0? "true".equals(arguments[0]) : false;
+
+// JavaFX start method
+function start(stage) {
+    start.title = "Time Color";
+    var root = new Group();
+    var label = new Label("time");
+    label.textFill = Color.WHITE;
+    root.children.add(label); 
+    stage.scene = new Scene(root, 700, 500);
+
+    setInterval(function() {
+        var d = new Date();
+        var hours = d.getHours();
+	var mins = d.getMinutes();
+	var secs = d.getSeconds();
+
+        if (hours < 10) hours = "0" + hours;
+        if (mins < 10) mins = "0" + mins;
+        if (secs < 10) secs = "0" + secs;
+
+	var hex = flip?
+            "#" + secs + mins + hours : "#" + hours + mins + secs;
+        label.text = "Color: " + hex;
+        stage.scene.fill = Color.web(hex);
+    }, 1000);
+
+    stage.show();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/undefined_call.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Nashorn extension: __noSuchMethod__
+// See also: https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions#Nashornextensions-__noSuchMethod__
+ 
+Object.prototype.__noSuchMethod__ = function(name) {
+    print(name + " function is not defined in " + this);
+ 
+    // Nashorn extension: stack property
+    // gives stack trace as a string
+    print(new Error().stack);
+}
+ 
+function func(obj) {
+    obj.foo();
+}
+ 
+func({});
+func(this); 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/unzip.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Simple unzip tool using #nashorn and #java
+ * zip fs file system interface.
+ */
+ 
+if (arguments.length == 0) {
+    print("Usage: jjs zipfs.js -- <.zip/.jar file> [out dir]");
+    exit(1);
+}
+ 
+var File = Java.type("java.io.File");
+// output directory where zip is extracted
+var outDir = arguments[1];
+if (!outDir) {
+    outDir = ".";
+} else {
+    if (! new File(outDir).isDirectory()) {
+        print(outDir + " directory does not exist!");
+        exit(1);
+    }
+}
+ 
+var Files = Java.type("java.nio.file.Files");
+var FileSystems = Java.type("java.nio.file.FileSystems");
+var Paths = Java.type("java.nio.file.Paths");
+ 
+var zipfile = Paths.get(arguments[0])
+var fs = FileSystems.newFileSystem(zipfile, null);
+var root = fs.rootDirectories[0];
+ 
+// walk root and handle each Path
+Files.walk(root).forEach(
+    function(p) {
+        var outPath = outDir +
+            p.toString().replace('/', File.separatorChar);
+        print(outPath);
+        if (Files.isDirectory(p)) {
+            // create directories as needed
+            new File(outPath).mkdirs();
+        } else {
+            // copy a 'file' resource
+            Files.copy(p, new File(outPath).toPath());
+        }
+    }
+);
+ 
+// done
+fs.close(); 
--- a/src/jdk/internal/dynalink/DynamicLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/DynamicLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -88,6 +88,7 @@
 import java.lang.invoke.MethodType;
 import java.lang.invoke.MutableCallSite;
 import java.util.List;
+import java.util.Objects;
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.LinkRequest;
@@ -98,10 +99,12 @@
 import jdk.internal.dynalink.support.RuntimeContextLinkRequestImpl;
 
 /**
- * The linker for {@link RelinkableCallSite} objects. Users of it (scripting frameworks and language runtimes) have to
- * create a linker using the {@link DynamicLinkerFactory} and invoke its link method from the invokedynamic bootstrap
- * methods to set the target of all the call sites in the code they generate. Usual usage would be to create one class
- * per language runtime to contain one linker instance as:
+ * The linker for {@link RelinkableCallSite} objects. Users of it (scripting
+ * frameworks and language runtimes) have to create a linker using the
+ * {@link DynamicLinkerFactory} and invoke its link method from the invokedynamic
+ * bootstrap methods to set the target of all the call sites in the code they
+ * generate. Usual usage would be to create one class per language runtime to
+ * contain one linker instance as:
  *
  * <pre>
  * class MyLanguageRuntime {
@@ -122,19 +125,27 @@
  *
  * Note how there are three components you will need to provide here:
  * <ul>
- * <li>You're expected to provide a {@link GuardingDynamicLinker} for your own language. If your runtime doesn't
- * have its own language and/or object model (i.e. it's a generic scripting shell), you don't need to implement a
- * dynamic linker; you would simply not invoke the {@code setPrioritizedLinker} method on the factory, or even better,
- * simply use {@link DefaultBootstrapper}.</li>
- * <li>The performance of the programs can depend on your choice of the class to represent call sites. The above
- * example used {@link MonomorphicCallSite}, but you might want to use {@link ChainedCallSite} instead. You'll need to
- * experiment and decide what fits your language runtime the best. You can subclass either of these or roll your own if
- * you need to.</li>
- * <li>You also need to provide {@link CallSiteDescriptor}s to your call sites. They are immutable objects that contain
- * all the information about the call site: the class performing the lookups, the name of the method being invoked, and
- * the method signature. The library has a default {@link CallSiteDescriptorFactory} for descriptors that you can use,
- * or you can create your own descriptor classes, especially if you need to add further information (values passed in
+ *
+ * <li>You're expected to provide a {@link GuardingDynamicLinker} for your own
+ * language. If your runtime doesn't have its own language and/or object model
+ * (i.e., it's a generic scripting shell), you don't need to implement a dynamic
+ * linker; you would simply not invoke the {@code setPrioritizedLinker} method
+ * on the factory, or even better, simply use {@link DefaultBootstrapper}.</li>
+ *
+ * <li>The performance of the programs can depend on your choice of the class to
+ * represent call sites. The above example used {@link MonomorphicCallSite}, but
+ * you might want to use {@link ChainedCallSite} instead. You'll need to
+ * experiment and decide what fits your language runtime the best. You can
+ * subclass either of these or roll your own if you need to.</li>
+ *
+ * <li>You also need to provide {@link CallSiteDescriptor}s to your call sites.
+ * They are immutable objects that contain all the information about the call
+ * site: the class performing the lookups, the name of the method being invoked,
+ * and the method signature. The library has a default {@link CallSiteDescriptorFactory}
+ * for descriptors that you can use, or you can create your own descriptor
+ * classes, especially if you need to add further information (values passed in
  * additional parameters to the bootstrap method) to them.</li>
+ *
  * </ul>
  *
  * @author Attila Szegedi
@@ -175,11 +186,15 @@
     }
 
     /**
-     * Links an invokedynamic call site. It will install a method handle into the call site that invokes the relinking
-     * mechanism of this linker. Next time the call site is invoked, it will be linked for the actual arguments it was
-     * invoked with.
+     * Links an invokedynamic call site. It will install a method handle into
+     * the call site that invokes the relinking mechanism of this linker. Next
+     * time the call site is invoked, it will be linked for the actual arguments
+     * it was invoked with.
      *
+     * @param <T> the particular subclass of {@link RelinkableCallSite} for
+     *        which to create a link.
      * @param callSite the call site to link.
+     *
      * @return the callSite, for easy call chaining.
      */
     public <T extends RelinkableCallSite> T link(final T callSite) {
@@ -188,10 +203,13 @@
     }
 
     /**
-     * Returns the object representing the lower level linker services of this class that are normally exposed to
-     * individual language-specific linkers. While as a user of this class you normally only care about the
-     * {@link #link(RelinkableCallSite)} method, in certain circumstances you might want to use the lower level services
-     * directly; either to lookup specific method handles, to access the type converters, and so on.
+     * Returns the object representing the lower level linker services of this
+     * class that are normally exposed to individual language-specific linkers.
+     * While as a user of this class you normally only care about the
+     * {@link #link(RelinkableCallSite)} method, in certain circumstances you
+     * might want to use the lower level services directly; either to lookup
+     * specific method handles, to access the type converters, and so on.
+     *
      * @return the object representing the linker services of this class.
      */
     public LinkerServices getLinkerServices() {
@@ -217,7 +235,9 @@
      *
      * @param callSite the call site itself
      * @param arguments arguments to the invocation
+     *
      * @return return the method handle for the invocation
+     *
      * @throws Exception rethrows any exception thrown by the linkers
      */
     @SuppressWarnings("unused")
@@ -252,7 +272,7 @@
         // Make sure we filter the invocation before linking it into the call site. This is typically used to match the
         // return type of the invocation to the call site.
         guardedInvocation = prelinkFilter.filter(guardedInvocation, linkRequest, linkerServices);
-        guardedInvocation.getClass(); // null pointer check
+        Objects.requireNonNull(guardedInvocation);
 
         int newRelinkCount = relinkCount;
         // Note that the short-circuited "&&" evaluation below ensures we'll increment the relinkCount until
@@ -271,11 +291,15 @@
     }
 
     /**
-     * Returns a stack trace element describing the location of the call site currently being linked on the current
-     * thread. The operation internally creates a Throwable object and inspects its stack trace, so it's potentially
-     * expensive. The recommended usage for it is in writing diagnostics code.
-     * @return a stack trace element describing the location of the call site currently being linked, or null if it is
-     * not invoked while a call site is being linked.
+     * Returns a stack trace element describing the location of the call site
+     * currently being linked on the current thread. The operation internally
+     * creates a Throwable object and inspects its stack trace, so it's
+     * potentially expensive. The recommended usage for it is in writing
+     * diagnostics code.
+     *
+     * @return a stack trace element describing the location of the call site
+     *         currently being linked, or null if it is not invoked while a call
+     *         site is being linked.
      */
     public static StackTraceElement getLinkedCallSiteLocation() {
         final StackTraceElement[] trace = new Throwable().getStackTrace();
@@ -289,8 +313,10 @@
     }
 
     /**
-     * Deprecated because of not precise name.
+     * Deprecated because of imprecise name.
+     *
      * @deprecated Use {@link #getLinkedCallSiteLocation()} instead.
+     *
      * @return see non-deprecated method
      */
     @Deprecated
@@ -299,20 +325,26 @@
     }
 
     /**
-     * Returns true if the frame represents {@code MethodHandleNatives.linkCallSite()}, the frame immediately on top of
-     * the call site frame when the call site is being linked for the first time.
+     * Returns {@code true} if the frame represents {@code MethodHandleNatives.linkCallSite()},
+     * the frame immediately on top of the call site frame when the call site is
+     * being linked for the first time.
+     *
      * @param frame the frame
-     * @return true if this frame represents {@code MethodHandleNatives.linkCallSite()}
+     *
+     * @return {@code true} if this frame represents {@code MethodHandleNatives.linkCallSite()}.
      */
     private static boolean isInitialLinkFrame(final StackTraceElement frame) {
         return testFrame(frame, INITIAL_LINK_METHOD_NAME, INITIAL_LINK_CLASS_NAME);
     }
 
     /**
-     * Returns true if the frame represents {@code DynamicLinker.relink()}, the frame immediately on top of the call
-     * site frame when the call site is being relinked (linked for second and subsequent times).
+     * Returns {@code true} if the frame represents {@code DynamicLinker.relink()},
+     * the frame immediately on top of the call site frame when the call site is
+     * being relinked (linked for second and subsequent times).
+     *
      * @param frame the frame
-     * @return true if this frame represents {@code DynamicLinker.relink()}
+     *
+     * @return {@code true} if this frame represents {@code DynamicLinker.relink()}.
      */
     private static boolean isRelinkFrame(final StackTraceElement frame) {
         return testFrame(frame, RELINK_METHOD_NAME, CLASS_NAME);
--- a/src/jdk/internal/dynalink/DynamicLinkerFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/DynamicLinkerFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -97,6 +97,8 @@
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.GuardingTypeConverterFactory;
 import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
 import jdk.internal.dynalink.linker.MethodTypeConversionStrategy;
 import jdk.internal.dynalink.support.AutoDiscovery;
 import jdk.internal.dynalink.support.BottomGuardingDynamicLinker;
@@ -132,6 +134,7 @@
     private int unstableRelinkThreshold = DEFAULT_UNSTABLE_RELINK_THRESHOLD;
     private GuardedInvocationFilter prelinkFilter;
     private MethodTypeConversionStrategy autoConversionStrategy;
+    private MethodHandleTransformer internalObjectsFilter;
 
     /**
      * Sets the class loader for automatic discovery of available linkers. If not set explicitly, then the thread
@@ -284,6 +287,15 @@
     }
 
     /**
+     * Sets a method handle transformer that is supposed to act as the implementation of this linker factory's linkers'
+     * services {@link LinkerServices#filterInternalObjects(java.lang.invoke.MethodHandle)} method.
+     * @param internalObjectsFilter a method handle transformer filtering out internal objects, or null.
+     */
+    public void setInternalObjectsFilter(final MethodHandleTransformer internalObjectsFilter) {
+        this.internalObjectsFilter = internalObjectsFilter;
+    }
+
+    /**
      * Creates a new dynamic linker consisting of all the prioritized, autodiscovered, and fallback linkers as well as
      * the pre-link filter.
      *
@@ -350,8 +362,8 @@
         }
 
         return new DynamicLinker(new LinkerServicesImpl(new TypeConverterFactory(typeConverters,
-                autoConversionStrategy), composite), prelinkFilter, runtimeContextArgCount, syncOnRelink,
-                unstableRelinkThreshold);
+                autoConversionStrategy), composite, internalObjectsFilter), prelinkFilter, runtimeContextArgCount,
+                syncOnRelink, unstableRelinkThreshold);
     }
 
     private static ClassLoader getThreadContextClassLoader() {
--- a/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -570,7 +570,7 @@
     private static final MethodHandle CONSTANT_NULL_DROP_ANNOTATED_METHOD = MethodHandles.dropArguments(
             MethodHandles.constant(Object.class, null), 0, AnnotatedDynamicMethod.class);
     private static final MethodHandle GET_ANNOTATED_METHOD = privateLookup.findVirtual(AnnotatedDynamicMethod.class,
-            "getTarget", MethodType.methodType(MethodHandle.class, MethodHandles.Lookup.class));
+            "getTarget", MethodType.methodType(MethodHandle.class, MethodHandles.Lookup.class, LinkerServices.class));
     private static final MethodHandle GETTER_INVOKER = MethodHandles.invoker(MethodType.methodType(Object.class, Object.class));
 
     private GuardedInvocationComponent getPropertyGetter(final CallSiteDescriptor callSiteDescriptor,
@@ -593,7 +593,7 @@
                 final MethodHandle typedGetter = linkerServices.asType(getPropertyGetterHandle, type.changeReturnType(
                         AnnotatedDynamicMethod.class));
                 final MethodHandle callSiteBoundMethodGetter = MethodHandles.insertArguments(
-                        GET_ANNOTATED_METHOD, 1, callSiteDescriptor.getLookup());
+                        GET_ANNOTATED_METHOD, 1, callSiteDescriptor.getLookup(), linkerServices);
                 final MethodHandle callSiteBoundInvoker = MethodHandles.filterArguments(GETTER_INVOKER, 0,
                         callSiteBoundMethodGetter);
                 // Object(AnnotatedDynamicMethod, Object)->Object(AnnotatedDynamicMethod, T0)
@@ -873,8 +873,8 @@
         }
 
         @SuppressWarnings("unused")
-        MethodHandle getTarget(final MethodHandles.Lookup lookup) {
-            final MethodHandle inv = method.getTarget(lookup);
+        MethodHandle getTarget(final MethodHandles.Lookup lookup, final LinkerServices linkerServices) {
+            final MethodHandle inv = linkerServices.filterInternalObjects(method.getTarget(lookup));
             assert inv != null;
             return inv;
         }
--- a/src/jdk/internal/dynalink/beans/BeanLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/beans/BeanLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -165,6 +165,10 @@
     private static MethodHandle LIST_GUARD = Guards.getInstanceOfGuard(List.class);
     private static MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class);
 
+    private enum CollectionType {
+        ARRAY, LIST, MAP
+    };
+
     private GuardedInvocationComponent getElementGetter(final CallSiteDescriptor callSiteDescriptor,
             final LinkerServices linkerServices, final List<String> operations) throws Exception {
         final MethodType callSiteType = callSiteDescriptor.getMethodType();
@@ -178,27 +182,27 @@
         // Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers
         // in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices.
         final GuardedInvocationComponent gic;
-        final boolean isMap;
+        final CollectionType collectionType;
         if(declaredType.isArray()) {
-            gic = new GuardedInvocationComponent(MethodHandles.arrayElementGetter(declaredType));
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(MethodHandles.arrayElementGetter(declaredType), linkerServices);
+            collectionType = CollectionType.ARRAY;
         } else if(List.class.isAssignableFrom(declaredType)) {
-            gic = new GuardedInvocationComponent(GET_LIST_ELEMENT);
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(GET_LIST_ELEMENT, linkerServices);
+            collectionType = CollectionType.LIST;
         } else if(Map.class.isAssignableFrom(declaredType)) {
-            gic = new GuardedInvocationComponent(GET_MAP_ELEMENT);
-            isMap = true;
+            gic = createInternalFilteredGuardedInvocationComponent(GET_MAP_ELEMENT, linkerServices);
+            collectionType = CollectionType.MAP;
         } else if(clazz.isArray()) {
-            gic = getClassGuardedInvocationComponent(MethodHandles.arrayElementGetter(clazz), callSiteType);
-            isMap = false;
+            gic = getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(MethodHandles.arrayElementGetter(clazz)), callSiteType);
+            collectionType = CollectionType.ARRAY;
         } else if(List.class.isAssignableFrom(clazz)) {
-            gic = new GuardedInvocationComponent(GET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class,
-                    ValidationType.INSTANCE_OF);
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(GET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class, ValidationType.INSTANCE_OF,
+                    linkerServices);
+            collectionType = CollectionType.LIST;
         } else if(Map.class.isAssignableFrom(clazz)) {
-            gic = new GuardedInvocationComponent(GET_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class,
-                    ValidationType.INSTANCE_OF);
-            isMap = true;
+            gic = createInternalFilteredGuardedInvocationComponent(GET_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class, ValidationType.INSTANCE_OF,
+                    linkerServices);
+            collectionType = CollectionType.MAP;
         } else {
             // Can't retrieve elements for objects that are neither arrays, nor list, nor maps.
             return nextComponent;
@@ -208,7 +212,7 @@
         final String fixedKey = getFixedKey(callSiteDescriptor);
         // Convert the key to a number if we're working with a list or array
         final Object typedFixedKey;
-        if(!isMap && fixedKey != null) {
+        if(collectionType != CollectionType.MAP && fixedKey != null) {
             typedFixedKey = convertKeyToInteger(fixedKey, linkerServices);
             if(typedFixedKey == null) {
                 // key is not numeric, it can never succeed
@@ -227,15 +231,21 @@
         }
 
         final MethodHandle checkGuard;
-        if(invocation == GET_LIST_ELEMENT) {
+        switch(collectionType) {
+        case LIST:
             checkGuard = convertArgToInt(RANGE_CHECK_LIST, linkerServices, callSiteDescriptor);
-        } else if(invocation == GET_MAP_ELEMENT) {
+            break;
+        case MAP:
             // TODO: A more complex solution could be devised for maps, one where we do a get() first, and fold it
             // into a GWT that tests if it returned null, and if it did, do another GWT with containsKey()
             // that returns constant null (on true), or falls back to next component (on false)
-            checkGuard = CONTAINS_MAP;
-        } else {
+            checkGuard = linkerServices.filterInternalObjects(CONTAINS_MAP);
+            break;
+        case ARRAY:
             checkGuard = convertArgToInt(RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor);
+            break;
+        default:
+            throw new AssertionError();
         }
         final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation),
                 nextComponent.getGuardedInvocation().getInvocation());
@@ -243,6 +253,18 @@
                 gic.getValidatorClass(), gic.getValidationType());
     }
 
+    private static GuardedInvocationComponent createInternalFilteredGuardedInvocationComponent(
+            final MethodHandle invocation, final LinkerServices linkerServices) {
+        return new GuardedInvocationComponent(linkerServices.filterInternalObjects(invocation));
+    }
+
+    private static GuardedInvocationComponent createInternalFilteredGuardedInvocationComponent(
+            final MethodHandle invocation, final MethodHandle guard, final Class<?> validatorClass,
+            final ValidationType validationType, final LinkerServices linkerServices) {
+        return new GuardedInvocationComponent(linkerServices.filterInternalObjects(invocation), guard,
+                validatorClass, validationType);
+    }
+
     private static String getFixedKey(final CallSiteDescriptor callSiteDescriptor) {
         return callSiteDescriptor.getNameTokenCount() == 2 ? null : callSiteDescriptor.getNameToken(
                 CallSiteDescriptor.NAME_OPERAND);
@@ -381,37 +403,38 @@
         // dealing with an array, or a list or map, but hey...
         // Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers
         // in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices.
-        final boolean isMap;
+        final CollectionType collectionType;
         if(declaredType.isArray()) {
-            gic = new GuardedInvocationComponent(MethodHandles.arrayElementSetter(declaredType));
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(MethodHandles.arrayElementSetter(declaredType), linkerServices);
+            collectionType = CollectionType.ARRAY;
         } else if(List.class.isAssignableFrom(declaredType)) {
-            gic = new GuardedInvocationComponent(SET_LIST_ELEMENT);
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(SET_LIST_ELEMENT, linkerServices);
+            collectionType = CollectionType.LIST;
         } else if(Map.class.isAssignableFrom(declaredType)) {
-            gic = new GuardedInvocationComponent(PUT_MAP_ELEMENT);
-            isMap = true;
+            gic = createInternalFilteredGuardedInvocationComponent(PUT_MAP_ELEMENT, linkerServices);
+            collectionType = CollectionType.MAP;
         } else if(clazz.isArray()) {
-            gic = getClassGuardedInvocationComponent(MethodHandles.arrayElementSetter(clazz), callSiteType);
-            isMap = false;
+            gic = getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(
+                    MethodHandles.arrayElementSetter(clazz)), callSiteType);
+            collectionType = CollectionType.ARRAY;
         } else if(List.class.isAssignableFrom(clazz)) {
-            gic = new GuardedInvocationComponent(SET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class,
-                    ValidationType.INSTANCE_OF);
-            isMap = false;
+            gic = createInternalFilteredGuardedInvocationComponent(SET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class, ValidationType.INSTANCE_OF,
+                    linkerServices);
+            collectionType = CollectionType.LIST;
         } else if(Map.class.isAssignableFrom(clazz)) {
-            gic = new GuardedInvocationComponent(PUT_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class,
-                    ValidationType.INSTANCE_OF);
-            isMap = true;
+            gic = createInternalFilteredGuardedInvocationComponent(PUT_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType),
+                    Map.class, ValidationType.INSTANCE_OF, linkerServices);
+            collectionType = CollectionType.MAP;
         } else {
             // Can't set elements for objects that are neither arrays, nor list, nor maps.
             gic = null;
-            isMap = false;
+            collectionType = null;
         }
 
         // In contrast to, say, getElementGetter, we only compute the nextComponent if the target object is not a map,
         // as maps will always succeed in setting the element and will never need to fall back to the next component
         // operation.
-        final GuardedInvocationComponent nextComponent = isMap ? null : getGuardedInvocationComponent(
+        final GuardedInvocationComponent nextComponent = collectionType == CollectionType.MAP ? null : getGuardedInvocationComponent(
                 callSiteDescriptor, linkerServices, operations);
         if(gic == null) {
             return nextComponent;
@@ -421,7 +444,7 @@
         final String fixedKey = getFixedKey(callSiteDescriptor);
         // Convert the key to a number if we're working with a list or array
         final Object typedFixedKey;
-        if(!isMap && fixedKey != null) {
+        if(collectionType != CollectionType.MAP && fixedKey != null) {
             typedFixedKey = convertKeyToInteger(fixedKey, linkerServices);
             if(typedFixedKey == null) {
                 // key is not numeric, it can never succeed
@@ -439,7 +462,8 @@
             return gic.replaceInvocation(binder.bind(invocation));
         }
 
-        final MethodHandle checkGuard = convertArgToInt(invocation == SET_LIST_ELEMENT ? RANGE_CHECK_LIST :
+        assert collectionType == CollectionType.LIST || collectionType == CollectionType.ARRAY;
+        final MethodHandle checkGuard = convertArgToInt(collectionType == CollectionType.LIST ? RANGE_CHECK_LIST :
             RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor);
         final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation),
                 nextComponent.getGuardedInvocation().getInvocation());
--- a/src/jdk/internal/dynalink/beans/OverloadedMethod.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/beans/OverloadedMethod.java	Fri Nov 13 15:38:44 2015 -0800
@@ -139,7 +139,8 @@
         final MethodHandle bound = SELECT_METHOD.bindTo(this);
         final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
                 callSiteType.changeReturnType(MethodHandle.class));
-        invoker = MethodHandles.foldArguments(MethodHandles.exactInvoker(this.callSiteType), collecting);
+        invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
+                MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
     }
 
     MethodHandle getInvoker() {
--- a/src/jdk/internal/dynalink/beans/SingleDynamicMethod.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/beans/SingleDynamicMethod.java	Fri Nov 13 15:38:44 2015 -0800
@@ -165,10 +165,11 @@
      * @return the adapted method handle.
      */
     static MethodHandle getInvocation(final MethodHandle target, final MethodType callSiteType, final LinkerServices linkerServices) {
-        final MethodType methodType = target.type();
+        final MethodHandle filteredTarget = linkerServices.filterInternalObjects(target);
+        final MethodType methodType = filteredTarget.type();
         final int paramsLen = methodType.parameterCount();
         final boolean varArgs = target.isVarargsCollector();
-        final MethodHandle fixTarget = varArgs ? target.asFixedArity() : target;
+        final MethodHandle fixTarget = varArgs ? filteredTarget.asFixedArity() : filteredTarget;
         final int fixParamsLen = varArgs ? paramsLen - 1 : paramsLen;
         final int argsLen = callSiteType.parameterCount();
         if(argsLen < fixParamsLen) {
@@ -204,7 +205,7 @@
             if(varArgType.isAssignableFrom(callSiteLastArgType)) {
                 // Call site signature guarantees we'll always be passed a single compatible array; just link directly
                 // to the method, introducing necessary conversions. Also, preserve it being a variable arity method.
-                return createConvertingInvocation(target, linkerServices, callSiteType).asVarargsCollector(
+                return createConvertingInvocation(filteredTarget, linkerServices, callSiteType).asVarargsCollector(
                         callSiteLastArgType);
             }
 
--- a/src/jdk/internal/dynalink/beans/StaticClass.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/beans/StaticClass.java	Fri Nov 13 15:38:44 2015 -0800
@@ -84,6 +84,7 @@
 package jdk.internal.dynalink.beans;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * Object that represents the static facet of a class (its static methods, properties, and fields, as well as
@@ -106,8 +107,7 @@
     private final Class<?> clazz;
 
     /*private*/ StaticClass(final Class<?> clazz) {
-        clazz.getClass(); // NPE check
-        this.clazz = clazz;
+        this.clazz = Objects.requireNonNull(clazz);
     }
 
     /**
--- a/src/jdk/internal/dynalink/linker/GuardedInvocation.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/linker/GuardedInvocation.java	Fri Nov 13 15:38:44 2015 -0800
@@ -91,6 +91,7 @@
 import java.lang.invoke.SwitchPoint;
 import java.lang.invoke.WrongMethodTypeException;
 import java.util.List;
+import java.util.Objects;
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.support.Guards;
 
@@ -170,8 +171,7 @@
      * @throws NullPointerException if invocation is null.
      */
     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
-        invocation.getClass(); // NPE check
-        this.invocation = invocation;
+        this.invocation = Objects.requireNonNull(invocation);
         this.guard = guard;
         this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };
         this.exception = exception;
@@ -190,8 +190,7 @@
      * @throws NullPointerException if invocation is null.
      */
     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
-        invocation.getClass(); // NPE check
-        this.invocation = invocation;
+        this.invocation = Objects.requireNonNull(invocation);
         this.guard = guard;
         this.switchPoints = switchPoints == null ? null : switchPoints.clone();
         this.exception = exception;
--- a/src/jdk/internal/dynalink/linker/LinkerServices.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/linker/LinkerServices.java	Fri Nov 13 15:38:44 2015 -0800
@@ -181,6 +181,15 @@
     public Comparison compareConversion(Class<?> sourceType, Class<?> targetType1, Class<?> targetType2);
 
     /**
+     * Modifies the method handle so that any parameters that can receive potentially internal language runtime objects
+     * will have a filter added on them to prevent them from escaping, potentially by wrapping them.
+     * It can also potentially add an unwrapping filter to the return value.
+     * @param target the target method handle
+     * @return a method handle with parameters and/or return type potentially filtered for wrapping and unwrapping.
+     */
+    public MethodHandle filterInternalObjects(final MethodHandle target);
+
+    /**
      * If we could just use Java 8 constructs, then {@code asTypeSafeReturn} would be a method with default
      * implementation. Since we can't do that, we extract common default implementations into this static class.
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/internal/dynalink/linker/MethodHandleTransformer.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+   Copyright 2009-2015 Attila Szegedi
+
+   Licensed under both the Apache License, Version 2.0 (the "Apache License")
+   and the BSD License (the "BSD License"), with licensee being free to
+   choose either of the two at their discretion.
+
+   You may not use this file except in compliance with either the Apache
+   License or the BSD License.
+
+   If you choose to use this file in compliance with the Apache License, the
+   following notice applies to you:
+
+       You may obtain a copy of the Apache License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing, software
+       distributed under the License is distributed on an "AS IS" BASIS,
+       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+       implied. See the License for the specific language governing
+       permissions and limitations under the License.
+
+   If you choose to use this file in compliance with the BSD License, the
+   following notice applies to you:
+
+       Redistribution and use in source and binary forms, with or without
+       modification, are permitted provided that the following conditions are
+       met:
+       * Redistributions of source code must retain the above copyright
+         notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+         notice, this list of conditions and the following disclaimer in the
+         documentation and/or other materials provided with the distribution.
+       * Neither the name of the copyright holder nor the names of
+         contributors may be used to endorse or promote products derived from
+         this software without specific prior written permission.
+
+       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+       IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+       TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+       PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+       BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.internal.dynalink.linker;
+
+import java.lang.invoke.MethodHandle;
+
+/**
+ * A generic interface describing operations that transform method handles.
+ */
+public interface MethodHandleTransformer {
+    /**
+     * Transforms a method handle.
+     * @param target the method handle being transformed.
+     * @return transformed method handle.
+     */
+    public MethodHandle transform(final MethodHandle target);
+}
--- a/src/jdk/internal/dynalink/support/CallSiteDescriptorFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/support/CallSiteDescriptorFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -91,6 +91,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.StringTokenizer;
 import java.util.WeakHashMap;
 import jdk.internal.dynalink.CallSiteDescriptor;
@@ -123,9 +124,9 @@
      * in fact return a weakly-referenced canonical instance.
      */
     public static CallSiteDescriptor create(final Lookup lookup, final String name, final MethodType methodType) {
-        name.getClass(); // NPE check
-        methodType.getClass(); // NPE check
-        lookup.getClass(); // NPE check
+        Objects.requireNonNull(name);
+        Objects.requireNonNull(methodType);
+        Objects.requireNonNull(lookup);
         final String[] tokenizedName = tokenizeName(name);
         if(isPublicLookup(lookup)) {
             return getCanonicalPublicDescriptor(createPublicCallSiteDescriptor(tokenizedName, methodType));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/internal/dynalink/support/DefaultInternalObjectFilter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+   Copyright 2009-2015 Attila Szegedi
+
+   Licensed under both the Apache License, Version 2.0 (the "Apache License")
+   and the BSD License (the "BSD License"), with licensee being free to
+   choose either of the two at their discretion.
+
+   You may not use this file except in compliance with either the Apache
+   License or the BSD License.
+
+   If you choose to use this file in compliance with the Apache License, the
+   following notice applies to you:
+
+       You may obtain a copy of the Apache License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing, software
+       distributed under the License is distributed on an "AS IS" BASIS,
+       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+       implied. See the License for the specific language governing
+       permissions and limitations under the License.
+
+   If you choose to use this file in compliance with the BSD License, the
+   following notice applies to you:
+
+       Redistribution and use in source and binary forms, with or without
+       modification, are permitted provided that the following conditions are
+       met:
+       * Redistributions of source code must retain the above copyright
+         notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+         notice, this list of conditions and the following disclaimer in the
+         documentation and/or other materials provided with the distribution.
+       * Neither the name of the copyright holder nor the names of
+         contributors may be used to endorse or promote products derived from
+         this software without specific prior written permission.
+
+       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+       IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+       TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+       PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+       BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.internal.dynalink.support;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import jdk.internal.dynalink.DynamicLinkerFactory;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
+
+/**
+ * Default implementation for a {@link DynamicLinkerFactory#setInternalObjectsFilter(MethodHandleTransformer)}.
+ * Given a method handle of {@code Object(Object)} type for filtering parameter and another one of the same type for
+ * filtering return values, applies them to passed method handles where their parameter types and/or return value types
+ * are declared to be {@link Object}.
+ */
+public class DefaultInternalObjectFilter implements MethodHandleTransformer {
+    private static final MethodHandle FILTER_VARARGS = new Lookup(MethodHandles.lookup()).findStatic(
+            DefaultInternalObjectFilter.class, "filterVarArgs", MethodType.methodType(Object[].class, MethodHandle.class, Object[].class));
+
+    private final MethodHandle parameterFilter;
+    private final MethodHandle returnFilter;
+    private final MethodHandle varArgFilter;
+
+    /**
+     * Creates a new filter.
+     * @param parameterFilter the filter for method parameters. Must be of type {@code Object(Object)}, or null.
+     * @param returnFilter the filter for return values. Must be of type {@code Object(Object)}, or null.
+     * @throws IllegalArgumentException if one or both filters are not of the expected type.
+     */
+    public DefaultInternalObjectFilter(final MethodHandle parameterFilter, final MethodHandle returnFilter) {
+        this.parameterFilter = checkHandle(parameterFilter, "parameterFilter");
+        this.returnFilter = checkHandle(returnFilter, "returnFilter");
+        this.varArgFilter = parameterFilter == null ? null : FILTER_VARARGS.bindTo(parameterFilter);
+    }
+
+    @Override
+    public MethodHandle transform(final MethodHandle target) {
+        assert target != null;
+        MethodHandle[] filters = null;
+        final MethodType type = target.type();
+        final boolean isVarArg = target.isVarargsCollector();
+        final int paramCount = type.parameterCount();
+        final MethodHandle paramsFiltered;
+        // Filter parameters
+        if (parameterFilter != null) {
+            int firstFilter = -1;
+            // Ignore receiver, start from argument 1
+            for(int i = 1; i < paramCount; ++i) {
+                final Class<?> paramType = type.parameterType(i);
+                final boolean filterVarArg = isVarArg && i == paramCount - 1 && paramType == Object[].class;
+                if (filterVarArg || paramType == Object.class) {
+                    if (filters == null) {
+                        firstFilter = i;
+                        filters = new MethodHandle[paramCount - firstFilter];
+                    }
+                    filters[i - firstFilter] = filterVarArg ? varArgFilter : parameterFilter;
+                }
+            }
+            paramsFiltered = filters != null ? MethodHandles.filterArguments(target, firstFilter, filters) : target;
+        } else {
+            paramsFiltered = target;
+        }
+        // Filter return value if needed
+        final MethodHandle returnFiltered = returnFilter != null && type.returnType() == Object.class ? MethodHandles.filterReturnValue(paramsFiltered, returnFilter) : paramsFiltered;
+        // Preserve varargs collector state
+        return isVarArg && !returnFiltered.isVarargsCollector() ? returnFiltered.asVarargsCollector(type.parameterType(paramCount - 1)) : returnFiltered;
+
+    }
+
+    private static MethodHandle checkHandle(final MethodHandle handle, final String handleKind) {
+        if (handle != null) {
+            final MethodType objectObjectType = MethodType.methodType(Object.class, Object.class);
+            if (!handle.type().equals(objectObjectType)) {
+                throw new IllegalArgumentException("Method type for " + handleKind + " must be " + objectObjectType);
+            }
+        }
+        return handle;
+    }
+
+    @SuppressWarnings("unused")
+    private static Object[] filterVarArgs(final MethodHandle parameterFilter, final Object[] args) throws Throwable {
+        Object[] newArgs = null;
+        for(int i = 0; i < args.length; ++i) {
+            final Object arg = args[i];
+            final Object newArg = parameterFilter.invokeExact(arg);
+            if (arg != newArg) {
+                if (newArgs == null) {
+                    newArgs = args.clone();
+                }
+                newArgs[i] = newArg;
+            }
+        }
+        return newArgs == null ? args : newArgs;
+    }
+}
--- a/src/jdk/internal/dynalink/support/LinkerServicesImpl.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/internal/dynalink/support/LinkerServicesImpl.java	Fri Nov 13 15:38:44 2015 -0800
@@ -90,6 +90,7 @@
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
 
 /**
  * Default implementation of the {@link LinkerServices} interface.
@@ -103,17 +104,21 @@
 
     private final TypeConverterFactory typeConverterFactory;
     private final GuardingDynamicLinker topLevelLinker;
+    private final MethodHandleTransformer internalObjectsFilter;
 
     /**
      * Creates a new linker services object.
      *
      * @param typeConverterFactory the type converter factory exposed by the services.
      * @param topLevelLinker the top level linker used by the services.
+     * @param internalObjectsFilter a method handle transformer that is supposed to act as the implementation of this
+     * services' {@link #filterInternalObjects(java.lang.invoke.MethodHandle)} method.
      */
     public LinkerServicesImpl(final TypeConverterFactory typeConverterFactory,
-            final GuardingDynamicLinker topLevelLinker) {
+            final GuardingDynamicLinker topLevelLinker, final MethodHandleTransformer internalObjectsFilter) {
         this.typeConverterFactory = typeConverterFactory;
         this.topLevelLinker = topLevelLinker;
+        this.internalObjectsFilter = internalObjectsFilter;
     }
 
     @Override
@@ -152,6 +157,11 @@
         }
     }
 
+    @Override
+    public MethodHandle filterInternalObjects(final MethodHandle target) {
+        return internalObjectsFilter != null ? internalObjectsFilter.transform(target) : target;
+    }
+
     /**
      * Returns the currently processed link request, or null if the method is invoked outside of the linking process.
      * @return the currently processed link request, or null.
--- a/src/jdk/nashorn/api/scripting/AbstractJSObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/AbstractJSObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,8 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
+import jdk.nashorn.internal.runtime.JSONListAdapter;
+import jdk.nashorn.internal.runtime.JSType;
 
 /**
  * This is the base class for nashorn ScriptObjectMirror class.
@@ -36,7 +38,10 @@
  * treat objects of such classes just like nashorn script objects. Usual nashorn
  * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
  * to appropriate method call of this class.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public abstract class AbstractJSObject implements JSObject {
     /**
      * Call this object as a JavaScript function. This is equivalent to
@@ -158,9 +163,8 @@
      * @return set of property names
      */
     @Override
-    @SuppressWarnings("unchecked")
     public Set<String> keySet() {
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     /**
@@ -169,9 +173,8 @@
      * @return set of property values.
      */
     @Override
-    @SuppressWarnings("unchecked")
     public Collection<Object> values() {
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     // JavaScript instanceof check
@@ -246,9 +249,43 @@
      * Returns this object's numeric value.
      *
      * @return this object's numeric value.
+     * @deprecated use {@link #getDefaultValue(Class)} with {@link Number} hint instead.
      */
-    @Override
+    @Override @Deprecated
     public double toNumber() {
-        return Double.NaN;
+        return JSType.toNumber(JSType.toPrimitive(this, Number.class));
+    }
+
+    /**
+     * Implements this object's {@code [[DefaultValue]]} method. The default implementation follows ECMAScript 5.1
+     * section 8.6.2 but subclasses are free to provide their own implementations.
+     *
+     * @param hint the type hint. Should be either {@code null}, {@code Number.class} or {@code String.class}.
+     * @return this object's default value.
+     * @throws UnsupportedOperationException if the conversion can't be performed. The engine will convert this
+     * exception into a JavaScript {@code TypeError}.
+     */
+    public Object getDefaultValue(final Class<?> hint) {
+        return DefaultValueImpl.getDefaultValue(this, hint);
+    }
+
+    /**
+     * When passed an {@link AbstractJSObject}, invokes its {@link #getDefaultValue(Class)} method. When passed any
+     * other {@link JSObject}, it will obtain its {@code [[DefaultValue]]} method as per ECMAScript 5.1 section
+     * 8.6.2.
+     *
+     * @param jsobj the {@link JSObject} whose {@code [[DefaultValue]]} is obtained.
+     * @param hint the type hint. Should be either {@code null}, {@code Number.class} or {@code String.class}.
+     * @return this object's default value.
+     * @throws UnsupportedOperationException if the conversion can't be performed. The engine will convert this
+     * exception into a JavaScript {@code TypeError}.
+     */
+    public static Object getDefaultValue(final JSObject jsobj, final Class<?> hint) {
+        if (jsobj instanceof AbstractJSObject) {
+            return ((AbstractJSObject)jsobj).getDefaultValue(hint);
+        } else if (jsobj instanceof JSONListAdapter) {
+            return ((JSONListAdapter)jsobj).getDefaultValue(hint);
+        }
+        return DefaultValueImpl.getDefaultValue(jsobj, hint);
     }
 }
--- a/src/jdk/nashorn/api/scripting/ClassFilter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/ClassFilter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,7 +28,10 @@
  * Class filter (optional) to be used by nashorn script engine.
  * jsr-223 program embedding nashorn script can set ClassFilter instance
  * to be used when an engine instance is created.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public interface ClassFilter {
      /**
       * Should the Java class of the specified name be exposed to scripts?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/api/scripting/DefaultValueImpl.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting;
+
+import jdk.nashorn.internal.runtime.JSType;
+
+/**
+ * Default implementation of {@link JSObject#getDefaultValue(Class)}. Isolated into a separate class mostly so
+ * that we can have private static instances of function name arrays, something we couldn't declare without it
+ * being visible in {@link JSObject} interface.
+ */
+class DefaultValueImpl {
+    private static final String[] DEFAULT_VALUE_FNS_NUMBER = new String[] { "valueOf", "toString" };
+    private static final String[] DEFAULT_VALUE_FNS_STRING = new String[] { "toString", "valueOf" };
+
+    static Object getDefaultValue(final JSObject jsobj, final Class<?> hint) throws UnsupportedOperationException {
+        final boolean isNumber = hint == null || hint == Number.class;
+        for(final String methodName: isNumber ? DEFAULT_VALUE_FNS_NUMBER : DEFAULT_VALUE_FNS_STRING) {
+            final Object objMember = jsobj.getMember(methodName);
+            if (objMember instanceof JSObject) {
+                final JSObject member = (JSObject)objMember;
+                if (member.isFunction()) {
+                    final Object value = member.call(jsobj);
+                    if (JSType.isPrimitive(value)) {
+                        return value;
+                    }
+                }
+            }
+        }
+        throw new UnsupportedOperationException(isNumber ? "cannot.get.default.number" : "cannot.get.default.string");
+    }
+}
--- a/src/jdk/nashorn/api/scripting/JSObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/JSObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -33,7 +33,10 @@
  * treat objects of such classes just like nashorn script objects. Usual nashorn
  * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
  * to appropriate method call of this interface.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public interface JSObject {
     /**
      * Call this object as a JavaScript function. This is equivalent to
@@ -183,6 +186,8 @@
      * Returns this object's numeric value.
      *
      * @return this object's numeric value.
+     * @deprecated use {@link AbstractJSObject#getDefaultValue(JSObject, Class)} with {@link Number} hint instead.
      */
+    @Deprecated
     public double toNumber();
 }
--- a/src/jdk/nashorn/api/scripting/NashornException.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/NashornException.java	Fri Nov 13 15:38:44 2015 -0800
@@ -41,7 +41,10 @@
  * script object or Java access to script object properties via java.util.Map
  * interface. In these cases, user code will get an instance of this or
  * implementation defined subclass.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 @SuppressWarnings("serial")
 public abstract class NashornException extends RuntimeException {
     // script file name
--- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Fri Nov 13 15:38:44 2015 -0800
@@ -39,6 +39,7 @@
 import java.security.ProtectionDomain;
 import java.text.MessageFormat;
 import java.util.Locale;
+import java.util.Objects;
 import java.util.ResourceBundle;
 import javax.script.AbstractScriptEngine;
 import javax.script.Bindings;
@@ -65,8 +66,10 @@
  * {@link NashornScriptEngineFactory#getScriptEngine()}. Note that this engine implements the {@link Compilable} and
  * {@link Invocable} interfaces, allowing for efficient precompilation and repeated execution of scripts.
  * @see NashornScriptEngineFactory
+ *
+ * @since 1.8u40
  */
-
+@jdk.Exported
 public final class NashornScriptEngine extends AbstractScriptEngine implements Compilable, Invocable {
     /**
      * Key used to associate Nashorn global object mirror with arbitrary Bindings instance.
@@ -351,14 +354,13 @@
             }
         }, CREATE_GLOBAL_ACC_CTXT);
 
-        nashornContext.initGlobal(newGlobal, this);
-        newGlobal.setScriptContext(ctxt);
+        nashornContext.initGlobal(newGlobal, this, ctxt);
 
         return newGlobal;
     }
 
     private Object invokeImpl(final Object selfObject, final String name, final Object... args) throws ScriptException, NoSuchMethodException {
-        name.getClass(); // null check
+        Objects.requireNonNull(name);
         assert !(selfObject instanceof ScriptObject) : "raw ScriptObject not expected here";
 
         Global invokeGlobal = null;
@@ -401,7 +403,7 @@
         return evalImpl(script, ctxt, getNashornGlobalFrom(ctxt));
     }
 
-    private static Object evalImpl(final Context.MultiGlobalCompiledScript mgcs, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException {
+    private Object evalImpl(final Context.MultiGlobalCompiledScript mgcs, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException {
         final Global oldGlobal = Context.getGlobal();
         final boolean globalChanged = (oldGlobal != ctxtGlobal);
         try {
@@ -410,8 +412,13 @@
             }
 
             final ScriptFunction script = mgcs.getFunction(ctxtGlobal);
+            final ScriptContext oldCtxt = ctxtGlobal.getScriptContext();
             ctxtGlobal.setScriptContext(ctxt);
-            return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script, ctxtGlobal), ctxtGlobal));
+            try {
+                return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script, ctxtGlobal), ctxtGlobal));
+            } finally {
+                ctxtGlobal.setScriptContext(oldCtxt);
+            }
         } catch (final Exception e) {
             throwAsScriptException(e, ctxtGlobal);
             throw new AssertionError("should not reach here");
@@ -422,7 +429,7 @@
         }
     }
 
-    private static Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException {
+    private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException {
         if (script == null) {
             return null;
         }
@@ -433,8 +440,13 @@
                 Context.setGlobal(ctxtGlobal);
             }
 
+            final ScriptContext oldCtxt = ctxtGlobal.getScriptContext();
             ctxtGlobal.setScriptContext(ctxt);
-            return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script, ctxtGlobal), ctxtGlobal));
+            try {
+                return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script, ctxtGlobal), ctxtGlobal));
+            } finally {
+                ctxtGlobal.setScriptContext(oldCtxt);
+            }
         } catch (final Exception e) {
             throwAsScriptException(e, ctxtGlobal);
             throw new AssertionError("should not reach here");
--- a/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineFactory;
 import jdk.nashorn.internal.runtime.Context;
@@ -44,7 +45,10 @@
  * </ul>
  * Programs executing in engines created using {@link #getScriptEngine(String[])} will have the passed arguments
  * accessible as a global variable named {@code "arguments"}.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public final class NashornScriptEngineFactory implements ScriptEngineFactory {
     @Override
     public String getEngineName() {
@@ -120,7 +124,7 @@
             // used to execute scripts concurrently on multiple threads.
             return null;
         default:
-            throw new IllegalArgumentException("Invalid key");
+            return null;
         }
     }
 
@@ -174,8 +178,7 @@
      *         denies {@code RuntimePermission("nashorn.setConfig")}
      */
     public ScriptEngine getScriptEngine(final ClassFilter classFilter) {
-        classFilter.getClass(); // null check
-        return newEngine(DEFAULT_OPTIONS, getAppClassLoader(), classFilter);
+        return newEngine(DEFAULT_OPTIONS, getAppClassLoader(), Objects.requireNonNull(classFilter));
     }
 
     /**
@@ -189,8 +192,7 @@
      *         denies {@code RuntimePermission("nashorn.setConfig")}
      */
     public ScriptEngine getScriptEngine(final String... args) {
-        args.getClass(); // null check
-        return newEngine(args, getAppClassLoader(), null);
+        return newEngine(Objects.requireNonNull(args), getAppClassLoader(), null);
     }
 
     /**
@@ -205,8 +207,7 @@
      *         denies {@code RuntimePermission("nashorn.setConfig")}
      */
     public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) {
-        args.getClass(); // null check
-        return newEngine(args, appLoader, null);
+        return newEngine(Objects.requireNonNull(args), appLoader, null);
     }
 
     /**
@@ -222,9 +223,7 @@
      *         denies {@code RuntimePermission("nashorn.setConfig")}
      */
     public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader, final ClassFilter classFilter) {
-        args.getClass(); // null check
-        classFilter.getClass(); // null check
-        return newEngine(args, appLoader, classFilter);
+        return newEngine(Objects.requireNonNull(args), appLoader, Objects.requireNonNull(classFilter));
     }
 
     private ScriptEngine newEngine(final String[] args, final ClassLoader appLoader, final ClassFilter classFilter) {
--- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Fri Nov 13 15:38:44 2015 -0800
@@ -39,12 +39,15 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import javax.script.Bindings;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ECMAException;
+import jdk.nashorn.internal.runtime.JSONListAdapter;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
@@ -54,7 +57,10 @@
 
 /**
  * Mirror object that wraps a given Nashorn Script object.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public final class ScriptObjectMirror extends AbstractJSObject implements Bindings {
     private static AccessControlContext getContextAccCtxt() {
         final Permissions perms = new Permissions();
@@ -67,6 +73,7 @@
     private final ScriptObject sobj;
     private final Global  global;
     private final boolean strict;
+    private final boolean jsonCompatible;
 
     @Override
     public boolean equals(final Object other) {
@@ -105,9 +112,9 @@
             }
 
             if (sobj instanceof ScriptFunction) {
-                final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
-                final Object self = globalChanged? wrap(thiz, oldGlobal) : thiz;
-                return wrap(ScriptRuntime.apply((ScriptFunction)sobj, unwrap(self, global), unwrapArray(modArgs, global)), global);
+                final Object[] modArgs = globalChanged? wrapArrayLikeMe(args, oldGlobal) : args;
+                final Object self = globalChanged? wrapLikeMe(thiz, oldGlobal) : thiz;
+                return wrapLikeMe(ScriptRuntime.apply((ScriptFunction)sobj, unwrap(self, global), unwrapArray(modArgs, global)));
             }
 
             throw new RuntimeException("not a function: " + toString());
@@ -135,8 +142,8 @@
             }
 
             if (sobj instanceof ScriptFunction) {
-                final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
-                return wrap(ScriptRuntime.construct((ScriptFunction)sobj, unwrapArray(modArgs, global)), global);
+                final Object[] modArgs = globalChanged? wrapArrayLikeMe(args, oldGlobal) : args;
+                return wrapLikeMe(ScriptRuntime.construct((ScriptFunction)sobj, unwrapArray(modArgs, global)));
             }
 
             throw new RuntimeException("not a constructor: " + toString());
@@ -165,7 +172,7 @@
                                 return Context.getContext();
                             }
                         }, GET_CONTEXT_ACC_CTXT);
-                return wrap(context.eval(global, s, sobj, null, false), global);
+                return wrapLikeMe(context.eval(global, s, sobj, null));
             }
         });
     }
@@ -177,7 +184,7 @@
      * @return return value of function
      */
     public Object callMember(final String functionName, final Object... args) {
-        functionName.getClass(); // null check
+        Objects.requireNonNull(functionName);
         final Global oldGlobal = Context.getGlobal();
         final boolean globalChanged = (oldGlobal != global);
 
@@ -188,8 +195,8 @@
 
             final Object val = sobj.get(functionName);
             if (val instanceof ScriptFunction) {
-                final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
-                return wrap(ScriptRuntime.apply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)), global);
+                final Object[] modArgs = globalChanged? wrapArrayLikeMe(args, oldGlobal) : args;
+                return wrapLikeMe(ScriptRuntime.apply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)));
             } else if (val instanceof JSObject && ((JSObject)val).isFunction()) {
                 return ((JSObject)val).call(sobj, args);
             }
@@ -210,10 +217,10 @@
 
     @Override
     public Object getMember(final String name) {
-        name.getClass();
+        Objects.requireNonNull(name);
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return wrap(sobj.get(name), global);
+                return wrapLikeMe(sobj.get(name));
             }
         });
     }
@@ -222,14 +229,14 @@
     public Object getSlot(final int index) {
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return wrap(sobj.get(index), global);
+                return wrapLikeMe(sobj.get(index));
             }
         });
     }
 
     @Override
     public boolean hasMember(final String name) {
-        name.getClass();
+        Objects.requireNonNull(name);
         return inGlobal(new Callable<Boolean>() {
             @Override public Boolean call() {
                 return sobj.has(name);
@@ -248,14 +255,12 @@
 
     @Override
     public void removeMember(final String name) {
-        name.getClass();
-        remove(name);
+        remove(Objects.requireNonNull(name));
     }
 
     @Override
     public void setMember(final String name, final Object value) {
-        name.getClass();
-        put(name, value);
+        put(Objects.requireNonNull(name), value);
     }
 
     @Override
@@ -337,9 +342,10 @@
 
     @Override
     public boolean containsKey(final Object key) {
+        checkKey(key);
         return inGlobal(new Callable<Boolean>() {
             @Override public Boolean call() {
-                return sobj.containsKey(unwrap(key, global));
+                return sobj.containsKey(key);
             }
         });
     }
@@ -362,7 +368,7 @@
 
                 while (iter.hasNext()) {
                     final String key   = iter.next();
-                    final Object value = translateUndefined(wrap(sobj.get(key), global));
+                    final Object value = translateUndefined(wrapLikeMe(sobj.get(key)));
                     entries.add(new AbstractMap.SimpleImmutableEntry<>(key, value));
                 }
 
@@ -373,9 +379,10 @@
 
     @Override
     public Object get(final Object key) {
+        checkKey(key);
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return translateUndefined(wrap(sobj.get(key), global));
+                return translateUndefined(wrapLikeMe(sobj.get(key)));
             }
         });
     }
@@ -407,26 +414,30 @@
 
     @Override
     public Object put(final String key, final Object value) {
+        checkKey(key);
         final ScriptObject oldGlobal = Context.getGlobal();
         final boolean globalChanged = (oldGlobal != global);
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
-                return translateUndefined(wrap(sobj.put(key, unwrap(modValue, global), strict), global));
+                final Object modValue = globalChanged? wrapLikeMe(value, oldGlobal) : value;
+                return translateUndefined(wrapLikeMe(sobj.put(key, unwrap(modValue, global), strict)));
             }
         });
     }
 
     @Override
     public void putAll(final Map<? extends String, ? extends Object> map) {
+        Objects.requireNonNull(map);
         final ScriptObject oldGlobal = Context.getGlobal();
         final boolean globalChanged = (oldGlobal != global);
         inGlobal(new Callable<Object>() {
             @Override public Object call() {
                 for (final Map.Entry<? extends String, ? extends Object> entry : map.entrySet()) {
                     final Object value = entry.getValue();
-                    final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
-                    sobj.set(entry.getKey(), unwrap(modValue, global), getCallSiteFlags());
+                    final Object modValue = globalChanged? wrapLikeMe(value, oldGlobal) : value;
+                    final String key = entry.getKey();
+                    checkKey(key);
+                    sobj.set(key, unwrap(modValue, global), getCallSiteFlags());
                 }
                 return null;
             }
@@ -435,9 +446,10 @@
 
     @Override
     public Object remove(final Object key) {
+        checkKey(key);
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return wrap(sobj.remove(unwrap(key, global), strict), global);
+                return translateUndefined(wrapLikeMe(sobj.remove(key, strict)));
             }
         });
     }
@@ -474,7 +486,7 @@
                 final Iterator<Object> iter   = sobj.valueIterator();
 
                 while (iter.hasNext()) {
-                    values.add(translateUndefined(wrap(iter.next(), global)));
+                    values.add(translateUndefined(wrapLikeMe(iter.next())));
                 }
 
                 return Collections.unmodifiableList(values);
@@ -491,7 +503,7 @@
     public Object getProto() {
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return wrap(sobj.getProto(), global);
+                return wrapLikeMe(sobj.getProto());
             }
         });
     }
@@ -520,7 +532,7 @@
     public Object getOwnPropertyDescriptor(final String key) {
         return inGlobal(new Callable<Object>() {
             @Override public Object call() {
-                return wrap(sobj.getOwnPropertyDescriptor(key), global);
+                return wrapLikeMe(sobj.getOwnPropertyDescriptor(key));
             }
         });
     }
@@ -626,7 +638,7 @@
     }
 
     /**
-     * Utilitity to convert this script object to the given type.
+     * Utility to convert this script object to the given type.
      *
      * @param <T> destination type to convert to
      * @param type destination type to convert to
@@ -649,16 +661,76 @@
      * @return wrapped/converted object
      */
     public static Object wrap(final Object obj, final Object homeGlobal) {
+        return wrap(obj, homeGlobal, false);
+    }
+
+    /**
+     * Make a script object mirror on given object if needed. Also converts ConsString instances to Strings. The
+     * created wrapper will implement the Java {@code List} interface if {@code obj} is a JavaScript
+     * {@code Array} object; this is compatible with Java JSON libraries expectations. Arrays retrieved through its
+     * properties (transitively) will also implement the list interface.
+     *
+     * @param obj object to be wrapped/converted
+     * @param homeGlobal global to which this object belongs. Not used for ConsStrings.
+     * @return wrapped/converted object
+     */
+    public static Object wrapAsJSONCompatible(final Object obj, final Object homeGlobal) {
+        return wrap(obj, homeGlobal, true);
+    }
+
+    /**
+     * Make a script object mirror on given object if needed. Also converts ConsString instances to Strings.
+     *
+     * @param obj object to be wrapped/converted
+     * @param homeGlobal global to which this object belongs. Not used for ConsStrings.
+     * @param jsonCompatible if true, the created wrapper will implement the Java {@code List} interface if
+     * {@code obj} is a JavaScript {@code Array} object. Arrays retrieved through its properties (transitively)
+     * will also implement the list interface.
+     * @return wrapped/converted object
+     */
+    private static Object wrap(final Object obj, final Object homeGlobal, final boolean jsonCompatible) {
         if(obj instanceof ScriptObject) {
-            return homeGlobal instanceof Global ? new ScriptObjectMirror((ScriptObject)obj, (Global)homeGlobal) : obj;
-        }
-        if(obj instanceof ConsString) {
+            if (!(homeGlobal instanceof Global)) {
+                return obj;
+            }
+            final ScriptObject sobj = (ScriptObject)obj;
+            final Global global = (Global)homeGlobal;
+            final ScriptObjectMirror mirror = new ScriptObjectMirror(sobj, global, jsonCompatible);
+            if (jsonCompatible && sobj.isArray()) {
+                return new JSONListAdapter(mirror, global);
+            }
+            return mirror;
+        } else if(obj instanceof ConsString) {
             return obj.toString();
+        } else if (jsonCompatible && obj instanceof ScriptObjectMirror) {
+            // Since choosing JSON compatible representation is an explicit decision on user's part, if we're asked to
+            // wrap a mirror that was not JSON compatible, explicitly create its compatible counterpart following the
+            // principle of least surprise.
+            return ((ScriptObjectMirror)obj).asJSONCompatible();
         }
         return obj;
     }
 
     /**
+     * Wraps the passed object with the same jsonCompatible flag as this mirror.
+     * @param obj the object
+     * @param homeGlobal the object's home global.
+     * @return a wrapper for the object.
+     */
+    private Object wrapLikeMe(final Object obj, final Object homeGlobal) {
+        return wrap(obj, homeGlobal, jsonCompatible);
+    }
+
+    /**
+     * Wraps the passed object with the same home global and jsonCompatible flag as this mirror.
+     * @param obj the object
+     * @return a wrapper for the object.
+     */
+    private Object wrapLikeMe(final Object obj) {
+        return wrapLikeMe(obj, global);
+    }
+
+    /**
      * Unwrap a script object mirror if needed.
      *
      * @param obj object to be unwrapped
@@ -669,6 +741,8 @@
         if (obj instanceof ScriptObjectMirror) {
             final ScriptObjectMirror mirror = (ScriptObjectMirror)obj;
             return (mirror.global == homeGlobal)? mirror.sobj : obj;
+        } else if (obj instanceof JSONListAdapter) {
+            return ((JSONListAdapter)obj).unwrap(homeGlobal);
         }
 
         return obj;
@@ -682,6 +756,10 @@
      * @return wrapped array
      */
     public static Object[] wrapArray(final Object[] args, final Object homeGlobal) {
+        return wrapArray(args, homeGlobal, false);
+    }
+
+    private static Object[] wrapArray(final Object[] args, final Object homeGlobal, final boolean jsonCompatible) {
         if (args == null || args.length == 0) {
             return args;
         }
@@ -689,12 +767,16 @@
         final Object[] newArgs = new Object[args.length];
         int index = 0;
         for (final Object obj : args) {
-            newArgs[index] = wrap(obj, homeGlobal);
+            newArgs[index] = wrap(obj, homeGlobal, jsonCompatible);
             index++;
         }
         return newArgs;
     }
 
+    private Object[] wrapArrayLikeMe(final Object[] args, final Object homeGlobal) {
+        return wrapArray(args, homeGlobal, jsonCompatible);
+    }
+
     /**
      * Unwrap an array of script object mirrors if needed.
      *
@@ -736,12 +818,17 @@
     // package-privates below this.
 
     ScriptObjectMirror(final ScriptObject sobj, final Global global) {
+        this(sobj, global, false);
+    }
+
+    private ScriptObjectMirror(final ScriptObject sobj, final Global global, final boolean jsonCompatible) {
         assert sobj != null : "ScriptObjectMirror on null!";
         assert global != null : "home Global is null";
 
         this.sobj = sobj;
         this.global = global;
         this.strict = global.isStrictContext();
+        this.jsonCompatible = jsonCompatible;
     }
 
     // accessors for script engine
@@ -783,7 +870,25 @@
         }
     }
 
-    @Override
+    /**
+     * Ensures the key is not null, empty string, or a non-String object. The contract of the {@link Bindings}
+     * interface requires that these are not accepted as keys.
+     * @param key the key to check
+     * @throws NullPointerException if key is null
+     * @throws ClassCastException if key is not a String
+     * @throws IllegalArgumentException if key is empty string
+     */
+    private static void checkKey(final Object key) {
+        Objects.requireNonNull(key, "key can not be null");
+
+        if (!(key instanceof String)) {
+            throw new ClassCastException("key should be a String. It is " + key.getClass().getName() + " instead.");
+        } else if (((String)key).length() == 0) {
+            throw new IllegalArgumentException("key can not be empty");
+        }
+    }
+
+    @Override @Deprecated
     public double toNumber() {
         return inGlobal(new Callable<Double>() {
             @Override public Double call() {
@@ -791,4 +896,28 @@
             }
         });
     }
+
+    @Override
+    public Object getDefaultValue(final Class<?> hint) {
+        return inGlobal(new Callable<Object>() {
+            @Override public Object call() {
+                try {
+                    return sobj.getDefaultValue(hint);
+                } catch (final ECMAException e) {
+                    // We're catching ECMAException (likely TypeError), and translating it to
+                    // UnsupportedOperationException. This in turn will be translated into TypeError of the
+                    // caller's Global by JSType#toPrimitive(JSObject,Class) therefore ensuring that it's
+                    // recognized as "instanceof TypeError" in the caller.
+                    throw new UnsupportedOperationException(e.getMessage(), e);
+                }
+            }
+        });
+    }
+
+    private ScriptObjectMirror asJSONCompatible() {
+        if (this.jsonCompatible) {
+            return this;
+        }
+        return new ScriptObjectMirror(sobj, global, true);
+    }
 }
--- a/src/jdk/nashorn/api/scripting/ScriptUtils.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/ScriptUtils.java	Fri Nov 13 15:38:44 2015 -0800
@@ -38,7 +38,10 @@
 
 /**
  * Utilities that are to be called from script code.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public final class ScriptUtils {
     private ScriptUtils() {}
 
--- a/src/jdk/nashorn/api/scripting/URLReader.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/URLReader.java	Fri Nov 13 15:38:44 2015 -0800
@@ -30,12 +30,16 @@
 import java.io.Reader;
 import java.net.URL;
 import java.nio.charset.Charset;
+import java.util.Objects;
 import jdk.nashorn.internal.runtime.Source;
 
 /**
  * A Reader that reads from a URL. Used to make sure that the reader
  * reads content from given URL and can be trusted to do so.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 public final class URLReader extends Reader {
     // underlying URL
     private final URL url;
@@ -74,9 +78,7 @@
      * @throws NullPointerException if url is null
      */
     public URLReader(final URL url, final Charset cs) {
-        // null check
-        url.getClass();
-        this.url = url;
+        this.url = Objects.requireNonNull(url);
         this.cs  = cs;
     }
 
--- a/src/jdk/nashorn/api/scripting/package-info.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/api/scripting/package-info.java	Fri Nov 13 15:38:44 2015 -0800
@@ -35,5 +35,8 @@
  * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. In addition,
  * this package provides nashorn specific extension classes, interfaces and methods. See
  * {@link jdk.nashorn.api.scripting.NashornScriptEngineFactory} for further details.
+ *
+ * @since 1.8u40
  */
+@jdk.Exported
 package jdk.nashorn.api.scripting;
--- a/src/jdk/nashorn/internal/codegen/AssignSymbols.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/AssignSymbols.java	Fri Nov 13 15:38:44 2015 -0800
@@ -84,6 +84,7 @@
 import jdk.nashorn.internal.ir.VarNode;
 import jdk.nashorn.internal.ir.WithNode;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+import jdk.nashorn.internal.parser.TokenType;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ECMAErrors;
 import jdk.nashorn.internal.runtime.ErrorManager;
@@ -135,15 +136,11 @@
             functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
         }
         // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
-        if(!functionNode.isDeclared() && !functionNode.usesSelfSymbol() && !functionNode.isAnonymous()) {
+        if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
             final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
-            if(selfSymbol != null) {
-                if(selfSymbol.isFunctionSelf()) {
-                    selfSymbol.setNeedsSlot(false);
-                    selfSymbol.clearFlag(Symbol.IS_VAR);
-                }
-            } else {
-                assert functionNode.isProgram();
+            if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
+                selfSymbol.setNeedsSlot(false);
+                selfSymbol.clearFlag(Symbol.IS_VAR);
             }
         }
         return functionNode;
@@ -490,20 +487,31 @@
         final Block body = lc.getCurrentBlock();
 
         initFunctionWideVariables(functionNode, body);
+        acceptDeclarations(functionNode, body);
+        defineFunctionSelfSymbol(functionNode, body);
+    }
 
-        if (!functionNode.isProgram() && !functionNode.isDeclared() && !functionNode.isAnonymous()) {
-            // It's neither declared nor program - it's a function expression then; assign it a self-symbol unless it's
-            // anonymous.
-            final String name = functionNode.getIdent().getName();
-            assert name != null;
-            assert body.getExistingSymbol(name) == null;
-            defineSymbol(body, name, functionNode, IS_VAR | IS_FUNCTION_SELF | HAS_OBJECT_VALUE);
-            if(functionNode.allVarsInScope()) { // basically, has deep eval
-                lc.setFlag(functionNode, FunctionNode.USES_SELF_SYMBOL);
-            }
+    private void defineFunctionSelfSymbol(final FunctionNode functionNode, final Block body) {
+        // Function self-symbol is only declared as a local variable for named function expressions. Declared functions
+        // don't need it as they are local variables in their declaring scope.
+        if (!functionNode.isNamedFunctionExpression()) {
+            return;
         }
 
-        acceptDeclarations(functionNode, body);
+        final String name = functionNode.getIdent().getName();
+        assert name != null; // As it's a named function expression.
+
+        if (body.getExistingSymbol(name) != null) {
+            // Body already has a declaration for the name. It's either a parameter "function x(x)" or a
+            // top-level variable "function x() { ... var x; ... }".
+            return;
+        }
+
+        defineSymbol(body, name, functionNode, IS_VAR | IS_FUNCTION_SELF | HAS_OBJECT_VALUE);
+        if(functionNode.allVarsInScope()) { // basically, has deep eval
+            // We must conservatively presume that eval'd code can dynamically use the function symbol.
+            lc.setFlag(functionNode, FunctionNode.USES_SELF_SYMBOL);
+        }
     }
 
     @Override
@@ -705,25 +713,12 @@
         return definingFn == function;
     }
 
-    private void checkConstAssignment(final IdentNode ident) {
-        // Check for reassignment of constant
-        final Symbol symbol = ident.getSymbol();
-        if (symbol.isConst()) {
-            throwParserException(ECMAErrors.getMessage("syntax.error.assign.constant", symbol.getName()), ident);
-        }
-    }
-
     @Override
     public Node leaveBinaryNode(final BinaryNode binaryNode) {
-        if (binaryNode.isAssignment() && binaryNode.lhs() instanceof IdentNode) {
-            checkConstAssignment((IdentNode) binaryNode.lhs());
+        if (binaryNode.isTokenType(TokenType.ASSIGN)) {
+            return leaveASSIGN(binaryNode);
         }
-        switch (binaryNode.tokenType()) {
-        case ASSIGN:
-            return leaveASSIGN(binaryNode);
-        default:
-            return super.leaveBinaryNode(binaryNode);
-        }
+        return super.leaveBinaryNode(binaryNode);
     }
 
     private Node leaveASSIGN(final BinaryNode binaryNode) {
@@ -744,9 +739,6 @@
 
     @Override
     public Node leaveUnaryNode(final UnaryNode unaryNode) {
-        if (unaryNode.isAssignment() && unaryNode.getExpression() instanceof IdentNode) {
-            checkConstAssignment((IdentNode) unaryNode.getExpression());
-        }
         switch (unaryNode.tokenType()) {
         case DELETE:
             return leaveDELETE(unaryNode);
@@ -919,9 +911,7 @@
     @Override
     public Node leaveTryNode(final TryNode tryNode) {
         tryNode.setException(exceptionSymbol());
-        if (tryNode.getFinallyBody() != null) {
-            tryNode.setFinallyCatchAll(exceptionSymbol());
-        }
+        assert tryNode.getFinallyBody() == null;
 
         end(tryNode);
 
--- a/src/jdk/nashorn/internal/codegen/BranchOptimizer.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/BranchOptimizer.java	Fri Nov 13 15:38:44 2015 -0800
@@ -31,6 +31,7 @@
 import static jdk.nashorn.internal.codegen.Condition.LE;
 import static jdk.nashorn.internal.codegen.Condition.LT;
 import static jdk.nashorn.internal.codegen.Condition.NE;
+import static jdk.nashorn.internal.parser.TokenType.NOT;
 
 import jdk.nashorn.internal.ir.BinaryNode;
 import jdk.nashorn.internal.ir.Expression;
@@ -57,21 +58,11 @@
     }
 
     private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) {
-        final Expression rhs = unaryNode.getExpression();
-
-        switch (unaryNode.tokenType()) {
-        case NOT:
-            branchOptimizer(rhs, label, !state);
-            return;
-        default:
-            if (unaryNode.getType().isBoolean()) {
-                branchOptimizer(rhs, label, state);
-                return;
-            }
-            break;
+        if (unaryNode.isTokenType(NOT)) {
+            branchOptimizer(unaryNode.getExpression(), label, !state);
+        } else {
+            loadTestAndJump(unaryNode, label, state);
         }
-
-        loadTestAndJump(unaryNode, label, state);
     }
 
     private void branchOptimizer(final BinaryNode binaryNode, final Label label, final boolean state) {
@@ -105,33 +96,33 @@
 
         case EQ:
         case EQ_STRICT:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? EQ : NE, true, label);
             return;
 
         case NE:
         case NE_STRICT:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? NE : EQ, true, label);
             return;
 
         case GE:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? GE : LT, false, label);
             return;
 
         case GT:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? GT : LE, false, label);
             return;
 
         case LE:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? LE : GT, true, label);
             return;
 
         case LT:
-            codegen.loadBinaryOperands(binaryNode);
+            codegen.loadComparisonOperands(binaryNode);
             method.conditionalJump(state ? LT : GE, true, label);
             return;
 
--- a/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -100,14 +100,10 @@
  * There is also a very nice debug interface that can emit formatted
  * bytecodes that have been written. This is enabled by setting the
  * environment "nashorn.codegen.debug" to true, or --log=codegen:{@literal <level>}
- * <p>
- * A ClassEmitter implements an Emitter - i.e. it needs to have
- * well defined start and end calls for whatever it is generating. Assertions
- * detect if this is not true
  *
  * @see Compiler
  */
-public class ClassEmitter implements Emitter {
+public class ClassEmitter {
     /** Default flags for class generation - public class */
     private static final EnumSet<Flag> DEFAULT_METHOD_FLAGS = EnumSet.of(Flag.PUBLIC);
 
@@ -147,7 +143,7 @@
 
     /**
      * Constructor - only used internally in this class as it breaks
-     * abstraction towards ASM or other code generator below
+     * abstraction towards ASM or other code generator below.
      *
      * @param env script environment
      * @param cw  ASM classwriter
@@ -160,7 +156,8 @@
     }
 
     /**
-     * Return the method names encountered
+     * Return the method names encountered.
+     *
      * @return method names
      */
     public Set<String> getMethodNames() {
@@ -168,12 +165,13 @@
     }
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param env             script environment
      * @param className       name of class to weave
      * @param superClassName  super class name for class
-     * @param interfaceNames  names of interfaces implemented by this class, or null if none
+     * @param interfaceNames  names of interfaces implemented by this class, or
+     *        {@code null} if none
      */
     ClassEmitter(final Context context, final String className, final String superClassName, final String... interfaceNames) {
         this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
@@ -181,7 +179,7 @@
     }
 
     /**
-     * Constructor from the compiler
+     * Constructor from the compiler.
      *
      * @param env           Script environment
      * @param sourceName    Source name
@@ -220,7 +218,6 @@
     }
 
     /**
-     * Returns the name of the compile unit class name.
      * @return the name of the compile unit class name.
      */
     String getUnitClassName() {
@@ -228,7 +225,8 @@
     }
 
     /**
-     * Get the method count, including init and clinit methods
+     * Get the method count, including init and clinit methods.
+     *
      * @return method count
      */
     public int getMethodCount() {
@@ -236,7 +234,8 @@
     }
 
     /**
-     * Get the clinit count
+     * Get the clinit count.
+     *
      * @return clinit count
      */
     public int getClinitCount() {
@@ -244,7 +243,8 @@
     }
 
     /**
-     * Get the init count
+     * Get the init count.
+     *
      * @return init count
      */
     public int getInitCount() {
@@ -252,7 +252,8 @@
     }
 
     /**
-     * Get the field count
+     * Get the field count.
+     *
      * @return field count
      */
     public int getFieldCount() {
@@ -263,6 +264,7 @@
      * Convert a binary name to a package/class name.
      *
      * @param name Binary name.
+     *
      * @return Package/class name.
      */
     private static String pathName(final String name) {
@@ -271,6 +273,7 @@
 
     /**
      * Define the static fields common in all scripts.
+     *
      * @param strictMode Should we generate this method in strict mode
      */
     private void defineCommonStatics(final boolean strictMode) {
@@ -287,8 +290,8 @@
     }
 
     /**
-     * Define static utilities common needed in scripts.  These are per compile unit
-     * and therefore have to be defined here and not in code gen.
+     * Define static utilities common needed in scripts. These are per compile
+     * unit and therefore have to be defined here and not in code gen.
      */
     private void defineCommonUtilities() {
         assert unitClassName != null;
@@ -336,7 +339,9 @@
     }
 
     /**
-     * Constructs a primitive specific method for getting the ith entry from the constants table as an array.
+     * Constructs a primitive specific method for getting the ith entry from the
+     * constants table as an array.
+     *
      * @param clazz Array class.
      */
     private void defineGetArrayMethod(final Class<?> clazz) {
@@ -359,7 +364,9 @@
 
     /**
      * Generate the name of a get array from constant pool method.
+     *
      * @param clazz Name of array class.
+     *
      * @return Method name.
      */
     static String getArrayMethodName(final Class<?> clazz) {
@@ -369,6 +376,7 @@
 
     /**
      * Ensure a get constant method is issued for the class.
+     *
      * @param clazz Class of constant.
      */
     void needGetConstantMethod(final Class<?> clazz) {
@@ -376,12 +384,12 @@
     }
 
     /**
-     * Inspect class name and decide whether we are generating a ScriptObject class
+     * Inspect class name and decide whether we are generating a ScriptObject class.
      *
      * @param scriptPrefix the script class prefix for the current script
      * @param type         the type to check
      *
-     * @return true if type is ScriptObject
+     * @return {@code true} if type is ScriptObject
      */
     private static boolean isScriptObject(final String scriptPrefix, final String type) {
         if (type.startsWith(scriptPrefix)) {
@@ -396,19 +404,15 @@
     }
 
     /**
-     * Call at beginning of class emission
-     * @see Emitter
+     * Call at beginning of class emission.
      */
-    @Override
     public void begin() {
         classStarted = true;
     }
 
     /**
-     * Call at end of class emission
-     * @see Emitter
+     * Call at end of class emission.
      */
-    @Override
     public void end() {
         assert classStarted : "class not started for " + unitClassName;
 
@@ -431,7 +435,9 @@
 
     /**
      * Disassemble an array of byte code.
+     *
      * @param bytecode  byte array representing bytecode
+     *
      * @return disassembly as human readable string
      */
     static String disassemble(final byte[] bytecode) {
@@ -453,7 +459,7 @@
     }
 
     /**
-     * Call back from MethodEmitter for method start
+     * Call back from MethodEmitter for method start.
      *
      * @see MethodEmitter
      *
@@ -465,7 +471,7 @@
     }
 
     /**
-     * Call back from MethodEmitter for method end
+     * Call back from MethodEmitter for method end.
      *
      * @see MethodEmitter
      *
@@ -477,7 +483,7 @@
     }
 
     /**
-     * Add a new method to the class - defaults to public method
+     * Add a new method to the class - defaults to public method.
      *
      * @param methodName name of method
      * @param rtype      return type of the method
@@ -490,7 +496,7 @@
     }
 
     /**
-     * Add a new method to the class - defaults to public method
+     * Add a new method to the class - defaults to public method.
      *
      * @param methodFlags access flags for the method
      * @param methodName  name of method
@@ -506,7 +512,7 @@
     }
 
     /**
-     * Add a new method to the class - defaults to public method
+     * Add a new method to the class - defaults to public method.
      *
      * @param methodName name of method
      * @param descriptor descriptor of method
@@ -518,7 +524,7 @@
     }
 
     /**
-     * Add a new method to the class - defaults to public method
+     * Add a new method to the class - defaults to public method.
      *
      * @param methodFlags access flags for the method
      * @param methodName  name of method
@@ -533,9 +539,10 @@
     }
 
     /**
-     * Add a new method to the class, representing a function node
+     * Add a new method to the class, representing a function node.
      *
      * @param functionNode the function node to generate a method for
+     *
      * @return method emitter to use for weaving this method
      */
     MethodEmitter method(final FunctionNode functionNode) {
@@ -553,9 +560,11 @@
     }
 
     /**
-     * Add a new method to the class, representing a rest-of version of the function node
+     * Add a new method to the class, representing a rest-of version of the
+     * function node.
      *
      * @param functionNode the function node to generate a method for
+     *
      * @return method emitter to use for weaving this method
      */
     MethodEmitter restOfMethod(final FunctionNode functionNode) {
@@ -573,7 +582,7 @@
 
 
     /**
-     * Start generating the <clinit> method in the class
+     * Start generating the <clinit> method in the class.
      *
      * @return method emitter to use for weaving <clinit>
      */
@@ -583,7 +592,7 @@
     }
 
     /**
-     * Start generating an <init>()V method in the class
+     * Start generating an <init>()V method in the class.
      *
      * @return method emitter to use for weaving <init>()V
      */
@@ -593,7 +602,7 @@
     }
 
     /**
-     * Start generating an <init>()V method in the class
+     * Start generating an <init>()V method in the class.
      *
      * @param ptypes parameter types for constructor
      * @return method emitter to use for weaving <init>()V
@@ -604,7 +613,7 @@
     }
 
     /**
-     * Start generating an <init>(...)V method in the class
+     * Start generating an <init>(...)V method in the class.
      *
      * @param flags  access flags for the constructor
      * @param ptypes parameter types for the constructor
@@ -617,7 +626,7 @@
     }
 
     /**
-     * Add a field to the class, initialized to a value
+     * Add a field to the class, initialized to a value.
      *
      * @param fieldFlags flags, e.g. should it be static or public etc
      * @param fieldName  name of field
@@ -632,7 +641,7 @@
     }
 
     /**
-     * Add a field to the class
+     * Add a field to the class.
      *
      * @param fieldFlags access flags for the field
      * @param fieldName  name of field
@@ -645,7 +654,7 @@
     }
 
     /**
-     * Add a field to the class - defaults to public
+     * Add a field to the class - defaults to public.
      *
      * @param fieldName  name of field
      * @param fieldType  type of field
@@ -658,7 +667,8 @@
      * Return a bytecode array from this ClassEmitter. The ClassEmitter must
      * have been ended (having its end function called) for this to work.
      *
-     * @return byte code array for generated class, null if class generation hasn't been ended with {@link ClassEmitter#end()}
+     * @return byte code array for generated class, {@code null} if class
+     *         generation hasn't been ended with {@link ClassEmitter#end()}.
      */
     byte[] toByteArray() {
         assert classEnded;
@@ -670,13 +680,9 @@
     }
 
     /**
-     * Abstraction for flags used in class emission
-     *
-     * We provide abstraction separating these from the underlying bytecode
-     * emitter.
-     *
-     * Flags are provided for method handles, protection levels, static/virtual
-     * fields/methods.
+     * Abstraction for flags used in class emission. We provide abstraction
+     * separating these from the underlying bytecode emitter. Flags are provided
+     * for method handles, protection levels, static/virtual fields/methods.
      */
     static enum Flag {
         /** method handle with static access */
@@ -714,10 +720,12 @@
         }
 
         /**
-         * Return the corresponding ASM flag value for an enum set of flags
+         * Return the corresponding ASM flag value for an enum set of flags.
          *
          * @param flags enum set of flags
-         * @return an integer value representing the flags intrinsic values or:ed together
+         *
+         * @return an integer value representing the flags intrinsic values
+         *         or:ed together
          */
         static int getValue(final EnumSet<Flag> flags) {
             int v = 0;
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -38,13 +38,11 @@
 import static jdk.nashorn.internal.codegen.CompilerConstants.SPLIT_PREFIX;
 import static jdk.nashorn.internal.codegen.CompilerConstants.THIS;
 import static jdk.nashorn.internal.codegen.CompilerConstants.VARARGS;
-import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.methodDescriptor;
 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor;
 import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 import static jdk.nashorn.internal.ir.Symbol.HAS_SLOT;
 import static jdk.nashorn.internal.ir.Symbol.IS_INTERNAL;
 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
@@ -86,7 +84,6 @@
 import jdk.nashorn.internal.ir.Block;
 import jdk.nashorn.internal.ir.BlockStatement;
 import jdk.nashorn.internal.ir.BreakNode;
-import jdk.nashorn.internal.ir.BreakableNode;
 import jdk.nashorn.internal.ir.CallNode;
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
@@ -103,6 +100,7 @@
 import jdk.nashorn.internal.ir.IndexNode;
 import jdk.nashorn.internal.ir.JoinPredecessorExpression;
 import jdk.nashorn.internal.ir.JumpStatement;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LabelNode;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LexicalContextNode;
@@ -176,8 +174,7 @@
  * This quickly became apparent when the code generator was generalized to work
  * with all types, and not just numbers or objects.
  * <p>
- * The CodeGenerator visits nodes only once, tags them as resolved and emits
- * bytecode for them.
+ * The CodeGenerator visits nodes only once and emits bytecode for them.
  */
 @Logger(name="codegen")
 final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContext> implements Loggable {
@@ -186,9 +183,6 @@
 
     private static final String GLOBAL_OBJECT = Type.getInternalName(Global.class);
 
-    private static final String SCRIPTFUNCTION_IMPL_NAME = Type.getInternalName(ScriptFunctionImpl.class);
-    private static final Type   SCRIPTFUNCTION_IMPL_TYPE   = Type.typeFor(ScriptFunction.class);
-
     private static final Call CREATE_REWRITE_EXCEPTION = CompilerConstants.staticCallNoLookup(RewriteException.class,
             "create", RewriteException.class, UnwarrantedOptimismException.class, Object[].class, String[].class);
     private static final Call CREATE_REWRITE_EXCEPTION_REST_OF = CompilerConstants.staticCallNoLookup(RewriteException.class,
@@ -201,6 +195,17 @@
     private static final Call ENSURE_NUMBER = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class,
             "ensureNumber", double.class, Object.class, int.class);
 
+    private static final Call CREATE_FUNCTION_OBJECT = CompilerConstants.staticCallNoLookup(ScriptFunctionImpl.class,
+            "create", ScriptFunction.class, Object[].class, int.class, ScriptObject.class);
+    private static final Call CREATE_FUNCTION_OBJECT_NO_SCOPE = CompilerConstants.staticCallNoLookup(ScriptFunctionImpl.class,
+            "create", ScriptFunction.class, Object[].class, int.class);
+
+    private static final Call TO_NUMBER_FOR_EQ = CompilerConstants.staticCallNoLookup(JSType.class,
+            "toNumberForEq", double.class, Object.class);
+    private static final Call TO_NUMBER_FOR_STRICT_EQ = CompilerConstants.staticCallNoLookup(JSType.class,
+            "toNumberForStrictEq", double.class, Object.class);
+
+
     private static final Class<?> ITERATOR_CLASS = Iterator.class;
     static {
         assert ITERATOR_CLASS == CompilerConstants.ITERATOR_PREFIX.type();
@@ -291,6 +296,20 @@
     }
 
     /**
+     * Gets the flags for a scope call site.
+     * @param symbol a scope symbol
+     * @return the correct flags for the scope call site
+     */
+    private int getScopeCallSiteFlags(final Symbol symbol) {
+        assert symbol.isScope();
+        final int flags = getCallSiteFlags() | CALLSITE_SCOPE;
+        if (isEvalCode() && symbol.isGlobal()) {
+            return flags; // Don't set fast-scope flag on non-declared globals in eval code - see JDK-8077955.
+        }
+        return isFastScope(symbol) ? flags | CALLSITE_FAST_SCOPE : flags;
+    }
+
+    /**
      * Are we generating code for 'eval' code?
      * @return true if currently compiled code is 'eval' code.
      */
@@ -299,6 +318,14 @@
     }
 
     /**
+     * Are we using dual primitive/object field representation?
+     * @return true if using dual field representation, false for object-only fields
+     */
+    boolean useDualFields() {
+        return compiler.getContext().useDualFields();
+    }
+
+    /**
      * Load an identity node
      *
      * @param identNode an identity node to load
@@ -319,7 +346,7 @@
         }
 
         assert identNode.getSymbol().isScope() : identNode + " is not in scope!";
-        final int flags = CALLSITE_SCOPE | getCallSiteFlags();
+        final int flags = getScopeCallSiteFlags(symbol);
         if (isFastScope(symbol)) {
             // Only generate shared scope getter for fast-scope symbols so we know we can dial in correct scope.
             if (symbol.getUseCount() > SharedScopeCall.FAST_SCOPE_GET_THRESHOLD && !isOptimisticOrRestOf()) {
@@ -342,8 +369,14 @@
     // This is called the temporal dead zone (TDZ). See https://gist.github.com/rwaldron/f0807a758aa03bcdd58a
     private void checkTemporalDeadZone(final IdentNode identNode) {
         if (identNode.isDead()) {
-            method.load(identNode.getSymbol().getName());
-            method.invoke(ScriptRuntime.THROW_REFERENCE_ERROR);
+            method.load(identNode.getSymbol().getName()).invoke(ScriptRuntime.THROW_REFERENCE_ERROR);
+        }
+    }
+
+    // Runtime check for assignment to ES6 const
+    private void checkAssignTarget(final Expression expression) {
+        if (expression instanceof IdentNode && ((IdentNode)expression).getSymbol().isConst()) {
+            method.load(((IdentNode)expression).getSymbol().getName()).invoke(ScriptRuntime.THROW_CONST_TYPE_ERROR);
         }
     }
 
@@ -437,7 +470,7 @@
         } else {
             method.load(-1);
         }
-        return lc.getScopeGet(unit, symbol, valueType, flags | CALLSITE_FAST_SCOPE).generateInvoke(method);
+        return lc.getScopeGet(unit, symbol, valueType, flags).generateInvoke(method);
     }
 
     private class LoadScopeVar extends OptimisticOperation {
@@ -475,7 +508,7 @@
 
     private class LoadFastScopeVar extends LoadScopeVar {
         LoadFastScopeVar(final IdentNode identNode, final TypeBounds resultBounds, final int flags) {
-            super(identNode, resultBounds, flags | CALLSITE_FAST_SCOPE);
+            super(identNode, resultBounds, flags);
         }
 
         @Override
@@ -486,7 +519,7 @@
 
     private MethodEmitter storeFastScopeVar(final Symbol symbol, final int flags) {
         loadFastScopeProto(symbol, true);
-        method.dynamicSet(symbol.getName(), flags | CALLSITE_FAST_SCOPE, false);
+        method.dynamicSet(symbol.getName(), flags, false);
         return method;
     }
 
@@ -611,6 +644,104 @@
         return method;
     }
 
+    /**
+     * Similar to {@link #loadBinaryOperands(BinaryNode)} but used specifically for loading operands of
+     * relational and equality comparison operators where at least one argument is non-object. (When both
+     * arguments are objects, we use {@link ScriptRuntime#EQ(Object, Object)}, {@link ScriptRuntime#LT(Object, Object)}
+     * etc. methods instead. Additionally, {@code ScriptRuntime} methods are used for strict (in)equality comparison
+     * of a boolean to anything that isn't a boolean.) This method handles the special case where one argument
+     * is an object and another is a primitive. Naively, these could also be delegated to {@code ScriptRuntime} methods
+     * by boxing the primitive. However, in all such cases the comparison is performed on numeric values, so it is
+     * possible to strength-reduce the operation by taking the number value of the object argument instead and
+     * comparing that to the primitive value ("primitive" will always be int, long, double, or boolean, and booleans
+     * compare as ints in these cases, so they're essentially numbers too). This method will emit code for loading
+     * arguments for such strength-reduced comparison. When both arguments are primitives, it just delegates to
+     * {@link #loadBinaryOperands(BinaryNode)}.
+     *
+     * @param cmp the comparison operation for which the operands need to be loaded on stack.
+     * @return the current method emitter.
+     */
+    MethodEmitter loadComparisonOperands(final BinaryNode cmp) {
+        final Expression lhs = cmp.lhs();
+        final Expression rhs = cmp.rhs();
+        final Type lhsType = lhs.getType();
+        final Type rhsType = rhs.getType();
+
+        // Only used when not both are object, for that we have ScriptRuntime.LT etc.
+        assert !(lhsType.isObject() && rhsType.isObject());
+
+        if (lhsType.isObject() || rhsType.isObject()) {
+            // We can reorder CONVERT LEFT and LOAD RIGHT only if either the left is a primitive, or the right
+            // is a local. This is more strict than loadBinaryNode reorder criteria, as it can allow JS primitive
+            // types too (notably: String is a JS primitive, but not a JVM primitive). We disallow String otherwise
+            // we would prematurely convert it to number when comparing to an optimistic expression, e.g. in
+            // "Hello" === String("Hello") the RHS starts out as an optimistic-int function call. If we allowed
+            // reordering, we'd end up with ToNumber("Hello") === {I%}String("Hello") that is obviously incorrect.
+            final boolean canReorder = lhsType.isPrimitive() || rhs.isLocal();
+            // If reordering is allowed, and we're using a relational operator (that is, <, <=, >, >=) and not an
+            // (in)equality operator, then we encourage combining of LOAD and CONVERT into a single operation.
+            // This is because relational operators' semantics prescribes vanilla ToNumber() conversion, while
+            // (in)equality operators need the specialized JSType.toNumberFor[Strict]Equals. E.g. in the code snippet
+            // "i < obj.size" (where i is primitive and obj.size is statically an object), ".size" will thus be allowed
+            // to compile as:
+            //   invokedynamic dyn:getProp|getElem|getMethod:size(Object;)D
+            // instead of the more costly:
+            //   invokedynamic dyn:getProp|getElem|getMethod:size(Object;)Object
+            //   invokestatic JSType.toNumber(Object)D
+            // Note also that even if this is allowed, we're only using it on operands that are non-optimistic, as
+            // otherwise the logic for determining effective optimistic-ness would turn an optimistic double return
+            // into a freely coercible one, which would be wrong.
+            final boolean canCombineLoadAndConvert = canReorder && cmp.isRelational();
+
+            // LOAD LEFT
+            loadExpression(lhs, canCombineLoadAndConvert && !lhs.isOptimistic() ? TypeBounds.NUMBER : TypeBounds.UNBOUNDED);
+
+            final Type lhsLoadedType = method.peekType();
+            final TokenType tt = cmp.tokenType();
+            if (canReorder) {
+                // Can reorder CONVERT LEFT and LOAD RIGHT
+                emitObjectToNumberComparisonConversion(method, tt);
+                loadExpression(rhs, canCombineLoadAndConvert && !rhs.isOptimistic() ? TypeBounds.NUMBER : TypeBounds.UNBOUNDED);
+            } else {
+                // Can't reorder CONVERT LEFT and LOAD RIGHT
+                loadExpression(rhs, TypeBounds.UNBOUNDED);
+                if (lhsLoadedType != Type.NUMBER) {
+                    method.swap();
+                    emitObjectToNumberComparisonConversion(method, tt);
+                    method.swap();
+                }
+            }
+
+            // CONVERT RIGHT
+            emitObjectToNumberComparisonConversion(method, tt);
+            return method;
+        }
+        // For primitive operands, just don't do anything special.
+        return loadBinaryOperands(cmp);
+    }
+
+    private static void emitObjectToNumberComparisonConversion(final MethodEmitter method, final TokenType tt) {
+        switch(tt) {
+        case EQ:
+        case NE:
+            if (method.peekType().isObject()) {
+                TO_NUMBER_FOR_EQ.invoke(method);
+                return;
+            }
+            break;
+        case EQ_STRICT:
+        case NE_STRICT:
+            if (method.peekType().isObject()) {
+                TO_NUMBER_FOR_STRICT_EQ.invoke(method);
+                return;
+            }
+            break;
+        default:
+            break;
+        }
+        method.convert(Type.NUMBER);
+    }
+
     private static final Type undefinedToNumber(final Type type) {
         return type == Type.UNDEFINED ? Type.NUMBER : type;
     }
@@ -621,6 +752,7 @@
 
         static final TypeBounds UNBOUNDED = new TypeBounds(Type.UNKNOWN, Type.OBJECT);
         static final TypeBounds INT = exact(Type.INT);
+        static final TypeBounds NUMBER = exact(Type.NUMBER);
         static final TypeBounds OBJECT = exact(Type.OBJECT);
         static final TypeBounds BOOLEAN = exact(Type.BOOLEAN);
 
@@ -724,7 +856,7 @@
          */
         final CodeGenerator codegen = this;
 
-        final Node currentDiscard = codegen.lc.getCurrentDiscard();
+        final boolean isCurrentDiscard = codegen.lc.isCurrentDiscard(expr);
         expr.accept(new NodeOperatorVisitor<LexicalContext>(new LexicalContext()) {
             @Override
             public boolean enterIdentNode(final IdentNode identNode) {
@@ -786,72 +918,84 @@
 
             @Override
             public boolean enterASSIGN(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_ADD(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_ADD(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_BIT_AND(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_BIT_AND(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_BIT_OR(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_BIT_OR(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_BIT_XOR(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_BIT_XOR(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_DIV(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_DIV(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_MOD(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_MOD(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_MUL(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_MUL(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_SAR(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_SAR(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_SHL(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_SHL(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_SHR(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_SHR(binaryNode);
                 return false;
             }
 
             @Override
             public boolean enterASSIGN_SUB(final BinaryNode binaryNode) {
+                checkAssignTarget(binaryNode.lhs());
                 loadASSIGN_SUB(binaryNode);
                 return false;
             }
@@ -1061,13 +1205,14 @@
 
             @Override
             public boolean enterDECINC(final UnaryNode unaryNode) {
+                checkAssignTarget(unaryNode.getExpression());
                 loadDECINC(unaryNode);
                 return false;
             }
 
             @Override
             public boolean enterJoinPredecessorExpression(final JoinPredecessorExpression joinExpr) {
-                loadExpression(joinExpr.getExpression(), resultBounds);
+                loadMaybeDiscard(joinExpr, joinExpr.getExpression(), resultBounds);
                 return false;
             }
 
@@ -1084,7 +1229,7 @@
                 throw new AssertionError(otherNode.getClass().getName());
             }
         });
-        if(currentDiscard != expr) {
+        if(!isCurrentDiscard) {
             coerceStackTop(resultBounds);
         }
         return method;
@@ -1109,7 +1254,14 @@
 
     @Override
     public boolean enterBlock(final Block block) {
-        method.label(block.getEntryLabel());
+        final Label entryLabel = block.getEntryLabel();
+        if (entryLabel.isBreakTarget()) {
+            // Entry label is a break target only for an inlined finally block.
+            assert !method.isReachable();
+            method.breakLabel(entryLabel, lc.getUsedSlotCount());
+        } else {
+            method.label(entryLabel);
+        }
         if(!method.isReachable()) {
             return false;
         }
@@ -1122,7 +1274,7 @@
         return true;
     }
 
-    private boolean useOptimisticTypes() {
+    boolean useOptimisticTypes() {
         return !lc.inSplitNode() && compiler.useOptimisticTypes();
     }
 
@@ -1239,6 +1391,11 @@
         return enterJumpStatement(breakNode);
     }
 
+    @Override
+    public boolean enterJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        return enterJumpStatement(jumpToInlinedFinally);
+    }
+
     private boolean enterJumpStatement(final JumpStatement jump) {
         if(!method.isReachable()) {
             return false;
@@ -1246,9 +1403,8 @@
         enterStatement(jump);
 
         method.beforeJoinPoint(jump);
-        final BreakableNode target = jump.getTarget(lc);
-        popScopesUntil(target);
-        final Label targetLabel = jump.getTargetLabel(target);
+        popScopesUntil(jump.getPopScopeLimit(lc));
+        final Label targetLabel = jump.getTargetLabel(lc);
         targetLabel.markAsBreakTarget();
         method._goto(targetLabel);
 
@@ -1283,7 +1439,6 @@
             private MethodEmitter sharedScopeCall(final IdentNode identNode, final int flags) {
                 final Symbol symbol = identNode.getSymbol();
                 final boolean isFastScope = isFastScope(symbol);
-                final int scopeCallFlags = flags | (isFastScope ? CALLSITE_FAST_SCOPE : 0);
                 new OptimisticOperation(callNode, resultBounds) {
                     @Override
                     void loadStack() {
@@ -1306,7 +1461,7 @@
                         // As shared scope calls are only used in non-optimistic compilation, we switch from using
                         // TypeBounds to just a single definitive type, resultBounds.widest.
                         final SharedScopeCall scopeCall = codegenLexicalContext.getScopeCall(unit, symbol,
-                                identNode.getType(), resultBounds.widest, paramTypes, scopeCallFlags);
+                                identNode.getType(), resultBounds.widest, paramTypes, flags);
                         scopeCall.generateInvoke(method);
                     }
                 }.emit();
@@ -1407,7 +1562,7 @@
                 final Symbol symbol = node.getSymbol();
 
                 if (symbol.isScope()) {
-                    final int flags = getCallSiteFlags() | CALLSITE_SCOPE;
+                    final int flags = getScopeCallSiteFlags(symbol);
                     final int useCount = symbol.getUseCount();
 
                     // Threshold for generating shared scope callsite is lower for fast scope symbols because we know
@@ -1558,11 +1713,7 @@
 
     @Override
     public boolean enterEmptyNode(final EmptyNode emptyNode) {
-        if(!method.isReachable()) {
-            return false;
-        }
-        enterStatement(emptyNode);
-
+        // Don't even record the line number, it's irrelevant as there's no code.
         return false;
     }
 
@@ -1760,10 +1911,10 @@
                         //this symbol will be put fielded, we can't initialize it as undefined with a known type
                         @Override
                         public Class<?> getValueType() {
-                            if (OBJECT_FIELDS_ONLY || value == null || paramType == null) {
+                            if (!useDualFields() ||  value == null || paramType == null || paramType.isBoolean()) {
                                 return Object.class;
                             }
-                            return paramType.isBoolean() ? Object.class : paramType.getTypeClass();
+                            return paramType.getTypeClass();
                         }
                     });
                 }
@@ -2242,7 +2393,6 @@
         } else {
             methodEmitter.loadConstants().load(index).arrayload();
             if (object instanceof ArrayData) {
-                // avoid cast to non-public ArrayData subclass
                 methodEmitter.checkcast(ArrayData.class);
                 methodEmitter.invoke(virtualCallNoLookup(ArrayData.class, "copy", ArrayData.class));
             } else if (cls != Object.class) {
@@ -2251,6 +2401,10 @@
         }
     }
 
+    private void loadConstantsAndIndex(final Object object, final MethodEmitter methodEmitter) {
+        methodEmitter.loadConstants().load(compiler.getConstantData().add(object));
+    }
+
     // literal values
     private void loadLiteral(final LiteralNode<?> node, final TypeBounds resultBounds) {
         final Object value = node.getValue();
@@ -2416,7 +2570,7 @@
 
             //for literals, a value of null means object type, i.e. the value null or getter setter function
             //(I think)
-            final Class<?> valueType = (OBJECT_FIELDS_ONLY || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass();
+            final Class<?> valueType = (!useDualFields() || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass();
             tuples.add(new MapTuple<Expression>(key, symbol, Type.typeFor(valueType), value) {
                 @Override
                 public Class<?> getValueType() {
@@ -2488,8 +2642,6 @@
         }
         enterStatement(returnNode);
 
-        method.registerReturn();
-
         final Type returnType = lc.getCurrentFunction().getReturnType();
 
         final Expression expression = returnNode.getExpression();
@@ -2722,25 +2874,18 @@
             newRuntimeNode = runtimeNode;
         }
 
-        new OptimisticOperation(newRuntimeNode, TypeBounds.UNBOUNDED) {
-            @Override
-            void loadStack() {
-                for (final Expression arg : args) {
-                    loadExpression(arg, TypeBounds.OBJECT);
-                }
-            }
-            @Override
-            void consumeStack() {
-                method.invokestatic(
-                        CompilerConstants.className(ScriptRuntime.class),
-                        newRuntimeNode.getRequest().toString(),
-                        new FunctionSignature(
-                            false,
-                            false,
-                            newRuntimeNode.getType(),
-                            args.size()).toString());
-            }
-        }.emit();
+        for (final Expression arg : args) {
+            loadExpression(arg, TypeBounds.OBJECT);
+        }
+
+        method.invokestatic(
+                CompilerConstants.className(ScriptRuntime.class),
+                newRuntimeNode.getRequest().toString(),
+                new FunctionSignature(
+                    false,
+                    false,
+                    newRuntimeNode.getType(),
+                    args.size()).toString());
 
         method.convert(newRuntimeNode.getType());
     }
@@ -3049,6 +3194,14 @@
         if (method.isReachable()) {
             method._goto(skip);
         }
+
+        for (final Block inlinedFinally : tryNode.getInlinedFinallies()) {
+            TryNode.getLabelledInlinedFinallyBlock(inlinedFinally).accept(this);
+            // All inlined finallies end with a jump or a return
+            assert !method.isReachable();
+        }
+
+
         method._catch(recovery);
         method.store(vmException, EXCEPTION_TYPE);
 
@@ -3099,6 +3252,7 @@
             if (isConditionalCatch) {
                 loadExpressionAsBoolean(exceptionCondition);
                 nextCatch = new Label("next_catch");
+                nextCatch.markAsBreakTarget();
                 method.ifeq(nextCatch);
             } else {
                 nextCatch = null;
@@ -3107,15 +3261,14 @@
             catchBody.accept(this);
             leaveBlock(catchBlock);
             lc.pop(catchBlock);
-            if(method.isReachable()) {
-                method._goto(afterCatch);
-            }
             if(nextCatch != null) {
-                method.label(nextCatch);
-            }
-        }
-
-        assert !method.isReachable();
+                if(method.isReachable()) {
+                    method._goto(afterCatch);
+                }
+                method.breakLabel(nextCatch, lc.getUsedSlotCount());
+            }
+        }
+
         // afterCatch could be the same as skip, except that we need to establish that the vmException is dead.
         method.label(afterCatch);
         if(method.isReachable()) {
@@ -3124,6 +3277,8 @@
         method.label(skip);
 
         // Finally body is always inlined elsewhere so it doesn't need to be emitted
+        assert tryNode.getFinallyBody() == null;
+
         return false;
     }
 
@@ -3143,7 +3298,7 @@
                 // block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ)
                 method.loadCompilerConstant(SCOPE);
                 method.loadUndefined(Type.OBJECT);
-                final int flags = CALLSITE_SCOPE | getCallSiteFlags() | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
+                final int flags = getScopeCallSiteFlags(identSymbol) | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
                 assert isFastScope(identSymbol);
                 storeFastScopeVar(identSymbol, flags);
             }
@@ -3160,7 +3315,7 @@
         if (needsScope) {
             loadExpressionUnbounded(init);
             // block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ)
-            final int flags = CALLSITE_SCOPE | getCallSiteFlags() | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
+            final int flags = getScopeCallSiteFlags(identSymbol) | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
             if (isFastScope(identSymbol)) {
                 storeFastScopeVar(identSymbol, flags);
             } else {
@@ -3506,7 +3661,7 @@
         // TODO: move checks for discarding to actual expression load code (e.g. as we do with void). That way we might
         // be able to eliminate even more checks.
         if(expr instanceof PrimitiveLiteralNode | isLocalVariable(expr)) {
-            assert lc.getCurrentDiscard() != expr;
+            assert !lc.isCurrentDiscard(expr);
             // Don't bother evaluating expressions without side effects. Typical usage is "void 0" for reliably generating
             // undefined.
             return;
@@ -3514,11 +3669,37 @@
 
         lc.pushDiscard(expr);
         loadExpression(expr, TypeBounds.UNBOUNDED);
-        if (lc.getCurrentDiscard() == expr) {
+        if (lc.popDiscardIfCurrent(expr)) {
             assert !expr.isAssignment();
             // NOTE: if we had a way to load with type void, we could avoid popping
             method.pop();
-            lc.popDiscard();
+        }
+    }
+
+    /**
+     * Loads the expression with the specified type bounds, but if the parent expression is the current discard,
+     * then instead loads and discards the expression.
+     * @param parent the parent expression that's tested for being the current discard
+     * @param expr the expression that's either normally loaded or discard-loaded
+     * @param resultBounds result bounds for when loading the expression normally
+     */
+    private void loadMaybeDiscard(final Expression parent, final Expression expr, final TypeBounds resultBounds) {
+        loadMaybeDiscard(lc.popDiscardIfCurrent(parent), expr, resultBounds);
+    }
+
+    /**
+     * Loads the expression with the specified type bounds, or loads and discards the expression, depending on the
+     * value of the discard flag. Useful as a helper for expressions with control flow where you often can't combine
+     * testing for being the current discard and loading the subexpressions.
+     * @param discard if true, the expression is loaded and discarded
+     * @param expr the expression that's either normally loaded or discard-loaded
+     * @param resultBounds result bounds for when loading the expression normally
+     */
+    private void loadMaybeDiscard(final boolean discard, final Expression expr, final TypeBounds resultBounds) {
+        if (discard) {
+            loadAndDiscard(expr);
+        } else {
+            loadExpression(expr, resultBounds);
         }
     }
 
@@ -3575,9 +3756,7 @@
 
     public void loadVOID(final UnaryNode unaryNode, final TypeBounds resultBounds) {
         loadAndDiscard(unaryNode.getExpression());
-        if(lc.getCurrentDiscard() == unaryNode) {
-            lc.popDiscard();
-        } else {
+        if (!lc.popDiscardIfCurrent(unaryNode)) {
             method.loadUndefined(resultBounds.widest);
         }
     }
@@ -3610,16 +3789,22 @@
     private void loadAND_OR(final BinaryNode binaryNode, final TypeBounds resultBounds, final boolean isAnd) {
         final Type narrowestOperandType = Type.widestReturnType(binaryNode.lhs().getType(), binaryNode.rhs().getType());
 
+        final boolean isCurrentDiscard = lc.popDiscardIfCurrent(binaryNode);
+
         final Label skip = new Label("skip");
         if(narrowestOperandType == Type.BOOLEAN) {
             // optimize all-boolean logical expressions
             final Label onTrue = new Label("andor_true");
             emitBranch(binaryNode, onTrue, true);
-            method.load(false);
-            method._goto(skip);
-            method.label(onTrue);
-            method.load(true);
-            method.label(skip);
+            if (isCurrentDiscard) {
+                method.label(onTrue);
+            } else {
+                method.load(false);
+                method._goto(skip);
+                method.label(onTrue);
+                method.load(true);
+                method.label(skip);
+            }
             return;
         }
 
@@ -3628,7 +3813,11 @@
         final boolean lhsConvert = LocalVariableConversion.hasLiveConversion(lhs);
         final Label evalRhs = lhsConvert ? new Label("eval_rhs") : null;
 
-        loadExpression(lhs, outBounds).dup().convert(Type.BOOLEAN);
+        loadExpression(lhs, outBounds);
+        if (!isCurrentDiscard) {
+            method.dup();
+        }
+        method.convert(Type.BOOLEAN);
         if (isAnd) {
             if(lhsConvert) {
                 method.ifne(evalRhs);
@@ -3647,9 +3836,11 @@
             method.label(evalRhs);
         }
 
-        method.pop();
+        if (!isCurrentDiscard) {
+            method.pop();
+        }
         final JoinPredecessorExpression rhs = (JoinPredecessorExpression)binaryNode.rhs();
-        loadExpression(rhs, outBounds);
+        loadMaybeDiscard(isCurrentDiscard, rhs, outBounds);
         method.beforeJoinPoint(rhs);
         method.label(skip);
     }
@@ -3671,9 +3862,8 @@
         // Detect dead assignments
         if(lhs instanceof IdentNode) {
             final Symbol symbol = ((IdentNode)lhs).getSymbol();
-            if(!symbol.isScope() && !symbol.hasSlotFor(rhsType) && lc.getCurrentDiscard() == binaryNode) {
+            if(!symbol.isScope() && !symbol.hasSlotFor(rhsType) && lc.popDiscardIfCurrent(binaryNode)) {
                 loadAndDiscard(rhs);
-                lc.popDiscard();
                 method.markDeadLocalVariable(symbol);
                 return;
             }
@@ -3927,11 +4117,11 @@
 
     private void loadCOMMARIGHT(final BinaryNode binaryNode, final TypeBounds resultBounds) {
         loadAndDiscard(binaryNode.lhs());
-        loadExpression(binaryNode.rhs(), resultBounds);
+        loadMaybeDiscard(binaryNode, binaryNode.rhs(), resultBounds);
     }
 
     private void loadCOMMALEFT(final BinaryNode binaryNode, final TypeBounds resultBounds) {
-        loadExpression(binaryNode.lhs(), resultBounds);
+        loadMaybeDiscard(binaryNode, binaryNode.lhs(), resultBounds);
         loadAndDiscard(binaryNode.rhs());
     }
 
@@ -3945,8 +4135,7 @@
     }
 
     private void loadCmp(final BinaryNode binaryNode, final Condition cond) {
-        assert comparisonOperandsArePrimitive(binaryNode) : binaryNode;
-        loadBinaryOperands(binaryNode);
+        loadComparisonOperands(binaryNode);
 
         final Label trueLabel  = new Label("trueLabel");
         final Label afterLabel = new Label("skip");
@@ -3960,11 +4149,6 @@
         method.label(afterLabel);
     }
 
-    private static boolean comparisonOperandsArePrimitive(final BinaryNode binaryNode) {
-        final Type widest = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType());
-        return widest.isNumeric() || widest.isBoolean();
-    }
-
     private void loadMOD(final BinaryNode binaryNode, final TypeBounds resultBounds) {
         new BinaryArith() {
             @Override
@@ -4037,13 +4221,14 @@
 
         emitBranch(test, falseLabel, false);
 
-        loadExpression(trueExpr.getExpression(), outBounds);
-        assert Type.generic(method.peekType()) == outBounds.narrowest;
+        final boolean isCurrentDiscard = lc.popDiscardIfCurrent(ternaryNode);
+        loadMaybeDiscard(isCurrentDiscard, trueExpr.getExpression(), outBounds);
+        assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
         method.beforeJoinPoint(trueExpr);
         method._goto(exitLabel);
         method.label(falseLabel);
-        loadExpression(falseExpr.getExpression(), outBounds);
-        assert Type.generic(method.peekType()) == outBounds.narrowest;
+        loadMaybeDiscard(isCurrentDiscard, falseExpr.getExpression(), outBounds);
+        assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
         method.beforeJoinPoint(falseExpr);
         method.label(exitLabel);
     }
@@ -4229,9 +4414,8 @@
 
         // store the result that "lives on" after the op, e.g. "i" in i++ postfix.
         protected void storeNonDiscard() {
-            if (lc.getCurrentDiscard() == assignNode) {
+            if (lc.popDiscardIfCurrent(assignNode)) {
                 assert assignNode.isAssignment();
-                lc.popDiscard();
                 return;
             }
 
@@ -4264,7 +4448,7 @@
                     final Symbol symbol = node.getSymbol();
                     assert symbol != null;
                     if (symbol.isScope()) {
-                        final int flags = CALLSITE_SCOPE | getCallSiteFlags();
+                        final int flags = getScopeCallSiteFlags(symbol);
                         if (isFastScope(symbol)) {
                             storeFastScopeVar(symbol, flags);
                         } else {
@@ -4322,21 +4506,19 @@
         final RecompilableScriptFunctionData data = compiler.getScriptFunctionData(functionNode.getId());
 
         if (functionNode.isProgram() && !compiler.isOnDemandCompilation()) {
-            final CompileUnit fnUnit = functionNode.getCompileUnit();
-            final MethodEmitter createFunction = fnUnit.getClassEmitter().method(
+            final MethodEmitter createFunction = functionNode.getCompileUnit().getClassEmitter().method(
                     EnumSet.of(Flag.PUBLIC, Flag.STATIC), CREATE_PROGRAM_FUNCTION.symbolName(),
                     ScriptFunction.class, ScriptObject.class);
             createFunction.begin();
-            createFunction._new(SCRIPTFUNCTION_IMPL_NAME, SCRIPTFUNCTION_IMPL_TYPE).dup();
-            loadConstant(data, fnUnit, createFunction);
+            loadConstantsAndIndex(data, createFunction);
             createFunction.load(SCOPE_TYPE, 0);
-            createFunction.invoke(constructorNoLookup(SCRIPTFUNCTION_IMPL_NAME, RecompilableScriptFunctionData.class, ScriptObject.class));
+            createFunction.invoke(CREATE_FUNCTION_OBJECT);
             createFunction._return();
             createFunction.end();
         }
 
         if (addInitializer && !compiler.isOnDemandCompilation()) {
-            compiler.addFunctionInitializer(data, functionNode);
+            functionNode.getCompileUnit().addFunctionInitializer(data, functionNode);
         }
 
         // We don't emit a ScriptFunction on stack for the outermost compiled function (as there's no code being
@@ -4345,15 +4527,14 @@
             return;
         }
 
-        method._new(SCRIPTFUNCTION_IMPL_NAME, SCRIPTFUNCTION_IMPL_TYPE).dup();
-        loadConstant(data);
+        loadConstantsAndIndex(data, method);
 
         if (functionNode.needsParentScope()) {
             method.loadCompilerConstant(SCOPE);
+            method.invoke(CREATE_FUNCTION_OBJECT);
         } else {
-            method.loadNull();
-        }
-        method.invoke(constructorNoLookup(SCRIPTFUNCTION_IMPL_NAME, RecompilableScriptFunctionData.class, ScriptObject.class));
+            method.invoke(CREATE_FUNCTION_OBJECT_NO_SCOPE);
+        }
     }
 
     // calls on Global class.
--- a/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java	Fri Nov 13 15:38:44 2015 -0800
@@ -34,6 +34,7 @@
 import jdk.nashorn.internal.IntDeque;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.Block;
+import jdk.nashorn.internal.ir.Expression;
 import jdk.nashorn.internal.ir.FunctionNode;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LexicalContextNode;
@@ -59,9 +60,11 @@
     /** Method emitter stack - every time we start a sub method (e.g. a split) we push one */
     private final Deque<MethodEmitter> methodEmitters = new ArrayDeque<>();
 
-    /** The discard stack - whenever we enter a discard node we keep track of its return value status -
-     *  i.e. should we keep it or throw it away */
-    private final Deque<Node> discard = new ArrayDeque<>();
+    /** The discard stack - whenever we evaluate an expression that will be discarded, we push it on this stack. Various
+     * implementations of expression code emitter can choose to emit code that'll discard the expression themselves, or
+     * ignore it in which case CodeGenerator.loadAndDiscard() will explicitly emit a pop instruction. */
+    private final Deque<Expression> discard = new ArrayDeque<>();
+
 
     private final Deque<Map<String, Collection<Label>>> unwarrantedOptimismHandlers = new ArrayDeque<>();
     private final Deque<StringBuilder> slotTypesDescriptors = new ArrayDeque<>();
@@ -74,7 +77,7 @@
     /** size of next free slot vector */
     private int nextFreeSlotsSize;
 
-    private boolean isWithBoundary(final LexicalContextNode node) {
+    private boolean isWithBoundary(final Object node) {
         return node instanceof Block && !isEmpty() && peek() instanceof WithNode;
     }
 
@@ -102,7 +105,7 @@
     }
 
     @Override
-    public <T extends LexicalContextNode> T pop(final T node) {
+    public <T extends Node> T pop(final T node) {
         final T popped = super.pop(node);
         if (isWithBoundary(node)) {
             dynamicScopeCount--;
@@ -270,16 +273,20 @@
         }
     }
 
-    void pushDiscard(final Node node) {
-        discard.push(node);
+    void pushDiscard(final Expression expr) {
+        discard.push(expr);
     }
 
-    Node popDiscard() {
-        return discard.pop();
+    boolean popDiscardIfCurrent(final Expression expr) {
+        if (isCurrentDiscard(expr)) {
+            discard.pop();
+            return true;
+        }
+        return false;
     }
 
-    Node getCurrentDiscard() {
-        return discard.peek();
+    boolean isCurrentDiscard(final Expression expr) {
+        return discard.peek() == expr;
     }
 
     int quickSlot(final Type type) {
--- a/src/jdk/nashorn/internal/codegen/CompilationPhase.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/CompilationPhase.java	Fri Nov 13 15:38:44 2015 -0800
@@ -57,7 +57,6 @@
 import jdk.nashorn.internal.ir.debug.PrintVisitor;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
 import jdk.nashorn.internal.runtime.CodeInstaller;
-import jdk.nashorn.internal.runtime.FunctionInitializer;
 import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData;
 import jdk.nashorn.internal.runtime.ScriptEnvironment;
 import jdk.nashorn.internal.runtime.logging.DebugLogger;
@@ -364,7 +363,7 @@
             //partial code generation
             final FunctionNode newFunctionNode = transformFunction(fn, new ReplaceCompileUnits() {
                 @Override
-                CompileUnit getReplacement(CompileUnit original) {
+                CompileUnit getReplacement(final CompileUnit original) {
                     return map.get(original);
                 }
 
@@ -581,18 +580,7 @@
                     continue;
                 }
                 unit.setCode(installedClasses.get(unit.getUnitClassName()));
-            }
-
-            if (!compiler.isOnDemandCompilation()) {
-                // Initialize functions
-                final Map<Integer, FunctionInitializer> initializers = compiler.getFunctionInitializers();
-                if (initializers != null) {
-                    for (final Entry<Integer, FunctionInitializer> entry : initializers.entrySet()) {
-                        final FunctionInitializer initializer = entry.getValue();
-                        initializer.setCode(installedClasses.get(initializer.getClassName()));
-                        compiler.getScriptFunctionData(entry.getKey()).initializeCode(initializer);
-                    }
-                }
+                unit.initializeFunctionsCode();
             }
 
             if (log.isEnabled()) {
--- a/src/jdk/nashorn/internal/codegen/CompileUnit.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/CompileUnit.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,9 +26,16 @@
 package jdk.nashorn.internal.codegen;
 
 import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
 import jdk.nashorn.internal.ir.CompileUnitHolder;
+import jdk.nashorn.internal.ir.FunctionNode;
+import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData;
 
 /**
   * Used to track split class compilation. Note that instances of the class are serializable, but all fields are
@@ -49,6 +56,8 @@
 
     private transient Class<?> clazz;
 
+    private transient Map<FunctionNode, RecompilableScriptFunctionData> functions = new IdentityHashMap<>();
+
     private transient boolean isUsed;
 
     private static int emittedUnitCount;
@@ -113,13 +122,38 @@
      * @param clazz class with code for this compile unit
      */
     void setCode(final Class<?> clazz) {
-        clazz.getClass(); // null check
-        this.clazz = clazz;
+        this.clazz = Objects.requireNonNull(clazz);
         // Revisit this - refactor to avoid null-ed out non-final fields
         // null out emitter
         this.classEmitter = null;
     }
 
+    void addFunctionInitializer(final RecompilableScriptFunctionData data, final FunctionNode functionNode) {
+        functions.put(functionNode, data);
+    }
+
+    /**
+     * Returns true if this compile unit is responsible for initializing the specified function data with specified
+     * function node.
+     * @param data the function data to check
+     * @param functionNode the function node to check
+     * @return true if this unit is responsible for initializing the function data with the function node, otherwise
+     * false
+     */
+    public boolean isInitializing(final RecompilableScriptFunctionData data, final FunctionNode functionNode) {
+        return functions.get(functionNode) == data;
+    }
+
+    void initializeFunctionsCode() {
+        for(final Map.Entry<FunctionNode, RecompilableScriptFunctionData> entry : functions.entrySet()) {
+            entry.getValue().initializeCode(entry.getKey());
+        }
+    }
+
+    Collection<FunctionNode> getFunctionNodes() {
+        return Collections.unmodifiableCollection(functions.keySet());
+    }
+
     /**
      * Add weight to this compile unit
      * @param w weight to add
--- a/src/jdk/nashorn/internal/codegen/Compiler.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/Compiler.java	Fri Nov 13 15:38:44 2015 -0800
@@ -103,7 +103,7 @@
 
     private final CodeInstaller<ScriptEnvironment> installer;
 
-    /** logger for compiler, trampolines, splits and related code generation events
+    /** logger for compiler, trampolines and related code generation events
      *  that affect classes */
     private final DebugLogger log;
 
@@ -565,7 +565,7 @@
      * @return a copy of this compiler's current mapping of invalidated optimistic program points to their types.
      */
     public Map<Integer, Type> getInvalidatedProgramPoints() {
-        return invalidatedProgramPoints == null ? null : new TreeMap<>(invalidatedProgramPoints);
+        return invalidatedProgramPoints.isEmpty() ? null : new TreeMap<>(invalidatedProgramPoints);
     }
 
     TypeMap getTypeMap() {
@@ -704,21 +704,6 @@
         return sb.toString();
     }
 
-    Map<Integer, FunctionInitializer> functionInitializers;
-
-    void addFunctionInitializer(final RecompilableScriptFunctionData functionData, final FunctionNode functionNode) {
-        if (functionInitializers == null) {
-            functionInitializers = new HashMap<>();
-        }
-        if (!functionInitializers.containsKey(functionData)) {
-            functionInitializers.put(functionData.getFunctionNodeId(), new FunctionInitializer(functionNode));
-        }
-    }
-
-    Map<Integer, FunctionInitializer> getFunctionInitializers() {
-        return functionInitializers;
-    }
-
     /**
      * Persist current compilation with the given {@code cacheKey}.
      * @param cacheKey cache key
@@ -726,15 +711,17 @@
      */
     public void persistClassInfo(final String cacheKey, final FunctionNode functionNode) {
         if (cacheKey != null && env._persistent_cache) {
-            Map<Integer, FunctionInitializer> initializers;
             // If this is an on-demand compilation create a function initializer for the function being compiled.
             // Otherwise use function initializer map generated by codegen.
-            if (functionInitializers == null) {
-                initializers = new HashMap<>();
-                final FunctionInitializer initializer = new FunctionInitializer(functionNode, getInvalidatedProgramPoints());
-                initializers.put(functionNode.getId(), initializer);
+            Map<Integer, FunctionInitializer> initializers = new HashMap<>();
+            if (isOnDemandCompilation()) {
+                initializers.put(functionNode.getId(), new FunctionInitializer(functionNode, getInvalidatedProgramPoints()));
             } else {
-                initializers = functionInitializers;
+                for (final CompileUnit compileUnit : getCompileUnits()) {
+                    for (final FunctionNode fn : compileUnit.getFunctionNodes()) {
+                        initializers.put(fn.getId(), new FunctionInitializer(fn));
+                    }
+                }
             }
             final String mainClassName = getFirstCompileUnit().getUnitClassName();
             installer.storeScript(cacheKey, source, mainClassName, bytecode, initializers, constantData.toArray(), compilationId);
--- a/src/jdk/nashorn/internal/codegen/CompilerConstants.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/CompilerConstants.java	Fri Nov 13 15:38:44 2015 -0800
@@ -149,8 +149,11 @@
     /** Arguments parameter in scope object constructors; in slot 3 when present */
     INIT_ARGUMENTS(null, 3),
 
-    /** prefix for all ScriptObject subclasses with fields, @see ObjectGenerator */
-    JS_OBJECT_PREFIX("JO"),
+    /** prefix for all ScriptObject subclasses with dual object/primitive fields, see {@link ObjectClassGenerator} */
+    JS_OBJECT_DUAL_FIELD_PREFIX("JD"),
+
+    /** prefix for all ScriptObject subclasses with object fields only, see {@link ObjectClassGenerator} */
+    JS_OBJECT_SINGLE_FIELD_PREFIX("JO"),
 
     /** name for allocate method in JO objects */
     ALLOCATE("allocate"),
--- a/src/jdk/nashorn/internal/codegen/Emitter.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.codegen;
-
-/**
- * Interface for anything that interacts with a low level bytecode
- * generation module, for example ASM.
- * <p>
- * This is pretty generic, i.e. it can be a ClassEmitter, MethodEmitter
- * or potentially even more fine grained stuff.
- *
- */
-public interface Emitter {
-
-    /**
-     * Register the start of emission for this CodeEmitter
-     */
-    public void begin();
-
-    /**
-     * Register the end of emission for this CodeEmitter.
-     * This is typically required before generated code can
-     * be requested from it
-     */
-    public void end();
-}
--- a/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -127,6 +127,8 @@
             method.invoke(constructorNoLookup(className, PropertyMap.class));
         }
 
+        helpOptimisticRecognizeDuplicateIdentity(method);
+
         // Set values.
         final Iterator<MapTuple<T>> iter = tuples.iterator();
 
@@ -136,6 +138,7 @@
             //if we didn't load, we need an array property
             if (tuple.symbol != null && tuple.value != null) {
                 final int index = getArrayIndex(tuple.key);
+                method.dup();
                 if (!isValidArrayIndex(index)) {
                     putField(method, tuple.key, tuple.symbol.getFieldIndex(), tuple);
                 } else {
@@ -151,7 +154,7 @@
     @Override
     protected PropertyMap makeMap() {
         assert propertyMap == null : "property map already initialized";
-        propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), fieldCount, paddedFieldCount, evalCode);
+        propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), codegen.useDualFields(), fieldCount, paddedFieldCount, evalCode);
         return propertyMap;
     }
 
@@ -164,9 +167,7 @@
      * @param tuple       Tuple to store.
      */
     private void putField(final MethodEmitter method, final String key, final int fieldIndex, final MapTuple<T> tuple) {
-        method.dup();
-
-        final Type    fieldType   = tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT;
+        final Type    fieldType   = codegen.useDualFields() && tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT;
         final String  fieldClass  = getClassName();
         final String  fieldName   = getFieldName(fieldIndex, fieldType);
         final String  fieldDesc   = typeDescriptor(fieldType.getTypeClass());
@@ -187,7 +188,6 @@
      * @param tuple  Tuple to store.
      */
     private void putSlot(final MethodEmitter method, final long index, final MapTuple<T> tuple) {
-        method.dup();
         if (JSType.isRepresentableAsInt(index)) {
             method.load((int)index);
         } else {
@@ -202,8 +202,8 @@
      */
     private void findClass() {
         fieldObjectClassName = isScope() ?
-                ObjectClassGenerator.getClassName(fieldCount, paramCount) :
-                ObjectClassGenerator.getClassName(paddedFieldCount);
+                ObjectClassGenerator.getClassName(fieldCount, paramCount, codegen.useDualFields()) :
+                ObjectClassGenerator.getClassName(paddedFieldCount, codegen.useDualFields());
 
         try {
             this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
--- a/src/jdk/nashorn/internal/codegen/FindScopeDepths.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/FindScopeDepths.java	Fri Nov 13 15:38:44 2015 -0800
@@ -32,7 +32,6 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator.AllocatorDescriptor;
 import jdk.nashorn.internal.ir.Block;
 import jdk.nashorn.internal.ir.FunctionNode;
 import jdk.nashorn.internal.ir.FunctionNode.CompilationState;
@@ -208,7 +207,7 @@
         final RecompilableScriptFunctionData data = new RecompilableScriptFunctionData(
                 newFunctionNode,
                 compiler.getCodeInstaller(),
-                new AllocatorDescriptor(newFunctionNode.getThisProperties()),
+                ObjectClassGenerator.createAllocationStrategy(newFunctionNode.getThisProperties(), compiler.getContext().useDualFields()),
                 nestedFunctions,
                 externalSymbolDepths.get(fnId),
                 internalSymbols.get(fnId),
--- a/src/jdk/nashorn/internal/codegen/Label.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/Label.java	Fri Nov 13 15:38:44 2015 -0800
@@ -333,7 +333,7 @@
          * @param slot the slot written to
          * @param onlySymbolLiveValue if true, this is the symbol's only live value, and other values of the symbol
          * should be marked dead
-         * @param Type the type written to the slot
+         * @param type the type written to the slot
          */
         void onLocalStore(final Type type, final int slot, final boolean onlySymbolLiveValue) {
             if(onlySymbolLiveValue) {
--- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -40,34 +40,38 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.AccessNode;
-import jdk.nashorn.internal.ir.BaseNode;
 import jdk.nashorn.internal.ir.BinaryNode;
 import jdk.nashorn.internal.ir.Block;
 import jdk.nashorn.internal.ir.BreakNode;
 import jdk.nashorn.internal.ir.BreakableNode;
+import jdk.nashorn.internal.ir.CallNode;
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
 import jdk.nashorn.internal.ir.ContinueNode;
 import jdk.nashorn.internal.ir.Expression;
+import jdk.nashorn.internal.ir.ExpressionStatement;
 import jdk.nashorn.internal.ir.ForNode;
 import jdk.nashorn.internal.ir.FunctionNode;
 import jdk.nashorn.internal.ir.FunctionNode.CompilationState;
+import jdk.nashorn.internal.ir.GetSplitState;
 import jdk.nashorn.internal.ir.IdentNode;
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.IndexNode;
 import jdk.nashorn.internal.ir.JoinPredecessor;
 import jdk.nashorn.internal.ir.JoinPredecessorExpression;
 import jdk.nashorn.internal.ir.JumpStatement;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LabelNode;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LexicalContextNode;
 import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
 import jdk.nashorn.internal.ir.LocalVariableConversion;
 import jdk.nashorn.internal.ir.LoopNode;
 import jdk.nashorn.internal.ir.Node;
+import jdk.nashorn.internal.ir.ObjectNode;
 import jdk.nashorn.internal.ir.PropertyNode;
 import jdk.nashorn.internal.ir.ReturnNode;
 import jdk.nashorn.internal.ir.RuntimeNode;
@@ -82,6 +86,7 @@
 import jdk.nashorn.internal.ir.UnaryNode;
 import jdk.nashorn.internal.ir.VarNode;
 import jdk.nashorn.internal.ir.WhileNode;
+import jdk.nashorn.internal.ir.WithNode;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
 import jdk.nashorn.internal.parser.TokenType;
 
@@ -131,8 +136,44 @@
         OBJECT(Type.OBJECT);
 
         private final Type type;
+        private final TypeHolderExpression typeExpression;
+
         private LvarType(final Type type) {
             this.type = type;
+            this.typeExpression = new TypeHolderExpression(type);
+        }
+    }
+
+    /**
+     * A bogus Expression subclass that only reports its type. Used to interrogate BinaryNode and UnaryNode about their
+     * types by creating temporary copies of them and replacing their operands with instances of these. An alternative
+     * solution would be to add BinaryNode.getType(Type lhsType, Type rhsType) and UnaryNode.getType(Type exprType)
+     * methods. For the time being though, this is easier to implement and is in fact fairly clean. It does result in
+     * generation of higher number of temporary short lived nodes, though.
+     */
+    private static class TypeHolderExpression extends Expression {
+        private static final long serialVersionUID = 1L;
+
+        private final Type type;
+
+        TypeHolderExpression(final Type type) {
+            super(0L, 0, 0);
+            this.type = type;
+        }
+
+        @Override
+        public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
+            throw new AssertionError();
+        }
+
+        @Override
+        public Type getType() {
+            return type;
+        }
+
+        @Override
+        public void toString(final StringBuilder sb, final boolean printType) {
+            throw new AssertionError();
         }
     }
 
@@ -165,7 +206,6 @@
         // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).
 
         symbolIsConverted(symbol, branchLvarType, targetType);
-        //symbolIsUsed(symbol, branchLvarType);
         return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
     }
 
@@ -188,7 +228,7 @@
             for(final Symbol symbol: commonSymbols) {
                 final LvarType type1 = types1.get(symbol);
                 final LvarType type2 = types2.get(symbol);
-                final LvarType widest = widestLvarType(type1,  type2);
+                final LvarType widest = widestLvarType(type1, type2);
                 if(widest != type1 && matches1) {
                     matches1 = false;
                     if(!matches2) {
@@ -201,7 +241,7 @@
                         union = cloneMap(types2);
                     }
                 }
-                if(!(matches1 || matches2) && union != null) { //remove overly enthusiastic "union can be null" warning
+                if(!(matches1 || matches2)) {
                     assert union != null;
                     union.put(symbol, widest);
                 }
@@ -359,6 +399,8 @@
     // allocates a new map. Immutability of maps allows for cheap snapshots by just keeping the reference to the current
     // value.
     private Map<Symbol, LvarType> localVariableTypes = new IdentityHashMap<>();
+    // Stack for evaluated expression types.
+    private final Deque<LvarType> typeStack = new ArrayDeque<>();
 
     // Whether the current point in the AST is reachable code
     private boolean reachable = true;
@@ -375,8 +417,6 @@
     private final Map<IdentNode, LvarType> identifierLvarTypes = new IdentityHashMap<>();
     private final Map<Symbol, SymbolConversions> symbolConversions = new IdentityHashMap<>();
 
-    private SymbolToType symbolToType = new SymbolToType();
-
     // Stack of open labels for starts of catch blocks, one for every currently traversed try block; for inserting
     // control flow edges to them. Note that we currently don't insert actual control flow edges, but instead edges that
     // help us with type calculations. This means that some operations that can result in an exception being thrown
@@ -400,62 +440,56 @@
     private void doesNotContinueSequentially() {
         reachable = false;
         localVariableTypes = Collections.emptyMap();
+        assertTypeStackIsEmpty();
     }
 
+    private boolean pushExpressionType(final Expression expr) {
+        typeStack.push(toLvarType(expr.getType()));
+        return false;
+    }
+
+    @Override
+    public boolean enterAccessNode(final AccessNode accessNode) {
+        visitExpression(accessNode.getBase());
+        return pushExpressionType(accessNode);
+    }
 
     @Override
     public boolean enterBinaryNode(final BinaryNode binaryNode) {
         // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
         final Expression lhs = binaryNode.lhs();
-        final boolean isAssignment = binaryNode.isAssignment();
-        LvarType lhsTypeOnLoad = null;
-        if(isAssignment) {
-            if(lhs instanceof BaseNode) {
-                ((BaseNode)lhs).getBase().accept(this);
-                if(lhs instanceof IndexNode) {
-                    ((IndexNode)lhs).getIndex().accept(this);
-                } else {
-                    assert lhs instanceof AccessNode;
-                }
-            } else {
-                assert lhs instanceof IdentNode;
-                if(binaryNode.isSelfModifying()) {
-                    final IdentNode ident = ((IdentNode)lhs);
-                    ident.accept(this);
-                    // Self-assignment can cause a change in the type of the variable. For purposes of evaluating
-                    // the type of the operation, we must use its type as it was when it was loaded. If we didn't
-                    // do this, some awkward expressions would end up being calculated incorrectly, e.g.
-                    // "var x; x += x = 0;". In this case we have undefined+int so the result type is double (NaN).
-                    // However, if we used the type of "x" on LHS after we evaluated RHS, we'd see int+int, so the
-                    // result type would be either optimistic int or pessimistic long, which would be wrong.
-                    lhsTypeOnLoad = getLocalVariableTypeIfBytecode(ident.getSymbol());
-                }
-            }
+        final LvarType lhsType;
+        if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
+            lhsType = visitExpression(lhs);
         } else {
-            lhs.accept(this);
+            // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
+            // The type is irrelevant, as only RHS is used to determine the type anyway.
+            lhsType = LvarType.UNDEFINED;
         }
 
         final boolean isLogical = binaryNode.isLogical();
-        assert !(isAssignment && isLogical); // there are no logical assignment operators in JS
         final Label joinLabel = isLogical ? new Label("") : null;
         if(isLogical) {
             jumpToLabel((JoinPredecessor)lhs, joinLabel);
         }
 
         final Expression rhs = binaryNode.rhs();
-        rhs.accept(this);
+        final LvarType rhsType = visitExpression(rhs);
         if(isLogical) {
             jumpToLabel((JoinPredecessor)rhs, joinLabel);
         }
         joinOnLabel(joinLabel);
 
-        if(isAssignment && lhs instanceof IdentNode) {
+        final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());
+
+        if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
             if(binaryNode.isSelfModifying()) {
-                onSelfAssignment((IdentNode)lhs, binaryNode, lhsTypeOnLoad);
+                onSelfAssignment((IdentNode)lhs, type);
             } else {
-                onAssignment((IdentNode)lhs, rhs);
+                onAssignment((IdentNode)lhs, type);
             }
         }
+        typeStack.push(type);
         return false;
     }
 
@@ -475,6 +509,17 @@
     }
 
     @Override
+    public boolean enterCallNode(final CallNode callNode) {
+        visitExpression(callNode.getFunction());
+        visitExpressions(callNode.getArgs());
+        final CallNode.EvalArgs evalArgs = callNode.getEvalArgs();
+        if (evalArgs != null) {
+            visitExpressions(evalArgs.getArgs());
+        }
+        return pushExpressionType(callNode);
+    }
+
+    @Override
     public boolean enterContinueNode(final ContinueNode continueNode) {
         return enterJumpStatement(continueNode);
     }
@@ -483,8 +528,8 @@
         if(!reachable) {
             return false;
         }
-        final BreakableNode target = jump.getTarget(lc);
-        jumpToLabel(jump, jump.getTargetLabel(target), getBreakTargetTypes(target));
+        assertTypeStackIsEmpty();
+        jumpToLabel(jump, jump.getTargetLabel(lc), getBreakTargetTypes(jump.getPopScopeLimit(lc)));
         doesNotContinueSequentially();
         return false;
     }
@@ -495,6 +540,7 @@
     }
 
     private void enterDoWhileLoop(final WhileNode loopNode) {
+        assertTypeStackIsEmpty();
         final JoinPredecessorExpression test = loopNode.getTest();
         final Block body = loopNode.getBody();
         final Label continueLabel = loopNode.getContinueLabel();
@@ -512,7 +558,7 @@
             if(!reachable) {
                 break;
             }
-            test.accept(this);
+            visitExpressionOnEmptyStack(test);
             jumpToLabel(test, breakLabel);
             if(isAlwaysFalse(test)) {
                 break;
@@ -535,6 +581,45 @@
     }
 
     @Override
+    public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
+        if (reachable) {
+            visitExpressionOnEmptyStack(expressionStatement.getExpression());
+        }
+        return false;
+    }
+
+    private void assertTypeStackIsEmpty() {
+        assert typeStack.isEmpty();
+    }
+
+    @Override
+    protected Node leaveDefault(final Node node) {
+        assert !(node instanceof Expression); // All expressions were handled
+        assert !(node instanceof Statement) || typeStack.isEmpty(); // No statements leave with a non-empty stack
+        return node;
+    }
+
+    private LvarType visitExpressionOnEmptyStack(final Expression expr) {
+        assertTypeStackIsEmpty();
+        return visitExpression(expr);
+    }
+
+    private LvarType visitExpression(final Expression expr) {
+        final int stackSize = typeStack.size();
+        expr.accept(this);
+        assert typeStack.size() == stackSize + 1;
+        return typeStack.pop();
+    }
+
+    private void visitExpressions(final List<Expression> exprs) {
+        for(final Expression expr: exprs) {
+            if (expr != null) {
+                visitExpression(expr);
+            }
+        }
+    }
+
+    @Override
     public boolean enterForNode(final ForNode forNode) {
         if(!reachable) {
             return false;
@@ -543,7 +628,7 @@
         final Expression init = forNode.getInit();
         if(forNode.isForIn()) {
             final JoinPredecessorExpression iterable = forNode.getModify();
-            iterable.accept(this);
+            visitExpression(iterable);
             enterTestFirstLoop(forNode, null, init,
                     // If we're iterating over property names, and we can discern from the runtime environment
                     // of the compilation that the object being iterated over must use strings for property
@@ -552,16 +637,18 @@
                     !compiler.useOptimisticTypes() || (!forNode.isForEach() && compiler.hasStringPropertyIterator(iterable.getExpression())));
         } else {
             if(init != null) {
-                init.accept(this);
+                visitExpressionOnEmptyStack(init);
             }
             enterTestFirstLoop(forNode, forNode.getModify(), null, false);
         }
+        assertTypeStackIsEmpty();
         return false;
     }
 
     @Override
     public boolean enterFunctionNode(final FunctionNode functionNode) {
         if(alreadyEnteredTopLevelFunction) {
+            typeStack.push(LvarType.OBJECT);
             return false;
         }
         int pos = 0;
@@ -603,76 +690,136 @@
     }
 
     @Override
+    public boolean enterGetSplitState(final GetSplitState getSplitState) {
+        return pushExpressionType(getSplitState);
+    }
+
+    @Override
     public boolean enterIdentNode(final IdentNode identNode) {
         final Symbol symbol = identNode.getSymbol();
         if(symbol.isBytecodeLocal()) {
             symbolIsUsed(symbol);
-            setIdentifierLvarType(identNode, getLocalVariableType(symbol));
+            final LvarType type = getLocalVariableType(symbol);
+            setIdentifierLvarType(identNode, type);
+            typeStack.push(type);
+        } else {
+            pushExpressionType(identNode);
         }
         return false;
     }
 
     @Override
     public boolean enterIfNode(final IfNode ifNode) {
+        processIfNode(ifNode);
+        return false;
+    }
+
+    private void processIfNode(final IfNode ifNode) {
         if(!reachable) {
-            return false;
+            return;
         }
 
         final Expression test = ifNode.getTest();
         final Block pass = ifNode.getPass();
         final Block fail = ifNode.getFail();
 
-        test.accept(this);
+        visitExpressionOnEmptyStack(test);
 
-        final Map<Symbol, LvarType> afterTestLvarTypes = localVariableTypes;
-        if(!isAlwaysFalse(test)) {
+        final Map<Symbol, LvarType> passLvarTypes;
+        final boolean reachableFromPass;
+        final boolean isTestAlwaysTrue = isAlwaysTrue(test);
+        if(isAlwaysFalse(test)) {
+            passLvarTypes = null;
+            reachableFromPass = false;
+        } else {
+            final Map<Symbol, LvarType> afterTestLvarTypes = localVariableTypes;
             pass.accept(this);
+            assertTypeStackIsEmpty();
+            if (isTestAlwaysTrue) {
+                return;
+            }
+            passLvarTypes = localVariableTypes;
+            reachableFromPass = reachable;
+            localVariableTypes = afterTestLvarTypes;
+            reachable = true;
         }
-        final Map<Symbol, LvarType> passLvarTypes = localVariableTypes;
-        final boolean reachableFromPass = reachable;
 
-        reachable = true;
-        localVariableTypes = afterTestLvarTypes;
-        if(!isAlwaysTrue(test) && fail != null) {
+        // If we get here, then we need to consider the case where pass block is not executed
+        assert !isTestAlwaysTrue;
+
+        if (fail != null) {
             fail.accept(this);
-            final boolean reachableFromFail = reachable;
-            reachable |= reachableFromPass;
-            if(!reachable) {
-                return false;
-            }
-
-            if(reachableFromFail) {
-                if(reachableFromPass) {
-                    final Map<Symbol, LvarType> failLvarTypes = localVariableTypes;
-                    localVariableTypes = getUnionTypes(passLvarTypes, failLvarTypes);
-                    setConversion(pass, passLvarTypes, localVariableTypes);
-                    setConversion(fail, failLvarTypes, localVariableTypes);
-                }
-                return false;
-            }
+            assertTypeStackIsEmpty();
         }
 
-        if(reachableFromPass) {
-            localVariableTypes = getUnionTypes(afterTestLvarTypes, passLvarTypes);
-            // IfNode itself is associated with conversions that might need to be performed after the test if there's no
-            // else branch. E.g.
-            // if(x = 1, cond) { x = 1.0 } must widen "x = 1" to a double.
-            setConversion(pass, passLvarTypes, localVariableTypes);
-            setConversion(ifNode, afterTestLvarTypes, localVariableTypes);
+        if(reachable) {
+            if(reachableFromPass) {
+                final Map<Symbol, LvarType> failLvarTypes = localVariableTypes;
+                localVariableTypes = getUnionTypes(passLvarTypes, failLvarTypes);
+                setConversion(pass, passLvarTypes, localVariableTypes);
+                // IfNode itself is associated with conversions that might need to be performed after the test if
+                // there's no else branch. E.g.
+                // if(x = 1, cond) { x = 1.0 } must widen "x = 1" to a double.
+                setConversion(fail != null ? fail : ifNode, failLvarTypes, localVariableTypes);
+            }
+        } else if (reachableFromPass) {
+            assert passLvarTypes != null;
+            localVariableTypes = passLvarTypes;
+            reachable = true;
+        }
+    }
+
+    @Override
+    public boolean enterIndexNode(final IndexNode indexNode) {
+        visitExpression(indexNode.getBase());
+        visitExpression(indexNode.getIndex());
+        return pushExpressionType(indexNode);
+    }
+
+    @Override
+    public boolean enterJoinPredecessorExpression(final JoinPredecessorExpression joinExpr) {
+        final Expression expr = joinExpr.getExpression();
+        if (expr != null) {
+            expr.accept(this);
         } else {
-            localVariableTypes = afterTestLvarTypes;
+            typeStack.push(LvarType.UNDEFINED);
         }
-
         return false;
     }
 
     @Override
+    public boolean enterJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        return enterJumpStatement(jumpToInlinedFinally);
+    }
+
+    @Override
+    public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
+        if (literalNode instanceof ArrayLiteralNode) {
+            final List<Expression> expressions = ((ArrayLiteralNode)literalNode).getElementExpressions();
+            if (expressions != null) {
+                visitExpressions(expressions);
+            }
+        }
+        pushExpressionType(literalNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterObjectNode(final ObjectNode objectNode) {
+        for(final PropertyNode propertyNode: objectNode.getElements()) {
+            // Avoid falsely adding property keys to the control flow graph
+            final Expression value = propertyNode.getValue();
+            if (value != null) {
+                visitExpression(value);
+            }
+        }
+        return pushExpressionType(objectNode);
+    }
+
+    @Override
     public boolean enterPropertyNode(final PropertyNode propertyNode) {
-        // Avoid falsely adding property keys to the control flow graph
-        if(propertyNode.getValue() != null) {
-            propertyNode.getValue().accept(this);
-        }
-        return false;
+        // Property nodes are only accessible through object literals, and we handled that case above
+        throw new AssertionError();
     }
 
     @Override
@@ -684,9 +831,9 @@
         final Expression returnExpr = returnNode.getExpression();
         final Type returnExprType;
         if(returnExpr != null) {
-            returnExpr.accept(this);
-            returnExprType = getType(returnExpr);
+            returnExprType = visitExpressionOnEmptyStack(returnExpr).type;
         } else {
+            assertTypeStackIsEmpty();
             returnExprType = Type.UNDEFINED;
         }
         returnType = Type.widestReturnType(returnType, returnExprType);
@@ -695,6 +842,12 @@
     }
 
     @Override
+    public boolean enterRuntimeNode(final RuntimeNode runtimeNode) {
+        visitExpressions(runtimeNode.getArgs());
+        return pushExpressionType(runtimeNode);
+    }
+
+    @Override
     public boolean enterSplitReturn(final SplitReturn splitReturn) {
         doesNotContinueSequentially();
         return false;
@@ -706,8 +859,7 @@
             return false;
         }
 
-        final Expression expr = switchNode.getExpression();
-        expr.accept(this);
+        visitExpressionOnEmptyStack(switchNode.getExpression());
 
         final List<CaseNode> cases = switchNode.getCases();
         if(cases.isEmpty()) {
@@ -724,7 +876,7 @@
         for(final CaseNode caseNode: cases) {
             final Expression test = caseNode.getTest();
             if(!isInteger && test != null) {
-                test.accept(this);
+                visitExpressionOnEmptyStack(test);
                 if(!tagUsed) {
                     symbolIsUsed(switchNode.getTag(), LvarType.OBJECT);
                     tagUsed = true;
@@ -769,29 +921,42 @@
         final Expression trueExpr = ternaryNode.getTrueExpression();
         final Expression falseExpr = ternaryNode.getFalseExpression();
 
-        test.accept(this);
+        visitExpression(test);
 
         final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
+        final LvarType trueType;
         if(!isAlwaysFalse(test)) {
-            trueExpr.accept(this);
+            trueType = visitExpression(trueExpr);
+        } else {
+            trueType = null;
         }
         final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
         localVariableTypes = testExitLvarTypes;
+        final LvarType falseType;
         if(!isAlwaysTrue(test)) {
-            falseExpr.accept(this);
+            falseType = visitExpression(falseExpr);
+        } else {
+            falseType = null;
         }
         final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
         localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
         setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
         setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);
+
+        typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
         return false;
     }
 
+    private static <T> T assertNotNull(final T t) {
+        assert t != null;
+        return t;
+    }
+
     private void enterTestFirstLoop(final LoopNode loopNode, final JoinPredecessorExpression modify,
             final Expression iteratorValues, final boolean iteratorValuesAreObject) {
         final JoinPredecessorExpression test = loopNode.getTest();
         if(isAlwaysFalse(test)) {
-            test.accept(this);
+            visitExpressionOnEmptyStack(test);
             return;
         }
 
@@ -804,7 +969,7 @@
             jumpToLabel(loopNode, repeatLabel, beforeLoopTypes);
             final Map<Symbol, LvarType> beforeRepeatTypes = localVariableTypes;
             if(test != null) {
-                test.accept(this);
+                visitExpressionOnEmptyStack(test);
             }
             if(!isAlwaysTrue(test)) {
                 jumpToLabel(test, breakLabel);
@@ -827,7 +992,7 @@
                 break;
             }
             if(modify != null) {
-                modify.accept(this);
+                visitExpressionOnEmptyStack(modify);
                 jumpToLabel(modify, repeatLabel);
                 joinOnLabel(repeatLabel);
             }
@@ -853,7 +1018,7 @@
             return false;
         }
 
-        throwNode.getExpression().accept(this);
+        visitExpressionOnEmptyStack(throwNode.getExpression());
         jumpToCatchBlock(throwNode);
         doesNotContinueSequentially();
         return false;
@@ -886,13 +1051,24 @@
         }
         doesNotContinueSequentially();
 
+        for (final Block inlinedFinally : tryNode.getInlinedFinallies()) {
+            final Block finallyBody = TryNode.getLabelledInlinedFinallyBlock(inlinedFinally);
+            joinOnLabel(finallyBody.getEntryLabel());
+            // NOTE: the jump to inlined finally can end up in dead code, so it is not necessarily reachable.
+            if (reachable) {
+                finallyBody.accept(this);
+                // All inlined finallies end with a jump or a return
+                assert !reachable;
+            }
+        }
+
         joinOnLabel(catchLabel);
         for(final CatchNode catchNode: tryNode.getCatches()) {
             final IdentNode exception = catchNode.getException();
             onAssignment(exception, LvarType.OBJECT);
             final Expression condition = catchNode.getExceptionCondition();
             if(condition != null) {
-                condition.accept(this);
+                visitExpression(condition);
             }
             final Map<Symbol, LvarType> afterConditionTypes = localVariableTypes;
             final Block catchBody = catchNode.getBody();
@@ -927,14 +1103,11 @@
     @Override
     public boolean enterUnaryNode(final UnaryNode unaryNode) {
         final Expression expr = unaryNode.getExpression();
-        expr.accept(this);
-
-        if(unaryNode.isSelfModifying()) {
-            if(expr instanceof IdentNode) {
-                final IdentNode ident = (IdentNode)expr;
-                onSelfAssignment(ident, unaryNode, getLocalVariableTypeIfBytecode(ident.getSymbol()));
-            }
+        final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
+        if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
+            onSelfAssignment((IdentNode)expr, unaryType);
         }
+        typeStack.push(unaryType);
         return false;
     }
 
@@ -945,8 +1118,7 @@
         }
         final Expression init = varNode.getInit();
         if(init != null) {
-            init.accept(this);
-            onAssignment(varNode.getName(), init);
+            onAssignment(varNode.getName(), visitExpression(init));
         }
         return false;
     }
@@ -964,7 +1136,16 @@
         return false;
     }
 
-    private Map<Symbol, LvarType> getBreakTargetTypes(final BreakableNode target) {
+    @Override
+    public boolean enterWithNode(final WithNode withNode) {
+        if (reachable) {
+            visitExpression(withNode.getExpression());
+            withNode.getBody().accept(this);
+        }
+        return false;
+    };
+
+    private Map<Symbol, LvarType> getBreakTargetTypes(final LexicalContextNode target) {
         // Remove symbols defined in the the blocks that are being broken out of.
         Map<Symbol, LvarType> types = localVariableTypes;
         for(final Iterator<LexicalContextNode> it = lc.getAllNodes(); it.hasNext();) {
@@ -1002,18 +1183,6 @@
     }
 
     /**
-     * Gets the type for a local variable if it is a bytecode local, otherwise null. Can be used in circumstances where
-     * the type is irrelevant if the symbol is not a bytecode local. Note that for bytecode locals, it delegates to
-     * {@link #getLocalVariableType(Symbol)}, so it will still assert that the type for such variable is already
-     * defined (that is, not null).
-     * @param symbol the symbol representing the variable.
-     * @return the current variable type, if it is a bytecode local, otherwise null.
-     */
-    private LvarType getLocalVariableTypeIfBytecode(final Symbol symbol) {
-        return symbol.isBytecodeLocal() ? getLocalVariableType(symbol) : null;
-    }
-
-    /**
      * Gets the type for a variable represented by a symbol, or null if the type is not know. This is the least strict
      * of all local variable type getters, and as such its use is discouraged except in initialization scenarios (where
      * a just-defined symbol might still be null).
@@ -1154,6 +1323,7 @@
      */
     private void leaveBreakable(final BreakableNode breakable) {
         joinOnLabel(breakable.getBreakLabel());
+        assertTypeStackIsEmpty();
     }
 
     @Override
@@ -1193,8 +1363,6 @@
                     final Expression lhs = binaryNode.lhs();
                     final Expression rhs = binaryNode.rhs();
 
-                    Type cmpWidest = Type.widest(lhs.getType(), rhs.getType());
-                    boolean newRuntimeNode = false, finalized = false;
                     final TokenType tt = binaryNode.tokenType();
                     switch (tt) {
                     case EQ_STRICT:
@@ -1207,14 +1375,12 @@
                         }
                         // Specialize comparison of boolean with non-boolean
                         if (lhs.getType().isBoolean() != rhs.getType().isBoolean()) {
-                            newRuntimeNode = true;
-                            cmpWidest = Type.OBJECT;
-                            finalized = true;
+                            return new RuntimeNode(binaryNode);
                         }
                         // fallthrough
                     default:
-                        if (newRuntimeNode || cmpWidest.isObject()) {
-                            return new RuntimeNode(binaryNode).setIsFinal(finalized);
+                        if (lhs.getType().isObject() && rhs.getType().isObject()) {
+                            return new RuntimeNode(binaryNode);
                         }
                     }
                 } else if(binaryNode.isOptimisticUndecidedType()) {
@@ -1230,7 +1396,11 @@
                 if(node instanceof JoinPredecessor) {
                     final JoinPredecessor original = joinPredecessors.pop();
                     assert original.getClass() == node.getClass() : original.getClass().getName() + "!=" + node.getClass().getName();
-                    return (Node)setLocalVariableConversion(original, (JoinPredecessor)node);
+                    final JoinPredecessor newNode = setLocalVariableConversion(original, (JoinPredecessor)node);
+                    if (newNode instanceof LexicalContextNode) {
+                        lc.replace((LexicalContextNode)node, (LexicalContextNode)newNode);
+                    }
+                    return (Node)newNode;
                 }
                 return node;
             }
@@ -1329,10 +1499,6 @@
         return conv == null || !conv.isLive();
     }
 
-    private void onAssignment(final IdentNode identNode, final Expression rhs) {
-        onAssignment(identNode, toLvarType(getType(rhs)));
-    }
-
     private void onAssignment(final IdentNode identNode, final LvarType type) {
         final Symbol symbol = identNode.getSymbol();
         assert symbol != null : identNode.getName();
@@ -1400,13 +1566,12 @@
         jumpToCatchBlock(identNode);
     }
 
-    private void onSelfAssignment(final IdentNode identNode, final Expression assignment, final LvarType typeOnLoad) {
+    private void onSelfAssignment(final IdentNode identNode, final LvarType type) {
         final Symbol symbol = identNode.getSymbol();
         assert symbol != null : identNode.getName();
         if(!symbol.isBytecodeLocal()) {
             return;
         }
-        final LvarType type = toLvarType(getType(assignment, symbol, typeOnLoad.type));
         // Self-assignment never produce either a boolean or undefined
         assert type != null && type != LvarType.UNDEFINED && type != LvarType.BOOLEAN;
         setType(symbol, type);
@@ -1466,7 +1631,6 @@
      * @param symbol the symbol representing the variable
      * @param type the type
      */
-    @SuppressWarnings("unused")
     private void setType(final Symbol symbol, final LvarType type) {
         if(getLocalVariableTypeOrNull(symbol) == type) {
             return;
@@ -1486,77 +1650,4 @@
     private void symbolIsUsed(final Symbol symbol) {
         symbolIsUsed(symbol, getLocalVariableType(symbol));
     }
-
-    /**
-     * Gets the type of the expression, dependent on the current types of the local variables.
-     *
-     * @param expr the expression
-     * @return the current type of the expression dependent on the current types of the local variables.
-     */
-    private Type getType(final Expression expr) {
-        return expr.getType(getSymbolToType());
-    }
-
-    /**
-     * Returns a function object from symbols to their types, used by the expressions to evaluate their type.
-     * {@link BinaryNode} specifically uses identity of the function to cache type calculations. This method makes
-     * sure to return the same function object while the local variable types don't change, and create a new function
-     * object if the local variable types have been changed.
-     * @return a function object representing a mapping from symbols to their types.
-     */
-    private Function<Symbol, Type> getSymbolToType() {
-        if(symbolToType.isStale()) {
-            symbolToType = new SymbolToType();
-        }
-        return symbolToType;
-    }
-
-    private class SymbolToType implements Function<Symbol, Type> {
-        private final Object boundTypes = localVariableTypes;
-        @Override
-        public Type apply(final Symbol t) {
-            return getLocalVariableType(t).type;
-        }
-
-        boolean isStale() {
-            return boundTypes != localVariableTypes;
-        }
-    }
-
-    /**
-     * Gets the type of the expression, dependent on the current types of the local variables and a single overridden
-     * symbol type. Used by type calculation on compound operators to ensure the type of the LHS at the time it was
-     * loaded (which can potentially be different after RHS evaluation, e.g. "var x; x += x = 0;") is preserved for
-     * the calculation.
-     *
-     * @param expr the expression
-     * @param overriddenSymbol the overridden symbol
-     * @param overriddenType the overridden type
-     * @return the current type of the expression dependent on the current types of the local variables and the single
-     * potentially overridden type.
-     */
-    private Type getType(final Expression expr, final Symbol overriddenSymbol, final Type overriddenType) {
-        return expr.getType(getSymbolToType(overriddenSymbol, overriddenType));
-    }
-
-    private Function<Symbol, Type> getSymbolToType(final Symbol overriddenSymbol, final Type overriddenType) {
-        return getLocalVariableType(overriddenSymbol).type == overriddenType ? getSymbolToType() :
-            new SymbolToTypeOverride(overriddenSymbol, overriddenType);
-    }
-
-    private class SymbolToTypeOverride implements Function<Symbol, Type> {
-        private final Function<Symbol, Type> originalSymbolToType = getSymbolToType();
-        private final Symbol overriddenSymbol;
-        private final Type overriddenType;
-
-        SymbolToTypeOverride(final Symbol overriddenSymbol, final Type overriddenType) {
-            this.overriddenSymbol = overriddenSymbol;
-            this.overriddenType = overriddenType;
-        }
-
-        @Override
-        public Type apply(final Symbol symbol) {
-            return symbol == overriddenSymbol ? overriddenType : originalSymbolToType.apply(symbol);
-        }
-    }
 }
--- a/src/jdk/nashorn/internal/codegen/Lower.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/Lower.java	Fri Nov 13 15:38:44 2015 -0800
@@ -56,9 +56,11 @@
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.IndexNode;
 import jdk.nashorn.internal.ir.JumpStatement;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LabelNode;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.ir.LiteralNode.PrimitiveLiteralNode;
 import jdk.nashorn.internal.ir.LoopNode;
 import jdk.nashorn.internal.ir.Node;
 import jdk.nashorn.internal.ir.ReturnNode;
@@ -115,7 +117,7 @@
                 for (final Statement statement : statements) {
                     if (!terminated) {
                         newStatements.add(statement);
-                        if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //TODO hasGoto? But some Loops are hasGoto too - why?
+                        if (statement.isTerminal() || statement instanceof JumpStatement) { //TODO hasGoto? But some Loops are hasGoto too - why?
                             terminated = true;
                         }
                     } else {
@@ -183,6 +185,12 @@
     }
 
     @Override
+    public boolean enterJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        addStatement(jumpToInlinedFinally);
+        return false;
+    }
+
+    @Override
     public boolean enterEmptyNode(final EmptyNode emptyNode) {
         return false;
     }
@@ -192,7 +200,7 @@
         final String name = getConstantPropertyName(indexNode.getIndex());
         if (name != null) {
             // If index node is a constant property name convert index node to access node.
-            assert Token.descType(indexNode.getToken()) == TokenType.LBRACKET;
+            assert indexNode.isIndex();
             return new AccessNode(indexNode.getToken(), indexNode.getFinish(), indexNode.getBase(), name);
         }
         return super.leaveIndexNode(indexNode);
@@ -318,8 +326,9 @@
         return addStatement(throwNode); //ThrowNodes are always terminal, marked as such in constructor
     }
 
-    private static Node ensureUniqueNamesIn(final Node node) {
-        return node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
+    @SuppressWarnings("unchecked")
+    private static <T extends Node> T ensureUniqueNamesIn(final T node) {
+        return (T)node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
             @Override
             public Node leaveFunctionNode(final FunctionNode functionNode) {
                 final String name = functionNode.getName();
@@ -333,15 +342,15 @@
         });
     }
 
-    private static List<Statement> copyFinally(final Block finallyBody) {
+    private static Block createFinallyBlock(final Block finallyBody) {
         final List<Statement> newStatements = new ArrayList<>();
         for (final Statement statement : finallyBody.getStatements()) {
-            newStatements.add((Statement)ensureUniqueNamesIn(statement));
+            newStatements.add(statement);
             if (statement.hasTerminalFlags()) {
-                return newStatements;
+                break;
             }
         }
-        return newStatements;
+        return finallyBody.setStatements(null, newStatements);
     }
 
     private Block catchAllBlock(final TryNode tryNode) {
@@ -367,28 +376,24 @@
         return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
     }
 
-    private static boolean isTerminal(final List<Statement> statements) {
-        return !statements.isEmpty() && statements.get(statements.size() - 1).hasTerminalFlags();
+    private static boolean isTerminalFinally(final Block finallyBlock) {
+        return finallyBlock.getLastStatement().hasTerminalFlags();
     }
 
     /**
      * Splice finally code into all endpoints of a trynode
      * @param tryNode the try node
-     * @param rethrows list of rethrowing throw nodes from synthetic catch blocks
+     * @param rethrow the rethrowing throw nodes from the synthetic catch block
      * @param finallyBody the code in the original finally block
      * @return new try node after splicing finally code (same if nop)
      */
-    private Node spliceFinally(final TryNode tryNode, final List<ThrowNode> rethrows, final Block finallyBody) {
+    private TryNode spliceFinally(final TryNode tryNode, final ThrowNode rethrow, final Block finallyBody) {
         assert tryNode.getFinallyBody() == null;
 
+        final Block finallyBlock = createFinallyBlock(finallyBody);
+        final ArrayList<Block> inlinedFinallies = new ArrayList<>();
+        final FunctionNode fn = lc.getCurrentFunction();
         final TryNode newTryNode = (TryNode)tryNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
-            final List<Node> insideTry = new ArrayList<>();
-
-            @Override
-            public boolean enterDefault(final Node node) {
-                insideTry.add(node);
-                return true;
-            }
 
             @Override
             public boolean enterFunctionNode(final FunctionNode functionNode) {
@@ -398,12 +403,8 @@
 
             @Override
             public Node leaveThrowNode(final ThrowNode throwNode) {
-                if (rethrows.contains(throwNode)) {
-                    final List<Statement> newStatements = copyFinally(finallyBody);
-                    if (!isTerminal(newStatements)) {
-                        newStatements.add(throwNode);
-                    }
-                    return BlockStatement.createReplacement(throwNode, newStatements);
+                if (rethrow == throwNode) {
+                    return new BlockStatement(prependFinally(finallyBlock, throwNode));
                 }
                 return throwNode;
             }
@@ -419,58 +420,94 @@
             }
 
             private Node leaveJumpStatement(final JumpStatement jump) {
-                return copy(jump, (Node)jump.getTarget(Lower.this.lc));
+                // NOTE: leaveJumpToInlinedFinally deliberately does not delegate to this method, only break and
+                // continue are edited. JTIF nodes should not be changed, rather the surroundings of
+                // break/continue/return that were moved into the inlined finally block itself will be changed.
+
+                // If this visitor's lc doesn't find the target of the jump, it means it's external to the try block.
+                if (jump.getTarget(lc) == null) {
+                    return createJumpToInlinedFinally(fn, inlinedFinallies, prependFinally(finallyBlock, jump));
+                }
+                return jump;
             }
 
             @Override
             public Node leaveReturnNode(final ReturnNode returnNode) {
-                final Expression expr  = returnNode.getExpression();
-                final List<Statement> newStatements = new ArrayList<>();
-
-                final Expression resultNode;
-                if (expr != null) {
-                    //we need to evaluate the result of the return in case it is complex while
-                    //still in the try block, store it in a result value and return it afterwards
-                    resultNode = new IdentNode(Lower.this.compilerConstant(RETURN));
-                    newStatements.add(new ExpressionStatement(returnNode.getLineNumber(), returnNode.getToken(), returnNode.getFinish(), new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
+                final Expression expr = returnNode.getExpression();
+                if (isTerminalFinally(finallyBlock)) {
+                    if (expr == null) {
+                        // Terminal finally; no return expression.
+                        return createJumpToInlinedFinally(fn, inlinedFinallies, ensureUniqueNamesIn(finallyBlock));
+                    }
+                    // Terminal finally; has a return expression.
+                    final List<Statement> newStatements = new ArrayList<>(2);
+                    final int retLineNumber = returnNode.getLineNumber();
+                    final long retToken = returnNode.getToken();
+                    // Expression is evaluated for side effects.
+                    newStatements.add(new ExpressionStatement(retLineNumber, retToken, returnNode.getFinish(), expr));
+                    newStatements.add(createJumpToInlinedFinally(fn, inlinedFinallies, ensureUniqueNamesIn(finallyBlock)));
+                    return new BlockStatement(retLineNumber, new Block(retToken, finallyBlock.getFinish(), newStatements));
+                } else if (expr == null || expr instanceof PrimitiveLiteralNode<?> || (expr instanceof IdentNode && RETURN.symbolName().equals(((IdentNode)expr).getName()))) {
+                    // Nonterminal finally; no return expression, or returns a primitive literal, or returns :return.
+                    // Just move the return expression into the finally block.
+                    return createJumpToInlinedFinally(fn, inlinedFinallies, prependFinally(finallyBlock, returnNode));
                 } else {
-                    resultNode = null;
+                    // We need to evaluate the result of the return in case it is complex while still in the try block,
+                    // store it in :return, and return it afterwards.
+                    final List<Statement> newStatements = new ArrayList<>();
+                    final int retLineNumber = returnNode.getLineNumber();
+                    final long retToken = returnNode.getToken();
+                    final int retFinish = returnNode.getFinish();
+                    final Expression resultNode = new IdentNode(expr.getToken(), expr.getFinish(), RETURN.symbolName());
+                    // ":return = <expr>;"
+                    newStatements.add(new ExpressionStatement(retLineNumber, retToken, retFinish, new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
+                    // inline finally and end it with "return :return;"
+                    newStatements.add(createJumpToInlinedFinally(fn, inlinedFinallies, prependFinally(finallyBlock, returnNode.setExpression(resultNode))));
+                    return new BlockStatement(retLineNumber, new Block(retToken, retFinish, newStatements));
                 }
-
-                newStatements.addAll(copyFinally(finallyBody));
-                if (!isTerminal(newStatements)) {
-                    newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
-                }
-
-                return BlockStatement.createReplacement(returnNode, lc.getCurrentBlock().getFinish(), newStatements);
-            }
-
-            private Node copy(final Statement endpoint, final Node targetNode) {
-                if (!insideTry.contains(targetNode)) {
-                    final List<Statement> newStatements = copyFinally(finallyBody);
-                    if (!isTerminal(newStatements)) {
-                        newStatements.add(endpoint);
-                    }
-                    return BlockStatement.createReplacement(endpoint, tryNode.getFinish(), newStatements);
-                }
-                return endpoint;
             }
         });
-
-        addStatement(newTryNode);
-        for (final Node statement : finallyBody.getStatements()) {
-            addStatement((Statement)statement);
-        }
+        addStatement(inlinedFinallies.isEmpty() ? newTryNode : newTryNode.setInlinedFinallies(lc, inlinedFinallies));
+        // TODO: if finallyStatement is terminal, we could just have sites of inlined finallies jump here.
+        addStatement(new BlockStatement(finallyBlock));
 
         return newTryNode;
     }
 
+    private static JumpToInlinedFinally createJumpToInlinedFinally(final FunctionNode fn, final List<Block> inlinedFinallies, final Block finallyBlock) {
+        final String labelName = fn.uniqueName(":finally");
+        final long token = finallyBlock.getToken();
+        final int finish = finallyBlock.getFinish();
+        inlinedFinallies.add(new Block(token, finish, new LabelNode(finallyBlock.getFirstStatementLineNumber(),
+                token, finish, labelName, finallyBlock)));
+        return new JumpToInlinedFinally(labelName);
+    }
+
+    private static Block prependFinally(final Block finallyBlock, final Statement statement) {
+        final Block inlinedFinally = ensureUniqueNamesIn(finallyBlock);
+        if (isTerminalFinally(finallyBlock)) {
+            return inlinedFinally;
+        }
+        final List<Statement> stmts = inlinedFinally.getStatements();
+        final List<Statement> newStmts = new ArrayList<>(stmts.size() + 1);
+        newStmts.addAll(stmts);
+        newStmts.add(statement);
+        return new Block(inlinedFinally.getToken(), statement.getFinish(), newStmts);
+    }
+
     @Override
     public Node leaveTryNode(final TryNode tryNode) {
         final Block finallyBody = tryNode.getFinallyBody();
+        TryNode newTryNode = tryNode.setFinallyBody(lc, null);
 
-        if (finallyBody == null) {
-            return addStatement(ensureUnconditionalCatch(tryNode));
+        // No finally or empty finally
+        if (finallyBody == null || finallyBody.getStatementCount() == 0) {
+            final List<CatchNode> catches = newTryNode.getCatches();
+            if (catches == null || catches.isEmpty()) {
+                // A completely degenerate try block: empty finally, no catches. Replace it with try body.
+                return addStatement(new BlockStatement(tryNode.getBody()));
+            }
+            return addStatement(ensureUnconditionalCatch(newTryNode));
         }
 
         /*
@@ -496,11 +533,9 @@
          *   now splice in finally code wherever needed
          *
          */
-        TryNode newTryNode;
-
         final Block catchAll = catchAllBlock(tryNode);
 
-        final List<ThrowNode> rethrows = new ArrayList<>();
+        final List<ThrowNode> rethrows = new ArrayList<>(1);
         catchAll.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
             @Override
             public boolean enterThrowNode(final ThrowNode throwNode) {
@@ -510,20 +545,18 @@
         });
         assert rethrows.size() == 1;
 
-        if (tryNode.getCatchBlocks().isEmpty()) {
-            newTryNode = tryNode.setFinallyBody(null);
-        } else {
-            final Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), ensureUnconditionalCatch(tryNode.setFinallyBody(null)));
-            newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null);
+        if (!tryNode.getCatchBlocks().isEmpty()) {
+            final Block outerBody = new Block(newTryNode.getToken(), newTryNode.getFinish(), ensureUnconditionalCatch(newTryNode));
+            newTryNode = newTryNode.setBody(lc, outerBody).setCatchBlocks(lc, null);
         }
 
-        newTryNode = newTryNode.setCatchBlocks(Arrays.asList(catchAll)).setFinallyBody(null);
+        newTryNode = newTryNode.setCatchBlocks(lc, Arrays.asList(catchAll));
 
         /*
          * Now that the transform is done, we have to go into the try and splice
          * the finally block in front of any statement that is outside the try
          */
-        return spliceFinally(newTryNode, rethrows, finallyBody);
+        return (TryNode)lc.replace(tryNode, spliceFinally(newTryNode, rethrows.get(0), finallyBody));
     }
 
     private TryNode ensureUnconditionalCatch(final TryNode tryNode) {
@@ -535,7 +568,7 @@
         final List<Block> newCatchBlocks = new ArrayList<>(tryNode.getCatchBlocks());
 
         newCatchBlocks.add(catchAllBlock(tryNode));
-        return tryNode.setCatchBlocks(newCatchBlocks);
+        return tryNode.setCatchBlocks(lc, newCatchBlocks);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/codegen/MapCreator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/MapCreator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -68,17 +68,17 @@
      * @param evalCode      is this property map created for 'eval' code?
      * @return New map populated with accessor properties.
      */
-    PropertyMap makeFieldMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum, final boolean evalCode) {
+    PropertyMap makeFieldMap(final boolean hasArguments, final boolean dualFields, final int fieldCount, final int fieldMaximum, final boolean evalCode) {
         final List<Property> properties = new ArrayList<>();
         assert tuples != null;
 
         for (final MapTuple<T> tuple : tuples) {
             final String   key         = tuple.key;
             final Symbol   symbol      = tuple.symbol;
-            final Class<?> initialType = tuple.getValueType();
+            final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;
 
             if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
-                final int      flags    = getPropertyFlags(symbol, hasArguments, evalCode);
+                final int      flags    = getPropertyFlags(symbol, hasArguments, evalCode, dualFields);
                 final Property property = new AccessorProperty(
                         key,
                         flags,
@@ -92,7 +92,7 @@
         return PropertyMap.newMap(properties, structure.getName(), fieldCount, fieldMaximum, 0);
     }
 
-    PropertyMap makeSpillMap(final boolean hasArguments) {
+    PropertyMap makeSpillMap(final boolean hasArguments, final boolean dualFields) {
         final List<Property> properties = new ArrayList<>();
         int spillIndex = 0;
         assert tuples != null;
@@ -100,15 +100,16 @@
         for (final MapTuple<T> tuple : tuples) {
             final String key    = tuple.key;
             final Symbol symbol = tuple.symbol;
+            final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;
 
-            //TODO initial type is object here no matter what. Is that right?
             if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
-                final int flags = getPropertyFlags(symbol, hasArguments, false);
+                final int flags = getPropertyFlags(symbol, hasArguments, false, dualFields);
                 properties.add(
                         new SpillProperty(
                                 key,
                                 flags,
-                                spillIndex++));
+                                spillIndex++,
+                                initialType));
             }
         }
 
@@ -123,7 +124,7 @@
      *
      * @return flags to use for fields
      */
-    static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) {
+    static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode, final boolean dualFields) {
         int flags = 0;
 
         if (symbol.isParam()) {
@@ -161,6 +162,10 @@
             flags |= Property.NEEDS_DECLARATION;
         }
 
+        if (dualFields) {
+            flags |= Property.DUAL_FIELDS;
+        }
+
         return flags;
     }
 }
--- a/src/jdk/nashorn/internal/codegen/MapTuple.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/MapTuple.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,8 +25,6 @@
 
 package jdk.nashorn.internal.codegen;
 
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
-
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.Symbol;
 
@@ -52,11 +50,11 @@
     }
 
     public Class<?> getValueType() {
-        return OBJECT_FIELDS_ONLY ? Object.class : null; //until proven otherwise we are undefined, see NASHORN-592 int.class;
+        return null; //until proven otherwise we are undefined, see NASHORN-592 int.class;
     }
 
     boolean isPrimitive() {
-        return !OBJECT_FIELDS_ONLY && getValueType().isPrimitive() && getValueType() != boolean.class;
+        return getValueType() != null && getValueType().isPrimitive() && getValueType() != boolean.class;
     }
 
     @Override
--- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -94,7 +94,6 @@
 import jdk.nashorn.internal.ir.JoinPredecessor;
 import jdk.nashorn.internal.ir.LiteralNode;
 import jdk.nashorn.internal.ir.LocalVariableConversion;
-import jdk.nashorn.internal.ir.RuntimeNode;
 import jdk.nashorn.internal.ir.Symbol;
 import jdk.nashorn.internal.ir.TryNode;
 import jdk.nashorn.internal.objects.Global;
@@ -125,7 +124,7 @@
  * all generated bytecode and labels to stderr, for easier debugging,
  * including bytecode stack contents
  */
-public class MethodEmitter implements Emitter {
+public class MethodEmitter {
     /** The ASM MethodVisitor we are plugged into */
     private final MethodVisitor method;
 
@@ -138,9 +137,6 @@
     /** Current type stack for current evaluation */
     private Label.Stack stack;
 
-    /** Check whether this emitter ever has a function return point */
-    private boolean hasReturn;
-
     private boolean preventUndefinedLoad;
 
     /**
@@ -175,9 +171,6 @@
     /** Bootstrap for normal indy:s */
     private static final Handle LINKERBOOTSTRAP  = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor());
 
-    /** Bootstrap for runtime node indy:s */
-    private static final Handle RUNTIMEBOOTSTRAP = new Handle(H_INVOKESTATIC, RuntimeCallSite.BOOTSTRAP.className(), RuntimeCallSite.BOOTSTRAP.name(), RuntimeCallSite.BOOTSTRAP.descriptor());
-
     /** Bootstrap for array populators */
     private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor());
 
@@ -212,9 +205,7 @@
 
     /**
      * Begin a method
-     * @see Emitter
      */
-    @Override
     public void begin() {
         classEmitter.beginMethod(this);
         newStack();
@@ -223,9 +214,7 @@
 
     /**
      * End a method
-     * @see Emitter
      */
-    @Override
     public void end() {
         method.visitMaxs(0, 0);
         method.visitEnd();
@@ -1592,7 +1581,7 @@
     /**
      * Abstraction for performing a conditional jump of any type
      *
-     * @see MethodEmitter.Condition
+     * @see Condition
      *
      * @param cond      the condition to test
      * @param trueLabel the destination label is condition is true
@@ -1620,15 +1609,6 @@
         }
     }
 
-    MethodEmitter registerReturn() {
-        setHasReturn();
-        return this;
-    }
-
-    void setHasReturn() {
-        this.hasReturn = true;
-    }
-
     /**
      * Perform a non void return, popping the type from the stack
      *
@@ -2189,25 +2169,6 @@
     }
 
     /**
-     * Generate a dynamic call for a runtime node
-     *
-     * @param name       tag for the invoke dynamic for this runtime node
-     * @param returnType return type
-     * @param request    RuntimeNode request
-     *
-     * @return the method emitter
-     */
-    MethodEmitter dynamicRuntimeCall(final String name, final Type returnType, final RuntimeNode.Request request) {
-        debug("dynamic_runtime_call", name, "args=", request.getArity(), "returnType=", returnType);
-        final String signature = getDynamicSignature(returnType, request.getArity());
-        debug("   signature", signature);
-        method.visitInvokeDynamicInsn(name, signature, RUNTIMEBOOTSTRAP);
-        pushType(returnType);
-
-        return this;
-    }
-
-    /**
      * Generate dynamic getter. Pop scope from stack. Push result
      *
      * @param valueType type of the value to set
@@ -2218,6 +2179,10 @@
      * @return the method emitter
      */
     MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) {
+        if (name.length() > LARGE_STRING_THRESHOLD) { // use getIndex for extremely long names
+            return load(name).dynamicGetIndex(valueType, flags, isMethod);
+        }
+
         debug("dynamic_get", name, valueType, getProgramPoint(flags));
 
         Type type = valueType;
@@ -2243,8 +2208,13 @@
      * @param isIndex is this an index operation?
      */
     void dynamicSet(final String name, final int flags, final boolean isIndex) {
-         assert !isOptimistic(flags);
-         debug("dynamic_set", name, peekType());
+        if (name.length() > LARGE_STRING_THRESHOLD) { // use setIndex for extremely long names
+            load(name).swap().dynamicSetIndex(flags);
+            return;
+        }
+
+        assert !isOptimistic(flags);
+        debug("dynamic_set", name, peekType());
 
         Type type = peekType();
         if (type.isObject() || type.isBoolean()) { //promote strings to objects etc
@@ -2739,10 +2709,6 @@
         this.functionNode = functionNode;
     }
 
-    boolean hasReturn() {
-        return hasReturn;
-    }
-
     /**
      * Invoke to enforce assertions preventing load from a local variable slot that's known to not have been written to.
      * Used by CodeGenerator, as it strictly enforces tracking of stores. Simpler uses of MethodEmitter, e.g. those
--- a/src/jdk/nashorn/internal/codegen/Namespace.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/Namespace.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,6 +25,8 @@
 
 package jdk.nashorn.internal.codegen;
 
+import static jdk.nashorn.internal.codegen.MethodEmitter.LARGE_STRING_THRESHOLD;
+
 import java.util.HashMap;
 
 /**
@@ -66,27 +68,28 @@
     }
 
     /**
-     * Create a uniqueName name in the namespace in the form base$n where n varies
-     * .
+     * Create a uniqueName name in the namespace in the form base$n where n varies.
+     * Also truncates very long names that would otherwise break ASM.
+     *
      * @param base Base of name.  Base will be returned if uniqueName.
-     *
      * @return Generated uniqueName name.
      */
     public String uniqueName(final String base) {
+        final String truncatedBase = base.length() > LARGE_STRING_THRESHOLD ? base.substring(0, LARGE_STRING_THRESHOLD) : base;
         for (Namespace namespace = this; namespace != null; namespace = namespace.getParent()) {
             final HashMap<String, Integer> namespaceDirectory = namespace.directory;
-            final Integer                  counter            = namespaceDirectory.get(base);
+            final Integer                  counter            = namespaceDirectory.get(truncatedBase);
 
             if (counter != null) {
                 final int count = counter + 1;
-                namespaceDirectory.put(base, count);
-                return base + '-' + count;
+                namespaceDirectory.put(truncatedBase, count);
+                return truncatedBase + '-' + count;
             }
         }
 
-        directory.put(base, 0);
+        directory.put(truncatedBase, 0);
 
-        return base;
+        return truncatedBase;
     }
 
     @Override
--- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -31,7 +31,8 @@
 import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_MAP;
 import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE;
 import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS;
-import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX;
 import static jdk.nashorn.internal.codegen.CompilerConstants.className;
 import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
@@ -56,6 +57,7 @@
 import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.runtime.AccessorProperty;
+import jdk.nashorn.internal.runtime.AllocationStrategy;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.FunctionScope;
 import jdk.nashorn.internal.runtime.JSType;
@@ -98,18 +100,10 @@
      */
     private final DebugLogger log;
 
-    /**
-     * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
-     * will be a primitive 64-bit long value used for all primitives and a java.lang.Object for references.
-     * This introduces a larger number of method handles in the system, as we need to have different getters
-     * and setters for the different fields.
-     *
-     * This is engineered to plug into the TaggedArray implementation, when it's done.
-     */
-    public static final boolean OBJECT_FIELDS_ONLY = Options.getBooleanProperty("nashorn.fields.objects");
-
-    /** The field types in the system */
-    private static final List<Type> FIELD_TYPES = new LinkedList<>();
+    /** Field types for object-only fields */
+    private static final Type[] FIELD_TYPES_OBJECT = new Type[] { Type.OBJECT };
+    /** Field types for dual primitive/object fields */
+    private static final Type[] FIELD_TYPES_DUAL   = new Type[] { Type.LONG, Type.OBJECT };
 
     /** What type is the primitive type in dual representation */
     public static final Type PRIMITIVE_FIELD_TYPE = Type.LONG;
@@ -117,33 +111,27 @@
     private static final MethodHandle GET_DIFFERENT           = findOwnMH("getDifferent", Object.class, Object.class, Class.class, MethodHandle.class, MethodHandle.class, int.class);
     private static final MethodHandle GET_DIFFERENT_UNDEFINED = findOwnMH("getDifferentUndefined", Object.class, int.class);
 
-    /**
-     * The list of field types that we support - one type creates one field. This is currently either
-     * LONG + OBJECT or just OBJECT for classic mode.
-     */
-    static {
-        if (!OBJECT_FIELDS_ONLY) {
-            FIELD_TYPES.add(PRIMITIVE_FIELD_TYPE);
-        }
-        FIELD_TYPES.add(Type.OBJECT);
-    }
     private static boolean initialized = false;
 
     /** The context */
     private final Context context;
 
+    private final boolean dualFields;
+
     /**
      * Constructor
      *
      * @param context a context
+     * @param dualFields whether to use dual fields representation
      */
-    public ObjectClassGenerator(final Context context) {
+    public ObjectClassGenerator(final Context context, final boolean dualFields) {
         this.context = context;
+        this.dualFields = dualFields;
         assert context != null;
         this.log = initLogger(context);
         if (!initialized) {
             initialized = true;
-            if (OBJECT_FIELDS_ONLY) {
+            if (!dualFields) {
                 log.warning("Running with object fields only - this is a deprecated configuration.");
             }
         }
@@ -175,16 +163,30 @@
         throw new AssertionError("cannot pack" + n);
     }
 
+    private static String getPrefixName(final boolean dualFields) {
+        return dualFields ? JS_OBJECT_DUAL_FIELD_PREFIX.symbolName() : JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName();
+    }
+
+    private static String getPrefixName(final String className) {
+        if (className.startsWith(JS_OBJECT_DUAL_FIELD_PREFIX.symbolName())) {
+            return getPrefixName(true);
+        } else if (className.startsWith(JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName())) {
+            return getPrefixName(false);
+        }
+        throw new AssertionError("Not a structure class: " + className);
+    }
+
     /**
      * Returns the class name for JavaScript objects with fieldCount fields.
      *
      * @param fieldCount Number of fields to allocate.
-     *
+     * @param dualFields whether to use dual fields representation
      * @return The class name.
      */
-    public static String getClassName(final int fieldCount) {
-        return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount :
-                                 SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName();
+    public static String getClassName(final int fieldCount, final boolean dualFields) {
+        final String prefix = getPrefixName(dualFields);
+        return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + prefix + fieldCount :
+                                 SCRIPTS_PACKAGE + '/' + prefix;
     }
 
     /**
@@ -193,22 +195,23 @@
      *
      * @param fieldCount Number of fields to allocate.
      * @param paramCount Number of parameters to allocate
-     *
+     * @param dualFields whether to use dual fields representation
      * @return The class name.
      */
-    public static String getClassName(final int fieldCount, final int paramCount) {
-        return SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount + SCOPE_MARKER + paramCount;
+    public static String getClassName(final int fieldCount, final int paramCount, final boolean dualFields) {
+        return SCRIPTS_PACKAGE + '/' + getPrefixName(dualFields) + fieldCount + SCOPE_MARKER + paramCount;
     }
 
     /**
      * Returns the number of fields in the JavaScript scope class. Its name had to be generated using either
-     * {@link #getClassName(int)} or {@link #getClassName(int, int)}.
+     * {@link #getClassName(int, boolean)} or {@link #getClassName(int, int, boolean)}.
      * @param clazz the JavaScript scope class.
      * @return the number of fields in the scope class.
      */
     public static int getFieldCount(final Class<?> clazz) {
         final String name = clazz.getSimpleName();
-        final String prefix = JS_OBJECT_PREFIX.symbolName();
+        final String prefix = getPrefixName(name);
+
         if (prefix.equals(name)) {
             return 0;
         }
@@ -237,8 +240,8 @@
      * @param className  name of class
      * @param fieldNames fields to initialize to undefined, where applicable
      */
-    private static void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
-        if (!OBJECT_FIELDS_ONLY) {
+    private void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
+        if (dualFields) {
             // no need to initialize anything to undefined in the dual field world
             // - then we have a constant getter for undefined for any unknown type
             return;
@@ -291,7 +294,7 @@
      * @return Byte codes for generated class.
      */
     public byte[] generate(final int fieldCount) {
-        final String       className    = getClassName(fieldCount);
+        final String       className    = getClassName(fieldCount, dualFields);
         final String       superName    = className(ScriptObject.class);
         final ClassEmitter classEmitter = newClassEmitter(className, superName);
 
@@ -321,7 +324,7 @@
      * @return Byte codes for generated class.
      */
     public byte[] generate(final int fieldCount, final int paramCount) {
-        final String       className    = getClassName(fieldCount, paramCount);
+        final String       className    = getClassName(fieldCount, paramCount, dualFields);
         final String       superName    = className(FunctionScope.class);
         final ClassEmitter classEmitter = newClassEmitter(className, superName);
         final List<String> initFields   = addFields(classEmitter, fieldCount);
@@ -352,11 +355,11 @@
      *
      * @return List fields that need to be initialized.
      */
-    private static List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
+    private List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
         final List<String> initFields = new LinkedList<>();
-
+        final Type[] fieldTypes = dualFields ? FIELD_TYPES_DUAL : FIELD_TYPES_OBJECT;
         for (int i = 0; i < fieldCount; i++) {
-            for (final Type type : FIELD_TYPES) {
+            for (final Type type : fieldTypes) {
                 final String fieldName = getFieldName(i, type);
                 classEmitter.field(fieldName, type.getTypeClass());
 
@@ -532,13 +535,10 @@
     private static MethodHandle getterForType(final Class<?> forType, final MethodHandle primitiveGetter, final MethodHandle objectGetter) {
         switch (getAccessorTypeIndex(forType)) {
         case TYPE_INT_INDEX:
-            assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
             return MH.explicitCastArguments(primitiveGetter, primitiveGetter.type().changeReturnType(int.class));
         case TYPE_LONG_INDEX:
-            assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
             return primitiveGetter;
         case TYPE_DOUBLE_INDEX:
-            assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
             return MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE);
         case TYPE_OBJECT_INDEX:
             return objectGetter;
@@ -556,7 +556,7 @@
         final boolean isPrimitiveStorage = forType != null && forType.isPrimitive();
 
         //which is the primordial getter
-        final MethodHandle getter = OBJECT_FIELDS_ONLY ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter;
+        final MethodHandle getter = primitiveGetter == null ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter;
 
         if (forType == null) {
             if (isOptimistic) {
@@ -579,8 +579,7 @@
             return MH.dropArguments(GET_UNDEFINED.get(ti), 0, Object.class);
         }
 
-        assert forType != null;
-        assert !OBJECT_FIELDS_ONLY || forType == Object.class : forType;
+        assert primitiveGetter != null || forType == Object.class : forType;
 
         if (isOptimistic) {
             if (fti < ti) {
@@ -634,8 +633,6 @@
             return tgetter;
         }
 
-        assert !OBJECT_FIELDS_ONLY;
-        //final MethodType pmt = primitiveGetter.type();
         assert primitiveGetter != null;
         final MethodType tgetterType = tgetter.type();
         switch (fti) {
@@ -726,7 +723,7 @@
         final int fti = getAccessorTypeIndex(forType);
         final int ti  = getAccessorTypeIndex(type);
 
-        if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
+        if (fti == TYPE_OBJECT_INDEX || primitiveSetter == null) {
             if (ti == TYPE_OBJECT_INDEX) {
                 return objectSetter;
             }
@@ -734,8 +731,6 @@
             return MH.asType(objectSetter, objectSetter.type().changeParameterType(1, type));
         }
 
-        assert !OBJECT_FIELDS_ONLY;
-
         final MethodType pmt = primitiveSetter.type();
 
         switch (fti) {
@@ -826,44 +821,13 @@
     }
 
     /**
-     * Describes the allocator class name and property map for a constructor function with the specified
+     * Creates the allocator class name and property map for a constructor function with the specified
      * number of "this" properties that it initializes.
-     *
+     * @param thisProperties number of properties assigned to "this"
+     * @return the allocation strategy
      */
-    public static class AllocatorDescriptor {
-        private final String allocatorClassName;
-        private final PropertyMap allocatorMap;
-
-        /**
-         * Creates a new allocator descriptor
-         * @param thisProperties the number of "this" properties that the function initializes
-         */
-        public AllocatorDescriptor(final int thisProperties) {
-            final int paddedFieldCount = getPaddedFieldCount(thisProperties);
-            this.allocatorClassName = Compiler.binaryName(getClassName(paddedFieldCount));
-            this.allocatorMap = PropertyMap.newMap(null, allocatorClassName, 0, paddedFieldCount, 0);
-        }
-
-        /**
-         * Returns the name of the class that the function allocates
-         * @return the name of the class that the function allocates
-         */
-        public String getAllocatorClassName() {
-            return allocatorClassName;
-        }
-
-        /**
-         * Returns the allocator map for the function.
-         * @return the allocator map for the function.
-         */
-        public PropertyMap getAllocatorMap() {
-            return allocatorMap;
-        }
-
-        @Override
-        public String toString() {
-            return "AllocatorDescriptor[allocatorClassName=" + allocatorClassName + ", allocatorMap.size=" +
-                    allocatorMap.size() + "]";
-        }
+    static AllocationStrategy createAllocationStrategy(final int thisProperties, final boolean dualFields) {
+        final int paddedFieldCount = getPaddedFieldCount(thisProperties);
+        return new AllocationStrategy(paddedFieldCount, dualFields);
     }
 }
--- a/src/jdk/nashorn/internal/codegen/ObjectCreator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -134,7 +134,7 @@
 
     MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple, final boolean pack) {
         loadValue(tuple.value, tuple.type);
-        if (pack && tuple.isPrimitive()) {
+        if (pack && codegen.useDualFields() && tuple.isPrimitive()) {
             method.pack();
         } else {
             method.convert(Type.OBJECT);
@@ -146,4 +146,28 @@
         return loadTuple(method, tuple, true);
     }
 
+    /**
+     * If using optimistic typing, let the code generator realize that the newly created object on the stack
+     * when DUP-ed will be the same value. Basically: {NEW, DUP, INVOKESPECIAL init, DUP} will leave a stack
+     * load specification {unknown, unknown} on stack (that is "there's two values on the stack, but neither
+     * comes from a known local load"). If there's an optimistic operation in the literal initializer,
+     * OptimisticOperation.storeStack will allocate two temporary locals for it and store them as
+     * {ASTORE 4, ASTORE 3}. If we instead do {NEW, DUP, INVOKESPECIAL init, ASTORE 3, ALOAD 3, DUP} we end up
+     * with stack load specification {ALOAD 3, ALOAD 3} (as DUP can track that the value it duplicated came
+     * from a local load), so if/when a continuation needs to be recreated from it, it'll be
+     * able to emit ALOAD 3, ALOAD 3 to recreate the stack. If we didn't do this, deoptimization within an
+     * object literal initialization could in rare cases cause an incompatible change in the shape of the
+     * local variable table for the temporaries, e.g. in the following snippet where a variable is reassigned
+     * to a wider type in an object initializer:
+     * <code>var m = 1; var obj = {p0: m, p1: m = "foo", p2: m}</code>
+     * @param method the current method emitter.
+     */
+    void helpOptimisticRecognizeDuplicateIdentity(final MethodEmitter method) {
+        if (codegen.useOptimisticTypes()) {
+            final Type objectType = method.peekType();
+            final int tempSlot = method.defineTemporaryLocalVariable(objectType.getSlots());
+            method.storeHidden(objectType, tempSlot);
+            method.load(objectType, tempSlot);
+        }
+    }
 }
--- a/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Fri Nov 13 15:38:44 2015 -0800
@@ -61,7 +61,7 @@
 import jdk.nashorn.internal.runtime.options.Options;
 
 /**
- * Static utility that encapsulates persistence of type information for functions compiled with optimistic
+ * <p>Static utility that encapsulates persistence of type information for functions compiled with optimistic
  * typing. With this feature enabled, when a JavaScript function is recompiled because it gets deoptimized,
  * the type information for deoptimization is stored in a cache file. If the same function is compiled in a
  * subsequent JVM invocation, the type information is used for initial compilation, thus allowing the system
@@ -77,6 +77,7 @@
  * {@code nashorn.typeInfo.cleanupDelaySeconds} system property. You can also specify the word
  * {@code unlimited} as the value for {@code nashorn.typeInfo.maxFiles} in which case the type info cache is
  * allowed to grow without limits.
+ * </p>
  */
 public final class OptimisticTypesPersistence {
     // Default is 0, for disabling the feature when not specified. A reasonable default when enabled is
--- a/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,683 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.codegen;
-
-import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
-import static jdk.nashorn.internal.codegen.types.Type.BOOLEAN;
-import static jdk.nashorn.internal.codegen.types.Type.INT;
-import static jdk.nashorn.internal.lookup.Lookup.MH;
-
-import java.lang.invoke.CallSite;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.lang.invoke.MutableCallSite;
-import java.util.HashMap;
-import java.util.Map;
-import jdk.nashorn.internal.codegen.CompilerConstants.Call;
-import jdk.nashorn.internal.codegen.types.Type;
-import jdk.nashorn.internal.ir.RuntimeNode;
-import jdk.nashorn.internal.ir.RuntimeNode.Request;
-import jdk.nashorn.internal.lookup.Lookup;
-import jdk.nashorn.internal.runtime.ScriptRuntime;
-import jdk.nashorn.internal.runtime.linker.Bootstrap;
-
-/**
- * Optimistic call site that assumes its Object arguments to be of a boxed type.
- * Gradually reverts to wider boxed types if the assumption for the RuntimeNode
- * is proven wrong. Finally reverts to the generic ScriptRuntime method.
- *
- * This is used from the CodeGenerator when we have a runtime node, but 1 or more
- * primitive arguments. This class generated appropriate specializations, for example
- * {@code Object a === int b} is a good idea to specialize to {@code ((Integer)a).intValue() == b}
- * surrounded by catch blocks that will try less narrow specializations
- */
-public final class RuntimeCallSite extends MutableCallSite {
-    static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "runtimeBootstrap", CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
-
-    private static final MethodHandle NEXT = findOwnMH_V("next",  MethodHandle.class, String.class);
-
-    private final RuntimeNode.Request request;
-
-    /**
-     * A specialized runtime node, i.e. on where we know at least one more specific type than object
-     */
-    static final class SpecializedRuntimeNode {
-        private static final char REQUEST_SEPARATOR = ':';
-
-        private final RuntimeNode.Request request;
-
-        private final Type[] parameterTypes;
-
-        private final Type   returnType;
-
-        /**
-         * Constructor.
-         *
-         * @param request        runtime node request to specialize
-         * @param parameterTypes parameter types of the call site
-         * @param returnType     return type of the call site
-         */
-        SpecializedRuntimeNode(final RuntimeNode.Request request, final Type[] parameterTypes, final Type returnType) {
-            this.request        = request;
-            this.parameterTypes = parameterTypes;
-            this.returnType     = returnType;
-        }
-
-        /**
-         * The first type to try to use for this generated runtime node
-         *
-         * @return a type
-         */
-        public Type firstTypeGuess() {
-            Type widest = Type.UNKNOWN;
-            for (final Type type : parameterTypes) {
-                if (type.isObject()) {
-                    continue;
-                }
-                widest = Type.widest(type, widest);
-            }
-            widest = Type.widest(widest, firstTypeGuessForObject(request));
-
-            return widest;
-        }
-
-        private static Type firstTypeGuessForObject(final Request request) {
-            switch (request) {
-            case ADD:
-                return INT;
-            default:
-                return BOOLEAN;
-            }
-        }
-
-        Request getRequest() {
-            return request;
-        }
-
-        Type[] getParameterTypes() {
-            return parameterTypes;
-        }
-
-        Type getReturnType() {
-            return returnType;
-        }
-
-        private static char descFor(final Type type) {
-            if (type.isObject()) {
-                return 'O';
-            }
-            return type.getDescriptor().charAt(0);
-        }
-
-        @Override
-        public boolean equals(final Object other) {
-            if (other instanceof SpecializedRuntimeNode) {
-                final SpecializedRuntimeNode otherNode = (SpecializedRuntimeNode)other;
-
-                if (!otherNode.getReturnType().equals(getReturnType())) {
-                    return false;
-                }
-
-                if (getParameterTypes().length != otherNode.getParameterTypes().length) {
-                    return false;
-                }
-
-                for (int i = 0; i < getParameterTypes().length; i++) {
-                    if (!Type.areEquivalent(getParameterTypes()[i], otherNode.getParameterTypes()[i])) {
-                        return false;
-                    }
-                }
-
-                return otherNode.getRequest().equals(getRequest());
-            }
-
-            return false;
-        }
-
-        @Override
-        public int hashCode() {
-            int hashCode = getRequest().toString().hashCode();
-            hashCode ^= getReturnType().hashCode();
-            for (final Type type : getParameterTypes()) {
-                hashCode ^= type.hashCode();
-            }
-            return hashCode;
-        }
-
-        @Override
-        public String toString() {
-            final StringBuilder sb = new StringBuilder();
-            sb.append(getRequest().toString());
-            sb.append(REQUEST_SEPARATOR);
-            sb.append(descFor(getReturnType()));
-
-            for (final Type type : getParameterTypes()) {
-                sb.append(descFor(type));
-            }
-
-            return sb.toString();
-        }
-
-        String getName(final Type extraType) {
-            return toString() + "_" + descFor(extraType);
-        }
-
-        String getInitialName() {
-            return getName(firstTypeGuess());
-        }
-    }
-
-
-    /**
-     * Constructor
-     *
-     * @param type method type for call site
-     * @param name name of runtime call
-     */
-    public RuntimeCallSite(final MethodType type, final String name) {
-        super(type);
-        this.request = Request.valueOf(name.substring(0, name.indexOf(SpecializedRuntimeNode.REQUEST_SEPARATOR)));
-        setTarget(makeMethod(name));
-    }
-
-    private String nextName(final String requestName) {
-        if (requestName.equals(request.toString())) {
-            return null;
-        }
-
-        final char[] c = requestName.toCharArray();
-        final int last = c.length - 1;
-
-        if (c[last - 1] != '_') {
-            return null;
-        }
-
-        switch (c[last]) {
-        case 'Z':
-            c[last] = 'I';
-            break;
-        case 'I':
-            c[last] = 'J';
-            break;
-        case 'J':
-            c[last] = 'D';
-            break;
-        case 'D':
-        default:
-            return request.toString();
-        }
-
-        return new String(c);
-    }
-
-    private boolean isSpecialized(final String requestName) {
-        return nextName(requestName) != null;
-    }
-
-    private MethodHandle makeMethod(final String requestName) {
-        MethodHandle mh;
-
-        if (isSpecialized(requestName)) {
-            final Class<?> boxedType;
-            final Class<?> primitiveType;
-
-            switch (requestName.charAt(requestName.length() - 1)) {
-            case 'Z':
-                boxedType = Boolean.class;
-                primitiveType = int.class;
-                break;
-            case 'I':
-                boxedType = Integer.class;
-                primitiveType = int.class;
-                break;
-            case 'J':
-                boxedType = Long.class;
-                primitiveType = long.class;
-                break;
-            case 'D':
-                boxedType = Number.class;
-                primitiveType = double.class;
-                break;
-            default:
-                throw new RuntimeException("should not reach here");
-            }
-
-            final boolean isStrictCmp = (request == Request.EQ_STRICT || request == Request.NE_STRICT);
-
-            if (isStrictCmp &&
-                    (boxedType != Boolean.class &&
-                        (type().parameterType(0) == boolean.class ||
-                         type().parameterType(1) == boolean.class))) {
-                // number and boolean are never strictly equal, e.g. 0 !== false
-                mh = MH.dropArguments(MH.constant(boolean.class, request == Request.NE_STRICT), 0, type().parameterArray());
-            } else {
-                mh = METHODS.get(request.nonStrictName() + primitiveType.getSimpleName());
-                // unbox objects
-
-                for (int i = 0; i < type().parameterCount(); i++) {
-                    if (!type().parameterType(i).isPrimitive()) {
-                        mh = MH.filterArguments(mh, i, UNBOX.get(boxedType));
-                    }
-                }
-
-                mh = Lookup.filterReturnType(mh, type().returnType());
-                mh = MH.explicitCastArguments(mh, type());
-            }
-
-            final MethodHandle fallback = MH.foldArguments(MethodHandles.exactInvoker(type()), MH.insertArguments(NEXT, 0, this, requestName));
-
-            MethodHandle guard;
-            if (type().parameterType(0).isPrimitive()) {
-                guard = MH.insertArguments(
-                            MH.dropArguments(CHECKCAST, 1, type().parameterType(0)), 0, boxedType);
-            } else if (type().parameterType(1).isPrimitive()) {
-                guard = MH.insertArguments(
-                            MH.dropArguments(CHECKCAST, 2, type().parameterType(1)), 0, boxedType);
-            } else {
-                assert !type().parameterType(0).isPrimitive() && !type().parameterType(1).isPrimitive();
-                guard = MH.insertArguments(CHECKCAST2, 0, boxedType);
-            }
-
-            if (request == Request.ADD && boxedType == Integer.class) {
-                // int add needs additional overflow check
-                MethodHandle addcheck = ADDCHECK;
-                for (int i = 0; i < type().parameterCount(); i++) {
-                    if (!type().parameterType(i).isPrimitive()) {
-                        addcheck = MH.filterArguments(addcheck, i, UNBOX.get(boxedType));
-                    }
-                }
-                addcheck = MH.explicitCastArguments(addcheck, type().changeReturnType(boolean.class));
-                guard    = MH.guardWithTest(upcastGuard(guard), addcheck,
-                                MH.dropArguments(MH.constant(boolean.class, false), 0, type().parameterArray()));
-            }
-
-            return MH.guardWithTest(upcastGuard(guard), mh, fallback);
-        }
-
-        // generic fallback
-        return MH.explicitCastArguments(Lookup.filterReturnType(GENERIC_METHODS.get(request.name()), type().returnType()), type());
-    }
-
-    private MethodHandle upcastGuard(final MethodHandle guard) {
-        return MH.asType(guard, type().changeReturnType(boolean.class));
-    }
-
-    /**
-     * This is public just so that the generated specialization code can
-     * use it to get the next wider typed method
-     *
-     * Do not call directly
-     *
-     * @param name current name (with type) of runtime call at the call site
-     * @return next wider specialization method for this RuntimeCallSite
-     */
-   public MethodHandle next(final String name) {
-        final MethodHandle next = makeMethod(nextName(name));
-        setTarget(next);
-        return next;
-    }
-
-    /** Method cache */
-    private static final Map<String, MethodHandle> METHODS;
-
-    /** Generic method cache */
-    private static final Map<String, MethodHandle> GENERIC_METHODS;
-
-    /** Unbox cache */
-    private static final Map<Class<?>, MethodHandle> UNBOX;
-
-    private static final MethodHandle CHECKCAST  = findOwnMH_S("checkcast", boolean.class, Class.class, Object.class);
-    private static final MethodHandle CHECKCAST2 = findOwnMH_S("checkcast", boolean.class, Class.class, Object.class, Object.class);
-    private static final MethodHandle ADDCHECK   = findOwnMH_S("ADDcheck",  boolean.class, int.class, int.class);
-
-    /**
-     * Build maps of correct boxing operations
-     */
-    static {
-        UNBOX = new HashMap<>();
-        UNBOX.put(Boolean.class, findOwnMH_S("unboxZ", int.class, Object.class));
-        UNBOX.put(Integer.class, findOwnMH_S("unboxI", int.class, Object.class));
-        UNBOX.put(Long.class,    findOwnMH_S("unboxJ", long.class, Object.class));
-        UNBOX.put(Number.class,  findOwnMH_S("unboxD", double.class, Object.class));
-
-        METHODS = new HashMap<>();
-
-        for (final Request req : Request.values()) {
-            if (req.canSpecialize()) {
-                if (req.name().endsWith("_STRICT")) {
-                    continue;
-                }
-
-                final boolean isCmp = Request.isComparison(req);
-
-                METHODS.put(req.name() + "int",    findOwnMH_S(req.name(), (isCmp ? boolean.class : int.class),  int.class, int.class));
-                METHODS.put(req.name() + "long",   findOwnMH_S(req.name(), (isCmp ? boolean.class : long.class), long.class, long.class));
-                METHODS.put(req.name() + "double", findOwnMH_S(req.name(), (isCmp ? boolean.class : double.class), double.class, double.class));
-            }
-        }
-
-        GENERIC_METHODS = new HashMap<>();
-        for (final Request req : Request.values()) {
-            if (req.canSpecialize()) {
-                GENERIC_METHODS.put(req.name(), MH.findStatic(MethodHandles.lookup(), ScriptRuntime.class, req.name(),
-                        MH.type(req.getReturnType().getTypeClass(), Object.class, Object.class)));
-            }
-        }
-    }
-
-    /**
-     * Specialized version of != operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a != b
-     */
-    public static boolean NE(final int a, final int b) {
-        return a != b;
-    }
-
-    /**
-     * Specialized version of != operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a != b
-     */
-    public static boolean NE(final double a, final double b) {
-        return a != b;
-    }
-
-    /**
-     * Specialized version of != operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a != b
-     */
-    public static boolean NE(final long a, final long b) {
-        return a != b;
-    }
-
-    /**
-     * Specialized version of == operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a == b
-     */
-    public static boolean EQ(final int a, final int b) {
-        return a == b;
-    }
-
-    /**
-     * Specialized version of == operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a == b
-     */
-    public static boolean EQ(final double a, final double b) {
-        return a == b;
-    }
-
-    /**
-     * Specialized version of == operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a == b
-     */
-    public static boolean EQ(final long a, final long b) {
-        return a == b;
-    }
-
-    /**
-     * Specialized version of {@literal <} operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a {@code <} b
-     */
-    public static boolean LT(final int a, final int b) {
-        return a < b;
-    }
-
-    /**
-     * Specialized version of {@literal <} operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a {@literal <} b
-     */
-    public static boolean LT(final double a, final double b) {
-        return a < b;
-    }
-
-    /**
-     * Specialized version of {@literal <} operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a {@literal <} b
-     */
-    public static boolean LT(final long a, final long b) {
-        return a < b;
-    }
-
-    /**
-     * Specialized version of {@literal <=} operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a {@literal <=} b
-     */
-    public static boolean LE(final int a, final int b) {
-        return a <= b;
-    }
-
-    /**
-     * Specialized version of {@literal <=} operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a {@literal <=} b
-     */
-    public static boolean LE(final double a, final double b) {
-        return a <= b;
-    }
-
-    /**
-     * Specialized version of {@literal <=} operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a {@literal <=} b
-     */
-    public static boolean LE(final long a, final long b) {
-        return a <= b;
-    }
-
-    /**
-     * Specialized version of {@literal >} operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a {@literal >} b
-     */
-    public static boolean GT(final int a, final int b) {
-        return a > b;
-    }
-
-    /**
-     * Specialized version of {@literal >} operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a {@literal >} b
-     */
-    public static boolean GT(final double a, final double b) {
-        return a > b;
-    }
-
-    /**
-     * Specialized version of {@literal >} operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a {@literal >} b
-     */
-    public static boolean GT(final long a, final long b) {
-        return a > b;
-    }
-
-    /**
-     * Specialized version of {@literal >=} operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a {@literal >=} b
-     */
-    public static boolean GE(final int a, final int b) {
-        return a >= b;
-    }
-
-    /**
-     * Specialized version of {@literal >=} operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a {@literal >=} b
-     */
-    public static boolean GE(final double a, final double b) {
-        return a >= b;
-    }
-
-    /**
-     * Specialized version of {@literal >=} operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a {@code >=} b
-     */
-    public static boolean GE(final long a, final long b) {
-        return a >= b;
-    }
-
-    /**
-     * Specialized version of + operator for two int arguments. Do not call directly.
-     * @param a int
-     * @param b int
-     * @return a + b
-     */
-    public static int ADD(final int a, final int b) {
-        return a + b;
-    }
-
-    /**
-     * Specialized version of + operator for two long arguments. Do not call directly.
-     * @param a long
-     * @param b long
-     * @return a + b
-     */
-    public static long ADD(final long a, final long b) {
-        return a + b;
-    }
-
-    /**
-     * Specialized version of + operator for two double arguments. Do not call directly.
-     * @param a double
-     * @param b double
-     * @return a + b
-     */
-    public static double ADD(final double a, final double b) {
-        return a + b;
-    }
-
-    /**
-     * Check that ints are addition compatible, i.e. their sum is equal to the sum
-     * of them cast to long. Otherwise the addition will overflow. Do not call directly.
-     *
-     * @param a int
-     * @param b int
-     *
-     * @return true if addition does not overflow
-     */
-    public static boolean ADDcheck(final int a, final int b) {
-        return (a + b == (long)a + (long)b);
-    }
-
-    /**
-     * Checkcast used for specialized ops. Do not call directly
-     *
-     * @param type to to check against
-     * @param obj  object to check for type
-     *
-     * @return true if type check holds
-     */
-    public static boolean checkcast(final Class<?> type, final Object obj) {
-        return type.isInstance(obj);
-    }
-
-    /**
-     * Checkcast used for specialized ops. Do not call directly
-     *
-     * @param type type to check against
-     * @param objA first object to check against type
-     * @param objB second object to check against type
-     *
-     * @return true if type check holds for both objects
-     */
-    public static boolean checkcast(final Class<?> type, final Object objA, final Object objB) {
-        return type.isInstance(objA) && type.isInstance(objB);
-    }
-
-    /**
-     * Unbox a java.lang.Boolean. Do not call directly
-     * @param obj object to cast to int and unbox
-     * @return an int value for the boolean, 1 is true, 0 is false
-     */
-    public static int unboxZ(final Object obj) {
-        return (boolean)obj ? 1 : 0;
-    }
-
-    /**
-     * Unbox a java.lang.Integer. Do not call directly
-     * @param obj object to cast to int and unbox
-     * @return an int
-     */
-    public static int unboxI(final Object obj) {
-        return (int)obj;
-    }
-
-    /**
-     * Unbox a java.lang.Long. Do not call directly
-     * @param obj object to cast to long and unbox
-     * @return a long
-     */
-    public static long unboxJ(final Object obj) {
-        return (long)obj;
-    }
-
-    /**
-     * Unbox a java.lang.Number. Do not call directly
-     * @param obj object to cast to Number and unbox
-     * @return a double
-     */
-    public static double unboxD(final Object obj) {
-        return ((Number)obj).doubleValue();
-    }
-
-    private static MethodHandle findOwnMH_S(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.lookup(), RuntimeCallSite.class, name, MH.type(rtype, types));
-    }
-
-    private static MethodHandle findOwnMH_V(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findVirtual(MethodHandles.lookup(), RuntimeCallSite.class, name, MH.type(rtype, types));
-    }
-}
--- a/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,6 @@
 
 import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -42,6 +41,7 @@
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
+import jdk.nashorn.internal.scripts.JD;
 import jdk.nashorn.internal.scripts.JO;
 
 /**
@@ -65,10 +65,13 @@
         assert !isScope() : "spill scope objects are not currently supported";
 
         final int          length        = tuples.size();
-        final long[]       jpresetValues = new long[ScriptObject.spillAllocationLength(length)];
-        final Object[]     opresetValues = new Object[ScriptObject.spillAllocationLength(length)];
+        final boolean      dualFields    = codegen.useDualFields();
+        final int          spillLength   = ScriptObject.spillAllocationLength(length);
+        final long[]       jpresetValues = dualFields ? new long[spillLength] : null;
+        final Object[]     opresetValues = new Object[spillLength];
         final Set<Integer> postsetValues = new LinkedHashSet<>();
         final int          callSiteFlags = codegen.getCallSiteFlags();
+        final Class<?>     objectClass   = dualFields ? JD.class : JO.class;
         ArrayData          arrayData     = ArrayData.allocate(ScriptRuntime.EMPTY_ARRAY);
 
         // Compute constant property values
@@ -88,9 +91,9 @@
                     final Property property = propertyMap.findProperty(key);
                     if (property != null) {
                         // normal property key
-                        property.setType(JSType.unboxedFieldType(constantValue));
+                        property.setType(dualFields ? JSType.unboxedFieldType(constantValue) : Object.class);
                         final int slot = property.getSlot();
-                        if (!OBJECT_FIELDS_ONLY && constantValue instanceof Number) {
+                        if (dualFields && constantValue instanceof Number) {
                             jpresetValues[slot] = ObjectClassGenerator.pack((Number)constantValue);
                         } else {
                             opresetValues[slot] = constantValue;
@@ -127,40 +130,23 @@
             pos++;
         }
 
-        //assert postsetValues.isEmpty() : "test me " + postsetValues;
-
         // create object and invoke constructor
-        method._new(JO.class).dup();
+        method._new(objectClass).dup();
         codegen.loadConstant(propertyMap);
 
-        //load primitive values to j spill array
-        codegen.loadConstant(jpresetValues);
-        for (final int i : postsetValues) {
-            final MapTuple<Expression> tuple    = tuples.get(i);
-            final Property                property = propertyMap.findProperty(tuple.key);
-            if (property != null && tuple.isPrimitive()) {
-                method.dup();
-                method.load(property.getSlot());
-                loadTuple(method, tuple);
-                method.arraystore();
-            }
+        // load primitive value spill array
+        if (dualFields) {
+            codegen.loadConstant(jpresetValues);
+        } else {
+            method.loadNull();
         }
+        // load object value spill array
+        codegen.loadConstant(opresetValues);
 
-        //load object values to o spill array
-        codegen.loadConstant(opresetValues);
-        for (final int i : postsetValues) {
-            final MapTuple<Expression> tuple    = tuples.get(i);
-            final Property             property = propertyMap.findProperty(tuple.key);
-            if (property != null && !tuple.isPrimitive()) {
-                method.dup();
-                method.load(property.getSlot());
-                loadTuple(method, tuple);
-                method.arraystore();
-            }
-        }
+        // instantiate the script object with spill objects
+        method.invoke(constructorNoLookup(objectClass, PropertyMap.class, long[].class, Object[].class));
 
-        //instantiate the script object with spill objects
-        method.invoke(constructorNoLookup(JO.class, PropertyMap.class, long[].class, Object[].class));
+        helpOptimisticRecognizeDuplicateIdentity(method);
 
         // Set prefix array data if any
         if (arrayData.length() > 0) {
@@ -169,10 +155,10 @@
             method.invoke(virtualCallNoLookup(ScriptObject.class, "setArray", void.class, ArrayData.class));
         }
 
-        // set postfix
+        // set postfix values
         for (final int i : postsetValues) {
-            final MapTuple<Expression> tuple    = tuples.get(i);
-            final Property             property = propertyMap.findProperty(tuple.key);
+            final MapTuple<Expression> tuple = tuples.get(i);
+            final Property property = propertyMap.findProperty(tuple.key);
             if (property == null) {
                 final int index = ArrayIndex.getArrayIndex(tuple.key);
                 assert ArrayIndex.isValidArrayIndex(index);
@@ -181,6 +167,10 @@
                 //method.println("putting " + tuple + " into arraydata");
                 loadTuple(method, tuple);
                 method.dynamicSetIndex(callSiteFlags);
+            } else {
+                method.dup();
+                loadTuple(method, tuple);
+                method.dynamicSet(property.getKey(), codegen.getCallSiteFlags(), false);
             }
         }
     }
@@ -188,7 +178,9 @@
     @Override
     protected PropertyMap makeMap() {
         assert propertyMap == null : "property map already initialized";
-        propertyMap = new MapCreator<>(JO.class, tuples).makeSpillMap(false);
+        final boolean dualFields = codegen.useDualFields();
+        final Class<? extends ScriptObject> clazz = dualFields ? JD.class : JO.class;
+        propertyMap = new MapCreator<>(clazz, tuples).makeSpillMap(false, codegen.useDualFields());
         return propertyMap;
     }
 
--- a/src/jdk/nashorn/internal/codegen/SplitIntoFunctions.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/SplitIntoFunctions.java	Fri Nov 13 15:38:44 2015 -0800
@@ -51,6 +51,7 @@
 import jdk.nashorn.internal.ir.IdentNode;
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.JumpStatement;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LiteralNode;
 import jdk.nashorn.internal.ir.Node;
 import jdk.nashorn.internal.ir.ReturnNode;
@@ -100,7 +101,7 @@
     public SplitIntoFunctions(final Compiler compiler) {
         super(new BlockLexicalContext() {
             @Override
-            protected Block afterSetStatements(Block block) {
+            protected Block afterSetStatements(final Block block) {
                 for(Statement stmt: block.getStatements()) {
                     assert !(stmt instanceof SplitNode);
                 }
@@ -300,7 +301,7 @@
     }
 
     @Override
-    public boolean enterVarNode(VarNode varNode) {
+    public boolean enterVarNode(final VarNode varNode) {
         if (!inSplitNode()) {
             return super.enterVarNode(varNode);
         }
@@ -355,6 +356,11 @@
         return leaveJumpNode(continueNode);
     }
 
+    @Override
+    public Node leaveJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        return leaveJumpNode(jumpToInlinedFinally);
+    }
+
     private JumpStatement leaveJumpNode(final JumpStatement jump) {
         if (inSplitNode()) {
             final SplitState splitState = getCurrentSplitState();
--- a/src/jdk/nashorn/internal/codegen/Splitter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/Splitter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -42,13 +42,17 @@
 import jdk.nashorn.internal.ir.SplitNode;
 import jdk.nashorn.internal.ir.Statement;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.logging.DebugLogger;
+import jdk.nashorn.internal.runtime.logging.Loggable;
+import jdk.nashorn.internal.runtime.logging.Logger;
 import jdk.nashorn.internal.runtime.options.Options;
 
 /**
  * Split the IR into smaller compile units.
  */
-final class Splitter extends NodeVisitor<LexicalContext> {
+@Logger(name="splitter")
+final class Splitter extends NodeVisitor<LexicalContext> implements Loggable {
     /** Current compiler. */
     private final Compiler compiler;
 
@@ -78,7 +82,17 @@
         this.compiler             = compiler;
         this.outermost            = functionNode;
         this.outermostCompileUnit = outermostCompileUnit;
-        this.log                  = compiler.getLogger();
+        this.log                  = initLogger(compiler.getContext());
+    }
+
+    @Override
+    public DebugLogger initLogger(final Context context) {
+        return context.getLogger(this.getClass());
+    }
+
+    @Override
+    public DebugLogger getLogger() {
+        return log;
     }
 
     /**
@@ -89,7 +103,7 @@
     FunctionNode split(final FunctionNode fn, final boolean top) {
         FunctionNode functionNode = fn;
 
-        log.finest("Initiating split of '", functionNode.getName(), "'");
+        log.fine("Initiating split of '", functionNode.getName(), "'");
 
         long weight = WeighNodes.weigh(functionNode);
 
@@ -98,7 +112,7 @@
         assert lc.isEmpty() : "LexicalContext not empty";
 
         if (weight >= SPLIT_THRESHOLD) {
-            log.finest("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
+            log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
             functionNode = (FunctionNode)functionNode.accept(this);
 
             if (functionNode.isSplit()) {
--- a/src/jdk/nashorn/internal/codegen/TypeEvaluator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/TypeEvaluator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -227,7 +227,8 @@
             // gradually introduce them as needed. An easy one would be to do the same for .call(this) idiom.
             final CallNode callExpr = (CallNode)expr;
             final Expression fnExpr = callExpr.getFunction();
-            if (fnExpr instanceof FunctionNode) {
+            // Skip evaluation if running with eager compilation as we may violate constraints in RecompilableScriptFunctionData
+            if (fnExpr instanceof FunctionNode && compiler.getContext().getEnv()._lazy_compilation) {
                 final FunctionNode fn = (FunctionNode)fnExpr;
                 if (callExpr.getArgs().isEmpty()) {
                     final RecompilableScriptFunctionData data = compiler.getScriptFunctionData(fn.getId());
--- a/src/jdk/nashorn/internal/codegen/WeighNodes.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/WeighNodes.java	Fri Nov 13 15:38:44 2015 -0800
@@ -40,6 +40,7 @@
 import jdk.nashorn.internal.ir.IdentNode;
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.IndexNode;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LiteralNode;
 import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
@@ -197,6 +198,12 @@
         return indexNode;
     }
 
+    @Override
+    public Node leaveJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        weight += BREAK_WEIGHT;
+        return jumpToInlinedFinally;
+    }
+
     @SuppressWarnings("rawtypes")
     @Override
     public boolean enterLiteralNode(final LiteralNode literalNode) {
--- a/src/jdk/nashorn/internal/codegen/types/BooleanType.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/codegen/types/BooleanType.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
 /*
  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- a/src/jdk/nashorn/internal/ir/AccessNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/AccessNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,8 +28,6 @@
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.parser.Token;
-import jdk.nashorn.internal.parser.TokenType;
 
 /**
  * IR representation of a property access (period operator.)
@@ -103,14 +101,6 @@
         return property;
     }
 
-    /**
-     * Return true if this node represents an index operation normally represented as {@link IndexNode}.
-     * @return true if an index access.
-     */
-    public boolean isIndex() {
-        return Token.descType(getToken()) == TokenType.LBRACKET;
-    }
-
     private AccessNode setBase(final Expression base) {
         if (this.base == base) {
             return this;
--- a/src/jdk/nashorn/internal/ir/BaseNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/BaseNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,9 +27,9 @@
 
 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
+import jdk.nashorn.internal.parser.TokenType;
 
 /**
  * IR base for accessing/indexing nodes.
@@ -98,7 +98,7 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return type == null ? getMostPessimisticType() : type;
     }
 
@@ -123,6 +123,14 @@
     }
 
     /**
+     * Return true if this node represents an index operation normally represented as {@link IndexNode}.
+     * @return true if an index access.
+     */
+    public boolean isIndex() {
+        return isTokenType(TokenType.LBRACKET);
+    }
+
+    /**
      * Mark this node as being the callee operand of a {@link CallNode}.
      * @return a base node identical to this one in all aspects except with its function flag set.
      */
--- a/src/jdk/nashorn/internal/ir/BinaryNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/BinaryNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -31,7 +31,6 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Ignore;
 import jdk.nashorn.internal.ir.annotations.Immutable;
@@ -57,9 +56,7 @@
     private final int programPoint;
 
     private final Type type;
-
     private transient Type cachedType;
-    private transient Object cachedTypeFunction;
 
     @Ignore
     private static final Set<TokenType> CAN_OVERFLOW =
@@ -101,7 +98,7 @@
     }
 
     /**
-     * Returns true if the node is a comparison operation.
+     * Returns true if the node is a comparison operation (either equality, inequality, or relational).
      * @return true if the node is a comparison operation.
      */
     public boolean isComparison() {
@@ -121,6 +118,22 @@
     }
 
     /**
+     * Returns true if the node is a relational operation (less than (or equals), greater than (or equals)).
+     * @return true if the node is a relational operation.
+     */
+    public boolean isRelational() {
+        switch (tokenType()) {
+        case LT:
+        case GT:
+        case LE:
+        case GE:
+            return true;
+        default:
+            return false;
+        }
+    }
+
+    /**
      * Returns true if the node is a logical operation.
      * @return true if the node is a logical operation.
      */
@@ -143,24 +156,6 @@
         }
     }
 
-    private static final Function<Symbol, Type> UNKNOWN_LOCALS = new Function<Symbol, Type>() {
-        @Override
-        public Type apply(final Symbol t) {
-            return null;
-        }
-    };
-
-    /**
-     * Return the widest possible type for this operation. This is used for compile time
-     * static type inference
-     *
-     * @return Type
-     */
-    @Override
-    public Type getWidestOperationType() {
-        return getWidestOperationType(UNKNOWN_LOCALS);
-    }
-
     /**
      * Return the widest possible operand type for this operation.
      *
@@ -181,14 +176,15 @@
         }
     }
 
-    private Type getWidestOperationType(final Function<Symbol, Type> localVariableTypes) {
+    @Override
+    public Type getWidestOperationType() {
         switch (tokenType()) {
         case ADD:
         case ASSIGN_ADD: {
             // Compare this logic to decideType(Type, Type); it's similar, but it handles the optimistic type
             // calculation case while this handles the conservative case.
-            final Type lhsType = lhs.getType(localVariableTypes);
-            final Type rhsType = rhs.getType(localVariableTypes);
+            final Type lhsType = lhs.getType();
+            final Type rhsType = rhs.getType();
             if(lhsType == Type.BOOLEAN && rhsType == Type.BOOLEAN) {
                 // Will always fit in an int, as the value range is [0, 1, 2]. If we didn't treat them specially here,
                 // they'd end up being treated as generic INT operands and their sum would be conservatively considered
@@ -238,8 +234,8 @@
         case SUB:
         case ASSIGN_MUL:
         case ASSIGN_SUB: {
-            final Type lhsType = lhs.getType(localVariableTypes);
-            final Type rhsType = rhs.getType(localVariableTypes);
+            final Type lhsType = lhs.getType();
+            final Type rhsType = rhs.getType();
             if(lhsType == Type.BOOLEAN && rhsType == Type.BOOLEAN) {
                 return Type.INT;
             }
@@ -253,20 +249,20 @@
             return Type.UNDEFINED;
         }
         case ASSIGN: {
-            return rhs.getType(localVariableTypes);
+            return rhs.getType();
         }
         case INSTANCEOF: {
             return Type.BOOLEAN;
         }
         case COMMALEFT: {
-            return lhs.getType(localVariableTypes);
+            return lhs.getType();
         }
         case COMMARIGHT: {
-            return rhs.getType(localVariableTypes);
+            return rhs.getType();
         }
         case AND:
         case OR:{
-            return Type.widestReturnType(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes));
+            return Type.widestReturnType(lhs.getType(), rhs.getType());
         }
         default:
             if (isComparison()) {
@@ -316,7 +312,7 @@
 
     @Override
     public boolean isSelfModifying() {
-        return isAssignment() && tokenType() != TokenType.ASSIGN;
+        return isAssignment() && !isTokenType(TokenType.ASSIGN);
     }
 
     @Override
@@ -487,7 +483,7 @@
 
     /**
      * Set the right hand side expression for this node
-     * @param rhs new left hand side expression
+     * @param rhs new right hand side expression
      * @return a node equivalent to this one except for the requested change.
      */
     public BinaryNode setRHS(final Expression rhs) {
@@ -497,6 +493,19 @@
         return new BinaryNode(this, lhs, rhs, type, programPoint);
     }
 
+    /**
+     * Set both the left and the right hand side expression for this node
+     * @param lhs new left hand side expression
+     * @param rhs new left hand side expression
+     * @return a node equivalent to this one except for the requested change.
+     */
+    public BinaryNode setOperands(final Expression lhs, final Expression rhs) {
+        if (this.lhs == lhs && this.rhs == rhs) {
+            return this;
+        }
+        return new BinaryNode(this, lhs, rhs, type, programPoint);
+    }
+
     @Override
     public int getProgramPoint() {
         return programPoint;
@@ -520,7 +529,7 @@
         final TokenType tokenType = tokenType();
         if(tokenType == TokenType.ADD || tokenType == TokenType.ASSIGN_ADD) {
             return OPTIMISTIC_UNDECIDED_TYPE;
-        } else if (CAN_OVERFLOW.contains(tokenType())) {
+        } else if (CAN_OVERFLOW.contains(tokenType)) {
             return Type.INT;
         }
         return getMostPessimisticType();
@@ -541,24 +550,22 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
-        if(localVariableTypes == cachedTypeFunction) {
-            return cachedType;
+    public Type getType() {
+        if (cachedType == null) {
+            cachedType = getTypeUncached();
         }
-        cachedType = getTypeUncached(localVariableTypes);
-        cachedTypeFunction = localVariableTypes;
         return cachedType;
     }
 
-    private Type getTypeUncached(final Function<Symbol, Type> localVariableTypes) {
+    private Type getTypeUncached() {
         if(type == OPTIMISTIC_UNDECIDED_TYPE) {
-            return decideType(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes));
+            return decideType(lhs.getType(), rhs.getType());
         }
-        final Type widest = getWidestOperationType(localVariableTypes);
+        final Type widest = getWidestOperationType();
         if(type == null) {
             return widest;
         }
-        return Type.narrowest(widest, Type.widest(type, Type.widest(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes))));
+        return Type.narrowest(widest, Type.widest(type, Type.widest(lhs.getType(), rhs.getType())));
     }
 
     private static Type decideType(final Type lhsType, final Type rhsType) {
--- a/src/jdk/nashorn/internal/ir/Block.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/Block.java	Fri Nov 13 15:38:44 2015 -0800
@@ -298,6 +298,14 @@
     }
 
     /**
+     * Returns the last statement in the block.
+     * @return the last statement in the block, or null if the block has no statements.
+     */
+    public Statement getLastStatement() {
+        return statements.isEmpty() ? null : statements.get(statements.size() - 1);
+    }
+
+    /**
      * Reset the statement list for this block
      *
      * @param lc lexical context
--- a/src/jdk/nashorn/internal/ir/BlockLexicalContext.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/BlockLexicalContext.java	Fri Nov 13 15:38:44 2015 -0800
@@ -74,7 +74,7 @@
 
     @SuppressWarnings("unchecked")
     @Override
-    public <T extends LexicalContextNode> T pop(final T node) {
+    public <T extends Node> T pop(final T node) {
         T expected = node;
         if (node instanceof Block) {
             final List<Statement> newStatements = popStatements();
--- a/src/jdk/nashorn/internal/ir/BlockStatement.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/BlockStatement.java	Fri Nov 13 15:38:44 2015 -0800
@@ -40,6 +40,15 @@
     /**
      * Constructor
      *
+     * @param block the block to execute
+     */
+    public BlockStatement(final Block block) {
+        this(block.getFirstStatementLineNumber(), block);
+    }
+
+    /**
+     * Constructor
+     *
      * @param lineNumber line number
      * @param block the block to execute
      */
--- a/src/jdk/nashorn/internal/ir/BreakNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/BreakNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -77,7 +77,7 @@
     }
 
     @Override
-    public Label getTargetLabel(final BreakableNode target) {
+    Label getTargetLabel(final BreakableNode target) {
         return target.getBreakLabel();
     }
 }
--- a/src/jdk/nashorn/internal/ir/CallNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/CallNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -30,7 +30,6 @@
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Ignore;
 import jdk.nashorn.internal.ir.annotations.Immutable;
@@ -154,7 +153,7 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return optimisticType == null ? Type.OBJECT : optimisticType;
     }
 
--- a/src/jdk/nashorn/internal/ir/ContinueNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/ContinueNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -78,7 +78,7 @@
     }
 
     @Override
-    public Label getTargetLabel(final BreakableNode target) {
+    Label getTargetLabel(final BreakableNode target) {
         return ((LoopNode)target).getContinueLabel();
     }
 }
--- a/src/jdk/nashorn/internal/ir/Expression.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/Expression.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.ir;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
 
@@ -39,14 +38,7 @@
 
     static final String OPT_IDENTIFIER = "%";
 
-    private static final Function<Symbol, Type> UNKNOWN_LOCALS = new Function<Symbol, Type>() {
-        @Override
-        public Type apply(final Symbol t) {
-            return null;
-        }
-    };
-
-    Expression(final long token, final int start, final int finish) {
+    protected Expression(final long token, final int start, final int finish) {
         super(token, start, finish);
     }
 
@@ -63,18 +55,7 @@
      *
      * @return the type of the expression.
      */
-    public final Type getType() {
-        return getType(UNKNOWN_LOCALS);
-    }
-
-    /**
-     * Returns the type of the expression under the specified symbol-to-type mapping. By default delegates to
-     * {@link #getType()} but expressions whose type depends on their subexpressions' types and expressions whose type
-     * depends on symbol type ({@link IdentNode}) will have a special implementation.
-     * @param localVariableTypes a mapping from symbols to their types, used for type calculation.
-     * @return the type of the expression under the specified symbol-to-type mapping.
-     */
-    public abstract Type getType(final Function<Symbol, Type> localVariableTypes);
+    public abstract Type getType();
 
     /**
      * Returns {@code true} if this expression depends exclusively on state that is constant
--- a/src/jdk/nashorn/internal/ir/FunctionNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/FunctionNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -36,7 +36,6 @@
 import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.AssertsEnabled;
 import jdk.nashorn.internal.codegen.CompileUnit;
 import jdk.nashorn.internal.codegen.Compiler;
@@ -1142,8 +1141,17 @@
         return getFlag(USES_SELF_SYMBOL);
     }
 
+    /**
+     * Returns true if this is a named function expression (that is, it isn't a declared function, it isn't an
+     * anonymous function expression, and it isn't a program).
+     * @return true if this is a named function expression
+     */
+    public boolean isNamedFunctionExpression() {
+        return !getFlag(IS_PROGRAM | IS_ANONYMOUS | IS_DECLARED);
+    }
+
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return FUNCTION_TYPE;
     }
 
--- a/src/jdk/nashorn/internal/ir/GetSplitState.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/GetSplitState.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.ir;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
@@ -47,7 +46,7 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return Type.INT;
     }
 
--- a/src/jdk/nashorn/internal/ir/IdentNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/IdentNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -30,7 +30,6 @@
 import static jdk.nashorn.internal.codegen.CompilerConstants.__LINE__;
 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
@@ -118,14 +117,13 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         if(type != null) {
             return type;
         } else if(symbol != null && symbol.isScope()) {
             return Type.OBJECT;
         }
-        final Type symbolType = localVariableTypes.apply(symbol);
-        return symbolType == null ? Type.UNDEFINED : symbolType;
+        return Type.UNDEFINED;
     }
 
     /**
--- a/src/jdk/nashorn/internal/ir/JoinPredecessorExpression.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/JoinPredecessorExpression.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.ir;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
 
@@ -71,8 +70,8 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
-        return expression.getType(localVariableTypes);
+    public Type getType() {
+        return expression.getType();
     }
 
     @Override
--- a/src/jdk/nashorn/internal/ir/JumpStatement.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/JumpStatement.java	Fri Nov 13 15:38:44 2015 -0800
@@ -101,7 +101,26 @@
      * @throws ClassCastException if invoked on the kind of breakable node that this jump statement is not prepared to
      * handle.
      */
-    public abstract Label getTargetLabel(final BreakableNode target);
+    abstract Label getTargetLabel(final BreakableNode target);
+
+    /**
+     * Returns the label this jump statement targets.
+     * @param lc the lexical context
+     * @return the label this jump statement targets.
+     */
+    public Label getTargetLabel(final LexicalContext lc) {
+        return getTargetLabel(getTarget(lc));
+    }
+
+    /**
+     * Returns the limit node for popping scopes when this jump statement is effected.
+     * @param lc the current lexical context
+     * @return the limit node for popping scopes when this jump statement is effected.
+     */
+    public LexicalContextNode getPopScopeLimit(final LexicalContext lc) {
+        // In most cases (break and continue) this is equal to the target.
+        return getTarget(lc);
+    }
 
     @Override
     public JumpStatement setLocalVariableConversion(final LexicalContext lc, final LocalVariableConversion conversion) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/internal/ir/JumpToInlinedFinally.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.ir;
+
+import java.util.Objects;
+import jdk.nashorn.internal.codegen.Label;
+import jdk.nashorn.internal.ir.annotations.Immutable;
+import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+
+/**
+ * IR representation for synthetic jump into an inlined finally statement.
+ */
+@Immutable
+public final class JumpToInlinedFinally extends JumpStatement {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructor
+     *
+     * @param labelName  label name for inlined finally block
+     */
+    public JumpToInlinedFinally(final String labelName) {
+        super(NO_LINE_NUMBER, NO_TOKEN, NO_FINISH, Objects.requireNonNull(labelName));
+    }
+
+    private JumpToInlinedFinally(final JumpToInlinedFinally breakNode, final LocalVariableConversion conversion) {
+        super(breakNode, conversion);
+    }
+
+    @Override
+    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
+        if (visitor.enterJumpToInlinedFinally(this)) {
+            return visitor.leaveJumpToInlinedFinally(this);
+        }
+
+        return this;
+    }
+
+    @Override
+    JumpStatement createNewJumpStatement(final LocalVariableConversion conversion) {
+        return new JumpToInlinedFinally(this, conversion);
+    }
+
+    @Override
+    String getStatementName() {
+        return ":jumpToInlinedFinally";
+    }
+
+    @Override
+    public Block getTarget(final LexicalContext lc) {
+        return lc.getInlinedFinally(getLabelName());
+    }
+
+    @Override
+    public TryNode getPopScopeLimit(final LexicalContext lc) {
+        // Returns the try node to which this jump's target belongs. This will make scope popping also pop the scope
+        // for the body of the try block, if it needs scope.
+        return lc.getTryNodeForInlinedFinally(getLabelName());
+    }
+
+    @Override
+    Label getTargetLabel(final BreakableNode target) {
+        assert target != null;
+        // We're jumping to the entry of the inlined finally block
+        return ((Block)target).getEntryLabel();
+    }
+}
--- a/src/jdk/nashorn/internal/ir/LexicalContext.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/LexicalContext.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,13 @@
 import jdk.nashorn.internal.runtime.Source;
 
 /**
- * A class that tracks the current lexical context of node visitation as a stack of {@link Block} nodes. Has special
- * methods to retrieve useful subsets of the context.
+ * A class that tracks the current lexical context of node visitation as a stack
+ * of {@link Block} nodes. Has special methods to retrieve useful subsets of the
+ * context.
  *
- * This is implemented with a primitive array and a stack pointer, because it really makes a difference
- * performance wise. None of the collection classes were optimal
+ * This is implemented with a primitive array and a stack pointer, because it
+ * really makes a difference performance-wise. None of the collection classes
+ * were optimal.
  */
 public class LexicalContext {
     private LexicalContextNode[] stack;
@@ -79,6 +81,7 @@
      * {@link Block#NEEDS_SCOPE} because it atomically also sets the
      * {@link FunctionNode#HAS_SCOPE_BLOCK} flag on the block's containing
      * function.
+     *
      * @param block the block that needs to be marked as creating a scope.
      */
     public void setBlockNeedsScope(final Block block) {
@@ -97,8 +100,10 @@
     }
 
     /**
-     * Get the flags for a lexical context node on the stack
+     * Get the flags for a lexical context node on the stack.
+     *
      * @param node node
+     *
      * @return the flags for the node
      */
     public int getFlags(final LexicalContextNode node) {
@@ -112,8 +117,10 @@
 
     /**
      * Get the function body of a function node on the lexical context
-     * stack. This will trigger an assertion if node isn't present
+     * stack. This will trigger an assertion if node isn't present.
+     *
      * @param functionNode function node
+     *
      * @return body of function node
      */
     public Block getFunctionBody(final FunctionNode functionNode) {
@@ -126,15 +133,16 @@
     }
 
     /**
-     * Return all nodes in the LexicalContext
-     * @return all nodes
+     * @return all nodes in the LexicalContext.
      */
     public Iterator<LexicalContextNode> getAllNodes() {
         return new NodeIterator<>(LexicalContextNode.class);
     }
 
     /**
-     * Returns the outermost function in this context. It is either the program, or a lazily compiled function.
+     * Returns the outermost function in this context. It is either the program,
+     * or a lazily compiled function.
+     *
      * @return the outermost function in this context.
      */
     public FunctionNode getOutermostFunction() {
@@ -142,8 +150,12 @@
     }
 
     /**
-     * Pushes a new block on top of the context, making it the innermost open block.
+     * Pushes a new block on top of the context, making it the innermost open
+     * block.
+     *
+     * @param <T> the type of the new node
      * @param node the new node
+     *
      * @return the node that was pushed
      */
     public <T extends LexicalContextNode> T push(final T node) {
@@ -168,29 +180,32 @@
 
     /**
      * Is the context empty?
-     * @return true if empty
+     *
+     * @return {@code true} if empty
      */
     public boolean isEmpty() {
         return sp == 0;
     }
 
     /**
-     * The depth of the lexical context
-     * @return depth
+     * @return the depth of the lexical context.
      */
     public int size() {
         return sp;
     }
 
     /**
-     * Pops the innermost block off the context and all nodes that has been contributed
-     * since it was put there
+     * Pops the innermost block off the context and all nodes that has been
+     * contributed since it was put there.
      *
-     * @param node the node expected to be popped, used to detect unbalanced pushes/pops
+     * @param <T> the type of the node to be popped
+     * @param node the node expected to be popped, used to detect unbalanced
+     *        pushes/pops
+     *
      * @return the node that was popped
      */
     @SuppressWarnings("unchecked")
-    public <T extends LexicalContextNode> T pop(final T node) {
+    public <T extends Node> T pop(final T node) {
         --sp;
         final LexicalContextNode popped = stack[sp];
         stack[sp] = null;
@@ -202,11 +217,17 @@
     }
 
     /**
-     * Explicitly apply flags to the topmost element on the stack. This is only valid to use from a
-     * {@code NodeVisitor.leaveXxx()} method and only on the node being exited at the time. It is not mandatory to use,
-     * as {@link #pop(LexicalContextNode)} will apply the flags automatically, but this method can be used to apply them
-     * during the {@code leaveXxx()} method in case its logic depends on the value of the flags.
-     * @param node the node to apply the flags to. Must be the topmost node on the stack.
+     * Explicitly apply flags to the topmost element on the stack. This is only
+     * valid to use from a {@code NodeVisitor.leaveXxx()} method and only on the
+     * node being exited at the time. It is not mandatory to use, as
+     * {@link #pop(Node)} will apply the flags automatically, but this method
+     * can be used to apply them during the {@code leaveXxx()} method in case
+     * its logic depends on the value of the flags.
+     *
+     * @param <T> the type of the node to apply the flags to.
+     * @param node the node to apply the flags to. Must be the topmost node on
+     *        the stack.
+     *
      * @return the passed in node, or a modified node (if any flags were modified)
      */
     public <T extends LexicalContextNode & Flags<T>> T applyTopFlags(final T node) {
@@ -215,7 +236,8 @@
     }
 
     /**
-     * Return the top element in the context
+     * Return the top element in the context.
+     *
      * @return the node that was pushed last
      */
     public LexicalContextNode peek() {
@@ -223,9 +245,11 @@
     }
 
     /**
-     * Check if a node is in the lexical context
+     * Check if a node is in the lexical context.
+     *
      * @param node node to check for
-     * @return true if in the context
+     *
+     * @return {@code true} if in the context
      */
     public boolean contains(final LexicalContextNode node) {
         for (int i = 0; i < sp; i++) {
@@ -242,6 +266,7 @@
      *
      * @param oldNode old node
      * @param newNode new node
+     *
      * @return the new node
      */
     public LexicalContextNode replace(final LexicalContextNode oldNode, final LexicalContextNode newNode) {
@@ -256,7 +281,9 @@
     }
 
     /**
-     * Returns an iterator over all blocks in the context, with the top block (innermost lexical context) first.
+     * Returns an iterator over all blocks in the context, with the top block
+     * (innermost lexical context) first.
+     *
      * @return an iterator over all blocks in the context.
      */
     public Iterator<Block> getBlocks() {
@@ -264,7 +291,9 @@
     }
 
     /**
-     * Returns an iterator over all functions in the context, with the top (innermost open) function first.
+     * Returns an iterator over all functions in the context, with the top
+     * (innermost open) function first.
+     *
      * @return an iterator over all functions in the context.
      */
     public Iterator<FunctionNode> getFunctions() {
@@ -273,6 +302,7 @@
 
     /**
      * Get the parent block for the current lexical context block
+     *
      * @return parent block
      */
     public Block getParentBlock() {
@@ -283,7 +313,9 @@
 
     /**
      * Gets the label node of the current block.
-     * @return the label node of the current block, if it is labeled. Otherwise returns null.
+     *
+     * @return the label node of the current block, if it is labeled. Otherwise
+     *         returns {@code null}.
      */
     public LabelNode getCurrentBlockLabelNode() {
         assert stack[sp - 1] instanceof Block;
@@ -294,21 +326,12 @@
         return parent instanceof LabelNode ? (LabelNode)parent : null;
     }
 
-
-    /*
-    public FunctionNode getProgram() {
-        final Iterator<FunctionNode> iter = getFunctions();
-        FunctionNode last = null;
-        while (iter.hasNext()) {
-            last = iter.next();
-        }
-        assert last != null;
-        return last;
-    }*/
-
     /**
-     * Returns an iterator over all ancestors block of the given block, with its parent block first.
+     * Returns an iterator over all ancestors block of the given block, with its
+     * parent block first.
+     *
      * @param block the block whose ancestors are returned
+     *
      * @return an iterator over all ancestors block of the given block.
      */
     public Iterator<Block> getAncestorBlocks(final Block block) {
@@ -323,8 +346,11 @@
     }
 
     /**
-     * Returns an iterator over a block and all its ancestors blocks, with the block first.
+     * Returns an iterator over a block and all its ancestors blocks, with the
+     * block first.
+     *
      * @param block the block that is the starting point of the iteration.
+     *
      * @return an iterator over a block and all its ancestors.
      */
     public Iterator<Block> getBlocks(final Block block) {
@@ -352,7 +378,9 @@
 
     /**
      * Get the function for this block.
+     *
      * @param block block for which to get function
+     *
      * @return function for block
      */
     public FunctionNode getFunction(final Block block) {
@@ -373,7 +401,6 @@
     }
 
     /**
-     * Returns the innermost block in the context.
      * @return the innermost block in the context.
      */
     public Block getCurrentBlock() {
@@ -381,7 +408,6 @@
     }
 
     /**
-     * Returns the innermost function in the context.
      * @return the innermost function in the context.
      */
     public FunctionNode getCurrentFunction() {
@@ -394,9 +420,12 @@
     }
 
     /**
-     * Get the block in which a symbol is defined
+     * Get the block in which a symbol is defined.
+     *
      * @param symbol symbol
-     * @return block in which the symbol is defined, assert if no such block in context
+     *
+     * @return block in which the symbol is defined, assert if no such block in
+     *         context.
      */
     public Block getDefiningBlock(final Symbol symbol) {
         final String name = symbol.getName();
@@ -410,9 +439,12 @@
     }
 
     /**
-     * Get the function in which a symbol is defined
+     * Get the function in which a symbol is defined.
+     *
      * @param symbol symbol
-     * @return function node in which this symbol is defined, assert if no such symbol exists in context
+     *
+     * @return function node in which this symbol is defined, assert if no such
+     *         symbol exists in context.
      */
     public FunctionNode getDefiningFunction(final Symbol symbol) {
         final String name = symbol.getName();
@@ -433,7 +465,8 @@
 
     /**
      * Is the topmost lexical context element a function body?
-     * @return true if function body
+     *
+     * @return {@code true} if function body.
      */
     public boolean isFunctionBody() {
         return getParentBlock() == null;
@@ -441,16 +474,20 @@
 
     /**
      * Is the topmost lexical context element body of a SplitNode?
-     * @return true if it's the body of a split node.
+     *
+     * @return {@code true} if it's the body of a split node.
      */
     public boolean isSplitBody() {
         return sp >= 2 && stack[sp - 1] instanceof Block && stack[sp - 2] instanceof SplitNode;
     }
 
     /**
-     * Get the parent function for a function in the lexical context
+     * Get the parent function for a function in the lexical context.
+     *
      * @param functionNode function for which to get parent
-     * @return parent function of functionNode or null if none (e.g. if functionNode is the program)
+     *
+     * @return parent function of functionNode or {@code null} if none (e.g., if
+     *         functionNode is the program).
      */
     public FunctionNode getParentFunction(final FunctionNode functionNode) {
         final Iterator<FunctionNode> iter = new NodeIterator<>(FunctionNode.class);
@@ -465,12 +502,16 @@
     }
 
     /**
-     * Count the number of scopes until a given node. Note that this method is solely used to figure out the number of
-     * scopes that need to be explicitly popped in order to perform a break or continue jump within the current bytecode
-     * method. For this reason, the method returns 0 if it encounters a {@code SplitNode} between the current location
-     * and the break/continue target.
-     * @param until node to stop counting at. Must be within the current  function
-     * @return number of with scopes encountered in the context
+     * Count the number of scopes until a given node. Note that this method is
+     * solely used to figure out the number of scopes that need to be explicitly
+     * popped in order to perform a break or continue jump within the current
+     * bytecode method. For this reason, the method returns 0 if it encounters a
+     * {@code SplitNode} between the current location and the break/continue
+     * target.
+     *
+     * @param until node to stop counting at. Must be within the current function.
+     *
+     * @return number of with scopes encountered in the context.
      */
     public int getScopeNestingLevelTo(final LexicalContextNode until) {
         assert until != null;
@@ -500,16 +541,17 @@
     }
 
     /**
-     * Check whether the lexical context is currently inside a loop
-     * @return true if inside a loop
+     * Check whether the lexical context is currently inside a loop.
+     *
+     * @return {@code true} if inside a loop
      */
     public boolean inLoop() {
         return getCurrentLoop() != null;
     }
 
     /**
-     * Returns the loop header of the current loop, or null if not inside a loop
-     * @return loop header
+     * @return the loop header of the current loop, or {@code null} if not
+     *         inside a loop.
      */
     public LoopNode getCurrentLoop() {
         final Iterator<LoopNode> iter = new NodeIterator<>(LoopNode.class, getCurrentFunction());
@@ -518,9 +560,12 @@
 
     /**
      * Find the breakable node corresponding to this label.
-     * @param labelName name of the label to search for. If null, the closest breakable node will be returned
-     * unconditionally, e.g. a while loop with no label
-     * @return closest breakable node
+     *
+     * @param labelName name of the label to search for. If {@code null}, the
+     *        closest breakable node will be returned unconditionally, e.g., a
+     *        while loop with no label.
+     *
+     * @return closest breakable node.
      */
     public BreakableNode getBreakable(final String labelName) {
         if (labelName != null) {
@@ -544,9 +589,12 @@
 
     /**
      * Find the continue target node corresponding to this label.
-     * @param labelName label name to search for. If null the closest loop node will be returned unconditionally, e.g. a
-     * while loop with no label
-     * @return closest continue target node
+     *
+     * @param labelName label name to search for. If {@code null} the closest
+     *        loop node will be returned unconditionally, e.g., a while loop
+     *        with no label.
+     *
+     * @return closest continue target node.
      */
     public LoopNode getContinueTo(final String labelName) {
         if (labelName != null) {
@@ -565,9 +613,45 @@
     }
 
     /**
-     * Check the lexical context for a given label node by name
-     * @param name name of the label
-     * @return LabelNode if found, null otherwise
+     * Find the inlined finally block node corresponding to this label.
+     *
+     * @param labelName label name to search for. Must not be {@code null}.
+     *
+     * @return closest inlined finally block with the given label.
+     */
+    public Block getInlinedFinally(final String labelName) {
+        for (final NodeIterator<TryNode> iter = new NodeIterator<>(TryNode.class); iter.hasNext(); ) {
+            final Block inlinedFinally = iter.next().getInlinedFinally(labelName);
+            if (inlinedFinally != null) {
+                return inlinedFinally;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Find the try node for an inlined finally block corresponding to this label.
+     *
+     * @param labelName label name to search for. Must not be {@code null}.
+     *
+     * @return the try node to which the labelled inlined finally block belongs.
+     */
+    public TryNode getTryNodeForInlinedFinally(final String labelName) {
+        for (final NodeIterator<TryNode> iter = new NodeIterator<>(TryNode.class); iter.hasNext(); ) {
+            final TryNode tryNode = iter.next();
+            if (tryNode.getInlinedFinally(labelName) != null) {
+                return tryNode;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Check the lexical context for a given label node by name.
+     *
+     * @param name name of the label.
+     *
+     * @return LabelNode if found, {@code null} otherwise.
      */
     public LabelNode findLabel(final String name) {
         for (final Iterator<LabelNode> iter = new NodeIterator<>(LabelNode.class, getCurrentFunction()); iter.hasNext(); ) {
@@ -580,10 +664,13 @@
     }
 
     /**
-     * Checks whether a given target is a jump destination that lies outside a given split node
-     * @param splitNode the split node
-     * @param target the target node
-     * @return true if target resides outside the split node
+     * Checks whether a given target is a jump destination that lies outside a
+     * given split node.
+     *
+     * @param splitNode the split node.
+     * @param target the target node.
+     *
+     * @return {@code true} if target resides outside the split node.
      */
     public boolean isExternalTarget(final SplitNode splitNode, final BreakableNode target) {
         for (int i = sp; i-- > 0;) {
@@ -592,14 +679,22 @@
                 return true;
             } else if (next == target) {
                 return false;
+            } else if (next instanceof TryNode) {
+                for(final Block inlinedFinally: ((TryNode)next).getInlinedFinallies()) {
+                    if (TryNode.getLabelledInlinedFinallyBlock(inlinedFinally) == target) {
+                        return false;
+                    }
+                }
             }
         }
         throw new AssertionError(target + " was expected in lexical context " + LexicalContext.this + " but wasn't");
     }
 
     /**
-     * Checks whether the current context is inside a switch statement without explicit blocks (curly braces).
-     * @return true if in unprotected switch statement
+     * Checks whether the current context is inside a switch statement without
+     * explicit blocks (curly braces).
+     *
+     * @return {@code true} if in unprotected switch statement.
      */
     public boolean inUnprotectedSwitchContext() {
         for (int i = sp; i > 0; i--) {
--- a/src/jdk/nashorn/internal/ir/LexicalContextNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/LexicalContextNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -54,8 +54,8 @@
         static Node accept(final LexicalContextNode node, final NodeVisitor<? extends LexicalContext> visitor) {
             final LexicalContext lc = visitor.getLexicalContext();
             lc.push(node);
-            final LexicalContextNode newNode = (LexicalContextNode)node.accept(lc, visitor);
-            return (Node)lc.pop(newNode);
+            final Node newNode = node.accept(lc, visitor);
+            return lc.pop(newNode);
         }
     }
 }
--- a/src/jdk/nashorn/internal/ir/LiteralNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/LiteralNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -29,7 +29,6 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.CompileUnit;
 import jdk.nashorn.internal.codegen.types.ArrayType;
 import jdk.nashorn.internal.codegen.types.Type;
@@ -109,7 +108,7 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return Type.typeFor(value.getClass());
     }
 
@@ -164,16 +163,6 @@
     }
 
     /**
-     * Get the array value of the node
-     *
-     * @return the array value
-     */
-    public Node[] getArray() {
-        assert false : "not an array node";
-        return null;
-    }
-
-    /**
      * Fetch String value of node.
      *
      * @return String value of node.
@@ -325,7 +314,7 @@
         }
 
         @Override
-        public Type getType(final Function<Symbol, Type> localVariableTypes) {
+        public Type getType() {
             return Type.BOOLEAN;
         }
 
@@ -389,7 +378,7 @@
         }
 
         @Override
-        public Type getType(final Function<Symbol, Type> localVariableTypes) {
+        public Type getType() {
             return type;
         }
 
@@ -519,7 +508,7 @@
         }
 
         @Override
-        public Type getType(final Function<Symbol, Type> localVariableTypes) {
+        public Type getType() {
             return Type.OBJECT;
         }
 
@@ -589,7 +578,7 @@
         }
 
         @Override
-        public Type getType(final Function<Symbol, Type> localVariableTypes) {
+        public Type getType() {
             return Type.OBJECT;
         }
 
@@ -840,9 +829,13 @@
             this.units       = units;
         }
 
-        @Override
-        public Node[] getArray() {
-            return value;
+        /**
+         * Returns a list of array element expressions. Note that empty array elements manifest themselves as
+         * null.
+         * @return a list of array element expressions.
+         */
+        public List<Expression> getElementExpressions() {
+            return Collections.unmodifiableList(Arrays.asList(value));
         }
 
         /**
@@ -879,7 +872,7 @@
         }
 
         @Override
-        public Type getType(final Function<Symbol, Type> localVariableTypes) {
+        public Type getType() {
             return Type.typeFor(NativeArray.class);
         }
 
--- a/src/jdk/nashorn/internal/ir/Node.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/Node.java	Fri Nov 13 15:38:44 2015 -0800
@@ -220,26 +220,28 @@
     }
 
     /**
-     * Return token tokenType from a token descriptor.
+     * Returns this node's token's type. If you want to check for the node having a specific token type,
+     * consider using {@link #isTokenType(TokenType)} instead.
      *
-     * @return Type of token.
+     * @return type of token.
      */
     public TokenType tokenType() {
         return Token.descType(token);
     }
 
     /**
-     * Test token tokenType.
+     * Tests if this node has the specific token type.
      *
-     * @param type a type to check this token against
+     * @param type a token type to check this node's token type against
      * @return true if token types match.
      */
     public boolean isTokenType(final TokenType type) {
-        return Token.descType(token) == type;
+        return tokenType() == type;
     }
 
     /**
-     * Get the token for this location
+     * Get the token for this node. If you want to retrieve the token's type, consider using
+     * {@link #tokenType()} or {@link #isTokenType(TokenType)} instead.
      * @return the token
      */
     public long getToken() {
--- a/src/jdk/nashorn/internal/ir/ObjectNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/ObjectNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,6 @@
 
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
@@ -69,7 +68,7 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return Type.OBJECT;
     }
 
--- a/src/jdk/nashorn/internal/ir/OptimisticLexicalContext.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/OptimisticLexicalContext.java	Fri Nov 13 15:38:44 2015 -0800
@@ -115,7 +115,7 @@
     }
 
     @Override
-    public <T extends LexicalContextNode> T pop(final T node) {
+    public <T extends Node> T pop(final T node) {
         final T popped = super.pop(node);
         if (isEnabled) {
             if(node instanceof FunctionNode) {
--- a/src/jdk/nashorn/internal/ir/RuntimeNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/RuntimeNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,12 +25,9 @@
 
 package jdk.nashorn.internal.ir;
 
-import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
@@ -40,7 +37,7 @@
  * IR representation for a runtime call.
  */
 @Immutable
-public class RuntimeNode extends Expression implements Optimistic {
+public class RuntimeNode extends Expression {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -334,11 +331,6 @@
     /** Call arguments. */
     private final List<Expression> args;
 
-    /** is final - i.e. may not be removed again, lower in the code pipeline */
-    private final boolean isFinal;
-
-    private final int programPoint;
-
     /**
      * Constructor
      *
@@ -352,17 +344,13 @@
 
         this.request      = request;
         this.args         = args;
-        this.isFinal      = false;
-        this.programPoint = INVALID_PROGRAM_POINT;
     }
 
-    private RuntimeNode(final RuntimeNode runtimeNode, final Request request, final boolean isFinal, final List<Expression> args, final int programPoint) {
+    private RuntimeNode(final RuntimeNode runtimeNode, final Request request, final List<Expression> args) {
         super(runtimeNode);
 
         this.request      = request;
         this.args         = args;
-        this.isFinal      = isFinal;
-        this.programPoint = programPoint;
     }
 
     /**
@@ -400,8 +388,6 @@
 
         this.request      = request;
         this.args         = args;
-        this.isFinal      = false;
-        this.programPoint = parent instanceof Optimistic ? ((Optimistic)parent).getProgramPoint() : INVALID_PROGRAM_POINT;
     }
 
     /**
@@ -429,38 +415,17 @@
      * @return new runtime node or same if same request
      */
     public RuntimeNode setRequest(final Request request) {
-       if (this.request == request) {
-           return this;
-       }
-       return new RuntimeNode(this, request, isFinal, args, programPoint);
-   }
-
-
-    /**
-     * Is this node final - i.e. it can never be replaced with other nodes again
-     * @return true if final
-     */
-    public boolean isFinal() {
-        return isFinal;
-    }
-
-    /**
-     * Flag this node as final - i.e it may never be replaced with other nodes again
-     * @param isFinal is the node final, i.e. can not be removed and replaced by a less generic one later in codegen
-     * @return same runtime node if already final, otherwise a new one
-     */
-    public RuntimeNode setIsFinal(final boolean isFinal) {
-        if (this.isFinal == isFinal) {
+        if (this.request == request) {
             return this;
         }
-        return new RuntimeNode(this, request, isFinal, args, programPoint);
-    }
+        return new RuntimeNode(this, request, args);
+   }
 
     /**
      * Return type for the ReferenceNode
      */
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
+    public Type getType() {
         return request.getReturnType();
     }
 
@@ -511,7 +476,7 @@
         if (this.args == args) {
             return this;
         }
-        return new RuntimeNode(this, request, isFinal, args, programPoint);
+        return new RuntimeNode(this, request, args);
     }
 
     /**
@@ -537,39 +502,4 @@
         }
         return true;
     }
-
-//TODO these are blank for now:
-
-    @Override
-    public int getProgramPoint() {
-        return programPoint;
-    }
-
-    @Override
-    public RuntimeNode setProgramPoint(final int programPoint) {
-        if(this.programPoint == programPoint) {
-            return this;
-        }
-        return new RuntimeNode(this, request, isFinal, args, programPoint);
-    }
-
-    @Override
-    public boolean canBeOptimistic() {
-        return false;
-    }
-
-    @Override
-    public Type getMostOptimisticType() {
-        return getType();
-    }
-
-    @Override
-    public Type getMostPessimisticType() {
-        return getType();
-    }
-
-    @Override
-    public RuntimeNode setType(final Type type) {
-        return this;
-    }
 }
--- a/src/jdk/nashorn/internal/ir/SplitReturn.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/SplitReturn.java	Fri Nov 13 15:38:44 2015 -0800
@@ -54,7 +54,7 @@
     }
 
     @Override
-    public void toString(StringBuilder sb, boolean printType) {
+    public void toString(final StringBuilder sb, final boolean printType) {
         sb.append(":splitreturn;");
     }
 
--- a/src/jdk/nashorn/internal/ir/TernaryNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/TernaryNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.ir;
 
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
@@ -122,8 +121,8 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
-        return Type.widestReturnType(getTrueExpression().getType(localVariableTypes), getFalseExpression().getType(localVariableTypes));
+    public Type getType() {
+        return Type.widestReturnType(getTrueExpression().getType(), getFalseExpression().getType());
     }
 
 
--- a/src/jdk/nashorn/internal/ir/TryNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/TryNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,9 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
 
@@ -35,7 +37,7 @@
  * IR representation of a TRY statement.
  */
 @Immutable
-public final class TryNode extends Statement implements JoinPredecessor {
+public final class TryNode extends LexicalContextStatement implements JoinPredecessor {
     private static final long serialVersionUID = 1L;
 
     /** Try statements. */
@@ -47,12 +49,24 @@
     /** Finally clause. */
     private final Block finallyBody;
 
+    /**
+     * List of inlined finally blocks. The structure of every inlined finally is:
+     * Block(LabelNode(label, Block(finally-statements, (JumpStatement|ReturnNode)?))).
+     * That is, the block has a single LabelNode statement with the label and a block containing the
+     * statements of the inlined finally block with the jump or return statement appended (if the finally
+     * block was not terminal; the original jump/return is simply ignored if the finally block itself
+     * terminates). The reason for this somewhat strange arrangement is that we didn't want to create a
+     * separate class for the (label, BlockStatement pair) but rather reused the already available LabelNode.
+     * However, if we simply used List&lt;LabelNode&gt; without wrapping the label nodes in an additional Block,
+     * that would've thrown off visitors relying on BlockLexicalContext -- same reason why we never use
+     * Statement as the type of bodies of e.g. IfNode, WhileNode etc. but rather blockify them even when they're
+     * single statements.
+     */
+    private final List<Block> inlinedFinallies;
+
     /** Exception symbol. */
     private Symbol exception;
 
-    /** Catchall exception for finally expansion, where applicable */
-    private Symbol finallyCatchAll;
-
     private final LocalVariableConversion conversion;
 
     /**
@@ -71,21 +85,23 @@
         this.catchBlocks = catchBlocks;
         this.finallyBody = finallyBody;
         this.conversion  = null;
+        this.inlinedFinallies = Collections.emptyList();
     }
 
-    private TryNode(final TryNode tryNode, final Block body, final List<Block> catchBlocks, final Block finallyBody, final LocalVariableConversion conversion) {
+    private TryNode(final TryNode tryNode, final Block body, final List<Block> catchBlocks, final Block finallyBody, final LocalVariableConversion conversion, final List<Block> inlinedFinallies) {
         super(tryNode);
         this.body        = body;
         this.catchBlocks = catchBlocks;
         this.finallyBody = finallyBody;
         this.conversion  = conversion;
+        this.inlinedFinallies = inlinedFinallies;
         this.exception = tryNode.exception;
     }
 
     @Override
     public Node ensureUniqueLabels(final LexicalContext lc) {
         //try nodes are never in lex context
-        return new TryNode(this, body, catchBlocks, finallyBody, conversion);
+        return new TryNode(this, body, catchBlocks, finallyBody, conversion, inlinedFinallies);
     }
 
     @Override
@@ -106,16 +122,16 @@
      * @param visitor IR navigating visitor.
      */
     @Override
-    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
+    public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
         if (visitor.enterTryNode(this)) {
             // Need to do finallybody first for termination analysis. TODO still necessary?
             final Block newFinallyBody = finallyBody == null ? null : (Block)finallyBody.accept(visitor);
             final Block newBody        = (Block)body.accept(visitor);
             return visitor.leaveTryNode(
-                setBody(newBody).
-                setFinallyBody(newFinallyBody).
-                setCatchBlocks(Node.accept(visitor, catchBlocks)).
-                setFinallyCatchAll(finallyCatchAll));
+                setBody(lc, newBody).
+                setFinallyBody(lc, newFinallyBody).
+                setCatchBlocks(lc, Node.accept(visitor, catchBlocks)).
+                setInlinedFinallies(lc, Node.accept(visitor, inlinedFinallies)));
         }
 
         return this;
@@ -136,14 +152,15 @@
 
     /**
      * Reset the body of this try block
+     * @param lc current lexical context
      * @param body new body
      * @return new TryNode or same if unchanged
      */
-    public TryNode setBody(final Block body) {
+    public TryNode setBody(final LexicalContext lc, final Block body) {
         if (this.body == body) {
             return this;
         }
-        return new TryNode(this,  body, catchBlocks, finallyBody, conversion);
+        return Node.replaceInLexicalContext(lc, this, new TryNode(this,  body, catchBlocks, finallyBody, conversion, inlinedFinallies));
     }
 
     /**
@@ -172,14 +189,15 @@
 
     /**
      * Set the catch blocks of this try
+     * @param lc current lexical context
      * @param catchBlocks list of catch blocks
      * @return new TryNode or same if unchanged
      */
-    public TryNode setCatchBlocks(final List<Block> catchBlocks) {
+    public TryNode setCatchBlocks(final LexicalContext lc, final List<Block> catchBlocks) {
         if (this.catchBlocks == catchBlocks) {
             return this;
         }
-        return new TryNode(this, body, catchBlocks, finallyBody, conversion);
+        return Node.replaceInLexicalContext(lc, this, new TryNode(this, body, catchBlocks, finallyBody, conversion, inlinedFinallies));
     }
 
     /**
@@ -200,27 +218,6 @@
     }
 
     /**
-     * Get the catch all symbol for this try block
-     * @return catch all symbol
-     */
-    public Symbol getFinallyCatchAll() {
-        return this.finallyCatchAll;
-    }
-
-    /**
-     * If a finally block exists, the synthetic catchall needs another symbol to
-     * store its throwable
-     * @param finallyCatchAll a symbol for the finally catch all exception
-     * @return new TryNode or same if unchanged
-     *
-     * TODO can this still be stateful?
-     */
-    public TryNode setFinallyCatchAll(final Symbol finallyCatchAll) {
-        this.finallyCatchAll = finallyCatchAll;
-        return this;
-    }
-
-    /**
      * Get the body of the finally clause for this try
      * @return finally body, or null if no finally
      */
@@ -229,15 +226,87 @@
     }
 
     /**
+     * Get the inlined finally block with the given label name. This returns the actual finally block in the
+     * {@link LabelNode}, not the outer wrapper block for the {@link LabelNode}.
+     * @param labelName the name of the inlined finally's label
+     * @return the requested finally block, or null if no finally block's label matches the name.
+     */
+    public Block getInlinedFinally(final String labelName) {
+        for(final Block inlinedFinally: inlinedFinallies) {
+            final LabelNode labelNode = getInlinedFinallyLabelNode(inlinedFinally);
+            if (labelNode.getLabelName().equals(labelName)) {
+                return labelNode.getBody();
+            }
+        }
+        return null;
+    }
+
+    private static LabelNode getInlinedFinallyLabelNode(final Block inlinedFinally) {
+        return (LabelNode)inlinedFinally.getStatements().get(0);
+    }
+
+    /**
+     * Given an outer wrapper block for the {@link LabelNode} as returned by {@link #getInlinedFinallies()},
+     * returns its actual inlined finally block.
+     * @param inlinedFinally the outer block for inlined finally, as returned as an element of
+     * {@link #getInlinedFinallies()}.
+     * @return the block contained in the {@link LabelNode} contained in the passed block.
+     */
+    public static Block getLabelledInlinedFinallyBlock(final Block inlinedFinally) {
+        return getInlinedFinallyLabelNode(inlinedFinally).getBody();
+    }
+
+    /**
+     * Returns a list of inlined finally blocks. Note that this returns a list of {@link Block}s such that each one of
+     * them has a single {@link LabelNode}, which in turn contains the label name for the finally block and the
+     * actual finally block. To safely extract the actual finally block, use
+     * {@link #getLabelledInlinedFinallyBlock(Block)}.
+     * @return a list of inlined finally blocks.
+     */
+    public List<Block> getInlinedFinallies() {
+        return Collections.unmodifiableList(inlinedFinallies);
+    }
+
+    /**
      * Set the finally body of this try
+     * @param lc current lexical context
      * @param finallyBody new finally body
      * @return new TryNode or same if unchanged
      */
-    public TryNode setFinallyBody(final Block finallyBody) {
+    public TryNode setFinallyBody(final LexicalContext lc, final Block finallyBody) {
         if (this.finallyBody == finallyBody) {
             return this;
         }
-        return new TryNode(this, body, catchBlocks, finallyBody, conversion);
+        return Node.replaceInLexicalContext(lc, this, new TryNode(this, body, catchBlocks, finallyBody, conversion, inlinedFinallies));
+    }
+
+    /**
+     * Set the inlined finally blocks of this try. Each element should be a block with a single statement that is a
+     * {@link LabelNode} with a unique label, and the block within the label node should contain the actual inlined
+     * finally block.
+     * @param lc current lexical context
+     * @param inlinedFinallies list of inlined finally blocks
+     * @return new TryNode or same if unchanged
+     */
+    public TryNode setInlinedFinallies(final LexicalContext lc, final List<Block> inlinedFinallies) {
+        if (this.inlinedFinallies == inlinedFinallies) {
+            return this;
+        }
+        assert checkInlinedFinallies(inlinedFinallies);
+        return Node.replaceInLexicalContext(lc, this, new TryNode(this, body, catchBlocks, finallyBody, conversion, inlinedFinallies));
+    }
+
+    private static boolean checkInlinedFinallies(final List<Block> inlinedFinallies) {
+        if (!inlinedFinallies.isEmpty()) {
+            final Set<String> labels = new HashSet<>();
+            for (final Block inlinedFinally : inlinedFinallies) {
+                final List<Statement> stmts = inlinedFinally.getStatements();
+                assert stmts.size() == 1;
+                final LabelNode ln = getInlinedFinallyLabelNode(inlinedFinally);
+                assert labels.add(ln.getLabelName()); // unique label
+            }
+        }
+        return true;
     }
 
     @Override
@@ -245,7 +314,7 @@
         if(this.conversion == conversion) {
             return this;
         }
-        return new TryNode(this, body, catchBlocks, finallyBody, conversion);
+        return new TryNode(this, body, catchBlocks, finallyBody, conversion, inlinedFinallies);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/ir/UnaryNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/UnaryNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -33,7 +33,6 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.function.Function;
 import jdk.nashorn.internal.codegen.types.Type;
 import jdk.nashorn.internal.ir.annotations.Ignore;
 import jdk.nashorn.internal.ir.annotations.Immutable;
@@ -123,23 +122,11 @@
         return isAssignment();
     }
 
-    private static final Function<Symbol, Type> UNKNOWN_LOCALS = new Function<Symbol, Type>() {
-        @Override
-        public Type apply(final Symbol t) {
-            return null;
-        }
-    };
-
-
     @Override
     public Type getWidestOperationType() {
-        return getWidestOperationType(UNKNOWN_LOCALS);
-    }
-
-    private Type getWidestOperationType(final Function<Symbol, Type> localVariableTypes) {
         switch (tokenType()) {
         case ADD:
-            final Type operandType = getExpression().getType(localVariableTypes);
+            final Type operandType = getExpression().getType();
             if(operandType == Type.BOOLEAN) {
                 return Type.INT;
             } else if(operandType.isObject()) {
@@ -326,12 +313,12 @@
     }
 
     @Override
-    public Type getType(final Function<Symbol, Type> localVariableTypes) {
-        final Type widest = getWidestOperationType(localVariableTypes);
+    public Type getType() {
+        final Type widest = getWidestOperationType();
         if(type == null) {
             return widest;
         }
-        return Type.narrowest(widest, Type.widest(type, expression.getType(localVariableTypes)));
+        return Type.narrowest(widest, Type.widest(type, expression.getType()));
     }
 
     @Override
--- a/src/jdk/nashorn/internal/ir/VarNode.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/VarNode.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,6 @@
 
 import jdk.nashorn.internal.ir.annotations.Immutable;
 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.parser.Token;
 
 /**
  * Node represents a var/let declaration.
@@ -182,7 +181,7 @@
 
     @Override
     public void toString(final StringBuilder sb, final boolean printType) {
-        sb.append(Token.descType(getToken()).getName()).append(' ');
+        sb.append(tokenType().getName()).append(' ');
         name.toString(sb, printType);
 
         if (init != null) {
--- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,7 +28,6 @@
 import static jdk.nashorn.internal.runtime.Source.sourceFor;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import jdk.nashorn.internal.ir.AccessNode;
 import jdk.nashorn.internal.ir.BinaryNode;
@@ -553,8 +552,7 @@
             type("ArrayExpression");
             comma();
 
-            final Node[] value = literalNode.getArray();
-            array("elements", Arrays.asList(value));
+            array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions());
         } else {
             type("Literal");
             comma();
--- a/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1109,7 +1109,7 @@
                 }
                 final String ex = catches.get(node);
                 if (ex != null) {
-                    sb.append("*** CATCH: ").append(ex).append(" ***\n");
+                    sb.append("*** CATCH: ").append(ex).append(" ***\\l");
                 }
                 sb.append(c);
                 sb.append("\"]\n");
--- a/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -38,6 +38,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Contains utility methods for calculating the memory usage of objects. It
@@ -150,7 +151,7 @@
      * @param memoryLayoutSpecification a description of the JVM memory layout.
      */
     public ObjectSizeCalculator(final MemoryLayoutSpecification memoryLayoutSpecification) {
-        memoryLayoutSpecification.getClass();
+        Objects.requireNonNull(memoryLayoutSpecification);
         arrayHeaderSize = memoryLayoutSpecification.getArrayHeaderSize();
         objectHeaderSize = memoryLayoutSpecification.getObjectHeaderSize();
         objectPadding = memoryLayoutSpecification.getObjectPadding();
--- a/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java	Fri Nov 13 15:38:44 2015 -0800
@@ -391,6 +391,9 @@
             finallyBody.accept(this);
         }
 
+        for (final Block inlinedFinally : tryNode.getInlinedFinallies()) {
+            inlinedFinally.accept(this);
+        }
         return false;
     }
 
--- a/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java	Fri Nov 13 15:38:44 2015 -0800
@@ -43,6 +43,7 @@
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.IndexNode;
 import jdk.nashorn.internal.ir.JoinPredecessorExpression;
+import jdk.nashorn.internal.ir.JumpToInlinedFinally;
 import jdk.nashorn.internal.ir.LabelNode;
 import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LiteralNode;
@@ -473,6 +474,26 @@
     }
 
     /**
+     * Callback for entering a JumpToInlinedFinally
+     *
+     * @param  jumpToInlinedFinally the node
+     * @return true if traversal should continue and node children be traversed, false otherwise
+     */
+    public boolean enterJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        return enterDefault(jumpToInlinedFinally);
+    }
+
+    /**
+     * Callback for leaving a JumpToInlinedFinally
+     *
+     * @param  jumpToInlinedFinally the node
+     * @return processed node, which will replace the original one, or the original node
+     */
+    public Node leaveJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
+        return leaveDefault(jumpToInlinedFinally);
+    }
+
+    /**
      * Callback for entering a LabelNode
      *
      * @param  labelNode the node
--- a/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,6 +25,8 @@
 
 package jdk.nashorn.internal.lookup;
 
+import static jdk.nashorn.internal.runtime.JSType.isString;
+
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.lang.invoke.MethodHandle;
@@ -36,7 +38,6 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.logging.Level;
-import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.Debug;
 import jdk.nashorn.internal.runtime.ScriptObject;
@@ -343,7 +344,7 @@
                 final Object d = data[i];
                 if (d == null) {
                     sb.append("<null> ");
-                } else if (d instanceof String || d instanceof ConsString) {
+                } else if (isString(d)) {
                     sb.append(d.toString());
                     sb.append(' ');
                 } else if (d.getClass().isArray()) {
--- a/src/jdk/nashorn/internal/objects/Global.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/Global.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,7 @@
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+import static jdk.nashorn.internal.runtime.JSType.isString;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
 
 import java.io.IOException;
@@ -41,6 +42,7 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import javax.script.ScriptContext;
@@ -52,11 +54,13 @@
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.lookup.Lookup;
 import jdk.nashorn.internal.objects.annotations.Attribute;
+import jdk.nashorn.internal.objects.annotations.Getter;
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
-import jdk.nashorn.internal.runtime.ConsString;
+import jdk.nashorn.internal.objects.annotations.Setter;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ECMAErrors;
+import jdk.nashorn.internal.runtime.FindProperty;
 import jdk.nashorn.internal.runtime.GlobalConstants;
 import jdk.nashorn.internal.runtime.GlobalFunctions;
 import jdk.nashorn.internal.runtime.JSType;
@@ -75,18 +79,23 @@
 import jdk.nashorn.internal.runtime.linker.InvokeByName;
 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
 import jdk.nashorn.internal.runtime.regexp.RegExpResult;
+import jdk.nashorn.internal.scripts.JD;
 import jdk.nashorn.internal.scripts.JO;
+import jdk.nashorn.tools.ShellFunctions;
 
 /**
  * Representation of global scope.
  */
 @ScriptClass("Global")
-public final class Global extends ScriptObject implements Scope {
+public final class Global extends Scope {
     // Placeholder value used in place of a location property (__FILE__, __DIR__, __LINE__)
     private static final Object LOCATION_PROPERTY_PLACEHOLDER = new Object();
     private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
     private final InvokeByName VALUE_OF  = new InvokeByName("valueOf",  ScriptObject.class);
 
+    // placeholder value for lazily initialized global objects
+    private static final Object LAZY_SENTINEL = new Object();
+
     /**
      * Optimistic builtin names that require switchpoint invalidation
      * upon assignment. Overly conservative, but works for now, to avoid
@@ -211,21 +220,117 @@
     @Property(name = "Number", attributes = Attribute.NOT_ENUMERABLE)
     public volatile Object number;
 
-    /** ECMA 15.1.4.7 Date constructor */
-    @Property(name = "Date", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object date;
-
-    /** ECMA 15.1.4.8 RegExp constructor */
-    @Property(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object regexp;
-
-    /** ECMA 15.12 - The JSON object */
-    @Property(name = "JSON", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object json;
-
-    /** Nashorn extension: global.JSAdapter */
-    @Property(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object jsadapter;
+    /**
+     * Getter for ECMA 15.1.4.7 Date property
+     *
+     * @param self self reference
+     * @return Date property value
+     */
+    @Getter(name = "Date", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getDate(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.date == LAZY_SENTINEL) {
+            global.date = global.getBuiltinDate();
+        }
+        return global.date;
+    }
+
+    /**
+     * Setter for ECMA 15.1.4.7 Date property
+     *
+     * @param self self reference
+     * @param value value for the Date property
+     */
+    @Setter(name = "Date", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setDate(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.date = value;
+    }
+
+    private volatile Object date = LAZY_SENTINEL;
+
+    /**
+     * Getter for ECMA 15.1.4.8 RegExp property
+     *
+     * @param self self reference
+     * @return RegExp property value
+     */
+    @Getter(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getRegExp(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.regexp == LAZY_SENTINEL) {
+            global.regexp = global.getBuiltinRegExp();
+        }
+        return global.regexp;
+    }
+
+    /**
+     * Setter for ECMA 15.1.4.8 RegExp property
+     *
+     * @param self self reference
+     * @param value value for the RegExp property
+     */
+    @Setter(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setRegExp(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.regexp = value;
+    }
+
+    private volatile Object regexp = LAZY_SENTINEL;
+
+    /**
+     * Getter for ECMA 15.12 - The JSON property
+     * @param self self reference
+     * @return the value of JSON property
+     */
+    @Getter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getJSON(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.json == LAZY_SENTINEL) {
+            global.json = global.getBuiltinJSON();
+        }
+        return global.json;
+    }
+
+    /**
+     * Setter for ECMA 15.12 - The JSON property
+     * @param self self reference
+     * @param value value for the JSON property
+     */
+    @Setter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setJSON(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.json = value;
+    }
+
+    private volatile Object json = LAZY_SENTINEL;
+
+    /**
+     * Getter for Nashorn extension: global.JSAdapter
+     * @param self self reference
+     * @return value of the JSAdapter property
+     */
+    @Getter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getJSAdapter(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.jsadapter == LAZY_SENTINEL) {
+            global.jsadapter = global.getBuiltinJSAdapter();
+        }
+        return global.jsadapter;
+    }
+
+    /**
+     * Setter for Nashorn extension: global.JSAdapter
+     * @param self self reference
+     * @param value value for the JSAdapter property
+     */
+    @Setter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setJSAdapter(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.jsadapter = value;
+    }
+
+    private volatile Object jsadapter = LAZY_SENTINEL;
 
     /** ECMA 15.8 - The Math object */
     @Property(name = "Math", attributes = Attribute.NOT_ENUMERABLE)
@@ -235,13 +340,60 @@
     @Property(name = "Error", attributes = Attribute.NOT_ENUMERABLE)
     public volatile Object error;
 
-    /** EvalError object */
-    @Property(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object evalError;
-
-    /** RangeError object */
-    @Property(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object rangeError;
+    /**
+     * Getter for the EvalError property
+     * @param self self reference
+     * @return the value of EvalError property
+     */
+    @Getter(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getEvalError(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.evalError == LAZY_SENTINEL) {
+            global.evalError = global.getBuiltinEvalError();
+        }
+        return global.evalError;
+    }
+
+    /**
+     * Setter for the EvalError property
+     * @param self self reference
+     * @param value value of the EvalError property
+     */
+    @Setter(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setEvalError(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.evalError = value;
+    }
+
+    private volatile Object evalError = LAZY_SENTINEL;
+
+    /**
+     * Getter for the RangeError property.
+     * @param self self reference
+     * @return the value of RangeError property
+     */
+    @Getter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getRangeError(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.rangeError == LAZY_SENTINEL) {
+            global.rangeError = global.getBuiltinRangeError();
+        }
+        return global.rangeError;
+    }
+
+
+    /**
+     * Setter for the RangeError property.
+     * @param self self reference
+     * @param value value for the RangeError property
+     */
+    @Setter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setRangeError(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.rangeError = value;
+    }
+
+    private volatile Object rangeError = LAZY_SENTINEL;
 
     /** ReferenceError object */
     @Property(name = "ReferenceError", attributes = Attribute.NOT_ENUMERABLE)
@@ -255,53 +407,340 @@
     @Property(name = "TypeError", attributes = Attribute.NOT_ENUMERABLE)
     public volatile Object typeError;
 
-    /** URIError object */
-    @Property(name = "URIError", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object uriError;
-
-    /** ArrayBuffer object */
-    @Property(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object arrayBuffer;
-
-    /** DataView object */
-    @Property(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object dataView;
-
-    /** TypedArray (int8) */
-    @Property(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object int8Array;
-
-    /** TypedArray (uint8) */
-    @Property(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object uint8Array;
-
-    /** TypedArray (uint8) - Clamped */
-    @Property(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object uint8ClampedArray;
-
-    /** TypedArray (int16) */
-    @Property(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object int16Array;
-
-    /** TypedArray (uint16) */
-    @Property(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object uint16Array;
-
-    /** TypedArray (int32) */
-    @Property(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object int32Array;
-
-    /** TypedArray (uint32) */
-    @Property(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object uint32Array;
-
-    /** TypedArray (float32) */
-    @Property(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object float32Array;
-
-    /** TypedArray (float64) */
-    @Property(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object float64Array;
+    /**
+     * Getter for the URIError property.
+     * @param self self reference
+     * @return the value of URIError property
+     */
+    @Getter(name = "URIError", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getURIError(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.uriError == LAZY_SENTINEL) {
+            global.uriError = global.getBuiltinURIError();
+        }
+        return global.uriError;
+    }
+
+    /**
+     * Setter for the URIError property.
+     * @param self self reference
+     * @param value value for the URIError property
+     */
+    @Setter(name = "URIError", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setURIError(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.uriError = value;
+    }
+
+    private volatile Object uriError = LAZY_SENTINEL;
+
+    /**
+     * Getter for the ArrayBuffer property.
+     * @param self self reference
+     * @return the value of the ArrayBuffer property
+     */
+    @Getter(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getArrayBuffer(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.arrayBuffer == LAZY_SENTINEL) {
+            global.arrayBuffer = global.getBuiltinArrayBuffer();
+        }
+        return global.arrayBuffer;
+    }
+
+    /**
+     * Setter for the ArrayBuffer property.
+     * @param self self reference
+     * @param value value of the ArrayBuffer property
+     */
+    @Setter(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setArrayBuffer(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.arrayBuffer = value;
+    }
+
+    private volatile Object arrayBuffer;
+
+    /**
+     * Getter for the DataView property.
+     * @param self self reference
+     * @return the value of the DataView property
+     */
+    @Getter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getDataView(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.dataView == LAZY_SENTINEL) {
+            global.dataView = global.getBuiltinDataView();
+        }
+        return global.dataView;
+    }
+
+
+    /**
+     * Setter for the DataView property.
+     * @param self self reference
+     * @param value value of the DataView property
+     */
+    @Setter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setDataView(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.dataView = value;
+    }
+
+    private volatile Object dataView;
+
+    /**
+     * Getter for the Int8Array property.
+     * @param self self reference
+     * @return the value of the Int8Array property.
+     */
+    @Getter(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getInt8Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.int8Array == LAZY_SENTINEL) {
+            global.int8Array = global.getBuiltinInt8Array();
+        }
+        return global.int8Array;
+    }
+
+    /**
+     * Setter for the Int8Array property.
+     * @param self self reference
+     * @param value value of the Int8Array property
+     */
+    @Setter(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setInt8Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.int8Array = value;
+    }
+
+    private volatile Object int8Array;
+
+    /**
+     * Getter for the Uin8Array property.
+     * @param self self reference
+     * @return the value of the Uint8Array property
+     */
+    @Getter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getUint8Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.uint8Array == LAZY_SENTINEL) {
+            global.uint8Array = global.getBuiltinUint8Array();
+        }
+        return global.uint8Array;
+    }
+
+    /**
+     * Setter for the Uin8Array property.
+     * @param self self reference
+     * @param value value of the Uin8Array property
+     */
+    @Setter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setUint8Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.uint8Array = value;
+    }
+
+    private volatile Object uint8Array;
+
+    /**
+     * Getter for the Uint8ClampedArray property.
+     * @param self self reference
+     * @return the value of the Uint8ClampedArray property
+     */
+    @Getter(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getUint8ClampedArray(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.uint8ClampedArray == LAZY_SENTINEL) {
+            global.uint8ClampedArray = global.getBuiltinUint8ClampedArray();
+        }
+        return global.uint8ClampedArray;
+    }
+
+    /**
+     * Setter for the Uint8ClampedArray property.
+     * @param self self reference
+     * @param value value of the Uint8ClampedArray property
+     */
+    @Setter(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setUint8ClampedArray(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.uint8ClampedArray = value;
+    }
+
+    private volatile Object uint8ClampedArray;
+
+    /**
+     * Getter for the Int16Array property.
+     * @param self self reference
+     * @return the value of the Int16Array property
+     */
+    @Getter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getInt16Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.int16Array == LAZY_SENTINEL) {
+            global.int16Array = global.getBuiltinInt16Array();
+        }
+        return global.int16Array;
+    }
+
+    /**
+     * Setter for the Int16Array property.
+     * @param self self reference
+     * @param value value of the Int16Array property
+     */
+    @Setter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setInt16Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.int16Array = value;
+    }
+
+    private volatile Object int16Array;
+
+    /**
+     * Getter for the Uint16Array property.
+     * @param self self reference
+     * @return the value of the Uint16Array property
+     */
+    @Getter(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getUint16Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.uint16Array == LAZY_SENTINEL) {
+            global.uint16Array = global.getBuiltinUint16Array();
+        }
+        return global.uint16Array;
+    }
+
+    /**
+     * Setter for the Uint16Array property.
+     * @param self self reference
+     * @param value value of the Uint16Array property
+     */
+    @Setter(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setUint16Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.uint16Array = value;
+    }
+
+    private volatile Object uint16Array;
+
+    /**
+     * Getter for the Int32Array property.
+     *
+     * @param self self reference
+     * @return the value of the Int32Array property
+     */
+    @Getter(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getInt32Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.int32Array == LAZY_SENTINEL) {
+            global.int32Array = global.getBuiltinInt32Array();
+        }
+        return global.int32Array;
+    }
+
+
+    /**
+     * Setter for the Int32Array property.
+     *
+     * @param self self reference
+     * @param value value of the Int32Array property
+     */
+    @Setter(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setInt32Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.int32Array = value;
+    }
+
+    private volatile Object int32Array;
+
+    /**
+     * Getter of the Uint32Array property.
+     *
+     * @param self self reference
+     * @return the value of the Uint32Array property
+     */
+    @Getter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getUint32Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.uint32Array == LAZY_SENTINEL) {
+            global.uint32Array = global.getBuiltinUint32Array();
+        }
+        return global.uint32Array;
+    }
+
+
+    /**
+     * Setter of the Uint32Array property.
+     *
+     * @param self self reference
+     * @param value value of the Uint32Array property
+     */
+    @Setter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setUint32Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.uint32Array = value;
+    }
+
+    private volatile Object uint32Array;
+
+    /**
+     * Getter for the Float32Array property.
+     *
+     * @param self self reference
+     * @return the value of the Float32Array property
+     */
+    @Getter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getFloat32Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.float32Array == LAZY_SENTINEL) {
+            global.float32Array = global.getBuiltinFloat32Array();
+        }
+        return global.float32Array;
+    }
+
+    /**
+     * Setter for the Float32Array property.
+     *
+     * @param self self reference
+     * @param value value of the Float32Array property
+     */
+    @Setter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setFloat32Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.float32Array = value;
+    }
+
+    private volatile Object float32Array;
+
+    /**
+     * Getter for the Float64Array property.
+     *
+     * @param self self reference
+     * @return the value of the Float64Array property
+     */
+    @Getter(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getFloat64Array(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.float64Array == LAZY_SENTINEL) {
+            global.float64Array = global.getBuiltinFloat64Array();
+        }
+        return global.float64Array;
+    }
+
+    /**
+     * Setter for the Float64Array property.
+     *
+     * @param self self reference
+     * @param value value of the Float64Array property
+     */
+    @Setter(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setFloat64Array(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.float64Array = value;
+    }
+
+    private volatile Object float64Array;
 
     /** Nashorn extension: Java access - global.Packages */
     @Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE)
@@ -331,13 +770,63 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE)
     public volatile Object org;
 
-    /** Nashorn extension: Java access - global.javaImporter */
-    @Property(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object javaImporter;
-
-    /** Nashorn extension: global.Java Object constructor. */
-    @Property(name = "Java", attributes = Attribute.NOT_ENUMERABLE)
-    public volatile Object javaApi;
+    /**
+     * Getter for the Nashorn extension: Java access - global.javaImporter.
+     *
+     * @param self self reference
+     * @return the value of the JavaImporter property
+     */
+    @Getter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getJavaImporter(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.javaImporter == LAZY_SENTINEL) {
+            global.javaImporter = global.getBuiltinJavaImporter();
+        }
+        return global.javaImporter;
+    }
+
+    /**
+     * Setter for the Nashorn extension: Java access - global.javaImporter.
+     *
+     * @param self self reference
+     * @param value value of the JavaImporter property
+     */
+    @Setter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setJavaImporter(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.javaImporter = value;
+    }
+
+    private volatile Object javaImporter;
+
+    /**
+     * Getter for the Nashorn extension: global.Java property.
+     *
+     * @param self self reference
+     * @return the value of the Java property
+     */
+    @Getter(name = "Java", attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getJavaApi(final Object self) {
+        final Global global = Global.instanceFrom(self);
+        if (global.javaApi == LAZY_SENTINEL) {
+            global.javaApi = global.getBuiltinJavaApi();
+        }
+        return global.javaApi;
+    }
+
+    /**
+     * Setter for the Nashorn extension: global.Java property.
+     *
+     * @param self self reference
+     * @param value value of the Java property
+     */
+    @Setter(name = "Java", attributes = Attribute.NOT_ENUMERABLE)
+    public static void setJavaApi(final Object self, final Object value) {
+        final Global global = Global.instanceFrom(self);
+        global.javaApi = value;
+    }
+
+    private volatile Object javaApi;
 
     /** Nashorn extension: current script's file name */
     @Property(name = "__FILE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT)
@@ -351,11 +840,19 @@
     @Property(name = "__LINE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT)
     public final Object __LINE__ = LOCATION_PROPERTY_PLACEHOLDER;
 
+    private volatile NativeDate DEFAULT_DATE;
+
     /** Used as Date.prototype's default value */
-    public NativeDate   DEFAULT_DATE;
+    NativeDate getDefaultDate() {
+        return DEFAULT_DATE;
+    }
+
+    private volatile NativeRegExp DEFAULT_REGEXP;
 
     /** Used as RegExp.prototype's default value */
-    public NativeRegExp DEFAULT_REGEXP;
+    NativeRegExp getDefaultRegExp() {
+        return DEFAULT_REGEXP;
+    }
 
     /*
      * Built-in constructor objects: Even if user changes dynamic values of
@@ -409,9 +906,6 @@
      */
     private ScriptFunction typeErrorThrower;
 
-    // Flag to indicate that a split method issued a return statement
-    private int splitState = -1;
-
     // Used to store the last RegExp result to support deprecated RegExp constructor properties
     private RegExpResult lastRegExpResult;
 
@@ -422,7 +916,7 @@
     private static final MethodHandle LOAD                 = findOwnMH_S("load",                Object.class, Object.class, Object.class);
     private static final MethodHandle LOAD_WITH_NEW_GLOBAL = findOwnMH_S("loadWithNewGlobal",   Object.class, Object.class, Object[].class);
     private static final MethodHandle EXIT                 = findOwnMH_S("exit",                Object.class, Object.class, Object.class);
-    private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter", Object.class, Object.class);
+    private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter",  Object.class, Object.class);
 
     // initialized by nasgen
     private static PropertyMap $nasgenmap$;
@@ -431,9 +925,11 @@
     private final Context context;
 
     // current ScriptContext to use - can be null.
-    private ScriptContext scontext;
+    private ThreadLocal<ScriptContext> scontext;
     // current ScriptEngine associated - can be null.
     private ScriptEngine engine;
+    // initial ScriptContext - can be null
+    private volatile ScriptContext initscontext;
 
     // ES6 global lexical scope.
     private final LexicalScope lexicalScope;
@@ -443,10 +939,25 @@
 
     /**
      * Set the current script context
-     * @param scontext script context
+     * @param ctxt script context
      */
-    public void setScriptContext(final ScriptContext scontext) {
-        this.scontext = scontext;
+    public void setScriptContext(final ScriptContext ctxt) {
+        assert scontext != null;
+        scontext.set(ctxt);
+    }
+
+    /**
+     * Get the current script context
+     * @return current script context
+     */
+    public ScriptContext getScriptContext() {
+        assert scontext != null;
+        return scontext.get();
+    }
+
+    private ScriptContext currentContext() {
+        final ScriptContext sc = scontext != null? scontext.get() : null;
+        return sc == null? initscontext : sc;
     }
 
     @Override
@@ -454,6 +965,11 @@
         return context;
     }
 
+    @Override
+    protected boolean useDualFields() {
+        return context.useDualFields();
+    }
+
     // performs initialization checks for Global constructor and returns the
     // PropertyMap, if everything is fine.
     private static PropertyMap checkAndGetMap(final Context context) {
@@ -463,8 +979,7 @@
             sm.checkPermission(new RuntimePermission(Context.NASHORN_CREATE_GLOBAL));
         }
 
-        // null check on context
-        context.getClass();
+        Objects.requireNonNull(context);
 
         return $nasgenmap$;
     }
@@ -477,7 +992,6 @@
     public Global(final Context context) {
         super(checkAndGetMap(context));
         this.context = context;
-        this.setIsScope();
         this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null;
     }
 
@@ -487,9 +1001,7 @@
      * @return the global singleton
      */
     public static Global instance() {
-        final Global global = Context.getGlobal();
-        global.getClass(); // null check
-        return global;
+        return Objects.requireNonNull(Context.getGlobal());
     }
 
     private static Global instanceFrom(final Object self) {
@@ -554,17 +1066,21 @@
      * as well as our extension builtin objects like "Java", "JSAdapter" as properties
      * of the global scope object.
      *
-     * @param engine ScriptEngine to initialize
+     * @param eng ScriptEngine to initialize
+     * @param ctxt ScriptContext to initialize
      */
-    @SuppressWarnings("hiding")
-    public void initBuiltinObjects(final ScriptEngine engine) {
+    public void initBuiltinObjects(final ScriptEngine eng, final ScriptContext ctxt) {
         if (this.builtinObject != null) {
             // already initialized, just return
             return;
         }
 
-        this.engine = engine;
-        init(engine);
+        this.engine = eng;
+        this.initscontext = ctxt;
+        if (this.engine != null) {
+            this.scontext = new ThreadLocal<>();
+        }
+        init(eng);
     }
 
     /**
@@ -578,16 +1094,18 @@
             return new NativeBoolean((Boolean)obj, this);
         } else if (obj instanceof Number) {
             return new NativeNumber(((Number)obj).doubleValue(), this);
-        } else if (obj instanceof String || obj instanceof ConsString) {
+        } else if (isString(obj)) {
             return new NativeString((CharSequence)obj, this);
         } else if (obj instanceof Object[]) { // extension
-            return new NativeArray((Object[])obj);
+            return new NativeArray(ArrayData.allocate((Object[])obj), this);
         } else if (obj instanceof double[]) { // extension
-            return new NativeArray((double[])obj);
+            return new NativeArray(ArrayData.allocate((double[])obj), this);
         } else if (obj instanceof long[]) {
-            return new NativeArray((long[])obj);
+            return new NativeArray(ArrayData.allocate((long[])obj), this);
         } else if (obj instanceof int[]) {
-            return new NativeArray((int[])obj);
+            return new NativeArray(ArrayData.allocate((int[]) obj), this);
+        } else if (obj instanceof ArrayData) {
+            return new NativeArray((ArrayData) obj, this);
         } else {
             // FIXME: more special cases? Map? List?
             return obj;
@@ -603,7 +1121,7 @@
      * @return guarded invocation
      */
     public static GuardedInvocation primitiveLookup(final LinkRequest request, final Object self) {
-        if (self instanceof String || self instanceof ConsString) {
+        if (isString(self)) {
             return NativeString.lookupPrimitive(request, self);
         } else if (self instanceof Number) {
             return NativeNumber.lookupPrimitive(request, self);
@@ -620,7 +1138,7 @@
      * @return method handle to create wrapper objects for primitive receiver
      */
     public static MethodHandle getPrimitiveWrapFilter(final Object self) {
-        if (self instanceof String || self instanceof ConsString) {
+        if (isString(self)) {
             return NativeString.WRAPFILTER;
         } else if (self instanceof Number) {
             return NativeNumber.WRAPFILTER;
@@ -637,7 +1155,7 @@
      * @return the new ScriptObject
      */
     public ScriptObject newObject() {
-        return new JO(getObjectPrototype(), JO.getInitialMap());
+        return useDualFields() ? new JD(getObjectPrototype()) : new JO(getObjectPrototype());
     }
 
     /**
@@ -890,7 +1408,7 @@
      */
     public static Object __noSuchProperty__(final Object self, final Object name) {
         final Global global = Global.instance();
-        final ScriptContext sctxt = global.scontext;
+        final ScriptContext sctxt = global.currentContext();
         final String nameStr = name.toString();
 
         if (sctxt != null) {
@@ -929,7 +1447,7 @@
      * @return the result of eval
      */
     public static Object eval(final Object self, final Object str) {
-        return directEval(self, str, UNDEFINED, UNDEFINED, false);
+        return directEval(self, str, Global.instanceFrom(self), UNDEFINED, false);
     }
 
     /**
@@ -939,18 +1457,18 @@
      * @param str      Evaluated code
      * @param callThis "this" to be passed to the evaluated code
      * @param location location of the eval call
-     * @param strict   is eval called a strict mode code?
+     * @param strict   is eval called from a strict mode code?
      *
      * @return the return value of the eval
      *
      * This is directly invoked from generated when eval(code) is called in user code
      */
     public static Object directEval(final Object self, final Object str, final Object callThis, final Object location, final boolean strict) {
-        if (!(str instanceof String || str instanceof ConsString)) {
+        if (!isString(str)) {
             return str;
         }
         final Global global = Global.instanceFrom(self);
-        final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global;
+        final ScriptObject scope = self instanceof ScriptObject && ((ScriptObject)self).isScope() ? (ScriptObject)self : global;
 
         return global.getContext().eval(scope, str.toString(), callThis, location, strict, true);
     }
@@ -980,26 +1498,53 @@
     }
 
     /**
-     * Global load implementation - Nashorn extension
+     * Global load implementation - Nashorn extension.
      *
-     * @param self    scope
-     * @param source  source to load
+     * <p>
+     * load builtin loads the given script. Script source can be a URL or a File
+     * or a script object with name and script properties. Evaluated code gets
+     * global object "this" and uses global object as scope for evaluation.
+     * </p>
+     * <p>
+     * If self is undefined or null or global, then global object is used
+     * as scope as well as "this" for the evaluated code. If self is any other
+     * object, then it is indirect load call. With indirect load call, the
+     * properties of scope are available to evaluated script as variables. Also,
+     * global scope properties are accessible. Any var, function definition in
+     * evaluated script goes into an object that is not accessible to user scripts.
+     * </p>
+     * Thus the indirect load call is equivalent to the following:
+     * <pre>
+     * <code>
+     * (function (scope, source) {
+     *    with(scope) {
+     *        eval(&lt;script_from_source&gt;);
+     *    }
+     * })(self, source);
+     * </code>
+     * </pre>
      *
-     * @return result of load (undefined)
+     * @param self    scope to use for the script evaluation
+     * @param source  script source
+     *
+     * @return result of load (may be undefined)
      *
      * @throws IOException if source could not be read
      */
     public static Object load(final Object self, final Object source) throws IOException {
         final Global global = Global.instanceFrom(self);
-        final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global;
-        return global.getContext().load(scope, source);
+        return global.getContext().load(self, source);
     }
 
     /**
-     * Global loadWithNewGlobal implementation - Nashorn extension
+     * Global loadWithNewGlobal implementation - Nashorn extension.
      *
-     * @param self scope
-     * @param args from plus (optional) arguments to be passed to the loaded script
+     * loadWithNewGlobal builtin loads the given script from a URL or a File
+     * or a script object with name and script properties. Evaluated code gets
+     * new global object "this" and uses that new global object as scope for evaluation.
+     *
+     * @param self self This value is ignored by this function
+     * @param args optional arguments to be passed to the loaded script
      *
      * @return result of load (may be undefined)
      *
@@ -1029,14 +1574,19 @@
     }
 
     // builtin prototype accessors
+
+    /**
+     * Get the builtin Object prototype.
+     * @return the object prototype.
+     */
+    public ScriptObject getObjectPrototype() {
+        return ScriptFunction.getPrototype(builtinObject);
+    }
+
     ScriptObject getFunctionPrototype() {
         return ScriptFunction.getPrototype(builtinFunction);
     }
 
-    ScriptObject getObjectPrototype() {
-        return ScriptFunction.getPrototype(builtinObject);
-    }
-
     ScriptObject getArrayPrototype() {
         return ScriptFunction.getPrototype(builtinArray);
     }
@@ -1050,11 +1600,11 @@
     }
 
     ScriptObject getDatePrototype() {
-        return ScriptFunction.getPrototype(builtinDate);
+        return ScriptFunction.getPrototype(getBuiltinDate());
     }
 
     ScriptObject getRegExpPrototype() {
-        return ScriptFunction.getPrototype(builtinRegExp);
+        return ScriptFunction.getPrototype(getBuiltinRegExp());
     }
 
     ScriptObject getStringPrototype() {
@@ -1066,11 +1616,11 @@
     }
 
     ScriptObject getEvalErrorPrototype() {
-        return ScriptFunction.getPrototype(builtinEvalError);
+        return ScriptFunction.getPrototype(getBuiltinEvalError());
     }
 
     ScriptObject getRangeErrorPrototype() {
-        return ScriptFunction.getPrototype(builtinRangeError);
+        return ScriptFunction.getPrototype(getBuiltinRangeError());
     }
 
     ScriptObject getReferenceErrorPrototype() {
@@ -1086,59 +1636,136 @@
     }
 
     ScriptObject getURIErrorPrototype() {
-        return ScriptFunction.getPrototype(builtinURIError);
+        return ScriptFunction.getPrototype(getBuiltinURIError());
     }
 
     ScriptObject getJavaImporterPrototype() {
-        return ScriptFunction.getPrototype(builtinJavaImporter);
+        return ScriptFunction.getPrototype(getBuiltinJavaImporter());
     }
 
     ScriptObject getJSAdapterPrototype() {
-        return ScriptFunction.getPrototype(builtinJSAdapter);
+        return ScriptFunction.getPrototype(getBuiltinJSAdapter());
+    }
+
+    private synchronized ScriptFunction getBuiltinArrayBuffer() {
+        if (this.builtinArrayBuffer == null) {
+            this.builtinArrayBuffer = initConstructorAndSwitchPoint("ArrayBuffer", ScriptFunction.class);
+        }
+        return this.builtinArrayBuffer;
     }
 
     ScriptObject getArrayBufferPrototype() {
-        return ScriptFunction.getPrototype(builtinArrayBuffer);
+        return ScriptFunction.getPrototype(getBuiltinArrayBuffer());
+    }
+
+    private synchronized ScriptFunction getBuiltinDataView() {
+        if (this.builtinDataView == null) {
+            this.builtinDataView = initConstructorAndSwitchPoint("DataView", ScriptFunction.class);
+        }
+        return this.builtinDataView;
     }
 
     ScriptObject getDataViewPrototype() {
-        return ScriptFunction.getPrototype(builtinDataView);
+        return ScriptFunction.getPrototype(getBuiltinDataView());
+    }
+
+    private synchronized ScriptFunction getBuiltinInt8Array() {
+        if (this.builtinInt8Array == null) {
+            this.builtinInt8Array = initConstructorAndSwitchPoint("Int8Array", ScriptFunction.class);
+        }
+        return this.builtinInt8Array;
     }
 
     ScriptObject getInt8ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinInt8Array);
+        return ScriptFunction.getPrototype(getBuiltinInt8Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinUint8Array() {
+        if (this.builtinUint8Array == null) {
+            this.builtinUint8Array = initConstructorAndSwitchPoint("Uint8Array", ScriptFunction.class);
+        }
+        return this.builtinUint8Array;
     }
 
     ScriptObject getUint8ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinUint8Array);
+        return ScriptFunction.getPrototype(getBuiltinUint8Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinUint8ClampedArray() {
+        if (this.builtinUint8ClampedArray == null) {
+            this.builtinUint8ClampedArray = initConstructorAndSwitchPoint("Uint8ClampedArray", ScriptFunction.class);
+        }
+        return this.builtinUint8ClampedArray;
     }
 
     ScriptObject getUint8ClampedArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinUint8ClampedArray);
+        return ScriptFunction.getPrototype(getBuiltinUint8ClampedArray());
+    }
+
+    private synchronized ScriptFunction getBuiltinInt16Array() {
+        if (this.builtinInt16Array == null) {
+            this.builtinInt16Array = initConstructorAndSwitchPoint("Int16Array", ScriptFunction.class);
+        }
+        return this.builtinInt16Array;
     }
 
     ScriptObject getInt16ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinInt16Array);
+        return ScriptFunction.getPrototype(getBuiltinInt16Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinUint16Array() {
+        if (this.builtinUint16Array == null) {
+            this.builtinUint16Array = initConstructorAndSwitchPoint("Uint16Array", ScriptFunction.class);
+        }
+        return this.builtinUint16Array;
     }
 
     ScriptObject getUint16ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinUint16Array);
+        return ScriptFunction.getPrototype(getBuiltinUint16Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinInt32Array() {
+        if (this.builtinInt32Array == null) {
+            this.builtinInt32Array = initConstructorAndSwitchPoint("Int32Array", ScriptFunction.class);
+        }
+        return this.builtinInt32Array;
     }
 
     ScriptObject getInt32ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinInt32Array);
+        return ScriptFunction.getPrototype(getBuiltinInt32Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinUint32Array() {
+        if (this.builtinUint32Array == null) {
+            this.builtinUint32Array = initConstructorAndSwitchPoint("Uint32Array", ScriptFunction.class);
+        }
+        return this.builtinUint32Array;
     }
 
     ScriptObject getUint32ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinUint32Array);
+        return ScriptFunction.getPrototype(getBuiltinUint32Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinFloat32Array() {
+        if (this.builtinFloat32Array == null) {
+            this.builtinFloat32Array = initConstructorAndSwitchPoint("Float32Array", ScriptFunction.class);
+        }
+        return this.builtinFloat32Array;
     }
 
     ScriptObject getFloat32ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinFloat32Array);
+        return ScriptFunction.getPrototype(getBuiltinFloat32Array());
+    }
+
+    private synchronized ScriptFunction getBuiltinFloat64Array() {
+        if (this.builtinFloat64Array == null) {
+            this.builtinFloat64Array = initConstructorAndSwitchPoint("Float64Array", ScriptFunction.class);
+        }
+        return this.builtinFloat64Array;
     }
 
     ScriptObject getFloat64ArrayPrototype() {
-        return ScriptFunction.getPrototype(builtinFloat64Array);
+        return ScriptFunction.getPrototype(getBuiltinFloat64Array());
     }
 
     private ScriptFunction getBuiltinArray() {
@@ -1173,8 +1800,14 @@
         return instance._boolean == instance.getBuiltinBoolean();
     }
 
-    private ScriptFunction getBuiltinDate() {
-        return builtinDate;
+    private synchronized ScriptFunction getBuiltinDate() {
+        if (this.builtinDate == null) {
+            this.builtinDate = initConstructorAndSwitchPoint("Date", ScriptFunction.class);
+            final ScriptObject dateProto = ScriptFunction.getPrototype(builtinDate);
+            // initialize default date
+            this.DEFAULT_DATE = new NativeDate(NaN, dateProto);
+        }
+        return this.builtinDate;
     }
 
     /**
@@ -1184,7 +1817,7 @@
      */
     public static boolean isBuiltinDate() {
         final Global instance = Global.instance();
-        return instance.date == instance.getBuiltinDate();
+        return instance.date == LAZY_SENTINEL || instance.date == instance.getBuiltinDate();
     }
 
     private ScriptFunction getBuiltinError() {
@@ -1201,8 +1834,11 @@
         return instance.error == instance.getBuiltinError();
     }
 
-    private ScriptFunction getBuiltinEvalError() {
-        return builtinEvalError;
+    private synchronized ScriptFunction getBuiltinEvalError() {
+        if (this.builtinEvalError == null) {
+            this.builtinEvalError = initErrorSubtype("EvalError", getErrorPrototype());
+        }
+        return this.builtinEvalError;
     }
 
     /**
@@ -1212,7 +1848,7 @@
      */
     public static boolean isBuiltinEvalError() {
         final Global instance = Global.instance();
-        return instance.evalError == instance.getBuiltinEvalError();
+        return instance.evalError == LAZY_SENTINEL || instance.evalError == instance.getBuiltinEvalError();
     }
 
     private ScriptFunction getBuiltinFunction() {
@@ -1263,7 +1899,10 @@
         return isBuiltinFunctionProperty("call");
     }
 
-    private ScriptFunction getBuiltinJSAdapter() {
+    private synchronized ScriptFunction getBuiltinJSAdapter() {
+        if (this.builtinJSAdapter == null) {
+            this.builtinJSAdapter = initConstructorAndSwitchPoint("JSAdapter", ScriptFunction.class);
+        }
         return builtinJSAdapter;
     }
 
@@ -1274,11 +1913,14 @@
      */
     public static boolean isBuiltinJSAdapter() {
         final Global instance = Global.instance();
-        return instance.jsadapter == instance.getBuiltinJSAdapter();
+        return instance.jsadapter == LAZY_SENTINEL || instance.jsadapter == instance.getBuiltinJSAdapter();
     }
 
-    private ScriptObject getBuiltinJSON() {
-        return builtinJSON;
+    private synchronized ScriptObject getBuiltinJSON() {
+        if (this.builtinJSON == null) {
+            this.builtinJSON = initConstructorAndSwitchPoint("JSON", ScriptObject.class);
+        }
+        return this.builtinJSON;
     }
 
     /**
@@ -1288,7 +1930,7 @@
      */
     public static boolean isBuiltinJSON() {
         final Global instance = Global.instance();
-        return instance.json == instance.getBuiltinJSON();
+        return instance.json == LAZY_SENTINEL || instance.json == instance.getBuiltinJSON();
     }
 
     private ScriptObject getBuiltinJava() {
@@ -1319,8 +1961,18 @@
         return instance.javax == instance.getBuiltinJavax();
     }
 
-    private ScriptObject getBuiltinJavaImporter() {
-        return builtinJavaImporter;
+    private synchronized ScriptFunction getBuiltinJavaImporter() {
+        if (this.builtinJavaImporter == null) {
+            this.builtinJavaImporter = initConstructor("JavaImporter", ScriptFunction.class);
+        }
+        return this.builtinJavaImporter;
+    }
+
+    private synchronized ScriptObject getBuiltinJavaApi() {
+        if (this.builtinJavaApi == null) {
+            this.builtinJavaApi = initConstructor("Java", ScriptObject.class);
+        }
+        return this.builtinJavaApi;
     }
 
     /**
@@ -1330,11 +1982,7 @@
      */
     public static boolean isBuiltinJavaImporter() {
         final Global instance = Global.instance();
-        return instance.javaImporter == instance.getBuiltinJavaImporter();
-    }
-
-    private ScriptObject getBuiltinMath() {
-        return builtinMath;
+        return instance.javaImporter == LAZY_SENTINEL || instance.javaImporter == instance.getBuiltinJavaImporter();
     }
 
     /**
@@ -1344,7 +1992,7 @@
      */
     public static boolean isBuiltinMath() {
         final Global instance = Global.instance();
-        return instance.math == instance.getBuiltinMath();
+        return instance.math == instance.builtinMath;
     }
 
     private ScriptFunction getBuiltinNumber() {
@@ -1389,7 +2037,10 @@
         return instance.packages == instance.getBuiltinPackages();
     }
 
-    private ScriptFunction getBuiltinRangeError() {
+    private synchronized ScriptFunction getBuiltinRangeError() {
+        if (this.builtinRangeError == null) {
+            this.builtinRangeError = initErrorSubtype("RangeError", getErrorPrototype());
+        }
         return builtinRangeError;
     }
 
@@ -1400,10 +2051,10 @@
      */
     public static boolean isBuiltinRangeError() {
         final Global instance = Global.instance();
-        return instance.rangeError == instance.getBuiltinRangeError();
+        return instance.rangeError == LAZY_SENTINEL || instance.rangeError == instance.getBuiltinRangeError();
     }
 
-    private ScriptFunction getBuiltinReferenceError() {
+    private synchronized ScriptFunction getBuiltinReferenceError() {
         return builtinReferenceError;
     }
 
@@ -1417,7 +2068,16 @@
         return instance.referenceError == instance.getBuiltinReferenceError();
     }
 
-    private ScriptFunction getBuiltinRegExp() {
+    private synchronized ScriptFunction getBuiltinRegExp() {
+        if (this.builtinRegExp == null) {
+            this.builtinRegExp = initConstructorAndSwitchPoint("RegExp", ScriptFunction.class);
+            final ScriptObject regExpProto = ScriptFunction.getPrototype(builtinRegExp);
+            // initialize default regexp object
+            this.DEFAULT_REGEXP = new NativeRegExp("(?:)", "", this, regExpProto);
+            // RegExp.prototype should behave like a RegExp object. So copy the
+            // properties.
+            regExpProto.addBoundProperties(DEFAULT_REGEXP);
+        }
         return builtinRegExp;
     }
 
@@ -1428,7 +2088,7 @@
      */
     public static boolean isBuiltinRegExp() {
         final Global instance = Global.instance();
-        return instance.regexp == instance.getBuiltinRegExp();
+        return instance.regexp == LAZY_SENTINEL || instance.regexp == instance.getBuiltinRegExp();
     }
 
     private ScriptFunction getBuiltinString() {
@@ -1473,8 +2133,11 @@
         return instance.typeError == instance.getBuiltinTypeError();
     }
 
-    private ScriptFunction getBuiltinURIError() {
-        return builtinURIError;
+    private synchronized ScriptFunction getBuiltinURIError() {
+        if (this.builtinURIError == null) {
+            this.builtinURIError = initErrorSubtype("URIError", getErrorPrototype());
+        }
+        return this.builtinURIError;
     }
 
     /**
@@ -1484,7 +2147,7 @@
      */
     public static boolean isBuiltinURIError() {
         final Global instance = Global.instance();
-        return instance.uriError == instance.getBuiltinURIError();
+        return instance.uriError == LAZY_SENTINEL || instance.uriError == instance.getBuiltinURIError();
     }
 
     @Override
@@ -1688,26 +2351,6 @@
     }
 
     /**
-     * Get the current split state.
-     *
-     * @return current split state
-     */
-    @Override
-    public int getSplitState() {
-        return splitState;
-    }
-
-    /**
-     * Set the current split state.
-     *
-     * @param state current split state
-     */
-    @Override
-    public void setSplitState(final int state) {
-        splitState = state;
-    }
-
-    /**
      * Return the ES6 global scope for lexically declared bindings.
      * @return the ES6 lexical global scope.
      */
@@ -1719,13 +2362,13 @@
     @Override
     public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
         PropertyMap ownMap = getMap();
-        LexicalScope lexicalScope = null;
+        LexicalScope lexScope = null;
         PropertyMap lexicalMap = null;
         boolean hasLexicalDefinitions = false;
 
         if (context.getEnv()._es6) {
-            lexicalScope = (LexicalScope) getLexicalScope();
-            lexicalMap = lexicalScope.getMap();
+            lexScope = (LexicalScope) getLexicalScope();
+            lexicalMap = lexScope.getMap();
 
             for (final jdk.nashorn.internal.runtime.Property property : properties) {
                 if (property.isLexicalBinding()) {
@@ -1745,8 +2388,8 @@
 
         for (final jdk.nashorn.internal.runtime.Property property : properties) {
             if (property.isLexicalBinding()) {
-                assert lexicalScope != null;
-                lexicalMap = lexicalScope.addBoundProperty(lexicalMap, source, property);
+                assert lexScope != null;
+                lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property);
 
                 if (ownMap.findProperty(property.getKey()) != null) {
                     // If property exists in the global object invalidate any global constant call sites.
@@ -1760,7 +2403,8 @@
         setMap(ownMap);
 
         if (hasLexicalDefinitions) {
-            lexicalScope.setMap(lexicalMap);
+            assert lexScope != null;
+            lexScope.setMap(lexicalMap);
             invalidateLexicalSwitchPoint();
         }
     }
@@ -1791,6 +2435,17 @@
     }
 
     @Override
+    protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+        if (lexicalScope != null && start != this && start.isScope()) {
+            final FindProperty find = lexicalScope.findProperty(key, false);
+            if (find != null) {
+                return find;
+            }
+        }
+        return super.findProperty(key, deep, start);
+    }
+
+    @Override
     public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
         final boolean isScope = NashornCallSiteDescriptor.isScope(desc);
 
@@ -1810,6 +2465,17 @@
         return invocation;
     }
 
+    /**
+     * Adds jjs shell interactive mode builtin functions to global scope.
+     */
+    public void addShellBuiltins() {
+        Object value = ScriptFunctionImpl.makeFunction("input", ShellFunctions.INPUT);
+        addOwnProperty("input", Attribute.NOT_ENUMERABLE, value);
+
+        value = ScriptFunctionImpl.makeFunction("evalinput", ShellFunctions.EVALINPUT);
+        addOwnProperty("evalinput", Attribute.NOT_ENUMERABLE, value);
+    }
+
     private synchronized SwitchPoint getLexicalScopeSwitchPoint() {
         SwitchPoint switchPoint = lexicalScopeSwitchPoint;
         if (switchPoint == null || switchPoint.hasBeenInvalidated()) {
@@ -1841,7 +2507,7 @@
     }
 
     @SuppressWarnings("hiding")
-    private void init(final ScriptEngine engine) {
+    private void init(final ScriptEngine eng) {
         assert Context.getGlobal() == this : "this global is not set as current";
 
         final ScriptEnvironment env = getContext().getEnv();
@@ -1886,13 +2552,9 @@
         // built-in constructors
         this.builtinArray     = initConstructorAndSwitchPoint("Array", ScriptFunction.class);
         this.builtinBoolean   = initConstructorAndSwitchPoint("Boolean", ScriptFunction.class);
-        this.builtinDate      = initConstructorAndSwitchPoint("Date", ScriptFunction.class);
-        this.builtinJSON      = initConstructorAndSwitchPoint("JSON", ScriptObject.class);
-        this.builtinJSAdapter = initConstructorAndSwitchPoint("JSAdapter", ScriptFunction.class);
+        this.builtinNumber    = initConstructorAndSwitchPoint("Number", ScriptFunction.class);
+        this.builtinString    = initConstructorAndSwitchPoint("String", ScriptFunction.class);
         this.builtinMath      = initConstructorAndSwitchPoint("Math", ScriptObject.class);
-        this.builtinNumber    = initConstructorAndSwitchPoint("Number", ScriptFunction.class);
-        this.builtinRegExp    = initConstructorAndSwitchPoint("RegExp", ScriptFunction.class);
-        this.builtinString    = initConstructorAndSwitchPoint("String", ScriptFunction.class);
 
         // initialize String.prototype.length to 0
         // add String.prototype.length
@@ -1903,26 +2565,28 @@
         final ScriptObject arrayPrototype = getArrayPrototype();
         arrayPrototype.setIsArray();
 
-        this.DEFAULT_DATE = new NativeDate(Double.NaN, this);
-
-        // initialize default regexp object
-        this.DEFAULT_REGEXP = new NativeRegExp("(?:)", this);
-
-        // RegExp.prototype should behave like a RegExp object. So copy the
-        // properties.
-        final ScriptObject regExpProto = getRegExpPrototype();
-        regExpProto.addBoundProperties(DEFAULT_REGEXP);
-
         // Error stuff
         initErrorObjects();
 
         // java access
         if (! env._no_java) {
+            this.javaApi = LAZY_SENTINEL;
+            this.javaImporter = LAZY_SENTINEL;
             initJavaAccess();
         }
 
         if (! env._no_typed_arrays) {
-            initTypedArray();
+            this.arrayBuffer       = LAZY_SENTINEL;
+            this.dataView          = LAZY_SENTINEL;
+            this.int8Array         = LAZY_SENTINEL;
+            this.uint8Array        = LAZY_SENTINEL;
+            this.uint8ClampedArray = LAZY_SENTINEL;
+            this.int16Array        = LAZY_SENTINEL;
+            this.uint16Array       = LAZY_SENTINEL;
+            this.int32Array        = LAZY_SENTINEL;
+            this.uint32Array       = LAZY_SENTINEL;
+            this.float32Array      = LAZY_SENTINEL;
+            this.float64Array      = LAZY_SENTINEL;
         }
 
         if (env._scripting) {
@@ -1959,7 +2623,7 @@
             addOwnProperty("$ARG", Attribute.NOT_ENUMERABLE, arguments);
         }
 
-        if (engine != null) {
+        if (eng != null) {
             // default file name
             addOwnProperty(ScriptEngine.FILENAME, Attribute.NOT_ENUMERABLE, null);
             // __noSuchProperty__ hook for ScriptContext search of missing variables
@@ -1996,12 +2660,9 @@
 
         tagBuiltinProperties("Error", builtinError);
 
-        this.builtinEvalError = initErrorSubtype("EvalError", errorProto);
-        this.builtinRangeError = initErrorSubtype("RangeError", errorProto);
         this.builtinReferenceError = initErrorSubtype("ReferenceError", errorProto);
         this.builtinSyntaxError = initErrorSubtype("SyntaxError", errorProto);
         this.builtinTypeError = initErrorSubtype("TypeError", errorProto);
-        this.builtinURIError = initErrorSubtype("URIError", errorProto);
     }
 
     private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) {
@@ -2023,8 +2684,6 @@
         this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
         this.builtinJavax = new NativeJavaPackage("javax", objectProto);
         this.builtinOrg = new NativeJavaPackage("org", objectProto);
-        this.builtinJavaImporter = initConstructor("JavaImporter", ScriptFunction.class);
-        this.builtinJavaApi = initConstructor("Java", ScriptObject.class);
     }
 
     private void initScripting(final ScriptEnvironment scriptEnv) {
@@ -2055,6 +2714,14 @@
             // Retrieve current state of ENV variables.
             final ScriptObject env = newObject();
             env.putAll(System.getenv(), scriptEnv._strict);
+
+            // Some platforms, e.g., Windows, do not define the PWD environment
+            // variable, so that the $ENV.PWD property needs to be explicitly
+            // set.
+            if (!env.containsKey(ScriptingFunctions.PWD_NAME)) {
+                env.put(ScriptingFunctions.PWD_NAME, System.getProperty("user.dir"), scriptEnv._strict);
+            }
+
             addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
         } else {
             addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
@@ -2076,60 +2743,25 @@
         }
     }
 
-    private void initTypedArray() {
-        this.builtinArrayBuffer       = initConstructorAndSwitchPoint("ArrayBuffer", ScriptFunction.class);
-        this.builtinDataView          = initConstructorAndSwitchPoint("DataView", ScriptFunction.class);
-        this.builtinInt8Array         = initConstructorAndSwitchPoint("Int8Array", ScriptFunction.class);
-        this.builtinUint8Array        = initConstructorAndSwitchPoint("Uint8Array", ScriptFunction.class);
-        this.builtinUint8ClampedArray = initConstructorAndSwitchPoint("Uint8ClampedArray", ScriptFunction.class);
-        this.builtinInt16Array        = initConstructorAndSwitchPoint("Int16Array", ScriptFunction.class);
-        this.builtinUint16Array       = initConstructorAndSwitchPoint("Uint16Array", ScriptFunction.class);
-        this.builtinInt32Array        = initConstructorAndSwitchPoint("Int32Array", ScriptFunction.class);
-        this.builtinUint32Array       = initConstructorAndSwitchPoint("Uint32Array", ScriptFunction.class);
-        this.builtinFloat32Array      = initConstructorAndSwitchPoint("Float32Array", ScriptFunction.class);
-        this.builtinFloat64Array      = initConstructorAndSwitchPoint("Float64Array", ScriptFunction.class);
-
-    }
-
     private void copyBuiltins() {
         this.array             = this.builtinArray;
         this._boolean          = this.builtinBoolean;
-        this.date              = this.builtinDate;
         this.error             = this.builtinError;
-        this.evalError         = this.builtinEvalError;
         this.function          = this.builtinFunction;
-        this.jsadapter         = this.builtinJSAdapter;
-        this.json              = this.builtinJSON;
         this.com               = this.builtinCom;
         this.edu               = this.builtinEdu;
         this.java              = this.builtinJava;
         this.javafx            = this.builtinJavafx;
         this.javax             = this.builtinJavax;
         this.org               = this.builtinOrg;
-        this.javaImporter      = this.builtinJavaImporter;
-        this.javaApi           = this.builtinJavaApi;
         this.math              = this.builtinMath;
         this.number            = this.builtinNumber;
         this.object            = this.builtinObject;
         this.packages          = this.builtinPackages;
-        this.rangeError        = this.builtinRangeError;
         this.referenceError    = this.builtinReferenceError;
-        this.regexp            = this.builtinRegExp;
         this.string            = this.builtinString;
         this.syntaxError       = this.builtinSyntaxError;
         this.typeError         = this.builtinTypeError;
-        this.uriError          = this.builtinURIError;
-        this.arrayBuffer       = this.builtinArrayBuffer;
-        this.dataView          = this.builtinDataView;
-        this.int8Array         = this.builtinInt8Array;
-        this.uint8Array        = this.builtinUint8Array;
-        this.uint8ClampedArray = this.builtinUint8ClampedArray;
-        this.int16Array        = this.builtinInt16Array;
-        this.uint16Array       = this.builtinUint16Array;
-        this.int32Array        = this.builtinInt32Array;
-        this.uint32Array       = this.builtinUint32Array;
-        this.float32Array      = this.builtinFloat32Array;
-        this.float64Array      = this.builtinFloat64Array;
     }
 
     private void initDebug() {
@@ -2137,8 +2769,9 @@
     }
 
     private Object printImpl(final boolean newLine, final Object... objects) {
+        final ScriptContext sc = currentContext();
         @SuppressWarnings("resource")
-        final PrintWriter out = scontext != null? new PrintWriter(scontext.getWriter()) : getContext().getEnv().getOut();
+        final PrintWriter out = sc != null? new PrintWriter(sc.getWriter()) : getContext().getEnv().getOut();
         final StringBuilder sb = new StringBuilder();
 
         for (final Object obj : objects) {
@@ -2351,8 +2984,8 @@
      */
     private static class LexicalScope extends ScriptObject {
 
-        LexicalScope(final ScriptObject proto) {
-            super(proto, PropertyMap.newMap());
+        LexicalScope(final Global global) {
+            super(global, PropertyMap.newMap());
         }
 
         @Override
--- a/src/jdk/nashorn/internal/objects/NativeArray.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeArray.java	Fri Nov 13 15:38:44 2015 -0800
@@ -120,9 +120,6 @@
         this(ArrayData.allocate(array.length));
 
         ArrayData arrayData = this.getArray();
-        if (array.length > 0) {
-            arrayData.ensure(array.length - 1);
-        }
 
         for (int index = 0; index < array.length; index++) {
             final Object value = array[index];
@@ -275,7 +272,7 @@
         final PropertyDescriptor newLenDesc = desc;
 
         // Step 3c and 3d - get new length and convert to long
-        final long newLen = NativeArray.validLength(newLenDesc.getValue(), true);
+        final long newLen = NativeArray.validLength(newLenDesc.getValue());
 
         // Step 3e
         newLenDesc.setValue(newLen);
@@ -348,8 +345,8 @@
         final PropertyDescriptor oldLenDesc = (PropertyDescriptor) super.getOwnPropertyDescriptor("length");
 
         // Step 2
-        // get old length and convert to long
-        final long oldLen = NativeArray.validLength(oldLenDesc.getValue(), true);
+        // get old length and convert to long. Always a Long/Uint32 but we take the safe road.
+        final long oldLen = JSType.toUint32(oldLenDesc.getValue());
 
         // Step 3
         if ("length".equals(key)) {
@@ -471,7 +468,7 @@
     @Setter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
     public static void length(final Object self, final Object length) {
         if (isArray(self)) {
-            ((ScriptObject)self).setLength(validLength(length, true));
+            ((ScriptObject)self).setLength(validLength(length));
         }
     }
 
@@ -495,18 +492,13 @@
         length(self, length);  // Same as instance setter but we can't make nasgen use the same method for prototype
     }
 
-    static long validLength(final Object length, final boolean reject) {
+    static long validLength(final Object length) {
+        // ES5 15.4.5.1, steps 3.c and 3.d require two ToNumber conversions here
         final double doubleLength = JSType.toNumber(length);
-        if (!Double.isNaN(doubleLength) && JSType.isRepresentableAsLong(doubleLength)) {
-            final long len = (long) doubleLength;
-            if (len >= 0 && len <= JSType.MAX_UINT) {
-                return len;
-            }
-        }
-        if (reject) {
+        if (doubleLength != JSType.toUint32(length)) {
             throw rangeError("inappropriate.array.length", ScriptRuntime.safeToString(length));
         }
-        return -1;
+        return (long) doubleLength;
     }
 
     /**
@@ -1236,31 +1228,41 @@
         final List<Object> list = Arrays.asList(array);
         final Object cmpThis = cmp == null || cmp.isStrict() ? ScriptRuntime.UNDEFINED : Global.instance();
 
-        Collections.sort(list, new Comparator<Object>() {
-            private final MethodHandle call_cmp = getCALL_CMP();
-            @Override
-            public int compare(final Object x, final Object y) {
-                if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) {
-                    return 0;
-                } else if (x == ScriptRuntime.UNDEFINED) {
-                    return 1;
-                } else if (y == ScriptRuntime.UNDEFINED) {
-                    return -1;
-                }
+        try {
+            Collections.sort(list, new Comparator<Object>() {
+                private final MethodHandle call_cmp = getCALL_CMP();
+                @Override
+                public int compare(final Object x, final Object y) {
+                    if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) {
+                        return 0;
+                    } else if (x == ScriptRuntime.UNDEFINED) {
+                        return 1;
+                    } else if (y == ScriptRuntime.UNDEFINED) {
+                        return -1;
+                    }
 
-                if (cmp != null) {
-                    try {
-                        return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y));
-                    } catch (final RuntimeException | Error e) {
-                        throw e;
-                    } catch (final Throwable t) {
-                        throw new RuntimeException(t);
+                    if (cmp != null) {
+                        try {
+                            return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y));
+                        } catch (final RuntimeException | Error e) {
+                            throw e;
+                        } catch (final Throwable t) {
+                            throw new RuntimeException(t);
+                        }
                     }
-                }
 
-                return JSType.toString(x).compareTo(JSType.toString(y));
-            }
-        });
+                    return JSType.toString(x).compareTo(JSType.toString(y));
+                }
+            });
+        } catch (final IllegalArgumentException iae) {
+            // Collections.sort throws IllegalArgumentException when
+            // Comparison method violates its general contract
+
+            // See ECMA spec 15.4.4.11 Array.prototype.sort (comparefn).
+            // If "comparefn" is not undefined and is not a consistent
+            // comparison function for the elements of this array, the
+            // behaviour of sort is implementation-defined.
+        }
 
         return list.toArray(new Object[array.length]);
     }
--- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java	Fri Nov 13 15:38:44 2015 -0800
@@ -101,7 +101,7 @@
         }
 
         if (args.length == 0) {
-            throw new RuntimeException("missing length argument");
+            return new NativeArrayBuffer(0);
         }
 
         return new NativeArrayBuffer(JSType.toInt32(args[0]));
--- a/src/jdk/nashorn/internal/objects/NativeDate.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeDate.java	Fri Nov 13 15:38:44 2015 -0800
@@ -30,6 +30,7 @@
 import static java.lang.Double.isNaN;
 import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.concurrent.Callable;
@@ -40,7 +41,6 @@
 import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.parser.DateParser;
-import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptEnvironment;
@@ -121,6 +121,10 @@
         this.timezone = env._timezone;
     }
 
+    NativeDate(final double time, final ScriptObject proto) {
+        this(time, proto, $nasgenmap$);
+    }
+
     NativeDate(final double time, final Global global) {
         this(time, global.getDatePrototype(), $nasgenmap$);
     }
@@ -183,7 +187,7 @@
         case 1:
             double num;
             final Object arg = JSType.toPrimitive(args[0]);
-            if (arg instanceof String || arg instanceof ConsString) {
+            if (JSType.isString(arg)) {
                 num = parseDateString(arg.toString());
             } else {
                 num = timeClip(JSType.toNumber(args[0]));
@@ -1276,7 +1280,7 @@
         if (self instanceof NativeDate) {
             return (NativeDate)self;
         } else if (self != null && self == Global.instance().getDatePrototype()) {
-            return Global.instance().DEFAULT_DATE;
+            return Global.instance().getDefaultDate();
         } else {
             throw typeError("not.a.date", ScriptRuntime.safeToString(self));
         }
--- a/src/jdk/nashorn/internal/objects/NativeDebug.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeDebug.java	Fri Nov 13 15:38:44 2015 -0800
@@ -37,6 +37,7 @@
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyListeners;
 import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.Scope;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -245,7 +246,7 @@
         final PrintWriter out = Context.getCurrentErr();
 
         out.println("ScriptObject count " + ScriptObject.getCount());
-        out.println("Scope count " + ScriptObject.getScopeCount());
+        out.println("Scope count " + Scope.getCount());
         out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
         out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
         out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
--- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -114,12 +114,11 @@
 
         private void setElem(final int index, final double elem) {
             try {
-                nb.put(index, (float)elem);
+                if (index < nb.limit()) {
+                    nb.put(index, (float) elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -114,12 +114,11 @@
 
         private void setElem(final int index, final double elem) {
             try {
-                nb.put(index, elem);
+                if (index < nb.limit()) {
+                    nb.put(index, elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
              }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeFunction.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeFunction.java	Fri Nov 13 15:38:44 2015 -0800
@@ -279,8 +279,8 @@
         sb.append("})");
 
         final Global global = Global.instance();
-
-        return (ScriptFunction)Global.directEval(global, sb.toString(), global, "<function>", global.isStrictContext());
+        final Context context = global.getContext();
+        return (ScriptFunction)context.eval(global, sb.toString(), global, "<function>");
     }
 
     private static void checkFunctionParameters(final String params) {
--- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -115,12 +115,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, (short)elem);
+                if (index < nb.limit()) {
+                    nb.put(index, (short) elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -104,11 +104,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, elem);
-               } catch (final IndexOutOfBoundsException e) {
-                   if (index < 0) {
-                      throw new ClassCastException();
-                 }
+                if (index < nb.limit()) {
+                    nb.put(index, elem);
+                }
+            } catch (final IndexOutOfBoundsException e) {
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -113,12 +113,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, (byte)elem);
+                if (index < nb.limit()) {
+                    nb.put(index, (byte) elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -160,7 +160,7 @@
     }
 
     private static ScriptObject wrapAdaptee(final ScriptObject adaptee) {
-        return new JO(adaptee, JO.getInitialMap());
+        return new JO(adaptee);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeJSON.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeJSON.java	Fri Nov 13 15:38:44 2015 -0800
@@ -181,7 +181,7 @@
                 }
                 gap = sb.toString();
             }
-        } else if (modSpace instanceof String || modSpace instanceof ConsString) {
+        } else if (JSType.isString(modSpace)) {
             final String str = modSpace.toString();
             gap = str.substring(0, Math.min(10, str.length()));
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeJava.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeJava.java	Fri Nov 13 15:38:44 2015 -0800
@@ -33,10 +33,12 @@
 import java.util.Collection;
 import java.util.Deque;
 import java.util.List;
+import java.util.Map;
+import java.util.Queue;
 import jdk.internal.dynalink.beans.StaticClass;
 import jdk.internal.dynalink.support.TypeUtilities;
 import jdk.nashorn.api.scripting.JSObject;
-import jdk.nashorn.api.scripting.ScriptUtils;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Function;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
@@ -339,7 +341,8 @@
 
     /**
      * Given a script object and a Java type, converts the script object into the desired Java type. Currently it
-     * performs shallow creation of Java arrays, as well as wrapping of objects in Lists and Dequeues. Example:
+     * performs shallow creation of Java arrays, as well as wrapping of objects in Lists, Dequeues, Queues,
+     * and Collections. Example:
      * <pre>
      * var anArray = [1, "13", false]
      * var javaIntArray = Java.to(anArray, "int[]")
@@ -353,9 +356,10 @@
      * object to create. Can not be null. If undefined, a "default" conversion is presumed (allowing the argument to be
      * omitted).
      * @return a Java object whose value corresponds to the original script object's value. Specifically, for array
-     * target types, returns a Java array of the same type with contents converted to the array's component type. Does
-     * not recursively convert for multidimensional arrays. For {@link List} or {@link Deque}, returns a live wrapper
-     * around the object, see {@link ListAdapter} for details. Returns null if obj is null.
+     * target types, returns a Java array of the same type with contents converted to the array's component type.
+     * Converts recursively when the target type is multidimensional array. For {@link List}, {@link Deque},
+     * {@link Queue}, or {@link Collection}, returns a live wrapper around the object, see {@link ListAdapter} for
+     * details. Returns null if obj is null.
      * @throws ClassNotFoundException if the class described by objType is not found
      */
     @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
@@ -385,7 +389,7 @@
             return JSType.toJavaArray(obj, targetClass.getComponentType());
         }
 
-        if(targetClass == List.class || targetClass == Deque.class) {
+        if (targetClass == List.class || targetClass == Deque.class || targetClass == Queue.class || targetClass == Collection.class) {
             return ListAdapter.create(obj);
         }
 
@@ -654,4 +658,20 @@
     public static Object _super(final Object self, final Object adapter) {
         return Bootstrap.createSuperAdapter(adapter);
     }
+
+    /**
+     * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any
+     * object transitively reachable through it is a JavaScript array, then such objects will be exposed as
+     * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit
+     * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the
+     * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other
+     * objects as {@link Map}s.
+     * @param self not used
+     * @param obj the object to be exposed in a Java JSON library compatible manner.
+     * @return a wrapper around the object that will enforce Java JSON library compatible exposure.
+     */
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    public static Object asJSONCompatible(final Object self, final Object obj) {
+        return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal());
+    }
 }
--- a/src/jdk/nashorn/internal/objects/NativeObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -499,7 +499,7 @@
         final Object obj = JSType.toScriptObject(self);
         if (obj instanceof ScriptObject) {
             final InvokeByName toStringInvoker = getTO_STRING();
-            final ScriptObject sobj = (ScriptObject)self;
+            final ScriptObject sobj = (ScriptObject)obj;
             try {
                 final Object toString = toStringInvoker.getGetter().invokeExact(sobj);
 
@@ -765,7 +765,7 @@
                 continue;
             }
             properties.add(AccessorProperty.create(methodName, Property.NOT_WRITABLE, getBoundBeanMethodGetter(source,
-                    method), null));
+                    method), Lookup.EMPTY_SETTER));
         }
         for(final String propertyName: propertyNames) {
             MethodHandle getter;
--- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Fri Nov 13 15:38:44 2015 -0800
@@ -78,8 +78,8 @@
         this.globalObject = global;
     }
 
-    NativeRegExp(final String input, final String flagString, final Global global) {
-        this(global);
+    NativeRegExp(final String input, final String flagString, final Global global, final ScriptObject proto) {
+        super(proto, $nasgenmap$);
         try {
             this.regexp = RegExpFactory.create(input, flagString);
         } catch (final ParserException e) {
@@ -87,8 +87,12 @@
             e.throwAsEcmaException();
             throw new AssertionError(); //guard against null warnings below
         }
+        this.globalObject = global;
+        this.setLastIndex(0);
+    }
 
-        this.setLastIndex(0);
+    NativeRegExp(final String input, final String flagString, final Global global) {
+        this(input, flagString, global, global.getRegExpPrototype());
     }
 
     NativeRegExp(final String input, final String flagString) {
@@ -928,7 +932,7 @@
         if (self instanceof NativeRegExp) {
             return (NativeRegExp)self;
         } else if (self != null && self == Global.instance().getRegExpPrototype()) {
-            return Global.instance().DEFAULT_REGEXP;
+            return Global.instance().getDefaultRegExp();
         } else {
             throw typeError("not.a.regexp", ScriptRuntime.safeToString(self));
         }
--- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java	Fri Nov 13 15:38:44 2015 -0800
@@ -88,7 +88,7 @@
     @Setter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
     public static void length(final Object self, final Object length) {
         if (self instanceof ScriptObject) {
-            ((ScriptObject)self).setLength(NativeArray.validLength(length, true));
+            ((ScriptObject)self).setLength(NativeArray.validLength(length));
         }
     }
 }
--- a/src/jdk/nashorn/internal/objects/NativeString.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeString.java	Fri Nov 13 15:38:44 2015 -0800
@@ -90,7 +90,7 @@
 
     private NativeString(final CharSequence value, final ScriptObject proto, final PropertyMap map) {
         super(proto, map);
-        assert value instanceof String || value instanceof ConsString;
+        assert JSType.isString(value);
         this.value = value;
     }
 
@@ -155,7 +155,7 @@
         final Object self = request.getReceiver();
         final Class<?> returnType = desc.getMethodType().returnType();
 
-        if (returnType == Object.class && (self instanceof String || self instanceof ConsString)) {
+        if (returnType == Object.class && JSType.isString(self)) {
             try {
                 return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getInstanceOf2Guard(String.class, ConsString.class));
             } catch (final LookupException e) {
@@ -1312,7 +1312,7 @@
     }
 
     private static CharSequence getCharSequence(final Object self) {
-        if (self instanceof String || self instanceof ConsString) {
+        if (JSType.isString(self)) {
             return (CharSequence)self;
         } else if (self instanceof NativeString) {
             return ((NativeString)self).getValue();
--- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -104,12 +104,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, (char)elem);
+                if (index < nb.limit()) {
+                    nb.put(index, (char) elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -113,12 +113,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, elem);
+                if (index < nb.limit()) {
+                    nb.put(index, elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Fri Nov 13 15:38:44 2015 -0800
@@ -104,12 +104,11 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                nb.put(index, (byte)elem);
+                if (index < nb.limit()) {
+                    nb.put(index, (byte) elem);
+                }
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Fri Nov 13 15:38:44 2015 -0800
@@ -133,18 +133,17 @@
 
         private void setElem(final int index, final int elem) {
             try {
-                final byte clamped;
-                if ((elem & 0xffff_ff00) == 0) {
-                    clamped = (byte)elem;
-                } else {
-                    clamped = elem < 0 ? 0 : (byte)0xff;
+                if (index < nb.limit()) {
+                    final byte clamped;
+                    if ((elem & 0xffff_ff00) == 0) {
+                        clamped = (byte) elem;
+                    } else {
+                        clamped = elem < 0 ? 0 : (byte) 0xff;
+                    }
+                    nb.put(index, clamped);
                 }
-                nb.put(index, clamped);
             } catch (final IndexOutOfBoundsException e) {
-                //swallow valid array indexes. it's ok.
-                if (index < 0) {
-                    throw new ClassCastException();
-                }
+                throw new ClassCastException();
             }
         }
 
--- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Fri Nov 13 15:38:44 2015 -0800
@@ -118,13 +118,26 @@
     }
 
     /**
-     * Constructor called by (compiler) generated code for {@link ScriptObject}s.
+     * Factory method called by compiler generated code for functions that need parent scope.
      *
-     * @param data static function data
-     * @param scope scope object
+     * @param constants the generated class' constant array
+     * @param index the index of the {@code RecompilableScriptFunctionData} object in the constants array.
+     * @param scope the parent scope object
+     * @return a newly created function object
      */
-    public ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope) {
-        this(data, scope, Global.instance());
+    public static ScriptFunction create(final Object[] constants, final int index, final ScriptObject scope) {
+        return new ScriptFunctionImpl((RecompilableScriptFunctionData)constants[index], scope, Global.instance());
+    }
+
+    /**
+     * Factory method called by compiler generated code for functions that don't need parent scope.
+     *
+     * @param constants the generated class' constant array
+     * @param index the index of the {@code RecompilableScriptFunctionData} object in the constants array.
+     * @return a newly created function object
+     */
+    public static ScriptFunction create(final Object[] constants, final int index) {
+        return create(constants, index, null);
     }
 
     /**
@@ -292,7 +305,7 @@
         final ScriptFunction typeErrorThrower = global.getTypeErrorThrower();
         if (findProperty("arguments", true) != null) {
             initUserAccessors("arguments", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower);
-       }
+        }
         if (findProperty("caller", true) != null) {
             initUserAccessors("caller", Property.NOT_CONFIGURABLE | Property.NOT_ENUMERABLE, typeErrorThrower, typeErrorThrower);
        }
--- a/src/jdk/nashorn/internal/objects/annotations/Constructor.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/Constructor.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,13 +37,15 @@
 @Target(ElementType.METHOD)
 public @interface Constructor {
     /**
-     * Name of the constructor function. If empty, the name is inferred.
+     * @return the name of the constructor function. If empty, the name is
+     *         inferred.
      */
     public String name() default "";
 
     /**
-     * The arity of the function. By default computed from the method signature.
-     * Note that -1 means varargs. So, -2 is used as invalid arity.
+     * @return the arity of the function. By default computed from the method
+     *         signature. Note that -1 means varargs. So, -2 is used as invalid
+     *         arity.
      */
     public int arity() default -2;
 }
--- a/src/jdk/nashorn/internal/objects/annotations/Function.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/Function.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,22 +41,23 @@
 @Target(ElementType.METHOD)
 public @interface Function {
     /**
-     * Name of the property. If empty, the name is inferred.
+     * @return the name of the property. If empty, the name is inferred.
      */
     public String name() default "";
 
     /**
-     * Attribute flags for this function.
+     * @return the attribute flags for this function.
      */
     public int attributes() default DEFAULT_ATTRIBUTES;
 
     /**
-     * The arity of the function. By default computed from the method signature
+     * @return the arity of the function. By default computed from the method
+     *         signature.
      */
     public int arity() default -2;
 
     /**
-     * where this function lives
+     * @return where this function lives.
      */
     public Where where() default Where.PROTOTYPE;
 }
--- a/src/jdk/nashorn/internal/objects/annotations/Getter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/Getter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,17 +39,17 @@
 @Target(ElementType.METHOD)
 public @interface Getter {
     /**
-     * Name of the property. If empty, the name is inferred.
+     * @return the name of the property. If empty, the name is inferred.
      */
     public String name() default "";
 
     /**
-     * Attribute flags for this setter.
+     * @return the attribute flags for this setter.
      */
     public int attributes() default DEFAULT_ATTRIBUTES;
 
     /**
-     * Where this getter lives?
+     * @return where this getter lives.
      */
     public Where where() default Where.INSTANCE;
 }
--- a/src/jdk/nashorn/internal/objects/annotations/ScriptClass.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/ScriptClass.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,8 +37,8 @@
 @Target(ElementType.TYPE)
 public @interface ScriptClass {
     /**
-     * Name of the script class. By default, the name is derived from
-     * the Java class name.
+     * @return the name of the script class. By default, the name is derived
+     *         from the Java class name.
      */
     public String value() default "";
 }
--- a/src/jdk/nashorn/internal/objects/annotations/Setter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/Setter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,17 +39,17 @@
 @Target(ElementType.METHOD)
 public @interface Setter {
     /**
-     * Name of the script property. If empty, the name is inferred.
+     * @return the name of the script property. If empty, the name is inferred.
      */
     public String name() default "";
 
     /**
-     * Attribute flags for this setter.
+     * @return the attribute flags for this setter.
      */
     public int attributes() default DEFAULT_ATTRIBUTES;
 
     /**
-     * Where this setter lives?
+     * @return where this setter lives.
      */
     public Where where() default Where.INSTANCE;
 }
--- a/src/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,11 @@
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.nashorn.internal.runtime.ScriptFunction;
+import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
 
 /**
  * The SpecializedFunction annotation is used to flag more type specific
- * functions than the standard one in the native objects
+ * functions than the standard one in the native objects.
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.METHOD)
@@ -45,23 +46,23 @@
     /**
      * Functionality for testing if we are allowed to link a specialized
      * function the first time we encounter it. Then the guard will handle the
-     * rest of the invocations
+     * rest of the invocations.
      *
-     * This is the same for all callsites in Nashorn, the first time callsite is
+     * This is the same for all callsites in Nashorn; the first time a callsite is
      * linked, we have to manually check that the linkage is OK. Even if we add
      * a guard and it fails upon the first try, this is not good enough.
-     * (Symmetrical to how it works everywhere else in the Nashorn runtime).
+     * (Symmetrical to how it works everywhere else in the Nashorn runtime.)
      *
      * Here we abstract out a few of the most common link guard checks.
      */
     public static abstract class LinkLogic {
         /**
-         * Empty link logic instance - this is the default
+         * Empty link logic instance - this is the default.
          * "no special linking or runtime guard behavior"
          */
         public static final LinkLogic EMPTY_INSTANCE = new Empty();
 
-        /** Empty link logic class - allow all linking, no guards */
+        /** Empty link logic class - allow all linking, no guards. */
         private static final class Empty extends LinkLogic {
             @Override
             public boolean canLink(final Object self, final CallSiteDescriptor desc, final LinkRequest request) {
@@ -75,7 +76,8 @@
         }
 
         /**
-         * Get the class representing the empty link logic
+         * Get the class representing the empty link logic.
+         *
          * @return class representing empty link logic
          */
         public static Class<? extends LinkLogic> getEmptyLinkLogicClass() {
@@ -83,31 +85,31 @@
         }
 
         /**
-         * Should this callsite relink when an exception is thrown
+         * Should this callsite relink when an exception is thrown?
          *
-         * @return the relink exception, or null if none
+         * @return the relink exception, or {@code null} if none
          */
         public Class<? extends Throwable> getRelinkException() {
             return null;
         }
 
         /**
-         * Is this link logic class empty - i.e. no special linking logic
-         * supplied
+         * Is this link logic class empty - i.e., no special linking logic
+         * supplied?
          *
          * @param clazz class to check
          *
-         * @return true if this link logic is empty
+         * @return {@code true} if this link logic is empty
          */
         public static boolean isEmpty(final Class<? extends LinkLogic> clazz) {
             return clazz == Empty.class;
         }
 
         /**
-         * Is this link logic instance empty - i.e. no special linking logic
-         * supplied
+         * Is this link logic instance empty - i.e., no special linking logic
+         * supplied?
          *
-         * @return true if this link logic instance is empty
+         * @return {@code true} if this link logic instance is empty
          */
         public boolean isEmpty() {
             return false;
@@ -121,7 +123,7 @@
          * @param desc    callsite descriptor
          * @param request link request
          *
-         * @return true if we can link this callsite at this time
+         * @return {@code true} if we can link this callsite at this time
          */
         public abstract boolean canLink(final Object self, final CallSiteDescriptor desc, final LinkRequest request);
 
@@ -131,7 +133,7 @@
          *
          * @param self receiver
          *
-         * @return true if a guard is to be woven into the callsite
+         * @return {@code true} if a guard is to be woven into the callsite
          */
         public boolean needsGuard(final Object self) {
             return true;
@@ -139,13 +141,13 @@
 
         /**
          * Given a callsite, and optional arguments, do we need an extra guard
-         * for specialization to go through - this guard can be a function of
-         * the arguments too
+         * for specialization to go through? This guard can be a function of
+         * the arguments too.
          *
          * @param self receiver
          * @param args arguments
          *
-         * @return true if a guard is to be woven into the callsite
+         * @return {@code true} if a guard is to be woven into the callsite
          */
         public boolean needsGuard(final Object self, final Object... args) {
             return true;
@@ -169,9 +171,9 @@
          * @param self receiver
          * @param desc callsite descriptor
          * @param request link request
-
-         * @return true if we can link, false otherwise - that means we have to
-         *         pick a non specialized target
+         *
+         * @return {@code true} if we can link, {@code false} otherwise - that
+         *         means we have to pick a non specialized target
          */
         public boolean checkLinkable(final Object self, final CallSiteDescriptor desc, final LinkRequest request) {
             // check the link guard, if it says we can link, go ahead
@@ -180,11 +182,11 @@
     }
 
     /**
-     * name override for return value polymorphism, for example we can't have
+     * Name override for return value polymorphism, for example we can't have
      * pop(V)I and pop(V)D in the same Java class, so they need to be named,
-     * e.g. popInt(V)I and popDouble(V)D for disambiguation, however, their
+     * e.g., popInt(V)I and popDouble(V)D for disambiguation, however, their
      * names still need to resolve to "pop" to JavaScript so we can still
-     * specialize on return values and so that the linker can find them
+     * specialize on return values and so that the linker can find them.
      *
      * @return name, "" means no override, use the Java function name, e.g.
      *         "push"
@@ -199,16 +201,18 @@
     Class<?> linkLogic() default LinkLogic.Empty.class;
 
     /**
-     * Is this a specialized constructor?
+     * @return whether this is a specialized constructor.
      */
     boolean isConstructor() default false;
 
     /**
-     * Can this function throw UnwarrantedOptimismExceptions? This works just
-     * like the normal functions, but we need the function to be
+     * Can this function throw {@link UnwarrantedOptimismException}s? This works
+     * just like the normal functions, but we need the function to be
      * immutable/non-state modifying, as we can't generate continuations for
      * native code. Luckily a lot of the methods we want to specialize have this
-     * property
+     * property.
+     *
+     * @return whether this function can throw {@link UnwarrantedOptimismException}.
      */
     boolean isOptimistic() default false;
 }
--- a/src/jdk/nashorn/internal/parser/AbstractParser.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/parser/AbstractParser.java	Fri Nov 13 15:38:44 2015 -0800
@@ -459,6 +459,19 @@
         if (kind == TokenKind.KEYWORD || kind == TokenKind.FUTURE || kind == TokenKind.FUTURESTRICT) {
             return true;
         }
+
+        // only literals allowed are null, false and true
+        if (kind == TokenKind.LITERAL) {
+            switch (type) {
+                case FALSE:
+                case NULL:
+                case TRUE:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
         // Fake out identifier.
         final long identToken = Token.recast(token, IDENT);
         // Get IDENT.
--- a/src/jdk/nashorn/internal/parser/JSONParser.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/parser/JSONParser.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,43 +25,69 @@
 
 package jdk.nashorn.internal.parser;
 
-import static jdk.nashorn.internal.parser.TokenType.COLON;
-import static jdk.nashorn.internal.parser.TokenType.COMMARIGHT;
-import static jdk.nashorn.internal.parser.TokenType.EOF;
-import static jdk.nashorn.internal.parser.TokenType.ESCSTRING;
-import static jdk.nashorn.internal.parser.TokenType.RBRACE;
-import static jdk.nashorn.internal.parser.TokenType.RBRACKET;
-import static jdk.nashorn.internal.parser.TokenType.STRING;
 import java.util.ArrayList;
 import java.util.List;
-import jdk.nashorn.internal.ir.Expression;
-import jdk.nashorn.internal.ir.LiteralNode;
-import jdk.nashorn.internal.ir.Node;
-import jdk.nashorn.internal.ir.ObjectNode;
-import jdk.nashorn.internal.ir.PropertyNode;
-import jdk.nashorn.internal.ir.UnaryNode;
+import jdk.nashorn.internal.codegen.ObjectClassGenerator;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.ECMAErrors;
 import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.JSErrorType;
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.Property;
+import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.SpillProperty;
+import jdk.nashorn.internal.runtime.arrays.ArrayData;
+import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
+import jdk.nashorn.internal.scripts.JD;
+import jdk.nashorn.internal.scripts.JO;
+
+import static jdk.nashorn.internal.parser.TokenType.STRING;
 
 /**
- * Parses JSON text and returns the corresponding IR node. This is derived from the objectLiteral production of the main parser.
+ * Parses JSON text and returns the corresponding IR node. This is derived from
+ * the objectLiteral production of the main parser.
  *
  * See: 15.12.1.2 The JSON Syntactic Grammar
  */
-public class JSONParser extends AbstractParser {
+public class JSONParser {
+
+    final private String source;
+    final private Global global;
+    final private boolean dualFields;
+    final int length;
+    int pos = 0;
+
+    private static final int EOF = -1;
+
+    private static final String TRUE  = "true";
+    private static final String FALSE = "false";
+    private static final String NULL  = "null";
+
+    private static final int STATE_EMPTY          = 0;
+    private static final int STATE_ELEMENT_PARSED = 1;
+    private static final int STATE_COMMA_PARSED   = 2;
 
     /**
-     * Constructor
-     * @param source  the source
-     * @param errors  the error manager
+     * Constructor.
+     *
+     * @param source     the source
+     * @param global     the global object
+     * @param dualFields whether the parser should regard dual field representation
      */
-    public JSONParser(final Source source, final ErrorManager errors) {
-        super(source, errors, false, 0);
+    public JSONParser(final String source, final Global global, final boolean dualFields) {
+        this.source = source;
+        this.global = global;
+        this.length = source.length();
+        this.dualFields = dualFields;
     }
 
     /**
-     * Implementation of the Quote(value) operation as defined in the ECMA script spec
-     * It wraps a String value in double quotes and escapes characters within in
+     * Implementation of the Quote(value) operation as defined in the ECMAscript
+     * spec. It wraps a String value in double quotes and escapes characters
+     * within.
      *
      * @param value string to quote
      *
@@ -114,329 +140,413 @@
     }
 
     /**
-     * Public parsed method - start lexing a new token stream for
-     * a JSON script
+     * Public parse method. Parse a string into a JSON object.
      *
-     * @return the JSON literal
+     * @return the parsed JSON Object
      */
-    public Node parse() {
-        stream = new TokenStream();
-
-        lexer = new Lexer(source, stream) {
-
-            @Override
-            protected boolean skipComments() {
-                return false;
-            }
-
-            @Override
-            protected boolean isStringDelimiter(final char ch) {
-                return ch == '\"';
-            }
-
-            // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONWhiteSpace
-            @Override
-            protected boolean isWhitespace(final char ch) {
-                return Lexer.isJsonWhitespace(ch);
-            }
-
-            @Override
-            protected boolean isEOL(final char ch) {
-                return Lexer.isJsonEOL(ch);
-            }
+    public Object parse() {
+        final Object value = parseLiteral();
+        skipWhiteSpace();
+        if (pos < length) {
+            throw expectedError(pos, "eof", toString(peek()));
+        }
+        return value;
+    }
 
-            // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONNumber
-            @Override
-            protected void scanNumber() {
-                // Record beginning of number.
-                final int startPosition = position;
-                // Assume value is a decimal.
-                TokenType valueType = TokenType.DECIMAL;
-
-                // floating point can't start with a "." with no leading digit before
-                if (ch0 == '.') {
-                    error(Lexer.message("json.invalid.number"), STRING, position, limit);
-                }
-
-                // First digit of number.
-                final int digit = convertDigit(ch0, 10);
-
-                // skip first digit
-                skip(1);
-
-                if (digit != 0) {
-                    // Skip over remaining digits.
-                    while (convertDigit(ch0, 10) != -1) {
-                        skip(1);
-                    }
-                }
-
-                if (ch0 == '.' || ch0 == 'E' || ch0 == 'e') {
-                    // Must be a double.
-                    if (ch0 == '.') {
-                        // Skip period.
-                        skip(1);
+    private Object parseLiteral() {
+        skipWhiteSpace();
 
-                        boolean mantissa = false;
-                        // Skip mantissa.
-                        while (convertDigit(ch0, 10) != -1) {
-                            mantissa = true;
-                            skip(1);
-                        }
-
-                        if (! mantissa) {
-                            // no digit after "."
-                            error(Lexer.message("json.invalid.number"), STRING, position, limit);
-                        }
-                    }
-
-                    // Detect exponent.
-                    if (ch0 == 'E' || ch0 == 'e') {
-                        // Skip E.
-                        skip(1);
-                        // Detect and skip exponent sign.
-                        if (ch0 == '+' || ch0 == '-') {
-                            skip(1);
-                        }
-                        boolean exponent = false;
-                        // Skip exponent.
-                        while (convertDigit(ch0, 10) != -1) {
-                            exponent = true;
-                            skip(1);
-                        }
-
-                        if (! exponent) {
-                            // no digit after "E"
-                            error(Lexer.message("json.invalid.number"), STRING, position, limit);
-                        }
-                    }
-
-                    valueType = TokenType.FLOATING;
-                }
-
-                // Add number token.
-                add(valueType, startPosition);
+        final int c = peek();
+        if (c == EOF) {
+            throw expectedError(pos, "json literal", "eof");
+        }
+        switch (c) {
+        case '{':
+            return parseObject();
+        case '[':
+            return parseArray();
+        case '"':
+            return parseString();
+        case 'f':
+            return parseKeyword(FALSE, Boolean.FALSE);
+        case 't':
+            return parseKeyword(TRUE, Boolean.TRUE);
+        case 'n':
+            return parseKeyword(NULL, null);
+        default:
+            if (isDigit(c) || c == '-') {
+                return parseNumber();
+            } else if (c == '.') {
+                throw numberError(pos);
+            } else {
+                throw expectedError(pos, "json literal", toString(c));
             }
-
-            // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONEscapeCharacter
-            @Override
-            protected boolean isEscapeCharacter(final char ch) {
-                switch (ch) {
-                    case '"':
-                    case '/':
-                    case '\\':
-                    case 'b':
-                    case 'f':
-                    case 'n':
-                    case 'r':
-                    case 't':
-                    // could be unicode escape
-                    case 'u':
-                        return true;
-                    default:
-                        return false;
-                }
-            }
-        };
-
-        k = -1;
-
-        next();
-
-        final Node resultNode = jsonLiteral();
-        expect(EOF);
-
-        return resultNode;
+        }
     }
 
-    @SuppressWarnings("fallthrough")
-    private LiteralNode<?> getStringLiteral() {
-        final LiteralNode<?> literal = getLiteral();
-        final String         str     = (String)literal.getValue();
+    private Object parseObject() {
+        PropertyMap propertyMap = dualFields ? JD.getInitialMap() : JO.getInitialMap();
+        ArrayData arrayData = ArrayData.EMPTY_ARRAY;
+        final ArrayList<Object> values = new ArrayList<>();
+        int state = STATE_EMPTY;
+
+        assert peek() == '{';
+        pos++;
+
+        while (pos < length) {
+            skipWhiteSpace();
+            final int c = peek();
 
-        for (int i = 0; i < str.length(); i++) {
-            final char ch = str.charAt(i);
-            switch (ch) {
+            switch (c) {
+            case '"':
+                if (state == STATE_ELEMENT_PARSED) {
+                    throw expectedError(pos - 1, ", or }", toString(c));
+                }
+                final String id = parseString();
+                expectColon();
+                final Object value = parseLiteral();
+                final int index = ArrayIndex.getArrayIndex(id);
+                if (ArrayIndex.isValidArrayIndex(index)) {
+                    arrayData = addArrayElement(arrayData, index, value);
+                } else {
+                    propertyMap = addObjectProperty(propertyMap, values, id, value);
+                }
+                state = STATE_ELEMENT_PARSED;
+                break;
+            case ',':
+                if (state != STATE_ELEMENT_PARSED) {
+                    throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+                }
+                state = STATE_COMMA_PARSED;
+                pos++;
+                break;
+            case '}':
+                if (state == STATE_COMMA_PARSED) {
+                    throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+                }
+                pos++;
+                return createObject(propertyMap, values, arrayData);
             default:
-                if (ch > 0x001f) {
-                    break;
-                }
-            case '"':
-            case '\\':
-                throw error(AbstractParser.message("unexpected.token", str));
+                throw expectedError(pos, ", or }", toString(c));
+            }
+        }
+        throw expectedError(pos, ", or }", "eof");
+    }
+
+    private static ArrayData addArrayElement(final ArrayData arrayData, final int index, final Object value) {
+        final long oldLength = arrayData.length();
+        final long longIndex = ArrayIndex.toLongIndex(index);
+        ArrayData newArrayData = arrayData;
+        if (longIndex >= oldLength) {
+            newArrayData = newArrayData.ensure(longIndex);
+            if (longIndex > oldLength) {
+                newArrayData = newArrayData.delete(oldLength, longIndex - 1);
+            }
+        }
+        return newArrayData.set(index, value, false);
+    }
+
+    private PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
+                                                 final String id, final Object value) {
+        final Property oldProperty = propertyMap.findProperty(id);
+        final PropertyMap newMap;
+        final Class<?> type;
+        final int flags;
+        if (dualFields) {
+            type = getType(value);
+            flags = Property.DUAL_FIELDS;
+        } else {
+            type = Object.class;
+            flags = 0;
+        }
+
+        if (oldProperty != null) {
+            values.set(oldProperty.getSlot(), value);
+            newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, flags, oldProperty.getSlot(), type));;
+        } else {
+            values.add(value);
+            newMap = propertyMap.addProperty(new SpillProperty(id, flags, propertyMap.size(), type));
+        }
+
+        return newMap;
+    }
+
+    private Object createObject(final PropertyMap propertyMap, final List<Object> values, final ArrayData arrayData) {
+        final long[] primitiveSpill = dualFields ? new long[values.size()] : null;
+        final Object[] objectSpill = new Object[values.size()];
+
+        for (final Property property : propertyMap.getProperties()) {
+            if (!dualFields || property.getType() == Object.class) {
+                objectSpill[property.getSlot()] = values.get(property.getSlot());
+            } else {
+                primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
             }
         }
 
-        return literal;
+        final ScriptObject object = dualFields ?
+                new JD(propertyMap, primitiveSpill, objectSpill) : new JO(propertyMap, null, objectSpill);
+        object.setInitialProto(global.getObjectPrototype());
+        object.setArray(arrayData);
+        return object;
+    }
+
+    private static Class<?> getType(final Object value) {
+        if (value instanceof Integer) {
+            return int.class;
+        } else if (value instanceof Long) {
+            return long.class;
+        } else if (value instanceof Double) {
+            return double.class;
+        } else {
+            return Object.class;
+        }
+    }
+
+    private void expectColon() {
+        skipWhiteSpace();
+        final int n = next();
+        if (n != ':') {
+            throw expectedError(pos - 1, ":", toString(n));
+        }
     }
 
-    /**
-     * Parse a JSON literal from the token stream
-     * @return the JSON literal as a Node
-     */
-    private Expression jsonLiteral() {
-        final long literalToken = token;
+    private Object parseArray() {
+        ArrayData arrayData = ArrayData.EMPTY_ARRAY;
+        int state = STATE_EMPTY;
 
-        switch (type) {
-        case STRING:
-            return getStringLiteral();
-        case ESCSTRING:
-        case DECIMAL:
-        case FLOATING:
-            return getLiteral();
-        case FALSE:
-            next();
-            return LiteralNode.newInstance(literalToken, finish, false);
-        case TRUE:
-            next();
-            return LiteralNode.newInstance(literalToken, finish, true);
-        case NULL:
-            next();
-            return LiteralNode.newInstance(literalToken, finish);
-        case LBRACKET:
-            return arrayLiteral();
-        case LBRACE:
-            return objectLiteral();
-        /*
-         * A.8.1 JSON Lexical Grammar
-         *
-         * JSONNumber :: See 15.12.1.1
-         *    -opt DecimalIntegerLiteral JSONFractionopt ExponentPartopt
-         */
-        case SUB:
-            next();
+        assert peek() == '[';
+        pos++;
 
-            final long realToken = token;
-            final Object value = getValue();
-
-            if (value instanceof Number) {
-                next();
-                return new UnaryNode(literalToken, LiteralNode.newInstance(realToken, finish, (Number)value));
-            }
+        while (pos < length) {
+            skipWhiteSpace();
+            final int c = peek();
 
-            throw error(AbstractParser.message("expected", "number", type.getNameOrType()));
-        default:
-            break;
-        }
-
-        throw error(AbstractParser.message("expected", "json literal", type.getNameOrType()));
-    }
-
-    /**
-     * Parse an array literal from the token stream
-     * @return the array literal as a Node
-     */
-    private LiteralNode<Expression[]> arrayLiteral() {
-        // Unlike JavaScript array literals, elison is not permitted in JSON.
-
-        // Capture LBRACKET token.
-        final long arrayToken = token;
-        // LBRACKET tested in caller.
-        next();
-
-        LiteralNode<Expression[]> result = null;
-        // Prepare to accummulating elements.
-        final List<Expression> elements = new ArrayList<>();
-
-loop:
-        while (true) {
-            switch (type) {
-            case RBRACKET:
-                next();
-                result = LiteralNode.newInstance(arrayToken, finish, elements);
-                break loop;
-
-            case COMMARIGHT:
-                next();
-                // check for trailing comma - not allowed in JSON
-                if (type == RBRACKET) {
-                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+            switch (c) {
+            case ',':
+                if (state != STATE_ELEMENT_PARSED) {
+                    throw error(AbstractParser.message("trailing.comma.in.json"), pos);
                 }
+                state = STATE_COMMA_PARSED;
+                pos++;
                 break;
-
+            case ']':
+                if (state == STATE_COMMA_PARSED) {
+                    throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+                }
+                pos++;
+                return global.wrapAsObject(arrayData);
             default:
-                // Add expression element.
-                elements.add(jsonLiteral());
-                // Comma between array elements is mandatory in JSON.
-                if (type != COMMARIGHT && type != RBRACKET) {
-                   throw error(AbstractParser.message("expected", ", or ]", type.getNameOrType()));
+                if (state == STATE_ELEMENT_PARSED) {
+                    throw expectedError(pos, ", or ]", toString(c));
                 }
+                final long index = arrayData.length();
+                arrayData = arrayData.ensure(index).set((int) index, parseLiteral(), true);
+                state = STATE_ELEMENT_PARSED;
                 break;
             }
         }
 
-        return result;
+        throw expectedError(pos, ", or ]", "eof");
     }
 
-    /**
-     * Parse an object literal from the token stream
-     * @return the object literal as a Node
-     */
-    private ObjectNode objectLiteral() {
-        // Capture LBRACE token.
-        final long objectToken = token;
-        // LBRACE tested in caller.
-        next();
+    private String parseString() {
+        // String buffer is only instantiated if string contains escape sequences.
+        int start = ++pos;
+        StringBuilder sb = null;
 
-        // Prepare to accumulate elements.
-        final List<PropertyNode> elements = new ArrayList<>();
+        while (pos < length) {
+            final int c = next();
+            if (c <= 0x1f) {
+                // Characters < 0x1f are not allowed in JSON strings.
+                throw syntaxError(pos, "String contains control character");
 
-        // Create a block for the object literal.
-loop:
-        while (true) {
-            switch (type) {
-            case RBRACE:
-                next();
-                break loop;
+            } else if (c == '\\') {
+                if (sb == null) {
+                    sb = new StringBuilder(pos - start + 16);
+                }
+                sb.append(source, start, pos - 1);
+                sb.append(parseEscapeSequence());
+                start = pos;
 
-            case COMMARIGHT:
-                next();
-                // check for trailing comma - not allowed in JSON
-                if (type == RBRACE) {
-                    throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+            } else if (c == '"') {
+                if (sb != null) {
+                    sb.append(source, start, pos - 1);
+                    return sb.toString();
                 }
-                break;
-
-            default:
-                // Get and add the next property.
-                final PropertyNode property = propertyAssignment();
-                elements.add(property);
-
-                // Comma between property assigments is mandatory in JSON.
-                if (type != RBRACE && type != COMMARIGHT) {
-                    throw error(AbstractParser.message("expected", ", or }", type.getNameOrType()));
-                }
-                break;
+                return source.substring(start, pos - 1);
             }
         }
 
-        // Construct new object literal.
-        return new ObjectNode(objectToken, finish, elements);
+        throw error(Lexer.message("missing.close.quote"), pos, length);
+    }
+
+    private char parseEscapeSequence() {
+        final int c = next();
+        switch (c) {
+        case '"':
+            return '"';
+        case '\\':
+            return '\\';
+        case '/':
+            return '/';
+        case 'b':
+            return '\b';
+        case 'f':
+            return '\f';
+        case 'n':
+            return '\n';
+        case 'r':
+            return '\r';
+        case 't':
+            return '\t';
+        case 'u':
+            return parseUnicodeEscape();
+        default:
+            throw error(Lexer.message("invalid.escape.char"), pos - 1, length);
+        }
+    }
+
+    private char parseUnicodeEscape() {
+        return (char) (parseHexDigit() << 12 | parseHexDigit() << 8 | parseHexDigit() << 4 | parseHexDigit());
+    }
+
+    private int parseHexDigit() {
+        final int c = next();
+        if (c >= '0' && c <= '9') {
+            return c - '0';
+        } else if (c >= 'A' && c <= 'F') {
+            return c + 10 - 'A';
+        } else if (c >= 'a' && c <= 'f') {
+            return c + 10 - 'a';
+        }
+        throw error(Lexer.message("invalid.hex"), pos - 1, length);
+    }
+
+    private boolean isDigit(final int c) {
+        return c >= '0' && c <= '9';
+    }
+
+    private void skipDigits() {
+        while (pos < length) {
+            final int c = peek();
+            if (!isDigit(c)) {
+                break;
+            }
+            pos++;
+        }
     }
 
-    /**
-     * Parse a property assignment from the token stream
-     * @return the property assignment as a Node
-     */
-    private PropertyNode propertyAssignment() {
-        // Capture firstToken.
-        final long propertyToken = token;
-        LiteralNode<?> name = null;
+    private Number parseNumber() {
+        final int start = pos;
+        int c = next();
+
+        if (c == '-') {
+            c = next();
+        }
+        if (!isDigit(c)) {
+            throw numberError(start);
+        }
+        // no more digits allowed after 0
+        if (c != '0') {
+            skipDigits();
+        }
 
-        if (type == STRING) {
-            name = getStringLiteral();
-        } else if (type == ESCSTRING) {
-            name = getLiteral();
+        // fraction
+        if (peek() == '.') {
+            pos++;
+            if (!isDigit(next())) {
+                throw numberError(pos - 1);
+            }
+            skipDigits();
+        }
+
+        // exponent
+        c = peek();
+        if (c == 'e' || c == 'E') {
+            pos++;
+            c = next();
+            if (c == '-' || c == '+') {
+                c = next();
+            }
+            if (!isDigit(c)) {
+                throw numberError(pos - 1);
+            }
+            skipDigits();
         }
 
-        if (name != null) {
-            expect(COLON);
-            final Expression value = jsonLiteral();
-            return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
+        final double d = Double.parseDouble(source.substring(start, pos));
+        if (JSType.isRepresentableAsInt(d)) {
+            return (int) d;
+        } else if (JSType.isRepresentableAsLong(d)) {
+            return (long) d;
+        }
+        return d;
+    }
+
+    private Object parseKeyword(final String keyword, final Object value) {
+        if (!source.regionMatches(pos, keyword, 0, keyword.length())) {
+            throw expectedError(pos, "json literal", "ident");
         }
+        pos += keyword.length();
+        return value;
+    }
 
-        // Raise an error.
-        throw error(AbstractParser.message("expected", "string", type.getNameOrType()));
+    private int peek() {
+        if (pos >= length) {
+            return -1;
+        }
+        return source.charAt(pos);
+    }
+
+    private int next() {
+        final int next = peek();
+        pos++;
+        return next;
     }
 
+    private void skipWhiteSpace() {
+        while (pos < length) {
+            switch (peek()) {
+            case '\t':
+            case '\r':
+            case '\n':
+            case ' ':
+                pos++;
+                break;
+            default:
+                return;
+            }
+        }
+    }
+
+    private static String toString(final int c) {
+        return c == EOF ? "eof" : String.valueOf((char) c);
+    }
+
+    ParserException error(final String message, final int start, final int length) throws ParserException {
+        final long token     = Token.toDesc(STRING, start, length);
+        final int  pos       = Token.descPosition(token);
+        final Source src     = Source.sourceFor("<json>", source);
+        final int  lineNum   = src.getLine(pos);
+        final int  columnNum = src.getColumn(pos);
+        final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
+        return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
+    }
+
+    private ParserException error(final String message, final int start) {
+        return error(message, start, length);
+    }
+
+    private ParserException numberError(final int start) {
+        return error(Lexer.message("json.invalid.number"), start);
+    }
+
+    private ParserException expectedError(final int start, final String expected, final String found) {
+        return error(AbstractParser.message("expected", expected, found), start);
+    }
+
+    private ParserException syntaxError(final int start, final String reason) {
+        final String message = ECMAErrors.getMessage("syntax.error.invalid.json", reason);
+        return error(message, start);
+    }
 }
--- a/src/jdk/nashorn/internal/parser/Lexer.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/parser/Lexer.java	Fri Nov 13 15:38:44 2015 -0800
@@ -93,9 +93,6 @@
     private static final String SPACETAB = " \t";  // ASCII space and tab
     private static final String LFCR     = "\n\r"; // line feed and carriage return (ctrl-m)
 
-    private static final String JSON_WHITESPACE_EOL = LFCR;
-    private static final String JSON_WHITESPACE     = SPACETAB + LFCR;
-
     private static final String JAVASCRIPT_WHITESPACE_EOL =
         LFCR +
         "\u2028" + // line separator
@@ -385,24 +382,6 @@
     }
 
     /**
-     * Test whether a char is valid JSON whitespace
-     * @param ch a char
-     * @return true if valid JSON whitespace
-     */
-    public static boolean isJsonWhitespace(final char ch) {
-        return JSON_WHITESPACE.indexOf(ch) != -1;
-    }
-
-    /**
-     * Test whether a char is valid JSON end of line
-     * @param ch a char
-     * @return true if valid JSON end of line
-     */
-    public static boolean isJsonEOL(final char ch) {
-        return JSON_WHITESPACE_EOL.indexOf(ch) != -1;
-    }
-
-    /**
      * Test if char is a string delimiter, e.g. '\' or '"'.  Also scans exec
      * strings ('`') in scripting mode.
      * @param ch a char
--- a/src/jdk/nashorn/internal/parser/Parser.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/parser/Parser.java	Fri Nov 13 15:38:44 2015 -0800
@@ -607,7 +607,7 @@
      * @return whether the ident can be used as L-value
      */
     private static boolean checkIdentLValue(final IdentNode ident) {
-        return Token.descType(ident.getToken()).getKind() != TokenKind.KEYWORD;
+        return ident.tokenType().getKind() != TokenKind.KEYWORD;
     }
 
     /**
@@ -2635,8 +2635,12 @@
             name = getIdent();
             verifyStrictIdent(name, "function name");
         } else if (isStatement) {
-            // Nashorn extension: anonymous function statements
-            if (env._no_syntax_extensions) {
+            // Nashorn extension: anonymous function statements.
+            // Do not allow anonymous function statement if extensions
+            // are now allowed. But if we are reparsing then anon function
+            // statement is possible - because it was used as function
+            // expression in surrounding code.
+            if (env._no_syntax_extensions && reparsedFunction == null) {
                 expect(IDENT);
             }
         }
--- a/src/jdk/nashorn/internal/parser/TokenType.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/parser/TokenType.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -222,9 +222,11 @@
 
     /**
      * Determines if the token has greater precedence than other.
+     *
      * @param other  Compare token.
      * @param isLeft Is to the left of the other.
-     * @return True if greater precedence.
+     *
+     * @return {@code true} if greater precedence.
      */
     public boolean needsParens(final TokenType other, final boolean isLeft) {
         return other.precedence != 0 &&
@@ -234,16 +236,16 @@
 
     /**
      * Determines if the type is a valid operator.
-     * @param noIn TRUE if IN operator should be ignored.
-     * @return TRUE if valid operator.
+     *
+     * @param noIn {@code true} if IN operator should be ignored.
+     *
+     * @return {@code true} if valid operator.
      */
     public boolean isOperator(final boolean noIn) {
         return kind == BINARY && (!noIn || this != IN) && precedence != 0;
     }
 
-    /**
-     * Accessors.
-     */
+
     public int getLength() {
         assert name != null : "Token name not set";
         return name.length();
--- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.runtime;
 
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_FIELD_TYPE;
 import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createGetter;
 import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createSetter;
@@ -98,7 +97,7 @@
                 objectSetters[i] = MH.asType(MH.setter(LOOKUP, structure, fieldName, typeClass), Lookup.SET_OBJECT_TYPE);
             }
 
-            if (!OBJECT_FIELDS_ONLY) {
+            if (!StructureLoader.isSingleFieldStructure(structure.getName())) {
                 for (int i = 0; i < fieldCount; i++) {
                     final String fieldNamePrimitive = getFieldName(i, PRIMITIVE_FIELD_TYPE);
                     final Class<?> typeClass = PRIMITIVE_FIELD_TYPE.getTypeClass();
@@ -211,7 +210,7 @@
      * @param setter the property setter or null if non writable, non configurable
      */
     private AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
-        super(key, flags | IS_BUILTIN | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot);
+        super(key, flags | IS_BUILTIN | DUAL_FIELDS | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot);
         assert !isSpill();
 
         // we don't need to prep the setters these will never be invalidated as this is a nasgen
@@ -221,18 +220,15 @@
         final Class<?> setterType = setter == null ? null : setter.type().parameterType(1);
 
         assert setterType == null || setterType == getterType;
-        if (OBJECT_FIELDS_ONLY) {
-            primitiveGetter = primitiveSetter = null;
+
+        if (getterType == int.class || getterType == long.class) {
+            primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE);
+            primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE);
+        } else if (getterType == double.class) {
+            primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE);
+            primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE);
         } else {
-            if (getterType == int.class || getterType == long.class) {
-                primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE);
-                primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE);
-            } else if (getterType == double.class) {
-                primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE);
-                primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE);
-            } else {
-                primitiveGetter = primitiveSetter = null;
-            }
+            primitiveGetter = primitiveSetter = null;
         }
 
         assert primitiveGetter == null || primitiveGetter.type() == Lookup.GET_PRIMITIVE_TYPE : primitiveGetter + "!=" + Lookup.GET_PRIMITIVE_TYPE;
@@ -241,7 +237,7 @@
         objectGetter  = getter.type() != Lookup.GET_OBJECT_TYPE ? MH.asType(getter, Lookup.GET_OBJECT_TYPE) : getter;
         objectSetter  = setter != null && setter.type() != Lookup.SET_OBJECT_TYPE ? MH.asType(setter, Lookup.SET_OBJECT_TYPE) : setter;
 
-        setType(OBJECT_FIELDS_ONLY ? Object.class : getterType);
+        setType(getterType);
     }
 
     /**
@@ -282,6 +278,9 @@
             objectSetter    = gs.objectSetters[slot];
             primitiveSetter = gs.primitiveSetters[slot];
         }
+
+        // Always use dual fields except for single field structures
+        assert hasDualFields() != StructureLoader.isSingleFieldStructure(structure.getName());
     }
 
     /**
@@ -310,7 +309,7 @@
      */
     public AccessorProperty(final String key, final int flags, final Class<?> structure, final int slot, final Class<?> initialType) {
         this(key, flags, structure, slot);
-        setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+        setType(hasDualFields() ? initialType : Object.class);
     }
 
     /**
@@ -347,7 +346,7 @@
      * @param initialValue initial value
      */
     protected final void setInitialValue(final ScriptObject owner, final Object initialValue) {
-        setType(JSType.unboxedFieldType(initialValue));
+        setType(hasDualFields() ? JSType.unboxedFieldType(initialValue) : Object.class);
         if (initialValue instanceof Integer) {
             invokeSetter(owner, ((Integer)initialValue).intValue());
         } else if (initialValue instanceof Long) {
@@ -363,7 +362,7 @@
      * Initialize the type of a property
      */
     protected final void initializeType() {
-        setType(OBJECT_FIELDS_ONLY ? Object.class : null);
+        setType(!hasDualFields() ? Object.class : null);
     }
 
     private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
@@ -670,7 +669,7 @@
 
     @Override
     public final boolean canChangeType() {
-        if (OBJECT_FIELDS_ONLY) {
+        if (!hasDualFields()) {
             return false;
         }
         // Return true for currently undefined even if non-writable/configurable to allow initialization of ES6 CONST.
--- a/src/jdk/nashorn/internal/runtime/AllocationStrategy.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/AllocationStrategy.java	Fri Nov 13 15:38:44 2015 -0800
@@ -29,55 +29,57 @@
 import java.io.Serializable;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
+import jdk.nashorn.internal.codegen.Compiler;
 import jdk.nashorn.internal.codegen.CompilerConstants;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator.AllocatorDescriptor;
+import jdk.nashorn.internal.codegen.ObjectClassGenerator;
 
 /**
- * Encapsulates the allocation strategy for a function when used as a constructor. Basically the same as
- * {@link AllocatorDescriptor}, but with an additionally cached resolved method handle. There is also a
- * canonical default allocation strategy for functions that don't assign any "this" properties (vast majority
- * of all functions), therefore saving some storage space in {@link RecompilableScriptFunctionData} that would
- * otherwise be lost to identical tuples of (map, className, handle) fields.
+ * Encapsulates the allocation strategy for a function when used as a constructor.
  */
-final class AllocationStrategy implements Serializable {
+final public class AllocationStrategy implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
 
-    private static final AllocationStrategy DEFAULT_STRATEGY = new AllocationStrategy(new AllocatorDescriptor(0));
+    /** Number of fields in the allocated object */
+    private final int fieldCount;
 
-    /** Allocator map from allocator descriptor */
-    private final PropertyMap allocatorMap;
+    /** Whether to use dual field representation */
+    private final boolean dualFields;
 
     /** Name of class where allocator function resides */
-    private final String allocatorClassName;
+    private transient String allocatorClassName;
 
     /** lazily generated allocator */
     private transient MethodHandle allocator;
 
-    private AllocationStrategy(final AllocatorDescriptor desc) {
-        this.allocatorMap = desc.getAllocatorMap();
-        // These classes get loaded, so an interned variant of their name is most likely around anyway.
-        this.allocatorClassName = desc.getAllocatorClassName().intern();
+    /**
+     * Construct an allocation strategy with the given map and class name.
+     * @param fieldCount number of fields in the allocated object
+     * @param dualFields whether to use dual field representation
+     */
+    public AllocationStrategy(final int fieldCount, final boolean dualFields) {
+        this.fieldCount = fieldCount;
+        this.dualFields = dualFields;
     }
 
-    private boolean matches(final AllocatorDescriptor desc) {
-        return desc.getAllocatorMap().size() == allocatorMap.size() &&
-                desc.getAllocatorClassName().equals(allocatorClassName);
-    }
-
-    static AllocationStrategy get(final AllocatorDescriptor desc) {
-        return DEFAULT_STRATEGY.matches(desc) ? DEFAULT_STRATEGY : new AllocationStrategy(desc);
+    private String getAllocatorClassName() {
+        if (allocatorClassName == null) {
+            // These classes get loaded, so an interned variant of their name is most likely around anyway.
+            allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
+        }
+        return allocatorClassName;
     }
 
     PropertyMap getAllocatorMap() {
-        return allocatorMap;
+        // Create a new map for each function instance
+        return PropertyMap.newMap(null, getAllocatorClassName(), 0, fieldCount, 0);
     }
 
     ScriptObject allocate(final PropertyMap map) {
         try {
             if (allocator == null) {
-                allocator = MH.findStatic(LOOKUP, Context.forStructureClass(allocatorClassName),
+                allocator = MH.findStatic(LOOKUP, Context.forStructureClass(getAllocatorClassName()),
                         CompilerConstants.ALLOCATE.symbolName(), MH.type(ScriptObject.class, PropertyMap.class));
             }
             return (ScriptObject)allocator.invokeExact(map);
@@ -88,17 +90,8 @@
         }
     }
 
-    private Object readResolve() {
-        if(allocatorMap.size() == DEFAULT_STRATEGY.allocatorMap.size() &&
-                allocatorClassName.equals(DEFAULT_STRATEGY.allocatorClassName)) {
-            return DEFAULT_STRATEGY;
-        }
-        return this;
-    }
-
     @Override
     public String toString() {
-        return "AllocationStrategy[allocatorClassName=" + allocatorClassName + ", allocatorMap.size=" +
-                allocatorMap.size() + "]";
+        return "AllocationStrategy[fieldCount=" + fieldCount + "]";
     }
 }
--- a/src/jdk/nashorn/internal/runtime/CodeInstaller.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/CodeInstaller.java	Fri Nov 13 15:38:44 2015 -0800
@@ -86,7 +86,7 @@
      * @param source the script source
      * @param mainClassName the main class name
      * @param classBytes map of class names to class bytes
-     * @param initializers compilation id -> FunctionInitializer map
+     * @param initializers compilation id -&gt; FunctionInitializer map
      * @param constants constants array
      * @param compilationId compilation id
      */
--- a/src/jdk/nashorn/internal/runtime/CodeStore.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/CodeStore.java	Fri Nov 13 15:38:44 2015 -0800
@@ -189,7 +189,7 @@
      * @param paramTypes parameter types
      * @return a string representing the function
      */
-    public static String getCacheKey(final int functionId, final Type[] paramTypes) {
+    public static String getCacheKey(final Object functionId, final Type[] paramTypes) {
         final StringBuilder b = new StringBuilder().append(functionId);
         if(paramTypes != null && paramTypes.length > 0) {
             b.append('-');
@@ -275,7 +275,7 @@
 
         @Override
         public StoredScript load(final Source source, final String functionKey) {
-            if (source.getLength() < minSize) {
+            if (belowThreshold(source)) {
                 return null;
             }
 
--- a/src/jdk/nashorn/internal/runtime/CompiledFunction.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/CompiledFunction.java	Fri Nov 13 15:38:44 2015 -0800
@@ -528,8 +528,9 @@
 
         final int fnParamCountNoCallee = fnParamCount - thisThisIndex;
         final int minParams = Math.min(csParamCount - 1, fnParamCountNoCallee); // callSiteType always has callee, so subtract 1
-        // We must match all incoming parameters, except "this". Starting from 1 to skip "this".
-        for(int i = 1; i < minParams; ++i) {
+        // We must match all incoming parameters, including "this". "this" will usually be Object, but there
+        // are exceptions, e.g. when calling functions with primitive "this" in strict mode or through call/apply.
+        for(int i = 0; i < minParams; ++i) {
             final Type fnType = Type.typeFor(type.parameterType(i + thisThisIndex));
             final Type csType = csIsVarArg ? Type.OBJECT : Type.typeFor(other.parameterType(i + 1));
             if(!fnType.isEquivalentTo(csType)) {
--- a/src/jdk/nashorn/internal/runtime/ConsString.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ConsString.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,6 +25,8 @@
 
 package jdk.nashorn.internal.runtime;
 
+import static jdk.nashorn.internal.runtime.JSType.isString;
+
 import java.util.ArrayDeque;
 import java.util.Deque;
 
@@ -52,8 +54,8 @@
      * @param right right char sequence
      */
     public ConsString(final CharSequence left, final CharSequence right) {
-        assert left instanceof String || left instanceof ConsString;
-        assert right instanceof String || right instanceof ConsString;
+        assert isString(left);
+        assert isString(right);
         this.left = left;
         this.right = right;
         length = left.length() + right.length();
--- a/src/jdk/nashorn/internal/runtime/Context.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/Context.java	Fri Nov 13 15:38:44 2015 -0800
@@ -60,11 +60,13 @@
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import java.util.logging.Level;
+import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.util.CheckClassAdapter;
@@ -130,6 +132,23 @@
     private static MethodType CREATE_PROGRAM_FUNCTION_TYPE = MethodType.methodType(ScriptFunction.class, ScriptObject.class);
 
     /**
+     * Should scripts use only object slots for fields, or dual long/object slots? The default
+     * behaviour is to couple this to optimistic types, using dual representation if optimistic types are enabled
+     * and single field representation otherwise. This can be overridden by setting either the "nashorn.fields.objects"
+     * or "nashorn.fields.dual" system property.
+     */
+    private final FieldMode fieldMode;
+
+    private static enum FieldMode {
+        /** Value for automatic field representation depending on optimistic types setting */
+        AUTO,
+        /** Value for object field representation regardless of optimistic types setting */
+        OBJECTS,
+        /** Value for dual primitive/object field representation regardless of optimistic types setting */
+        DUAL
+    }
+
+    /**
      * Keeps track of which builtin prototypes and properties have been relinked
      * Currently we are conservative and associate the name of a builtin class with all
      * its properties, so it's enough to invalidate a property to break all assumptions
@@ -433,7 +452,7 @@
      * @param appLoader application class loader
      */
     public Context(final Options options, final ErrorManager errors, final ClassLoader appLoader) {
-        this(options, errors, appLoader, (ClassFilter)null);
+        this(options, errors, appLoader, null);
     }
 
     /**
@@ -521,6 +540,14 @@
             getErr().println("nashorn full version " + Version.fullVersion());
         }
 
+        if (Options.getBooleanProperty("nashorn.fields.dual")) {
+            fieldMode = FieldMode.DUAL;
+        } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
+            fieldMode = FieldMode.OBJECTS;
+        } else {
+            fieldMode = FieldMode.AUTO;
+        }
+
         initLoggers();
     }
 
@@ -575,6 +602,14 @@
     }
 
     /**
+     * Should scripts compiled by this context use dual field representation?
+     * @return true if using dual fields, false for object-only fields
+     */
+    public boolean useDualFields() {
+        return fieldMode == FieldMode.DUAL || (fieldMode == FieldMode.AUTO && env._optimistic_types);
+    }
+
+    /**
      * Get the PropertyMap of the current global scope
      * @return the property map of the current global scope
      */
@@ -633,12 +668,11 @@
      * @param string       Evaluated code as a String
      * @param callThis     "this" to be passed to the evaluated code
      * @param location     location of the eval call
-     * @param strict       is this {@code eval} call from a strict mode code?
      * @return the return value of the {@code eval}
      */
     public Object eval(final ScriptObject initialScope, final String string,
-            final Object callThis, final Object location, final boolean strict) {
-        return eval(initialScope, string, callThis, location, strict, false);
+            final Object callThis, final Object location) {
+        return eval(initialScope, string, callThis, location, false, false);
     }
 
     /**
@@ -657,14 +691,16 @@
             final Object callThis, final Object location, final boolean strict, final boolean evalCall) {
         final String  file       = location == UNDEFINED || location == null ? "<eval>" : location.toString();
         final Source  source     = sourceFor(file, string, evalCall);
-        final boolean directEval = location != UNDEFINED; // is this direct 'eval' call or indirectly invoked eval?
+        // is this direct 'eval' builtin call?
+        final boolean directEval = evalCall && (location != UNDEFINED);
         final Global  global = Context.getGlobal();
         ScriptObject scope = initialScope;
 
         // ECMA section 10.1.1 point 2 says eval code is strict if it begins
         // with "use strict" directive or eval direct call itself is made
         // from from strict mode code. We are passed with caller's strict mode.
-        boolean strictFlag = directEval && strict;
+        // Nashorn extension: any 'eval' is unconditionally strict when -strict is specified.
+        boolean strictFlag = strict || this._strict;
 
         Class<?> clazz = null;
         try {
@@ -688,29 +724,26 @@
         // In strict mode, eval does not instantiate variables and functions
         // in the caller's environment. A new environment is created!
         if (strictFlag) {
-            // Create a new scope object
-            final ScriptObject strictEvalScope = global.newObject();
-
-            // bless it as a "scope"
-            strictEvalScope.setIsScope();
-
-            // set given scope to be it's proto so that eval can still
-            // access caller environment vars in the new environment.
-            strictEvalScope.setProto(scope);
-            scope = strictEvalScope;
+            // Create a new scope object with given scope as its prototype
+            scope = newScope(scope);
         }
 
         final ScriptFunction func = getProgramFunction(clazz, scope);
         Object evalThis;
         if (directEval) {
-            evalThis = callThis instanceof ScriptObject || strictFlag ? callThis : global;
+            evalThis = (callThis != UNDEFINED && callThis != null) || strictFlag ? callThis : global;
         } else {
-            evalThis = global;
+            // either indirect evalCall or non-eval (Function, engine.eval, ScriptObjectMirror.eval..)
+            evalThis = callThis;
         }
 
         return ScriptRuntime.apply(func, evalThis);
     }
 
+    private static ScriptObject newScope(final ScriptObject callerScope) {
+        return new Scope(callerScope, PropertyMap.newMap(Scope.class));
+    }
+
     private static Source loadInternal(final String srcStr, final String prefix, final String resourcePath) {
         if (srcStr.startsWith(prefix)) {
             final String resource = resourcePath + srcStr.substring(prefix.length());
@@ -744,7 +777,7 @@
      *
      * @throws IOException if source cannot be found or loaded
      */
-    public Object load(final ScriptObject scope, final Object from) throws IOException {
+    public Object load(final Object scope, final Object from) throws IOException {
         final Object src = from instanceof ConsString ? from.toString() : from;
         Source source = null;
 
@@ -796,7 +829,42 @@
         }
 
         if (source != null) {
-            return evaluateSource(source, scope, scope);
+            if (scope instanceof ScriptObject && ((ScriptObject)scope).isScope()) {
+                final ScriptObject sobj = (ScriptObject)scope;
+                // passed object is a script object
+                // Global is the only user accessible scope ScriptObject
+                assert sobj.isGlobal() : "non-Global scope object!!";
+                return evaluateSource(source, sobj, sobj);
+            } else if (scope == null || scope == UNDEFINED) {
+                // undefined or null scope. Use current global instance.
+                final Global global = getGlobal();
+                return evaluateSource(source, global, global);
+            } else {
+                /*
+                 * Arbitrary object passed for scope.
+                 * Indirect load that is equivalent to:
+                 *
+                 *    (function(scope, source) {
+                 *        with (scope) {
+                 *            eval(<script_from_source>);
+                 *        }
+                 *    })(scope, source);
+                 */
+                final Global global = getGlobal();
+                // Create a new object. This is where all declarations
+                // (var, function) from the evaluated code go.
+                // make global to be its __proto__ so that global
+                // definitions are accessible to the evaluated code.
+                final ScriptObject evalScope = newScope(global);
+
+                // finally, make a WithObject around user supplied scope object
+                // so that it's properties are accessible as variables.
+                final ScriptObject withObj = ScriptRuntime.openWith(evalScope, scope);
+
+                // evaluate given source with 'withObj' as scope
+                // but use global object as "this".
+                return evaluateSource(source, withObj, global);
+            }
         }
 
         throw typeError("cant.load.script", ScriptRuntime.safeToString(from));
@@ -904,7 +972,7 @@
      * @throw SecurityException if not accessible
      */
     private static void checkPackageAccess(final SecurityManager sm, final String fullName) {
-        sm.getClass(); // null check
+        Objects.requireNonNull(sm);
         final int index = fullName.lastIndexOf('.');
         if (index != -1) {
             final String pkgName = fullName.substring(0, index);
@@ -1061,16 +1129,17 @@
      *
      * @param global the global
      * @param engine the associated ScriptEngine instance, can be null
+     * @param ctxt the initial ScriptContext, can be null
      * @return the initialized global scope object.
      */
-    public Global initGlobal(final Global global, final ScriptEngine engine) {
+    public Global initGlobal(final Global global, final ScriptEngine engine, final ScriptContext ctxt) {
         // Need only minimal global object, if we are just compiling.
         if (!env._compile_only) {
             final Global oldGlobal = Context.getGlobal();
             try {
                 Context.setGlobal(global);
                 // initialize global scope with builtin global objects
-                global.initBuiltinObjects(engine);
+                global.initBuiltinObjects(engine, ctxt);
             } finally {
                 Context.setGlobal(oldGlobal);
             }
@@ -1086,7 +1155,7 @@
      * @return the initialized global scope object.
      */
     public Global initGlobal(final Global global) {
-        return initGlobal(global, null);
+        return initGlobal(global, null, null);
     }
 
     /**
@@ -1194,16 +1263,21 @@
 
         StoredScript storedScript = null;
         FunctionNode functionNode = null;
-        // We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation
-        // just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData.
-        final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types;
-        final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
+        // Don't use code store if optimistic types is enabled but lazy compilation is not.
+        // This would store a full script compilation with many wrong optimistic assumptions that would
+        // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
+        final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
+        final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;
 
         if (useCodeStore) {
             storedScript = codeStore.load(source, cacheKey);
         }
 
         if (storedScript == null) {
+            if (env._dest_dir != null) {
+                source.dump(env._dest_dir);
+            }
+
             functionNode = new Parser(env, source, errMan, strict, getLogger(Parser.class)).parse();
 
             if (errMan.hasErrors()) {
@@ -1247,7 +1321,7 @@
             compiler.persistClassInfo(cacheKey, compiledFunction);
         } else {
             Compiler.updateCompilationId(storedScript.getCompilationId());
-            script = install(storedScript, source, installer);
+            script = storedScript.installScript(source, installer);
         }
 
         cacheClass(source, script);
@@ -1269,51 +1343,6 @@
     }
 
     /**
-     * Install a previously compiled class from the code cache.
-     *
-     * @param storedScript cached script containing class bytes and constants
-     * @return main script class
-     */
-    private static Class<?> install(final StoredScript storedScript, final Source source, final CodeInstaller<ScriptEnvironment> installer) {
-
-        final Map<String, Class<?>> installedClasses = new HashMap<>();
-        final Map<String, byte[]>   classBytes       = storedScript.getClassBytes();
-        final Object[] constants       = storedScript.getConstants();
-        final String   mainClassName   = storedScript.getMainClassName();
-        final byte[]   mainClassBytes  = classBytes.get(mainClassName);
-        final Class<?> mainClass       = installer.install(mainClassName, mainClassBytes);
-        final Map<Integer, FunctionInitializer> initializers = storedScript.getInitializers();
-
-        installedClasses.put(mainClassName, mainClass);
-
-        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
-            final String className = entry.getKey();
-            if (className.equals(mainClassName)) {
-                continue;
-            }
-            final byte[] code = entry.getValue();
-
-            installedClasses.put(className, installer.install(className, code));
-        }
-
-        installer.initialize(installedClasses.values(), source, constants);
-
-        for (final Object constant : constants) {
-            if (constant instanceof RecompilableScriptFunctionData) {
-                final RecompilableScriptFunctionData data = (RecompilableScriptFunctionData) constant;
-                data.initTransients(source, installer);
-                final FunctionInitializer initializer = initializers.get(data.getFunctionNodeId());
-                if (initializer != null) {
-                    initializer.setCode(installedClasses.get(initializer.getClassName()));
-                    data.initializeCode(initializer);
-                }
-            }
-        }
-
-        return mainClass;
-    }
-
-    /**
      * Cache for compiled script classes.
      */
     @SuppressWarnings("serial")
--- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Fri Nov 13 15:38:44 2015 -0800
@@ -3,18 +3,18 @@
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General  License version 2 only, as
+ * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Oracle in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General  License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
- * You should have received a copy of the GNU General  License version
+ * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
@@ -156,7 +156,7 @@
         final Context context = global.getContext();
 
         try {
-            return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED, false);
+            return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED);
         } catch (final Throwable ex) {
             return returnException ? ex : null;
         }
--- a/src/jdk/nashorn/internal/runtime/ErrorManager.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ErrorManager.java	Fri Nov 13 15:38:44 2015 -0800
@@ -113,7 +113,7 @@
 
         // Pointer to column.
         for (int i = 0; i < column; i++) {
-            if (sourceLine.charAt(i) == '\t') {
+            if (i < sourceLine.length() && sourceLine.charAt(i) == '\t') {
                 sb.append('\t');
             } else {
                 sb.append(' ');
--- a/src/jdk/nashorn/internal/runtime/FunctionInitializer.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/FunctionInitializer.java	Fri Nov 13 15:38:44 2015 -0800
@@ -60,17 +60,6 @@
     }
 
     /**
-     * Copy constructor.
-     *
-     * @param init original initializer
-     */
-    FunctionInitializer(final FunctionInitializer init) {
-        this.className = init.getClassName();
-        this.methodType = init.getMethodType();
-        this.flags = init.getFlags();
-    }
-
-    /**
      * Constructor.
      *
      * @param functionNode the function node
@@ -130,7 +119,7 @@
      * Set the class implementing the function
      * @param code the class
      */
-    public void setCode(final Class<?> code) {
+    void setCode(final Class<?> code) {
         // Make sure code has not been set and has expected class name
         if (this.code != null) {
             throw new IllegalStateException("code already set");
--- a/src/jdk/nashorn/internal/runtime/FunctionScope.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/FunctionScope.java	Fri Nov 13 15:38:44 2015 -0800
@@ -35,17 +35,12 @@
  *
  * The constructor of this class is responsible for any function prologue
  * involving the scope.
- *
- * TODO see NASHORN-715.
  */
-public class FunctionScope extends ScriptObject implements Scope {
+public class FunctionScope extends Scope {
 
     /** Area to store scope arguments. (public for access from scripts.) */
     public final ScriptObject arguments;
 
-    /** Flag to indicate that a split method issued a return statement */
-    private int splitState = -1;
-
     /**
      * Constructor
      *
@@ -56,7 +51,6 @@
     public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final ScriptObject arguments) {
         super(callerScope, map);
         this.arguments = arguments;
-        setIsScope();
     }
 
     /**
@@ -68,7 +62,6 @@
     public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
         super(callerScope, map);
         this.arguments = null;
-        setIsScope();
     }
 
     /**
@@ -82,23 +75,4 @@
         super(map, primitiveSpill, objectSpill);
         this.arguments = null;
     }
-
-
-    /**
-     * Get the current split state.
-     * @return current split state
-     */
-    @Override
-    public int getSplitState() {
-        return splitState;
-    }
-
-    /**
-     * Set the current split state.
-     * @param state current split state
-     */
-    @Override
-    public void setSplitState(final int state) {
-        splitState = state;
-    }
 }
--- a/src/jdk/nashorn/internal/runtime/JSONFunctions.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/JSONFunctions.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,19 +25,11 @@
 
 package jdk.nashorn.internal.runtime;
 
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-
 import java.lang.invoke.MethodHandle;
 import java.util.Iterator;
 import java.util.concurrent.Callable;
-import jdk.nashorn.internal.ir.LiteralNode;
-import jdk.nashorn.internal.ir.Node;
-import jdk.nashorn.internal.ir.ObjectNode;
-import jdk.nashorn.internal.ir.PropertyNode;
-import jdk.nashorn.internal.ir.UnaryNode;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.parser.JSONParser;
-import jdk.nashorn.internal.parser.TokenType;
 import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
 
@@ -78,20 +70,19 @@
      * @return Object representation of JSON text given
      */
     public static Object parse(final Object text, final Object reviver) {
-        final String     str     = JSType.toString(text);
-        final JSONParser parser  = new JSONParser(sourceFor("<json>", str), new Context.ThrowErrorManager());
-
-        Node node;
+        final String     str    = JSType.toString(text);
+        final Global     global = Context.getGlobal();
+        final boolean    dualFields = ((ScriptObject) global).useDualFields();
+        final JSONParser parser = new JSONParser(str, global, dualFields);
+        final Object     value;
 
         try {
-            node = parser.parse();
+            value = parser.parse();
         } catch (final ParserException e) {
             throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage());
         }
 
-        final Global global = Context.getGlobal();
-        final Object unfiltered = convertNode(global, node);
-        return applyReviver(global, unfiltered, reviver);
+        return applyReviver(global, value, reviver);
     }
 
     // -- Internals only below this point
@@ -137,61 +128,6 @@
         }
     }
 
-    // Converts IR node to runtime value
-    private static Object convertNode(final Global global, final Node node) {
-        if (node instanceof LiteralNode) {
-            // check for array literal
-            if (node.tokenType() == TokenType.ARRAY) {
-                assert node instanceof LiteralNode.ArrayLiteralNode;
-                final Node[] elements = ((LiteralNode.ArrayLiteralNode)node).getValue();
-
-                // NOTE: We cannot use LiteralNode.isNumericArray() here as that
-                // method uses symbols of element nodes. Since we don't do lower
-                // pass, there won't be any symbols!
-                if (isNumericArray(elements)) {
-                    final double[] values = new double[elements.length];
-                    int   index = 0;
-
-                    for (final Node elem : elements) {
-                        values[index++] = JSType.toNumber(convertNode(global, elem));
-                    }
-                    return global.wrapAsObject(values);
-                }
-
-                final Object[] values = new Object[elements.length];
-                int   index = 0;
-
-                for (final Node elem : elements) {
-                    values[index++] = convertNode(global, elem);
-                }
-
-                return global.wrapAsObject(values);
-            }
-
-            return ((LiteralNode<?>)node).getValue();
-
-        } else if (node instanceof ObjectNode) {
-            final ObjectNode   objNode  = (ObjectNode) node;
-            final ScriptObject object   = global.newObject();
-
-            for (final PropertyNode pNode: objNode.getElements()) {
-                final Node         valueNode = pNode.getValue();
-
-                final String name = pNode.getKeyName();
-                final Object value = convertNode(global, valueNode);
-                setPropertyValue(object, name, value);
-            }
-
-            return object;
-        } else if (node instanceof UnaryNode) {
-            // UnaryNode used only to represent negative number JSON value
-            final UnaryNode unaryNode = (UnaryNode)node;
-            return -((LiteralNode<?>)unaryNode.getExpression()).getNumber();
-        } else {
-            return null;
-        }
-    }
-
     // add a new property if does not exist already, or else set old property
     private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value) {
         final int index = ArrayIndex.getArrayIndex(name);
@@ -207,14 +143,4 @@
         }
     }
 
-    // does the given IR node represent a numeric array?
-    private static boolean isNumericArray(final Node[] values) {
-        for (final Node node : values) {
-            if (node instanceof LiteralNode && ((LiteralNode<?>)node).getValue() instanceof Number) {
-                continue;
-            }
-            return false;
-        }
-        return true;
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/internal/runtime/JSONListAdapter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import jdk.nashorn.api.scripting.AbstractJSObject;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.objects.Global;
+
+/**
+ * A {@link ListAdapter} that also implements {@link JSObject}. Named {@code JSONListAdapter} as it is used as a
+ * {@code JSObject} implementing the {@link List} interface, which is the expected interface to be implemented by
+ * JSON-parsed arrays when they are handled in Java. We aren't implementing {@link JSObject} on {@link ListAdapter}
+ * directly since that'd have implications for other uses of list adapter (e.g. interferences of JSObject default
+ * value calculation vs. List's {@code toString()} etc.)
+ */
+public final class JSONListAdapter extends ListAdapter implements JSObject {
+    /**
+     * Creates a new JSON list adapter.
+     * @param obj the underlying object being exposed as a list.
+     * @param global the home global of the underlying object.
+     */
+    public JSONListAdapter(final JSObject obj, final Global global) {
+        super(obj, global);
+    }
+
+    /**
+     * Unwraps this adapter into its underlying non-JSObject representative.
+     * @param homeGlobal the home global for unwrapping
+     * @return either the unwrapped object or this if it should not be unwrapped in the specified global.
+     */
+    public Object unwrap(final Object homeGlobal) {
+        final Object unwrapped = ScriptObjectMirror.unwrap(obj, homeGlobal);
+        return unwrapped != obj ? unwrapped : this;
+    }
+
+    @Override
+    public Object call(final Object thiz, final Object... args) {
+        return obj.call(thiz, args);
+    }
+
+    @Override
+    public Object newObject(final Object... args) {
+        return obj.newObject(args);
+    }
+
+    @Override
+    public Object eval(final String s) {
+        return obj.eval(s);
+    }
+
+    @Override
+    public Object getMember(final String name) {
+        return obj.getMember(name);
+    }
+
+    @Override
+    public Object getSlot(final int index) {
+        return obj.getSlot(index);
+    }
+
+    @Override
+    public boolean hasMember(final String name) {
+        return obj.hasMember(name);
+    }
+
+    @Override
+    public boolean hasSlot(final int slot) {
+        return obj.hasSlot(slot);
+    }
+
+    @Override
+    public void removeMember(final String name) {
+        obj.removeMember(name);
+    }
+
+    @Override
+    public void setMember(final String name, final Object value) {
+        obj.setMember(name, value);
+    }
+
+    @Override
+    public void setSlot(final int index, final Object value) {
+        obj.setSlot(index, value);
+    }
+
+    @Override
+    public Set<String> keySet() {
+        return obj.keySet();
+    }
+
+    @Override
+    public Collection<Object> values() {
+        return obj.values();
+    }
+
+    @Override
+    public boolean isInstance(final Object instance) {
+        return obj.isInstance(instance);
+    }
+
+    @Override
+    public boolean isInstanceOf(final Object clazz) {
+        return obj.isInstanceOf(clazz);
+    }
+
+    @Override
+    public String getClassName() {
+        return obj.getClassName();
+    }
+
+    @Override
+    public boolean isFunction() {
+        return obj.isFunction();
+    }
+
+    @Override
+    public boolean isStrictFunction() {
+        return obj.isStrictFunction();
+    }
+
+    @Override
+    public boolean isArray() {
+        return obj.isArray();
+    }
+
+    @Override @Deprecated
+    public double toNumber() {
+        return obj.toNumber();
+    }
+
+    /**
+     * Implements this object's {@code [[DefaultValue]]} method by returning its wrapped object's {@code [[DefaultValue]]}.
+     *
+     * @param hint the type hint. Should be either {@code null}, {@code Number.class} or {@code String.class}.
+     * @return the wrapped object's default value.
+     * @throws UnsupportedOperationException if the conversion can't be performed. The engine will convert this
+     * exception into a JavaScript {@code TypeError}.
+     */
+    public Object getDefaultValue(final Class<?> hint) {
+        return AbstractJSObject.getDefaultValue(obj, hint);
+    }
+}
--- a/src/jdk/nashorn/internal/runtime/JSObjectListAdapter.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import jdk.nashorn.api.scripting.JSObject;
-
-/**
- * A ListAdapter that can wraps a JSObject.
- */
-public final class JSObjectListAdapter extends ListAdapter {
-    /**
-     * Creates a new list wrapper for the specified JSObject.
-     * @param obj JSOcript the object to wrap
-     */
-    public JSObjectListAdapter(final JSObject obj) {
-        super(obj);
-    }
-
-    @Override
-    public int size() {
-        return JSType.toInt32(((JSObject)obj).getMember("length"));
-    }
-
-    @Override
-    protected Object getAt(final int index) {
-        return ((JSObject)obj).getSlot(index);
-    }
-
-    @Override
-    protected void setAt(final int index, final Object element) {
-        ((JSObject)obj).setSlot(index, element);
-    }
-}
--- a/src/jdk/nashorn/internal/runtime/JSType.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/JSType.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,17 +26,17 @@
 package jdk.nashorn.internal.runtime;
 
 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Array;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Deque;
 import java.util.List;
 import jdk.internal.dynalink.beans.StaticClass;
+import jdk.nashorn.api.scripting.AbstractJSObject;
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.codegen.types.Type;
@@ -180,10 +180,10 @@
     /** Div exact wrapper for potentially integer division that turns into float point */
     public static final Call DIV_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", long.class, long.class, long.class, int.class);
 
-    /** Div zero wrapper for long division that handles (0/0) >>> 0 == 0 */
+    /** Div zero wrapper for long division that handles (0/0) &gt;&gt;&gt; 0 == 0 */
     public static final Call DIV_ZERO_LONG        = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", long.class, long.class, long.class);
 
-    /** Mod zero wrapper for long division that handles (0%0) >>> 0 == 0 */
+    /** Mod zero wrapper for long division that handles (0%0) &gt;&gt;&gt; 0 == 0 */
     public static final Call REM_ZERO_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", long.class, long.class, long.class);
 
     /** Mod exact wrapper for potentially integer remainders that turns into float point */
@@ -201,16 +201,9 @@
     /** Method handle to convert a JS Object to a Java array. */
     public static final Call TO_JAVA_ARRAY = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArray", Object.class, Object.class, Class.class);
 
-    /** Method handle to convert a JS Object to a Java List. */
-    public static final Call TO_JAVA_LIST = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaList", List.class, Object.class);
-
-    /** Method handle to convert a JS Object to a Java deque. */
-    public static final Call TO_JAVA_DEQUE = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaDeque", Deque.class, Object.class);
-
     /** Method handle for void returns. */
     public static final Call VOID_RETURN = staticCall(JSTYPE_LOOKUP, JSType.class, "voidReturn", void.class);
 
-
     /**
      * The list of available accessor types in width order. This order is used for type guesses narrow{@literal ->} wide
      *  in the dual--fields world
@@ -311,7 +304,7 @@
             return JSType.BOOLEAN;
         }
 
-        if (obj instanceof String || obj instanceof ConsString) {
+        if (isString(obj)) {
             return JSType.STRING;
         }
 
@@ -349,7 +342,7 @@
             return JSType.BOOLEAN;
         }
 
-        if (obj instanceof String || obj instanceof ConsString) {
+        if (isString(obj)) {
             return JSType.STRING;
         }
 
@@ -455,8 +448,7 @@
                obj == ScriptRuntime.UNDEFINED ||
                obj instanceof Boolean ||
                obj instanceof Number ||
-               obj instanceof String ||
-               obj instanceof ConsString;
+               isString(obj);
     }
 
    /**
@@ -480,17 +472,47 @@
      * @return the primitive form of the object
      */
     public static Object toPrimitive(final Object obj, final Class<?> hint) {
-        return obj instanceof ScriptObject ? toPrimitive((ScriptObject)obj, hint) : obj;
+        if (obj instanceof ScriptObject) {
+            return toPrimitive((ScriptObject)obj, hint);
+        } else if (isPrimitive(obj)) {
+            return obj;
+        } else if (obj instanceof JSObject) {
+            return toPrimitive((JSObject)obj, hint);
+        } else if (obj instanceof StaticClass) {
+            final String name = ((StaticClass)obj).getRepresentedClass().getName();
+            return new StringBuilder(12 + name.length()).append("[JavaClass ").append(name).append(']').toString();
+        }
+        return obj.toString();
     }
 
     private static Object toPrimitive(final ScriptObject sobj, final Class<?> hint) {
-        final Object result = sobj.getDefaultValue(hint);
+        return requirePrimitive(sobj.getDefaultValue(hint));
+    }
 
+    private static Object requirePrimitive(final Object result) {
         if (!isPrimitive(result)) {
             throw typeError("bad.default.value", result.toString());
         }
+        return result;
+    }
 
-        return result;
+    /**
+     * Primitive converter for a {@link JSObject} including type hint. Invokes
+     * {@link AbstractJSObject#getDefaultValue(JSObject, Class)} and translates any thrown
+     * {@link UnsupportedOperationException} to an ECMAScript {@code TypeError}.
+     * See ECMA 9.1 ToPrimitive
+     *
+     * @param jsobj  a JSObject
+     * @param hint a type hint
+     *
+     * @return the primitive form of the JSObject
+     */
+    public static Object toPrimitive(final JSObject jsobj, final Class<?> hint) {
+        try {
+            return requirePrimitive(AbstractJSObject.getDefaultValue(jsobj, hint));
+        } catch (final UnsupportedOperationException e) {
+            throw new ECMAException(Context.getGlobal().newTypeError(e.getMessage()), e);
+        }
     }
 
     /**
@@ -547,7 +569,7 @@
             return num != 0 && !Double.isNaN(num);
         }
 
-        if (obj instanceof String || obj instanceof ConsString) {
+        if (isString(obj)) {
             return ((CharSequence)obj).length() > 0;
         }
 
@@ -598,6 +620,15 @@
     }
 
     /**
+     * Returns true if object represents a primitive JavaScript string value.
+     * @param obj the object
+     * @return true if the object represents a primitive JavaScript string value.
+     */
+    public static boolean isString(final Object obj) {
+        return obj instanceof String || obj instanceof ConsString;
+    }
+
+    /**
      * JavaScript compliant conversion of integer to String
      *
      * @param num an integer
@@ -723,6 +754,48 @@
         return toNumberGeneric(obj);
     }
 
+    /**
+     * Converts an object for a comparison with a number. Almost identical to {@link #toNumber(Object)} but
+     * converts {@code null} to {@code NaN} instead of zero, so it won't compare equal to zero.
+     *
+     * @param obj  an object
+     *
+     * @return a number
+     */
+    public static double toNumberForEq(final Object obj) {
+        return obj == null ? Double.NaN : toNumber(obj);
+    }
+
+    /**
+     * Converts an object for strict comparison with a number. Returns {@code NaN} for any object that is not
+     * a {@link Number}, so only boxed numerics can compare strictly equal to numbers.
+     *
+     * @param obj  an object
+     *
+     * @return a number
+     */
+    public static double toNumberForStrictEq(final Object obj) {
+        if (obj instanceof Double) {
+            return (Double)obj;
+        }
+        if (obj instanceof Number) {
+            return ((Number)obj).doubleValue();
+        }
+        return Double.NaN;
+    }
+
+
+    /**
+     * JavaScript compliant conversion of Boolean to number
+     * See ECMA 9.3 ToNumber
+     *
+     * @param b a boolean
+     *
+     * @return JS numeric value of the boolean: 1.0 or 0.0
+     */
+    public static double toNumber(final Boolean b) {
+        return b ? 1d : +0d;
+    }
 
     /**
      * JavaScript compliant conversion of Object to number
@@ -853,11 +926,15 @@
         if (start + 1 < end && f == '0' && Character.toLowerCase(str.charAt(start + 1)) == 'x') {
             //decode hex string
             value = parseRadix(str.toCharArray(), start + 2, end, 16);
+        } else if (f == 'I' && end - start == 8 && str.regionMatches(start, "Infinity", 0, 8)) {
+            return negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
         } else {
-            // Fast (no NumberFormatException) path to NaN for non-numeric strings. We allow those starting with "I" or
-            // "N" to allow for parsing "NaN" and "Infinity" correctly.
-            if ((f < '0' || f > '9') && f != '.' && f != 'I' && f != 'N') {
-                return Double.NaN;
+            // Fast (no NumberFormatException) path to NaN for non-numeric strings.
+            for (int i = start; i < end; i++) {
+                f = str.charAt(i);
+                if ((f < '0' || f > '9') && f != '.' && f != 'e' && f != 'E' && f != '+' && f != '-') {
+                    return Double.NaN;
+                }
             }
             try {
                 value = Double.parseDouble(str.substring(start, end));
@@ -1268,24 +1345,6 @@
     }
 
     /**
-     * Converts a JavaScript object to a Java List. See {@link ListAdapter} for details.
-     * @param obj the object to convert. Can be any array-like object.
-     * @return a List that is live-backed by the JavaScript object.
-     */
-    public static List<?> toJavaList(final Object obj) {
-        return ListAdapter.create(obj);
-    }
-
-    /**
-     * Converts a JavaScript object to a Java Deque. See {@link ListAdapter} for details.
-     * @param obj the object to convert. Can be any array-like object.
-     * @return a Deque that is live-backed by the JavaScript object.
-     */
-    public static Deque<?> toJavaDeque(final Object obj) {
-        return ListAdapter.create(obj);
-    }
-
-    /**
      * Check if an object is null or undefined
      *
      * @param obj object to check
@@ -1301,6 +1360,10 @@
             return (String)obj;
         }
 
+        if (obj instanceof ConsString) {
+            return obj.toString();
+        }
+
         if (obj instanceof Number) {
             return toString(((Number)obj).doubleValue());
         }
@@ -1313,23 +1376,19 @@
             return "null";
         }
 
-        if (obj instanceof ScriptObject) {
-            if (safe) {
-                final ScriptObject sobj = (ScriptObject)obj;
-                final Global gobj = Context.getGlobal();
-                return gobj.isError(sobj) ?
-                    ECMAException.safeToString(sobj) :
-                    sobj.safeToString();
-            }
-
-            return toString(toPrimitive(obj, String.class));
+        if (obj instanceof Boolean) {
+            return obj.toString();
         }
 
-        if (obj instanceof StaticClass) {
-            return "[JavaClass " + ((StaticClass)obj).getRepresentedClass().getName() + "]";
+        if (safe && obj instanceof ScriptObject) {
+            final ScriptObject sobj = (ScriptObject)obj;
+            final Global gobj = Context.getGlobal();
+            return gobj.isError(sobj) ?
+                ECMAException.safeToString(sobj) :
+                sobj.safeToString();
         }
 
-        return obj.toString();
+        return toString(toPrimitive(obj, String.class));
     }
 
     // trim from left for JS whitespaces.
@@ -1822,18 +1881,18 @@
         }
 
         if (obj instanceof Boolean) {
-            return (Boolean)obj ? 1 : +0.0;
+            return toNumber((Boolean)obj);
         }
 
         if (obj instanceof ScriptObject) {
             return toNumber((ScriptObject)obj);
         }
 
-        if (obj instanceof JSObject) {
-            return ((JSObject)obj).toNumber();
+        if (obj instanceof Undefined) {
+            return Double.NaN;
         }
 
-        return Double.NaN;
+        return toNumber(toPrimitive(obj, Number.class));
     }
 
     private static Object invoke(final MethodHandle mh, final Object arg) {
@@ -1888,10 +1947,6 @@
      * @return primive type or Object.class if not primitive
      */
     public static Class<?> unboxedFieldType(final Object o) {
-        if (OBJECT_FIELDS_ONLY) {
-            return Object.class;
-        }
-
         if (o == null) {
             return Object.class;
         } else if (o.getClass() == Integer.class) {
--- a/src/jdk/nashorn/internal/runtime/ListAdapter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ListAdapter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,17 +25,19 @@
 
 package jdk.nashorn.internal.runtime;
 
+import java.lang.invoke.MethodHandle;
 import java.util.AbstractList;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.ListIterator;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.RandomAccess;
 import java.util.concurrent.Callable;
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
-import jdk.nashorn.internal.runtime.linker.InvokeByName;
 
 /**
  * An adapter that can wrap any ECMAScript Array-like object (that adheres to the array rules for the property
@@ -50,82 +52,43 @@
  * operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and
  * {@code pop}.
  */
-public abstract class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
-    // These add to the back and front of the list
-    private static final Object PUSH    = new Object();
-    private static InvokeByName getPUSH() {
-        return Context.getGlobal().getInvokeByName(PUSH,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("push", Object.class, void.class, Object.class);
-                    }
-                });
-    }
+public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
+    // Invoker creator for methods that add to the start or end of the list: PUSH and UNSHIFT. Takes fn, this, and value, returns void.
+    private static final Callable<MethodHandle> ADD_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, Object.class);
 
+    // PUSH adds to the start of the list
+    private static final Object PUSH = new Object();
+    // UNSHIFT adds to the end of the list
     private static final Object UNSHIFT = new Object();
-    private static InvokeByName getUNSHIFT() {
-        return Context.getGlobal().getInvokeByName(UNSHIFT,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("unshift", Object.class, void.class, Object.class);
-                    }
-                });
-    }
 
-    // These remove from the back and front of the list
+    // Invoker creator for methods that remove from the tail or head of the list: POP and SHIFT. Takes fn, this, returns Object.
+    private static final Callable<MethodHandle> REMOVE_INVOKER_CREATOR = invokerCreator(Object.class, Object.class, JSObject.class);
+
+    // POP removes from the start of the list
     private static final Object POP = new Object();
-    private static InvokeByName getPOP() {
-        return Context.getGlobal().getInvokeByName(POP,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("pop", Object.class, Object.class);
-                    }
-                });
-    }
-
+    // SHIFT removes from the end of the list
     private static final Object SHIFT = new Object();
-    private static InvokeByName getSHIFT() {
-        return Context.getGlobal().getInvokeByName(SHIFT,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("shift", Object.class, Object.class);
-                    }
-                });
-    }
 
-    // These insert and remove in the middle of the list
+    // SPLICE can be used to add a value in the middle of the list.
     private static final Object SPLICE_ADD = new Object();
-    private static InvokeByName getSPLICE_ADD() {
-        return Context.getGlobal().getInvokeByName(SPLICE_ADD,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("splice", Object.class, void.class, int.class, int.class, Object.class);
-                    }
-                });
-    }
+    private static final Callable<MethodHandle> SPLICE_ADD_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, int.class, int.class, Object.class);
 
+    // SPLICE can also be used to remove values from the middle of the list.
     private static final Object SPLICE_REMOVE = new Object();
-    private static InvokeByName getSPLICE_REMOVE() {
-        return  Context.getGlobal().getInvokeByName(SPLICE_REMOVE,
-                new Callable<InvokeByName>() {
-                    @Override
-                    public InvokeByName call() {
-                        return new InvokeByName("splice", Object.class, void.class, int.class, int.class);
-                    }
-                });
-    }
+    private static final Callable<MethodHandle> SPLICE_REMOVE_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, int.class, int.class);
 
     /** wrapped object */
-    protected final Object obj;
+    final JSObject obj;
+    private final Global global;
 
     // allow subclasses only in this package
-    ListAdapter(final Object obj) {
+    ListAdapter(final JSObject obj, final Global global) {
+        if (global == null) {
+            throw new IllegalStateException(ECMAErrors.getMessage("list.adapter.null.global"));
+        }
+
         this.obj = obj;
+        this.global = global;
     }
 
     /**
@@ -135,14 +98,17 @@
      * @return A ListAdapter wrapper object
      */
     public static ListAdapter create(final Object obj) {
+        final Global global = Context.getGlobal();
+        return new ListAdapter(getJSObject(obj, global), global);
+    }
+
+    private static JSObject getJSObject(final Object obj, final Global global) {
         if (obj instanceof ScriptObject) {
-            final Object mirror = ScriptObjectMirror.wrap(obj, Context.getGlobal());
-            return new JSObjectListAdapter((JSObject)mirror);
+            return (JSObject)ScriptObjectMirror.wrap(obj, global);
         } else if (obj instanceof JSObject) {
-            return new JSObjectListAdapter((JSObject)obj);
-        } else {
-            throw new IllegalArgumentException("ScriptObject or JSObject expected");
+            return (JSObject)obj;
         }
+        throw new IllegalArgumentException("ScriptObject or JSObject expected");
     }
 
     @Override
@@ -151,28 +117,18 @@
         return getAt(index);
     }
 
-    /**
-     * Get object at an index
-     * @param index index in list
-     * @return object
-     */
-    protected abstract Object getAt(final int index);
+    private Object getAt(final int index) {
+        return obj.getSlot(index);
+    }
 
     @Override
     public Object set(final int index, final Object element) {
         checkRange(index);
         final Object prevValue = getAt(index);
-        setAt(index, element);
+        obj.setSlot(index, element);
         return prevValue;
     }
 
-    /**
-     * Set object at an index
-     * @param index   index in list
-     * @param element element
-     */
-    protected abstract void setAt(final int index, final Object element);
-
     private void checkRange(final int index) {
         if(index < 0 || index >= size()) {
             throw invalidIndex(index);
@@ -180,6 +136,11 @@
     }
 
     @Override
+    public int size() {
+        return JSType.toInt32(obj.getMember("length"));
+    }
+
+    @Override
     public final void push(final Object e) {
         addFirst(e);
     }
@@ -193,10 +154,7 @@
     @Override
     public final void addFirst(final Object e) {
         try {
-            final InvokeByName unshiftInvoker = getUNSHIFT();
-            final Object fn = unshiftInvoker.getGetter().invokeExact(obj);
-            checkFunction(fn, unshiftInvoker);
-            unshiftInvoker.getInvoker().invokeExact(fn, obj, e);
+            getDynamicInvoker(UNSHIFT, ADD_INVOKER_CREATOR).invokeExact(getFunction("unshift"), obj, e);
         } catch(RuntimeException | Error ex) {
             throw ex;
         } catch(final Throwable t) {
@@ -207,10 +165,7 @@
     @Override
     public final void addLast(final Object e) {
         try {
-            final InvokeByName pushInvoker = getPUSH();
-            final Object fn = pushInvoker.getGetter().invokeExact(obj);
-            checkFunction(fn, pushInvoker);
-            pushInvoker.getInvoker().invokeExact(fn, obj, e);
+            getDynamicInvoker(PUSH, ADD_INVOKER_CREATOR).invokeExact(getFunction("push"), obj, e);
         } catch(RuntimeException | Error ex) {
             throw ex;
         } catch(final Throwable t) {
@@ -228,10 +183,7 @@
             } else {
                 final int size = size();
                 if(index < size) {
-                    final InvokeByName spliceAddInvoker = getSPLICE_ADD();
-                    final Object fn = spliceAddInvoker.getGetter().invokeExact(obj);
-                    checkFunction(fn, spliceAddInvoker);
-                    spliceAddInvoker.getInvoker().invokeExact(fn, obj, index, 0, e);
+                    getDynamicInvoker(SPLICE_ADD, SPLICE_ADD_INVOKER_CREATOR).invokeExact(obj.getMember("splice"), obj, index, 0, e);
                 } else if(index == size) {
                     addLast(e);
                 } else {
@@ -244,10 +196,12 @@
             throw new RuntimeException(t);
         }
     }
-    private static void checkFunction(final Object fn, final InvokeByName invoke) {
+    private Object getFunction(final String name) {
+        final Object fn = obj.getMember(name);
         if(!(Bootstrap.isCallable(fn))) {
-            throw new UnsupportedOperationException("The script object doesn't have a function named " + invoke.getName());
+            throw new UnsupportedOperationException("The script object doesn't have a function named " + name);
         }
+        return fn;
     }
 
     private static IndexOutOfBoundsException invalidIndex(final int index) {
@@ -321,10 +275,7 @@
 
     private Object invokeShift() {
         try {
-            final InvokeByName shiftInvoker = getSHIFT();
-            final Object fn = shiftInvoker.getGetter().invokeExact(obj);
-            checkFunction(fn, shiftInvoker);
-            return shiftInvoker.getInvoker().invokeExact(fn, obj);
+            return getDynamicInvoker(SHIFT, REMOVE_INVOKER_CREATOR).invokeExact(getFunction("shift"), obj);
         } catch(RuntimeException | Error ex) {
             throw ex;
         } catch(final Throwable t) {
@@ -334,10 +285,7 @@
 
     private Object invokePop() {
         try {
-            final InvokeByName popInvoker = getPOP();
-            final Object fn = popInvoker.getGetter().invokeExact(obj);
-            checkFunction(fn, popInvoker);
-            return popInvoker.getInvoker().invokeExact(fn, obj);
+            return getDynamicInvoker(POP, REMOVE_INVOKER_CREATOR).invokeExact(getFunction("pop"), obj);
         } catch(RuntimeException | Error ex) {
             throw ex;
         } catch(final Throwable t) {
@@ -352,10 +300,7 @@
 
     private void invokeSpliceRemove(final int fromIndex, final int count) {
         try {
-            final InvokeByName spliceRemoveInvoker = getSPLICE_REMOVE();
-            final Object fn = spliceRemoveInvoker.getGetter().invokeExact(obj);
-            checkFunction(fn, spliceRemoveInvoker);
-            spliceRemoveInvoker.getInvoker().invokeExact(fn, obj, fromIndex, count);
+            getDynamicInvoker(SPLICE_REMOVE, SPLICE_REMOVE_INVOKER_CREATOR).invokeExact(getFunction("splice"), obj, fromIndex, count);
         } catch(RuntimeException | Error ex) {
             throw ex;
         } catch(final Throwable t) {
@@ -443,12 +388,24 @@
 
     private static boolean removeOccurrence(final Object o, final Iterator<Object> it) {
         while(it.hasNext()) {
-            final Object e = it.next();
-            if(o == null ? e == null : o.equals(e)) {
+            if(Objects.equals(o, it.next())) {
                 it.remove();
                 return true;
             }
         }
         return false;
     }
+
+    private static Callable<MethodHandle> invokerCreator(final Class<?> rtype, final Class<?>... ptypes) {
+        return new Callable<MethodHandle>() {
+            @Override
+            public MethodHandle call() {
+                return Bootstrap.createDynamicInvoker("dyn:call", rtype, ptypes);
+            }
+        };
+    }
+
+    private MethodHandle getDynamicInvoker(final Object key, final Callable<MethodHandle> creator) {
+        return global.getDynamicInvoker(key, creator);
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/Property.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/Property.java	Fri Nov 13 15:38:44 2015 -0800
@@ -96,6 +96,9 @@
     /** Is this property an ES6 lexical binding? */
     public static final int IS_LEXICAL_BINDING      = 1 << 10;
 
+    /** Does this property support dual field representation? */
+    public static final int DUAL_FIELDS             = 1 << 11;
+
     /** Property key. */
     private final String key;
 
@@ -286,7 +289,7 @@
      * @return true if parameter
      */
     public boolean isParameter() {
-        return (flags & IS_PARAMETER) == IS_PARAMETER;
+        return (flags & IS_PARAMETER) != 0;
     }
 
     /**
@@ -294,7 +297,7 @@
      * @return true if has arguments
      */
     public boolean hasArguments() {
-        return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS;
+        return (flags & HAS_ARGUMENTS) != 0;
     }
 
     /**
@@ -316,7 +319,7 @@
      * @return true if this is a bound property
      */
     public boolean isBound() {
-        return (flags & IS_BOUND) == IS_BOUND;
+        return (flags & IS_BOUND) != 0;
     }
 
     /**
@@ -325,7 +328,7 @@
      * @return true if this is a block-scoped variable
      */
     public boolean needsDeclaration() {
-        return (flags & NEEDS_DECLARATION) == NEEDS_DECLARATION;
+        return (flags & NEEDS_DECLARATION) != 0;
     }
 
     /**
@@ -346,16 +349,6 @@
     }
 
     /**
-     * Check if a flag is set for a property
-     * @param property property
-     * @param flag     flag to check
-     * @return true if flag is set
-     */
-    public static boolean checkFlag(final Property property, final int flag) {
-        return (property.getFlags() & flag) == flag;
-    }
-
-    /**
      * Get the flags for this property
      * @return property flags
      */
@@ -364,16 +357,6 @@
     }
 
     /**
-     * Get the modify flags for this property. The modify flags are the ECMA 8.6.1
-     * flags that decide if the Property is writable, configurable and/or enumerable.
-     *
-     * @return modify flags for property
-     */
-    public int getModifyFlags() {
-        return flags & MODIFY_MASK;
-    }
-
-    /**
      * Remove property flags from the property. Properties are immutable here,
      * so any property change that results in a smaller flag set results in the
      * property being cloned. Use only the return value
@@ -715,7 +698,7 @@
      * @return whether this property is a function declaration or not.
      */
     public boolean isFunctionDeclaration() {
-        return (flags & IS_FUNCTION_DECLARATION) == IS_FUNCTION_DECLARATION;
+        return (flags & IS_FUNCTION_DECLARATION) != 0;
     }
 
     /**
@@ -723,6 +706,14 @@
      * @return true if this property represents a lexical binding.
      */
     public boolean isLexicalBinding() {
-        return (flags & IS_LEXICAL_BINDING) == IS_LEXICAL_BINDING;
+        return (flags & IS_LEXICAL_BINDING) != 0;
+    }
+
+    /**
+     * Does this property support dual fields for both primitive and object values?
+     * @return true if supports dual fields
+     */
+    public boolean hasDualFields() {
+        return (flags & DUAL_FIELDS) != 0;
     }
 }
--- a/src/jdk/nashorn/internal/runtime/PropertyMap.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java	Fri Nov 13 15:38:44 2015 -0800
@@ -199,12 +199,21 @@
     }
 
     /**
+     * Return a sharable empty map for the given object class.
+     * @param clazz the base object class
+     * @return New empty {@link PropertyMap}.
+     */
+    public static PropertyMap newMap(final Class<? extends ScriptObject> clazz) {
+        return new PropertyMap(EMPTY_HASHMAP, clazz.getName(), 0, 0, 0, false);
+    }
+
+    /**
      * Return a sharable empty map.
      *
      * @return New empty {@link PropertyMap}.
      */
     public static PropertyMap newMap() {
-        return new PropertyMap(EMPTY_HASHMAP, JO.class.getName(), 0, 0, 0, false);
+        return newMap(JO.class);
     }
 
     /**
@@ -330,12 +339,15 @@
      * Indicate that proto itself has changed in hierarchy somewhere.
      */
     synchronized void invalidateAllProtoGetSwitchPoints() {
-        if (protoGetSwitches != null && !protoGetSwitches.isEmpty()) {
-            if (Context.DEBUG) {
-                protoInvalidations += protoGetSwitches.size();
+        if (protoGetSwitches != null) {
+            final int size = protoGetSwitches.size();
+            if (size > 0) {
+                if (Context.DEBUG) {
+                    protoInvalidations += size;
+                }
+                SwitchPoint.invalidateAll(protoGetSwitches.values().toArray(new SwitchPoint[size]));
+                protoGetSwitches.clear();
             }
-            SwitchPoint.invalidateAll(protoGetSwitches.values().toArray(new SwitchPoint[protoGetSwitches.values().size()]));
-            protoGetSwitches.clear();
         }
     }
 
@@ -375,7 +387,8 @@
         }
     }
 
-    // Update the free slots bitmap for a property that has been deleted and/or added.
+    // Update the free slots bitmap for a property that has been deleted and/or added. This method is not synchronized
+    // as it is always invoked on a newly created instance.
     private void updateFreeSlots(final Property oldProperty, final Property newProperty) {
         // Free slots bitset is possibly shared with parent map, so we must clone it before making modifications.
         boolean freeSlotsCloned = false;
@@ -425,7 +438,7 @@
      *
      * @return New {@link PropertyMap} with {@link Property} added.
      */
-    public PropertyMap addProperty(final Property property) {
+    public synchronized PropertyMap addProperty(final Property property) {
         if (listeners != null) {
             listeners.propertyAdded(property);
         }
@@ -434,9 +447,9 @@
         if (newMap == null) {
             final PropertyHashMap newProperties = properties.immutableAdd(property);
             newMap = new PropertyMap(this, newProperties);
-            addToHistory(property, newMap);
             newMap.updateFlagsAndBoundaries(property);
             newMap.updateFreeSlots(null, property);
+            addToHistory(property, newMap);
         }
 
         return newMap;
@@ -449,7 +462,7 @@
      *
      * @return New {@link PropertyMap} with {@link Property} removed or {@code null} if not found.
      */
-    public PropertyMap deleteProperty(final Property property) {
+    public synchronized PropertyMap deleteProperty(final Property property) {
         if (listeners != null) {
             listeners.propertyDeleted(property);
         }
@@ -486,7 +499,7 @@
      *
      * @return New {@link PropertyMap} with {@link Property} replaced.
      */
-    PropertyMap replaceProperty(final Property oldProperty, final Property newProperty) {
+    public PropertyMap replaceProperty(final Property oldProperty, final Property newProperty) {
         if (listeners != null) {
             listeners.propertyModified(oldProperty, newProperty);
         }
@@ -881,8 +894,7 @@
      * @param newProto New prototype object to replace oldProto.
      * @return New {@link PropertyMap} with prototype changed.
      */
-    public PropertyMap changeProto(final ScriptObject newProto) {
-
+    public synchronized PropertyMap changeProto(final ScriptObject newProto) {
         final PropertyMap nextMap = checkProtoHistory(newProto);
         if (nextMap != null) {
             return nextMap;
--- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -32,7 +32,6 @@
 import java.lang.invoke.MethodType;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -43,7 +42,6 @@
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.codegen.FunctionSignature;
 import jdk.nashorn.internal.codegen.Namespace;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator.AllocatorDescriptor;
 import jdk.nashorn.internal.codegen.OptimisticTypesPersistence;
 import jdk.nashorn.internal.codegen.TypeMap;
 import jdk.nashorn.internal.codegen.types.Type;
@@ -126,7 +124,7 @@
      *
      * @param functionNode        functionNode that represents this function code
      * @param installer           installer for code regeneration versions of this function
-     * @param allocationDescriptor descriptor for the allocation behavior when this function is used as a constructor
+     * @param allocationStrategy  strategy for the allocation behavior when this function is used as a constructor
      * @param nestedFunctions     nested function map
      * @param externalScopeDepths external scope depths
      * @param internalSymbols     internal symbols to method, defined in its scope
@@ -135,7 +133,7 @@
     public RecompilableScriptFunctionData(
         final FunctionNode functionNode,
         final CodeInstaller<ScriptEnvironment> installer,
-        final AllocatorDescriptor allocationDescriptor,
+        final AllocationStrategy allocationStrategy,
         final Map<Integer, RecompilableScriptFunctionData> nestedFunctions,
         final Map<String, Integer> externalScopeDepths,
         final Set<String> internalSymbols,
@@ -153,7 +151,7 @@
         this.endParserState      = functionNode.getEndParserState();
         this.token               = tokenFor(functionNode);
         this.installer           = installer;
-        this.allocationStrategy  = AllocationStrategy.get(allocationDescriptor);
+        this.allocationStrategy  = allocationStrategy;
         this.nestedFunctions     = smallMap(nestedFunctions);
         this.externalScopeDepths = smallMap(externalScopeDepths);
         this.internalSymbols     = smallSet(new HashSet<>(internalSymbols));
@@ -344,6 +342,9 @@
         if (functionNode.isVarArg()) {
             flags |= IS_VARIABLE_ARITY;
         }
+        if (functionNode.getKind() == FunctionNode.Kind.GETTER || functionNode.getKind() == FunctionNode.Kind.SETTER) {
+            flags |= IS_PROPERTY_ACCESSOR;
+        }
         return flags;
     }
 
@@ -384,7 +385,7 @@
         parser.setReparsedFunction(this);
 
         final FunctionNode program = parser.parse(CompilerConstants.PROGRAM.symbolName(), descPosition,
-                Token.descLength(token), true);
+                Token.descLength(token), isPropertyAccessor());
         // Parser generates a program AST even if we're recompiling a single function, so when we are only
         // recompiling a single function, extract it from the program.
         return (isProgram() ? program : extractFunctionFromScript(program)).setName(null, functionName);
@@ -493,7 +494,7 @@
             log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType);
         }
 
-        final boolean persistentCache = usePersistentCodeCache() && persist;
+        final boolean persistentCache = persist && usePersistentCodeCache();
         String cacheKey = null;
         if (persistentCache) {
             final TypeMap typeMap = typeMap(actualCallSiteType);
@@ -504,7 +505,7 @@
 
             if (script != null) {
                 Compiler.updateCompilationId(script.getCompilationId());
-                return installStoredScript(script, newInstaller);
+                return script.installFunction(this, newInstaller);
             }
         }
 
@@ -519,59 +520,8 @@
         return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints());
     }
 
-    private static Map<String, Class<?>> installStoredScriptClasses(final StoredScript script, final CodeInstaller<ScriptEnvironment> installer) {
-        final Map<String, Class<?>> installedClasses = new HashMap<>();
-        final Map<String, byte[]>   classBytes       = script.getClassBytes();
-        final String   mainClassName   = script.getMainClassName();
-        final byte[]   mainClassBytes  = classBytes.get(mainClassName);
-
-        final Class<?> mainClass       = installer.install(mainClassName, mainClassBytes);
-
-        installedClasses.put(mainClassName, mainClass);
-
-        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
-            final String className = entry.getKey();
-            final byte[] bytecode = entry.getValue();
-
-            if (className.equals(mainClassName)) {
-                continue;
-            }
-
-            installedClasses.put(className, installer.install(className, bytecode));
-        }
-        return installedClasses;
-    }
-
-    /**
-     * Install this script using the given {@code installer}.
-     *
-     * @param script the compiled script
-     * @return the function initializer
-     */
-    private FunctionInitializer installStoredScript(final StoredScript script, final CodeInstaller<ScriptEnvironment> newInstaller) {
-        final Map<String, Class<?>> installedClasses = installStoredScriptClasses(script, newInstaller);
-
-        final Map<Integer, FunctionInitializer> initializers = script.getInitializers();
-        assert initializers != null;
-        assert initializers.size() == 1;
-        final FunctionInitializer initializer = initializers.values().iterator().next();
-
-        final Object[] constants = script.getConstants();
-        for (int i = 0; i < constants.length; i++) {
-            if (constants[i] instanceof RecompilableScriptFunctionData) {
-                // replace deserialized function data with the ones we already have
-                constants[i] = getScriptFunctionData(((RecompilableScriptFunctionData) constants[i]).getFunctionNodeId());
-            }
-        }
-
-        newInstaller.initialize(installedClasses.values(), source, constants);
-        initializer.setCode(installedClasses.get(initializer.getClassName()));
-        return initializer;
-    }
-
     boolean usePersistentCodeCache() {
-        final ScriptEnvironment env = installer.getOwner();
-        return env._persistent_cache && env._optimistic_types;
+        return installer != null && installer.getOwner()._persistent_cache;
     }
 
     private MethodType explicitParams(final MethodType callSiteType) {
@@ -646,13 +596,21 @@
      * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
      * externally will result in an exception.
      *
-     * @param initializer FunctionInitializer for this data
+     * @param functionNode FunctionNode for this data
      */
-    public void initializeCode(final FunctionInitializer initializer) {
+    public void initializeCode(final FunctionNode functionNode) {
         // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
-        if(!code.isEmpty()) {
+        if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
             throw new IllegalStateException(name);
         }
+        addCode(lookup(functionNode), null, null, functionNode.getFlags());
+    }
+
+    /**
+     * Initializes this function with the given function code initializer.
+     * @param initializer function code initializer
+     */
+    void initializeCode(final FunctionInitializer initializer) {
         addCode(lookup(initializer, true), null, null, initializer.getFlags());
     }
 
--- a/src/jdk/nashorn/internal/runtime/Scope.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/Scope.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,30 +25,105 @@
 
 package jdk.nashorn.internal.runtime;
 
-import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
+import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
 
 import jdk.nashorn.internal.codegen.CompilerConstants;
 
 /**
- * Interface implemented by {@link ScriptObject}s that act as scope.
+ * A {@link ScriptObject} subclass for objects that act as scope.
  */
-public interface Scope {
+public class Scope extends ScriptObject {
+
+    /* This is used to store return state of split functions. */
+    private int splitState = -1;
+
+    /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */
+    private static int count;
 
     /** Method handle that points to {@link Scope#getSplitState}. */
-    public static final CompilerConstants.Call GET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "getSplitState", int.class);
+    public static final CompilerConstants.Call GET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "getSplitState", int.class);
+    /** Method handle that points to {@link Scope#setSplitState(int)}. */
+    public static final CompilerConstants.Call SET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "setSplitState", void.class, int.class);
+
+    /**
+     * Constructor
+     *
+     * @param map initial property map
+     */
+    public Scope(final PropertyMap map) {
+        super(map);
+        if (Context.DEBUG) {
+            count++;
+        }
+    }
+
+    /**
+     * Constructor
+     *
+     * @param proto parent scope
+     * @param map   initial property map
+     */
+    public Scope(final ScriptObject proto, final PropertyMap map) {
+        super(proto, map);
+        if (Context.DEBUG) {
+            count++;
+        }
+    }
 
-    /** Method handle that points to {@link Scope#setSplitState(int)}. */
-    public static final CompilerConstants.Call SET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "setSplitState", void.class, int.class);
+    /**
+     * Constructor
+     *
+     * @param map            property map
+     * @param primitiveSpill primitive spill array
+     * @param objectSpill    reference spill array
+     */
+    public Scope(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) {
+        super(map, primitiveSpill, objectSpill);
+        if (Context.DEBUG) {
+            count++;
+        }
+    }
+
+    @Override
+    public boolean isScope() {
+        return true;
+    }
+
+    @Override
+    boolean hasWithScope() {
+        for (ScriptObject obj = this; obj != null; obj = obj.getProto()) {
+            if (obj instanceof WithObject) {
+                return true;
+            }
+        }
+        return false;
+    }
 
     /**
      * Get the scope's split method state.
-     * @return the current state
+     *
+     * @return current split state
      */
-    public int getSplitState();
+    public int getSplitState() {
+        return splitState;
+    }
 
     /**
      * Set the scope's split method state.
-     * @param state the new state.
+     *
+     * @param state current split state
      */
-    public void setSplitState(int state);
+    public void setSplitState(final int state) {
+        splitState = state;
+    }
+
+    /**
+     * Get number of {@code Scope} instances created. If not running in debug
+     * mode this is always 0.
+     *
+     * @return number of scope ScriptObjects created
+     */
+    public static int getScopeCount() {
+        return count;
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Fri Nov 13 15:38:44 2015 -0800
@@ -73,7 +73,7 @@
     /** Generate line number table in class files */
     public final boolean _debug_lines;
 
-    /** Package to which generated class files are added */
+    /** Directory in which source files and generated class files are dumped */
     public final String  _dest_dir;
 
     /** Display stack trace upon error, default is false */
--- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Fri Nov 13 15:38:44 2015 -0800
@@ -143,7 +143,6 @@
 
         this.data  = data;
         this.scope = scope;
-        this.allocatorMap = data.getAllocatorMap();
     }
 
     @Override
@@ -253,7 +252,7 @@
 
         assert !isBoundFunction(); // allocate never invoked on bound functions
 
-        final ScriptObject object = data.allocate(allocatorMap);
+        final ScriptObject object = data.allocate(getAllocatorMap());
 
         if (object != null) {
             final Object prototype = getPrototype();
@@ -269,6 +268,13 @@
         return object;
     }
 
+    private PropertyMap getAllocatorMap() {
+        if (allocatorMap == null) {
+            allocatorMap = data.getAllocatorMap();
+        }
+        return allocatorMap;
+    }
+
     /**
      * Return Object.prototype - used by "allocate"
      * @return Object.prototype
--- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,7 @@
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
+
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
@@ -79,24 +80,24 @@
     private static final MethodHandle BIND_VAR_ARGS = findOwnMH("bindVarArgs", Object[].class, Object[].class, Object[].class);
 
     /** Is this a strict mode function? */
-    public static final int IS_STRICT      = 1 << 0;
+    public static final int IS_STRICT            = 1 << 0;
     /** Is this a built-in function? */
-    public static final int IS_BUILTIN     = 1 << 1;
+    public static final int IS_BUILTIN           = 1 << 1;
     /** Is this a constructor function? */
-    public static final int IS_CONSTRUCTOR = 1 << 2;
+    public static final int IS_CONSTRUCTOR       = 1 << 2;
     /** Does this function expect a callee argument? */
-    public static final int NEEDS_CALLEE   = 1 << 3;
+    public static final int NEEDS_CALLEE         = 1 << 3;
     /** Does this function make use of the this-object argument? */
-    public static final int USES_THIS      = 1 << 4;
+    public static final int USES_THIS            = 1 << 4;
     /** Is this a variable arity function? */
-    public static final int IS_VARIABLE_ARITY = 1 << 5;
+    public static final int IS_VARIABLE_ARITY    = 1 << 5;
+    /** Is this a object literal property getter or setter? */
+    public static final int IS_PROPERTY_ACCESSOR = 1 << 6;
 
     /** Flag for strict or built-in functions */
     public static final int IS_STRICT_OR_BUILTIN = IS_STRICT | IS_BUILTIN;
     /** Flag for built-in constructors */
     public static final int IS_BUILTIN_CONSTRUCTOR = IS_BUILTIN | IS_CONSTRUCTOR;
-    /** Flag for strict constructors */
-    public static final int IS_STRICT_CONSTRUCTOR = IS_STRICT | IS_CONSTRUCTOR;
 
     private static final long serialVersionUID = 4252901245508769114L;
 
@@ -121,6 +122,10 @@
         return (flags & IS_VARIABLE_ARITY) != 0;
     }
 
+    final boolean isPropertyAccessor() {
+        return (flags & IS_PROPERTY_ACCESSOR) != 0;
+    }
+
     /**
      * Used from e.g. Native*$Constructors as an explicit call. TODO - make arity immutable and final
      * @param arity new arity
@@ -456,8 +461,7 @@
     }
 
     static boolean isPrimitiveThis(final Object obj) {
-        return obj instanceof String || obj instanceof ConsString ||
-               obj instanceof Number || obj instanceof Boolean;
+        return JSType.isString(obj) || obj instanceof Number || obj instanceof Boolean;
     }
 
     /**
--- a/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,6 +26,7 @@
 package jdk.nashorn.internal.runtime;
 
 import java.security.CodeSource;
+import java.util.Objects;
 
 /**
  * Responsible for loading script generated classes.
@@ -69,8 +70,6 @@
      * @return Installed class.
      */
     synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) {
-        // null check
-        cs.getClass();
-        return defineClass(name, data, 0, data.length, cs);
+        return defineClass(name, data, 0, data.length, Objects.requireNonNull(cs));
     }
 }
--- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,7 +28,6 @@
 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCall;
 import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
@@ -110,20 +109,17 @@
     /** Search fall back routine name for "no such property" */
     public static final String NO_SUCH_PROPERTY_NAME = "__noSuchProperty__";
 
-    /** Per ScriptObject flag - is this a scope object? */
-    public static final int IS_SCOPE       = 1 << 0;
-
     /** Per ScriptObject flag - is this an array object? */
-    public static final int IS_ARRAY       = 1 << 1;
+    public static final int IS_ARRAY               = 1 << 0;
 
     /** Per ScriptObject flag - is this an arguments object? */
-    public static final int IS_ARGUMENTS   = 1 << 2;
+    public static final int IS_ARGUMENTS           = 1 << 1;
 
     /** Is length property not-writable? */
-    public static final int IS_LENGTH_NOT_WRITABLE = 1 << 3;
+    public static final int IS_LENGTH_NOT_WRITABLE = 1 << 2;
 
     /** Is this a builtin object? */
-    public static final int IS_BUILTIN = 1 << 4;
+    public static final int IS_BUILTIN             = 1 << 3;
 
     /**
      * Spill growth rate - by how many elements does {@link ScriptObject#primitiveSpill} and
@@ -146,12 +142,6 @@
     /** Area for reference properties added to object after instantiation, see {@link AccessorProperty} */
     protected Object[] objectSpill;
 
-    /**
-     * Number of elements in the spill. This may be less than the spill array lengths, if not all of
-     * the allocated memory is in use
-     */
-    private int spillLength;
-
     /** Indexed array data. */
     private ArrayData arrayData;
 
@@ -171,12 +161,6 @@
     /** Method handle for getting the array data */
     public static final Call GET_ARRAY          = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArray", ArrayData.class);
 
-    /** Method handle for getting the property map - debugging purposes */
-    public static final Call GET_MAP            = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getMap", PropertyMap.class);
-
-    /** Method handle for setting the array data */
-    public static final Call SET_ARRAY          = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setArray", void.class, ArrayData.class);
-
     /** Method handle for getting a function argument at a given index. Used from MapCreator */
     public static final Call GET_ARGUMENT       = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArgument", Object.class, int.class);
 
@@ -259,8 +243,7 @@
         this(map);
         this.primitiveSpill = primitiveSpill;
         this.objectSpill    = objectSpill;
-        assert primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size";
-        this.spillLength = spillAllocationLength(primitiveSpill.length);
+        assert primitiveSpill == null || primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size";
     }
 
     /**
@@ -410,14 +393,6 @@
     }
 
     /**
-     * ECMA 8.10.3 IsGenericDescriptor ( Desc )
-     * @return true if this has a descriptor describing an {@link AccessorPropertyDescriptor} or {@link DataPropertyDescriptor}
-     */
-    public final boolean isGenericDescriptor() {
-        return isAccessorDescriptor() || isDataDescriptor();
-    }
-
-    /**
       * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
       *
       * @return property descriptor
@@ -722,8 +697,12 @@
     public void defineOwnProperty(final int index, final Object value) {
         assert isValidArrayIndex(index) : "invalid array index";
         final long longIndex = ArrayIndex.toLongIndex(index);
-        doesNotHaveEnsureDelete(longIndex, getArray().length(), false);
-        setArray(getArray().ensure(longIndex).set(index,value, false));
+        final long oldLength = getArray().length();
+        if (longIndex >= oldLength) {
+            setArray(getArray().ensure(longIndex));
+            doesNotHaveEnsureDelete(longIndex, oldLength, false);
+        }
+        setArray(getArray().set(index, value, false));
     }
 
     private void checkIntegerKey(final String key) {
@@ -808,7 +787,7 @@
      *
      * @return FindPropertyData or null if not found.
      */
-    FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+    protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
 
         final PropertyMap selfMap  = getMap();
         final Property    property = selfMap.findProperty(key);
@@ -972,10 +951,10 @@
      * @param setter        setter for {@link UserAccessorProperty}, null if not present or N/A
      */
     protected final void initUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
-        final int slot = spillLength;
-        ensureSpillSize(spillLength); //arguments=slot0, caller=slot0
+        final PropertyMap oldMap = getMap();
+        final int slot = oldMap.getFreeSpillSlot();
+        ensureSpillSize(slot);
         objectSpill[slot] = new UserAccessorProperty.Accessors(getter, setter);
-        final PropertyMap oldMap = getMap();
         Property    newProperty;
         PropertyMap newMap;
         do {
@@ -1002,19 +981,12 @@
             final int slot = uc.getSlot();
 
             assert uc.getLocalType() == Object.class;
-            if (slot >= spillLength) {
-                uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
-            } else {
-                final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes
-                if (gs == null) {
-                    uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
-                } else {
-                    //reuse existing getter setter for speed
-                    gs.set(getter, setter);
-                    if (uc.getFlags() == propertyFlags) {
-                        return oldProperty;
-                    }
-                }
+            final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes
+            assert gs != null;
+            //reuse existing getter setter for speed
+            gs.set(getter, setter);
+            if (uc.getFlags() == propertyFlags) {
+                return oldProperty;
             }
             newProperty = new UserAccessorProperty(uc.getKey(), propertyFlags, slot);
         } else {
@@ -1647,23 +1619,12 @@
         return getMap().isFrozen();
     }
 
-
-    /**
-     * Flag this ScriptObject as scope
-     */
-    public final void setIsScope() {
-        if (Context.DEBUG) {
-            scopeCount++;
-        }
-        flags |= IS_SCOPE;
-    }
-
     /**
      * Check whether this ScriptObject is scope
      * @return true if scope
      */
-    public final boolean isScope() {
-        return (flags & IS_SCOPE) != 0;
+    public boolean isScope() {
+        return false;
     }
 
     /**
@@ -1938,14 +1899,7 @@
      * Test whether this object contains in its prototype chain or is itself a with-object.
      * @return true if a with-object was found
      */
-    final boolean hasWithScope() {
-        if (isScope()) {
-            for (ScriptObject obj = this; obj != null; obj = obj.getProto()) {
-                if (obj instanceof WithObject) {
-                    return true;
-                }
-            }
-        }
+    boolean hasWithScope() {
         return false;
     }
 
@@ -2049,8 +2003,6 @@
             protoSwitchPoint = null;
         }
 
-        assert OBJECT_FIELDS_ONLY || guard != null : "we always need a map guard here";
-
         final GuardedInvocation inv = new GuardedInvocation(mh, guard, protoSwitchPoint, exception);
         return inv.addSwitchPoint(findBuiltinSwitchPoint(name));
     }
@@ -2527,13 +2479,14 @@
 
     /**
      * Add a spill property for the given key.
-     * @param key           Property key.
-     * @param propertyFlags Property flags.
+     * @param key    Property key.
+     * @param flags  Property flags.
      * @return Added property.
      */
-    private Property addSpillProperty(final String key, final int propertyFlags, final Object value, final boolean hasInitialValue) {
+    private Property addSpillProperty(final String key, final int flags, final Object value, final boolean hasInitialValue) {
         final PropertyMap propertyMap = getMap();
         final int fieldSlot  = propertyMap.getFreeFieldSlot();
+        final int propertyFlags = flags | (useDualFields() ? Property.DUAL_FIELDS : 0);
 
         Property property;
         if (fieldSlot > -1) {
@@ -2558,7 +2511,7 @@
      * @return Setter method handle.
      */
     MethodHandle addSpill(final Class<?> type, final String key) {
-        return addSpillProperty(key, 0, null, false).getSetter(OBJECT_FIELDS_ONLY ? Object.class : type, getMap());
+        return addSpillProperty(key, 0, null, false).getSetter(type, getMap());
     }
 
     /**
@@ -2600,7 +2553,7 @@
         final int callCount      = callType.parameterCount();
 
         final boolean isCalleeVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray();
-        final boolean isCallerVarArg = callerVarArg != null ? callerVarArg.booleanValue() : callCount > 0 &&
+        final boolean isCallerVarArg = callerVarArg != null ? callerVarArg : callCount > 0 &&
                 callType.parameterType(callCount - 1).isArray();
 
         if (isCalleeVarArg) {
@@ -2645,9 +2598,9 @@
         final int spreadArgs = mh.type().parameterCount() - callSiteParamCount + 1;
         return MH.filterArguments(
             MH.asSpreader(
-            mh,
-            Object[].class,
-            spreadArgs),
+                mh,
+                Object[].class,
+                spreadArgs),
             callSiteParamCount - 1,
             MH.insertArguments(
                 TRUNCATINGFILTER,
@@ -3735,24 +3688,32 @@
         return uc;
     }
 
+    /**
+     * Returns {@code true} if properties for this object should use dual field mode, {@code false} otherwise.
+     * @return {@code true} if dual fields should be used.
+     */
+    protected boolean useDualFields() {
+        return !StructureLoader.isSingleFieldStructure(getClass().getName());
+    }
+
     Object ensureSpillSize(final int slot) {
-        if (slot < spillLength) {
+        final int oldLength = objectSpill == null ? 0 : objectSpill.length;
+        if (slot < oldLength) {
             return this;
         }
         final int newLength = alignUp(slot + 1, SPILL_RATE);
         final Object[] newObjectSpill    = new Object[newLength];
-        final long[]   newPrimitiveSpill = OBJECT_FIELDS_ONLY ? null : new long[newLength];
+        final long[]   newPrimitiveSpill = useDualFields() ? new long[newLength] : null;
 
         if (objectSpill != null) {
-            System.arraycopy(objectSpill, 0, newObjectSpill, 0, spillLength);
-            if (!OBJECT_FIELDS_ONLY) {
-                System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, spillLength);
+            System.arraycopy(objectSpill, 0, newObjectSpill, 0, oldLength);
+            if (primitiveSpill != null && newPrimitiveSpill != null) {
+                System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, oldLength);
             }
         }
 
         this.primitiveSpill = newPrimitiveSpill;
         this.objectSpill    = newObjectSpill;
-        this.spillLength = newLength;
 
         return this;
     }
@@ -3827,9 +3788,6 @@
     /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created */
     private static int count;
 
-    /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */
-    private static int scopeCount;
-
     /**
      * Get number of {@code ScriptObject} instances created. If not running in debug
      * mode this is always 0
@@ -3839,15 +3797,4 @@
     public static int getCount() {
         return count;
     }
-
-    /**
-     * Get number of scope {@code ScriptObject} instances created. If not running in debug
-     * mode this is always 0
-     *
-     * @return number of scope ScriptObjects created
-     */
-    public static int getScopeCount() {
-        return scopeCount;
-    }
-
 }
--- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Fri Nov 13 15:38:44 2015 -0800
@@ -32,6 +32,8 @@
 import static jdk.nashorn.internal.runtime.ECMAErrors.syntaxError;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.JSType.isRepresentableAsInt;
+import static jdk.nashorn.internal.runtime.JSType.isString;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.SwitchPoint;
@@ -55,7 +57,6 @@
 import jdk.nashorn.internal.parser.Lexer;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
 
-
 /**
  * Utilities to be called by JavaScript runtime API and generated classes.
  */
@@ -114,6 +115,11 @@
     public static final Call THROW_REFERENCE_ERROR = staticCall(MethodHandles.lookup(), ScriptRuntime.class, "throwReferenceError", void.class, String.class);
 
     /**
+     * Throws a reference error for an undefined variable.
+     */
+    public static final Call THROW_CONST_TYPE_ERROR = staticCall(MethodHandles.lookup(), ScriptRuntime.class, "throwConstTypeError", void.class, String.class);
+
+    /**
      * Used to invalidate builtin names, e.g "Function" mapping to all properties in Function.prototype and Function.prototype itself.
      */
     public static final Call INVALIDATE_RESERVED_BUILTIN_NAME = staticCallNoLookup(ScriptRuntime.class, "invalidateReservedBuiltinName", void.class, String.class);
@@ -367,9 +373,9 @@
      * @return prototype object after merge
      */
     public static ScriptObject mergeScope(final ScriptObject scope) {
-        final ScriptObject global = scope.getProto();
-        global.addBoundProperties(scope);
-        return global;
+        final ScriptObject parentScope = scope.getProto();
+        parentScope.addBoundProperties(scope);
+        return parentScope;
     }
 
     /**
@@ -402,6 +408,15 @@
     }
 
     /**
+     * Throws a type error for an assignment to a const.
+     *
+     * @param name the const name
+     */
+    public static void throwConstTypeError(final String name) {
+        throw typeError("assign.constant", name);
+    }
+
+    /**
      * Call a script function as a constructor with given args.
      *
      * @param target ScriptFunction object.
@@ -521,8 +536,6 @@
 
     /**
      * ECMA 11.6.1 - The addition operator (+) - generic implementation
-     * Compiler specializes using {@link jdk.nashorn.internal.codegen.RuntimeCallSite}
-     * if any type information is available for any of the operands
      *
      * @param x  first term
      * @param y  second term
@@ -549,8 +562,7 @@
         final Object xPrim = JSType.toPrimitive(x);
         final Object yPrim = JSType.toPrimitive(y);
 
-        if (xPrim instanceof String || yPrim instanceof String
-                || xPrim instanceof ConsString || yPrim instanceof ConsString) {
+        if (isString(xPrim) || isString(yPrim)) {
             try {
                 return new ConsString(JSType.toCharSequence(xPrim), JSType.toCharSequence(yPrim));
             } catch (final IllegalArgumentException iae) {
@@ -720,7 +732,7 @@
             return true;
         }
         if (x instanceof ScriptObject && y instanceof ScriptObject) {
-            return x == y;
+            return false; // x != y
         }
         if (x instanceof ScriptObjectMirror || y instanceof ScriptObjectMirror) {
             return ScriptObjectMirror.identical(x, y);
@@ -784,37 +796,55 @@
      * @return true if they're equal
      */
     private static boolean equalDifferentTypeValues(final Object x, final Object y, final JSType xType, final JSType yType) {
-        if (xType == JSType.UNDEFINED && yType == JSType.NULL || xType == JSType.NULL && yType == JSType.UNDEFINED) {
+        if (isUndefinedAndNull(xType, yType) || isUndefinedAndNull(yType, xType)) {
             return true;
-        }
-
-        if (xType == JSType.NUMBER && yType == JSType.STRING) {
-            return equals(x, JSType.toNumber(y));
-        }
-
-        if (xType == JSType.STRING && yType == JSType.NUMBER) {
-            return equals(JSType.toNumber(x), y);
-        }
-
-        if (xType == JSType.BOOLEAN) {
-            return equals(JSType.toNumber(x), y);
-        }
-
-        if (yType == JSType.BOOLEAN) {
-            return equals(x, JSType.toNumber(y));
-        }
-
-        if ((xType == JSType.STRING || xType == JSType.NUMBER) && y instanceof ScriptObject)  {
-            return equals(x, JSType.toPrimitive(y));
-        }
-
-        if (x instanceof ScriptObject && (yType == JSType.STRING || yType == JSType.NUMBER)) {
-            return equals(JSType.toPrimitive(x), y);
+        } else if (isNumberAndString(xType, yType)) {
+            return equalNumberToString(x, y);
+        } else if (isNumberAndString(yType, xType)) {
+            // Can reverse order as both are primitives
+            return equalNumberToString(y, x);
+        } else if (xType == JSType.BOOLEAN) {
+            return equalBooleanToAny(x, y);
+        } else if (yType == JSType.BOOLEAN) {
+            // Can reverse order as y is primitive
+            return equalBooleanToAny(y, x);
+        } else if (isNumberOrStringAndObject(xType, yType)) {
+            return equalNumberOrStringToObject(x, y);
+        } else if (isNumberOrStringAndObject(yType, xType)) {
+            // Can reverse order as y is primitive
+            return equalNumberOrStringToObject(y, x);
         }
 
         return false;
     }
 
+    private static boolean isUndefinedAndNull(final JSType xType, final JSType yType) {
+        return xType == JSType.UNDEFINED && yType == JSType.NULL;
+    }
+
+    private static boolean isNumberAndString(final JSType xType, final JSType yType) {
+        return xType == JSType.NUMBER && yType == JSType.STRING;
+    }
+
+    private static boolean isNumberOrStringAndObject(final JSType xType, final JSType yType) {
+        return (xType == JSType.NUMBER || xType == JSType.STRING) && yType == JSType.OBJECT;
+    }
+
+    private static boolean equalNumberToString(final Object num, final Object str) {
+        // Specification says comparing a number to string should be done as "equals(num, JSType.toNumber(str))". We
+        // can short circuit it to this as we know that "num" is a number, so it'll end up being a number-number
+        // comparison.
+        return ((Number)num).doubleValue() == JSType.toNumber(str.toString());
+    }
+
+    private static boolean equalBooleanToAny(final Object bool, final Object any) {
+        return equals(JSType.toNumber((Boolean)bool), any);
+    }
+
+    private static boolean equalNumberOrStringToObject(final Object numOrStr, final Object any) {
+        return equals(numOrStr, JSType.toPrimitive(any));
+    }
+
     /**
      * ECMA 11.9.4 - The strict equal operator (===) - generic implementation
      *
@@ -921,8 +951,15 @@
      * @return true if x is less than y
      */
     public static boolean LT(final Object x, final Object y) {
-        final Object value = lessThan(x, y, true);
-        return value == UNDEFINED ? false : (Boolean)value;
+        final Object px = JSType.toPrimitive(x, Number.class);
+        final Object py = JSType.toPrimitive(y, Number.class);
+
+        return areBothString(px, py) ? px.toString().compareTo(py.toString()) < 0 :
+            JSType.toNumber(px) < JSType.toNumber(py);
+    }
+
+    private static boolean areBothString(final Object x, final Object y) {
+        return isString(x) && isString(y);
     }
 
     /**
@@ -934,8 +971,11 @@
      * @return true if x is greater than y
      */
     public static boolean GT(final Object x, final Object y) {
-        final Object value = lessThan(y, x, false);
-        return value == UNDEFINED ? false : (Boolean)value;
+        final Object px = JSType.toPrimitive(x, Number.class);
+        final Object py = JSType.toPrimitive(y, Number.class);
+
+        return areBothString(px, py) ? px.toString().compareTo(py.toString()) > 0 :
+            JSType.toNumber(px) > JSType.toNumber(py);
     }
 
     /**
@@ -947,8 +987,11 @@
      * @return true if x is less than or equal to y
      */
     public static boolean LE(final Object x, final Object y) {
-        final Object value = lessThan(y, x, false);
-        return !(Boolean.TRUE.equals(value) || value == UNDEFINED);
+        final Object px = JSType.toPrimitive(x, Number.class);
+        final Object py = JSType.toPrimitive(y, Number.class);
+
+        return areBothString(px, py) ? px.toString().compareTo(py.toString()) <= 0 :
+            JSType.toNumber(px) <= JSType.toNumber(py);
     }
 
     /**
@@ -960,48 +1003,11 @@
      * @return true if x is greater than or equal to y
      */
     public static boolean GE(final Object x, final Object y) {
-        final Object value = lessThan(x, y, true);
-        return !(Boolean.TRUE.equals(value) || value == UNDEFINED);
-    }
-
-    /** ECMA 11.8.5 The Abstract Relational Comparison Algorithm */
-    private static Object lessThan(final Object x, final Object y, final boolean leftFirst) {
-        Object px, py;
-
-        //support e.g. x < y should throw exception correctly if x or y are not numeric
-        if (leftFirst) {
-            px = JSType.toPrimitive(x, Number.class);
-            py = JSType.toPrimitive(y, Number.class);
-        } else {
-            py = JSType.toPrimitive(y, Number.class);
-            px = JSType.toPrimitive(x, Number.class);
-        }
+        final Object px = JSType.toPrimitive(x, Number.class);
+        final Object py = JSType.toPrimitive(y, Number.class);
 
-        if (JSType.ofNoFunction(px) == JSType.STRING && JSType.ofNoFunction(py) == JSType.STRING) {
-            // May be String or ConsString
-            return px.toString().compareTo(py.toString()) < 0;
-        }
-
-        final double nx = JSType.toNumber(px);
-        final double ny = JSType.toNumber(py);
-
-        if (Double.isNaN(nx) || Double.isNaN(ny)) {
-            return UNDEFINED;
-        }
-
-        if (nx == ny) {
-            return false;
-        }
-
-        if (nx > 0 && ny > 0 && Double.isInfinite(nx) && Double.isInfinite(ny)) {
-            return false;
-        }
-
-        if (nx < 0 && ny < 0 && Double.isInfinite(nx) && Double.isInfinite(ny)) {
-            return false;
-        }
-
-        return nx < ny;
+        return areBothString(px, py) ? px.toString().compareTo(py.toString()) >= 0 :
+            JSType.toNumber(px) >= JSType.toNumber(py);
     }
 
     /**
@@ -1014,9 +1020,7 @@
         final Context context = Context.getContextTrusted();
         final SwitchPoint sp = context.getBuiltinSwitchPoint(name);
         assert sp != null;
-        if (sp != null) {
-            context.getLogger(ApplySpecialization.class).info("Overwrote special name '" + name +"' - invalidating switchpoint");
-            SwitchPoint.invalidateAll(new SwitchPoint[] { sp });
-        }
+        context.getLogger(ApplySpecialization.class).info("Overwrote special name '" + name +"' - invalidating switchpoint");
+        SwitchPoint.invalidateAll(new SwitchPoint[] { sp });
     }
 }
--- a/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,15 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
-import java.util.StringTokenizer;
+import jdk.nashorn.internal.objects.NativeArray;
 
 /**
  * Global functions supported only in scripting mode.
@@ -51,7 +56,7 @@
     public static final MethodHandle READFULLY = findOwnMH("readFully",     Object.class, Object.class, Object.class);
 
     /** Handle to implementation of {@link ScriptingFunctions#exec} - Nashorn extension */
-    public static final MethodHandle EXEC = findOwnMH("exec",     Object.class, Object.class, Object.class, Object.class);
+    public static final MethodHandle EXEC = findOwnMH("exec",     Object.class, Object.class, Object[].class);
 
     /** EXEC name - special property used by $EXEC API. */
     public static final String EXEC_NAME = "$EXEC";
@@ -68,7 +73,8 @@
     /** Names of special properties used by $ENV API. */
     public  static final String ENV_NAME  = "$ENV";
 
-    private static final String PWD_NAME  = "PWD";
+    /** Name of the environment variable for the current working directory. */
+    public static final String PWD_NAME  = "PWD";
 
     private ScriptingFunctions() {
     }
@@ -107,7 +113,7 @@
 
         if (file instanceof File) {
             f = (File)file;
-        } else if (file instanceof String || file instanceof ConsString) {
+        } else if (JSType.isString(file)) {
             f = new java.io.File(((CharSequence)file).toString());
         }
 
@@ -122,26 +128,32 @@
      * Nashorn extension: exec a string in a separate process.
      *
      * @param self   self reference
-     * @param string string to execute
-     * @param input  input
+     * @param args   string to execute, input and additional arguments, to be appended to {@code string}. Additional arguments can be passed as
+     *               either one JavaScript array, whose elements will be converted to strings; or as a sequence of
+     *               varargs, each of which will be converted to a string.
      *
      * @return output string from the request
+     *
      * @throws IOException           if any stream access fails
      * @throws InterruptedException  if execution is interrupted
      */
-    public static Object exec(final Object self, final Object string, final Object input) throws IOException, InterruptedException {
+    public static Object exec(final Object self, final Object... args) throws IOException, InterruptedException {
         // Current global is need to fetch additional inputs and for additional results.
         final ScriptObject global = Context.getGlobal();
-
-        // Break exec string into tokens.
-        final StringTokenizer tokenizer = new StringTokenizer(JSType.toString(string));
-        final String[] cmdArray = new String[tokenizer.countTokens()];
-        for (int i = 0; tokenizer.hasMoreTokens(); i++) {
-            cmdArray[i] = tokenizer.nextToken();
+        final Object string = args.length > 0? args[0] : UNDEFINED;
+        final Object input = args.length > 1? args[1] : UNDEFINED;
+        final Object[] argv = (args.length > 2)? Arrays.copyOfRange(args, 2, args.length) : ScriptRuntime.EMPTY_ARRAY;
+        // Assemble command line, process additional arguments.
+        final List<String> cmdLine = tokenizeString(JSType.toString(string));
+        final Object[] additionalArgs = argv.length == 1 && argv[0] instanceof NativeArray ?
+                ((NativeArray) argv[0]).asObjectArray() :
+                argv;
+        for (Object arg : additionalArgs) {
+            cmdLine.add(JSType.toString(arg));
         }
 
         // Set up initial process.
-        final ProcessBuilder processBuilder = new ProcessBuilder(cmdArray);
+        final ProcessBuilder processBuilder = new ProcessBuilder(cmdLine);
 
         // Current ENV property state.
         final Object env = global.get(ENV_NAME);
@@ -239,4 +251,42 @@
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
         return MH.findStatic(MethodHandles.lookup(), ScriptingFunctions.class, name, MH.type(rtype, types));
     }
+
+    /**
+     * Break a string into tokens, honoring quoted arguments and escaped spaces.
+     *
+     * @param str a {@link String} to tokenize.
+     * @return a {@link List} of {@link String}s representing the tokens that
+     * constitute the string.
+     * @throws IOException in case {@link StreamTokenizer#nextToken()} raises it.
+     */
+    public static List<String> tokenizeString(final String str) throws IOException {
+        final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(str));
+        tokenizer.resetSyntax();
+        tokenizer.wordChars(0, 255);
+        tokenizer.whitespaceChars(0, ' ');
+        tokenizer.commentChar('#');
+        tokenizer.quoteChar('"');
+        tokenizer.quoteChar('\'');
+        final List<String> tokenList = new ArrayList<>();
+        final StringBuilder toAppend = new StringBuilder();
+        while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
+            final String s = tokenizer.sval;
+            // The tokenizer understands about honoring quoted strings and recognizes
+            // them as one token that possibly contains multiple space-separated words.
+            // It does not recognize quoted spaces, though, and will split after the
+            // escaping \ character. This is handled here.
+            if (s.endsWith("\\")) {
+                // omit trailing \, append space instead
+                toAppend.append(s.substring(0, s.length() - 1)).append(' ');
+            } else {
+                tokenList.add(toAppend.append(s).toString());
+                toAppend.setLength(0);
+            }
+        }
+        if (toAppend.length() != 0) {
+            tokenList.add(toAppend.toString());
+        }
+        return tokenList;
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -232,14 +232,18 @@
     }
 
     private SetMethod createNewFieldSetter(final SwitchPoint builtinSwitchPoint) {
-        return createNewSetter(new AccessorProperty(getName(), 0, sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint);
+        return createNewSetter(new AccessorProperty(getName(), getFlags(sobj), sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint);
     }
 
     private SetMethod createNewSpillPropertySetter(final SwitchPoint builtinSwitchPoint) {
-        return createNewSetter(new SpillProperty(getName(), 0, getMap().getFreeSpillSlot(), type), builtinSwitchPoint);
+        return createNewSetter(new SpillProperty(getName(), getFlags(sobj), getMap().getFreeSpillSlot(), type), builtinSwitchPoint);
     }
 
     private PropertyMap getNewMap(final Property property) {
         return getMap().addProperty(property);
     }
+
+    private static int getFlags(final ScriptObject scriptObject) {
+        return scriptObject.useDualFields() ? Property.DUAL_FIELDS : 0;
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/Source.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/Source.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,9 +28,11 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOError;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
 import java.io.Reader;
 import java.lang.ref.WeakReference;
 import java.net.MalformedURLException;
@@ -44,6 +46,7 @@
 import java.nio.file.Paths;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.Base64;
 import java.util.Objects;
@@ -907,14 +910,16 @@
             start = 2;
             cs = StandardCharsets.UTF_16BE;
         } else if (bytes.length > 1 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE) {
-            start = 2;
-            cs = StandardCharsets.UTF_16LE;
+            if (bytes.length > 3 && bytes[2] == 0 && bytes[3] == 0) {
+                start = 4;
+                cs = Charset.forName("UTF-32LE");
+            } else {
+                start = 2;
+                cs = StandardCharsets.UTF_16LE;
+            }
         } else if (bytes.length > 2 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 0xBB && bytes[2] == (byte) 0xBF) {
             start = 3;
             cs = StandardCharsets.UTF_8;
-        } else if (bytes.length > 3 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE && bytes[2] == 0 && bytes[3] == 0) {
-            start = 4;
-            cs = Charset.forName("UTF-32LE");
         } else if (bytes.length > 3 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == (byte) 0xFE && bytes[3] == (byte) 0xFF) {
             start = 4;
             cs = Charset.forName("UTF-32BE");
@@ -965,4 +970,39 @@
     public DebugLogger getLogger() {
         return initLogger(Context.getContextTrusted());
     }
+
+    private File dumpFile(final String dir) {
+        final URL u = getURL();
+        final StringBuilder buf = new StringBuilder();
+        // make it unique by prefixing current date & time
+        buf.append(LocalDateTime.now().toString());
+        buf.append('_');
+        if (u != null) {
+            // make it a safe file name
+            buf.append(u.toString()
+                    .replace('/', '_')
+                    .replace('\\', '_'));
+        } else {
+            buf.append(getName());
+        }
+
+        return new File(dir, buf.toString());
+    }
+
+    void dump(final String dir) {
+        final File file = dumpFile(dir);
+        try (final FileOutputStream fos = new FileOutputStream(file)) {
+            final PrintWriter pw = new PrintWriter(fos);
+            pw.print(data.toString());
+            pw.flush();
+        } catch (final IOException ioExp) {
+            debug("Skipping source dump for " +
+                    name +
+                    ": " +
+                    ECMAErrors.getMessage(
+                        "io.error.cant.write",
+                        dir.toString() +
+                        " : " + ioExp.toString()));
+        }
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/SpillProperty.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/SpillProperty.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.runtime;
 
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 
 import java.lang.invoke.MethodHandle;
@@ -139,11 +138,11 @@
         }
     }
 
-    private static MethodHandle primitiveGetter(final int slot) {
-        return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, true);
+    private static MethodHandle primitiveGetter(final int slot, final int flags) {
+        return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, true) : null;
     }
-    private static MethodHandle primitiveSetter(final int slot) {
-        return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, false);
+    private static MethodHandle primitiveSetter(final int slot, final int flags) {
+        return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, false) : null;
     }
     private static MethodHandle objectGetter(final int slot) {
         return Accessors.getCached(slot, false, true);
@@ -160,13 +159,19 @@
      * @param slot   spill slot
      */
     public SpillProperty(final String key, final int flags, final int slot) {
-        super(key, flags, slot, primitiveGetter(slot), primitiveSetter(slot), objectGetter(slot), objectSetter(slot));
-        assert !OBJECT_FIELDS_ONLY || getLocalType() == Object.class;
+        super(key, flags, slot, primitiveGetter(slot, flags), primitiveSetter(slot, flags), objectGetter(slot), objectSetter(slot));
     }
 
-    SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
+    /**
+     * Constructor for spill properties with an initial type.
+     * @param key         the property key
+     * @param flags       the property flags
+     * @param slot        spill slot
+     * @param initialType initial type
+     */
+    public SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
         this(key, flags, slot);
-        setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+        setType(hasDualFields() ? initialType : Object.class);
     }
 
     SpillProperty(final String key, final int flags, final int slot, final ScriptObject owner, final Object initialValue) {
@@ -209,8 +214,8 @@
     @Override
     void initMethodHandles(final Class<?> structure) {
         final int slot  = getSlot();
-        primitiveGetter = primitiveGetter(slot);
-        primitiveSetter = primitiveSetter(slot);
+        primitiveGetter = primitiveGetter(slot, getFlags());
+        primitiveSetter = primitiveSetter(slot, getFlags());
         objectGetter    = objectGetter(slot);
         objectSetter    = objectSetter(slot);
     }
--- a/src/jdk/nashorn/internal/runtime/StoredScript.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/StoredScript.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,7 @@
 
 import java.io.Serializable;
 import java.util.Arrays;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -58,7 +58,7 @@
      * @param compilationId compilation id
      * @param mainClassName main class name
      * @param classBytes map of class names to class bytes
-     * @param initializers initializer map, id -> FunctionInitializer
+     * @param initializers initializer map, id -&gt; FunctionInitializer
      * @param constants constants array
      */
     public StoredScript(final int compilationId, final String mainClassName, final Map<String, byte[]> classBytes, final Map<Integer, FunctionInitializer> initializers, final Object[] constants) {
@@ -77,44 +77,70 @@
         return compilationId;
     }
 
-    /**
-     * Returns the main class name.
-     * @return the main class name
-     */
-    public String getMainClassName() {
-        return mainClassName;
+    private Map<String, Class<?>> installClasses(final Source source, final CodeInstaller<ScriptEnvironment> installer) {
+        final Map<String, Class<?>> installedClasses = new HashMap<>();
+        final byte[]   mainClassBytes = classBytes.get(mainClassName);
+        final Class<?> mainClass      = installer.install(mainClassName, mainClassBytes);
+
+        installedClasses.put(mainClassName, mainClass);
+
+        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
+            final String className = entry.getKey();
+
+            if (!className.equals(mainClassName)) {
+                installedClasses.put(className, installer.install(className, entry.getValue()));
+            }
+        }
+
+        installer.initialize(installedClasses.values(), source, constants);
+        return installedClasses;
+    }
+
+    FunctionInitializer installFunction(final RecompilableScriptFunctionData data, final CodeInstaller<ScriptEnvironment> installer) {
+        final Map<String, Class<?>> installedClasses = installClasses(data.getSource(), installer);
+
+        assert initializers != null;
+        assert initializers.size() == 1;
+        final FunctionInitializer initializer = initializers.values().iterator().next();
+
+        for (int i = 0; i < constants.length; i++) {
+            if (constants[i] instanceof RecompilableScriptFunctionData) {
+                // replace deserialized function data with the ones we already have
+                final RecompilableScriptFunctionData newData = data.getScriptFunctionData(((RecompilableScriptFunctionData) constants[i]).getFunctionNodeId());
+                assert newData != null;
+                newData.initTransients(data.getSource(), installer);
+                constants[i] = newData;
+            }
+        }
+
+        initializer.setCode(installedClasses.get(initializer.getClassName()));
+        return initializer;
     }
 
     /**
-     * Returns a map of class names to class bytes.
-     * @return map of class bytes
-     */
-    public Map<String, byte[]> getClassBytes() {
-        final Map<String, byte[]> clonedMap = new LinkedHashMap<>();
-        for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) {
-            clonedMap.put(entry.getKey(), entry.getValue().clone());
-        }
-        return clonedMap;
-    }
-
-    /**
-     * Returns the constants array.
-     * @return constants array
+     * Install as script.
+     *
+     * @param source the source
+     * @param installer the installer
+     * @return main script class
      */
-    public Object[] getConstants() {
-        return constants.clone();
-    }
+    Class<?> installScript(final Source source, final CodeInstaller<ScriptEnvironment> installer) {
+
+        final Map<String, Class<?>> installedClasses = installClasses(source, installer);
 
-    /**
-     * Returns the function initializers map.
-     * @return The initializers map.
-     */
-    public Map<Integer, FunctionInitializer> getInitializers() {
-        final Map<Integer, FunctionInitializer> clonedMap = new LinkedHashMap<>();
-        for (final Map.Entry<Integer, FunctionInitializer> entry : initializers.entrySet()) {
-            clonedMap.put(entry.getKey(), new FunctionInitializer(entry.getValue()));
+        for (final Object constant : constants) {
+            if (constant instanceof RecompilableScriptFunctionData) {
+                final RecompilableScriptFunctionData data = (RecompilableScriptFunctionData) constant;
+                data.initTransients(source, installer);
+                final FunctionInitializer initializer = initializers.get(data.getFunctionNodeId());
+                if (initializer != null) {
+                    initializer.setCode(installedClasses.get(initializer.getClassName()));
+                    data.initializeCode(initializer);
+                }
+            }
         }
-        return clonedMap;
+
+        return installedClasses.get(mainClassName);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/runtime/StructureLoader.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/StructureLoader.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,7 +27,8 @@
 
 import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE;
 import static jdk.nashorn.internal.codegen.Compiler.binaryName;
-import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX;
 
 import java.security.ProtectionDomain;
 import jdk.nashorn.internal.codegen.ObjectClassGenerator;
@@ -36,7 +37,8 @@
  * Responsible for on the fly construction of structure classes.
  */
 final class StructureLoader extends NashornLoader {
-    private static final String JS_OBJECT_PREFIX_EXTERNAL = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_PREFIX.symbolName();
+    private static final String SINGLE_FIELD_PREFIX = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName();
+    private static final String DUAL_FIELD_PREFIX   = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_DUAL_FIELD_PREFIX.symbolName();
 
     /**
      * Constructor.
@@ -45,14 +47,39 @@
         super(parent);
     }
 
+    /**
+     * Returns true if the class name represents a structure object with dual primitive/object fields.
+     * @param name a class name
+     * @return true if a dual field structure class
+     */
+    private static boolean isDualFieldStructure(final String name) {
+        return name.startsWith(DUAL_FIELD_PREFIX);
+    }
+
+    /**
+     * Returns true if the class name represents a structure object with single object-only fields.
+     * @param name a class name
+     * @return true if a single field structure class
+     */
+    static boolean isSingleFieldStructure(final String name) {
+        return name.startsWith(SINGLE_FIELD_PREFIX);
+    }
+
+    /**
+     * Returns true if the class name represents a Nashorn structure object.
+     * @param name a class name
+     * @return true if a structure class
+     */
     static boolean isStructureClass(final String name) {
-        return name.startsWith(JS_OBJECT_PREFIX_EXTERNAL);
+        return isDualFieldStructure(name) || isSingleFieldStructure(name);
     }
 
     @Override
     protected Class<?> findClass(final String name) throws ClassNotFoundException {
-        if (isStructureClass(name)) {
-            return generateClass(name, name.substring(JS_OBJECT_PREFIX_EXTERNAL.length()));
+        if (isDualFieldStructure(name)) {
+            return generateClass(name, name.substring(DUAL_FIELD_PREFIX.length()), true);
+        } else if (isSingleFieldStructure(name)) {
+            return generateClass(name, name.substring(SINGLE_FIELD_PREFIX.length()), false);
         }
         return super.findClass(name);
     }
@@ -63,10 +90,10 @@
      * @param descriptor Layout descriptor.
      * @return Generated class.
      */
-    private Class<?> generateClass(final String name, final String descriptor) {
+    private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
         final Context context = Context.getContextTrusted();
 
-        final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
+        final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
         return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
     }
 }
--- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Fri Nov 13 15:38:44 2015 -0800
@@ -24,7 +24,6 @@
  */
 
 package jdk.nashorn.internal.runtime;
-
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
@@ -34,6 +33,7 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
+import java.util.concurrent.Callable;
 import jdk.nashorn.internal.lookup.Lookup;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
@@ -80,6 +80,15 @@
     private final static MethodHandle INVOKE_LONG_SETTER = findOwnMH_S("invokeLongSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, long.class);
     private final static MethodHandle INVOKE_NUMBER_SETTER = findOwnMH_S("invokeNumberSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, double.class);
 
+    private static final Object OBJECT_GETTER_INVOKER_KEY = new Object();
+    private static MethodHandle getObjectGetterInvoker() {
+        return Context.getGlobal().getDynamicInvoker(OBJECT_GETTER_INVOKER_KEY, new Callable<MethodHandle>() {
+            @Override
+            public MethodHandle call() throws Exception {
+                return getINVOKE_UA_GETTER(Object.class, INVALID_PROGRAM_POINT);
+            }
+        });
+    }
 
     static MethodHandle getINVOKE_UA_GETTER(final Class<?> returnType, final int programPoint) {
         if (UnwarrantedOptimismException.isValid(programPoint)) {
@@ -90,6 +99,16 @@
         }
     }
 
+    private static final Object OBJECT_SETTER_INVOKER_KEY = new Object();
+    private static MethodHandle getObjectSetterInvoker() {
+        return Context.getGlobal().getDynamicInvoker(OBJECT_SETTER_INVOKER_KEY, new Callable<MethodHandle>() {
+            @Override
+            public MethodHandle call() throws Exception {
+                return getINVOKE_UA_SETTER(Object.class);
+            }
+        });
+    }
+
     static MethodHandle getINVOKE_UA_SETTER(final Class<?> valueType) {
         return Bootstrap.createDynamicInvoker("dyn:call", void.class, Object.class, Object.class, valueType);
     }
@@ -181,7 +200,7 @@
     @Override
     public Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
         try {
-            return invokeObjectGetter(getAccessors((owner != null) ? owner : self), getINVOKE_UA_GETTER(Object.class, INVALID_PROGRAM_POINT), self);
+            return invokeObjectGetter(getAccessors((owner != null) ? owner : self), getObjectGetterInvoker(), self);
         } catch (final Error | RuntimeException t) {
             throw t;
         } catch (final Throwable t) {
@@ -207,7 +226,7 @@
     @Override
     public void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) {
         try {
-            invokeObjectSetter(getAccessors((owner != null) ? owner : self), getINVOKE_UA_SETTER(Object.class), strict ? getKey() : null, self, value);
+            invokeObjectSetter(getAccessors((owner != null) ? owner : self), getObjectSetterInvoker(), strict ? getKey() : null, self, value);
         } catch (final Error | RuntimeException t) {
             throw t;
         } catch (final Throwable t) {
--- a/src/jdk/nashorn/internal/runtime/WithObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/WithObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -44,7 +44,7 @@
  * This class supports the handling of scope in a with body.
  *
  */
-public final class WithObject extends ScriptObject implements Scope {
+public final class WithObject extends Scope {
     private static final MethodHandle WITHEXPRESSIONGUARD    = findOwnMH("withExpressionGuard",  boolean.class, Object.class, PropertyMap.class, SwitchPoint.class);
     private static final MethodHandle WITHEXPRESSIONFILTER   = findOwnMH("withFilterExpression", Object.class, Object.class);
     private static final MethodHandle WITHSCOPEFILTER        = findOwnMH("withFilterScope",      Object.class, Object.class);
@@ -62,7 +62,6 @@
      */
     WithObject(final ScriptObject scope, final ScriptObject expression) {
         super(scope, null);
-        setIsScope();
         this.expression = expression;
     }
 
@@ -198,7 +197,7 @@
      * @return FindPropertyData or null if not found.
      */
     @Override
-    FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+    protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
         // We call findProperty on 'expression' with 'expression' itself as start parameter.
         // This way in ScriptObject.setObject we can tell the property is from a 'with' expression
         // (as opposed from another non-scope object in the proto chain such as Object.prototype).
@@ -224,29 +223,33 @@
 
     @Override
     public void setSplitState(final int state) {
-        getNonWithParent().setSplitState(state);
+        ((Scope) getNonWithParent()).setSplitState(state);
     }
 
     @Override
     public int getSplitState() {
-        return getNonWithParent().getSplitState();
+        return ((Scope) getNonWithParent()).getSplitState();
+    }
+
+    @Override
+    public void addBoundProperties(final ScriptObject source, final Property[] properties) {
+        // Declared variables in nested eval go to first normal (non-with) parent scope.
+        getNonWithParent().addBoundProperties(source, properties);
     }
 
     /**
      * Get first parent scope that is not an instance of WithObject.
      */
-    private Scope getNonWithParent() {
-        ScriptObject proto = getParentScope();
+    private ScriptObject getNonWithParent() {
+        ScriptObject proto = getProto();
 
         while (proto != null && proto instanceof WithObject) {
-            proto = ((WithObject)proto).getParentScope();
+            proto = proto.getProto();
         }
 
-        assert proto instanceof Scope : "with scope without parent scope";
-        return (Scope) proto;
+        return proto;
     }
 
-
     private static GuardedInvocation fixReceiverType(final GuardedInvocation link, final MethodHandle filter) {
         // The receiver may be an Object or a ScriptObject.
         final MethodType invType = link.getInvocation().type();
@@ -380,14 +383,6 @@
         return expression;
     }
 
-    /**
-     * Get the parent scope for this {@code WithObject}
-     * @return the parent scope
-     */
-    public ScriptObject getParentScope() {
-        return getProto();
-    }
-
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
         return MH.findStatic(MethodHandles.lookup(), WithObject.class, name, MH.type(rtype, types));
     }
--- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,6 +26,7 @@
 package jdk.nashorn.internal.runtime.arrays;
 
 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Array;
@@ -117,7 +118,7 @@
                     return new SparseArrayData(this, safeIndex + 1);
                 }
                 //known to fit in int
-                return toRealArrayData((int)safeIndex).ensure(safeIndex);
+                return toRealArrayData((int)safeIndex);
            }
            return this;
         }
@@ -275,7 +276,7 @@
     /**
      * Align an array size up to the nearest array chunk size
      * @param size size required
-     * @return size given, always >= size
+     * @return size given, always &gt;= size
      */
     protected final static int alignUp(final int size) {
         return size + CHUNK_SIZE - 1 & ~(CHUNK_SIZE - 1);
@@ -496,7 +497,9 @@
     public abstract ArrayData shiftRight(final int by);
 
     /**
-     * Ensure that the given index exists and won't fail subsequent
+     * Ensure that the given index exists and won't fail in a subsequent access.
+     * If {@code safeIndex} is equal or greater than the current length the length is
+     * updated to {@code safeIndex + 1}.
      *
      * @param safeIndex the index to ensure wont go out of bounds
      * @return new array data (or same)
@@ -761,39 +764,6 @@
     }
 
     /**
-     * Push an array of items to the end of the array
-     *
-     * @param strict are we in strict mode
-     * @param item   the item
-     * @return new array data (or same)
-     */
-    public ArrayData push(final boolean strict, final double item) {
-        return push(strict, item);
-    }
-
-    /**
-     * Push an array of items to the end of the array
-     *
-     * @param strict are we in strict mode
-     * @param item   the item
-     * @return new array data (or same)
-     */
-    public ArrayData push(final boolean strict, final long item) {
-        return push(strict, item);
-    }
-
-    /**
-     * Push an array of items to the end of the array
-     *
-     * @param strict are we in strict mode
-     * @param item   the item
-     * @return new array data (or same)
-     */
-    public ArrayData push(final boolean strict, final int item) {
-        return push(strict, item);
-    }
-
-    /**
      * Pop an element from the end of the array
      *
      * @return the popped element
--- a/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -57,7 +57,7 @@
     }
 
     /**
-     * Check if we can put one more element at the end of this continous
+     * Check if we can put one more element at the end of this continuous
      * array without reallocating, or if we are overwriting an already
      * allocated element
      *
--- a/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,6 +26,7 @@
 package jdk.nashorn.internal.runtime.arrays;
 
 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.util.Arrays;
@@ -181,14 +182,13 @@
 
     @Override
     public ArrayData convert(final Class<?> type) {
-        if (type == Integer.class) {
+        if (type == Integer.class || type == Byte.class || type == Short.class) {
             return this;
         } else if (type == Long.class) {
             return convertToLong();
-        } else if (type == Double.class) {
+        } else if (type == Double.class || type == Float.class) {
             return convertToDouble();
         } else {
-            assert type == null || (!Number.class.isAssignableFrom(type) && !type.isPrimitive());
             return convertToObject();
         }
     }
@@ -220,7 +220,9 @@
             final int newLength = ArrayData.nextSize((int)safeIndex);
             array = Arrays.copyOf(array, newLength);
         }
-        setLength(safeIndex + 1);
+        if (safeIndex >= length()) {
+            setLength(safeIndex + 1);
+        }
         return this;
     }
 
@@ -343,17 +345,6 @@
     }
 
     @Override
-    public final ArrayData push(final boolean strict, final int item) {
-        final long      len     = length();
-        final ArrayData newData = ensure(len);
-        if (newData == this) {
-            array[(int)len] = item;
-            return this;
-        }
-        return newData.set((int)len, item, strict);
-    }
-
-    @Override
     public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException {
         final long oldLength = length();
         final long newLength = oldLength - removed + added;
--- a/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,6 +27,7 @@
 
 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.util.Arrays;
@@ -119,11 +120,11 @@
 
     @Override
     public ContinuousArrayData convert(final Class<?> type) {
-        if (type == Integer.class || type == Long.class) {
+        if (type == Integer.class || type == Long.class || type == Byte.class || type == Short.class) {
             return this;
         }
         final int len = (int)length();
-        if (type == Double.class) {
+        if (type == Double.class || type == Float.class) {
             return new NumberArrayData(toDoubleArray(), len);
         }
         return new ObjectArrayData(toObjectArray(false), len);
@@ -156,7 +157,9 @@
             final int newLength = ArrayData.nextSize((int)safeIndex);
             array = Arrays.copyOf(array, newLength);
         }
-        setLength(safeIndex + 1);
+        if (safeIndex >= length()) {
+            setLength(safeIndex + 1);
+        }
         return this;
     }
 
@@ -168,7 +171,8 @@
 
     @Override
     public ArrayData set(final int index, final Object value, final boolean strict) {
-        if (value instanceof Long || value instanceof Integer) {
+        if (value instanceof Long || value instanceof Integer ||
+            value instanceof Byte || value instanceof Short) {
             return set(index, ((Number)value).longValue(), strict);
         } else if (value == ScriptRuntime.UNDEFINED) {
             return new UndefinedArrayFilter(this).set(index, value, strict);
@@ -303,17 +307,6 @@
     }
 
     @Override
-    public final ArrayData push(final boolean strict, final long item) {
-        final long      len     = length();
-        final ArrayData newData = ensure(len);
-        if (newData == this) {
-            array[(int)len] = item;
-            return this;
-        }
-        return newData.set((int)len, item, strict);
-    }
-
-    @Override
     public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException {
         final long oldLength = length();
         final long newLength = oldLength - removed + added;
--- a/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,8 @@
 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall;
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
+
+import jdk.internal.dynalink.support.TypeUtilities;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.util.Arrays;
@@ -103,9 +105,14 @@
         return super.asArrayOfType(componentType);
     }
 
+    private static boolean canWiden(final Class<?> type) {
+        return TypeUtilities.isWrapperType(type) &&
+            type != Boolean.class && type != Character.class;
+    }
+
     @Override
     public ContinuousArrayData convert(final Class<?> type) {
-        if (type != Double.class && type != Integer.class && type != Long.class) {
+        if (! canWiden(type)) {
             final int len = (int)length();
             return new ObjectArrayData(toObjectArray(false), len);
         }
@@ -138,7 +145,9 @@
             final int newLength = ArrayData.nextSize((int)safeIndex);
             array = Arrays.copyOf(array, newLength); //todo fill with nan or never accessed?
         }
-        setLength(safeIndex + 1);
+        if (safeIndex >= length()) {
+            setLength(safeIndex + 1);
+        }
         return this;
 
     }
@@ -151,7 +160,7 @@
 
     @Override
     public ArrayData set(final int index, final Object value, final boolean strict) {
-        if (value instanceof Double || value instanceof Integer || value instanceof Long) {
+        if (value instanceof Double || (value != null && canWiden(value.getClass()))) {
             return set(index, ((Number)value).doubleValue(), strict);
         } else if (value == UNDEFINED) {
             return new UndefinedArrayFilter(this).set(index, value, strict);
@@ -277,17 +286,6 @@
     }
 
     @Override
-    public final ArrayData push(final boolean strict, final double item) {
-        final long      len     = length();
-        final ArrayData newData = ensure(len);
-        if (newData == this) {
-            array[(int)len] = item;
-            return this;
-        }
-        return newData.set((int)len, item, strict);
-    }
-
-    @Override
     public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException {
         final long oldLength = length();
         final long newLength = oldLength - removed + added;
--- a/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -123,7 +123,9 @@
             final int newLength = ArrayData.nextSize((int)safeIndex);
             array = Arrays.copyOf(array, newLength); //fill with undefined or OK? TODO
         }
-        setLength(safeIndex + 1);
+        if (safeIndex >= length()) {
+            setLength(safeIndex + 1);
+        }
         return this;
     }
 
--- a/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java	Fri Nov 13 15:38:44 2015 -0800
@@ -135,10 +135,17 @@
 
     @Override
     public ArrayData ensure(final long safeIndex) {
+        // Usually #ensure only needs to be called if safeIndex is greater or equal current length.
+        // SparseArrayData is an exception as an index smaller than our current length may still
+        // exceed the underlying ArrayData's capacity. Because of this, SparseArrayData invokes
+        // its ensure method internally in various places where other ArrayData subclasses don't,
+        // making it safe for outside uses to only call ensure(safeIndex) if safeIndex >= length.
         if (safeIndex < maxDenseLength && underlying.length() <= safeIndex) {
             underlying = underlying.ensure(safeIndex);
         }
-        setLength(Math.max(safeIndex + 1, length()));
+        if (safeIndex >= length()) {
+            setLength(safeIndex + 1);
+        }
         return this;
     }
 
--- a/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java	Fri Nov 13 15:38:44 2015 -0800
@@ -48,28 +48,25 @@
         ERROR_NO_ACCESSIBLE_CONSTRUCTOR,
         ERROR_MULTIPLE_SUPERCLASSES,
         ERROR_NO_COMMON_LOADER,
-        ERROR_FINAL_FINALIZER
+        ERROR_FINAL_FINALIZER,
+        ERROR_OTHER
     }
 
     static final AdaptationResult SUCCESSFUL_RESULT = new AdaptationResult(Outcome.SUCCESS, "");
 
     private final Outcome outcome;
-    private final String classList;
+    private final String[] messageArgs;
 
-    AdaptationResult(final Outcome outcome, final String classList) {
+    AdaptationResult(final Outcome outcome, final String... messageArgs) {
         this.outcome = outcome;
-        this.classList = classList;
+        this.messageArgs = messageArgs;
     }
 
     Outcome getOutcome() {
         return outcome;
     }
 
-    String getClassList() {
-        return classList;
-    }
-
     ECMAException typeError() {
-        return ECMAErrors.typeError("extend." + outcome, classList);
+        return ECMAErrors.typeError("extend." + outcome, messageArgs);
     }
 }
--- a/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Fri Nov 13 15:38:44 2015 -0800
@@ -48,7 +48,6 @@
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.codegen.ObjectClassGenerator;
-import jdk.nashorn.internal.codegen.RuntimeCallSite;
 import jdk.nashorn.internal.lookup.MethodHandleFactory;
 import jdk.nashorn.internal.lookup.MethodHandleFunctionality;
 import jdk.nashorn.internal.objects.ScriptFunctionImpl;
@@ -75,17 +74,16 @@
      * of object fields only, it is fine. However, with dual fields, in order to get
      * performance on benchmarks with a lot of object instantiation and then field
      * reassignment, it can take slightly more relinks to become stable with type
-     * changes swapping out an entire proprety map and making a map guard fail.
-     * Therefore the relink threshold is set to 16 for dual fields (now the default).
-     * This doesn't seem to have any other negative performance implication.
+     * changes swapping out an entire property map and making a map guard fail.
+     * Since we need to set this value statically it must work with possibly changing
+     * optimistic types and dual fields settings. A higher value does not seem to have
+     * any other negative performance implication when running with object-only fields,
+     * so we choose a higher value here.
      *
      * See for example octane.gbemu, run with --log=fields:warning to study
      * megamorphic behavior
      */
-    private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD =
-            ObjectClassGenerator.OBJECT_FIELDS_ONLY ?
-                     8 :
-                    16;
+    private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD = 16;
 
     // do not create me!!
     private Bootstrap() {
@@ -119,6 +117,7 @@
                 return unboxReturnType(target, newType);
             }
         });
+        factory.setInternalObjectsFilter(NashornBeansLinker.createHiddenObjectFilter());
         final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD);
         if (relinkThreshold > -1) {
             factory.setUnstableRelinkThreshold(relinkThreshold);
@@ -209,19 +208,6 @@
     }
 
     /**
-     * Bootstrapper for a specialized Runtime call
-     *
-     * @param lookup       lookup
-     * @param initialName  initial name for callsite
-     * @param type         method type for call site
-     *
-     * @return callsite for a runtime node
-     */
-    public static CallSite runtimeBootstrap(final MethodHandles.Lookup lookup, final String initialName, final MethodType type) {
-        return new RuntimeCallSite(type, initialName);
-    }
-
-    /**
      * Boostrapper for math calls that may overflow
      * @param lookup         lookup
      * @param name           name of operation
--- a/src/jdk/nashorn/internal/runtime/linker/BoundCallableLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/BoundCallableLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -99,7 +99,7 @@
         MethodType newMethodType = descriptor.getMethodType().changeParameterType(0, callable.getClass());
         if (isCall) {
             // R(callable.class, T1, ...) => R(callable.class, boundThis.class, ...)
-            newMethodType = newMethodType.changeParameterType(1, boundThis.getClass());
+            newMethodType = newMethodType.changeParameterType(1, boundThis == null? Object.class : boundThis.getClass());
         }
         // R(callable.class[, boundThis.class], T2, ...) => R(callable.class[, boundThis.class], boundArg0.class, ..., boundArgn.class, T2, ...)
         for(int i = boundArgs.length; i-- > 0;) {
--- a/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,11 +25,13 @@
 
 package jdk.nashorn.internal.runtime.linker;
 
+import static jdk.nashorn.internal.runtime.JSType.isString;
+import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_CALL;
 import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETMEMBER;
 import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETSLOT;
 import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETMEMBER;
 import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETSLOT;
-import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_CALL;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import jdk.internal.dynalink.CallSiteDescriptor;
@@ -110,20 +112,21 @@
     private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
         final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
         final int c = desc.getNameTokenCount();
+        GuardedInvocation inv;
+        try {
+            inv = nashornBeansLinker.getGuardedInvocation(request, linkerServices);
+        } catch (Throwable th) {
+            inv = null;
+        }
 
         switch (operator) {
             case "getProp":
             case "getElem":
             case "getMethod":
-                if (c > 2) {
-                    return findGetMethod(desc);
-                }
-            // For indexed get, we want GuardedInvocation from beans linker and pass it.
-            // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access.
-            return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
+                return c > 2? findGetMethod(desc, inv) : findGetIndexMethod(inv);
             case "setProp":
             case "setElem":
-                return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
+                return c > 2? findSetMethod(desc, inv) : findSetIndexMethod();
             case "call":
                 return findCallMethod(desc);
             default:
@@ -131,7 +134,10 @@
         }
     }
 
-    private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) {
+    private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) {
+        if (inv != null) {
+            return inv;
+        }
         final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
         final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name);
         return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
@@ -142,7 +148,10 @@
         return inv.replaceMethods(getter, inv.getGuard());
     }
 
-    private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc) {
+    private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) {
+        if (inv != null) {
+            return inv;
+        }
         final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2));
         return new GuardedInvocation(getter, IS_JSOBJECT_GUARD);
     }
@@ -170,12 +179,12 @@
             if (index > -1) {
                 return JSOBJECT_GETSLOT.invokeExact(jsobj, index);
             }
-        } else if (key instanceof String) {
-            final String name = (String)key;
+        } else if (isString(key)) {
+            final String name = key.toString();
             if (name.indexOf('(') != -1) {
-                return fallback.invokeExact(jsobj, key);
+                return fallback.invokeExact(jsobj, (Object) name);
             }
-            return JSOBJECT_GETMEMBER.invokeExact(jsobj, (String)key);
+            return JSOBJECT_GETMEMBER.invokeExact(jsobj, name);
         }
         return null;
     }
@@ -186,8 +195,8 @@
             JSOBJECT_SETSLOT.invokeExact(jsobj, (int)key, value);
         } else if (key instanceof Number) {
             JSOBJECT_SETSLOT.invokeExact(jsobj, getIndex((Number)key), value);
-        } else if (key instanceof String) {
-            JSOBJECT_SETMEMBER.invokeExact(jsobj, (String)key, value);
+        } else if (isString(key)) {
+            JSOBJECT_SETMEMBER.invokeExact(jsobj, key.toString(), value);
         }
     }
 
--- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,16 +25,14 @@
 
 package jdk.nashorn.internal.runtime.linker;
 
+import static jdk.nashorn.internal.runtime.JSType.isString;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.util.HashMap;
 import java.util.Map;
 import javax.script.Bindings;
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.linker.GuardedInvocation;
-import jdk.internal.dynalink.linker.GuardedTypeConversion;
-import jdk.internal.dynalink.linker.GuardingTypeConverterFactory;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.internal.dynalink.linker.LinkerServices;
 import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
@@ -48,7 +46,7 @@
  * A Dynalink linker to handle web browser built-in JS (DOM etc.) objects as well
  * as ScriptObjects from other Nashorn contexts.
  */
-final class JSObjectLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory {
+final class JSObjectLinker implements TypeBasedGuardingDynamicLinker {
     private final NashornBeansLinker nashornBeansLinker;
 
     JSObjectLinker(final NashornBeansLinker nashornBeansLinker) {
@@ -94,22 +92,6 @@
         return Bootstrap.asTypeSafeReturn(inv, linkerServices, desc);
     }
 
-    @Override
-    public GuardedTypeConversion convertToType(final Class<?> sourceType, final Class<?> targetType) throws Exception {
-        final boolean sourceIsAlwaysJSObject = JSObject.class.isAssignableFrom(sourceType);
-        if(!sourceIsAlwaysJSObject && !sourceType.isAssignableFrom(JSObject.class)) {
-            return null;
-        }
-
-        final MethodHandle converter = CONVERTERS.get(targetType);
-        if(converter == null) {
-            return null;
-        }
-
-        return new GuardedTypeConversion(new GuardedInvocation(converter, sourceIsAlwaysJSObject ? null : IS_JSOBJECT_GUARD).asType(MethodType.methodType(targetType, sourceType)), true);
-    }
-
-
     private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
         final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
         final int c = desc.getNameTokenCount();
@@ -185,11 +167,11 @@
             if (index > -1) {
                 return ((JSObject)jsobj).getSlot(index);
             }
-        } else if (key instanceof String) {
-            final String name = (String)key;
+        } else if (isString(key)) {
+            final String name = key.toString();
             // get with method name and signature. delegate it to beans linker!
             if (name.indexOf('(') != -1) {
-                return fallback.invokeExact(jsobj, key);
+                return fallback.invokeExact(jsobj, (Object) name);
             }
             return ((JSObject)jsobj).getMember(name);
         }
@@ -202,30 +184,11 @@
             ((JSObject)jsobj).setSlot((Integer)key, value);
         } else if (key instanceof Number) {
             ((JSObject)jsobj).setSlot(getIndex((Number)key), value);
-        } else if (key instanceof String) {
-            ((JSObject)jsobj).setMember((String)key, value);
+        } else if (isString(key)) {
+            ((JSObject)jsobj).setMember(key.toString(), value);
         }
     }
 
-    @SuppressWarnings("unused")
-    private static int toInt32(final JSObject obj) {
-        return JSType.toInt32(toNumber(obj));
-    }
-
-    @SuppressWarnings("unused")
-    private static long toLong(final JSObject obj) {
-        return JSType.toLong(toNumber(obj));
-    }
-
-    private static double toNumber(final JSObject obj) {
-        return obj == null ? 0 : obj.toNumber();
-    }
-
-    @SuppressWarnings("unused")
-    private static boolean toBoolean(final JSObject obj) {
-        return obj != null;
-    }
-
     private static int getIndex(final Number n) {
         final double value = n.doubleValue();
         return JSType.isRepresentableAsInt(value) ? (int)value : -1;
@@ -260,14 +223,6 @@
     private static final MethodHandle JSOBJECT_CALL_TO_APPLY = findOwnMH_S("callToApply", Object.class, MethodHandle.class, JSObject.class, Object.class, Object[].class);
     private static final MethodHandle JSOBJECT_NEW           = findJSObjectMH_V("newObject", Object.class, Object[].class);
 
-    private static final Map<Class<?>, MethodHandle> CONVERTERS = new HashMap<>();
-    static {
-        CONVERTERS.put(boolean.class, findOwnMH_S("toBoolean", boolean.class, JSObject.class));
-        CONVERTERS.put(int.class,     findOwnMH_S("toInt32", int.class, JSObject.class));
-        CONVERTERS.put(long.class,    findOwnMH_S("toLong", long.class, JSObject.class));
-        CONVERTERS.put(double.class,  findOwnMH_S("toNumber", double.class, JSObject.class));
-    }
-
     private static MethodHandle findJSObjectMH_V(final String name, final Class<?> rtype, final Class<?>... types) {
         return MH.findVirtual(MethodHandles.lookup(), JSObject.class, name, MH.type(rtype, types));
     }
--- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java	Fri Nov 13 15:38:44 2015 -0800
@@ -106,7 +106,9 @@
  * <li>
  * If the adapter being generated can have class-level overrides, constructors taking same arguments as the superclass
  * constructors are created. These constructors simply delegate to the superclass constructor. They are simply used to
- * create instances of the adapter class, with no instance-level overrides, as they don't have them.
+ * create instances of the adapter class, with no instance-level overrides, as they don't have them. If the original
+ * class' constructor was variable arity, the adapter constructor will also be variable arity. Protected constructors
+ * are exposed as public.
  * </li>
  * </ul>
  * </p><p>
@@ -190,7 +192,6 @@
     private static final int MAX_GENERATED_TYPE_NAME_LENGTH = 255;
 
     private static final String CLASS_INIT = "<clinit>";
-    static final String CONVERTER_INIT = "<converter-init>";
 
     // Method name prefix for invoking super-methods
     static final String SUPER_PREFIX = "super$";
@@ -494,7 +495,8 @@
         final Type[] argTypes = originalCtorType.getArgumentTypes();
 
         // All constructors must be public, even if in the superclass they were protected.
-        final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT,
+        final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC |
+                (ctor.isVarArgs() ? ACC_VARARGS : 0), INIT,
                 Type.getMethodDescriptor(originalCtorType.getReturnType(), argTypes), null, null));
 
         mv.visitCode();
@@ -543,7 +545,8 @@
         System.arraycopy(originalArgTypes, 0, newArgTypes, 0, argLen);
 
         // All constructors must be public, even if in the superclass they were protected.
-        // Existing super constructor <init>(this, args...) triggers generating <init>(this, scriptObj, args...).
+        // Existing super constructor <init>(this, args...) triggers generating <init>(this, args..., scriptObj).
+        // Any variable arity constructors become fixed-arity with explicit array arguments.
         final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT,
                 Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null));
 
@@ -593,7 +596,7 @@
         if (! fromFunction) {
             newArgTypes[argLen] = OBJECT_TYPE;
             final InstructionAdapter mv2 = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, INIT,
-                Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null));
+                    Type.getMethodDescriptor(originalCtorType.getReturnType(), newArgTypes), null, null));
             generateOverridingConstructorWithObjectParam(mv2, ctor, originalCtorType.getDescriptor());
         }
     }
--- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,23 +54,28 @@
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
- * <p>A factory class that generates adapter classes. Adapter classes allow implementation of Java interfaces and
- * extending of Java classes from JavaScript. For every combination of a superclass to extend and interfaces to
- * implement (collectively: "original types"), exactly one adapter class is generated that extends the specified
- * superclass and implements the specified interfaces. (But see the discussion of class-based overrides for exceptions.)
- * </p><p>
- * The adapter class is generated in a new secure class loader that inherits Nashorn's protection domain, and has either
- * one of the original types' class loader or the Nashorn's class loader as its parent - the parent class loader
- * is chosen so that all the original types and the Nashorn core classes are visible from it (as the adapter will have
- * constant pool references to ScriptObject and ScriptFunction classes). In case none of the candidate class loaders has
- * visibility of all the required types, an error is thrown. The class uses {@link JavaAdapterBytecodeGenerator} to
- * generate the adapter class itself; see its documentation for details about the generated class.
- * </p><p>
- * You normally don't use this class directly, but rather either create adapters from script using
- * {@link jdk.nashorn.internal.objects.NativeJava#extend(Object, Object...)}, using the {@code new} operator on abstract classes and interfaces (see
- * {@link jdk.nashorn.internal.objects.NativeJava#type(Object, Object)}), or implicitly when passing script functions to Java methods expecting SAM
- * types.
- * </p>
+ * A factory class that generates adapter classes. Adapter classes allow
+ * implementation of Java interfaces and extending of Java classes from
+ * JavaScript. For every combination of a superclass to extend and interfaces to
+ * implement (collectively: "original types"), exactly one adapter class is
+ * generated that extends the specified superclass and implements the specified
+ * interfaces. (But see the discussion of class-based overrides for exceptions.)
+ * <p>
+ * The adapter class is generated in a new secure class loader that inherits
+ * Nashorn's protection domain, and has either one of the original types' class
+ * loader or the Nashorn's class loader as its parent - the parent class loader
+ * is chosen so that all the original types and the Nashorn core classes are
+ * visible from it (as the adapter will have constant pool references to
+ * ScriptObject and ScriptFunction classes). In case none of the candidate class
+ * loaders has visibility of all the required types, an error is thrown. The
+ * class uses {@link JavaAdapterBytecodeGenerator} to generate the adapter class
+ * itself; see its documentation for details about the generated class.
+ * <p>
+ * You normally don't use this class directly, but rather either create adapters
+ * from script using {@link jdk.nashorn.internal.objects.NativeJava#extend(Object, Object...)},
+ * using the {@code new} operator on abstract classes and interfaces (see
+ * {@link jdk.nashorn.internal.objects.NativeJava#type(Object, Object)}), or
+ * implicitly when passing script functions to Java methods expecting SAM types.
  */
 
 @SuppressWarnings("javadoc")
@@ -93,25 +98,39 @@
     };
 
     /**
-     * Returns an adapter class for the specified original types. The adapter class extends/implements the original
-     * class/interfaces.
-     * @param types the original types. The caller must pass at least one Java type representing either a public
-     * interface or a non-final public class with at least one public or protected constructor. If more than one type is
-     * specified, at most one can be a class and the rest have to be interfaces. The class can be in any position in the
-     * array. Invoking the method twice with exactly the same types in the same order will return the same adapter
-     * class, any reordering of types or even addition or removal of redundant types (i.e. interfaces that other types
-     * in the list already implement/extend, or {@code java.lang.Object} in a list of types consisting purely of
-     * interfaces) will result in a different adapter class, even though those adapter classes are functionally
-     * identical; we deliberately don't want to incur the additional processing cost of canonicalizing type lists.
-     * @param classOverrides a JavaScript object with functions serving as the class-level overrides and
-     * implementations. These overrides are defined for all instances of the class, and can be further overridden on a
-     * per-instance basis by passing additional objects in the constructor.
-     * @param lookup the lookup object identifying the caller class. The generated adapter class will have the
-     * protection domain of the caller class iff the lookup object is full-strength, otherwise it will be completely
-     * unprivileged.
-     * @return an adapter class. See this class' documentation for details on the generated adapter class.
-     * @throws ECMAException with a TypeError if the adapter class can not be generated because the original class is
-     * final, non-public, or has no public or protected constructors.
+     * Returns an adapter class for the specified original types. The adapter
+     * class extends/implements the original class/interfaces.
+     *
+     * @param types the original types. The caller must pass at least one Java
+     *        type representing either a public interface or a non-final public
+     *        class with at least one public or protected constructor. If more
+     *        than one type is specified, at most one can be a class and the
+     *        rest have to be interfaces. The class can be in any position in
+     *        the array. Invoking the method twice with exactly the same types
+     *        in the same order will return the same adapter class, any
+     *        reordering of types or even addition or removal of redundant types
+     *        (i.e., interfaces that other types in the list already
+     *        implement/extend, or {@code java.lang.Object} in a list of types
+     *        consisting purely of interfaces) will result in a different
+     *        adapter class, even though those adapter classes are functionally
+     *        identical; we deliberately don't want to incur the additional
+     *        processing cost of canonicalizing type lists.
+     * @param classOverrides a JavaScript object with functions serving as the
+     *        class-level overrides and implementations. These overrides are
+     *        defined for all instances of the class, and can be further
+     *        overridden on a per-instance basis by passing additional objects
+     *        in the constructor.
+     * @param lookup the lookup object identifying the caller class. The
+     *        generated adapter class will have the protection domain of the
+     *        caller class iff the lookup object is full-strength, otherwise it
+     *        will be completely unprivileged.
+     *
+     * @return an adapter class. See this class' documentation for details on
+     *         the generated adapter class.
+     *
+     * @throws ECMAException with a TypeError if the adapter class can not be
+     *         generated because the original class is final, non-public, or has
+     *         no public or protected constructors.
      */
     public static StaticClass getAdapterClassFor(final Class<?>[] types, final ScriptObject classOverrides, final MethodHandles.Lookup lookup) {
         return getAdapterClassFor(types, classOverrides, getProtectionDomain(lookup));
@@ -148,15 +167,23 @@
     }
 
     /**
-     * Returns a method handle representing a constructor that takes a single argument of the source type (which,
-     * really, should be one of {@link ScriptObject}, {@link ScriptFunction}, or {@link Object}, and returns an instance
-     * of the adapter for the target type. Used to implement the function autoconverters as well as the Nashorn's
-     * JSR-223 script engine's {@code getInterface()} method.
-     * @param sourceType the source type; should be either {@link ScriptObject}, {@link ScriptFunction}, or
-     * {@link Object}. In case of {@code Object}, it will return a method handle that dispatches to either the script
-     * object or function constructor at invocation based on the actual argument.
+     * Returns a method handle representing a constructor that takes a single
+     * argument of the source type (which, really, should be one of {@link ScriptObject},
+     * {@link ScriptFunction}, or {@link Object}, and returns an instance of the
+     * adapter for the target type. Used to implement the function autoconverters
+     * as well as the Nashorn JSR-223 script engine's {@code getInterface()}
+     * method.
+     *
+     * @param sourceType the source type; should be either {@link ScriptObject},
+     *        {@link ScriptFunction}, or {@link Object}. In case of {@code Object},
+     *        it will return a method handle that dispatches to either the script
+     *        object or function constructor at invocation based on the actual
+     *        argument.
      * @param targetType the target type, for which adapter instances will be created
+     * @param lookup method handle lookup to use
+     *
      * @return the constructor method handle.
+     *
      * @throws Exception if anything goes wrong
      */
     public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType, final MethodHandles.Lookup lookup) throws Exception {
@@ -168,13 +195,18 @@
     }
 
     /**
-     * Returns whether an instance of the specified class/interface can be generated from a ScriptFunction. Returns true
-     * iff: the adapter for the class/interface can be created, it is abstract (this includes interfaces), it has at
-     * least one abstract method, all the abstract methods share the same name, and it has a public or protected default
-     * constructor. Note that invoking this class will most likely result in the adapter class being defined in the JVM
-     * if it hasn't been already.
+     * Returns whether an instance of the specified class/interface can be
+     * generated from a ScriptFunction. Returns {@code true} iff: the adapter
+     * for the class/interface can be created, it is abstract (this includes
+     * interfaces), it has at least one abstract method, all the abstract
+     * methods share the same name, and it has a public or protected default
+     * constructor. Note that invoking this class will most likely result in the
+     * adapter class being defined in the JVM if it hasn't been already.
+     *
      * @param clazz the inspected class
-     * @return true iff an instance of the specified class/interface can be generated from a ScriptFunction.
+     *
+     * @return {@code true} iff an instance of the specified class/interface can
+     *         be generated from a ScriptFunction.
      */
     static boolean isAutoConvertibleFromFunction(final Class<?> clazz) {
         return getAdapterInfo(new Class<?>[] { clazz }).autoConvertibleFromFunction;
@@ -184,7 +216,7 @@
         final ClassAndLoader definingClassAndLoader = ClassAndLoader.getDefiningClassAndLoader(types);
 
         final Map<List<Class<?>>, AdapterInfo> adapterInfoMap = ADAPTER_INFO_MAPS.get(definingClassAndLoader.getRepresentativeClass());
-        final List<Class<?>> typeList = types.length == 1 ? getSingletonClassList(types[0]) : Arrays.asList(types.clone());
+        final List<Class<?>> typeList = types.length == 1 ? Collections.<Class<?>>singletonList(types[0]) : Arrays.asList(types.clone());
         AdapterInfo adapterInfo;
         synchronized(adapterInfoMap) {
             adapterInfo = adapterInfoMap.get(typeList);
@@ -196,14 +228,11 @@
         return adapterInfo;
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    private static List<Class<?>> getSingletonClassList(final Class<?> clazz) {
-        return (List)Collections.singletonList(clazz);
-    }
-
    /**
      * For a given class, create its adapter class and associated info.
+     *
      * @param type the class for which the adapter is created
+     *
      * @return the adapter info for the class.
      */
     private static AdapterInfo createAdapterInfo(final Class<?>[] types, final ClassAndLoader definingClassAndLoader) {
@@ -241,6 +270,8 @@
                     return new AdapterInfo(effectiveSuperClass, interfaces, definingClassAndLoader);
                 } catch (final AdaptationException e) {
                     return new AdapterInfo(e.getAdaptationResult());
+                } catch (final RuntimeException e) {
+                    return new AdapterInfo(new AdaptationResult(AdaptationResult.Outcome.ERROR_OTHER, Arrays.toString(types), e.toString()));
                 }
             }
         }, CREATE_ADAPTER_INFO_ACC_CTXT);
@@ -314,11 +345,14 @@
         }
 
         /**
-         * Choose between the passed class loader and the class loader that defines the ScriptObject class, based on which
-         * of the two can see the classes in both.
-         * @param classAndLoader the loader and a representative class from it that will be used to add the generated
-         * adapter to its ADAPTER_INFO_MAPS.
+         * Choose between the passed class loader and the class loader that defines the
+         * ScriptObject class, based on which of the two can see the classes in both.
+         *
+         * @param classAndLoader the loader and a representative class from it that will
+         *        be used to add the generated adapter to its ADAPTER_INFO_MAPS.
+         *
          * @return the class loader that sees both the specified class and Nashorn classes.
+         *
          * @throws IllegalStateException if no such class loader is found.
          */
         private static ClassLoader findCommonLoader(final ClassAndLoader classAndLoader) throws AdaptationException {
--- a/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java	Fri Nov 13 15:38:44 2015 -0800
@@ -27,6 +27,7 @@
 
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+import static jdk.nashorn.internal.runtime.JSType.isString;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
 
 import java.lang.invoke.MethodHandle;
@@ -78,7 +79,7 @@
         }
 
         if (obj == UNDEFINED) {
-            // NOTE: same reasoning for FindBugs NP_BOOLEAN_RETURN_NUL warning as in the preceding comment.
+            // NOTE: same reasoning for FindBugs NP_BOOLEAN_RETURN_NULL warning as in the preceding comment.
             return null;
         }
 
@@ -87,7 +88,7 @@
             return num != 0 && !Double.isNaN(num);
         }
 
-        if (obj instanceof String || obj instanceof ConsString) {
+        if (isString(obj)) {
             return ((CharSequence) obj).length() > 0;
         }
 
@@ -207,7 +208,7 @@
                 return f.longValue();
             } else if (obj instanceof Number) {
                 return ((Number)obj).longValue();
-            } else if (obj instanceof String || obj instanceof ConsString) {
+            } else if (isString(obj)) {
                 return JSType.toLong(obj);
             } else if (obj instanceof Boolean) {
                 return (Boolean)obj ? 1L : 0L;
--- a/src/jdk/nashorn/internal/runtime/linker/JavaSuperAdapter.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaSuperAdapter.java	Fri Nov 13 15:38:44 2015 -0800
@@ -25,6 +25,8 @@
 
 package jdk.nashorn.internal.runtime.linker;
 
+import java.util.Objects;
+
 /**
  * Represents a an adapter for invoking superclass methods on an adapter instance generated by
  * {@code JavaAdapterBytecodeGenerator}. Note that objects of this class are just wrappers around the adapter instances,
@@ -34,8 +36,7 @@
     private final Object adapter;
 
     JavaSuperAdapter(final Object adapter) {
-        adapter.getClass(); // NPE check
-        this.adapter = adapter;
+        this.adapter = Objects.requireNonNull(adapter);
     }
 
     public Object getAdapter() {
--- a/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -40,10 +40,11 @@
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
+import jdk.internal.dynalink.support.DefaultInternalObjectFilter;
 import jdk.internal.dynalink.support.Guards;
 import jdk.internal.dynalink.support.Lookup;
 import jdk.nashorn.api.scripting.ScriptUtils;
-import jdk.nashorn.internal.objects.NativeArray;
 import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ScriptObject;
@@ -52,10 +53,14 @@
 
 /**
  * This linker delegates to a {@code BeansLinker} but passes it a special linker services object that has a modified
- * {@code asType} method that will ensure that we never pass internal engine objects that should not be externally
- * observable (currently ConsString and ScriptObject) to Java APIs, but rather that we flatten it into a String. We can't just add
- * this functionality as custom converters via {@code GuaardingTypeConverterFactory}, since they are not consulted when
- * the target method handle parameter signature is {@code Object}.
+ * {@code compareConversion} method that favors conversion of {@link ConsString} to either {@link String} or
+ * {@link CharSequence}. It also provides a {@link #createHiddenObjectFilter()} method for use with bootstrap that will
+ * ensure that we never pass internal engine objects that should not be externally observable (currently ConsString and
+ * ScriptObject) to Java APIs, but rather that we flatten it into a String. We can't just add this functionality as
+ * custom converters via {@code GuaardingTypeConverterFactory}, since they are not consulted when
+ * the target method handle parameter signature is {@code Object}. This linker also makes sure that primitive
+ * {@link String} operations can be invoked on a {@link ConsString}, and allows invocation of objects implementing
+ * the {@link FunctionalInterface} attribute.
  */
 public class NashornBeansLinker implements GuardingDynamicLinker {
     // System property to control whether to wrap ScriptObject->ScriptObjectMirror for
@@ -63,16 +68,12 @@
     private static final boolean MIRROR_ALWAYS = Options.getBooleanProperty("nashorn.mirror.always", true);
 
     private static final MethodHandle EXPORT_ARGUMENT;
-    private static final MethodHandle EXPORT_NATIVE_ARRAY;
-    private static final MethodHandle EXPORT_SCRIPT_OBJECT;
     private static final MethodHandle IMPORT_RESULT;
     private static final MethodHandle FILTER_CONSSTRING;
 
     static {
         final Lookup lookup  = new Lookup(MethodHandles.lookup());
         EXPORT_ARGUMENT      = lookup.findOwnStatic("exportArgument", Object.class, Object.class);
-        EXPORT_NATIVE_ARRAY  = lookup.findOwnStatic("exportNativeArray", Object.class, NativeArray.class);
-        EXPORT_SCRIPT_OBJECT = lookup.findOwnStatic("exportScriptObject", Object.class, ScriptObject.class);
         IMPORT_RESULT        = lookup.findOwnStatic("importResult", Object.class, Object.class);
         FILTER_CONSSTRING    = lookup.findOwnStatic("consStringFilter", Object.class, Object.class);
     }
@@ -115,9 +116,10 @@
                 }
                 return new GuardedInvocation(
                         // drop 'thiz' passed from the script.
-                        MH.dropArguments(desc.getLookup().unreflect(m), 1, callType.parameterType(1)),
-                        Guards.getInstanceOfGuard(m.getDeclaringClass())).asTypeSafeReturn(
-                                new NashornBeansLinkerServices(linkerServices), callType);
+                        MH.dropArguments(linkerServices.filterInternalObjects(desc.getLookup().unreflect(m)), 1,
+                                callType.parameterType(1)), Guards.getInstanceOfGuard(
+                                        m.getDeclaringClass())).asTypeSafeReturn(
+                                                new NashornBeansLinkerServices(linkerServices), callType);
             }
         }
         return getGuardedInvocation(beansLinker, linkRequest, linkerServices);
@@ -141,21 +143,6 @@
         return exportArgument(arg, MIRROR_ALWAYS);
     }
 
-    @SuppressWarnings("unused")
-    private static Object exportNativeArray(final NativeArray arg) {
-        return exportArgument(arg, MIRROR_ALWAYS);
-    }
-
-    @SuppressWarnings("unused")
-    private static Object exportScriptObject(final ScriptObject arg) {
-        return exportArgument(arg, MIRROR_ALWAYS);
-    }
-
-    @SuppressWarnings("unused")
-    private static Object exportScriptArray(final NativeArray arg) {
-        return exportArgument(arg, MIRROR_ALWAYS);
-    }
-
     static Object exportArgument(final Object arg, final boolean mirrorAlways) {
         if (arg instanceof ConsString) {
             return arg.toString();
@@ -208,6 +195,10 @@
         return FUNCTIONAL_IFACE_METHOD.get(clazz);
     }
 
+    static MethodHandleTransformer createHiddenObjectFilter() {
+        return new DefaultInternalObjectFilter(EXPORT_ARGUMENT, MIRROR_ALWAYS ? IMPORT_RESULT : null);
+    }
+
     private static class NashornBeansLinkerServices implements LinkerServices {
         private final LinkerServices linkerServices;
 
@@ -217,50 +208,7 @@
 
         @Override
         public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {
-            final MethodType handleType = handle.type();
-            final int paramCount = handleType.parameterCount();
-            assert fromType.parameterCount() == handleType.parameterCount();
-
-            MethodType newFromType = fromType;
-            MethodHandle[] filters = null;
-            for(int i = 0; i < paramCount; ++i) {
-                final MethodHandle filter = argConversionFilter(handleType.parameterType(i), fromType.parameterType(i));
-                if (filter != null) {
-                    if (filters == null) {
-                        filters = new MethodHandle[paramCount];
-                    }
-                    // "erase" specific type with Object type or else we'll get filter mismatch
-                    newFromType = newFromType.changeParameterType(i, Object.class);
-                    filters[i] = filter;
-                }
-            }
-
-            final MethodHandle typed = linkerServices.asType(handle, newFromType);
-            MethodHandle result = filters != null ? MethodHandles.filterArguments(typed, 0, filters) : typed;
-            // Filter Object typed return value for possible ScriptObjectMirror. We convert
-            // ScriptObjectMirror as ScriptObject (if it is mirror from current global).
-            if (MIRROR_ALWAYS && areBothObjects(handleType.returnType(), fromType.returnType())) {
-                result = MethodHandles.filterReturnValue(result, IMPORT_RESULT);
-            }
-
-            return result;
-        }
-
-        private static MethodHandle argConversionFilter(final Class<?> handleType, final Class<?> fromType) {
-            if (handleType == Object.class) {
-                if (fromType == Object.class) {
-                    return EXPORT_ARGUMENT;
-                } else if (fromType == NativeArray.class) {
-                    return EXPORT_NATIVE_ARRAY;
-                } else if (fromType == ScriptObject.class) {
-                    return EXPORT_SCRIPT_OBJECT;
-                }
-            }
-            return null;
-        }
-
-        private static boolean areBothObjects(final Class<?> handleType, final Class<?> fromType) {
-            return handleType == Object.class && fromType == Object.class;
+            return linkerServices.asType(handle, fromType);
         }
 
         @Override
@@ -296,5 +244,10 @@
             }
             return linkerServices.compareConversion(sourceType, targetType1, targetType2);
         }
+
+        @Override
+        public MethodHandle filterInternalObjects(final MethodHandle target) {
+            return linkerServices.filterInternalObjects(target);
+        }
     }
 }
--- a/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -86,6 +86,9 @@
         final String operator = desc.getFirstOperator();
         switch (operator) {
         case "new":
+            if(BeansLinker.isDynamicConstructor(self)) {
+                throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self));
+            }
             if(BeansLinker.isDynamicMethod(self)) {
                 throw typeError("method.not.constructor", ScriptRuntime.safeToString(self));
             }
--- a/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java	Fri Nov 13 15:38:44 2015 -0800
@@ -33,7 +33,6 @@
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.nashorn.api.scripting.JSObject;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.runtime.Property;
 import jdk.nashorn.internal.runtime.PropertyMap;
@@ -123,7 +122,7 @@
      */
     static boolean needsGuard(final Property property, final CallSiteDescriptor desc) {
         return property == null || property.isConfigurable()
-                || property.isBound() || !ObjectClassGenerator.OBJECT_FIELDS_ONLY
+                || property.isBound() || property.hasDualFields()
                 || !NashornCallSiteDescriptor.isFastScope(desc) || property.canChangeType();
     }
 
--- a/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -29,13 +29,15 @@
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.invoke.MethodType;
 import java.lang.reflect.Modifier;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Collection;
 import java.util.Deque;
 import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import javax.script.Bindings;
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.linker.ConversionComparator;
@@ -47,11 +49,13 @@
 import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.internal.dynalink.support.Guards;
 import jdk.internal.dynalink.support.LinkerServicesImpl;
+import jdk.internal.dynalink.support.Lookup;
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.api.scripting.ScriptUtils;
 import jdk.nashorn.internal.objects.NativeArray;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ListAdapter;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.Undefined;
@@ -167,7 +171,7 @@
         return null;
     }
 
-    private static Lookup getCurrentLookup() {
+    private static java.lang.invoke.MethodHandles.Lookup getCurrentLookup() {
         final LinkRequest currentRequest = AccessController.doPrivileged(new PrivilegedAction<LinkRequest>() {
             @Override
             public LinkRequest run() {
@@ -179,12 +183,12 @@
 
     /**
      * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or
-     * Deque type.
+     * Queue or Deque or Collection type.
      * @param sourceType the source type (presumably NativeArray a superclass of it)
-     * @param targetType the target type (presumably an array type, or List or Deque)
+     * @param targetType the target type (presumably an array type, or List or Queue, or Deque, or Collection)
      * @return a guarded invocation that converts from the source type to the target type. null is returned if
      * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
-     * type, List, or Deque.
+     * type, List, Queue, Deque, or Collection.
      */
     private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
         final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
@@ -195,12 +199,14 @@
             final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
             if(targetType.isArray()) {
                 return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
-            }
-            if(targetType == List.class) {
-                return new GuardedInvocation(JSType.TO_JAVA_LIST.methodHandle(), guard);
-            }
-            if(targetType == Deque.class) {
-                return new GuardedInvocation(JSType.TO_JAVA_DEQUE.methodHandle(), guard);
+            } else if(targetType == List.class) {
+                return new GuardedInvocation(TO_LIST, guard);
+            } else if(targetType == Deque.class) {
+                return new GuardedInvocation(TO_DEQUE, guard);
+            } else if(targetType == Queue.class) {
+                return new GuardedInvocation(TO_QUEUE, guard);
+            } else if(targetType == Collection.class) {
+                return new GuardedInvocation(TO_COLLECTION, guard);
             }
         }
         return null;
@@ -216,10 +222,11 @@
         // Could've also used (targetType.isAssignableFrom(ScriptObjectMirror.class) && targetType != Object.class) but
         // it's probably better to explicitly spell out the supported target types
         if (targetType == Map.class || targetType == Bindings.class || targetType == JSObject.class || targetType == ScriptObjectMirror.class) {
-            if(ScriptObject.class.isAssignableFrom(sourceType)) {
+            if (ScriptObject.class.isAssignableFrom(sourceType)) {
                 return new GuardedInvocation(CREATE_MIRROR);
+            } else if (sourceType.isAssignableFrom(ScriptObject.class) || sourceType.isInterface()) {
+                return new GuardedInvocation(CREATE_MIRROR, IS_SCRIPT_OBJECT);
             }
-            return new GuardedInvocation(CREATE_MIRROR, IS_SCRIPT_OBJECT);
         }
         return null;
     }
@@ -285,6 +292,23 @@
     private static final MethodHandle IS_NASHORN_OR_UNDEFINED_TYPE = findOwnMH("isNashornTypeOrUndefined", Boolean.TYPE, Object.class);
     private static final MethodHandle CREATE_MIRROR = findOwnMH("createMirror", Object.class, Object.class);
 
+    private static final MethodHandle TO_COLLECTION;
+    private static final MethodHandle TO_DEQUE;
+    private static final MethodHandle TO_LIST;
+    private static final MethodHandle TO_QUEUE;
+    static {
+        final MethodHandle listAdapterCreate = new Lookup(MethodHandles.lookup()).findStatic(
+                ListAdapter.class, "create", MethodType.methodType(ListAdapter.class, Object.class));
+        TO_COLLECTION = asReturning(listAdapterCreate, Collection.class);
+        TO_DEQUE = asReturning(listAdapterCreate, Deque.class);
+        TO_LIST = asReturning(listAdapterCreate, List.class);
+        TO_QUEUE = asReturning(listAdapterCreate, Queue.class);
+    }
+
+    private static MethodHandle asReturning(final MethodHandle mh, final Class<?> nrtype) {
+        return mh.asType(mh.type().changeReturnType(nrtype));
+    }
+
     @SuppressWarnings("unused")
     private static boolean isNashornTypeOrUndefined(final Object obj) {
         return obj instanceof ScriptObject || obj instanceof Undefined;
--- a/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java	Fri Nov 13 15:38:44 2015 -0800
@@ -39,6 +39,7 @@
 import jdk.internal.dynalink.support.TypeUtilities;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.runtime.ConsString;
+import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 
 /**
@@ -170,7 +171,7 @@
 
     @SuppressWarnings("unused")
     private static boolean isJavaScriptPrimitive(final Object o) {
-        return o instanceof String || o instanceof Boolean || o instanceof Number || o instanceof ConsString || o == null;
+        return JSType.isString(o) || o instanceof Boolean || o instanceof Number || o == null;
     }
 
     private static final MethodHandle GUARD_PRIMITIVE = findOwnMH("isJavaScriptPrimitive", boolean.class, Object.class);
--- a/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,17 +26,23 @@
 package jdk.nashorn.internal.runtime.linker;
 
 import static jdk.nashorn.internal.lookup.Lookup.MH;
+import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+
 import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.invoke.SwitchPoint;
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
 import jdk.internal.dynalink.support.Guards;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.FindProperty;
 import jdk.nashorn.internal.runtime.GlobalConstants;
+import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.runtime.UserAccessorProperty;
 
 /**
@@ -46,6 +52,11 @@
  */
 public final class PrimitiveLookup {
 
+    /** Method handle to link setters on primitive base. See ES5 8.7.2. */
+    private static final MethodHandle PRIMITIVE_SETTER = findOwnMH("primitiveSetter",
+            MH.type(void.class, ScriptObject.class, Object.class, Object.class, boolean.class, Object.class));
+
+
     private PrimitiveLookup() {
     }
 
@@ -87,40 +98,58 @@
                                                     final ScriptObject wrappedReceiver, final MethodHandle wrapFilter,
                                                     final MethodHandle protoFilter) {
         final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+        final String name;
+        final FindProperty find;
 
-        //checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem)
-        //if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be.
-        //so in that case we can skip creation of primitive wrapper and start our search with the prototype.
         if (desc.getNameTokenCount() > 2) {
-            final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
-            final FindProperty find = wrappedReceiver.findProperty(name, true);
+            name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
+            find = wrappedReceiver.findProperty(name, true);
+        } else {
+            name = null;
+            find = null;
+        }
 
-            if (find == null) {
-                // Give up early, give chance to BeanLinker and NashornBottomLinker to deal with it.
-                return null;
-            }
+        final String firstOp = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
 
-            final SwitchPoint sp = find.getProperty().getBuiltinSwitchPoint(); //can use this instead of proto filter
-            if (sp instanceof Context.BuiltinSwitchPoint && !sp.hasBeenInvalidated()) {
-                return new GuardedInvocation(GlobalConstants.staticConstantGetter(find.getObjectValue()), guard, sp, null);
-            }
+        switch (firstOp) {
+        case "getProp":
+        case "getElem":
+        case "getMethod":
+            //checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem)
+            //if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be.
+            //so in that case we can skip creation of primitive wrapper and start our search with the prototype.
+            if (name != null) {
+                if (find == null) {
+                    // Give up early, give chance to BeanLinker and NashornBottomLinker to deal with it.
+                    return null;
+                }
 
-            if (find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
-                // If property is found in the prototype object bind the method handle directly to
-                // the proto filter instead of going through wrapper instantiation below.
-                final ScriptObject proto = wrappedReceiver.getProto();
-                final GuardedInvocation link = proto.lookup(desc, request);
+                final SwitchPoint sp = find.getProperty().getBuiltinSwitchPoint(); //can use this instead of proto filter
+                if (sp instanceof Context.BuiltinSwitchPoint && !sp.hasBeenInvalidated()) {
+                    return new GuardedInvocation(GlobalConstants.staticConstantGetter(find.getObjectValue()), guard, sp, null);
+                }
 
-                if (link != null) {
-                    final MethodHandle invocation = link.getInvocation(); //this contains the builtin switchpoint
+                if (find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
+                    // If property is found in the prototype object bind the method handle directly to
+                    // the proto filter instead of going through wrapper instantiation below.
+                    final ScriptObject proto = wrappedReceiver.getProto();
+                    final GuardedInvocation link = proto.lookup(desc, request);
 
-                    final MethodHandle adaptedInvocation = MH.asType(invocation, invocation.type().changeParameterType(0, Object.class));
-                    final MethodHandle method = MH.filterArguments(adaptedInvocation, 0, protoFilter);
-                    final MethodHandle protoGuard = MH.filterArguments(link.getGuard(), 0, protoFilter);
-
-                    return new GuardedInvocation(method, NashornGuards.combineGuards(guard, protoGuard));
+                    if (link != null) {
+                        final MethodHandle invocation = link.getInvocation(); //this contains the builtin switchpoint
+                        final MethodHandle adaptedInvocation = MH.asType(invocation, invocation.type().changeParameterType(0, Object.class));
+                        final MethodHandle method = MH.filterArguments(adaptedInvocation, 0, protoFilter);
+                        final MethodHandle protoGuard = MH.filterArguments(link.getGuard(), 0, protoFilter);
+                        return new GuardedInvocation(method, NashornGuards.combineGuards(guard, protoGuard));
+                    }
                 }
             }
+            break;
+        case "setProp":
+        case "setElem":
+            return getPrimitiveSetter(name, guard, wrapFilter, NashornCallSiteDescriptor.isStrict(desc));
+        default:
+            break;
         }
 
         final GuardedInvocation link = wrappedReceiver.lookup(desc, request);
@@ -138,4 +167,41 @@
 
         return null;
     }
+
+    private static GuardedInvocation getPrimitiveSetter(final String name, final MethodHandle guard,
+                                                        final MethodHandle wrapFilter, final boolean isStrict) {
+        MethodHandle filter = MH.asType(wrapFilter, wrapFilter.type().changeReturnType(ScriptObject.class));
+        final MethodHandle target;
+
+        if (name == null) {
+            filter = MH.dropArguments(filter, 1, Object.class, Object.class);
+            target = MH.insertArguments(PRIMITIVE_SETTER, 3, isStrict);
+        } else {
+            filter = MH.dropArguments(filter, 1, Object.class);
+            target = MH.insertArguments(PRIMITIVE_SETTER, 2, name, isStrict);
+        }
+
+        return new GuardedInvocation(MH.foldArguments(target, filter), guard);
+    }
+
+
+    @SuppressWarnings("unused")
+    private static void primitiveSetter(final ScriptObject wrappedSelf, final Object self, final Object key,
+                                        final boolean strict, final Object value) {
+        // See ES5.1 8.7.2 PutValue (V, W)
+        final String name = JSType.toString(key);
+        final FindProperty find = wrappedSelf.findProperty(name, true);
+        if (find == null || !(find.getProperty() instanceof UserAccessorProperty) || !find.getProperty().isWritable()) {
+            if (strict) {
+                throw typeError("property.not.writable", name, ScriptRuntime.safeToString(self));
+            }
+            return;
+        }
+        // property found and is a UserAccessorProperty
+        find.setValue(value, strict);
+    }
+
+    private static MethodHandle findOwnMH(final String name, final MethodType type) {
+        return MH.findStatic(MethodHandles.lookup(), PrimitiveLookup.class, name, type);
+    }
 }
--- a/src/jdk/nashorn/internal/runtime/options/Options.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/options/Options.java	Fri Nov 13 15:38:44 2015 -0800
@@ -42,6 +42,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
+import java.util.Objects;
 import java.util.PropertyPermission;
 import java.util.ResourceBundle;
 import java.util.StringTokenizer;
@@ -135,6 +136,12 @@
         return options.toString();
     }
 
+    private static void checkPropertyName(final String name) {
+        if (! Objects.requireNonNull(name).startsWith("nashorn.")) {
+            throw new IllegalArgumentException(name);
+        }
+    }
+
     /**
      * Convenience function for getting system properties in a safe way
 
@@ -143,11 +150,7 @@
      * @return true if set to true, default value if unset or set to false
      */
     public static boolean getBooleanProperty(final String name, final Boolean defValue) {
-        name.getClass(); // null check
-        if (!name.startsWith("nashorn.")) {
-            throw new IllegalArgumentException(name);
-        }
-
+        checkPropertyName(name);
         return AccessController.doPrivileged(
                 new PrivilegedAction<Boolean>() {
                     @Override
@@ -184,11 +187,7 @@
      * @return string property if set or default value
      */
     public static String getStringProperty(final String name, final String defValue) {
-        name.getClass(); // null check
-        if (! name.startsWith("nashorn.")) {
-            throw new IllegalArgumentException(name);
-        }
-
+        checkPropertyName(name);
         return AccessController.doPrivileged(
                 new PrivilegedAction<String>() {
                     @Override
@@ -211,11 +210,7 @@
      * @return integer property if set or default value
      */
     public static int getIntProperty(final String name, final int defValue) {
-        name.getClass(); // null check
-        if (! name.startsWith("nashorn.")) {
-            throw new IllegalArgumentException(name);
-        }
-
+        checkPropertyName(name);
         return AccessController.doPrivileged(
                 new PrivilegedAction<Integer>() {
                     @Override
@@ -423,9 +418,17 @@
     public void process(final String[] args) {
         final LinkedList<String> argList = new LinkedList<>();
         addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList);
+        processArgList(argList);
+        assert argList.isEmpty();
         Collections.addAll(argList, args);
+        processArgList(argList);
+        assert argList.isEmpty();
         addSystemProperties(NASHORN_ARGS_PROPERTY, argList);
+        processArgList(argList);
+        assert argList.isEmpty();
+    }
 
+    private void processArgList(final LinkedList<String> argList) {
         while (!argList.isEmpty()) {
             final String arg = argList.remove(0);
 
--- a/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java	Fri Nov 13 15:38:44 2015 -0800
@@ -26,7 +26,7 @@
 package jdk.nashorn.internal.runtime.regexp;
 
 import java.util.Collections;
-import java.util.Set;
+import java.util.Map;
 import java.util.WeakHashMap;
 import jdk.nashorn.internal.runtime.ParserException;
 import jdk.nashorn.internal.runtime.options.Options;
@@ -45,11 +45,10 @@
     /** Weak cache of already validated regexps - when reparsing, we don't, for example
      *  need to recompile (reverify) all regexps that have previously been parsed by this
      *  RegExpFactory in a previous compilation. This saves significant time in e.g. avatar
-     *  startup */
-    private static final Set<String> VALID_CACHE_SET =
-            Collections.newSetFromMap(
-                    Collections.synchronizedMap(
-                            new WeakHashMap<String, Boolean>()));
+     *  startup
+     */
+    private static final Map<String, RegExp> REGEXP_CACHE =
+            Collections.synchronizedMap(new WeakHashMap<String, RegExp>());
 
     static {
         final String impl = Options.getStringProperty("nashorn.regexp.impl", JONI);
@@ -87,7 +86,13 @@
      * @throws ParserException if invalid source or flags
      */
     public static RegExp create(final String pattern, final String flags) {
-        return instance.compile(pattern,  flags);
+        final String key = pattern + "/" + flags;
+        RegExp regexp = REGEXP_CACHE.get(key);
+        if (regexp == null) {
+            regexp = instance.compile(pattern,  flags);
+            REGEXP_CACHE.put(key, regexp);
+        }
+        return regexp;
     }
 
     /**
@@ -98,11 +103,8 @@
      *
      * @throws ParserException if invalid source or flags
      */
-    // @SuppressWarnings({"unused"})
     public static void validate(final String pattern, final String flags) throws ParserException {
-        if (VALID_CACHE_SET.add(pattern + flags)) {
-            instance.compile(pattern, flags);
-        }
+        create(pattern, flags);
     }
 
     /**
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java	Fri Nov 13 15:38:44 2015 -0800
@@ -145,9 +145,6 @@
             case TargetInfo.IS_EMPTY_MEM:
                 addOpcode(OPCode.NULL_CHECK_END_MEMST);
                 break;
-            case TargetInfo.IS_EMPTY_REC:
-                addOpcode(OPCode.NULL_CHECK_END_MEMST_PUSH);
-                break;
             default:
                 break;
             } // switch
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java	Fri Nov 13 15:38:44 2015 -0800
@@ -183,7 +183,6 @@
                 case OPCode.NULL_CHECK_START:           opNullCheckStart();        continue;
                 case OPCode.NULL_CHECK_END:             opNullCheckEnd();          continue;
                 case OPCode.NULL_CHECK_END_MEMST:       opNullCheckEndMemST();     continue;
-                case OPCode.NULL_CHECK_END_MEMST_PUSH:  opNullCheckEndMemSTPush(); continue;
 
                 case OPCode.JUMP:                       opJump();                  continue;
                 case OPCode.PUSH:                       opPush();                  continue;
@@ -1025,29 +1024,6 @@
         }
     }
 
-    // USE_SUBEXP_CALL
-    private void opNullCheckEndMemSTPush() {
-        final int mem = code[ip++];   /* mem: null check id */
-
-        int isNull;
-        if (Config.USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT) {
-            isNull = nullCheckMemStRec(mem, s);
-        } else {
-            isNull = nullCheckRec(mem, s);
-        }
-
-        if (isNull != 0) {
-            if (Config.DEBUG_MATCH) {
-                Config.log.println("NULL_CHECK_END_MEMST_PUSH: skip  id:" + mem + ", s:" + s);
-            }
-
-            if (isNull == -1) {opFail(); return;}
-            nullCheckFound();
-        } else {
-            pushNullCheckEnd(mem);
-        }
-    }
-
     private void opJump() {
         ip += code[ip] + 1;
     }
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java	Fri Nov 13 15:38:44 2015 -0800
@@ -229,6 +229,11 @@
 
     /**
      * @see <a href="http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt">http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt</a>
+     *
+     * @param code code
+     * @param ctype ctype
+     *
+     * @return isCodeCType
      */
     public static boolean isCodeCType(final int code, final int ctype) {
         int type;
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java	Fri Nov 13 15:38:44 2015 -0800
@@ -19,7 +19,6 @@
  */
 package jdk.nashorn.internal.runtime.regexp.joni;
 
-import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt;
 import java.lang.ref.WeakReference;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel;
 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackType;
@@ -369,118 +368,9 @@
         }
     }
 
-    protected final int nullCheckRec(final int id, final int s) {
-        int level = 0;
-        int k = stk;
-        while (true) {
-            k--;
-            final StackEntry e = stack[k];
-
-            if (e.type == NULL_CHECK_START) {
-                if (e.getNullCheckNum() == id) {
-                    if (level == 0) {
-                        return e.getNullCheckPStr() == s ? 1 : 0;
-                    }
-                    level--;
-                }
-            } else if (e.type == NULL_CHECK_END) {
-                level++;
-            }
-        }
-    }
-
     protected final int nullCheckMemSt(final int id, final int s) {
-        int k = stk;
-        int isNull;
-        while (true) {
-            k--;
-            StackEntry e = stack[k];
-
-            if (e.type == NULL_CHECK_START) {
-                if (e.getNullCheckNum() == id) {
-                    if (e.getNullCheckPStr() != s) {
-                        isNull = 0;
-                        break;
-                    }
-                    int endp;
-                    isNull = 1;
-                    while (k < stk) {
-                        if (e.type == MEM_START) {
-                            if (e.getMemEnd() == INVALID_INDEX) {
-                                isNull = 0;
-                                break;
-                            }
-                            if (bsAt(regex.btMemEnd, e.getMemNum())) {
-                                endp = stack[e.getMemEnd()].getMemPStr();
-                            } else {
-                                endp = e.getMemEnd();
-                            }
-                            if (stack[e.getMemStart()].getMemPStr() != endp) {
-                                isNull = 0;
-                                break;
-                            } else if (endp != s) {
-                                isNull = -1; /* empty, but position changed */
-                            }
-                        }
-                        k++;
-                        e = stack[k]; // !!
-                    }
-                    break;
-                }
-            }
-        }
-        return isNull;
-    }
-
-    protected final int nullCheckMemStRec(final int id, final int s) {
-        int level = 0;
-        int k = stk;
-        int isNull;
-        while (true) {
-            k--;
-            StackEntry e = stack[k];
-
-            if (e.type == NULL_CHECK_START) {
-                if (e.getNullCheckNum() == id) {
-                    if (level == 0) {
-                        if (e.getNullCheckPStr() != s) {
-                            isNull = 0;
-                            break;
-                        }
-                        int endp;
-                        isNull = 1;
-                        while (k < stk) {
-                            if (e.type == MEM_START) {
-                                if (e.getMemEnd() == INVALID_INDEX) {
-                                    isNull = 0;
-                                    break;
-                                }
-                                if (bsAt(regex.btMemEnd, e.getMemNum())) {
-                                    endp = stack[e.getMemEnd()].getMemPStr();
-                                } else {
-                                    endp = e.getMemEnd();
-                                }
-                                if (stack[e.getMemStart()].getMemPStr() != endp) {
-                                    isNull = 0;
-                                    break;
-                                } else if (endp != s) {
-                                    isNull = -1; /* empty, but position changed */
-                                }
-                            }
-                            k++;
-                            e = stack[k];
-                        }
-                        break;
-                    }
-                    level--;
-                }
-            } else if (e.type == NULL_CHECK_END) {
-                if (e.getNullCheckNum() == id) {
-                    level++;
-                }
-            }
-        }
-        return isNull;
+        // Return -1 here to cause operation to fail
+        return -nullCheck(id, s);
     }
 
     protected final int getRepeat(final int id) {
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java	Fri Nov 13 15:38:44 2015 -0800
@@ -57,10 +57,10 @@
         }
     }
 
-    /**
-     * OP
-     *
-     */
+    //
+    // OP
+    //
+
     protected boolean isOp(final int opm) {
         return (op & opm) != 0;
     }
@@ -189,11 +189,10 @@
         return isOp(OP_ESC_X_BRACE_HEX8);
     }
 
+    //
+    // OP2
+    //
 
-    /**
-     * OP
-     *
-     */
     protected boolean isOp2(final int opm) {
         return (op2 & opm) != 0;
     }
@@ -278,10 +277,10 @@
         return isOp2(OP2_INEFFECTIVE_ESCAPE);
     }
 
-    /**
-     * BEHAVIOR
-     *
-     */
+    //
+    // BEHAVIOR
+    //
+
     protected boolean isBehavior(final int bvm) {
         return (behavior & bvm) != 0;
     }
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java	Fri Nov 13 15:38:44 2015 -0800
@@ -24,5 +24,4 @@
     final int ISNOT_EMPTY   = 0;
     final int IS_EMPTY      = 1;
     final int IS_EMPTY_MEM  = 2;
-    final int IS_EMPTY_REC  = 3;
 }
--- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Fri Nov 13 15:38:44 2015 -0800
@@ -121,7 +121,7 @@
 type.error.cannot.get.default.number=Cannot get default number value
 type.error.cant.apply.with.to.null=Cannot apply "with" to null
 type.error.cant.apply.with.to.undefined=Cannot apply "with" to undefined
-type.error.cant.apply.with.to.non.scriptobject=Cannot apply "with" to non script object
+type.error.cant.apply.with.to.non.scriptobject=Cannot apply "with" to non script object. Consider using "with(Object.bindProperties('{'}, nonScriptObject))".
 type.error.in.with.non.object=Right hand side of "in" cannot be non-Object, found {0}
 type.error.prototype.not.an.object="prototype" of {0} is not an Object, it is {1}
 type.error.cant.load.script=Cannot load script from {0}
@@ -141,8 +141,10 @@
 type.error.extend.ERROR_MULTIPLE_SUPERCLASSES=Can not extend multiple classes {0}. At most one of the specified types can be a class, the rest must all be interfaces.
 type.error.extend.ERROR_NO_COMMON_LOADER=Can not find a common class loader for ScriptObject and {0}.
 type.error.extend.ERROR_FINAL_FINALIZER=Can not extend class because {0} has a final finalize method.
+type.error.extend.ERROR_OTHER=Can not extend/implement {0} because of {1}
 type.error.no.constructor.matches.args=Can not construct {0} with the passed arguments; they do not match any of its constructor signatures.
 type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures.
+type.error.no.constructor.matches.args=Can not create new object with constructor {0} with the passed arguments; they do not match any of its method signatures.
 type.error.method.not.constructor=Java method {0} cannot be used as a constructor.
 type.error.env.not.object=$ENV must be an Object.
 type.error.unsupported.java.to.type=Unsupported Java.to target type {0}.
@@ -166,11 +168,10 @@
 syntax.error.invalid.json=Invalid JSON: {0}
 syntax.error.strict.cant.delete=cannot delete "{0}" in strict mode
 syntax.error.redeclare.variable=Variable "{0}" has already been declared
-syntax.error.assign.constant=Assignment to constant "{0}"
 syntax.error.unprotected.switch.declaration=Unsupported {0} declaration in unprotected switch statement
 
 io.error.cant.write=cannot write "{0}"
 config.error.no.dest=no destination directory supplied
 
 uri.error.bad.uri=Bad URI "{0}" near offset {1}
-
+list.adapter.null.global=Attempted to create the adapter from outside a JavaScript execution context.
--- a/src/jdk/nashorn/internal/runtime/resources/Options.properties	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/runtime/resources/Options.properties	Fri Nov 13 15:38:44 2015 -0800
@@ -114,7 +114,7 @@
     short_name="-d",                                             \
     is_undocumented=true,                                        \
     params="<path>",                                             \
-    desc="specify a destination directory to dump class files.", \
+    desc="specify a destination directory to dump source and class files.", \
     type=String                                                  \
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/internal/scripts/JD.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.scripts;
+
+import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.ScriptObject;
+
+/**
+ * Empty object class for dual primitive-object fields.
+ */
+public class JD extends ScriptObject {
+
+    private static final PropertyMap map$ = PropertyMap.newMap(JD.class);
+
+    /**
+     * Returns the initial property map to be used.
+     * @return the initial property map.
+     */
+    public static PropertyMap getInitialMap() {
+        return map$;
+    }
+
+    /**
+     * Constructor given an initial property map
+     *
+     * @param map the property map
+     */
+    public JD(final PropertyMap map) {
+        super(map);
+    }
+
+    /**
+     * Constructor given an initial prototype and the default initial property map.
+     *
+     * @param proto the prototype object
+     */
+    public JD(final ScriptObject proto) {
+        super(proto, getInitialMap());
+    }
+
+    /**
+     * Constructor that takes a pre-initialized spill pool. Used by
+     * {@link jdk.nashorn.internal.codegen.SpillObjectCreator} and
+     * {@link jdk.nashorn.internal.parser.JSONParser} for initializing object literals
+     *
+     * @param map            property map
+     * @param primitiveSpill primitive spill pool
+     * @param objectSpill    reference spill pool
+     */
+    public JD(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) {
+        super(map, primitiveSpill, objectSpill);
+    }
+
+    /**
+     * A method handle of this method is passed to the ScriptFunction constructor.
+     *
+     * @param map  the property map to use for allocatorMap
+     *
+     * @return newly allocated ScriptObject
+     */
+    public static ScriptObject allocate(final PropertyMap map) {
+        return new JD(map);
+    }
+}
+
--- a/src/jdk/nashorn/internal/scripts/JO.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/internal/scripts/JO.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,16 +25,15 @@
 
 package jdk.nashorn.internal.scripts;
 
-import jdk.nashorn.internal.codegen.SpillObjectCreator;
 import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
- * Empty object class.
+ * Empty object class for object-only fields.
  */
 public class JO extends ScriptObject {
 
-    private static final PropertyMap map$ = PropertyMap.newMap();
+    private static final PropertyMap map$ = PropertyMap.newMap(JO.class);
 
     /**
      * Returns the initial property map to be used.
@@ -54,18 +53,18 @@
     }
 
     /**
-     * Constructor given an initial prototype and an initial property map.
+     * Constructor given an initial prototype and the default initial property map.
      *
      * @param proto the prototype object
-     * @param map the property map
      */
-    public JO(final ScriptObject proto, final PropertyMap map) {
-        super(proto, map);
+    public JO(final ScriptObject proto) {
+        super(proto, getInitialMap());
     }
 
     /**
-     * Constructor that takes a pre-initialized spill pool. Used for
-     * by {@link SpillObjectCreator} for intializing object literals
+     * Constructor that takes a pre-initialized spill pool. Used by
+     * {@link jdk.nashorn.internal.codegen.SpillObjectCreator} and
+     * {@link jdk.nashorn.internal.parser.JSONParser} for initializing object literals
      *
      * @param map            property map
      * @param primitiveSpill primitive spill pool
@@ -86,3 +85,4 @@
         return new JO(map);
     }
 }
+
--- a/src/jdk/nashorn/tools/Shell.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/src/jdk/nashorn/tools/Shell.java	Fri Nov 13 15:38:44 2015 -0800
@@ -109,7 +109,10 @@
      */
     public static void main(final String[] args) {
         try {
-            System.exit(main(System.in, System.out, System.err, args));
+            final int exitCode = main(System.in, System.out, System.err, args);
+            if (exitCode != SUCCESS) {
+                System.exit(exitCode);
+            }
         } catch (final IOException e) {
             System.err.println(e); //bootstrapping, Context.err may not exist
             System.exit(IO_ERROR);
@@ -414,18 +417,7 @@
                 Context.setGlobal(global);
             }
 
-            // initialize with "shell.js" script
-            try {
-                final Source source = sourceFor("<shell.js>", Shell.class.getResource("resources/shell.js"));
-                context.eval(global, source.getString(), global, "<shell.js>", false);
-            } catch (final Exception e) {
-                err.println(e);
-                if (env._dump_on_error) {
-                    e.printStackTrace(err);
-                }
-
-                return INTERNAL_ERROR;
-            }
+            global.addShellBuiltins();
 
             while (true) {
                 err.print(prompt);
@@ -447,7 +439,7 @@
                 }
 
                 try {
-                    final Object res = context.eval(global, source, global, "<shell>", env._strict);
+                    final Object res = context.eval(global, source, global, "<shell>");
                     if (res != ScriptRuntime.UNDEFINED) {
                         err.println(JSType.toString(res));
                     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk/nashorn/tools/ShellFunctions.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.tools;
+
+import static jdk.nashorn.internal.lookup.Lookup.MH;
+import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.objects.Global;
+
+/**
+ * Global functions supported only in shell interactive mode.
+ */
+public final class ShellFunctions {
+
+    /** Handle to implementation of {@link ShellFunctions#input} - Nashorn extension */
+    public static final MethodHandle INPUT = findOwnMH("input", Object.class, Object.class, Object.class, Object.class);
+
+    /** Handle to implementation of {@link ShellFunctions#evalinput} - Nashorn extension */
+    public static final MethodHandle EVALINPUT = findOwnMH("evalinput",     Object.class, Object.class, Object.class, Object.class);
+
+    private ShellFunctions() {
+    }
+
+    /**
+     * Nashorn extension: global.input (shell-interactive-mode-only)
+     * Read one or more lines of input from the standard input till the
+     * given end marker is seen in standard input.
+     *
+     * @param self   self reference
+     * @param endMarker String used as end marker for input
+     * @param prompt String used as input prompt
+     *
+     * @return line that was read
+     *
+     * @throws IOException if an exception occurs
+     */
+    public static Object input(final Object self, final Object endMarker, final Object prompt) throws IOException {
+        final String endMarkerStr = (endMarker != UNDEFINED)? JSType.toString(endMarker) : "";
+        final String promptStr = (prompt != UNDEFINED)? JSType.toString(prompt)  : ">> ";
+        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+        final StringBuilder buf = new StringBuilder();
+        while (true) {
+            System.out.print(promptStr);
+            final String line = reader.readLine();
+            if (line == null || line.equals(endMarkerStr)) {
+                break;
+            }
+            buf.append(line);
+            buf.append('\n');
+        }
+        return buf.toString();
+    }
+
+    /**
+     * Nashorn extension: Reads zero or more lines from standard input and
+     * evaluates the concatenated string as code
+     *
+     * @param self self reference
+     * @param endMarker String used as end marker for input
+     * @param prompt String used as input prompt
+     *
+     * @return output from evaluating the script
+     *
+     * @throws IOException if an exception occurs
+     */
+    public static Object evalinput(final Object self, final Object endMarker, final Object prompt) throws IOException {
+        return Global.eval(self, input(self, endMarker, prompt));
+    }
+
+    private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
+        return MH.findStatic(MethodHandles.lookup(), ShellFunctions.class, name, MH.type(rtype, types));
+    }
+}
--- a/src/jdk/nashorn/tools/resources/shell.js	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * Initialization script for shell when running in interactive mode.
- */
-
-/**
- * Reads zero or more lines from standard input and returns concatenated string
- *
- * @param endMarker marker string that signals end of input
- * @param prompt prompt printed for each line
- */
-Object.defineProperty(this, "input", {
-    value: function input(endMarker, prompt) {
-        if (!endMarker) {
-            endMarker = "";
-        }
-
-        if (!prompt) {
-            prompt = " >> ";
-        }
-
-        var imports = new JavaImporter(java.io, java.lang);
-        var str = "";
-        with (imports) {
-            var reader = new BufferedReader(new InputStreamReader(System['in']));
-            var line;
-            while (true) {
-                System.out.print(prompt);
-                line = reader.readLine();
-                if (line == null || line == endMarker) {
-                    break;
-                }
-                str += line + "\n";
-            }
-        }
-
-        return str;
-    },
-    enumerable: false,
-    writable: true,
-    configurable: true
-});
-
-
-/**
- * Reads zero or more lines from standard input and evaluates the concatenated
- * string as code
- *
- * @param endMarker marker string that signals end of input
- * @param prompt prompt printed for each line
- */
-Object.defineProperty(this, "evalinput", {
-    value: function evalinput(endMarker, prompt) {
-        var code = input(endMarker, prompt);
-        // make sure everything is evaluated in global scope!
-        return this.eval(code);
-    },
-    enumerable: false,
-    writable: true,
-    configurable: true
-});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/examples/json-parser-micro.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function bench() {
+    var start = Date.now();
+    for (var i = 0; i < 2000; i++) {
+        JSON.parse(String(json));
+    }
+    print("1000 iterations in", Date.now() - start, "millis");
+}
+
+var json = '[\
+  {\
+    "_id": "54ca34171d3ade49782294c8",\
+    "index": 0,\
+    "guid": "ed0e74d5-ac63-47b6-8938-1750abab5770",\
+    "isActive": false,\
+    "balance": "$1,996.19",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 39,\
+    "eyeColor": "green",\
+    "name": "Rose Graham",\
+    "gender": "male",\
+    "company": "PRIMORDIA",\
+    "email": "rosegraham@primordia.com",\
+    "phone": "+1 (985) 600-3551",\
+    "address": "364 Melba Court, Succasunna, Texas, 8393",\
+    "about": "Sunt commodo cillum occaecat velit eu eiusmod ex eiusmod sunt deserunt nulla proident incididunt. Incididunt ullamco Lorem elit do culpa esse do ex dolor aliquip labore. Ullamco velit laboris incididunt dolor. Nostrud dolor sint pariatur fugiat ullamco exercitation. Eu laboris do cupidatat eiusmod incididunt mollit occaecat voluptate.",\
+    "registered": "2014-03-13T12:05:14 -01:00",\
+    "latitude": 18.55665,\
+    "longitude": 81.641001,\
+    "tags": [\
+      "sint",\
+      "Lorem",\
+      "veniam",\
+      "quis",\
+      "proident",\
+      "consectetur",\
+      "consequat"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Evangelina Morgan"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Saunders Snyder"\
+      },\
+      {\
+        "id": 2,\
+        "name": "Walker Wood"\
+      }\
+    ],\
+    "greeting": "Hello, Rose Graham! You have 1 unread messages.",\
+    "favoriteFruit": "strawberry"\
+  },\
+  {\
+    "_id": "54ca34176790c4c60fcae085",\
+    "index": 1,\
+    "guid": "9dc42e4c-b58f-4d92-a2ee-968d2b627d92",\
+    "isActive": true,\
+    "balance": "$3,832.97",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 40,\
+    "eyeColor": "brown",\
+    "name": "Delaney Cherry",\
+    "gender": "male",\
+    "company": "INJOY",\
+    "email": "delaneycherry@injoy.com",\
+    "phone": "+1 (807) 463-2295",\
+    "address": "470 Hale Avenue, Mulberry, District Of Columbia, 5455",\
+    "about": "Deserunt sit cupidatat elit Lorem excepteur ex. Magna officia minim cupidatat nulla enim deserunt. Amet ex in tempor commodo consequat non ad qui elit cupidatat esse labore sint.",\
+    "registered": "2014-03-27T23:06:33 -01:00",\
+    "latitude": -4.984238,\
+    "longitude": 116.039285,\
+    "tags": [\
+      "minim",\
+      "velit",\
+      "aute",\
+      "minim",\
+      "id",\
+      "enim",\
+      "enim"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Barrera Flowers"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Leann Larson"\
+      },\
+      {\
+        "id": 2,\
+        "name": "Latoya Petty"\
+      }\
+    ],\
+    "greeting": "Hello, Delaney Cherry! You have 2 unread messages.",\
+    "favoriteFruit": "strawberry"\
+  },\
+  {\
+    "_id": "54ca3417920666f00c54bfc4",\
+    "index": 2,\
+    "guid": "f91e08f8-1598-49bc-a08b-bb48f0cc1751",\
+    "isActive": true,\
+    "balance": "$2,932.84",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 28,\
+    "eyeColor": "brown",\
+    "name": "Mosley Hammond",\
+    "gender": "male",\
+    "company": "AQUACINE",\
+    "email": "mosleyhammond@aquacine.com",\
+    "phone": "+1 (836) 598-2591",\
+    "address": "879 Columbia Place, Seymour, Montana, 4897",\
+    "about": "Sunt laborum incididunt et elit in deserunt deserunt irure enim ea qui non. Minim nisi sint aute veniam reprehenderit veniam reprehenderit. Elit enim eu voluptate eu cupidatat nulla ea incididunt exercitation voluptate ut aliquip excepteur ipsum. Consequat anim fugiat irure Lorem anim consectetur est.",\
+    "registered": "2014-07-27T05:05:58 -02:00",\
+    "latitude": -43.608015,\
+    "longitude": -38.33894,\
+    "tags": [\
+      "proident",\
+      "incididunt",\
+      "eiusmod",\
+      "anim",\
+      "consectetur",\
+      "qui",\
+      "excepteur"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Hanson Davidson"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Autumn Kaufman"\
+      },\
+      {\
+        "id": 2,\
+        "name": "Tammy Foley"\
+      }\
+    ],\
+    "greeting": "Hello, Mosley Hammond! You have 4 unread messages.",\
+    "favoriteFruit": "apple"\
+  },\
+  {\
+    "_id": "54ca341753b67572a2b04935",\
+    "index": 3,\
+    "guid": "3377416b-43a2-4f9e-ada3-2479e13b44b8",\
+    "isActive": false,\
+    "balance": "$3,821.54",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 31,\
+    "eyeColor": "green",\
+    "name": "Mueller Barrett",\
+    "gender": "male",\
+    "company": "GROK",\
+    "email": "muellerbarrett@grok.com",\
+    "phone": "+1 (890) 535-2834",\
+    "address": "571 Norwood Avenue, Westwood, Arkansas, 2164",\
+    "about": "Occaecat est sunt commodo ut ex excepteur elit nulla velit minim commodo commodo esse. Lorem quis eu minim consectetur. Cupidatat cupidatat consequat sit eu ex non quis nulla veniam sint enim excepteur. Consequat minim duis do do minim fugiat minim elit laborum ut velit. Occaecat laboris veniam sint reprehenderit.",\
+    "registered": "2014-07-18T17:15:35 -02:00",\
+    "latitude": 10.746577,\
+    "longitude": -160.266041,\
+    "tags": [\
+      "reprehenderit",\
+      "veniam",\
+      "sint",\
+      "commodo",\
+      "exercitation",\
+      "cillum",\
+      "sunt"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Summers Finch"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Tracie Mcdaniel"\
+      },\
+      {\
+        "id": 2,\
+        "name": "Ayers Patrick"\
+      }\
+    ],\
+    "greeting": "Hello, Mueller Barrett! You have 7 unread messages.",\
+    "favoriteFruit": "apple"\
+  },\
+  {\
+    "_id": "54ca34172775ab9615db0d1d",\
+    "index": 4,\
+    "guid": "a3102a3e-3f08-4df3-b5b5-62eff985d5ca",\
+    "isActive": true,\
+    "balance": "$3,962.27",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 34,\
+    "eyeColor": "green",\
+    "name": "Patrick Foster",\
+    "gender": "male",\
+    "company": "QUAREX",\
+    "email": "patrickfoster@quarex.com",\
+    "phone": "+1 (805) 577-2362",\
+    "address": "640 Richards Street, Roberts, American Samoa, 5530",\
+    "about": "Aute occaecat occaecat ad eiusmod esse aliqua ullamco minim. Exercitation aute ut ex nostrud deserunt laboris officia amet enim do. Cillum officia laborum occaecat eiusmod reprehenderit ex et aliqua minim elit ex aliqua mollit. Occaecat dolor in fugiat laboris aliquip nisi ad voluptate duis eiusmod ad do.",\
+    "registered": "2014-07-22T16:45:35 -02:00",\
+    "latitude": 6.609025,\
+    "longitude": -5.357026,\
+    "tags": [\
+      "ea",\
+      "ut",\
+      "excepteur",\
+      "enim",\
+      "ad",\
+      "non",\
+      "sit"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Duncan Lewis"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Alyce Benton"\
+      },\
+      {\
+        "id": 2,\
+        "name": "Angelique Larsen"\
+      }\
+    ],\
+    "greeting": "Hello, Patrick Foster! You have 1 unread messages.",\
+    "favoriteFruit": "strawberry"\
+  },\
+  {\
+    "_id": "54ca3417a190f26fef815f6d",\
+    "index": 5,\
+    "guid": "c09663dd-bb0e-45a4-960c-232c0e8a9486",\
+    "isActive": false,\
+    "balance": "$1,871.12",\
+    "picture": "http://placehold.it/32x32",\
+    "age": 20,\
+    "eyeColor": "blue",\
+    "name": "Foreman Chaney",\
+    "gender": "male",\
+    "company": "DEMINIMUM",\
+    "email": "foremanchaney@deminimum.com",\
+    "phone": "+1 (966) 523-2182",\
+    "address": "960 Granite Street, Sunnyside, Tennessee, 1097",\
+    "about": "Adipisicing nisi qui id sit incididunt aute exercitation veniam consequat ipsum sit irure. Aute officia commodo Lorem consequat. Labore exercitation consequat voluptate deserunt consequat do est fugiat nisi eu dolor minim id ea.",\
+    "registered": "2015-01-21T00:18:00 -01:00",\
+    "latitude": -69.841726,\
+    "longitude": 121.809383,\
+    "tags": [\
+      "laboris",\
+      "sunt",\
+      "exercitation",\
+      "enim",\
+      "anim",\
+      "excepteur",\
+      "tempor"\
+    ],\
+    "friends": [\
+      {\
+        "id": 0,\
+        "name": "Espinoza Johnston"\
+      },\
+      {\
+        "id": 1,\
+        "name": "Doreen Holder"\
+      },\
+      {\
+        "id": 2,\
+        "name": "William Ellison"\
+      }\
+    ],\
+    "greeting": "Hello, Foreman Chaney! You have 5 unread messages.",\
+    "favoriteFruit": "strawberry"\
+  }\
+]';
+
+for (var i = 0; i < 100; i++) {
+    bench();
+}
--- a/test/script/basic/8024180/with_java_object.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/8024180/with_java_object.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -1,1 +1,1 @@
-TypeError: Cannot apply "with" to non script object
+TypeError: Cannot apply "with" to non script object. Consider using "with(Object.bindProperties({}, nonScriptObject))".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8007456.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8007456: Nashorn test framework argument does not handle quoted strings
+ *
+ * @test
+ * @argument "hello world"
+ * @argument "This has spaces"
+ * @run
+ */
+
+print(arguments.length);
+print(arguments[0]);
+print(arguments[1]);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8007456.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+2
+hello world
+This has spaces
--- a/test/script/basic/JDK-8023026.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8023026.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -26,7 +26,7 @@
 reduceRight 15 1
 right sum 16
 squared 1,9,25,49
-iterating on [object Array]
+iterating on 2,4,6,8
 forEach 2
 forEach 4
 forEach 6
--- a/test/script/basic/JDK-8024847.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8024847.js	Fri Nov 13 15:38:44 2015 -0800
@@ -102,7 +102,18 @@
 print(jlist);
 
 var obj = new JSObject() {
-    toNumber: function() { return 42; }
+    getMember: function(name) {
+        if (name == "valueOf") {
+            return new JSObject() {
+                isFunction: function() {
+                    return true;
+                },
+                call: function(thiz) {
+                    return 42;
+                }
+            };
+        }
+    }
 };
 
 print(32 + obj);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8035712.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8035712: Restore some of the RuntimeCallSite specializations
+ *
+ * @test
+ * @run
+ */
+
+if ((typeof Assert) == "undefined") {
+    Assert = { 
+        assertTrue: function(x) { if(!x) { throw "expected true" } },
+        assertFalse: function(x) { if(x) { throw "expected false" } },
+    };
+}
+
+function nop() {}
+
+function EQ(x, y) {
+    // Exercise normal evaluation
+    Assert.assertTrue (x == y);
+    Assert.assertTrue (y == x);
+    Assert.assertFalse(x != y);
+    Assert.assertFalse(y != x);
+    // Exercise the branch optimizer
+    if (x == y) { nop(); } else { Assert.fail(); }
+    if (y == x) { nop(); } else { Assert.fail(); }
+    if (x != y) { Assert.fail(); } else { nop(); }
+    if (y != x) { Assert.fail(); } else { nop(); }
+}
+
+function NE(x, y) {
+    // Exercise normal evaluation
+    Assert.assertTrue (x != y);
+    Assert.assertTrue (y != x);
+    Assert.assertFalse(x == y);
+    Assert.assertFalse(y == x);
+    // Exercise the branch optimizer
+    if (x != y) { nop(); } else { Assert.fail(); }
+    if (y != x) { nop(); } else { Assert.fail(); }
+    if (x == y) { Assert.fail(); } else { nop(); }
+    if (y == x) { Assert.fail(); } else { nop(); }
+}
+
+function STRICT_EQ(x, y) {
+    // Exercise normal evaluation
+    Assert.assertTrue (x === y);
+    Assert.assertTrue (y === x);
+    Assert.assertFalse(x !== y);
+    Assert.assertFalse(y !== x);
+    // Exercise the branch optimizer
+    if (x === y) { nop(); } else { Assert.fail(); }
+    if (y === x) { nop(); } else { Assert.fail(); }
+    if (x !== y) { Assert.fail(); } else { nop(); }
+    if (y !== x) { Assert.fail(); } else { nop(); }
+}
+
+function STRICT_NE(x, y) {
+    // Exercise normal evaluation
+    Assert.assertTrue (x !== y);
+    Assert.assertTrue (y !== x);
+    Assert.assertFalse(x === y);
+    Assert.assertFalse(y === x);
+    // Exercise the branch optimizer
+    if (x !== y) { nop(); } else { Assert.fail(); }
+    if (y !== x) { nop(); } else { Assert.fail(); }
+    if (x === y) { Assert.fail(); } else { nop(); }
+    if (y === x) { Assert.fail(); } else { nop(); }
+}
+
+function cmpToAnyNumber(cmp, value) {
+    cmp(1, value);
+    cmp(4294967296, value);
+    cmp(1.2, value);
+    cmp(Infinity, value);
+    cmp(-Infinity, value);
+    cmp(1/Infinity, value);
+    cmp(0, value);
+    cmp(-0, value);
+    cmp(true, value);
+    cmp(false, value);
+}
+
+function notEqualToAnyNumber(value) {
+    cmpToAnyNumber(NE, value);
+    cmpToAnyNumber(STRICT_NE, value);
+}
+
+notEqualToAnyNumber(null);
+notEqualToAnyNumber(void 0);
+notEqualToAnyNumber("abc");
+notEqualToAnyNumber({});
+notEqualToAnyNumber(["xyz"]);
+
+function objectWithPrimitiveFunctionNotEqualToAnyNumber(fnName) {
+    var obj = {
+        count: 0
+    };
+    obj[fnName] = function() { this.count++; return "foo"; };
+    notEqualToAnyNumber(obj);
+    // Every NE will invoke it 8 times; cmpToAnyNumber has 10 comparisons
+    // STRICT_NE doesn't invoke toString.
+    Assert.assertTrue(80 === obj.count);
+}
+objectWithPrimitiveFunctionNotEqualToAnyNumber("valueOf");
+objectWithPrimitiveFunctionNotEqualToAnyNumber("toString");
+
+function objectEqualButNotStrictlyEqual(val, obj) {
+    EQ(val, obj);
+    STRICT_NE(val, obj);
+}
+
+function numberEqualButNotStrictlyEqualToObject(num, obj) {
+    objectEqualButNotStrictlyEqual(num, obj);
+    objectEqualButNotStrictlyEqual(num, [obj]);
+    objectEqualButNotStrictlyEqual(num, [[obj]]);
+}
+
+function numberEqualButNotStrictlyEqualToZeroObjects(num) {
+    numberEqualButNotStrictlyEqualToObject(num, [0]);
+    numberEqualButNotStrictlyEqualToObject(num, "");
+    numberEqualButNotStrictlyEqualToObject(num, []);
+    numberEqualButNotStrictlyEqualToObject(num, "0");
+}
+
+numberEqualButNotStrictlyEqualToZeroObjects(0);
+numberEqualButNotStrictlyEqualToZeroObjects(1/Infinity);
+numberEqualButNotStrictlyEqualToZeroObjects(false);
+
+function numberEqualButNotStrictlyEqualToObjectEquivalent(num) {
+    var str = String(num);
+    objectEqualButNotStrictlyEqual(num, str);
+    objectEqualButNotStrictlyEqual(num, { valueOf:  function() { return str }});
+    objectEqualButNotStrictlyEqual(num, { toString: function() { return str }});
+    objectEqualButNotStrictlyEqual(num, { valueOf:  function() { return num }});
+    objectEqualButNotStrictlyEqual(num, { toString: function() { return num }});
+}
+
+numberEqualButNotStrictlyEqualToObjectEquivalent(1);
+numberEqualButNotStrictlyEqualToObjectEquivalent(4294967296);
+numberEqualButNotStrictlyEqualToObjectEquivalent(1.2);
+numberEqualButNotStrictlyEqualToObjectEquivalent(Infinity);
+numberEqualButNotStrictlyEqualToObjectEquivalent(-Infinity);
+numberEqualButNotStrictlyEqualToObjectEquivalent(1/Infinity);
+numberEqualButNotStrictlyEqualToObjectEquivalent(0);
+numberEqualButNotStrictlyEqualToObjectEquivalent(-0);
+
+STRICT_EQ(1, new java.lang.Integer(1));
+STRICT_EQ(1, new java.lang.Double(1));
+STRICT_EQ(1.2, new java.lang.Double(1.2));
+
+function LE(x, y) {
+    // Exercise normal evaluation
+    Assert.assertTrue(x <= y);
+    Assert.assertTrue(y >= x);
+    Assert.assertFalse(x > y);
+    Assert.assertFalse(x < y);
+    // Exercise the branch optimizer
+    if (x <= y) { nop(); } else { Assert.fail(); }
+    if (y >= x) { nop(); } else { Assert.fail(); }
+    if (x > y) { Assert.fail(); } else { nop(); }
+    if (y < x) { Assert.fail(); } else { nop(); }
+}
+
+function mutuallyLessThanOrEqual(x, y) {
+    LE(x, y);
+    LE(y, x);
+}
+
+mutuallyLessThanOrEqual(0, null);
+mutuallyLessThanOrEqual(false, null);
+mutuallyLessThanOrEqual(1/Infinity, null);
+
+function mutuallyLessThanEqualToObjectWithValue(num, val) {
+    mutuallyLessThanOrEqual(num, { valueOf: function() { return val } });
+    mutuallyLessThanOrEqual(num, { toString: function() { return val } });
+}
+
+mutuallyLessThanEqualToObjectWithValue(false, 0);
+mutuallyLessThanEqualToObjectWithValue(false, "");
+
+mutuallyLessThanEqualToObjectWithValue(true, 1);
+mutuallyLessThanEqualToObjectWithValue(true, "1");
+
+function lessThanEqualToObjectEquivalent(num) {
+    var str = String(num);
+    mutuallyLessThanOrEqual(num, str);
+    mutuallyLessThanEqualToObjectWithValue(num, num);
+    mutuallyLessThanEqualToObjectWithValue(num, str);
+}
+
+lessThanEqualToObjectEquivalent(1);
+lessThanEqualToObjectEquivalent(4294967296);
+lessThanEqualToObjectEquivalent(1.2);
+lessThanEqualToObjectEquivalent(Infinity);
+lessThanEqualToObjectEquivalent(-Infinity);
+lessThanEqualToObjectEquivalent(1/Infinity);
+lessThanEqualToObjectEquivalent(0);
+lessThanEqualToObjectEquivalent(-0);
+
+function INCOMPARABLE(x, y) {
+    // Exercise normal evaluation
+    Assert.assertFalse(x < y);
+    Assert.assertFalse(x > y);
+    Assert.assertFalse(x <= y);
+    Assert.assertFalse(x >= y);
+    Assert.assertFalse(y < x);
+    Assert.assertFalse(y > x);
+    Assert.assertFalse(y <= x);
+    Assert.assertFalse(y >= x);
+    // Exercise the branch optimizer
+    if (x < y) { Assert.fail(); } else { nop(); }
+    if (x > y) { Assert.fail(); } else { nop(); }
+    if (x <= y) { Assert.fail(); } else { nop(); }
+    if (x >= y) { Assert.fail(); } else { nop(); }
+    if (y < x) { Assert.fail(); } else { nop(); }
+    if (y > x) { Assert.fail(); } else { nop(); }
+    if (y <= x) { Assert.fail(); } else { nop(); }
+    if (y >= x) { Assert.fail(); } else { nop(); }
+}
+
+function isIncomparable(value) {
+    cmpToAnyNumber(INCOMPARABLE, value);
+}
+
+isIncomparable(void 0);
+isIncomparable({ valueOf: function() { return NaN }});
+isIncomparable({ toString: function() { return NaN }});
+
+// Force ScriptRuntime.LT(Object, Object) etc. comparisons
+function cmpObj(fn, x, y) {
+    fn({valueOf: function() { return x }}, {valueOf: function() { return y }});
+}
+
+function LT(x, y) {
+    Assert.assertTrue(x < y);
+    Assert.assertTrue(y > x);
+    Assert.assertFalse(x >= y);
+    Assert.assertFalse(y <= x);
+}
+
+cmpObj(LT, 1, 2);
+cmpObj(LT, 1, "2");
+cmpObj(LT, "1", 2);
+cmpObj(LT, "a", "b");
+cmpObj(LT, -Infinity, 0);
+cmpObj(LT, 0, Infinity);
+cmpObj(LT, -Infinity, Infinity);
+cmpObj(INCOMPARABLE, 1, NaN);
+cmpObj(INCOMPARABLE, NaN, NaN);
+cmpObj(INCOMPARABLE, "boo", NaN);
+cmpObj(INCOMPARABLE, 1, "boo"); // boo number value will be NaN
+
+// Test that a comparison call site can deoptimize from (int, int) to (object, object)
+(function(){
+    var x = [1,  2,  "a"];
+    var y = [2, "3", "b"];
+    for(var i = 0; i < 3; ++i) {
+        Assert.assertTrue(x[i] < y[i]);
+    }
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8047365.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8047365: Very long function names break codegen
+ *
+ * @test
+ * @run
+ */
+
+// string of length 131071, twice the limit of UTF8 strings in ASM
+var longId = Array(0x20000).join("a");
+print(longId.length);
+
+eval("function " + longId + "(){ print('hello world'); }");
+eval("print(typeof " + longId + ")");
+eval("print(" + longId + ".name === longId)");
+eval("print(/a+/.exec(" + longId + ".toString())[0] === longId)");
+eval(longId + "()");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8047365.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,5 @@
+131071
+function
+true
+true
+hello world
--- a/test/script/basic/JDK-8051778.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8051778.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8053905.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8053905: Eager code generation fails for earley boyer with split threshold set to 1000
+ *
+ * @test
+ * @runif external.octane
+ * @fork
+ * @option -Dnashorn.compiler.splitter.threshold=1000
+ * @option -scripting
+ * @option --lazy-compilation=false
+ */
+
+var fn  = __DIR__ + 'compile-octane.js';
+arguments.push("earley-boyer"); // run only earley-boyer
+var url = new java.io.File(fn).toURL();
+load(url);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8053905.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+Compiling 'earley-boyer'...
+Done.
--- a/test/script/basic/JDK-8055762.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8055762.js	Fri Nov 13 15:38:44 2015 -0800
@@ -74,9 +74,12 @@
         }
     };
 
+    var a = "a";
     print(obj["foo"]);
+    print(obj[a + "bc"]);
     print(obj[2]);
     obj.bar = 23;
+    obj[a + "bc"] = 23;
     obj[3] = 23;
     obj.func("hello");
 }
--- a/test/script/basic/JDK-8055762.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8055762.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,7 @@
 FOO
+ABC
 0
 bar set to 23
+abc set to 23
 [3] set to 23
 func called with hello
--- a/test/script/basic/JDK-8058610.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8058610.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- a/test/script/basic/JDK-8061113.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8061113.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8062141.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8062141: Various performance issues parsing JSON
+ *
+ * @test
+ * @run
+ */
+
+function testJson(json) {
+    try {
+        print(JSON.stringify(JSON.parse(json)));
+    } catch (error) {
+        print(error);
+    }
+}
+
+testJson('"\\u003f"');
+testJson('"\\u0"');
+testJson('"\\u0"');
+testJson('"\\u00"');
+testJson('"\\u003"');
+testJson('"\\u003x"');
+testJson('"\\"');
+testJson('"');
+testJson('+1');
+testJson('-1');
+testJson('1.');
+testJson('.1');
+testJson('01');
+testJson('1e');
+testJson('1e0');
+testJson('1a');
+testJson('1e+');
+testJson('1e-');
+testJson('0.0e+0');
+testJson('0.0e-0');
+testJson('[]');
+testJson('[ 1 ]');
+testJson('[1,]');
+testJson('[ 1 , 2 ]');
+testJson('[1, 2');
+testJson('{}');
+testJson('{ "a" : "b" }');
+testJson('{ "a" : "b" ');
+testJson('{ "a" : }');
+testJson('true');
+testJson('tru');
+testJson('true1');
+testJson('false');
+testJson('fals');
+testJson('falser');
+testJson('null');
+testJson('nul');
+testJson('null0');
+testJson('{} 0');
+testJson('{} a');
+testJson('[] 0');
+testJson('[] a');
+testJson('1 0');
+testJson('1 a');
+testJson('["a":true]');
+testJson('{"a",truer}');
+testJson('{"a":truer}');
+testJson('[1, 2, 3]');
+testJson('[9223372036854774000, 9223372036854775000, 9223372036854776000]');
+testJson('[1.1, 1.2, 1.3]');
+testJson('[1, 1.2, 9223372036854776000, null, true]');
+testJson('{ "a" : "string" , "b": 1 , "c" : 1.2 , "d" : 9223372036854776000 , "e" : null , "f" : true }');
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8062141.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,120 @@
+"?"
+SyntaxError: Invalid JSON: <json>:1:4 Invalid hex digit
+"\u0"
+    ^
+SyntaxError: Invalid JSON: <json>:1:4 Invalid hex digit
+"\u0"
+    ^
+SyntaxError: Invalid JSON: <json>:1:5 Invalid hex digit
+"\u00"
+     ^
+SyntaxError: Invalid JSON: <json>:1:6 Invalid hex digit
+"\u003"
+      ^
+SyntaxError: Invalid JSON: <json>:1:6 Invalid hex digit
+"\u003x"
+      ^
+SyntaxError: Invalid JSON: <json>:1:3 Missing close quote
+"\"
+   ^
+SyntaxError: Invalid JSON: <json>:1:1 Missing close quote
+"
+ ^
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found +
++1
+^
+-1
+SyntaxError: Invalid JSON: <json>:1:2 Invalid JSON number format
+1.
+  ^
+SyntaxError: Invalid JSON: <json>:1:0 Invalid JSON number format
+.1
+^
+SyntaxError: Invalid JSON: <json>:1:1 Expected eof but found 1
+01
+ ^
+SyntaxError: Invalid JSON: <json>:1:2 Invalid JSON number format
+1e
+  ^
+1
+SyntaxError: Invalid JSON: <json>:1:1 Expected eof but found a
+1a
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Invalid JSON number format
+1e+
+   ^
+SyntaxError: Invalid JSON: <json>:1:3 Invalid JSON number format
+1e-
+   ^
+0
+0
+[]
+[1]
+SyntaxError: Invalid JSON: <json>:1:3 Trailing comma is not allowed in JSON
+[1,]
+   ^
+[1,2]
+SyntaxError: Invalid JSON: <json>:1:5 Expected , or ] but found eof
+[1, 2
+     ^
+{}
+{"a":"b"}
+SyntaxError: Invalid JSON: <json>:1:12 Expected , or } but found eof
+{ "a" : "b" 
+            ^
+SyntaxError: Invalid JSON: <json>:1:8 Expected json literal but found }
+{ "a" : }
+        ^
+true
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+tru
+^
+SyntaxError: Invalid JSON: <json>:1:4 Expected eof but found 1
+true1
+    ^
+false
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+fals
+^
+SyntaxError: Invalid JSON: <json>:1:5 Expected eof but found r
+falser
+     ^
+null
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+nul
+^
+SyntaxError: Invalid JSON: <json>:1:4 Expected eof but found 0
+null0
+    ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found 0
+{} 0
+   ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found a
+{} a
+   ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found 0
+[] 0
+   ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found a
+[] a
+   ^
+SyntaxError: Invalid JSON: <json>:1:2 Expected eof but found 0
+1 0
+  ^
+SyntaxError: Invalid JSON: <json>:1:2 Expected eof but found a
+1 a
+  ^
+SyntaxError: Invalid JSON: <json>:1:4 Expected , or ] but found :
+["a":true]
+    ^
+SyntaxError: Invalid JSON: <json>:1:4 Expected : but found ,
+{"a",truer}
+    ^
+SyntaxError: Invalid JSON: <json>:1:9 Expected , or } but found r
+{"a":truer}
+         ^
+[1,2,3]
+[9223372036854773800,9223372036854774800,9223372036854776000]
+[1.1,1.2,1.3]
+[1,1.2,9223372036854776000,null,true]
+{"a":"string","b":1,"c":1.2,"d":9223372036854776000,"e":null,"f":true}
--- a/test/script/basic/JDK-8062799.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8062799.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
@@ -100,4 +100,4 @@
 
     
     
-        
\ No newline at end of file
+        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066214.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066214: Fuzzing bug: Object.prototype.toLocaleString(0)
+ *
+ * @test
+ * @run
+ */
+
+function test(func) {
+    print(func.call(0));
+    print(func.call("abc"));
+    print(func.call(true));
+    try {
+        print(func.call(undefined));
+    } catch (e) {
+        print(e);
+    }
+    try {
+        print(func.call(null));
+    } catch (e) {
+        print(e);
+    }
+}
+
+test(Object.prototype.toLocaleString);
+test(Object.prototype.toString);
+test(Object.prototype.valueOf);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066214.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,15 @@
+0
+abc
+true
+TypeError: undefined is not an Object
+TypeError: null is not an Object
+[object Number]
+[object String]
+[object Boolean]
+[object Undefined]
+[object Null]
+0
+abc
+true
+TypeError: undefined is not an Object
+TypeError: null is not an Object
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066215.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066215: Fuzzing bug: length valueOf bug
+ *
+ * @test
+ * @run
+ */
+
+function defineLength(arr, length) {
+    Object.defineProperty(arr, "length", {
+        value: {
+            valueOf: function() {
+                print("value retrieved: " + length);
+                return length;
+            }
+        }
+    });
+    print("done: " + arr.length + ", " + typeof arr.length);
+}
+
+var a = [];
+defineLength(a, 3);
+defineLength(a, 6);
+defineLength(a, 3);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066215.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,9 @@
+value retrieved: 3
+value retrieved: 3
+done: 3, number
+value retrieved: 6
+value retrieved: 6
+done: 6, number
+value retrieved: 3
+value retrieved: 3
+done: 3, number
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066220.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066220: Fuzzing bug: MethodHandle bug (Object,Object) != (boolean)Object
+ *
+ * @test
+ * @run
+ */
+
+
+function f() {}
+// Call f with primitive this first, then as constructor
+f.call(1);
+new f();
+
+// Same as above in strict mode
+eval('"use strict"; function e() { print(typeof this); } e.call(1); new e();');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066220.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+number
+object
--- a/test/script/basic/JDK-8066221.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066221.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066222.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066222: too strong assertion on function expression names
+ *
+ * @test
+ * @run
+ */
+
+// Has to print "SUCCESS"
+(function x (x){print(x)})("SUCCESS");
+
+// Has to print "undefined" and "1", not the function source in any case.
+(function x(){print(x); var x=1; print(x)})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066222.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+SUCCESS
+undefined
+1
--- a/test/script/basic/JDK-8066224.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066224.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- a/test/script/basic/JDK-8066225.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066225.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066226.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ *
+ JDK-8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
+ *
+ * @test
+ * @run
+ */
+
+Object.defineProperty(Object.prototype, "accessor", {
+    set: function(value) {
+        print("Setting accessor on " + this + " to " + value);
+    }
+});
+
+Object.defineProperty(Object.prototype, "getterOnly", {
+    get: function() {
+        return 1;
+    }
+});
+
+function set(o) {
+    print("set(" + o + ")");
+    o.foo = 1;
+    o.constructor = 1;
+    o.accessor = 1;
+    o.getterOnly = 1;
+    print();
+}
+
+function setStrict(o) {
+    "use strict";
+    print("setStrict(" + o + ")")
+    try {
+        o.foo = 1;
+    } catch (e) {
+        print(e);
+    }
+    try {
+        o.constructor = 1;
+    } catch (e) {
+        print(e);
+    }
+    try {
+        o.accessor = 1;
+    } catch (e) {
+        print(e);
+    }
+    try {
+        o.getterOnly = 1;
+    } catch (e) {
+        print(e);
+    }
+    print();
+}
+
+function setAttr(o, id) {
+    print("setAttr(" + o + ", " + id + ")")
+    o[id] = 1;
+    print();
+}
+
+function setAttrStrict(o, id) {
+    "use strict";
+    print("setAttrStrict(" + o + ", " + id + ")")
+    try {
+        o[id] = 1;
+    } catch (e) {
+        print(e);
+    }
+    print();
+}
+
+set(1);
+set("str");
+set(true);
+set({});
+set([]);
+
+setStrict(1);
+setStrict("str");
+setStrict(true);
+setStrict({});
+setStrict([]);
+
+setAttr(1, "foo");
+setAttr(1, "constructor");
+setAttr(1, "accessor");
+setAttr(1, "getterOnly");
+setAttr("str", "foo");
+setAttr("str", "constructor");
+setAttr("str", "accessor");
+setAttr("str", "getterOnly");
+setAttr(true, "foo");
+setAttr(true, "constructor");
+setAttr(true, "accessor");
+setAttr(true, "getterOnly");
+
+setAttrStrict(1, "foo");
+setAttrStrict(1, "constructor");
+setAttrStrict(1, "accessor");
+setAttrStrict(1, "getterOnly");
+setAttrStrict("str", "foo");
+setAttrStrict("str", "constructor");
+setAttrStrict("str", "accessor");
+setAttrStrict("str", "getterOnly");
+setAttrStrict(true, "foo");
+setAttrStrict(true, "constructor");
+setAttrStrict(true, "accessor");
+setAttrStrict(true, "getterOnly");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066226.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,104 @@
+set(1)
+Setting accessor on 1 to 1
+
+set(str)
+Setting accessor on str to 1
+
+set(true)
+Setting accessor on true to 1
+
+set([object Object])
+Setting accessor on [object Object] to 1
+
+set()
+Setting accessor on  to 1
+
+setStrict(1)
+TypeError: "foo" is not a writable property of 1
+TypeError: "constructor" is not a writable property of 1
+Setting accessor on 1 to 1
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setStrict(str)
+TypeError: "foo" is not a writable property of str
+TypeError: "constructor" is not a writable property of str
+Setting accessor on str to 1
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setStrict(true)
+TypeError: "foo" is not a writable property of true
+TypeError: "constructor" is not a writable property of true
+Setting accessor on true to 1
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setStrict([object Object])
+Setting accessor on [object Object] to 1
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setStrict()
+Setting accessor on  to 1
+TypeError: Cannot set property "getterOnly" of [object Array] that has only a getter
+
+setAttr(1, foo)
+
+setAttr(1, constructor)
+
+setAttr(1, accessor)
+Setting accessor on 1 to 1
+
+setAttr(1, getterOnly)
+
+setAttr(str, foo)
+
+setAttr(str, constructor)
+
+setAttr(str, accessor)
+Setting accessor on str to 1
+
+setAttr(str, getterOnly)
+
+setAttr(true, foo)
+
+setAttr(true, constructor)
+
+setAttr(true, accessor)
+Setting accessor on true to 1
+
+setAttr(true, getterOnly)
+
+setAttrStrict(1, foo)
+TypeError: "foo" is not a writable property of 1
+
+setAttrStrict(1, constructor)
+TypeError: "constructor" is not a writable property of 1
+
+setAttrStrict(1, accessor)
+Setting accessor on 1 to 1
+
+setAttrStrict(1, getterOnly)
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setAttrStrict(str, foo)
+TypeError: "foo" is not a writable property of str
+
+setAttrStrict(str, constructor)
+TypeError: "constructor" is not a writable property of str
+
+setAttrStrict(str, accessor)
+Setting accessor on str to 1
+
+setAttrStrict(str, getterOnly)
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
+setAttrStrict(true, foo)
+TypeError: "foo" is not a writable property of true
+
+setAttrStrict(true, constructor)
+TypeError: "constructor" is not a writable property of true
+
+setAttrStrict(true, accessor)
+Setting accessor on true to 1
+
+setAttrStrict(true, getterOnly)
+TypeError: Cannot set property "getterOnly" of [object Object] that has only a getter
+
--- a/test/script/basic/JDK-8066227.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066227.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- a/test/script/basic/JDK-8066230.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066230.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066232.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066232: problem with conditional catch compilation
+ *
+ * @test
+ * @run
+ */
+
+(function () { 
+    try {
+        x;
+    } catch(e if 1) {
+    }
+})()
+
+print("SUCCESS");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066232.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,1 @@
+SUCCESS
--- a/test/script/basic/JDK-8066236.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8066236.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066237.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066237: Fuzzing bug: Parser error on optimistic recompilation
+ *
+ * @test
+ * @run
+ */
+
+try {
+    (function() {
+        eval("get, a")
+    })();
+    fail("should have thrown");
+} catch (e) {
+    Assert.assertTrue(e.name === "ReferenceError");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8066407.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8066407: Function with same body not reparsed after SyntaxError
+ *
+ * @test
+ * @run
+ */
+
+function testFunction(body) {
+    try {
+        Function(body);
+        Assert.fail("Should have thrown");
+    } catch (e) {
+        Assert.assertEquals(e.name, "SyntaxError");
+        count++;
+    }
+
+}
+
+var count = 0;
+
+testFunction("/a/r");
+testFunction("/a/r");
+testFunction("/a/r");
+
+Assert.assertTrue(count === 3);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8067139.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8067139: Finally blocks inlined incorrectly
+ *
+ * @test
+ * @run
+ */
+
+// Test case for JDK-8067139
+// as well as for JDK-8030198 which is a duplicate.
+(function(){
+    var catchCount = 0; 
+    try {
+        (function (){
+            try { 
+                return; 
+            } catch(x) { 
+                ++catchCount;
+            } finally { 
+                throw 0; 
+            } 
+        })();
+        Assert.fail(); // must throw
+    } catch(e) {
+        Assert.assertEquals(e, 0); // threw 0
+        Assert.assertEquals(catchCount, 0); // inner catch never executed
+    }
+})();
+
+// Test case for JDK-8048862 which is a duplicate of this bug
+var ret = (function(o) { 
+    try{
+        with(o) {
+            return x;
+        }
+    } finally {
+        try { 
+            return x;
+        } catch(e) {
+            Assert.assertTrue(e instanceof ReferenceError);
+            return 2;
+        }
+    }
+})({x: 1});
+Assert.assertEquals(ret, 2); // executed the catch block
+
+// Test cases for JDK-8066231 that is a duplicate of this bug
+// Case 1
+(function (){ try { Object; } catch(x if x >>>=0) { throw x2; } finally { } })();
+// Case 2
+try {
+    (function (){ try { return; } catch(x) { return x ^= 0; } finally { throw 0; } })();
+    Assert.fail();
+} catch(e) {
+    Assert.assertEquals(e, 0); // threw 0
+}
+// Case 3
+try {
+    (function (){ try { return; } catch(x) { return x ^= Object; } finally { throw Object; } })();
+    Assert.fail();
+} catch(e) {
+    Assert.assertEquals(e, Object); // threw Object
+}
+// Case from comment
+try {
+    (function () { try { Object } catch(x) { (x=y); return; } finally { throw Object; } })();
+    Assert.fail();
+} catch(e) {
+    Assert.assertEquals(e, Object); // threw Object
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8067774.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8067774: Use a stack of types when calculating local variable types
+ *
+ * @test
+ * @run
+ */
+
+print((function (p) {
+    var a, b;
+    
+    a = p ? ((b = 1), b) : 0;
+
+    return a;
+})(true));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8067774.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,1 @@
+1
--- a/test/script/basic/JDK-8068573.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8068573.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8068580.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8068580: make JavaAdapterFactory.isAutoConvertibleFromFunction more robust
+ *
+ * @test
+ * @run
+ */
+
+var BigAbstract = Java.type("jdk.nashorn.test.models.BigAbstract")
+try {
+    new BigAbstract({});
+} catch (e) {
+    Assert.assertTrue(e instanceof TypeError);
+    Assert.assertEquals(e.message, "Can not extend/implement [class jdk.nashorn.test.models.BigAbstract] because of java.lang.RuntimeException: Method code too large!");
+}
+try {
+    BigAbstract.accept(function() { });
+} catch (e) {
+    Assert.assertSame(e.class, java.lang.ClassCastException.class);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8068872.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8068872:  Nashorn JSON.parse drops numeric keys
+ *
+ * @test
+ * @run
+ */
+
+print(JSON.stringify(JSON.parse('{"3": 1, "5": "a"}')));
+print(JSON.stringify(JSON.parse('{"5": 1, "3": "a"}')));
+print(JSON.stringify(JSON.parse('{"0": 1, "4294967294": "a"}')));
+print(JSON.stringify(JSON.parse('{"4294967294": 1, "0": "a"}')));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8068872.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,4 @@
+{"3":1,"5":"a"}
+{"3":"a","5":1}
+{"0":1,"4294967294":"a"}
+{"0":"a","4294967294":1}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8068985.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
+ *
+ * @test
+ * @run
+ */
+
+function func(arg) {
+  (function() { print(eval('this')); }).call(arg);
+}
+
+// primitives
+func(undefined);
+func(null);
+func(34.23);
+func("hello");
+func(false);
+
+// script objects
+func(this);
+func({});
+func({ toString: function() { return "foo" } });
+
+// java objects
+func(new java.util.Vector());
+var m = new java.util.HashMap();
+m.put("foo", "bar");
+func(m);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8068985.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,10 @@
+[object global]
+[object global]
+34.23
+hello
+false
+[object global]
+[object Object]
+foo
+[]
+{foo=bar}
--- a/test/script/basic/JDK-8069002.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/JDK-8069002.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,21 +1,21 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8071928.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8071928: Instance properties with getters returning wrong values
+ *
+ * @test
+ * @run
+ */
+
+
+var types = {};
+
+function Type() {}
+
+Type.prototype.getName = function() {
+    return this._name;
+};
+
+function defineType(init) {
+    return Object.create(Type.prototype, {
+        _name: { get: function() { return init.name; } }
+    });
+}
+
+types.A = defineType({ name: 'A' });
+types.B = defineType({ name: 'B' });
+types.C = defineType({ name: 'C' });
+types.D = defineType({ name: 'D' });
+
+var keys = Object.keys(types);
+for (var i = 0; i < keys.length; i++) {
+    var t = types[keys[i]];
+    if (t.getName() != keys[i]) {
+        throw 'wrong name for ' + keys[i] + ': ' + t.getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8072426.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8072426: Can't compare Java objects to strings or numbers
+ *
+ * @test
+ * @run
+ */
+
+Assert.assertTrue(java.math.RoundingMode.UP == "UP");
+
+var JSObject = Java.type("jdk.nashorn.api.scripting.JSObject");
+
+// Adds an "isFunction" member to the JSObject that returns the specified value
+function addIsFunction(isFunction, obj) {
+    obj.isFunction = function() {
+        return isFunction;
+    };
+    return obj;
+}
+
+function makeJSObjectConstantFunction(value) {
+    return new JSObject(addIsFunction(true, {
+        call: function() {
+            return value;
+        }
+    }));
+}
+
+function makeJSObjectWithMembers(mapping) {
+    return new JSObject({
+        getMember: function(name) {
+            Assert.assertTrue(mapping.hasOwnProperty(name));
+            return mapping[name];
+        },
+        toNumber: function() {
+            // toNumber no longer invoked
+            Assert.fail();
+        }
+    });
+}
+
+// Test JSObjectLinker toInt32/toLong/toNumber
+function testNumericJSObject(kind, value) {
+    var obj = makeJSObjectWithMembers({
+            valueOf: makeJSObjectConstantFunction(value)
+        });
+
+    if (kind === "double") {
+        // There's no assertEquals(double actual, double expected). There's only
+        // assertEquals(double actual, double expected, double delta).
+        Assert["assertEquals(double,double,double)"](value, obj, 0);
+    } else {
+        Assert["assertEquals(" + kind + ", " + kind + ")"](value, obj);
+    }
+    Assert.assertTrue(value == Number(obj));
+}
+testNumericJSObject("int", 42);
+testNumericJSObject("long", 4294967296);
+testNumericJSObject("double", 1.2);
+
+// Test fallback from toNumber to toString for numeric conversion when toNumber doesn't exist
+(function() {
+    var obj = makeJSObjectWithMembers({
+        valueOf:  null, // Explicitly no valueOf
+        toString: makeJSObjectConstantFunction("123")
+    });
+    Assert["assertEquals(int,int)"](123, obj);
+})();
+
+// Test fallback from toNumber to toString for numeric conversion when toNumber isn't a callable
+(function() {
+    var obj = makeJSObjectWithMembers({
+        valueOf:  new JSObject(addIsFunction(false, {})),
+        toString: makeJSObjectConstantFunction("124")
+    });
+    Assert["assertEquals(int,int)"](124, obj);
+})();
+
+// Test fallback from toNumber to toString for numeric conversion when toNumber returns a non-primitive
+(function() {
+    var obj = makeJSObjectWithMembers({
+        valueOf:  makeJSObjectConstantFunction({}),
+        toString: makeJSObjectConstantFunction("125")
+    });
+    Assert["assertEquals(int,int)"](125, obj);
+})();
+
+// Test TypeError from toNumber to toString when both return a non-primitive
+(function() {
+    var obj = makeJSObjectWithMembers({
+        valueOf:  makeJSObjectConstantFunction({}),
+        toString: makeJSObjectConstantFunction({})
+    });
+    try {
+        Number(obj);
+        Assert.fail(); // must throw
+    } catch(e) {
+        Assert.assertTrue(e instanceof TypeError); 
+    }
+})();
+
+// Test toString for string conversion
+(function() {
+    var obj = makeJSObjectWithMembers({
+        toString: makeJSObjectConstantFunction("Hello")
+    });
+    Assert.assertTrue("Hello" === String(obj));
+    Assert["assertEquals(String,String)"]("Hello", obj);
+})();
+
+// Test fallback from toString to valueOf for string conversion when toString doesn't exist
+(function() {
+    var obj = makeJSObjectWithMembers({
+        toString: null,
+        valueOf:  makeJSObjectConstantFunction("Hello1")
+    });
+    Assert.assertTrue("Hello1" === String(obj));
+    Assert["assertEquals(String,String)"]("Hello1", obj);
+})();
+
+// Test fallback from toString to valueOf for string conversion when toString is not callable
+(function() {
+    var obj = makeJSObjectWithMembers({
+        toString: new JSObject(addIsFunction(false, {})),
+        valueOf:  makeJSObjectConstantFunction("Hello2")
+    });
+    Assert["assertEquals(String,String)"]("Hello2", obj);
+})();
+
+// Test fallback from toString to valueOf for string conversion when toString returns non-primitive
+(function() {
+    var obj = makeJSObjectWithMembers({
+        toString: makeJSObjectConstantFunction({}),
+        valueOf:  makeJSObjectConstantFunction("Hello3")
+    });
+    Assert["assertEquals(String,String)"]("Hello3", obj);
+})();
+
+// Test toBoolean for JSObject
+(function() {
+    Assert["assertEquals(boolean,boolean)"](true, new JSObject({}));
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8072596.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8072596: Arrays.asList results in ClassCastException with a JS array
+ *
+ * @test
+ * @run
+ */
+var arr = java.util.Arrays.asList("hello world".split(' '));
+// We split it into a list of two elements: [hello, world]
+Assert.assertTrue(arr instanceof java.util.List);
+Assert.assertEquals(arr.length, 2);
+Assert.assertEquals(arr[0], "hello");
+Assert.assertEquals(arr[1], "world");
+
+var Jdk8072596TestSubject = Java.type("jdk.nashorn.test.models.Jdk8072596TestSubject");
+var testSubject = new Jdk8072596TestSubject({bar: 0});
+testSubject.test1(true, {foo: 1}, {bar: 2});
+testSubject.test2(true, {foo: 1}, {bar: 2}, {baz: 3}, {bing: 4});
+var h = "h";
+var ello = "ello";
+testSubject.test3(true, {foo: 5}, /* ConsString, why not */ h + ello, [6, 7], 8);
+Jdk8072596TestSubject.test4({foo: 9});
+
+// Test wrapping setters arguments and unwrapping getters return values on list.
+var list = new java.util.ArrayList();
+list.add(null);
+var obj0 = {valueOf: function() { return 0; }};
+var obj1 = {foo: 10};
+list[obj0] = obj1;
+testSubject.testListHasWrappedObject(list);
+// NOTE: can't use Assert.assertSame(obj1, list[obj0]), as the arguments would end up being wrapped...
+Assert.assertTrue(obj1 === list[obj0]);
+
+// Test wrapping setters arguments and unwrapping getters return values on array.
+var arr2 = new (Java.type("java.lang.Object[]"))(1);
+var obj2 = {bar: 11};
+arr2[obj0] = obj2;
+testSubject.testArrayHasWrappedObject(arr2);
+Assert.assertTrue(obj2 === arr2[obj0]);
+
+// Test wrapping setters index and arguments and getters index, and unwrapping getters return values on map.
+// Since ScriptObjectMirror.equals() uses underlying ScriptObject identity, using them as map keys works.
+var map = new java.util.HashMap();
+var obj3 = {bar: 12};
+map[obj0] = obj3;
+testSubject.testMapHasWrappedObject(map, obj0);
+Assert.assertTrue(obj3 === map[obj0]);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8073846.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8073846: Javascript for-in loop returned extra keys
+ *
+ * @test
+ * @run
+ */
+
+var obj = {};
+
+var list = [
+    '2100000',
+    '420000',
+    '430000'
+];
+
+for (var i = 0; i < list.length; i++) {
+    if (obj[list[i]]) print("duplicate: " + list[i]);
+    obj[list[i]] = 'obj' + list[i]
+}
+
+var count = 0;
+for (var a in obj) {
+    count++;
+    if ('obj' + a !== obj[a]) {
+        throw 'wrong key or value: ' + a + ', ' + obj[a];
+    }
+}
+
+if (count !== 3) {
+    throw 'wrong entry count: ' + count;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8073868.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8073868: Regex matching causes java.lang.ArrayIndexOutOfBoundsException: 64
+ *
+ * @test
+ * @run
+ */
+
+function test(input) {
+    var comma = input.indexOf(",");
+    Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[0], input.trimLeft());
+    Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[1], input.substring(0, comma).trimLeft());
+    Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[2], input.substring(comma + 1));
+    Assert.assertEquals(/(.*)+/.exec(input)[0], input);
+    Assert.assertEquals(/(.*)+/.exec(input)[1], input);
+}
+
+test(" xxxx,         xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+test("x,         xxxxxxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+
+Assert.assertEquals(/(?:\1a|())*/.exec("a")[0], "a");
+Assert.assertEquals(/(?:\1a|())*/.exec("a")[1], undefined);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074021.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8074021: Indirect eval fails when used as an element of an array or as a property of an object
+ *
+ * @test
+ * @run
+ */
+
+var obj = { foo: eval };
+Assert.assertTrue(obj.foo("typeof(print) == 'function'"));
+Assert.assertTrue(obj.foo("RegExp instanceof Function"));
+Assert.assertEquals(obj.foo("String(new Array(2, 4, 3))"), "2,4,3");
+obj.foo("print('hello')");
+
+var args = [ eval ];
+Assert.assertTrue(args[0]("typeof(print) == 'function'"));
+Assert.assertTrue(args[0]("RegExp instanceof Function"));
+Assert.assertEquals(args[0]("String(new Array(2, 4, 3))"), "2,4,3");
+args[0]("print('hello')");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074021.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+hello
+hello
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074545.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,1038 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8074545: Undefined object values in object literals with spill properties
+ *
+ * @test
+ * @run
+ */
+
+var obj = {
+    "p0": { "x" : 0 },
+    "p1": { "x" : 1 },
+    "p2": { "x" : 2 },
+    "p3": { "x" : 3 },
+    "p4": { "x" : 4 },
+    "p5": { "x" : 5 },
+    "p6": { "x" : 6 },
+    "p7": { "x" : 7 },
+    "p8": { "x" : 8 },
+    "p9": { "x" : 9 },
+    "p10": { "x" : 10 },
+    "p11": { "x" : 11 },
+    "p12": { "x" : 12 },
+    "p13": { "x" : 13 },
+    "p14": { "x" : 14 },
+    "p15": { "x" : 15 },
+    "p16": { "x" : 16 },
+    "p17": { "x" : 17 },
+    "p18": { "x" : 18 },
+    "p19": { "x" : 19 },
+    "p20": { "x" : 20 },
+    "p21": { "x" : 21 },
+    "p22": { "x" : 22 },
+    "p23": { "x" : 23 },
+    "p24": { "x" : 24 },
+    "p25": { "x" : 25 },
+    "p26": { "x" : 26 },
+    "p27": { "x" : 27 },
+    "p28": { "x" : 28 },
+    "p29": { "x" : 29 },
+    "p30": { "x" : 30 },
+    "p31": { "x" : 31 },
+    "p32": { "x" : 32 },
+    "p33": { "x" : 33 },
+    "p34": { "x" : 34 },
+    "p35": { "x" : 35 },
+    "p36": { "x" : 36 },
+    "p37": { "x" : 37 },
+    "p38": { "x" : 38 },
+    "p39": { "x" : 39 },
+    "p40": { "x" : 40 },
+    "p41": { "x" : 41 },
+    "p42": { "x" : 42 },
+    "p43": { "x" : 43 },
+    "p44": { "x" : 44 },
+    "p45": { "x" : 45 },
+    "p46": { "x" : 46 },
+    "p47": { "x" : 47 },
+    "p48": { "x" : 48 },
+    "p49": { "x" : 49 },
+    "p50": { "x" : 50 },
+    "p51": { "x" : 51 },
+    "p52": { "x" : 52 },
+    "p53": { "x" : 53 },
+    "p54": { "x" : 54 },
+    "p55": { "x" : 55 },
+    "p56": { "x" : 56 },
+    "p57": { "x" : 57 },
+    "p58": { "x" : 58 },
+    "p59": { "x" : 59 },
+    "p60": { "x" : 60 },
+    "p61": { "x" : 61 },
+    "p62": { "x" : 62 },
+    "p63": { "x" : 63 },
+    "p64": { "x" : 64 },
+    "p65": { "x" : 65 },
+    "p66": { "x" : 66 },
+    "p67": { "x" : 67 },
+    "p68": { "x" : 68 },
+    "p69": { "x" : 69 },
+    "p70": { "x" : 70 },
+    "p71": { "x" : 71 },
+    "p72": { "x" : 72 },
+    "p73": { "x" : 73 },
+    "p74": { "x" : 74 },
+    "p75": { "x" : 75 },
+    "p76": { "x" : 76 },
+    "p77": { "x" : 77 },
+    "p78": { "x" : 78 },
+    "p79": { "x" : 79 },
+    "p80": { "x" : 80 },
+    "p81": { "x" : 81 },
+    "p82": { "x" : 82 },
+    "p83": { "x" : 83 },
+    "p84": { "x" : 84 },
+    "p85": { "x" : 85 },
+    "p86": { "x" : 86 },
+    "p87": { "x" : 87 },
+    "p88": { "x" : 88 },
+    "p89": { "x" : 89 },
+    "p90": { "x" : 90 },
+    "p91": { "x" : 91 },
+    "p92": { "x" : 92 },
+    "p93": { "x" : 93 },
+    "p94": { "x" : 94 },
+    "p95": { "x" : 95 },
+    "p96": { "x" : 96 },
+    "p97": { "x" : 97 },
+    "p98": { "x" : 98 },
+    "p99": { "x" : 99 },
+    "p100": { "x" : 100 },
+    "p101": { "x" : 101 },
+    "p102": { "x" : 102 },
+    "p103": { "x" : 103 },
+    "p104": { "x" : 104 },
+    "p105": { "x" : 105 },
+    "p106": { "x" : 106 },
+    "p107": { "x" : 107 },
+    "p108": { "x" : 108 },
+    "p109": { "x" : 109 },
+    "p110": { "x" : 110 },
+    "p111": { "x" : 111 },
+    "p112": { "x" : 112 },
+    "p113": { "x" : 113 },
+    "p114": { "x" : 114 },
+    "p115": { "x" : 115 },
+    "p116": { "x" : 116 },
+    "p117": { "x" : 117 },
+    "p118": { "x" : 118 },
+    "p119": { "x" : 119 },
+    "p120": { "x" : 120 },
+    "p121": { "x" : 121 },
+    "p122": { "x" : 122 },
+    "p123": { "x" : 123 },
+    "p124": { "x" : 124 },
+    "p125": { "x" : 125 },
+    "p126": { "x" : 126 },
+    "p127": { "x" : 127 },
+    "p128": { "x" : 128 },
+    "p129": { "x" : 129 },
+    "p130": { "x" : 130 },
+    "p131": { "x" : 131 },
+    "p132": { "x" : 132 },
+    "p133": { "x" : 133 },
+    "p134": { "x" : 134 },
+    "p135": { "x" : 135 },
+    "p136": { "x" : 136 },
+    "p137": { "x" : 137 },
+    "p138": { "x" : 138 },
+    "p139": { "x" : 139 },
+    "p140": { "x" : 140 },
+    "p141": { "x" : 141 },
+    "p142": { "x" : 142 },
+    "p143": { "x" : 143 },
+    "p144": { "x" : 144 },
+    "p145": { "x" : 145 },
+    "p146": { "x" : 146 },
+    "p147": { "x" : 147 },
+    "p148": { "x" : 148 },
+    "p149": { "x" : 149 },
+    "p150": { "x" : 150 },
+    "p151": { "x" : 151 },
+    "p152": { "x" : 152 },
+    "p153": { "x" : 153 },
+    "p154": { "x" : 154 },
+    "p155": { "x" : 155 },
+    "p156": { "x" : 156 },
+    "p157": { "x" : 157 },
+    "p158": { "x" : 158 },
+    "p159": { "x" : 159 },
+    "p160": { "x" : 160 },
+    "p161": { "x" : 161 },
+    "p162": { "x" : 162 },
+    "p163": { "x" : 163 },
+    "p164": { "x" : 164 },
+    "p165": { "x" : 165 },
+    "p166": { "x" : 166 },
+    "p167": { "x" : 167 },
+    "p168": { "x" : 168 },
+    "p169": { "x" : 169 },
+    "p170": { "x" : 170 },
+    "p171": { "x" : 171 },
+    "p172": { "x" : 172 },
+    "p173": { "x" : 173 },
+    "p174": { "x" : 174 },
+    "p175": { "x" : 175 },
+    "p176": { "x" : 176 },
+    "p177": { "x" : 177 },
+    "p178": { "x" : 178 },
+    "p179": { "x" : 179 },
+    "p180": { "x" : 180 },
+    "p181": { "x" : 181 },
+    "p182": { "x" : 182 },
+    "p183": { "x" : 183 },
+    "p184": { "x" : 184 },
+    "p185": { "x" : 185 },
+    "p186": { "x" : 186 },
+    "p187": { "x" : 187 },
+    "p188": { "x" : 188 },
+    "p189": { "x" : 189 },
+    "p190": { "x" : 190 },
+    "p191": { "x" : 191 },
+    "p192": { "x" : 192 },
+    "p193": { "x" : 193 },
+    "p194": { "x" : 194 },
+    "p195": { "x" : 195 },
+    "p196": { "x" : 196 },
+    "p197": { "x" : 197 },
+    "p198": { "x" : 198 },
+    "p199": { "x" : 199 },
+    "p200": { "x" : 200 },
+    "p201": { "x" : 201 },
+    "p202": { "x" : 202 },
+    "p203": { "x" : 203 },
+    "p204": { "x" : 204 },
+    "p205": { "x" : 205 },
+    "p206": { "x" : 206 },
+    "p207": { "x" : 207 },
+    "p208": { "x" : 208 },
+    "p209": { "x" : 209 },
+    "p210": { "x" : 210 },
+    "p211": { "x" : 211 },
+    "p212": { "x" : 212 },
+    "p213": { "x" : 213 },
+    "p214": { "x" : 214 },
+    "p215": { "x" : 215 },
+    "p216": { "x" : 216 },
+    "p217": { "x" : 217 },
+    "p218": { "x" : 218 },
+    "p219": { "x" : 219 },
+    "p220": { "x" : 220 },
+    "p221": { "x" : 221 },
+    "p222": { "x" : 222 },
+    "p223": { "x" : 223 },
+    "p224": { "x" : 224 },
+    "p225": { "x" : 225 },
+    "p226": { "x" : 226 },
+    "p227": { "x" : 227 },
+    "p228": { "x" : 228 },
+    "p229": { "x" : 229 },
+    "p230": { "x" : 230 },
+    "p231": { "x" : 231 },
+    "p232": { "x" : 232 },
+    "p233": { "x" : 233 },
+    "p234": { "x" : 234 },
+    "p235": { "x" : 235 },
+    "p236": { "x" : 236 },
+    "p237": { "x" : 237 },
+    "p238": { "x" : 238 },
+    "p239": { "x" : 239 },
+    "p240": { "x" : 240 },
+    "p241": { "x" : 241 },
+    "p242": { "x" : 242 },
+    "p243": { "x" : 243 },
+    "p244": { "x" : 244 },
+    "p245": { "x" : 245 },
+    "p246": { "x" : 246 },
+    "p247": { "x" : 247 },
+    "p248": { "x" : 248 },
+    "p249": { "x" : 249 },
+    "p250": { "x" : 250 },
+    "p251": { "x" : 251 },
+    "p252": { "x" : 252 },
+    "p253": { "x" : 253 },
+    "p254": { "x" : 254 },
+    "p255": { "x" : 255 },
+    "p256": { "x" : 256 },
+    "p257": { "x" : 257 },
+    "p258": { "x" : 258 },
+    "p259": { "x" : 259 },
+    "p260": { "x" : 260 },
+    "p261": { "x" : 261 },
+    "p262": { "x" : 262 },
+    "p263": { "x" : 263 },
+    "p264": { "x" : 264 },
+    "p265": { "x" : 265 },
+    "p266": { "x" : 266 },
+    "p267": { "x" : 267 },
+    "p268": { "x" : 268 },
+    "p269": { "x" : 269 },
+    "p270": { "x" : 270 },
+    "p271": { "x" : 271 },
+    "p272": { "x" : 272 },
+    "p273": { "x" : 273 },
+    "p274": { "x" : 274 },
+    "p275": { "x" : 275 },
+    "p276": { "x" : 276 },
+    "p277": { "x" : 277 },
+    "p278": { "x" : 278 },
+    "p279": { "x" : 279 },
+    "p280": { "x" : 280 },
+    "p281": { "x" : 281 },
+    "p282": { "x" : 282 },
+    "p283": { "x" : 283 },
+    "p284": { "x" : 284 },
+    "p285": { "x" : 285 },
+    "p286": { "x" : 286 },
+    "p287": { "x" : 287 },
+    "p288": { "x" : 288 },
+    "p289": { "x" : 289 },
+    "p290": { "x" : 290 },
+    "p291": { "x" : 291 },
+    "p292": { "x" : 292 },
+    "p293": { "x" : 293 },
+    "p294": { "x" : 294 },
+    "p295": { "x" : 295 },
+    "p296": { "x" : 296 },
+    "p297": { "x" : 297 },
+    "p298": { "x" : 298 },
+    "p299": { "x" : 299 },
+    "p300": { "x" : 300 },
+    "p301": { "x" : 301 },
+    "p302": { "x" : 302 },
+    "p303": { "x" : 303 },
+    "p304": { "x" : 304 },
+    "p305": { "x" : 305 },
+    "p306": { "x" : 306 },
+    "p307": { "x" : 307 },
+    "p308": { "x" : 308 },
+    "p309": { "x" : 309 },
+    "p310": { "x" : 310 },
+    "p311": { "x" : 311 },
+    "p312": { "x" : 312 },
+    "p313": { "x" : 313 },
+    "p314": { "x" : 314 },
+    "p315": { "x" : 315 },
+    "p316": { "x" : 316 },
+    "p317": { "x" : 317 },
+    "p318": { "x" : 318 },
+    "p319": { "x" : 319 },
+    "p320": { "x" : 320 },
+    "p321": { "x" : 321 },
+    "p322": { "x" : 322 },
+    "p323": { "x" : 323 },
+    "p324": { "x" : 324 },
+    "p325": { "x" : 325 },
+    "p326": { "x" : 326 },
+    "p327": { "x" : 327 },
+    "p328": { "x" : 328 },
+    "p329": { "x" : 329 },
+    "p330": { "x" : 330 },
+    "p331": { "x" : 331 },
+    "p332": { "x" : 332 },
+    "p333": { "x" : 333 },
+    "p334": { "x" : 334 },
+    "p335": { "x" : 335 },
+    "p336": { "x" : 336 },
+    "p337": { "x" : 337 },
+    "p338": { "x" : 338 },
+    "p339": { "x" : 339 },
+    "p340": { "x" : 340 },
+    "p341": { "x" : 341 },
+    "p342": { "x" : 342 },
+    "p343": { "x" : 343 },
+    "p344": { "x" : 344 },
+    "p345": { "x" : 345 },
+    "p346": { "x" : 346 },
+    "p347": { "x" : 347 },
+    "p348": { "x" : 348 },
+    "p349": { "x" : 349 },
+    "p350": { "x" : 350 },
+    "p351": { "x" : 351 },
+    "p352": { "x" : 352 },
+    "p353": { "x" : 353 },
+    "p354": { "x" : 354 },
+    "p355": { "x" : 355 },
+    "p356": { "x" : 356 },
+    "p357": { "x" : 357 },
+    "p358": { "x" : 358 },
+    "p359": { "x" : 359 },
+    "p360": { "x" : 360 },
+    "p361": { "x" : 361 },
+    "p362": { "x" : 362 },
+    "p363": { "x" : 363 },
+    "p364": { "x" : 364 },
+    "p365": { "x" : 365 },
+    "p366": { "x" : 366 },
+    "p367": { "x" : 367 },
+    "p368": { "x" : 368 },
+    "p369": { "x" : 369 },
+    "p370": { "x" : 370 },
+    "p371": { "x" : 371 },
+    "p372": { "x" : 372 },
+    "p373": { "x" : 373 },
+    "p374": { "x" : 374 },
+    "p375": { "x" : 375 },
+    "p376": { "x" : 376 },
+    "p377": { "x" : 377 },
+    "p378": { "x" : 378 },
+    "p379": { "x" : 379 },
+    "p380": { "x" : 380 },
+    "p381": { "x" : 381 },
+    "p382": { "x" : 382 },
+    "p383": { "x" : 383 },
+    "p384": { "x" : 384 },
+    "p385": { "x" : 385 },
+    "p386": { "x" : 386 },
+    "p387": { "x" : 387 },
+    "p388": { "x" : 388 },
+    "p389": { "x" : 389 },
+    "p390": { "x" : 390 },
+    "p391": { "x" : 391 },
+    "p392": { "x" : 392 },
+    "p393": { "x" : 393 },
+    "p394": { "x" : 394 },
+    "p395": { "x" : 395 },
+    "p396": { "x" : 396 },
+    "p397": { "x" : 397 },
+    "p398": { "x" : 398 },
+    "p399": { "x" : 399 },
+    "p400": { "x" : 400 },
+    "p401": { "x" : 401 },
+    "p402": { "x" : 402 },
+    "p403": { "x" : 403 },
+    "p404": { "x" : 404 },
+    "p405": { "x" : 405 },
+    "p406": { "x" : 406 },
+    "p407": { "x" : 407 },
+    "p408": { "x" : 408 },
+    "p409": { "x" : 409 },
+    "p410": { "x" : 410 },
+    "p411": { "x" : 411 },
+    "p412": { "x" : 412 },
+    "p413": { "x" : 413 },
+    "p414": { "x" : 414 },
+    "p415": { "x" : 415 },
+    "p416": { "x" : 416 },
+    "p417": { "x" : 417 },
+    "p418": { "x" : 418 },
+    "p419": { "x" : 419 },
+    "p420": { "x" : 420 },
+    "p421": { "x" : 421 },
+    "p422": { "x" : 422 },
+    "p423": { "x" : 423 },
+    "p424": { "x" : 424 },
+    "p425": { "x" : 425 },
+    "p426": { "x" : 426 },
+    "p427": { "x" : 427 },
+    "p428": { "x" : 428 },
+    "p429": { "x" : 429 },
+    "p430": { "x" : 430 },
+    "p431": { "x" : 431 },
+    "p432": { "x" : 432 },
+    "p433": { "x" : 433 },
+    "p434": { "x" : 434 },
+    "p435": { "x" : 435 },
+    "p436": { "x" : 436 },
+    "p437": { "x" : 437 },
+    "p438": { "x" : 438 },
+    "p439": { "x" : 439 },
+    "p440": { "x" : 440 },
+    "p441": { "x" : 441 },
+    "p442": { "x" : 442 },
+    "p443": { "x" : 443 },
+    "p444": { "x" : 444 },
+    "p445": { "x" : 445 },
+    "p446": { "x" : 446 },
+    "p447": { "x" : 447 },
+    "p448": { "x" : 448 },
+    "p449": { "x" : 449 },
+    "p450": { "x" : 450 },
+    "p451": { "x" : 451 },
+    "p452": { "x" : 452 },
+    "p453": { "x" : 453 },
+    "p454": { "x" : 454 },
+    "p455": { "x" : 455 },
+    "p456": { "x" : 456 },
+    "p457": { "x" : 457 },
+    "p458": { "x" : 458 },
+    "p459": { "x" : 459 },
+    "p460": { "x" : 460 },
+    "p461": { "x" : 461 },
+    "p462": { "x" : 462 },
+    "p463": { "x" : 463 },
+    "p464": { "x" : 464 },
+    "p465": { "x" : 465 },
+    "p466": { "x" : 466 },
+    "p467": { "x" : 467 },
+    "p468": { "x" : 468 },
+    "p469": { "x" : 469 },
+    "p470": { "x" : 470 },
+    "p471": { "x" : 471 },
+    "p472": { "x" : 472 },
+    "p473": { "x" : 473 },
+    "p474": { "x" : 474 },
+    "p475": { "x" : 475 },
+    "p476": { "x" : 476 },
+    "p477": { "x" : 477 },
+    "p478": { "x" : 478 },
+    "p479": { "x" : 479 },
+    "p480": { "x" : 480 },
+    "p481": { "x" : 481 },
+    "p482": { "x" : 482 },
+    "p483": { "x" : 483 },
+    "p484": { "x" : 484 },
+    "p485": { "x" : 485 },
+    "p486": { "x" : 486 },
+    "p487": { "x" : 487 },
+    "p488": { "x" : 488 },
+    "p489": { "x" : 489 },
+    "p490": { "x" : 490 },
+    "p491": { "x" : 491 },
+    "p492": { "x" : 492 },
+    "p493": { "x" : 493 },
+    "p494": { "x" : 494 },
+    "p495": { "x" : 495 },
+    "p496": { "x" : 496 },
+    "p497": { "x" : 497 },
+    "p498": { "x" : 498 },
+    "p499": { "x" : 499 },
+    "p500": { "x" : 500 },
+    "p501": { "x" : 501 },
+    "p502": { "x" : 502 },
+    "p503": { "x" : 503 },
+    "p504": { "x" : 504 },
+    "p505": { "x" : 505 },
+    "p506": { "x" : 506 },
+    "p507": { "x" : 507 },
+    "p508": { "x" : 508 },
+    "p509": { "x" : 509 },
+    "p510": { "x" : 510 },
+    "p511": { "x" : 511 },
+    "p512": { "x" : 512 },
+    "p513": { "x" : 513 },
+    "p514": { "x" : 514 },
+    "p515": { "x" : 515 },
+    "p516": { "x" : 516 },
+    "p517": { "x" : 517 },
+    "p518": { "x" : 518 },
+    "p519": { "x" : 519 },
+    "p520": { "x" : 520 },
+    "p521": { "x" : 521 },
+    "p522": { "x" : 522 },
+    "p523": { "x" : 523 },
+    "p524": { "x" : 524 },
+    "p525": { "x" : 525 },
+    "p526": { "x" : 526 },
+    "p527": { "x" : 527 },
+    "p528": { "x" : 528 },
+    "p529": { "x" : 529 },
+    "p530": { "x" : 530 },
+    "p531": { "x" : 531 },
+    "p532": { "x" : 532 },
+    "p533": { "x" : 533 },
+    "p534": { "x" : 534 },
+    "p535": { "x" : 535 },
+    "p536": { "x" : 536 },
+    "p537": { "x" : 537 },
+    "p538": { "x" : 538 },
+    "p539": { "x" : 539 },
+    "p540": { "x" : 540 },
+    "p541": { "x" : 541 },
+    "p542": { "x" : 542 },
+    "p543": { "x" : 543 },
+    "p544": { "x" : 544 },
+    "p545": { "x" : 545 },
+    "p546": { "x" : 546 },
+    "p547": { "x" : 547 },
+    "p548": { "x" : 548 },
+    "p549": { "x" : 549 },
+    "p550": { "x" : 550 },
+    "p551": { "x" : 551 },
+    "p552": { "x" : 552 },
+    "p553": { "x" : 553 },
+    "p554": { "x" : 554 },
+    "p555": { "x" : 555 },
+    "p556": { "x" : 556 },
+    "p557": { "x" : 557 },
+    "p558": { "x" : 558 },
+    "p559": { "x" : 559 },
+    "p560": { "x" : 560 },
+    "p561": { "x" : 561 },
+    "p562": { "x" : 562 },
+    "p563": { "x" : 563 },
+    "p564": { "x" : 564 },
+    "p565": { "x" : 565 },
+    "p566": { "x" : 566 },
+    "p567": { "x" : 567 },
+    "p568": { "x" : 568 },
+    "p569": { "x" : 569 },
+    "p570": { "x" : 570 },
+    "p571": { "x" : 571 },
+    "p572": { "x" : 572 },
+    "p573": { "x" : 573 },
+    "p574": { "x" : 574 },
+    "p575": { "x" : 575 },
+    "p576": { "x" : 576 },
+    "p577": { "x" : 577 },
+    "p578": { "x" : 578 },
+    "p579": { "x" : 579 },
+    "p580": { "x" : 580 },
+    "p581": { "x" : 581 },
+    "p582": { "x" : 582 },
+    "p583": { "x" : 583 },
+    "p584": { "x" : 584 },
+    "p585": { "x" : 585 },
+    "p586": { "x" : 586 },
+    "p587": { "x" : 587 },
+    "p588": { "x" : 588 },
+    "p589": { "x" : 589 },
+    "p590": { "x" : 590 },
+    "p591": { "x" : 591 },
+    "p592": { "x" : 592 },
+    "p593": { "x" : 593 },
+    "p594": { "x" : 594 },
+    "p595": { "x" : 595 },
+    "p596": { "x" : 596 },
+    "p597": { "x" : 597 },
+    "p598": { "x" : 598 },
+    "p599": { "x" : 599 },
+    "p600": { "x" : 600 },
+    "p601": { "x" : 601 },
+    "p602": { "x" : 602 },
+    "p603": { "x" : 603 },
+    "p604": { "x" : 604 },
+    "p605": { "x" : 605 },
+    "p606": { "x" : 606 },
+    "p607": { "x" : 607 },
+    "p608": { "x" : 608 },
+    "p609": { "x" : 609 },
+    "p610": { "x" : 610 },
+    "p611": { "x" : 611 },
+    "p612": { "x" : 612 },
+    "p613": { "x" : 613 },
+    "p614": { "x" : 614 },
+    "p615": { "x" : 615 },
+    "p616": { "x" : 616 },
+    "p617": { "x" : 617 },
+    "p618": { "x" : 618 },
+    "p619": { "x" : 619 },
+    "p620": { "x" : 620 },
+    "p621": { "x" : 621 },
+    "p622": { "x" : 622 },
+    "p623": { "x" : 623 },
+    "p624": { "x" : 624 },
+    "p625": { "x" : 625 },
+    "p626": { "x" : 626 },
+    "p627": { "x" : 627 },
+    "p628": { "x" : 628 },
+    "p629": { "x" : 629 },
+    "p630": { "x" : 630 },
+    "p631": { "x" : 631 },
+    "p632": { "x" : 632 },
+    "p633": { "x" : 633 },
+    "p634": { "x" : 634 },
+    "p635": { "x" : 635 },
+    "p636": { "x" : 636 },
+    "p637": { "x" : 637 },
+    "p638": { "x" : 638 },
+    "p639": { "x" : 639 },
+    "p640": { "x" : 640 },
+    "p641": { "x" : 641 },
+    "p642": { "x" : 642 },
+    "p643": { "x" : 643 },
+    "p644": { "x" : 644 },
+    "p645": { "x" : 645 },
+    "p646": { "x" : 646 },
+    "p647": { "x" : 647 },
+    "p648": { "x" : 648 },
+    "p649": { "x" : 649 },
+    "p650": { "x" : 650 },
+    "p651": { "x" : 651 },
+    "p652": { "x" : 652 },
+    "p653": { "x" : 653 },
+    "p654": { "x" : 654 },
+    "p655": { "x" : 655 },
+    "p656": { "x" : 656 },
+    "p657": { "x" : 657 },
+    "p658": { "x" : 658 },
+    "p659": { "x" : 659 },
+    "p660": { "x" : 660 },
+    "p661": { "x" : 661 },
+    "p662": { "x" : 662 },
+    "p663": { "x" : 663 },
+    "p664": { "x" : 664 },
+    "p665": { "x" : 665 },
+    "p666": { "x" : 666 },
+    "p667": { "x" : 667 },
+    "p668": { "x" : 668 },
+    "p669": { "x" : 669 },
+    "p670": { "x" : 670 },
+    "p671": { "x" : 671 },
+    "p672": { "x" : 672 },
+    "p673": { "x" : 673 },
+    "p674": { "x" : 674 },
+    "p675": { "x" : 675 },
+    "p676": { "x" : 676 },
+    "p677": { "x" : 677 },
+    "p678": { "x" : 678 },
+    "p679": { "x" : 679 },
+    "p680": { "x" : 680 },
+    "p681": { "x" : 681 },
+    "p682": { "x" : 682 },
+    "p683": { "x" : 683 },
+    "p684": { "x" : 684 },
+    "p685": { "x" : 685 },
+    "p686": { "x" : 686 },
+    "p687": { "x" : 687 },
+    "p688": { "x" : 688 },
+    "p689": { "x" : 689 },
+    "p690": { "x" : 690 },
+    "p691": { "x" : 691 },
+    "p692": { "x" : 692 },
+    "p693": { "x" : 693 },
+    "p694": { "x" : 694 },
+    "p695": { "x" : 695 },
+    "p696": { "x" : 696 },
+    "p697": { "x" : 697 },
+    "p698": { "x" : 698 },
+    "p699": { "x" : 699 },
+    "p700": { "x" : 700 },
+    "p701": { "x" : 701 },
+    "p702": { "x" : 702 },
+    "p703": { "x" : 703 },
+    "p704": { "x" : 704 },
+    "p705": { "x" : 705 },
+    "p706": { "x" : 706 },
+    "p707": { "x" : 707 },
+    "p708": { "x" : 708 },
+    "p709": { "x" : 709 },
+    "p710": { "x" : 710 },
+    "p711": { "x" : 711 },
+    "p712": { "x" : 712 },
+    "p713": { "x" : 713 },
+    "p714": { "x" : 714 },
+    "p715": { "x" : 715 },
+    "p716": { "x" : 716 },
+    "p717": { "x" : 717 },
+    "p718": { "x" : 718 },
+    "p719": { "x" : 719 },
+    "p720": { "x" : 720 },
+    "p721": { "x" : 721 },
+    "p722": { "x" : 722 },
+    "p723": { "x" : 723 },
+    "p724": { "x" : 724 },
+    "p725": { "x" : 725 },
+    "p726": { "x" : 726 },
+    "p727": { "x" : 727 },
+    "p728": { "x" : 728 },
+    "p729": { "x" : 729 },
+    "p730": { "x" : 730 },
+    "p731": { "x" : 731 },
+    "p732": { "x" : 732 },
+    "p733": { "x" : 733 },
+    "p734": { "x" : 734 },
+    "p735": { "x" : 735 },
+    "p736": { "x" : 736 },
+    "p737": { "x" : 737 },
+    "p738": { "x" : 738 },
+    "p739": { "x" : 739 },
+    "p740": { "x" : 740 },
+    "p741": { "x" : 741 },
+    "p742": { "x" : 742 },
+    "p743": { "x" : 743 },
+    "p744": { "x" : 744 },
+    "p745": { "x" : 745 },
+    "p746": { "x" : 746 },
+    "p747": { "x" : 747 },
+    "p748": { "x" : 748 },
+    "p749": { "x" : 749 },
+    "p750": { "x" : 750 },
+    "p751": { "x" : 751 },
+    "p752": { "x" : 752 },
+    "p753": { "x" : 753 },
+    "p754": { "x" : 754 },
+    "p755": { "x" : 755 },
+    "p756": { "x" : 756 },
+    "p757": { "x" : 757 },
+    "p758": { "x" : 758 },
+    "p759": { "x" : 759 },
+    "p760": { "x" : 760 },
+    "p761": { "x" : 761 },
+    "p762": { "x" : 762 },
+    "p763": { "x" : 763 },
+    "p764": { "x" : 764 },
+    "p765": { "x" : 765 },
+    "p766": { "x" : 766 },
+    "p767": { "x" : 767 },
+    "p768": { "x" : 768 },
+    "p769": { "x" : 769 },
+    "p770": { "x" : 770 },
+    "p771": { "x" : 771 },
+    "p772": { "x" : 772 },
+    "p773": { "x" : 773 },
+    "p774": { "x" : 774 },
+    "p775": { "x" : 775 },
+    "p776": { "x" : 776 },
+    "p777": { "x" : 777 },
+    "p778": { "x" : 778 },
+    "p779": { "x" : 779 },
+    "p780": { "x" : 780 },
+    "p781": { "x" : 781 },
+    "p782": { "x" : 782 },
+    "p783": { "x" : 783 },
+    "p784": { "x" : 784 },
+    "p785": { "x" : 785 },
+    "p786": { "x" : 786 },
+    "p787": { "x" : 787 },
+    "p788": { "x" : 788 },
+    "p789": { "x" : 789 },
+    "p790": { "x" : 790 },
+    "p791": { "x" : 791 },
+    "p792": { "x" : 792 },
+    "p793": { "x" : 793 },
+    "p794": { "x" : 794 },
+    "p795": { "x" : 795 },
+    "p796": { "x" : 796 },
+    "p797": { "x" : 797 },
+    "p798": { "x" : 798 },
+    "p799": { "x" : 799 },
+    "p800": { "x" : 800 },
+    "p801": { "x" : 801 },
+    "p802": { "x" : 802 },
+    "p803": { "x" : 803 },
+    "p804": { "x" : 804 },
+    "p805": { "x" : 805 },
+    "p806": { "x" : 806 },
+    "p807": { "x" : 807 },
+    "p808": { "x" : 808 },
+    "p809": { "x" : 809 },
+    "p810": { "x" : 810 },
+    "p811": { "x" : 811 },
+    "p812": { "x" : 812 },
+    "p813": { "x" : 813 },
+    "p814": { "x" : 814 },
+    "p815": { "x" : 815 },
+    "p816": { "x" : 816 },
+    "p817": { "x" : 817 },
+    "p818": { "x" : 818 },
+    "p819": { "x" : 819 },
+    "p820": { "x" : 820 },
+    "p821": { "x" : 821 },
+    "p822": { "x" : 822 },
+    "p823": { "x" : 823 },
+    "p824": { "x" : 824 },
+    "p825": { "x" : 825 },
+    "p826": { "x" : 826 },
+    "p827": { "x" : 827 },
+    "p828": { "x" : 828 },
+    "p829": { "x" : 829 },
+    "p830": { "x" : 830 },
+    "p831": { "x" : 831 },
+    "p832": { "x" : 832 },
+    "p833": { "x" : 833 },
+    "p834": { "x" : 834 },
+    "p835": { "x" : 835 },
+    "p836": { "x" : 836 },
+    "p837": { "x" : 837 },
+    "p838": { "x" : 838 },
+    "p839": { "x" : 839 },
+    "p840": { "x" : 840 },
+    "p841": { "x" : 841 },
+    "p842": { "x" : 842 },
+    "p843": { "x" : 843 },
+    "p844": { "x" : 844 },
+    "p845": { "x" : 845 },
+    "p846": { "x" : 846 },
+    "p847": { "x" : 847 },
+    "p848": { "x" : 848 },
+    "p849": { "x" : 849 },
+    "p850": { "x" : 850 },
+    "p851": { "x" : 851 },
+    "p852": { "x" : 852 },
+    "p853": { "x" : 853 },
+    "p854": { "x" : 854 },
+    "p855": { "x" : 855 },
+    "p856": { "x" : 856 },
+    "p857": { "x" : 857 },
+    "p858": { "x" : 858 },
+    "p859": { "x" : 859 },
+    "p860": { "x" : 860 },
+    "p861": { "x" : 861 },
+    "p862": { "x" : 862 },
+    "p863": { "x" : 863 },
+    "p864": { "x" : 864 },
+    "p865": { "x" : 865 },
+    "p866": { "x" : 866 },
+    "p867": { "x" : 867 },
+    "p868": { "x" : 868 },
+    "p869": { "x" : 869 },
+    "p870": { "x" : 870 },
+    "p871": { "x" : 871 },
+    "p872": { "x" : 872 },
+    "p873": { "x" : 873 },
+    "p874": { "x" : 874 },
+    "p875": { "x" : 875 },
+    "p876": { "x" : 876 },
+    "p877": { "x" : 877 },
+    "p878": { "x" : 878 },
+    "p879": { "x" : 879 },
+    "p880": { "x" : 880 },
+    "p881": { "x" : 881 },
+    "p882": { "x" : 882 },
+    "p883": { "x" : 883 },
+    "p884": { "x" : 884 },
+    "p885": { "x" : 885 },
+    "p886": { "x" : 886 },
+    "p887": { "x" : 887 },
+    "p888": { "x" : 888 },
+    "p889": { "x" : 889 },
+    "p890": { "x" : 890 },
+    "p891": { "x" : 891 },
+    "p892": { "x" : 892 },
+    "p893": { "x" : 893 },
+    "p894": { "x" : 894 },
+    "p895": { "x" : 895 },
+    "p896": { "x" : 896 },
+    "p897": { "x" : 897 },
+    "p898": { "x" : 898 },
+    "p899": { "x" : 899 },
+    "p900": { "x" : 900 },
+    "p901": { "x" : 901 },
+    "p902": { "x" : 902 },
+    "p903": { "x" : 903 },
+    "p904": { "x" : 904 },
+    "p905": { "x" : 905 },
+    "p906": { "x" : 906 },
+    "p907": { "x" : 907 },
+    "p908": { "x" : 908 },
+    "p909": { "x" : 909 },
+    "p910": { "x" : 910 },
+    "p911": { "x" : 911 },
+    "p912": { "x" : 912 },
+    "p913": { "x" : 913 },
+    "p914": { "x" : 914 },
+    "p915": { "x" : 915 },
+    "p916": { "x" : 916 },
+    "p917": { "x" : 917 },
+    "p918": { "x" : 918 },
+    "p919": { "x" : 919 },
+    "p920": { "x" : 920 },
+    "p921": { "x" : 921 },
+    "p922": { "x" : 922 },
+    "p923": { "x" : 923 },
+    "p924": { "x" : 924 },
+    "p925": { "x" : 925 },
+    "p926": { "x" : 926 },
+    "p927": { "x" : 927 },
+    "p928": { "x" : 928 },
+    "p929": { "x" : 929 },
+    "p930": { "x" : 930 },
+    "p931": { "x" : 931 },
+    "p932": { "x" : 932 },
+    "p933": { "x" : 933 },
+    "p934": { "x" : 934 },
+    "p935": { "x" : 935 },
+    "p936": { "x" : 936 },
+    "p937": { "x" : 937 },
+    "p938": { "x" : 938 },
+    "p939": { "x" : 939 },
+    "p940": { "x" : 940 },
+    "p941": { "x" : 941 },
+    "p942": { "x" : 942 },
+    "p943": { "x" : 943 },
+    "p944": { "x" : 944 },
+    "p945": { "x" : 945 },
+    "p946": { "x" : 946 },
+    "p947": { "x" : 947 },
+    "p948": { "x" : 948 },
+    "p949": { "x" : 949 },
+    "p950": { "x" : 950 },
+    "p951": { "x" : 951 },
+    "p952": { "x" : 952 },
+    "p953": { "x" : 953 },
+    "p954": { "x" : 954 },
+    "p955": { "x" : 955 },
+    "p956": { "x" : 956 },
+    "p957": { "x" : 957 },
+    "p958": { "x" : 958 },
+    "p959": { "x" : 959 },
+    "p960": { "x" : 960 },
+    "p961": { "x" : 961 },
+    "p962": { "x" : 962 },
+    "p963": { "x" : 963 },
+    "p964": { "x" : 964 },
+    "p965": { "x" : 965 },
+    "p966": { "x" : 966 },
+    "p967": { "x" : 967 },
+    "p968": { "x" : 968 },
+    "p969": { "x" : 969 },
+    "p970": { "x" : 970 },
+    "p971": { "x" : 971 },
+    "p972": { "x" : 972 },
+    "p973": { "x" : 973 },
+    "p974": { "x" : 974 },
+    "p975": { "x" : 975 },
+    "p976": { "x" : 976 },
+    "p977": { "x" : 977 },
+    "p978": { "x" : 978 },
+    "p979": { "x" : 979 },
+    "p980": { "x" : 980 },
+    "p981": { "x" : 981 },
+    "p982": { "x" : 982 },
+    "p983": { "x" : 983 },
+    "p984": { "x" : 984 },
+    "p985": { "x" : 985 },
+    "p986": { "x" : 986 },
+    "p987": { "x" : 987 },
+    "p988": { "x" : 988 },
+    "p989": { "x" : 989 },
+    "p990": { "x" : 990 },
+    "p991": { "x" : 991 },
+    "p992": { "x" : 992 },
+    "p993": { "x" : 993 },
+    "p994": { "x" : 994 },
+    "p995": { "x" : 995 },
+    "p996": { "x" : 996 },
+    "p997": { "x" : 997 },
+    "p998": { "x" : 998 },
+    "p999": { "x" : 999 }
+};
+
+for (var i = 0; i < 1000; i++) {
+    var value = obj["p" + i];
+    Assert.assertTrue(typeof value === "object");
+    Assert.assertTrue(value.x === i);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074556.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8074556: Functions should not share allocator maps
+ *
+ * @test
+ * @run
+ */
+
+function A () {
+    return this;
+}
+
+function B() {
+    return this;
+}
+
+A.prototype.x = "x";
+A.prototype.y = "y";
+B.prototype.y = "y";  // same properties but different order
+B.prototype.x = "x";
+
+function test(o) {
+    Assert.assertEquals(o.x, "x");
+    Assert.assertEquals(o.y, "y");
+}
+
+test(new A());
+test(new B());
+test(new A());
+test(new B());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074687.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8074687:  Add tests for JSON parsing of numeric keys
+ *
+ * @test
+ * @run
+ */
+
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": {} }')),                   '{"0":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": 1 }')),                    '{"0":1}');
+
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "65503": {} }')),               '{"65503":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "65503": 1 }')),                '{"65503":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": {}, "65503": {} }')),      '{"0":{},"65503":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": 1, "65503": 1 }')),        '{"0":1,"65503":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "65503": {}, "0": {} }')),      '{"0":{},"65503":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "65503": 1, "0": 1 }')),        '{"0":1,"65503":1}');
+
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "4294967295": {} }')),          '{"4294967295":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "4294967295": 1 }')),           '{"4294967295":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": {}, "4294967295": {} }')), '{"0":{},"4294967295":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": 1, "4294967295": 1 }')),   '{"0":1,"4294967295":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "4294967295": {}, "0": {} }')), '{"0":{},"4294967295":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "4294967295": 1, "0": 1 }')),   '{"0":1,"4294967295":1}');
+
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "100": {} }')),                 '{"100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "100": 1 }')),                  '{"100":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": {}, "100": {} }')),        '{"0":{},"100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": 1, "100": 1 }')),          '{"0":1,"100":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "100": {}, "0": {} }')),        '{"0":{},"100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "100": 1, "0": 1 }')),          '{"0":1,"100":1}');
+
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "-100": {} }')),                '{"-100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "-100": 1 }')),                 '{"-100":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": {}, "-100": {} }')),       '{"0":{},"-100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "0": 1, "-100": 1 }')),         '{"0":1,"-100":1}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "-100": {}, "0": {} }')),       '{"0":{},"-100":{}}');
+Assert.assertEquals(JSON.stringify(JSON.parse('{ "-100": 1, "0": 1 }')),         '{"0":1,"-100":1}');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074693.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8074693: Different instances of same function use same allocator map
+ *
+ * @test
+ * @run
+ */
+
+var lib = {};
+
+lib.mixin = function(target, source) {
+    for (var p in source) {
+        if (source.hasOwnProperty(p) && !target.hasOwnProperty(p)) {
+            target.prototype[p] = source[p];
+        }
+    }
+};
+
+lib.declare = function(def) {
+    var className = def.name;
+
+    lib[className] = function() {
+        this.init.apply(this, arguments);
+    };
+
+    lib.mixin(lib[className], def.members);
+};
+
+
+lib.declare({
+    name: "ClassA",
+    members: {
+        init : function () {
+            print("init A called");
+        }
+    }
+});
+
+lib.declare({
+    name: "ClassB",
+    members: {
+        util : function () {
+            print("util called")
+        },
+        init : function() {
+            print("init B called");
+        }
+    }
+});
+
+var objA = new lib.ClassA();
+var objB = new lib.ClassB();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8074693.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+init A called
+init B called
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8075090.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8075090: Add tests for the basic failure of try/finally compilation
+ *
+ * @test
+ * @run
+ */
+
+(function() {
+    var finallyExpected = false;
+    try {
+        for(var i = 0; i < 2; ++i) {
+            if(i == 1) {
+                continue;
+            }
+        }
+        finallyExpected = true;
+    } finally {
+        Assert.assertTrue(finallyExpected);
+    }
+})();
+
+(function() {
+    var finallyExpected = false;
+    try {
+        for(var i = 0; i < 2; ++i) {
+            if(i == 1) {
+                break;
+            }
+        }
+        finallyExpected = true;
+    } finally {
+        Assert.assertTrue(finallyExpected);
+    }
+})();
+
+(function() {
+    var finallyExpected = false;
+    try {
+        L1: {
+            if ((function(){return true})()) {
+                break L1;
+            }
+            Assert.fail(); // unreachable
+        }
+        finallyExpected = true;
+    } finally {
+        Assert.assertTrue(finallyExpected);
+    }
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8075927.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8075927: toNumber(String) accepts illegal characters
+ *
+ * @test
+ * @run
+ */
+
+Assert.assertTrue(isNaN(Number("-123d")));
+Assert.assertTrue(isNaN(Number("-123f")));
+Assert.assertTrue(Number("   123 ") === 123);
+Assert.assertTrue(Number("  -123 ") === -123);
+Assert.assertEquals(Number("  Infinity  "), Infinity);
+Assert.assertEquals(Number(" +Infinity  "), Infinity);
+Assert.assertEquals(Number(" -Infinity  "), -Infinity);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8077955.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8077955: Undeclared globals in eval code should not be handled as fast scope
+ *
+ * @test
+ * @run
+ * @fork
+ * @option -Dnashorn.fields.objects
+ */
+
+var m = new javax.script.ScriptEngineManager();
+var e = m.getEngineByName('js');
+
+// leave the whitespace - need both eval("e") at same column for this test!
+
+e.eval('function f(e) {            eval("e") } f()');
+e.eval('function f() { var e = 33; eval("e") } f()');
+
+function f() {
+    Function.call.call(function x() { eval("x") }); eval("x")
+}
+
+try {
+    f();
+    fail("Should have thrown ReferenceError");
+} catch (e) {
+    if (! (e instanceof ReferenceError)) {
+        fail("ReferenceError expected but got " + e);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_1a.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8078612: Persistent code cache should support more configurations
+ *
+ * @test
+ * @runif external.prototype
+ * @option -pcc
+ * @option --lazy-compilation=false
+ * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
+ * @fork
+ */
+
+load(__DIR__ + 'prototype.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_1a.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,1 @@
+parsed and compiled ok prototype.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_1b.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8078612: Persistent code cache should support more configurations
+ *
+ * @test
+ * @runif external.prototype
+ * @option -pcc
+ * @option --lazy-compilation=false
+ * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
+ * @fork
+ */
+
+load(__DIR__ + 'prototype.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_1b.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,1 @@
+parsed and compiled ok prototype.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_2a.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8078612: Persistent code cache should support more configurations
+ *
+ * @test
+ * @runif external.yui
+ * @option -pcc
+ * @option --lazy-compilation=false
+ * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
+ * @fork
+ */
+
+load(__DIR__ + 'yui.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_2a.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+parsed and compiled ok yui-min.js
+parsed and compiled ok yui.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_2b.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8078612: Persistent code cache should support more configurations
+ *
+ * @test
+ * @runif external.yui
+ * @option -pcc
+ * @option --lazy-compilation=false
+ * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
+ * @fork
+ */
+
+load(__DIR__ + 'yui.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8078612_eager_2b.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+parsed and compiled ok yui-min.js
+parsed and compiled ok yui.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079145.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8079145: jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion
+ *
+ * @test
+ * @fork
+ * @option -Dnashorn.debug=true
+ * @run
+ */
+
+var Byte = java.lang.Byte;
+var Short = java.lang.Short;
+var Integer = java.lang.Integer;
+var Long = java.lang.Long;
+var Float = java.lang.Float;
+var Double = java.lang.Double;
+var Character = java.lang.Character;
+
+function checkWiden(arr, value, name) {
+    switch (typeof value) {
+    case 'object':
+    case 'undefined':
+        print(name + ": check widen for " + value);
+        break;
+    default:
+        print(name + ": check widen for " + value + 
+            " [" + Debug.getClass(value) + "]");
+    }
+
+    arr[0] = value;
+}
+
+function checkIntWiden(value) {
+   checkWiden([34], value, "int array");
+}
+
+function checkLongWiden(value) {
+    checkWiden([Integer.MAX_VALUE + 1], value, "long array");
+}
+
+function checkNumberWiden(value) {
+    checkWiden([Math.PI], value, "number array");
+}
+
+function checkObjectWiden(value) {
+    checkWiden([null], value, "object array");
+}
+
+var values = [{}, null, undefined, false, true, new Byte(34),
+   new Integer(344454), new Long(454545), new Long(Integer.MAX_VALUE + 1),
+   new Float(34.3), new Double(Math.PI), new Character('s')];
+
+for each (var v in values) {
+    checkIntWiden(v);
+}
+
+for each (var v in values) {
+    checkLongWiden(v);
+}
+
+for each (var v in values) {
+    checkNumberWiden(v);
+}
+
+for each (var v in values) {
+    checkObjectWiden(v);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079145.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,48 @@
+int array: check widen for [object Object]
+int array: check widen for null
+int array: check widen for undefined
+int array: check widen for false [class java.lang.Boolean]
+int array: check widen for true [class java.lang.Boolean]
+int array: check widen for 34 [class java.lang.Byte]
+int array: check widen for 344454 [class java.lang.Integer]
+int array: check widen for 454545 [class java.lang.Long]
+int array: check widen for 2147483648 [class java.lang.Long]
+int array: check widen for 34.29999923706055 [class java.lang.Float]
+int array: check widen for 3.141592653589793 [class java.lang.Double]
+int array: check widen for s
+long array: check widen for [object Object]
+long array: check widen for null
+long array: check widen for undefined
+long array: check widen for false [class java.lang.Boolean]
+long array: check widen for true [class java.lang.Boolean]
+long array: check widen for 34 [class java.lang.Byte]
+long array: check widen for 344454 [class java.lang.Integer]
+long array: check widen for 454545 [class java.lang.Long]
+long array: check widen for 2147483648 [class java.lang.Long]
+long array: check widen for 34.29999923706055 [class java.lang.Float]
+long array: check widen for 3.141592653589793 [class java.lang.Double]
+long array: check widen for s
+number array: check widen for [object Object]
+number array: check widen for null
+number array: check widen for undefined
+number array: check widen for false [class java.lang.Boolean]
+number array: check widen for true [class java.lang.Boolean]
+number array: check widen for 34 [class java.lang.Byte]
+number array: check widen for 344454 [class java.lang.Integer]
+number array: check widen for 454545 [class java.lang.Long]
+number array: check widen for 2147483648 [class java.lang.Long]
+number array: check widen for 34.29999923706055 [class java.lang.Float]
+number array: check widen for 3.141592653589793 [class java.lang.Double]
+number array: check widen for s
+object array: check widen for [object Object]
+object array: check widen for null
+object array: check widen for undefined
+object array: check widen for false [class java.lang.Boolean]
+object array: check widen for true [class java.lang.Boolean]
+object array: check widen for 34 [class java.lang.Byte]
+object array: check widen for 344454 [class java.lang.Integer]
+object array: check widen for 454545 [class java.lang.Long]
+object array: check widen for 2147483648 [class java.lang.Long]
+object array: check widen for 34.29999923706055 [class java.lang.Float]
+object array: check widen for 3.141592653589793 [class java.lang.Double]
+object array: check widen for s
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079269.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8079269: Optimistic rewrite in object literal causes ArrayIndexOutOfBoundsException
+ *
+ * @test
+ * @run
+ */
+
+// m must be in scope so it's accessed with optimistic getters on scope
+var m = 1; 
+
+(function() {
+    return { 
+        p0: m, 
+        p1: m = "foo",
+        p2: m
+    }
+})();
+
+var n = 1; 
+
+// Test the spill object creator too
+(function() {
+    return { 
+        p0: n, 
+        p1: n = "foo",
+        p2: n,
+        p3: n,
+        p4: n,
+        p5: n,
+        p6: n,
+        p7: n,
+        p8: n,
+        p9: n,
+        p10: n,
+        p11: n,
+        p12: n,
+        p13: n,
+        p14: n,
+        p15: n,
+        p16: n,
+        p17: n,
+        p18: n,
+        p19: n,
+        p20: n,
+        p21: n,
+        p22: n,
+        p23: n,
+        p24: n,
+        p25: n,
+        p26: n,
+        p27: n,
+        p28: n,
+        p29: n,
+        p30: n,
+        p31: n,
+        p32: n,
+        p33: n,
+        p34: n,
+        p35: n,
+        p36: n,
+        p37: n,
+        p38: n,
+        p39: n,
+        p40: n,
+        p41: n,
+        p42: n,
+        p43: n,
+        p44: n,
+        p45: n,
+        p46: n,
+        p47: n,
+        p48: n,
+        p49: n,
+        p50: n,
+        p51: n,
+        p52: n,
+        p53: n,
+        p54: n,
+        p55: n,
+        p56: n,
+        p57: n,
+        p58: n,
+        p59: n,
+        p60: n,
+        p61: n,
+        p62: n,
+        p63: n,
+        p64: n,
+        p65: n,
+        p66: n,
+        p67: n,
+        p68: n,
+        p69: n,
+        p70: n,
+        p71: n,
+        p72: n,
+        p73: n,
+        p74: n,
+        p75: n,
+        p76: n,
+        p77: n,
+        p78: n,
+        p79: n,
+        p80: n,
+        p81: n,
+        p82: n,
+        p83: n,
+        p84: n,
+        p85: n,
+        p86: n,
+        p87: n,
+        p88: n,
+        p89: n,
+        p90: n,
+        p91: n,
+        p92: n,
+        p93: n,
+        p94: n,
+        p95: n,
+        p96: n,
+        p97: n,
+        p98: n,
+        p99: n,
+        p100: n,
+        p101: n,
+        p102: n,
+        p103: n,
+        p104: n,
+        p105: n,
+        p106: n,
+        p107: n,
+        p108: n,
+        p109: n,
+        p110: n,
+        p111: n,
+        p112: n,
+        p113: n,
+        p114: n,
+        p115: n,
+        p116: n,
+        p117: n,
+        p118: n,
+        p119: n,
+        p120: n,
+        p121: n,
+        p122: n,
+        p123: n,
+        p124: n,
+        p125: n,
+        p126: n,
+        p127: n,
+        p128: n,
+        p129: n,
+        p130: n,
+        p131: n,
+        p132: n,
+        p133: n,
+        p134: n,
+        p135: n,
+        p136: n,
+        p137: n,
+        p138: n,
+        p139: n,
+        p140: n,
+        p141: n,
+        p142: n,
+        p143: n,
+        p144: n,
+        p145: n,
+        p146: n,
+        p147: n,
+        p148: n,
+        p149: n,
+        p150: n,
+        p151: n,
+        p152: n,
+        p153: n,
+        p154: n,
+        p155: n,
+        p156: n,
+        p157: n,
+        p158: n,
+        p159: n,
+        p160: n,
+        p161: n,
+        p162: n,
+        p163: n,
+        p164: n,
+        p165: n,
+        p166: n,
+        p167: n,
+        p168: n,
+        p169: n,
+        p170: n,
+        p171: n,
+        p172: n,
+        p173: n,
+        p174: n,
+        p175: n,
+        p176: n,
+        p177: n,
+        p178: n,
+        p179: n,
+        p180: n,
+        p181: n,
+        p182: n,
+        p183: n,
+        p184: n,
+        p185: n,
+        p186: n,
+        p187: n,
+        p188: n,
+        p189: n,
+        p190: n,
+        p191: n,
+        p192: n,
+        p193: n,
+        p194: n,
+        p195: n,
+        p196: n,
+        p197: n,
+        p198: n,
+        p199: n,
+        p200: n,
+        p201: n,
+        p202: n,
+        p203: n,
+        p204: n,
+        p205: n,
+        p206: n,
+        p207: n,
+        p208: n,
+        p209: n,
+        p210: n,
+        p211: n,
+        p212: n,
+        p213: n,
+        p214: n,
+        p215: n,
+        p216: n,
+        p217: n,
+        p218: n,
+        p219: n,
+        p220: n,
+        p221: n,
+        p222: n,
+        p223: n,
+        p224: n,
+        p225: n,
+        p226: n,
+        p227: n,
+        p228: n,
+        p229: n,
+        p230: n,
+        p231: n,
+        p232: n,
+        p233: n,
+        p234: n,
+        p235: n,
+        p236: n,
+        p237: n,
+        p238: n,
+        p239: n,
+        p240: n,
+        p241: n,
+        p242: n,
+        p243: n,
+        p244: n,
+        p245: n,
+        p246: n,
+        p247: n,
+        p248: n,
+        p249: n,
+        p250: n,
+        p251: n,
+        p252: n,
+        p253: n,
+        p254: n,
+        p255: n,
+        p256: n,
+        p257: n,
+        p258: n,
+        p259: n
+    }
+})();
+
+// No output; as long as it completes without
+// ArrayIndexOutOfBoundsException in the OSR continuation handler, it's
+// a success.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079424.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8079424: code generator for discarded boolean logical operation has an extra pop
+ *
+ * @test
+ * @run
+ */
+
+// If the compiler manages to compile all of these, the test passes.
+void (true && true);
+void (true && false);
+void (false && true);
+void (false && false);
+
+void (true || true);
+void (true || false);
+void (false || true);
+void (false || false);
+
+void (1 && 1);
+void (1 && 0);
+void (0 && 1);
+void (0 && 0);
+
+void (1 || 1);
+void (1 || 0);
+void (0 || 1);
+void (0 || 0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079470.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8079470: Misleading error message when explicit signature constructor is called with wrong arguments
+ *
+ * @test
+ * @run
+ */
+
+
+var File = Java.type("java.io.File");
+try {
+    var f = new File['(String,String)']();
+} catch (e) {
+    print(e);
+}
+
+var Color = java.awt["Color(int,int,int)"]
+try {
+    var c = new Color(255, 255)
+} catch (e) {
+    print(e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8079470.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,2 @@
+TypeError: Can not create new object with constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod File java.io.File.java.io.File(String,String)] with the passed arguments; they do not match any of its method signatures.
+TypeError: Can not create new object with constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] with the passed arguments; they do not match any of its method signatures.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8080182.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8080182: Array.prototype.sort throws IAE on inconsistent comparison
+ *
+ * @test
+ * @run
+ */
+
+function Random() { 
+    this.toString = function() {
+        return (Math.random() * 100).toString();
+    }
+}
+
+for (var i = 0; i < 100; ++i) {
+    var arr = []; 
+
+    for (var j = 0; j < 64; ++j) {
+        arr[j] = new Random();
+    }
+
+    // no IllegalArgumentException expected!
+    arr.sort();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8080848.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8080848: delete of bound Java method property results in crash
+ *
+ * @test
+ * @run
+ */
+
+var obj = Object.bindProperties({}, new java.io.File("."));
+
+delete obj.wait;
+
+if (typeof obj.wait != 'undefined') {
+    throw new Error("obj.wait was not deleted");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8081156.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8081156: jjs "nashorn.args" system property is not effective when script arguments are passed
+ *
+ * @test
+ * @fork
+ * @option -Dnashorn.args=-strict
+ * @argument foo
+ * @argument bar
+ * @run
+ */
+
+try {
+   x = 14;
+   throw new Error("should have thrown ReferenceError");
+} catch (e) {
+   if (! (e instanceof ReferenceError)) {
+       throw e;
+   }
+}
+
+Assert.assertTrue(arguments.length == 2);
+Assert.assertTrue(arguments[0] == "foo");
+Assert.assertTrue(arguments[1] == "bar");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8085802.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8085802: Nashorn -nse option causes parse error on anonymous function definition
+ *
+ * @test
+ * @run
+ * @option -nse
+ */
+
+// even with -nse passed, the following should run fine
+// because anonymous function is used as expression here
+
+(function (){})()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8087211.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8087211: Indirect evals should be strict with -strict option
+ *
+ * @test
+ * @run
+ * @option -strict
+ */
+
+var global = this;
+
+try {
+    // indirect eval call.
+    global.eval("x = 34;");
+    throw new Error("should have thrown ReferenceError");
+} catch (e if e instanceof ReferenceError) {
+}
+
+
+function teststrict() {
+    "use strict";
+    // strict caller, indirect eval.
+    global.eval('public = 1;');
+}
+
+try {
+    teststrict();
+    throw new Error("should have thrown SyntaxError");
+} catch (e if e instanceof SyntaxError) {
+}
+
+function testnonstrict() {
+    // non strict caller, indirect eval.
+    global.eval('public = 1;');
+}
+
+try {
+    testnonstrict();
+    throw new Error("should have thrown SyntaxError");
+} catch (e if e instanceof SyntaxError) {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8087211_2.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8087211: Indirect evals should be strict with -strict option
+ * Make sure without -strict option, indirect evals are not strict.
+ *
+ * @test
+ * @run
+ */
+
+var global = this;
+
+// indirect eval call.
+global.eval("x = 34;");
+
+function teststrict() {
+    "use strict";
+    // strict caller, indirect eval.
+    global.eval('public = 1;');
+}
+
+teststrict();
+
+function testnonstrict() {
+    // non strict caller, indirect eval.
+    global.eval('public = 1;');
+}
+
+testnonstrict();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8098546.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8098546: eval within a 'with' leaks definitions into global scope
+ *
+ * @test
+ * @run
+ */
+
+function func() {
+    var obj = { foo: 344 };
+    with (obj) {
+       eval("var x = foo + 3");
+    }
+    Assert.assertTrue(obj.x === undefined);
+    Assert.assertTrue(x === 347);
+}
+
+func();
+
+// x should be undefined here
+Assert.assertTrue(typeof x === "undefined");
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8098578.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8098578: Global scope is not accessible with indirect load call
+ *
+ * @test
+ * @run
+ */
+
+var obj = { foo: 343 };
+var global = this;
+var x = 434;
+
+// indirect load call
+var res = load.call(obj, {
+   name: "t.js",
+   // global is accessible. All declarations go into
+   // intermediate inaccessible scope. "this" is global
+   // User's passed object's properties are accessible
+   // as variables.
+   script: "foo -= 300; var bar = x; Assert.assertTrue(bar == 434); function func() {}; this"
+})
+
+// 'this' for the evaluated code is global
+Assert.assertTrue(res === global);
+
+// properties of passed object are accessible in evaluated code
+Assert.assertTrue(obj.foo == 43);
+
+// vars, functions definined in evaluated code don't go into passed object
+Assert.assertTrue(typeof obj.bar == "undefined");
+Assert.assertTrue(typeof obj.func == "undefined");
+
+// vars, functions definined in evaluated code don't go leak into global
+Assert.assertTrue(typeof bar == "undefined");
+Assert.assertTrue(typeof func == "undefined");
+Assert.assertTrue(typeof foo == "undefined");
+
+var res = load.call(undefined, {
+    name: "t1.js",
+    // still global is accessible and 'this' is global
+    script: "Assert.assertTrue(x == 434); this"
+});
+
+// indirect load with 'undefined' this is same as as direct load
+// or load on global itself.
+Assert.assertTrue(res === global);
+
+// indirect load with 'undefined' this is same as as direct load
+// or load on global itself.
+var res = load.call(null, {
+    name: "t2.js",
+    // still global is accessible and 'this' is global
+    script: "Assert.assertTrue(x == 434); this"
+});
+Assert.assertTrue(res === global);
+
+// indirect load with mirror object
+var mirror = loadWithNewGlobal({
+    name: "t3.js",
+    script: "({ foo: 'hello', x: Math.PI })"
+});
+
+var res = load.call(mirror, {
+    name: "t4.js",
+    script: "Assert.assertTrue(foo == 'hello'); Assert.assertTrue(x == Math.PI); this"
+});
+Assert.assertTrue(res === global);
+
+// indirect load on non-script object, non-mirror results in TypeError
+function tryLoad(obj) {
+    try {
+        load.call(obj, {
+            name: "t5.js", script: "this"
+        });
+        throw new Error("should thrown TypeError for: " + obj);
+    } catch (e if TypeError) {}
+}
+
+tryLoad("hello");
+tryLoad(Math.E);
+tryLoad(true);
+tryLoad(false);
+
+// indirect load of a large script
+load.call({}, __DIR__ + "JDK-8098807-payload.js");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8098807-payload.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8098807:  Strict eval throws ClassCastException with large scripts
+ *
+ * @subtest
+ */
+
+function f() {}
+
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8098807.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8098807:  Strict eval throws ClassCastException with large scripts
+ *
+ * @test
+ * @run
+ * @option -scripting
+ */
+
+"use strict";
+
+var path = __DIR__ + "JDK-8098807-payload.js"
+var source = readFully(path);
+eval(source);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8129410.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8129410: Java adapters with class-level overrides should preserve variable arity constructors
+ *
+ * @test
+ * @run
+ */
+
+var VarArgConstructor = Java.type("jdk.nashorn.test.models.VarArgConstructor");
+var VarArgConstructorExtended = Java.extend(VarArgConstructor, {});
+
+// If the fix didn't work we wouldn't even get past the constructor invocation
+// as it'd complain there's no matching arity constructor.
+var newExtended = new VarArgConstructorExtended(1, true, "a", "b");
+
+// Assert the expected constructor was invoked.
+Assert.assertEquals("vararg", newExtended.indicator);
--- a/test/script/basic/NASHORN-623.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/NASHORN-623.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -1,3 +1,3 @@
-SyntaxError: Invalid JSON: <json>:1:12 Expected number but found ident
+SyntaxError: Invalid JSON: <json>:1:11 Invalid JSON number format
 { "test" : -xxx }
-            ^
+           ^
--- a/test/script/basic/compile-octane-splitter.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/compile-octane-splitter.js	Fri Nov 13 15:38:44 2015 -0800
@@ -29,11 +29,10 @@
  * forever, so make this test future safe, we specify them explicitly
  *
  * @test
- * @fork
- * @option -Dnashorn.compiler.splitter.threshold=1000
+ * @runif external.octane
  * @fork
- * @runif external.octane
  * @option -scripting
+ * @option -Dnashorn.compiler.splitter.threshold=1000
  * @option -Dnashorn.typeInfo.disabled=true
  * @option --class-cache-size=0
  * @option --persistent-code-cache=false
--- a/test/script/basic/es6/const-reassign.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/es6/const-reassign.js	Fri Nov 13 15:38:44 2015 -0800
@@ -31,144 +31,147 @@
 "use strict";
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x = 1;\n');
+    const x = 2;
+    x = 1;
+    fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x++;\n');
+    const x = 2;
+    x++;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x--;\n');
+    const x = 2;
+    x--;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
+}
+
+try {
+    const x = 2;
+    ++x;
+    fail("const assignment didn't throw");
+} catch (e) {
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        '++x;\n');
+    const x = 2;
+    --x;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        '--x;\n');
+    const x = 2;
+    x += 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x += 1;\n');
+    const x = 2;
+    x *= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x *= 1;\n');
+    const x = 2;
+    x /= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x /= 1;\n');
+    const x = 2;
+    x %= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x %= 1;\n');
+    const x = 2;
+    x |= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x |= 1;\n');
+    const x = 2;
+    x &= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x &= 1;\n');
+    const x = 2;
+    x ^= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
+}
+
+try {
+    const x = 2;
+    x <<= 1;
+    fail("const assignment didn't throw");
+} catch (e) {
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x ^= 1;\n');
+    const x = 2;
+    x >>= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x <<= 1;\n');
+    const x = 2;
+    x >>>= 1;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x >>= 1;\n');
+    const x = 2;
+    delete x;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
+const c = 1;
+
 try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'x >>>= 1;\n');
+    c = 2;
     fail("const assignment didn't throw");
 } catch (e) {
-    print(e.name);
+    print(e);
 }
 
-try {
-    eval('"use strict";\n' +
-        'const x = 2;\n' +
-        'delete x;\n');
-    fail("const assignment didn't throw");
-} catch (e) {
-    print(e.name);
-}
+(function() {
+    try {
+        c = 2;
+        fail("const assignment didn't throw");
+    } catch (e) {
+        print(e);
+    }
+})();
--- a/test/script/basic/es6/const-reassign.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/es6/const-reassign.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -1,16 +1,18 @@
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
-SyntaxError
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+TypeError: Assignment to constant "x"
+SyntaxError: cannot delete "x" in strict mode
+TypeError: Assignment to constant "c"
+TypeError: Assignment to constant "c"
--- a/test/script/basic/es6/let-eval.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/es6/let-eval.js	Fri Nov 13 15:38:44 2015 -0800
@@ -96,3 +96,9 @@
 f();
 
 print(typeof a, typeof b, typeof c, typeof x, typeof z);
+
+let v = 1;
+eval("print('v: ' + v); v = 2; print ('v: ' + v);");
+print("this.v: " + this.v);
+print("v: " + v);
+
--- a/test/script/basic/es6/let-eval.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/es6/let-eval.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -14,3 +14,7 @@
 2 1 0
 2 1 0 undefined
 undefined undefined undefined undefined undefined
+v: 1
+v: 2
+this.v: undefined
+v: 2
--- a/test/script/basic/es6/let_const_reuse.js.EXPECTED	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/es6/let_const_reuse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -1,8 +1,4 @@
 ReferenceError: "a" is not defined
-SyntaxError: test/script/basic/es6/let_const_reuse.js#35:9<eval>:3:8 Assignment to constant "a"
-        a--
-        ^
-SyntaxError: test/script/basic/es6/let_const_reuse.js#35:9<eval>:3:8 Assignment to constant "a"
-        a--
-        ^
+TypeError: Assignment to constant "a"
+TypeError: Assignment to constant "a"
 ReferenceError: "a" is not defined
--- a/test/script/basic/typedarrays.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/basic/typedarrays.js	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,17 @@
  * @run
  */
 
+//JDK-8066217, constructor for arraybuffer not behaving as per spec
+function checkLength(ab, l) {
+    if (ab.byteLength != l) {
+        throw "length error: " + ab.byteLength + " != " + l;
+    }
+}
+checkLength(new ArrayBuffer(), 0);
+checkLength(new ArrayBuffer(0), 0);
+checkLength(new ArrayBuffer(1024), 1024);
+checkLength(new ArrayBuffer(1,2,3), 1);
+checkLength(new ArrayBuffer([17]), 17);
 
 var typeDefinitions = [
 Int8Array,
--- a/test/script/currently-failing/gettersetter.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/currently-failing/gettersetter.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/currently-failing/property_delete.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/currently-failing/property_delete.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/JDK-8098847.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8098847: obj."prop" and obj.'prop' should result in SyntaxError
+ *
+ * @test/compile-error
+ */
+
+var obj = { "prop": 45 };
+
+obj."prop" = "hello";
+obj.'prop' = "hello";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/JDK-8098847.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,6 @@
+test/script/error/JDK-8098847.js:32:5 Expected ident but found prop
+obj."prop" = "hello";
+     ^
+test/script/error/JDK-8098847.js:33:5 Expected ident but found prop
+obj.'prop' = "hello";
+     ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/anon_func_stat_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Anonymous function statement should result in error in -nse
+ *
+ * @option -nse
+ * @test/compile-error
+ */
+
+function() {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/anon_func_stat_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+test/script/error/anon_func_stat_nse.js:31:8 Expected ident but found (
+function() {}
+        ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/backquote_string_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Backquote string should result in error with -nse even with -scripting
+ *
+ * @option -nse
+ * @option -scripting
+ * @test/compile-error
+ */
+
+`ls -l`;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/backquote_string_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+test/script/error/backquote_string_nse.js:32:0 Expected an operand but found error
+`ls -l`;
+^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/conditional_catch_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * conditional catch should result in error with -nse
+ *
+ * @option -nse
+ * @test/compile-error
+ */
+
+try {
+    func();
+} catch (e if e instanceof ReferenceError) {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/conditional_catch_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,6 @@
+test/script/error/conditional_catch_nse.js:33:11 Expected ) but found if
+} catch (e if e instanceof ReferenceError) {
+           ^
+test/script/error/conditional_catch_nse.js:34:0 Expected eof but found }
+}
+^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/expr_closure_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Expression closures should result in error with -nse
+ *
+ * @option -nse
+ * @test/compile-error
+ */
+
+function square(x) x*x;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/expr_closure_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+test/script/error/expr_closure_nse.js:31:19 Expected { but found x
+function square(x) x*x;
+                   ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/for_each_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * for..each should result in error with -nse
+ *
+ * @option -nse
+ * @test/compile-error
+ */
+
+for each (var x in [3, 454, 4]) {
+    print(x);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/for_each_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,6 @@
+test/script/error/for_each_nse.js:31:4 Expected ( but found each
+for each (var x in [3, 454, 4]) {
+    ^
+test/script/error/for_each_nse.js:33:0 Expected eof but found }
+}
+^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/hash_comment_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Hash comment should result in error with -nse even with -scripting
+ *
+ * @option -nse
+ * @option -scripting
+ * @test/compile-error
+ */
+
+# this is a comment
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/hash_comment_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,3 @@
+test/script/error/hash_comment_nse.js:32:0 Expected an operand but found error
+# this is a comment
+^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/heredoc_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Heredoc string should result in error with -nse even with -scripting
+ *
+ * @option -nse
+ * @option -scripting
+ * @test/compile-error
+ */
+
+var str = <<EOF
+This is a multiple line string
+inside a heredoc
+EOF;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/heredoc_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,9 @@
+test/script/error/heredoc_nse.js:32:10 Expected an operand but found <<
+var str = <<EOF
+          ^
+test/script/error/heredoc_nse.js:33:5 Expected ; but found is
+This is a multiple line string
+     ^
+test/script/error/heredoc_nse.js:34:7 Expected ; but found a
+inside a heredoc
+       ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/object_literal_in_new_nse.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Object literal outside 'new' should result in error in -nse
+ *
+ * @option -nse
+ * @test/compile-error
+ */
+
+var r = new java.lang.Runnable() {
+  run: function() { print("hello"); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/error/object_literal_in_new_nse.js.EXPECTED	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,9 @@
+test/script/error/object_literal_in_new_nse.js:31:33 Expected ; but found {
+var r = new java.lang.Runnable() {
+                                 ^
+test/script/error/object_literal_in_new_nse.js:32:15 Expected ident but found (
+  run: function() { print("hello"); }
+               ^
+test/script/error/object_literal_in_new_nse.js:32:36 Expected eof but found }
+  run: function() { print("hello"); }
+                                    ^
--- a/test/script/maptests/builtins.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/builtins.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/constructor.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/constructor.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/maputil.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/maputil.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/object_create.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/object_create.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/object_literals.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/object_literals.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/point.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/point.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/property_add.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/property_add.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/maptests/proto.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/maptests/proto.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/nosecurity/JDK-8050964.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/nosecurity/JDK-8050964.js	Fri Nov 13 15:38:44 2015 -0800
@@ -47,7 +47,7 @@
 }
 
 var javahome = System.getProperty("java.home");
-var jdepsPath = javahome + "/../bin/jdeps".replaceAll(/\//g, File.separater);
+var jdepsPath = javahome + "/../bin/jdeps".replace(/\//g, File.separator);
 
 // run jdep on nashorn.jar - only summary but print profile info
 $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin
--- a/test/script/nosecurity/JDK-8055034.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/nosecurity/JDK-8055034.js	Fri Nov 13 15:38:44 2015 -0800
@@ -48,7 +48,7 @@
 // we want to use nashorn.jar passed and not the one that comes with JRE
 var jjsCmd = javahome + "/../bin/jjs";
 jjsCmd += " -J-Djava.ext.dirs=" + nashornJarDir;
-jjsCmd = jjsCmd.toString().replaceAll(/\//g, File.separater);
+jjsCmd = jjsCmd.toString().replace(/\//g, File.separator);
 $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin
 $EXEC(jjsCmd, "var x = Object.create(null);\nx;\nprint('PASSED');\nexit(0)");
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/nosecurity/JDK-8067215.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8067215: Disable dual fields when not using optimistic types
+ *
+ * @test
+ * @run
+ * @option -Dnashorn.debug=true
+ * @fork
+ */
+
+var intType    = Java.type("int");
+var doubleType = Java.type("double");
+var longType   = Java.type("long");
+var objectType = Java.type("java.lang.Object");
+
+var Context = Java.type("jdk.nashorn.internal.runtime.Context");
+var JSType  = Java.type("jdk.nashorn.internal.runtime.JSType");
+
+var context = Context.getContext();
+var dualFields = context.useDualFields();
+var optimisticTypes = context.getEnv()._optimistic_types;
+
+if (dualFields != optimisticTypes) {
+    throw new Error("Wrong dual fields setting");
+}
+
+function testMap(obj) {
+    obj.x = "foo";
+    obj["y"] = 0;
+    Object.defineProperty(obj, "z", {value: 0.5});
+    var map = Debug.map(obj);
+    for (var key in obj) {
+        var prop = map.findProperty(key);
+        if (prop.hasDualFields() !== dualFields) {
+            throw new Error("Wrong property flags: " + prop);
+        }
+        if (prop.getType() != getExpectedType(obj[key])) {
+            throw new Error("Wrong property type: " + prop.getType() + " // " + getExpectedType(obj[key]));
+
+        }
+    }
+}
+
+function getExpectedType(value) {
+    if (!dualFields) {
+        return objectType.class;
+    }
+    if (JSType.isRepresentableAsInt(value)) {
+        return intType.class;
+    }
+    if (JSType.isRepresentableAsLong(value)) {
+        return longType.class;
+    }
+    if (JSType.isNumber(value)) {
+        return doubleType.class;
+    }
+    return objectType.class;
+}
+
+var o = {
+    a: 1,
+    b: 2.5,
+    c: 0x10000000000,
+    d: true
+};
+
+function C() {
+    this.a = 1;
+    this.b = 2.5;
+    this.c = 0x10000000000;
+    this.d = true;
+}
+
+var a = 1;
+var b = 2.5;
+var c = 0x10000000000;
+var d = true;
+
+testMap(o);
+testMap(new C());
+testMap(JSON.parse('{ "a": 1, "b": 2.5, "c": 1099511627776, "d": true }'));
+testMap(this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/nosecurity/JDK-8078049.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,553 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8078049: Nashorn crashes when attempting to start the new tsc.js compiler for TypeScript
+ *
+ * @test
+ * @run
+ * @fork
+ * @option -Dnashorn.debug=true
+ */
+
+var m = 1;
+
+var fields = {
+    p0: { code: 0, category: m },
+    p1: { code: 1, category: m },
+    p2: { code: 2, category: m }
+};
+
+var spill = {
+    p0: { code: 0, category: m },
+    p1: { code: 1, category: m },
+    p2: { code: 2, category: m },
+    p3: { code: 3, category: m },
+    p4: { code: 4, category: m },
+    p5: { code: 5, category: m },
+    p6: { code: 6, category: m },
+    p7: { code: 7, category: m },
+    p8: { code: 8, category: m },
+    p9: { code: 9, category: m },
+    p10: { code: 10, category: m },
+    p11: { code: 11, category: m },
+    p12: { code: 12, category: m },
+    p13: { code: 13, category: m },
+    p14: { code: 14, category: m },
+    p15: { code: 15, category: m },
+    p16: { code: 16, category: m },
+    p17: { code: 17, category: m },
+    p18: { code: 18, category: m },
+    p19: { code: 19, category: m },
+    p20: { code: 20, category: m },
+    p21: { code: 21, category: m },
+    p22: { code: 22, category: m },
+    p23: { code: 23, category: m },
+    p24: { code: 24, category: m },
+    p25: { code: 25, category: m },
+    p26: { code: 26, category: m },
+    p27: { code: 27, category: m },
+    p28: { code: 28, category: m },
+    p29: { code: 29, category: m },
+    p30: { code: 30, category: m },
+    p31: { code: 31, category: m },
+    p32: { code: 32, category: m },
+    p33: { code: 33, category: m },
+    p34: { code: 34, category: m },
+    p35: { code: 35, category: m },
+    p36: { code: 36, category: m },
+    p37: { code: 37, category: m },
+    p38: { code: 38, category: m },
+    p39: { code: 39, category: m },
+    p40: { code: 40, category: m },
+    p41: { code: 41, category: m },
+    p42: { code: 42, category: m },
+    p43: { code: 43, category: m },
+    p44: { code: 44, category: m },
+    p45: { code: 45, category: m },
+    p46: { code: 46, category: m },
+    p47: { code: 47, category: m },
+    p48: { code: 48, category: m },
+    p49: { code: 49, category: m },
+    p50: { code: 50, category: m },
+    p51: { code: 51, category: m },
+    p52: { code: 52, category: m },
+    p53: { code: 53, category: m },
+    p54: { code: 54, category: m },
+    p55: { code: 55, category: m },
+    p56: { code: 56, category: m },
+    p57: { code: 57, category: m },
+    p58: { code: 58, category: m },
+    p59: { code: 59, category: m },
+    p60: { code: 60, category: m },
+    p61: { code: 61, category: m },
+    p62: { code: 62, category: m },
+    p63: { code: 63, category: m },
+    p64: { code: 64, category: m },
+    p65: { code: 65, category: m },
+    p66: { code: 66, category: m },
+    p67: { code: 67, category: m },
+    p68: { code: 68, category: m },
+    p69: { code: 69, category: m },
+    p70: { code: 70, category: m },
+    p71: { code: 71, category: m },
+    p72: { code: 72, category: m },
+    p73: { code: 73, category: m },
+    p74: { code: 74, category: m },
+    p75: { code: 75, category: m },
+    p76: { code: 76, category: m },
+    p77: { code: 77, category: m },
+    p78: { code: 78, category: m },
+    p79: { code: 79, category: m },
+    p80: { code: 80, category: m },
+    p81: { code: 81, category: m },
+    p82: { code: 82, category: m },
+    p83: { code: 83, category: m },
+    p84: { code: 84, category: m },
+    p85: { code: 85, category: m },
+    p86: { code: 86, category: m },
+    p87: { code: 87, category: m },
+    p88: { code: 88, category: m },
+    p89: { code: 89, category: m },
+    p90: { code: 90, category: m },
+    p91: { code: 91, category: m },
+    p92: { code: 92, category: m },
+    p93: { code: 93, category: m },
+    p94: { code: 94, category: m },
+    p95: { code: 95, category: m },
+    p96: { code: 96, category: m },
+    p97: { code: 97, category: m },
+    p98: { code: 98, category: m },
+    p99: { code: 99, category: m },
+    p100: { code: 100, category: m },
+    p101: { code: 101, category: m },
+    p102: { code: 102, category: m },
+    p103: { code: 103, category: m },
+    p104: { code: 104, category: m },
+    p105: { code: 105, category: m },
+    p106: { code: 106, category: m },
+    p107: { code: 107, category: m },
+    p108: { code: 108, category: m },
+    p109: { code: 109, category: m },
+    p110: { code: 110, category: m },
+    p111: { code: 111, category: m },
+    p112: { code: 112, category: m },
+    p113: { code: 113, category: m },
+    p114: { code: 114, category: m },
+    p115: { code: 115, category: m },
+    p116: { code: 116, category: m },
+    p117: { code: 117, category: m },
+    p118: { code: 118, category: m },
+    p119: { code: 119, category: m },
+    p120: { code: 120, category: m },
+    p121: { code: 121, category: m },
+    p122: { code: 122, category: m },
+    p123: { code: 123, category: m },
+    p124: { code: 124, category: m },
+    p125: { code: 125, category: m },
+    p126: { code: 126, category: m },
+    p127: { code: 127, category: m },
+    p128: { code: 128, category: m },
+    p129: { code: 129, category: m },
+    p130: { code: 130, category: m },
+    p131: { code: 131, category: m },
+    p132: { code: 132, category: m },
+    p133: { code: 133, category: m },
+    p134: { code: 134, category: m },
+    p135: { code: 135, category: m },
+    p136: { code: 136, category: m },
+    p137: { code: 137, category: m },
+    p138: { code: 138, category: m },
+    p139: { code: 139, category: m },
+    p140: { code: 140, category: m },
+    p141: { code: 141, category: m },
+    p142: { code: 142, category: m },
+    p143: { code: 143, category: m },
+    p144: { code: 144, category: m },
+    p145: { code: 145, category: m },
+    p146: { code: 146, category: m },
+    p147: { code: 147, category: m },
+    p148: { code: 148, category: m },
+    p149: { code: 149, category: m },
+    p150: { code: 150, category: m },
+    p151: { code: 151, category: m },
+    p152: { code: 152, category: m },
+    p153: { code: 153, category: m },
+    p154: { code: 154, category: m },
+    p155: { code: 155, category: m },
+    p156: { code: 156, category: m },
+    p157: { code: 157, category: m },
+    p158: { code: 158, category: m },
+    p159: { code: 159, category: m },
+    p160: { code: 160, category: m },
+    p161: { code: 161, category: m },
+    p162: { code: 162, category: m },
+    p163: { code: 163, category: m },
+    p164: { code: 164, category: m },
+    p165: { code: 165, category: m },
+    p166: { code: 166, category: m },
+    p167: { code: 167, category: m },
+    p168: { code: 168, category: m },
+    p169: { code: 169, category: m },
+    p170: { code: 170, category: m },
+    p171: { code: 171, category: m },
+    p172: { code: 172, category: m },
+    p173: { code: 173, category: m },
+    p174: { code: 174, category: m },
+    p175: { code: 175, category: m },
+    p176: { code: 176, category: m },
+    p177: { code: 177, category: m },
+    p178: { code: 178, category: m },
+    p179: { code: 179, category: m },
+    p180: { code: 180, category: m },
+    p181: { code: 181, category: m },
+    p182: { code: 182, category: m },
+    p183: { code: 183, category: m },
+    p184: { code: 184, category: m },
+    p185: { code: 185, category: m },
+    p186: { code: 186, category: m },
+    p187: { code: 187, category: m },
+    p188: { code: 188, category: m },
+    p189: { code: 189, category: m },
+    p190: { code: 190, category: m },
+    p191: { code: 191, category: m },
+    p192: { code: 192, category: m },
+    p193: { code: 193, category: m },
+    p194: { code: 194, category: m },
+    p195: { code: 195, category: m },
+    p196: { code: 196, category: m },
+    p197: { code: 197, category: m },
+    p198: { code: 198, category: m },
+    p199: { code: 199, category: m },
+    p200: { code: 200, category: m },
+    p201: { code: 201, category: m },
+    p202: { code: 202, category: m },
+    p203: { code: 203, category: m },
+    p204: { code: 204, category: m },
+    p205: { code: 205, category: m },
+    p206: { code: 206, category: m },
+    p207: { code: 207, category: m },
+    p208: { code: 208, category: m },
+    p209: { code: 209, category: m },
+    p210: { code: 210, category: m },
+    p211: { code: 211, category: m },
+    p212: { code: 212, category: m },
+    p213: { code: 213, category: m },
+    p214: { code: 214, category: m },
+    p215: { code: 215, category: m },
+    p216: { code: 216, category: m },
+    p217: { code: 217, category: m },
+    p218: { code: 218, category: m },
+    p219: { code: 219, category: m },
+    p220: { code: 220, category: m },
+    p221: { code: 221, category: m },
+    p222: { code: 222, category: m },
+    p223: { code: 223, category: m },
+    p224: { code: 224, category: m },
+    p225: { code: 225, category: m },
+    p226: { code: 226, category: m },
+    p227: { code: 227, category: m },
+    p228: { code: 228, category: m },
+    p229: { code: 229, category: m },
+    p230: { code: 230, category: m },
+    p231: { code: 231, category: m },
+    p232: { code: 232, category: m },
+    p233: { code: 233, category: m },
+    p234: { code: 234, category: m },
+    p235: { code: 235, category: m },
+    p236: { code: 236, category: m },
+    p237: { code: 237, category: m },
+    p238: { code: 238, category: m },
+    p239: { code: 239, category: m },
+    p240: { code: 240, category: m },
+    p241: { code: 241, category: m },
+    p242: { code: 242, category: m },
+    p243: { code: 243, category: m },
+    p244: { code: 244, category: m },
+    p245: { code: 245, category: m },
+    p246: { code: 246, category: m },
+    p247: { code: 247, category: m },
+    p248: { code: 248, category: m },
+    p249: { code: 249, category: m },
+    p250: { code: 250, category: m },
+    p251: { code: 251, category: m },
+    p252: { code: 252, category: m },
+    p253: { code: 253, category: m },
+    p254: { code: 254, category: m },
+    p255: { code: 255, category: m },
+    p256: { code: 256, category: m },
+    p257: { code: 257, category: m },
+    p258: { code: 258, category: m },
+    p259: { code: 259, category: m },
+    p260: { code: 260, category: m },
+    p261: { code: 261, category: m },
+    p262: { code: 262, category: m },
+    p263: { code: 263, category: m },
+    p264: { code: 264, category: m },
+    p265: { code: 265, category: m },
+    p266: { code: 266, category: m },
+    p267: { code: 267, category: m },
+    p268: { code: 268, category: m },
+    p269: { code: 269, category: m },
+    p270: { code: 270, category: m },
+    p271: { code: 271, category: m },
+    p272: { code: 272, category: m },
+    p273: { code: 273, category: m },
+    p274: { code: 274, category: m },
+    p275: { code: 275, category: m },
+    p276: { code: 276, category: m },
+    p277: { code: 277, category: m },
+    p278: { code: 278, category: m },
+    p279: { code: 279, category: m },
+    p280: { code: 280, category: m },
+    p281: { code: 281, category: m },
+    p282: { code: 282, category: m },
+    p283: { code: 283, category: m },
+    p284: { code: 284, category: m },
+    p285: { code: 285, category: m },
+    p286: { code: 286, category: m },
+    p287: { code: 287, category: m },
+    p288: { code: 288, category: m },
+    p289: { code: 289, category: m },
+    p290: { code: 290, category: m },
+    p291: { code: 291, category: m },
+    p292: { code: 292, category: m },
+    p293: { code: 293, category: m },
+    p294: { code: 294, category: m },
+    p295: { code: 295, category: m },
+    p296: { code: 296, category: m },
+    p297: { code: 297, category: m },
+    p298: { code: 298, category: m },
+    p299: { code: 299, category: m },
+    p300: { code: 300, category: m },
+    p301: { code: 301, category: m },
+    p302: { code: 302, category: m },
+    p303: { code: 303, category: m },
+    p304: { code: 304, category: m },
+    p305: { code: 305, category: m },
+    p306: { code: 306, category: m },
+    p307: { code: 307, category: m },
+    p308: { code: 308, category: m },
+    p309: { code: 309, category: m },
+    p310: { code: 310, category: m },
+    p311: { code: 311, category: m },
+    p312: { code: 312, category: m },
+    p313: { code: 313, category: m },
+    p314: { code: 314, category: m },
+    p315: { code: 315, category: m },
+    p316: { code: 316, category: m },
+    p317: { code: 317, category: m },
+    p318: { code: 318, category: m },
+    p319: { code: 319, category: m },
+    p320: { code: 320, category: m },
+    p321: { code: 321, category: m },
+    p322: { code: 322, category: m },
+    p323: { code: 323, category: m },
+    p324: { code: 324, category: m },
+    p325: { code: 325, category: m },
+    p326: { code: 326, category: m },
+    p327: { code: 327, category: m },
+    p328: { code: 328, category: m },
+    p329: { code: 329, category: m },
+    p330: { code: 330, category: m },
+    p331: { code: 331, category: m },
+    p332: { code: 332, category: m },
+    p333: { code: 333, category: m },
+    p334: { code: 334, category: m },
+    p335: { code: 335, category: m },
+    p336: { code: 336, category: m },
+    p337: { code: 337, category: m },
+    p338: { code: 338, category: m },
+    p339: { code: 339, category: m },
+    p340: { code: 340, category: m },
+    p341: { code: 341, category: m },
+    p342: { code: 342, category: m },
+    p343: { code: 343, category: m },
+    p344: { code: 344, category: m },
+    p345: { code: 345, category: m },
+    p346: { code: 346, category: m },
+    p347: { code: 347, category: m },
+    p348: { code: 348, category: m },
+    p349: { code: 349, category: m },
+    p350: { code: 350, category: m },
+    p351: { code: 351, category: m },
+    p352: { code: 352, category: m },
+    p353: { code: 353, category: m },
+    p354: { code: 354, category: m },
+    p355: { code: 355, category: m },
+    p356: { code: 356, category: m },
+    p357: { code: 357, category: m },
+    p358: { code: 358, category: m },
+    p359: { code: 359, category: m },
+    p360: { code: 360, category: m },
+    p361: { code: 361, category: m },
+    p362: { code: 362, category: m },
+    p363: { code: 363, category: m },
+    p364: { code: 364, category: m },
+    p365: { code: 365, category: m },
+    p366: { code: 366, category: m },
+    p367: { code: 367, category: m },
+    p368: { code: 368, category: m },
+    p369: { code: 369, category: m },
+    p370: { code: 370, category: m },
+    p371: { code: 371, category: m },
+    p372: { code: 372, category: m },
+    p373: { code: 373, category: m },
+    p374: { code: 374, category: m },
+    p375: { code: 375, category: m },
+    p376: { code: 376, category: m },
+    p377: { code: 377, category: m },
+    p378: { code: 378, category: m },
+    p379: { code: 379, category: m },
+    p380: { code: 380, category: m },
+    p381: { code: 381, category: m },
+    p382: { code: 382, category: m },
+    p383: { code: 383, category: m },
+    p384: { code: 384, category: m },
+    p385: { code: 385, category: m },
+    p386: { code: 386, category: m },
+    p387: { code: 387, category: m },
+    p388: { code: 388, category: m },
+    p389: { code: 389, category: m },
+    p390: { code: 390, category: m },
+    p391: { code: 391, category: m },
+    p392: { code: 392, category: m },
+    p393: { code: 393, category: m },
+    p394: { code: 394, category: m },
+    p395: { code: 395, category: m },
+    p396: { code: 396, category: m },
+    p397: { code: 397, category: m },
+    p398: { code: 398, category: m },
+    p399: { code: 399, category: m },
+    p400: { code: 400, category: m },
+    p401: { code: 401, category: m },
+    p402: { code: 402, category: m },
+    p403: { code: 403, category: m },
+    p404: { code: 404, category: m },
+    p405: { code: 405, category: m },
+    p406: { code: 406, category: m },
+    p407: { code: 407, category: m },
+    p408: { code: 408, category: m },
+    p409: { code: 409, category: m },
+    p410: { code: 410, category: m },
+    p411: { code: 411, category: m },
+    p412: { code: 412, category: m },
+    p413: { code: 413, category: m },
+    p414: { code: 414, category: m },
+    p415: { code: 415, category: m },
+    p416: { code: 416, category: m },
+    p417: { code: 417, category: m },
+    p418: { code: 418, category: m },
+    p419: { code: 419, category: m },
+    p420: { code: 420, category: m },
+    p421: { code: 421, category: m },
+    p422: { code: 422, category: m },
+    p423: { code: 423, category: m },
+    p424: { code: 424, category: m },
+    p425: { code: 425, category: m },
+    p426: { code: 426, category: m },
+    p427: { code: 427, category: m },
+    p428: { code: 428, category: m },
+    p429: { code: 429, category: m },
+    p430: { code: 430, category: m },
+    p431: { code: 431, category: m },
+    p432: { code: 432, category: m },
+    p433: { code: 433, category: m },
+    p434: { code: 434, category: m },
+    p435: { code: 435, category: m },
+    p436: { code: 436, category: m },
+    p437: { code: 437, category: m },
+    p438: { code: 438, category: m },
+    p439: { code: 439, category: m },
+    p440: { code: 440, category: m },
+    p441: { code: 441, category: m },
+    p442: { code: 442, category: m },
+    p443: { code: 443, category: m },
+    p444: { code: 444, category: m },
+    p445: { code: 445, category: m },
+    p446: { code: 446, category: m },
+    p447: { code: 447, category: m },
+    p448: { code: 448, category: m },
+    p449: { code: 449, category: m },
+    p450: { code: 450, category: m },
+    p451: { code: 451, category: m },
+    p452: { code: 452, category: m },
+    p453: { code: 453, category: m },
+    p454: { code: 454, category: m },
+    p455: { code: 455, category: m },
+    p456: { code: 456, category: m },
+    p457: { code: 457, category: m },
+    p458: { code: 458, category: m },
+    p459: { code: 459, category: m },
+    p460: { code: 460, category: m },
+    p461: { code: 461, category: m },
+    p462: { code: 462, category: m },
+    p463: { code: 463, category: m },
+    p464: { code: 464, category: m },
+    p465: { code: 465, category: m },
+    p466: { code: 466, category: m },
+    p467: { code: 467, category: m },
+    p468: { code: 468, category: m },
+    p469: { code: 469, category: m },
+    p470: { code: 470, category: m },
+    p471: { code: 471, category: m },
+    p472: { code: 472, category: m },
+    p473: { code: 473, category: m },
+    p474: { code: 474, category: m },
+    p475: { code: 475, category: m },
+    p476: { code: 476, category: m },
+    p477: { code: 477, category: m },
+    p478: { code: 478, category: m },
+    p479: { code: 479, category: m },
+    p480: { code: 480, category: m },
+    p481: { code: 481, category: m },
+    p482: { code: 482, category: m },
+    p483: { code: 483, category: m },
+    p484: { code: 484, category: m },
+    p485: { code: 485, category: m },
+    p486: { code: 486, category: m },
+    p487: { code: 487, category: m },
+    p488: { code: 488, category: m },
+    p489: { code: 489, category: m },
+    p490: { code: 490, category: m },
+    p491: { code: 491, category: m },
+    p492: { code: 492, category: m },
+    p493: { code: 493, category: m },
+    p494: { code: 494, category: m },
+    p495: { code: 495, category: m },
+    p496: { code: 496, category: m },
+    p497: { code: 497, category: m },
+    p498: { code: 498, category: m },
+    p499: { code: 499, category: m }
+};
+
+var AccessorProperty = Java.type("jdk.nashorn.internal.runtime.AccessorProperty");
+var SpillProperty    = Java.type("jdk.nashorn.internal.runtime.SpillProperty");
+
+Assert.assertTrue(Object.keys(fields).length === 3);
+Assert.assertTrue(Debug.map(fields).findProperty("p0").getClass() === AccessorProperty.class);
+Assert.assertTrue(Debug.map(fields).findProperty("p2").getClass() === AccessorProperty.class);
+
+Assert.assertTrue(Object.keys(spill).length === 500);
+Assert.assertTrue(Debug.map(spill).findProperty("p0").getClass() === SpillProperty.class);
+Assert.assertTrue(Debug.map(spill).findProperty("p499").getClass() === SpillProperty.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/nosecurity/JDK-8080087.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8080087: Nashorn $ENV.PWD is originally undefined
+ *
+ * This is to ensure that $ENV.PWD is correctly set on Windows as well as on all
+ * other platforms.
+ *
+ * @test
+ * @option -scripting
+ * @run
+ */
+
+if (typeof($ENV.PWD) === 'undefined') {
+    fail('$ENV.PWD is undefined')
+}
+
--- a/test/script/sandbox/interfaceimpl.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/sandbox/interfaceimpl.js	Fri Nov 13 15:38:44 2015 -0800
@@ -29,8 +29,8 @@
  * @security
  */
 
-var Window = Java.type("jdk.nashorn.api.scripting.Window");
-var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.WindowEventHandler");
+var Window = Java.type("jdk.nashorn.api.scripting.test.Window");
+var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.test.WindowEventHandler");
 
 var w = new Window();
 
--- a/test/script/sandbox/safeprops.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/sandbox/safeprops.js	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/script/trusted/JDK-8025629.js	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/script/trusted/JDK-8025629.js	Fri Nov 13 15:38:44 2015 -0800
@@ -28,6 +28,6 @@
  * @run
  */
 
-load("classpath:jdk/nashorn/internal/runtime/resources/load_test.js")
+load("classpath:jdk/nashorn/internal/runtime/test/resources/load_test.js")
 
 Assert.assertEquals(loadedFunc("hello"), "HELLO");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/trusted/JDK-8067854.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8067854: bound java static method throws NPE when 'null' is used for this argument
+ *
+ * @test
+ * @run
+ */
+
+getProp = java.lang.System.getProperty;
+
+// bind this and an argument. "null" for this as getProperty is a
+// static method of java.lang.System
+getHome = Function.prototype.bind.call(getProp, null, "java.home");
+
+if (getHome() != getProp("java.home")) {
+    fail("getHome() failed to get java.home");
+}
--- a/test/src/META-INF/services/java.sql.Driver	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/src/META-INF/services/java.sql.Driver	Fri Nov 13 15:38:44 2015 -0800
@@ -1,1 +1,1 @@
-jdk.nashorn.api.NashornSQLDriver
+jdk.nashorn.api.test.NashornSQLDriver
--- a/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.dynalink.beans;
-
-import jdk.nashorn.test.models.ClassLoaderAware;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class CallerSensitiveTest {
-    @Test
-    public void testCallerSensitive() {
-        BeansLinker.getLinkerForClass(ClassLoaderAware.class);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.dynalink.beans.test;
+
+import jdk.internal.dynalink.beans.BeansLinker;
+import jdk.nashorn.test.models.ClassLoaderAware;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class CallerSensitiveTest {
+    @Test
+    public void testCallerSensitive() {
+        BeansLinker.getLinkerForClass(ClassLoaderAware.class);
+    }
+}
--- a/test/src/jdk/nashorn/api/NashornSQLDriver.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-/**
- * A dummy SQL driver for testing purpose.
- */
-public final class NashornSQLDriver implements Driver {
-    static {
-        try {
-            DriverManager.registerDriver(new NashornSQLDriver(), null);
-        } catch (final SQLException se) {
-            throw new RuntimeException(se);
-        }
-    }
-
-    @Override
-    public boolean acceptsURL(final String url) {
-        return url.startsWith("jdbc:nashorn:");
-    }
-
-    @Override
-    public Connection connect(final String url, final Properties info) {
-        throw new UnsupportedOperationException("I am a dummy!!");
-    }
-
-    @Override
-    public int getMajorVersion() {
-        return -1;
-    }
-
-    @Override
-    public int getMinorVersion() {
-        return -1;
-    }
-
-    @Override
-    public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
-        return new DriverPropertyInfo[0];
-    }
-
-    @Override
-    public boolean jdbcCompliant() {
-        // no way!
-        return false;
-    }
-
-    @Override
-    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
-        throw new SQLFeatureNotSupportedException();
-    }
-}
--- a/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import java.util.Arrays;
-import java.util.List;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ArrayConversionTest {
-    private static ScriptEngine e = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() {
-        e = new ScriptEngineManager().getEngineByName("nashorn");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-    }
-
-    @Test
-    public void testIntArrays() throws ScriptException {
-        runTest("assertNullIntArray", "null");
-        runTest("assertEmptyIntArray", "[]");
-        runTest("assertSingle42IntArray", "[42]");
-        runTest("assertSingle42IntArray", "['42']");
-        runTest("assertIntArrayConversions", "[false, true, NaN, Infinity, -Infinity, 0.4, 0.6, null, undefined, [], {}, [1], [1, 2]]");
-    }
-
-    @Test
-    public void testIntIntArrays() throws ScriptException {
-        runTest("assertNullIntIntArray", "null");
-        runTest("assertEmptyIntIntArray", "[]");
-        runTest("assertSingleEmptyIntIntArray", "[[]]");
-        runTest("assertSingleNullIntIntArray", "[null]");
-        runTest("assertLargeIntIntArray", "[[false], [1], [2, 3], [4, 5, 6], ['7', {valueOf: function() { return 8 }}]]");
-    }
-
-    @Test
-    public void testObjectObjectArrays() throws ScriptException {
-        runTest("assertLargeObjectObjectArray", "[[false], [1], ['foo', 42.3], [{x: 17}]]");
-    }
-
-    @Test
-    public void testBooleanArrays() throws ScriptException {
-        runTest("assertBooleanArrayConversions", "[false, true, '', 'false', 0, 1, 0.4, 0.6, {}, [], [false], [true], NaN, Infinity, null, undefined]");
-    }
-
-    @Test
-    public void testArrayAmbiguity() throws ScriptException {
-        runTest("x", "'abc'");
-        runTest("x", "['foo', 'bar']");
-    }
-
-    @Test
-    public void testListArrays() throws ScriptException {
-        runTest("assertListArray", "[['foo', 'bar'], ['apple', 'orange']]");
-    }
-
-    @Test
-    public void testVarArgs() throws ScriptException {
-        // Sole NativeArray in vararg position becomes vararg array itself
-        runTest("assertVarArg_42_17", "[42, 17]");
-        // NativeArray in vararg position becomes an argument if there are more arguments
-        runTest("assertVarArg_array_17", "[42], 18");
-        // Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
-        runTest("assertVarArg_function", "function() { return 'Hello' }");
-    }
-
-    private static void runTest(final String testMethodName, final String argument) throws ScriptException {
-        e.eval("Java.type('" + ArrayConversionTest.class.getName() + "')." + testMethodName + "(" + argument + ")");
-    }
-
-    public static void assertNullIntArray(final int[] array) {
-        assertNull(array);
-    }
-
-    public static void assertNullIntIntArray(final int[][] array) {
-        assertNull(array);
-    }
-
-    public static void assertEmptyIntArray(final int[] array) {
-        assertEquals(0, array.length);
-    }
-
-    public static void assertSingle42IntArray(final int[] array) {
-        assertEquals(1, array.length);
-        assertEquals(42, array[0]);
-    }
-
-
-    public static void assertIntArrayConversions(final int[] array) {
-        assertEquals(13, array.length);
-        assertEquals(0, array[0]); // false
-        assertEquals(1, array[1]); // true
-        assertEquals(0, array[2]); // NaN
-        assertEquals(0, array[3]); // Infinity
-        assertEquals(0, array[4]); // -Infinity
-        assertEquals(0, array[5]); // 0.4
-        assertEquals(0, array[6]); // 0.6 - floor, not round
-        assertEquals(0, array[7]); // null
-        assertEquals(0, array[8]); // undefined
-        assertEquals(0, array[9]); // []
-        assertEquals(0, array[10]); // {}
-        assertEquals(1, array[11]); // [1]
-        assertEquals(0, array[12]); // [1, 2]
-    }
-
-    public static void assertEmptyIntIntArray(final int[][] array) {
-        assertEquals(0, array.length);
-    }
-
-    public static void assertSingleEmptyIntIntArray(final int[][] array) {
-        assertEquals(1, array.length);
-        assertTrue(Arrays.equals(new int[0], array[0]));
-    }
-
-    public static void assertSingleNullIntIntArray(final int[][] array) {
-        assertEquals(1, array.length);
-        assertNull(null, array[0]);
-    }
-
-    public static void assertLargeIntIntArray(final int[][] array) {
-        assertEquals(5, array.length);
-        assertTrue(Arrays.equals(new int[] { 0 }, array[0]));
-        assertTrue(Arrays.equals(new int[] { 1 }, array[1]));
-        assertTrue(Arrays.equals(new int[] { 2, 3 }, array[2]));
-        assertTrue(Arrays.equals(new int[] { 4, 5, 6 }, array[3]));
-        assertTrue(Arrays.equals(new int[] { 7, 8 }, array[4]));
-    }
-
-    public static void assertLargeObjectObjectArray(final Object[][] array) throws ScriptException {
-        assertEquals(4, array.length);
-        assertTrue(Arrays.equals(new Object[] { Boolean.FALSE }, array[0]));
-        assertTrue(Arrays.equals(new Object[] { 1 }, array[1]));
-        assertTrue(Arrays.equals(new Object[] { "foo", 42.3d }, array[2]));
-        assertEquals(1, array[3].length);
-        e.getBindings(ScriptContext.ENGINE_SCOPE).put("obj", array[3][0]);
-        assertEquals(17, e.eval("obj.x"));
-    }
-
-    public static void assertBooleanArrayConversions(final boolean[] array) {
-        assertEquals(16, array.length);
-        assertFalse(array[0]); // false
-        assertTrue(array[1]); // true
-        assertFalse(array[2]); // ''
-        assertTrue(array[3]); // 'false' (yep, every non-empty string converts to true)
-        assertFalse(array[4]); // 0
-        assertTrue(array[5]); // 1
-        assertTrue(array[6]); // 0.4
-        assertTrue(array[7]); // 0.6
-        assertTrue(array[8]); // {}
-        assertTrue(array[9]); // []
-        assertTrue(array[10]); // [false]
-        assertTrue(array[11]); // [true]
-        assertFalse(array[12]); // NaN
-        assertTrue(array[13]); // Infinity
-        assertFalse(array[14]); // null
-        assertFalse(array[15]); // undefined
-    }
-
-    public static void assertListArray(final List<?>[] array) {
-        assertEquals(2, array.length);
-        assertEquals(Arrays.asList("foo", "bar"), array[0]);
-        assertEquals(Arrays.asList("apple", "orange"), array[1]);
-    }
-
-    public static void assertVarArg_42_17(final Object... args) {
-        assertEquals(2, args.length);
-        assertEquals(42, ((Number)args[0]).intValue());
-        assertEquals(17, ((Number)args[1]).intValue());
-    }
-
-    public static void assertVarArg_array_17(final Object... args) throws ScriptException {
-        assertEquals(2, args.length);
-        e.getBindings(ScriptContext.ENGINE_SCOPE).put("arr", args[0]);
-        assertTrue((Boolean)e.eval("arr instanceof Array && arr.length == 1 && arr[0] == 42"));
-        assertEquals(18, ((Number)args[1]).intValue());
-    }
-
-    public static void assertVarArg_function(final Object... args) throws ScriptException {
-        assertEquals(1, args.length);
-        e.getBindings(ScriptContext.ENGINE_SCOPE).put("fn", args[0]);
-        assertEquals("Hello", e.eval("fn()"));
-    }
-
-
-
-    public static void x(final String y) {
-        assertEquals("abc", y);
-    }
-    public static void x(final String[] y) {
-        assertTrue(Arrays.equals(new String[] { "foo", "bar"}, y));
-    }
-}
--- a/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import java.util.Arrays;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.BooleanAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.BooleanAccessTest
- */
-@SuppressWarnings("javadoc")
-public class BooleanAccessTest {
-
-    private static ScriptEngine e = null;
-    private static SharedObject o = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    @Test
-    public void accessFieldBoolean() throws ScriptException {
-        e.eval("var p_boolean = o.publicBoolean;");
-        assertEquals(o.publicBoolean, e.get("p_boolean"));
-        assertEquals("boolean", e.eval("typeof p_boolean;"));
-        e.eval("o.publicBoolean = false;");
-        assertEquals(false, o.publicBoolean);
-    }
-
-    @Test
-    public void accessFieldBooleanArray() throws ScriptException {
-        e.eval("var p_boolean_array = o.publicBooleanArray;");
-        assertEquals(o.publicBooleanArray[0], e.eval("o.publicBooleanArray[0]"));
-        assertTrue(Arrays.equals(o.publicBooleanArray, (boolean[])e.get("p_boolean_array")));
-        e.eval("var t_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
-                "t_boolean_arr[0] = true;" +
-                "t_boolean_arr[1] = false;" +
-                "t_boolean_arr[2] = false;" +
-                "o.publicBooleanArray = t_boolean_arr;");
-        assertTrue(Arrays.equals(new boolean[] { true, false, false }, o.publicBooleanArray));
-        e.eval("o.publicBooleanArray[0] = false;");
-        assertEquals(false, o.publicBooleanArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldBoolean() throws ScriptException {
-        e.eval("var ps_boolean = SharedObject.publicStaticBoolean;");
-        assertEquals(SharedObject.publicStaticBoolean, e.get("ps_boolean"));
-        assertEquals("boolean", e.eval("typeof ps_boolean;"));
-        e.eval("SharedObject.publicStaticBoolean = false;");
-        assertEquals(false, SharedObject.publicStaticBoolean);
-    }
-
-    @Test
-    public void accessStaticFieldBooleanArray() throws ScriptException {
-        e.eval("var ps_boolean_array = SharedObject.publicStaticBooleanArray;");
-        assertEquals(SharedObject.publicStaticBooleanArray[0], e.eval("SharedObject.publicStaticBooleanArray[0]"));
-        assertTrue(Arrays.equals(SharedObject.publicStaticBooleanArray, (boolean[])e.get("ps_boolean_array")));
-        e.eval("var ts_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
-                "ts_boolean_arr[0] = true;" +
-                "ts_boolean_arr[1] = false;" +
-                "ts_boolean_arr[2] = true;" +
-                "SharedObject.publicStaticBooleanArray = ts_boolean_arr;");
-        assertTrue(Arrays.equals(new boolean[] { true, false, true }, SharedObject.publicStaticBooleanArray));
-        e.eval("SharedObject.publicStaticBooleanArray[0] = false;");
-        assertEquals(false, SharedObject.publicStaticBooleanArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldBoolean() throws ScriptException {
-        e.eval("var pf_boolean = o.publicFinalBoolean;");
-        assertEquals(o.publicFinalBoolean, e.get("pf_boolean"));
-        assertEquals("boolean", e.eval("typeof pf_boolean;"));
-        e.eval("o.publicFinalBoolean = false;");
-        assertEquals(true, o.publicFinalBoolean);
-    }
-
-    @Test
-    public void accessFinalFieldBooleanArray() throws ScriptException {
-        e.eval("var pf_boolean_array = o.publicFinalBooleanArray;");
-        assertEquals(o.publicFinalBooleanArray[0], e.eval("o.publicFinalBooleanArray[0]"));
-        assertTrue(Arrays.equals(o.publicFinalBooleanArray, (boolean[])e.get("pf_boolean_array")));
-        e.eval("var tf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
-                "tf_boolean_arr[0] = false;" +
-                "tf_boolean_arr[1] = false;" +
-                "tf_boolean_arr[2] = true;" +
-                "o.publicOFinalbjectArray = tf_boolean_arr;");
-        assertTrue(Arrays.equals(new boolean[] { false, false, true, false }, o.publicFinalBooleanArray));
-        e.eval("o.publicFinalBooleanArray[0] = true;");
-        assertEquals(true, o.publicFinalBooleanArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldBoolean() throws ScriptException {
-        e.eval("var psf_boolean = SharedObject.publicStaticFinalBoolean;");
-        assertEquals(SharedObject.publicStaticFinalBoolean, e.get("psf_boolean"));
-        assertEquals("boolean", e.eval("typeof psf_boolean;"));
-        e.eval("SharedObject.publicStaticFinalBoolean = false;");
-        assertEquals(true, SharedObject.publicStaticFinalBoolean);
-    }
-
-    @Test
-    public void accessStaticFinalFieldBooleanArray() throws ScriptException {
-        e.eval("var psf_boolean_array = SharedObject.publicStaticFinalBooleanArray;");
-        assertEquals(SharedObject.publicStaticFinalBooleanArray[0], e.eval("SharedObject.publicStaticFinalBooleanArray[0]"));
-        assertTrue(Arrays.equals(SharedObject.publicStaticFinalBooleanArray, (boolean[])e.get("psf_boolean_array")));
-        e.eval("var tsf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
-                "tsf_boolean_arr[0] = false;" +
-                "tsf_boolean_arr[1] = true;" +
-                "tsf_boolean_arr[2] = false;" +
-                "SharedObject.publicStaticFinalBooleanArray = tsf_boolean_arr;");
-        assertTrue(Arrays.equals(new boolean[] { false, true, false, false }, SharedObject.publicStaticFinalBooleanArray));
-        e.eval("SharedObject.publicStaticFinalBooleanArray[0] = true;");
-        assertEquals(true, SharedObject.publicStaticFinalBooleanArray[0]);
-    }
-
-    @Test
-    public void accessFieldBooleanBoxing() throws ScriptException {
-        e.eval("var p_boolean_box = o.publicBooleanBox;");
-        assertEquals(o.publicBooleanBox, e.get("p_boolean_box"));
-        assertEquals("boolean", e.eval("typeof p_boolean_box;"));
-        e.eval("o.publicBooleanBox = false;");
-        assertEquals(false, (boolean)o.publicBooleanBox);
-    }
-
-    @Test
-    public void accessStaticFieldBooleanBoxing() throws ScriptException {
-        e.eval("var ps_boolean_box = SharedObject.publicStaticBooleanBox;");
-        assertEquals(SharedObject.publicStaticBooleanBox, e.get("ps_boolean_box"));
-        assertEquals("boolean", e.eval("typeof ps_boolean_box;"));
-        e.eval("SharedObject.publicStaticBooleanBox = false;");
-        assertEquals(false, (boolean)SharedObject.publicStaticBooleanBox);
-    }
-
-    @Test
-    public void accessFinalFieldBooleanBoxing() throws ScriptException {
-        e.eval("var pf_boolean_box = o.publicFinalBooleanBox;");
-        assertEquals(o.publicFinalBooleanBox, e.get("pf_boolean_box"));
-        assertEquals("boolean", e.eval("typeof pf_boolean_box;"));
-        e.eval("o.publicFinalBooleanBox = false;");
-        assertEquals(true, (boolean)o.publicFinalBooleanBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldBooleanBoxing() throws ScriptException {
-        e.eval("var psf_boolean_box = SharedObject.publicStaticFinalBooleanBox;");
-        assertEquals(SharedObject.publicStaticFinalBooleanBox, e.get("psf_boolean_box"));
-        assertEquals("boolean", e.eval("typeof psf_boolean_box;"));
-        e.eval("SharedObject.publicStaticFinalBooleanBox = false;");
-        assertEquals(true, (boolean)SharedObject.publicStaticFinalBooleanBox);
-    }
-
-    @Test
-    public void accessVolatileField() throws ScriptException {
-        e.eval("var pv_boolean = o.volatileBoolean;");
-        assertEquals(o.volatileBoolean, e.get("pv_boolean"));
-        assertEquals("boolean", e.eval("typeof pv_boolean;"));
-        e.eval("o.volatileBoolean = false;");
-        assertEquals(false, o.volatileBoolean);
-    }
-
-    @Test
-    public void accessTransientField() throws ScriptException {
-        e.eval("var pt_boolean = o.transientBoolean;");
-        assertEquals(o.transientBoolean, e.get("pt_boolean"));
-        assertEquals("boolean", e.eval("typeof pt_boolean;"));
-        e.eval("o.transientBoolean = false;");
-        assertEquals(false, o.transientBoolean);
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import java.util.HashMap;
-import java.util.Map;
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.JSObject;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ConsStringTest {
-    private static ScriptEngine e = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() {
-        e = new ScriptEngineManager().getEngineByName("nashorn");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-    }
-
-    @Test
-    public void testConsStringFlattening() throws ScriptException {
-        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
-        final Map<Object, Object> m = new HashMap<>();
-        b.put("m", m);
-        e.eval("var x = 'f'; x += 'oo'; var y = 'b'; y += 'ar'; m.put(x, y)");
-        assertEquals("bar", m.get("foo"));
-    }
-
-    @Test
-    public void testConsStringFromMirror() throws ScriptException {
-        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
-        //final Map<Object, Object> m = new HashMap<>();
-        e.eval("var x = 'f'; x += 'oo'; var obj = {x: x};");
-        assertEquals("foo", ((JSObject)b.get("obj")).getMember("x"));
-    }
-
-    @Test
-    public void testArrayConsString() throws ScriptException {
-        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
-        final ArrayHolder h = new ArrayHolder();
-        b.put("h", h);
-        e.eval("var x = 'f'; x += 'oo'; h.array = [x];");
-        assertEquals(1, h.array.length);
-        assertEquals("foo", h.array[0]);
-    }
-
-
-    public static class ArrayHolder {
-        private Object[] array;
-
-        public void setArray(final Object[] array) {
-            this.array = array;
-        }
-
-        public Object[] getArray() {
-            return array;
-        }
-    }
-}
--- a/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,466 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Locale;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.MethodAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.MethodAccessTest
- */
-@SuppressWarnings("javadoc")
-public class MethodAccessTest {
-
-    private static ScriptEngine e = null;
-    private static SharedObject o = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        o.setEngine(e);
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-        e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    @Test
-    public void accessMethodthrowsCheckedException() throws ScriptException {
-        e.eval("try {" +
-                "    var a = java.lang.Long.parseLong('foo');" +
-                "} catch(e) {" +
-                "    var isThrown = true;" +
-                "    var isNumberException = e instanceof java.lang.NumberFormatException;" +
-                "} finally {" +
-                "    var isFinalized = true;" +
-                "}");
-        assertEquals("Exception thrown", true, e.get("isThrown"));
-        assertEquals("Finally called", true, e.get("isFinalized"));
-        assertEquals("Type is NumberFormatException", true, e.get("isNumberException"));
-    }
-
-    @Test
-    public void accessMethodthrowsUnCheckedException() throws ScriptException {
-        e.eval("try {" +
-                "    var a = java.lang.String.valueOf(null);" +
-                "} catch(e) {" +
-                "    var isThrown = true;" +
-                "    var isNumberException = e instanceof java.lang.NullPointerException;" +
-                "} finally {" +
-                "    var isFinalized = true;" +
-                "}");
-        assertEquals(true, e.get("isThrown"));
-        assertEquals(true, e.get("isFinalized"));
-        assertEquals(true, e.get("isNumberException"));
-    }
-
-    @Test
-    public void accessMethodStartsThread() throws ScriptException {
-        e.eval("o.methodStartsThread();");
-        assertEquals(false, o.isFinished);
-    }
-
-    @Test
-    public void accessStaticMethod() throws ScriptException {
-        assertEquals(10, e.eval("java.lang.Math.abs(-10);"));
-    }
-
-    @Test
-    public void accessSynchronousMethod() throws ScriptException {
-        e.eval("var v = new java.util.Vector();" + "v.add(10);" + "v.add(20);" + "v.add(30);");
-        assertEquals(10, e.eval("v[0]"));
-        assertEquals(20, e.eval("v[1]"));
-        assertEquals(30, e.eval("v[2]"));
-        assertEquals(3, e.eval("v.size()"));
-    }
-
-    @Test
-    public void accessStaticSynchronousMethod() throws ScriptException {
-        e.eval("var locales = java.util.Calendar.getAvailableLocales();");
-        final Locale[] locales = (Locale[])e.get("locales");
-        assertEquals(locales.length, Calendar.getAvailableLocales().length);
-    }
-
-    @Test
-    public void accessNativeMethod() throws ScriptException {
-        assertEquals(4.0, e.eval("java.lang.StrictMath.log10(10000);"));
-    }
-
-    @Test
-    public void accessConstructorOfAbstractClass() throws ScriptException {
-        e.eval("try {" +
-                "    var a = new java.util.AbstractList();" +
-                "    print('fail');" +
-                "} catch(e) {" +
-                "    var isThrown = true;" +
-                "}");
-        assertEquals(true, e.get("isThrown"));
-    }
-
-    @Test
-    public void accessMethodVoid() throws ScriptException {
-        o.isAccessed = false;
-        e.eval("o.voidMethod();");
-        assertTrue(o.isAccessed);
-    }
-
-    @Test
-    public void accessMethodBoolean() throws ScriptException {
-        assertEquals(true, e.eval("o.booleanMethod(false);"));
-        assertEquals(false, e.eval("o.booleanMethod(true);"));
-        assertEquals(false, e.eval("o.booleanMethod('false');"));
-        assertEquals(true, e.eval("o.booleanMethod('');"));
-        assertEquals(true, e.eval("o.booleanMethod(0);"));
-    }
-
-    @Test
-    public void accessMethodInt() throws ScriptException {
-        assertEquals(0, e.eval("o.intMethod(0);"));
-        assertEquals(-200, e.eval("o.intMethod(-100);"));
-        assertEquals(0, e.eval("o.intMethod('0');"));
-        assertEquals(-200, e.eval("o.intMethod('-100');"));
-    }
-
-    @Test
-    public void accessMethodLong() throws ScriptException {
-        assertEquals((long)0, e.eval("o.longMethod(0);"));
-        assertEquals((long)400, e.eval("o.longMethod(200);"));
-        assertEquals((long) 0, e.eval("o.longMethod('0');"));
-        assertEquals((long) 400, e.eval("o.longMethod('200');"));
-    }
-
-    @Test
-    public void accessMethodByte() throws ScriptException {
-        assertEquals((byte) 0, e.eval("o.byteMethod(0);"));
-        assertEquals((byte) 10, e.eval("o.byteMethod(5);"));
-        assertEquals((byte) 0, e.eval("o.byteMethod('0');"));
-        assertEquals((byte) 10, e.eval("o.byteMethod('5');"));
-    }
-
-    @Test
-    public void accessMethodShort() throws ScriptException {
-        assertEquals((short)0, e.eval("o.shortMethod(0);"));
-        assertEquals((short)8000, e.eval("o.shortMethod(4000);"));
-        assertEquals((short) 0, e.eval("o.shortMethod('0');"));
-        assertEquals((short) 8000, e.eval("o.shortMethod('4000');"));
-    }
-
-    @Test
-    public void accessMethodChar() throws ScriptException {
-        assertEquals('A', e.eval("o.charMethod('a');"));
-        assertEquals('Z', e.eval("o.charMethod('z');"));
-        assertEquals(o.charMethod((char)0), e.eval("o.charMethod(0);"));
-        assertEquals(o.charMethod((char)3150), e.eval("o.charMethod(3150);"));
-    }
-
-    @Test
-    public void accessMethodFloat() throws ScriptException {
-        assertEquals(0.0f, e.eval("o.floatMethod(0.0);"));
-        assertEquals(4.2f, e.eval("o.floatMethod(2.1);"));
-        assertEquals(0.0f, e.eval("o.floatMethod('0.0');"));
-        assertEquals(4.2f, e.eval("o.floatMethod('2.1');"));
-    }
-
-    @Test
-    public void accessMethodDouble() throws ScriptException {
-        assertEquals(0.0, e.eval("o.doubleMethod(0.0);"));
-        assertEquals(14.0, e.eval("o.doubleMethod(7.0);"));
-        assertEquals(0.0, e.eval("o.doubleMethod('0.0');"));
-        assertEquals(14.0, e.eval("o.doubleMethod('7.0');"));
-    }
-
-    @Test
-    public void accessMethodBooleanBoxing() throws ScriptException {
-        assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.FALSE);"));
-        assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.TRUE);"));
-        assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod('');"));
-        assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod('false');"));
-    }
-
-    @Test
-    public void accessMethodIntBoxing() throws ScriptException {
-        assertEquals(0, e.eval("o.intBoxingMethod(0);"));
-        assertEquals(-200, e.eval("o.intBoxingMethod(-100);"));
-        assertTrue((int)e.eval("(new java.lang.Integer(2)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodLongBoxing() throws ScriptException {
-        assertEquals((long) 0, e.eval("o.longBoxingMethod(0);"));
-        assertEquals((long) 400, e.eval("o.longBoxingMethod(200);"));
-        assertTrue((int)e.eval("(new java.lang.Long(2)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodByteBoxing() throws ScriptException {
-        assertEquals((byte) 0, e.eval("o.byteBoxingMethod(0);"));
-        assertEquals((byte) 10, e.eval("o.byteBoxingMethod(5);"));
-        assertTrue((int)e.eval("(new java.lang.Byte(2)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodShortBoxing() throws ScriptException {
-        assertEquals((short) 0, e.eval("o.shortBoxingMethod(0);"));
-        assertEquals((short) 8000, e.eval("o.shortBoxingMethod(4000);"));
-        assertTrue((int)e.eval("(new java.lang.Short(2)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodCharBoxing() throws ScriptException {
-        assertEquals('A', e.eval("o.charBoxingMethod('a');"));
-        assertEquals('Z', e.eval("o.charBoxingMethod('z');"));
-        assertTrue((int)e.eval("(new java.lang.Character(2)).compareTo(10)") < 0);
-    }
-
-    @Test
-    public void accessMethodFloatBoxing() throws ScriptException {
-        assertEquals(0.0f, e.eval("o.floatBoxingMethod(0.0);"));
-        assertEquals(4.2f, e.eval("o.floatBoxingMethod(2.1);"));
-        assertTrue((int)e.eval("(new java.lang.Float(2.0)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodDoubleBoxing() throws ScriptException {
-        assertEquals(0.0, e.eval("o.doubleBoxingMethod(0.0);"));
-        assertEquals(14.0, e.eval("o.doubleBoxingMethod(7.0);"));
-        assertTrue((int)e.eval("(new java.lang.Double(2)).compareTo(10.0)") < 0);
-    }
-
-    @Test
-    public void accessMethodString() throws ScriptException {
-        assertEquals("", e.eval("o.stringMethod('');"));
-        assertEquals("abcabc", e.eval("o.stringMethod('abc');"));
-    }
-
-    @Test
-    public void accessMethodObject() throws ScriptException {
-        e.put("so", new Person(5));
-        e.eval("var rso = o.objectMethod(so);");
-        assertEquals(new Person(10), e.get("rso"));
-    }
-
-    @Test
-    public void accessMethodBooleanArray() throws ScriptException {
-        assertTrue(Arrays.equals(o.booleanArrayMethod(o.publicBooleanArray), (boolean[])e.eval("o.booleanArrayMethod(o.publicBooleanArray);")));
-    }
-
-    @Test
-    public void accessMethodIntArray() throws ScriptException {
-        assertArrayEquals(o.intArrayMethod(o.publicIntArray), (int[])e.eval("o.intArrayMethod(o.publicIntArray);"));
-    }
-
-    @Test
-    public void accessMethodLongArray() throws ScriptException {
-        assertArrayEquals(o.longArrayMethod(o.publicLongArray), (long[])e.eval("o.longArrayMethod(o.publicLongArray);"));
-    }
-
-    @Test
-    public void accessMethodByteArray() throws ScriptException {
-        assertArrayEquals(o.byteArrayMethod(o.publicByteArray), (byte[])e.eval("o.byteArrayMethod(o.publicByteArray);"));
-    }
-
-    @Test
-    public void accessMethodShortArray() throws ScriptException {
-        assertArrayEquals(o.shortArrayMethod(o.publicShortArray), (short[])e.eval("o.shortArrayMethod(o.publicShortArray);"));
-    }
-
-    @Test
-    public void accessMethodCharArray() throws ScriptException {
-        assertArrayEquals(o.charArrayMethod(o.publicCharArray), (char[])e.eval("o.charArrayMethod(o.publicCharArray);"));
-    }
-
-    @Test
-    public void accessMethodFloatArray() throws ScriptException {
-        assertArrayEquals(o.floatArrayMethod(o.publicFloatArray), (float[])e.eval("o.floatArrayMethod(o.publicFloatArray);"), 1e-10f);
-    }
-
-    @Test
-    public void accessMethodDoubleArray() throws ScriptException {
-        assertArrayEquals(o.doubleArrayMethod(o.publicDoubleArray), (double[])e.eval("o.doubleArrayMethod(o.publicDoubleArray);"), 1e-10);
-    }
-
-    @Test
-    public void accessMethodStringArray() throws ScriptException {
-        assertArrayEquals(o.stringArrayMethod(o.publicStringArray), (String[])e.eval("o.stringArrayMethod(o.publicStringArray);"));
-    }
-
-    @Test
-    public void accessMethodObjectArray() throws ScriptException {
-        assertArrayEquals(o.objectArrayMethod(o.publicObjectArray), (Person[])e.eval("o.objectArrayMethod(o.publicObjectArray);"));
-    }
-
-    @Test
-    public void accessDefaultConstructor() throws ScriptException {
-        e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.Person()");
-        assertEquals(new Person(), e.get("dc"));
-    }
-
-    @Test
-    public void accessCustomConstructor() throws ScriptException {
-        e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.Person(17)");
-        assertEquals(new Person(17), e.get("cc"));
-    }
-
-    @Test
-    public void accessMethod2PrimitiveParams() throws ScriptException {
-        assertEquals(o.twoParamMethod(50, 40.0), e.eval("o.twoParamMethod(50,40);"));
-    }
-
-    @Test
-    public void accessMethod3PrimitiveParams() throws ScriptException {
-        assertEquals(o.threeParamMethod((short)10, 20L, 'b'), e.eval("o.threeParamMethod(10,20,'b');"));
-    }
-
-    @Test
-    public void accessMethod2ObjectParams() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(200), new Person(300) }, (Person[])e.eval("o.twoObjectParamMethod(new Person(300),new Person(200));"));
-    }
-
-    @Test
-    public void accessMethod3ObjectParams() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.threeObjectParamMethod(new Person(1),new Person(2),new Person(3));"));
-    }
-
-    @Test
-    public void accessMethod8ObjectParams() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.eightObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6),new Person(7),new Person(8));"));
-    }
-
-    @Test
-    public void accessMethod9ObjectParams() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.nineObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
-    }
-
-    @Test
-    public void accessMethodObjectEllipsis() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
-        assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodObjectEllipsis()"));
-        assertArrayEquals(new Person[] { new Person(9) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(9))"));
-    }
-
-    @Test
-    public void accessMethodPrimitiveEllipsis() throws ScriptException {
-        assertArrayEquals(new Person[] { new Person(1), new Person(3), new Person(2) }, (Person[])e.eval("o.methodPrimitiveEllipsis(1,3,2);"));
-        assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodPrimitiveEllipsis();"));
-        assertArrayEquals(o.methodPrimitiveEllipsis(9, 8, 7, 6, 5, 4, 3, 2, 1), (Person[])e.eval("o.methodPrimitiveEllipsis(9,8,7,6,5,4,3,2,1);"));
-    }
-
-    @Test
-    public void accessMethodMixedEllipsis() throws ScriptException {
-        assertArrayEquals(new Object[] { new Person(1), 12, "hello", true }, (Object[])e.eval("o.methodMixedEllipsis(new Person(1),12,'hello',true);"));
-        assertArrayEquals(new Object[] {}, (Object[])e.eval("o.methodMixedEllipsis();"));
-    }
-
-    @Test
-    public void accessMethodObjectWithEllipsis() throws ScriptException {
-        assertArrayEquals(new Object[] { "hello", 12, 15, 16 }, (Object[])e.eval("o.methodObjectWithEllipsis('hello',12,15,16);"));
-        assertArrayEquals(new Object[] { "hello" }, (Object[])e.eval("o.methodObjectWithEllipsis('hello');"));
-    }
-
-    @Test
-    public void accessMethodPrimitiveWithEllipsis() throws ScriptException {
-        assertArrayEquals(new Object[] { 14, 12L, 15L, 16L }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(14,12,15,16);"));
-        assertArrayEquals(new Object[] { 12 }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(12);"));
-    }
-
-    @Test
-    public void accessMethodMixedWithEllipsis() throws ScriptException {
-        assertArrayEquals(new Object[] { "Hello", 10, true, -100500, 80d }, (Object[])e.eval("o.methodMixedWithEllipsis('Hello', 10, true, -100500,80.0);"));
-        assertArrayEquals(new Object[] { "Nashorn", 15 }, (Object[])e.eval("o.methodMixedWithEllipsis('Nashorn',15);"));
-    }
-
-    @Test
-    public void accessMethodOverloaded() throws ScriptException {
-        assertEquals(0, e.eval("o.overloadedMethod(0);"));
-        assertEquals(2000, e.eval("o.overloadedMethod(1000);"));
-        assertEquals(2, e.eval("o.overloadedMethod('10');"));
-        assertEquals(7, e.eval("o.overloadedMethod('Nashorn');"));
-        assertEquals(4, e.eval("o.overloadedMethod('true');"));
-        assertEquals(1, e.eval("o.overloadedMethod(true);"));
-        assertEquals(0, e.eval("o.overloadedMethod(false);"));
-        assertEquals(44, e.eval("o.overloadedMethod(new Person(22));"));
-        assertEquals(0, e.eval("o.overloadedMethod(new Person());"));
-    }
-
-    @Test
-    public void accessMethodDoubleVSintOverloaded() throws ScriptException {
-        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.0);"));
-        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(1000.0);"));
-        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.01);"));
-        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(100.02);"));
-        assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(0);"));
-        assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(1000);"));
-    }
-
-    @Test
-    public void accessJavaMethodIntFromJSFromJavaFromJS() throws ScriptException {
-        e.eval("function secondLevelMethodInt(a) {"
-                + "return o.thirdLevelMethodInt(a);"
-                + "}");
-        assertEquals(50, e.eval("o.firstLevelMethodInt(10);"));
-    }
-
-    @Test
-    public void accessJavaMethodIntegerFromJSFromJavaFromJS() throws ScriptException {
-        e.eval("function secondLevelMethodInteger(a) {"
-                + "return o.thirdLevelMethodInteger(a);"
-                + "}");
-        assertEquals(100, e.eval("o.firstLevelMethodInteger(10);"));
-    }
-
-    @Test
-    public void accessJavaMethodObjectFromJSFromJavaFromJS() throws ScriptException {
-        e.eval("function secondLevelMethodObject(p) {"
-                + "return o.thirdLevelMethodObject(p);"
-                + "}");
-        assertEquals(new Person(100), e.eval("o.firstLevelMethodObject(new Person(10));"));
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,789 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.NumberAccessTest
- */
-@SuppressWarnings("javadoc")
-public class NumberAccessTest {
-
-    private static ScriptEngine e;
-    private static SharedObject o;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    // --------------------------------long
-    // tests------------------------------------
-    @Test
-    public void accessFieldLong() throws ScriptException {
-        e.eval("var p_long = o.publicLong;");
-        assertEquals(o.publicLong, e.get("p_long"));
-        e.eval("o.publicLong = 12;");
-        assertEquals(12, o.publicLong);
-    }
-
-    @Test
-    public void accessFieldLongArray() throws ScriptException {
-        e.eval("var p_long_array = o.publicLongArray;");
-        assertEquals(o.publicLongArray[0], e.eval("o.publicLongArray[0];"));
-        assertArrayEquals(o.publicLongArray, (long[])e.get("p_long_array"));
-        e.eval("var t_long_arr = new (Java.type(\"long[]\"))(3);" +
-                "t_long_arr[0] = -189009;" +
-                "t_long_arr[1] = 456;" +
-                "t_long_arr[2] = 600000001;" +
-                "o.publicLongArray = t_long_arr;");
-        // e.eval("o.publicIntArray = [-189009,456,600000001];");
-        assertArrayEquals(new long[] { -189009, 456, 600000001 }, o.publicLongArray);
-        e.eval("o.publicLongArray[0] = 10;");
-        assertEquals(10, o.publicLongArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldLong() throws ScriptException {
-        e.eval("var ps_long = SharedObject.publicStaticLong;");
-        assertEquals(SharedObject.publicStaticLong, e.get("ps_long"));
-        e.eval("SharedObject.publicStaticLong = 120;");
-        assertEquals(120, SharedObject.publicStaticLong);
-    }
-
-    @Test
-    public void accessStaticFieldLongArray() throws ScriptException {
-        e.eval("var ps_long_array = SharedObject.publicStaticLongArray;");
-        assertEquals(SharedObject.publicStaticLongArray[0], e.eval("SharedObject.publicStaticLongArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticLongArray, (long[])e.get("ps_long_array"));
-        e.eval("var ts_long_arr = new (Java.type(\"long[]\"))(3);" +
-                "ts_long_arr[0] = -189009;" +
-                "ts_long_arr[1] = 456;" +
-                "ts_long_arr[2] = 600000001;" +
-                "SharedObject.publicStaticLongArray = ts_long_arr;");
-        // e.eval("o.publicIntArray = [-189009,456,600000001];");
-        assertArrayEquals(new long[] { -189009, 456, 600000001 }, SharedObject.publicStaticLongArray);
-        e.eval("SharedObject.publicStaticLongArray[0] = 10;");
-        assertEquals(10, SharedObject.publicStaticLongArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldLong() throws ScriptException {
-        e.eval("var pf_long = o.publicFinalLong;");
-        assertEquals(o.publicFinalLong, e.get("pf_long"));
-        e.eval("o.publicFinalLong = 120;");
-        assertEquals(13353333333333333L, o.publicFinalLong);
-    }
-
-    @Test
-    public void accessFinalFieldLongArray() throws ScriptException {
-        e.eval("var pf_long_array = o.publicFinalLongArray;");
-        assertEquals(o.publicFinalLongArray[0], e.eval("o.publicFinalLongArray[0];"));
-        assertArrayEquals(o.publicFinalLongArray, (long[])e.get("pf_long_array"));
-        e.eval("var tf_long_arr = new (Java.type(\"long[]\"))(3);" +
-                "tf_long_arr[0] = -189009;" +
-                "tf_long_arr[1] = 456;" +
-                "tf_long_arr[2] = 600000001;" +
-                "o.publicFinalLongArray = tf_long_arr;");
-        // e.eval("o.publicIntArray = [-189009,456,600000001];");
-        assertArrayEquals(new long[] { 1901733333333L, -2247355555L, 3977377777L }, o.publicFinalLongArray);
-        e.eval("o.publicFinalLongArray[0] = 10;");
-        assertEquals(10, o.publicFinalLongArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldLong() throws ScriptException {
-        e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
-        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
-        e.eval("SharedObject.publicStaticFinalLong = 120;");
-        assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
-    }
-
-    @Test
-    public void accessStaticFinalFieldLongArray() throws ScriptException {
-        e.eval("var psf_long_array = SharedObject.publicStaticFinalLongArray;");
-        assertEquals(SharedObject.publicStaticFinalLongArray[0], e.eval("SharedObject.publicStaticFinalLongArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalLongArray, (long[])e.get("psf_long_array"));
-        e.eval("var tsf_long_arr = new (Java.type(\"long[]\"))(3);" +
-                "tsf_long_arr[0] = -189009;" +
-                "tsf_long_arr[1] = 456;" +
-                "tsf_long_arr[2] = 600000001;" +
-                "SharedObject.publicStaticFinalLongArray = tsf_long_arr;");
-        // e.eval("o.publicIntArray = [-189009,456,600000001];");
-        assertArrayEquals(new long[] { 19017383333L, -2247358L, 39773787L }, SharedObject.publicStaticFinalLongArray);
-        e.eval("SharedObject.publicStaticFinalLongArray[0] = 10;");
-        assertEquals(10, SharedObject.publicStaticFinalLongArray[0]);
-    }
-
-    // --------------------------------int
-    // tests------------------------------------
-    @Test
-    public void accessFieldInt() throws ScriptException {
-        e.eval("var p_int = o.publicInt;");
-        assertEquals(o.publicInt, e.get("p_int"));
-        e.eval("o.publicInt = 14;");
-        assertEquals(14, o.publicInt);
-    }
-
-    @Test
-    public void accessFieldIntArray() throws ScriptException {
-        e.eval("var p_int_array = o.publicIntArray;");
-        assertEquals(o.publicIntArray[0], e.eval("o.publicIntArray[0];"));
-        assertArrayEquals(o.publicIntArray, (int[])e.get("p_int_array"));
-        e.eval("var t_int_arr = new (Java.type(\"int[]\"))(3);" +
-                "t_int_arr[0] = 4;" +
-                "t_int_arr[1] = 5;" +
-                "t_int_arr[2] = 6;" +
-                "o.publicIntArray = t_int_arr;");
-        assertArrayEquals(new int[] { 4, 5, 6 }, o.publicIntArray);
-        e.eval("o.publicIntArray[0] = 100;");
-        assertEquals(100, o.publicIntArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldInt() throws ScriptException {
-        e.eval("var ps_int = SharedObject.publicStaticInt;");
-        assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
-        e.eval("SharedObject.publicStaticInt = 140;");
-        assertEquals(140, SharedObject.publicStaticInt);
-    }
-
-    @Test
-    public void accessStaticFieldIntArray() throws ScriptException {
-        e.eval("var ps_int_array = SharedObject.publicStaticIntArray;");
-        assertEquals(SharedObject.publicStaticIntArray[0], e.eval("SharedObject.publicStaticIntArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticIntArray, (int[])e.get("ps_int_array"));
-        e.eval("var ts_int_arr = new (Java.type(\"int[]\"))(3);" +
-                "ts_int_arr[0] = 4;" +
-                "ts_int_arr[1] = 5;" +
-                "ts_int_arr[2] = 6;" +
-                "SharedObject.publicStaticIntArray = ts_int_arr;");
-        assertArrayEquals(new int[] { 4, 5, 6 }, SharedObject.publicStaticIntArray);
-        e.eval("SharedObject.publicStaticIntArray[0] = 100;");
-        assertEquals(100, SharedObject.publicStaticIntArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldInt() throws ScriptException {
-        e.eval("var pf_int = o.publicFinalInt;");
-        assertEquals(o.publicFinalInt, e.get("pf_int"));
-
-        e.eval("o.publicFinalInt = 10;");
-        assertEquals(20712023, o.publicFinalInt);
-    }
-
-    @Test
-    public void accessFinalFieldIntArray() throws ScriptException {
-        e.eval("var pf_int_array = o.publicFinalIntArray;");
-        assertEquals(o.publicFinalIntArray[0], e.eval("o.publicFinalIntArray[0];"));
-        assertArrayEquals(o.publicFinalIntArray, (int[])e.get("pf_int_array"));
-        e.eval("var tf_int_arr = new (Java.type(\"int[]\"))(3);" +
-                "tf_int_arr[0] = 4;" +
-                "tf_int_arr[1] = 5;" +
-                "tf_int_arr[2] = 6;" +
-                "o.publicFinalIntArray = tf_int_arr;");
-        assertArrayEquals(new int[] { 50, 80, 130, 210, 340 }, o.publicFinalIntArray);
-        e.eval("o.publicFinalIntArray[0] = 100;");
-        assertEquals(100, o.publicFinalIntArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldInt() throws ScriptException {
-        e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
-        assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
-        e.eval("SharedObject.publicStaticFinalInt = 140;");
-        assertEquals(207182023, SharedObject.publicStaticFinalInt);
-    }
-
-    @Test
-    public void accessStaticFinalFieldIntArray() throws ScriptException {
-        e.eval("var psf_int_array = SharedObject.publicStaticFinalIntArray;");
-        assertEquals(SharedObject.publicStaticFinalIntArray[0], e.eval("SharedObject.publicStaticFinalIntArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalIntArray, (int[])e.get("psf_int_array"));
-        e.eval("var tsf_int_arr = new (Java.type(\"int[]\"))(3);" +
-                "tsf_int_arr[0] = 4;" +
-                "tsf_int_arr[1] = 5;" +
-                "tsf_int_arr[2] = 6;" +
-                "SharedObject.publicStaticFinalIntArray = tsf_int_arr;");
-        assertArrayEquals(new int[] { 1308, 210, 340 }, SharedObject.publicStaticFinalIntArray);
-        e.eval("SharedObject.publicStaticFinalIntArray[0] = 100;");
-        assertEquals(100, SharedObject.publicStaticFinalIntArray[0]);
-    }
-
-    // --------------------------------byte
-    // tests------------------------------------
-    @Test
-    public void accessFieldByte() throws ScriptException {
-        e.eval("var p_byte = o.publicByte;");
-        assertEquals((double)o.publicByte, ((Number)e.get("p_byte")).doubleValue());
-        e.eval("o.publicByte = 16;");
-        assertEquals(16, o.publicByte);
-    }
-
-    @Test
-    public void accessFieldByteArray() throws ScriptException {
-        e.eval("var p_byte_array = o.publicByteArray;");
-        assertEquals(o.publicByteArray[0], e.eval("o.publicByteArray[0];"));
-        assertArrayEquals(o.publicByteArray, (byte[])e.get("p_byte_array"));
-        e.eval("var t_byte_arr = new (Java.type(\"byte[]\"))(3);" +
-                "t_byte_arr[0] = -18;" +
-                "t_byte_arr[1] = 56;" +
-                "t_byte_arr[2] = 60;" +
-                "o.publicByteArray = t_byte_arr;");
-        assertArrayEquals(new byte[] { -18, 56, 60 }, o.publicByteArray);
-        e.eval("o.publicByteArray[0] = 100;");
-        assertEquals(100, o.publicByteArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldByte() throws ScriptException {
-        e.eval("var ps_byte = SharedObject.publicStaticByte;");
-        assertEquals((double)SharedObject.publicStaticByte, ((Number)e.get("ps_byte")).doubleValue());
-        e.eval("SharedObject.publicStaticByte = 16;");
-        assertEquals(16, SharedObject.publicStaticByte);
-    }
-
-    @Test
-    public void accessStaticFieldByteArray() throws ScriptException {
-        e.eval("var ps_byte_array = SharedObject.publicStaticByteArray;");
-        assertEquals(SharedObject.publicStaticByteArray[0], e.eval("SharedObject.publicStaticByteArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticByteArray, (byte[])e.get("ps_byte_array"));
-        e.eval("var ts_byte_arr = new (Java.type(\"byte[]\"))(3);" +
-                "ts_byte_arr[0] = -18;" +
-                "ts_byte_arr[1] = 56;" +
-                "ts_byte_arr[2] = 60;" +
-                "SharedObject.publicStaticByteArray = ts_byte_arr;");
-        assertArrayEquals(new byte[] { -18, 56, 60 }, SharedObject.publicStaticByteArray);
-        e.eval("SharedObject.publicStaticByteArray[0] = -90;");
-        assertEquals(-90, SharedObject.publicStaticByteArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldByte() throws ScriptException {
-        e.eval("var pf_byte = o.publicFinalByte;");
-        assertEquals((double)o.publicFinalByte, ((Number)e.get("pf_byte")).doubleValue());
-        e.eval("o.publicFinalByte = 16;");
-        assertEquals(-7, o.publicFinalByte);
-    }
-
-    @Test
-    public void accessFinalFieldByteArray() throws ScriptException {
-        e.eval("var pf_byte_array = o.publicFinalByteArray;");
-        assertEquals(o.publicFinalByteArray[0], e.eval("o.publicFinalByteArray[0];"));
-        assertArrayEquals(o.publicFinalByteArray, (byte[])e.get("pf_byte_array"));
-        e.eval("var tf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
-                "tf_byte_arr[0] = -18;" +
-                "tf_byte_arr[1] = 56;" +
-                "tf_byte_arr[2] = 60;" +
-                "o.publicFinalByteArray = tf_byte_arr;");
-        assertArrayEquals(new byte[] { 1, 3, 6, 17, -128 }, o.publicFinalByteArray);
-        e.eval("o.publicFinalByteArray[0] = -90;");
-        assertEquals(-90, o.publicFinalByteArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldByte() throws ScriptException {
-        e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
-        assertEquals((double)SharedObject.publicStaticFinalByte, ((Number)e.get("psf_byte")).doubleValue());
-        e.eval("SharedObject.publicStaticFinalByte = 16;");
-        assertEquals(-70, SharedObject.publicStaticFinalByte);
-    }
-
-    @Test
-    public void accessStaticFinalFieldByteArray() throws ScriptException {
-        e.eval("var psf_byte_array = SharedObject.publicStaticFinalByteArray;");
-        assertEquals(SharedObject.publicStaticFinalByteArray[0], e.eval("SharedObject.publicStaticFinalByteArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalByteArray, (byte[])e.get("psf_byte_array"));
-        e.eval("var tsf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
-                "tsf_byte_arr[0] = -18;" +
-                "tsf_byte_arr[1] = 56;" +
-                "tsf_byte_arr[2] = 60;" +
-                "SharedObject.publicStaticFinalByteArray = tsf_byte_arr;");
-        assertArrayEquals(new byte[] { 17, -128, 81 }, SharedObject.publicStaticFinalByteArray);
-        e.eval("SharedObject.publicStaticFinalByteArray[0] = -90;");
-        assertEquals(-90, SharedObject.publicStaticFinalByteArray[0]);
-    }
-
-    // --------------------------------short
-    // tests------------------------------------
-    @Test
-    public void accessFieldShort() throws ScriptException {
-        e.eval("var p_short = o.publicShort;");
-        assertEquals((double)o.publicShort, ((Number)e.get("p_short")).doubleValue());
-        e.eval("o.publicShort = 18;");
-        assertEquals(18, o.publicShort);
-    }
-
-    @Test
-    public void accessFieldShortArray() throws ScriptException {
-        e.eval("var p_short_array = o.publicShortArray;");
-        assertEquals(o.publicShortArray[0], e.eval("o.publicShortArray[0];"));
-        assertArrayEquals(o.publicShortArray, (short[])e.get("p_short_array"));
-        e.eval("var t_short_arr = new (Java.type(\"short[]\"))(3);" +
-                "t_short_arr[0] = 90;" +
-                "t_short_arr[1] = 5;" +
-                "t_short_arr[2] = -6000;" +
-                "o.publicShortArray = t_short_arr;");
-        assertArrayEquals(new short[] { 90, 5, -6000 }, o.publicShortArray);
-        e.eval("o.publicShortArray[0] = -1000;");
-        assertEquals(-1000, o.publicShortArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldShort() throws ScriptException {
-        e.eval("var ps_short = SharedObject.publicStaticShort;");
-        assertEquals((double)SharedObject.publicStaticShort, ((Number)e.get("ps_short")).doubleValue());
-        e.eval("SharedObject.publicStaticShort = 180;");
-        assertEquals(180, SharedObject.publicStaticShort);
-    }
-
-    @Test
-    public void accessStaticFieldShortArray() throws ScriptException {
-        e.eval("var ps_short_array = SharedObject.publicStaticShortArray;");
-        assertEquals(SharedObject.publicStaticShortArray[0], e.eval("SharedObject.publicStaticShortArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticShortArray, (short[])e.get("ps_short_array"));
-        e.eval("var ts_short_arr = new (Java.type(\"short[]\"))(3);" +
-                "ts_short_arr[0] = 90;" +
-                "ts_short_arr[1] = 5;" +
-                "ts_short_arr[2] = -6000;" +
-                "SharedObject.publicStaticShortArray = ts_short_arr;");
-        assertArrayEquals(new short[] { 90, 5, -6000 }, SharedObject.publicStaticShortArray);
-        e.eval("SharedObject.publicStaticShortArray[0] = -1000;");
-        assertEquals(-1000, SharedObject.publicStaticShortArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldShort() throws ScriptException {
-        e.eval("var pf_short = o.publicFinalShort;");
-        assertEquals((double)o.publicFinalShort, ((Number)e.get("pf_short")).doubleValue());
-        e.eval("o.publicFinalShort = 180;");
-        assertEquals(31220, o.publicFinalShort);
-    }
-
-    @Test
-    public void accessFinalFieldShortArray() throws ScriptException {
-        e.eval("var pf_short_array = o.publicFinalShortArray;");
-        assertEquals(o.publicFinalShortArray[0], e.eval("o.publicFinalShortArray[0];"));
-        assertArrayEquals(o.publicFinalShortArray, (short[])e.get("pf_short_array"));
-        e.eval("var tf_short_arr = new (Java.type(\"short[]\"))(3);" +
-                "tf_short_arr[0] = 90;" +
-                "tf_short_arr[1] = 5;" +
-                "tf_short_arr[2] = -6000;" +
-                "o.publicFinalShortArray = tf_short_arr;");
-        assertArrayEquals(new short[] { 12240, 9200, -17289, 1200, 12 }, o.publicFinalShortArray);
-        e.eval("o.publicFinalShortArray[0] = -1000;");
-        assertEquals(-1000, o.publicFinalShortArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldShort() throws ScriptException {
-        e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
-        assertEquals((double)SharedObject.publicStaticFinalShort, ((Number)e.get("psf_short")).doubleValue());
-        e.eval("SharedObject.publicStaticFinalShort = 180;");
-        assertEquals(8888, SharedObject.publicStaticFinalShort);
-    }
-
-    @Test
-    public void accessStaticFinalFieldShortArray() throws ScriptException {
-        e.eval("var psf_short_array = SharedObject.publicStaticFinalShortArray;");
-        assertEquals(SharedObject.publicStaticFinalShortArray[0], e.eval("SharedObject.publicStaticFinalShortArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalShortArray, (short[])e.get("psf_short_array"));
-        e.eval("var tsf_short_arr = new (Java.type(\"short[]\"))(3);" +
-                "tsf_short_arr[0] = 90;" +
-                "tsf_short_arr[1] = 5;" +
-                "tsf_short_arr[2] = -6000;" +
-                "SharedObject.publicStaticFinalShortArray = tsf_short_arr;");
-        assertArrayEquals(new short[] { 8240, 9280, -1289, 120, 812 }, SharedObject.publicStaticFinalShortArray);
-        e.eval("SharedObject.publicStaticFinalShortArray[0] = -1000;");
-        assertEquals(-1000, SharedObject.publicStaticFinalShortArray[0]);
-    }
-
-    // --------------------------------char
-    // tests------------------------------------
-    @Test
-    public void accessFieldChar() throws ScriptException {
-        e.eval("var p_char = o.publicChar;");
-        assertEquals(o.publicChar, e.get("p_char"));
-        e.eval("o.publicChar = 'S';");
-        assertEquals('S', o.publicChar);
-        e.eval("o.publicChar = 10;");
-        assertEquals(10, o.publicChar);
-        e.eval("try {"
-                + "    o.publicChar = 'Big string';" +
-                "} catch(e) {" +
-                "    var isThrown = true;" +
-                "}");
-        assertEquals("Exception thrown", true, e.get("isThrown"));
-        assertEquals(10, o.publicChar);
-    }
-
-    @Test
-    public void accessFieldCharArray() throws ScriptException {
-        e.eval("var p_char_array = o.publicCharArray;");
-        assertEquals(o.publicCharArray[0], e.eval("o.publicCharArray[0];"));
-        assertArrayEquals(o.publicCharArray, (char[])e.get("p_char_array"));
-        e.eval("var t_char_arr = new (Java.type(\"char[]\"))(3);" +
-                "t_char_arr[0] = 'F';" +
-                "t_char_arr[1] = 'o';" +
-                "t_char_arr[2] = 'o';" +
-                "o.publicCharArray = t_char_arr;");
-        assertArrayEquals("Foo".toCharArray(), o.publicCharArray);
-        e.eval("o.publicCharArray[0] = 'Z';");
-        assertEquals('Z', o.publicCharArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldChar() throws ScriptException {
-        e.eval("var ps_char = SharedObject.publicStaticChar;");
-        assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
-        e.eval("SharedObject.publicStaticChar = 'Z';");
-        assertEquals('Z', SharedObject.publicStaticChar);
-    }
-
-    @Test
-    public void accessStaticFieldCharArray() throws ScriptException {
-        e.eval("var ps_char_array = SharedObject.publicStaticCharArray;");
-        assertEquals(SharedObject.publicStaticCharArray[0], e.eval("SharedObject.publicStaticCharArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticCharArray, (char[])e.get("ps_char_array"));
-        e.eval("var ts_char_arr = new (Java.type(\"char[]\"))(3);" +
-                "ts_char_arr[0] = 'G';" +
-                "ts_char_arr[1] = 'o';" +
-                "ts_char_arr[2] = 'o';" +
-                "SharedObject.publicStaticCharArray = ts_char_arr;");
-        assertArrayEquals("Goo".toCharArray(), SharedObject.publicStaticCharArray);
-        e.eval("SharedObject.publicStaticCharArray[0] = 'Z';");
-        assertEquals('Z', SharedObject.publicStaticCharArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldChar() throws ScriptException {
-        e.eval("var pf_char = o.publicFinalChar;");
-        assertEquals(o.publicFinalChar, e.get("pf_char"));
-        e.eval("o.publicFinalChar = 'S';");
-        assertEquals('E', o.publicFinalChar);
-    }
-
-    @Test
-    public void accessFinalCharArray() throws ScriptException {
-        e.eval("var pf_char_array = o.publicFinalCharArray;");
-        assertEquals(o.publicFinalCharArray[0], e.eval("o.publicFinalCharArray[0];"));
-        assertArrayEquals(o.publicFinalCharArray, (char[])e.get("pf_char_array"));
-        e.eval("var tf_char_arr = new (Java.type(\"char[]\"))(3);" +
-                "tf_char_arr[0] = 'F';" +
-                "tf_char_arr[1] = 'o';" +
-                "tf_char_arr[2] = 'o';" +
-                "o.publicFinalCharArray = tf_char_arr;");
-        assertArrayEquals("Nashorn hello".toCharArray(), o.publicFinalCharArray);
-        e.eval("o.publicFinalCharArray[0] = 'Z';");
-        assertEquals('Z', o.publicFinalCharArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldChar() throws ScriptException {
-        e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
-        assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
-        e.eval("SharedObject.publicStaticFinalChar = 'Z';");
-        assertEquals('K', SharedObject.publicStaticFinalChar);
-    }
-
-    @Test
-    public void accessStaticFinalFieldCharArray() throws ScriptException {
-        e.eval("var psf_char_array = SharedObject.publicStaticFinalCharArray;");
-        assertEquals(SharedObject.publicStaticFinalCharArray[0], e.eval("SharedObject.publicStaticFinalCharArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalCharArray, (char[])e.get("psf_char_array"));
-        e.eval("var tsf_char_arr = new (Java.type(\"char[]\"))(3);" +
-                "tsf_char_arr[0] = 'Z';" +
-                "tsf_char_arr[1] = 'o';" +
-                "tsf_char_arr[2] = 'o';" +
-                "SharedObject.publicStaticFinalCharArray = tsf_char_arr;");
-        assertArrayEquals("StaticString".toCharArray(), SharedObject.publicStaticFinalCharArray);
-        e.eval("SharedObject.publicStaticFinalCharArray[0] = 'Z';");
-        assertEquals('Z', SharedObject.publicStaticFinalCharArray[0]);
-    }
-
-    // --------------------------------float
-    // tests------------------------------------
-    @Test
-    public void accessFieldFloat() throws ScriptException {
-        e.eval("var p_float = o.publicFloat;");
-        assertEquals((double)o.publicFloat, ((Number)e.get("p_float")).doubleValue());
-        o.publicFloat = 0.0f / 0.0f;
-        assertEquals(true, e.eval("isNaN(o.publicFloat)"));
-        o.publicFloat = 1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloat"));
-        o.publicFloat = -1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloat"));
-        e.eval("o.publicFloat = 20;");
-        assertEquals(20, o.publicFloat, 1e-10);
-        e.eval("o.publicFloat = 0.0/0.0;");
-        assertTrue(Float.isNaN(o.publicFloat));
-        e.eval("o.publicFloat = 1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloat));
-        e.eval("o.publicFloat = -1.0/0.0;");
-        assertEquals(Float.NEGATIVE_INFINITY, o.publicFloat, 1e-10);
-    }
-
-    @Test
-    public void accessFieldFloatArray() throws ScriptException {
-        e.eval("var p_float_array = o.publicFloatArray;");
-        assertEquals(o.publicFloatArray[0], e.eval("o.publicFloatArray[0];"));
-        assertArrayEquals(o.publicFloatArray, (float[])e.get("p_float_array"), 1e-10f);
-        e.eval("var t_float_arr = new (Java.type(\"float[]\"))(3);" +
-                "t_float_arr[0] = 9.0;" +
-                "t_float_arr[1] = 5.12345;" +
-                "t_float_arr[2] = -60.03;" +
-                "o.publicFloatArray = t_float_arr;");
-        assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
-        e.eval("o.publicFloatArray[0] = -513.2;");
-        assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
-    }
-
-    @Test
-    public void accessStaticFieldFloat() throws ScriptException {
-        e.eval("var ps_float = SharedObject.publicStaticFloat;");
-        assertEquals((double)SharedObject.publicStaticFloat, ((Number)e.get("ps_float")).doubleValue());
-        SharedObject.publicStaticFloat = 0.0f / 0.0f;
-        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
-        SharedObject.publicStaticFloat = 1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
-        SharedObject.publicStaticFloat = -1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
-        e.eval("SharedObject.publicStaticFloat = 20.0;");
-        assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
-        e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
-        assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
-        e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
-        e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
-    }
-
-    @Test
-    public void accessStaticFieldFloatArray() throws ScriptException {
-        e.eval("var ps_float_array = SharedObject.publicStaticFloatArray;");
-        assertEquals(SharedObject.publicStaticFloatArray[0], e.eval("SharedObject.publicStaticFloatArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFloatArray, (float[])e.get("ps_float_array"), 1e-10f);
-        e.eval("var ts_float_arr = new (Java.type(\"float[]\"))(3);" +
-                "ts_float_arr[0] = 9.0;" +
-                "ts_float_arr[1] = 5.12345;" +
-                "ts_float_arr[2] = -60.03;" +
-                "SharedObject.publicStaticFloatArray = ts_float_arr;");
-        assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
-        e.eval("SharedObject.publicStaticFloatArray[0] = -513.2;");
-        assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
-    }
-
-    @Test
-    public void accessFinalFloat() throws ScriptException {
-        e.eval("var pf_float = o.publicFinalFloat;");
-        assertEquals((double)o.publicFinalFloat, ((Number)e.get("pf_float")).doubleValue());
-        e.eval("o.publicFinalFloat = 20.0;");
-        assertEquals(7.72e8f, o.publicFinalFloat, 1e-10);
-    }
-
-    @Test
-    public void accessFinalFloatArray() throws ScriptException {
-        e.eval("var pf_float_array = o.publicFinalFloatArray;");
-        assertEquals(o.publicFinalFloatArray[0], e.eval("o.publicFinalFloatArray[0];"));
-        assertArrayEquals(o.publicFinalFloatArray, (float[])e.get("pf_float_array"), 1e-10f);
-        e.eval("var tf_float_arr = new (Java.type(\"float[]\"))(3);" +
-                "tf_float_arr[0] = 9.0;" +
-                "tf_float_arr[1] = 5.12345;" +
-                "tf_float_arr[2] = -60.03;" +
-                "o.publicFinalFloatArray = tf_float_arr;");
-        assertArrayEquals(new float[] { -131.012f, 189.32f, -31.32e8f, 3.72f }, o.publicFinalFloatArray, 1e-10f);
-        e.eval("o.publicFinalFloatArray[0] = -513.2;");
-        assertEquals(-513.2f, o.publicFinalFloatArray[0], 1e-10f);
-    }
-
-    @Test
-    public void accessStaticFinalFieldFloat() throws ScriptException {
-        e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
-        assertEquals((double)SharedObject.publicStaticFinalFloat, ((Number)e.get("psf_float")).doubleValue());
-        e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
-        assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
-    }
-
-    @Test
-    public void accessStaticFinalFieldFloatArray() throws ScriptException {
-        e.eval("var psf_float_array = SharedObject.publicStaticFinalFloatArray;");
-        assertEquals(SharedObject.publicStaticFinalFloatArray[0], e.eval("SharedObject.publicStaticFinalFloatArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalFloatArray, (float[])e.get("psf_float_array"), 1e-10f);
-        e.eval("var tsf_float_arr = new (Java.type(\"float[]\"))(3);" +
-                "tsf_float_arr[0] = 9.0;" +
-                "tsf_float_arr[1] = 5.12345;" +
-                "tsf_float_arr[2] = -60.03;" +
-                "SharedObject.publicStaticFinalFloatArray = tsf_float_arr;");
-        assertArrayEquals(new float[] { -8131.012f, 9.32f, -138.32e8f, 0.72f }, SharedObject.publicStaticFinalFloatArray, 1e-10f);
-        e.eval("SharedObject.publicStaticFinalFloatArray[0] = -513.2;");
-        assertEquals(-513.2f, SharedObject.publicStaticFinalFloatArray[0], 1e-10f);
-    }
-
-    // --------------------------------double
-    // tests------------------------------------
-    @Test
-    public void accessFieldDouble() throws ScriptException {
-        e.eval("var p_double = o.publicDouble;");
-        assertEquals(o.publicDouble, e.get("p_double"));
-        o.publicDouble = 0.0 / 0.0;
-        assertEquals(true, e.eval("isNaN(o.publicDouble)"));
-        o.publicDouble = 1.0 / 0.0;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDouble"));
-        o.publicDouble = -1.0 / 0.0;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDouble"));
-        e.eval("o.publicDouble = 30;");
-        assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDouble));
-        e.eval("o.publicDouble = 0.0/0.0;");
-        assertTrue(Double.isNaN(o.publicDouble));
-        e.eval("o.publicDouble = 1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
-        e.eval("o.publicDouble = -1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
-    }
-
-    @Test
-    public void accessFieldDoubleArrayRead() throws ScriptException {
-        e.eval("var p_double_array = o.publicDoubleArray;");
-        assertEquals(o.publicDoubleArray[0], e.eval("o.publicDoubleArray[0];"));
-        assertArrayEquals(o.publicDoubleArray, (double[])e.get("p_double_array"), 1e-10);
-        e.eval("var t_double_arr = new (Java.type(\"double[]\"))(3);" +
-                "t_double_arr[0] = 9e10;" +
-                "t_double_arr[1] = 0.677777;" +
-                "t_double_arr[2] = -0.0000001;" +
-                "o.publicDoubleArray = t_double_arr;");
-        assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, o.publicDoubleArray, 1e-10f);
-        e.eval("o.publicDoubleArray[0] = -5.2e10;");
-        assertEquals(-5.2e10, o.publicDoubleArray[0], 1e-10f);
-    }
-
-    @Test
-    public void accessStaticFieldDouble() throws ScriptException {
-        e.eval("var ps_double = SharedObject.publicStaticDouble;");
-        assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
-        SharedObject.publicStaticDouble = 0.0 / 0.0;
-        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
-        SharedObject.publicStaticDouble = 1.0 / 0.0;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
-        SharedObject.publicStaticDouble = -1.0 / 0.0;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
-        e.eval("SharedObject.publicStaticDouble = 40.0;");
-        assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
-        assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-    }
-
-    @Test
-    public void accessStaticFieldDoubleArrayRead() throws ScriptException {
-        e.eval("var ps_double_array = SharedObject.publicStaticDoubleArray;");
-        assertEquals(SharedObject.publicStaticDoubleArray[0], e.eval("SharedObject.publicStaticDoubleArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticDoubleArray, (double[])e.get("ps_double_array"), 1e-10);
-        e.eval("var ts_double_arr = new (Java.type(\"double[]\"))(3);" +
-                "ts_double_arr[0] = 9e10;" +
-                "ts_double_arr[1] = 0.677777;" +
-                "ts_double_arr[2] = -0.0000001;" +
-                "SharedObject.publicStaticDoubleArray = ts_double_arr;");
-        assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, SharedObject.publicStaticDoubleArray, 1e-10f);
-        e.eval("SharedObject.publicStaticDoubleArray[0] = -5.2e10;");
-        assertEquals(-5.2e10, SharedObject.publicStaticDoubleArray[0], 1e-10f);
-    }
-
-    @Test
-    public void accessFinalFieldDouble() throws ScriptException {
-        e.eval("var pf_double = o.publicFinalDouble;");
-        assertEquals(o.publicFinalDouble, e.get("pf_double"));
-        e.eval("o.publicFinalDouble = 30.0;");
-        assertEquals(Double.doubleToLongBits(1.3412e20), Double.doubleToLongBits(o.publicFinalDouble));
-    }
-
-    @Test
-    public void accessFinalFieldDoubleArrayRead() throws ScriptException {
-        e.eval("var pf_double_array = o.publicFinalDoubleArray;");
-        assertEquals(o.publicFinalDoubleArray[0], e.eval("o.publicFinalDoubleArray[0];"));
-        assertArrayEquals(o.publicFinalDoubleArray, (double[])e.get("pf_double_array"), 1e-10);
-        e.eval("var tf_double_arr = new (Java.type(\"double[]\"))(3);" +
-                "tf_double_arr[0] = 9e10;" +
-                "tf_double_arr[1] = 0.677777;" +
-                "tf_double_arr[2] = -0.0000001;" +
-                "o.publicFinalDoubleArray = tf_double_arr;");
-        assertArrayEquals(new double[] { 0.725e80, 0.12e10, 8e-3, 1.00077 }, o.publicFinalDoubleArray, 1e-10f);
-        e.eval("o.publicFinalDoubleArray[0] = -5.2e10;");
-        assertEquals(-5.2e10, o.publicFinalDoubleArray[0], 1e-10f);
-    }
-
-    @Test
-    public void accessStaticFinalFieldDouble() throws ScriptException {
-        e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
-        assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
-        e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
-        assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
-    }
-
-    @Test
-    public void accessStaticFinalFieldDoubleArrayRead() throws ScriptException {
-        e.eval("var psf_double_array = SharedObject.publicStaticFinalDoubleArray;");
-        assertEquals(SharedObject.publicStaticFinalDoubleArray[0], e.eval("SharedObject.publicStaticFinalDoubleArray[0];"));
-        assertArrayEquals(SharedObject.publicStaticFinalDoubleArray, (double[])e.get("psf_double_array"), 1e-10);
-        e.eval("var tsf_double_arr = new (Java.type(\"double[]\"))(3);" +
-                "tsf_double_arr[0] = 9e10;" +
-                "tsf_double_arr[1] = 0.677777;" +
-                "tsf_double_arr[2] = -0.0000001;" +
-                "SharedObject.publicStaticFinalDoubleArray = tsf_double_arr;");
-        assertArrayEquals(new double[] { 8.725e80, 0.82e10, 18e-3, 1.08077 }, SharedObject.publicStaticFinalDoubleArray, 1e-10f);
-        e.eval("SharedObject.publicStaticFinalDoubleArray[0] = -5.2e10;");
-        assertEquals(-5.2e10, SharedObject.publicStaticFinalDoubleArray[0], 1e-10f);
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberBoxingTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.NumberBoxingTest
- */
-@SuppressWarnings("javadoc")
-public class NumberBoxingTest {
-
-    private static ScriptEngine e;
-    private static SharedObject o;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    // --------------------------------long
-    // tests------------------------------------
-    @Test
-    public void accessFieldLongBoxing() throws ScriptException {
-        e.eval("var p_long = o.publicLongBox;");
-        assertEquals(o.publicLongBox, e.get("p_long"));
-        e.eval("o.publicLongBox = 12;");
-        assertEquals(Long.valueOf(12), o.publicLongBox);
-    }
-
-    @Test
-    public void accessStaticFieldLongBoxing() throws ScriptException {
-        e.eval("var ps_long = SharedObject.publicStaticLongBox;");
-        assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long"));
-        e.eval("SharedObject.publicStaticLongBox = 120;");
-        assertEquals(120L, SharedObject.publicStaticLongBox.longValue());
-    }
-
-    @Test
-    public void accessFinalFieldLongBoxing() throws ScriptException {
-        e.eval("var pf_long = o.publicFinalLongBox;");
-        assertEquals(o.publicFinalLongBox, e.get("pf_long"));
-        e.eval("o.publicFinalLongBox = 120;");
-        assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldLongBoxing() throws ScriptException {
-        e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
-        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
-        e.eval("SharedObject.publicStaticFinalLong = 120;");
-        assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
-    }
-
-    // --------------------------------int
-    // tests------------------------------------
-    @Test
-    public void accessFieldIntBoxing() throws ScriptException {
-        e.eval("var p_int = o.publicIntBox;");
-        assertEquals(o.publicIntBox, e.get("p_int"));
-        e.eval("o.publicIntBox = 14;");
-        assertEquals(Integer.valueOf(14), o.publicIntBox);
-    }
-
-    @Test
-    public void accessStaticFieldIntBoxing() throws ScriptException {
-        e.eval("var ps_int = SharedObject.publicStaticInt;");
-        assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
-        e.eval("SharedObject.publicStaticInt = 140;");
-        assertEquals(140, SharedObject.publicStaticInt);
-    }
-
-    @Test
-    public void accessFinalFieldIntBoxing() throws ScriptException {
-        e.eval("var pf_int = o.publicFinalIntBox;");
-        assertEquals(o.publicFinalIntBox, e.get("pf_int"));
-        e.eval("o.publicFinalIntBox = 10;");
-        assertEquals(Integer.valueOf(207512301), o.publicFinalIntBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldIntBoxing() throws ScriptException {
-        e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
-        assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
-        e.eval("SharedObject.publicStaticFinalInt = 140;");
-        assertEquals(207182023, SharedObject.publicStaticFinalInt);
-    }
-
-    // --------------------------------byte
-    // tests------------------------------------
-    @Test
-    public void accessFieldByteBoxing() throws ScriptException {
-        e.eval("var p_byte = o.publicByteBox;");
-        assertEqualsDouble(o.publicByteBox, "p_byte");
-        e.eval("o.publicByteBox = 16;");
-        assertEquals(Byte.valueOf((byte)16), o.publicByteBox);
-    }
-
-    @Test
-    public void accessStaticFieldByteBoxing() throws ScriptException {
-        e.eval("var ps_byte = SharedObject.publicStaticByte;");
-        assertEqualsDouble(SharedObject.publicStaticByte, "ps_byte");
-        e.eval("SharedObject.publicStaticByte = 16;");
-        assertEquals(16, SharedObject.publicStaticByte);
-    }
-
-    @Test
-    public void accessFinalFieldByteBoxing() throws ScriptException {
-        e.eval("var pf_byte = o.publicFinalByteBox;");
-        assertEqualsDouble(o.publicFinalByteBox, "pf_byte");
-        e.eval("o.publicFinalByteBox = 16;");
-        assertEquals(Byte.valueOf((byte)19), o.publicFinalByteBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldByteBoxing() throws ScriptException {
-        e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
-        assertEqualsDouble(SharedObject.publicStaticFinalByte, "psf_byte");
-        e.eval("SharedObject.publicStaticFinalByte = 16;");
-        assertEquals(-70, SharedObject.publicStaticFinalByte);
-    }
-
-    // --------------------------------short
-    // tests------------------------------------
-    @Test
-    public void accessFieldShortBoxing() throws ScriptException {
-        e.eval("var p_short = o.publicShortBox;");
-        assertEqualsDouble(o.publicShortBox, "p_short");
-        e.eval("o.publicShortBox = 18;");
-        assertEquals(Short.valueOf((short)18), o.publicShortBox);
-    }
-
-    private static void assertEqualsDouble(final Number n, final String name) {
-        assertEquals(n.doubleValue(), ((Number)e.get(name)).doubleValue());
-    }
-
-    @Test
-    public void accessStaticFieldShortBoxing() throws ScriptException {
-        e.eval("var ps_short = SharedObject.publicStaticShort;");
-        assertEqualsDouble(SharedObject.publicStaticShort, "ps_short");
-        e.eval("SharedObject.publicStaticShort = 180;");
-        assertEquals(180, SharedObject.publicStaticShort);
-    }
-
-    @Test
-    public void accessFinalFieldShortBoxing() throws ScriptException {
-        e.eval("var pf_short = o.publicFinalShortBox;");
-        assertEqualsDouble(o.publicFinalShortBox, "pf_short");
-        e.eval("o.publicFinalShortBox = 180;");
-        assertEquals(Short.valueOf((short)-26777), o.publicFinalShortBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldShortBoxing() throws ScriptException {
-        e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
-        assertEqualsDouble(SharedObject.publicStaticFinalShort, "psf_short");
-        e.eval("SharedObject.publicStaticFinalShort = 180;");
-        assertEquals(8888, SharedObject.publicStaticFinalShort);
-    }
-
-    // --------------------------------char
-    // tests------------------------------------
-    @Test
-    public void accessFieldCharBoxing() throws ScriptException {
-        e.eval("var p_char = o.publicCharBox;");
-        assertEquals(o.publicCharBox, e.get("p_char"));
-        e.eval("o.publicCharBox = 'S';");
-        assertEquals(Character.valueOf('S'), o.publicCharBox);
-        e.eval("try {" +
-                "    o.publicCharBox = 'Big string';" +
-                "} catch(e) {" +
-                "    var isThrown = true;" +
-                "}");
-        assertEquals("Exception thrown", true, e.get("isThrown"));
-        assertEquals(Character.valueOf('S'), o.publicCharBox);
-    }
-
-    @Test
-    public void accessStaticFieldCharBoxing() throws ScriptException {
-        e.eval("var ps_char = SharedObject.publicStaticChar;");
-        assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
-        e.eval("SharedObject.publicStaticChar = 'Z';");
-        assertEquals('Z', SharedObject.publicStaticChar);
-    }
-
-    @Test
-    public void accessFinalFieldCharBoxing() throws ScriptException {
-        e.eval("var pf_char = o.publicFinalCharBox;");
-        assertEquals(o.publicFinalCharBox, e.get("pf_char"));
-        e.eval("o.publicFinalCharBox = 'S';");
-        assertEquals(Character.valueOf('F'), o.publicFinalCharBox);
-    }
-
-    @Test
-    public void accessStaticFinalFieldCharBoxing() throws ScriptException {
-        e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
-        assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
-        e.eval("SharedObject.publicStaticFinalChar = 'Z';");
-        assertEquals('K', SharedObject.publicStaticFinalChar);
-    }
-
-    // --------------------------------float
-    // tests------------------------------------
-    @Test
-    public void accessFieldFloatBoxing() throws ScriptException {
-        e.eval("var p_float = o.publicFloatBox;");
-        assertEqualsDouble(o.publicFloatBox, "p_float");
-        o.publicFloatBox = 0.0f / 0.0f;
-        assertEquals(true, e.eval("isNaN(o.publicFloatBox)"));
-        o.publicFloatBox = 1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloatBox"));
-        o.publicFloatBox = -1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloatBox"));
-        e.eval("o.publicFloatBox = 20;");
-        assertEquals(20, o.publicFloatBox, 1e-10);
-        e.eval("o.publicFloatBox = 0.0/0.0;");
-        assertTrue(Float.isNaN(o.publicFloatBox));
-        e.eval("o.publicFloatBox = 1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloatBox));
-        e.eval("o.publicFloatBox = -1.0/0.0;");
-        assertEquals(Float.NEGATIVE_INFINITY, o.publicFloatBox, 1e-10);
-    }
-
-    @Test
-    public void accessStaticFieldFloatBoxing() throws ScriptException {
-        e.eval("var ps_float = SharedObject.publicStaticFloat;");
-        assertEqualsDouble(SharedObject.publicStaticFloat, "ps_float");
-        SharedObject.publicStaticFloat = 0.0f / 0.0f;
-        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
-        SharedObject.publicStaticFloat = 1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
-        SharedObject.publicStaticFloat = -1.0f / 0.0f;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
-        e.eval("SharedObject.publicStaticFloat = 20.0;");
-        assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
-        e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
-        assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
-        e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
-        e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
-        assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
-    }
-
-    @Test
-    public void accessFinalFloatBoxing() throws ScriptException {
-        e.eval("var pf_float = o.publicFinalFloatBox;");
-        assertEqualsDouble(o.publicFinalFloatBox, "pf_float");
-        e.eval("o.publicFinalFloatBox = 20.0;");
-        assertEquals(1.372e4f, o.publicFinalFloatBox, 1e-10);
-    }
-
-    @Test
-    public void accessStaticFinalFieldFloatBoxing() throws ScriptException {
-        e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
-        assertEqualsDouble(SharedObject.publicStaticFinalFloat, "psf_float");
-        e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
-        assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
-    }
-
-    // --------------------------------double
-    // tests------------------------------------
-    @Test
-    public void accessFieldDoubleBoxing() throws ScriptException {
-        e.eval("var p_double = o.publicDoubleBox;");
-        assertEquals(o.publicDoubleBox, e.get("p_double"));
-        o.publicDoubleBox = 0.0 / 0.0;
-        assertEquals(true, e.eval("isNaN(o.publicDoubleBox)"));
-        o.publicDoubleBox = 1.0 / 0.0;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDoubleBox"));
-        o.publicDoubleBox = -1.0 / 0.0;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDoubleBox"));
-        e.eval("o.publicDoubleBox = 30;");
-        assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDoubleBox));
-        e.eval("o.publicDoubleBox = 0.0/0.0;");
-        assertTrue(Double.isNaN(o.publicDoubleBox));
-        e.eval("o.publicDoubleBox = 1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
-        e.eval("o.publicDoubleBox = -1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
-    }
-
-    @Test
-    public void accessStaticFieldDoubleBoxing() throws ScriptException {
-        e.eval("var ps_double = SharedObject.publicStaticDouble;");
-        assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
-        SharedObject.publicStaticDouble = 0.0 / 0.0;
-        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
-        SharedObject.publicStaticDouble = 1.0 / 0.0;
-        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
-        SharedObject.publicStaticDouble = -1.0 / 0.0;
-        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
-        e.eval("SharedObject.publicStaticDouble = 40.0;");
-        assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
-        assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-        e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
-        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
-    }
-
-    @Test
-    public void accessFinalFieldDoubleBoxing() throws ScriptException {
-        e.eval("var pf_double = o.publicFinalDoubleBox;");
-        assertEquals(o.publicFinalDoubleBox, e.get("pf_double"));
-        e.eval("o.publicFinalDoubleBox = 30.0;");
-        assertEquals(Double.doubleToLongBits(1.412e-12), Double.doubleToLongBits(o.publicFinalDoubleBox));
-    }
-
-    @Test
-    public void accessStaticFinalFieldDoubleBoxing() throws ScriptException {
-        e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
-        assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
-        e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
-        assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.ObjectAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.ObjectAccessTest
- */
-@SuppressWarnings("javadoc")
-public class ObjectAccessTest {
-
-    private static ScriptEngine e = null;
-    private static SharedObject o = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-        e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    @Test
-    public void accessFieldObject() throws ScriptException {
-        e.eval("var p_object = o.publicObject;");
-        assertEquals(o.publicObject, e.get("p_object"));
-        assertEquals("object", e.eval("typeof p_object;"));
-        e.eval("o.publicObject = new Person(14);");
-        assertEquals(new Person(14), o.publicObject);
-    }
-
-    @Test
-    public void accessFieldObjectArray() throws ScriptException {
-        e.eval("var p_object_array = o.publicObjectArray;");
-        assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]"));
-        assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array"));
-        e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
-                "t_object_arr[0] = new Person(100);" +
-                "t_object_arr[1] = new Person(120);" +
-                "t_object_arr[2] = new Person(140);" +
-                "o.publicObjectArray = t_object_arr;");
-        assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, o.publicObjectArray);
-        e.eval("o.publicObjectArray[0] = new Person(10);");
-        assertEquals(new Person(10), o.publicObjectArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldObject() throws ScriptException {
-        e.eval("var ps_object = SharedObject.publicStaticObject;");
-        assertEquals(SharedObject.publicStaticObject, e.get("ps_object"));
-        assertEquals("object", e.eval("typeof ps_object;"));
-        e.eval("SharedObject.publicStaticObject = new Person(16);");
-        assertEquals(new Person(16), SharedObject.publicStaticObject);
-    }
-
-    @Test
-    public void accessStaticFieldObjectArray() throws ScriptException {
-        e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;");
-        assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]"));
-        assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array"));
-        e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
-                "ts_object_arr[0] = new Person(100);" +
-                "ts_object_arr[1] = new Person(120);" +
-                "ts_object_arr[2] = new Person(140);" +
-                "SharedObject.publicStaticObjectArray = ts_object_arr;");
-        assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, SharedObject.publicStaticObjectArray);
-        e.eval("SharedObject.publicStaticObjectArray[0] = new Person(10);");
-        assertEquals(new Person(10), SharedObject.publicStaticObjectArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldObject() throws ScriptException {
-        e.eval("var pf_object = o.publicFinalObject;");
-        assertEquals(o.publicFinalObject, e.get("pf_object"));
-        assertEquals("object", e.eval("typeof pf_object;"));
-        e.eval("o.publicFinalObject = new Person(-999);");
-        assertEquals(new Person(1024), o.publicFinalObject);
-    }
-
-    @Test
-    public void accessFinalFieldObjectArray() throws ScriptException {
-        e.eval("var pf_object_array = o.publicFinalObjectArray;");
-        assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]"));
-        assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array"));
-        e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
-                "tf_object_arr[0] = new Person(100);" +
-                "tf_object_arr[1] = new Person(120);" +
-                "tf_object_arr[2] = new Person(140);" +
-                "o.publicOFinalbjectArray = tf_object_arr;");
-        assertArrayEquals(new Person[] { new Person(-900), new Person(1000), new Person(180) }, o.publicFinalObjectArray);
-        e.eval("o.publicFinalObjectArray[0] = new Person(10);");
-        assertEquals(new Person(10), o.publicFinalObjectArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldObject() throws ScriptException {
-        e.eval("var psf_object = SharedObject.publicStaticFinalObject;");
-        assertEquals(SharedObject.publicStaticFinalObject, e.get("psf_object"));
-        assertEquals("object", e.eval("typeof psf_object;"));
-        e.eval("SharedObject.publicStaticFinalObject = new Person(6);");
-        assertEquals(new Person(2048), SharedObject.publicStaticFinalObject);
-    }
-
-    @Test
-    public void accessStaticFinalFieldObjectArray() throws ScriptException {
-        e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;");
-        assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]"));
-        assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array"));
-        e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
-                "tsf_object_arr[0] = new Person(100);" +
-                "tsf_object_arr[1] = new Person(120);" +
-                "tsf_object_arr[2] = new Person(140);" +
-                "SharedObject.publicStaticFinalObjectArray = tsf_object_arr;");
-        assertArrayEquals(new Person[] { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) }, SharedObject.publicStaticFinalObjectArray);
-        e.eval("SharedObject.publicStaticFinalObjectArray[0] = new Person(90);");
-        assertEquals(new Person(90), SharedObject.publicStaticFinalObjectArray[0]);
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/Person.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-@SuppressWarnings("javadoc")
-public class Person {
-
-    public int id = 0;
-
-    public Person() {
-    }
-
-    public Person(final int code) {
-        this.id = code;
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (obj != null && obj instanceof Person) {
-            final Person o = (Person)obj;
-            return this.id == o.id;
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return id;
-    }
-
-    @Override
-    public String toString() {
-        return "Person(" + id + ")";
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/SharedObject.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import javax.script.Invocable;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-@SuppressWarnings("javadoc")
-public class SharedObject {
-
-    // Public fields
-    public String                 publicString                  = "PublicString";
-    public String[]               publicStringArray             = { "ArrayString[0]", "ArrayString[1]", "ArrayString[2]", "ArrayString[3]" };
-    public Person                 publicObject                  = new Person(256);
-    public Person[]               publicObjectArray             = { new Person(4), new Person(-422), new Person(14) };
-    public boolean                publicBoolean                 = true;
-    public boolean[]              publicBooleanArray            = { true, false, false, true };
-    public Boolean                publicBooleanBox              = true;
-    public long                   publicLong                    = 933333333333333333L;
-    public long[]                 publicLongArray               = { 99012333333333L, -124355555L, 89777777777L };
-    public Long                   publicLongBox                 = 9333333333L;
-    public int                    publicInt                     = 2076543123;
-    public int[]                  publicIntArray                = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
-    public Integer                publicIntBox                  = 20765123;
-    public byte                   publicByte                    = -128;
-    public byte[]                 publicByteArray               = { 1, 2, 4, 8, 16, 32, 64, 127, -128 };
-    public Byte                   publicByteBox                 = 127;
-    public short                  publicShort                   = 32000;
-    public short[]                publicShortArray              = { 3240, 8900, -16789, 1, 12 };
-    public Short                  publicShortBox                = Short.MIN_VALUE;
-    public float                  publicFloat                   = 0.7f;
-    public float[]                publicFloatArray              = { -32.01f, 89.3f, -1.3e8f, 3.1f };
-    public Float                  publicFloatBox                = 1.377e4f;
-    public double                 publicDouble                  = 1.34e20;
-    public double[]               publicDoubleArray             = { 0.75e80, 8e-43, 1.000077, 0.123e10 };
-    public Double                 publicDoubleBox               = 1.4e-19;
-    public char                   publicChar                    = 'A';
-    public char[]                 publicCharArray               = "Hello Nashorn".toCharArray();
-    public Character              publicCharBox                 = 'B';
-    // Public static fields
-    public static String          publicStaticString            = "PublicStaticString";
-    public static String[]        publicStaticStringArray       = { "StaticArrayString[0]", "StaticArrayString[1]", "StaticArrayString[2]", "StaticArrayString[3]" };
-    public static Person          publicStaticObject            = new Person(512);
-    public static Person[]        publicStaticObjectArray       = { new Person(40), new Person(-22), new Person(18) };
-    public static boolean         publicStaticBoolean           = true;
-    public static boolean[]       publicStaticBooleanArray      = { false, false, false, true };
-    public static Boolean         publicStaticBooleanBox        = true;
-    public static long            publicStaticLong              = 13333333333333333L;
-    public static long[]          publicStaticLongArray         = { 19012333333333L, -224355555L, 39777777777L };
-    public static Long            publicStaticLongBox           = 9333333334L;
-    public static int             publicStaticInt               = 207654323;
-    public static int[]           publicStaticIntArray          = { 5, 8, 13, 21, 34 };
-    public static Integer         publicStaticIntBox            = 2075123;
-    public static byte            publicStaticByte              = -12;
-    public static byte[]          publicStaticByteArray         = { 16, 32, 64, 127, -128 };
-    public static Byte            publicStaticByteBox           = 17;
-    public static short           publicStaticShort             = 320;
-    public static short[]         publicStaticShortArray        = { 1240, 900, -1789, 100, 12 };
-    public static Short           publicStaticShortBox          = -16777;
-    public static float           publicStaticFloat             = 7.7e8f;
-    public static float[]         publicStaticFloatArray        = { -131.01f, 189.3f, -31.3e8f, 3.7f };
-    public static Float           publicStaticFloatBox          = 1.37e4f;
-    public static double          publicStaticDouble            = 1.341e20;
-    public static double[]        publicStaticDoubleArray       = { 0.75e80, 0.123e10, 8e-43, 1.000077 };
-    public static Double          publicStaticDoubleBox         = 1.41e-12;
-    public static char            publicStaticChar              = 'C';
-    public static char[]          publicStaticCharArray         = "Nashorn".toCharArray();
-    public static Character       publicStaticCharBox           = 'D';
-    // Public final fields
-    public final String           publicFinalString             = "PublicFinalString";
-    public final String[]         publicFinalStringArray        = { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" };
-    public final Person           publicFinalObject             = new Person(1024);
-    public final Person[]         publicFinalObjectArray        = { new Person(-900), new Person(1000), new Person(180) };
-    public final boolean          publicFinalBoolean            = true;
-    public final boolean[]        publicFinalBooleanArray       = { false, false, true, false };
-    public final Boolean          publicFinalBooleanBox         = true;
-    public final long             publicFinalLong               = 13353333333333333L;
-    public final long[]           publicFinalLongArray          = { 1901733333333L, -2247355555L, 3977377777L };
-    public final Long             publicFinalLongBox            = 9377333334L;
-    public final int              publicFinalInt                = 20712023;
-    public final int[]            publicFinalIntArray           = { 50, 80, 130, 210, 340 };
-    public final Integer          publicFinalIntBox             = 207512301;
-    public final byte             publicFinalByte               = -7;
-    public final byte[]           publicFinalByteArray          = { 1, 3, 6, 17, -128 };
-    public final Byte             publicFinalByteBox            = 19;
-    public final short            publicFinalShort              = 31220;
-    public final short[]          publicFinalShortArray         = { 12240, 9200, -17289, 1200, 12 };
-    public final Short            publicFinalShortBox           = -26777;
-    public final float            publicFinalFloat              = 7.72e8f;
-    public final float[]          publicFinalFloatArray         = { -131.012f, 189.32f, -31.32e8f, 3.72f };
-    public final Float            publicFinalFloatBox           = 1.372e4f;
-    public final double           publicFinalDouble             = 1.3412e20;
-    public final double[]         publicFinalDoubleArray        = { 0.725e80, 0.12e10, 8e-3, 1.00077 };
-    public final Double           publicFinalDoubleBox          = 1.412e-12;
-    public final char             publicFinalChar               = 'E';
-    public final char[]           publicFinalCharArray          = "Nashorn hello".toCharArray();
-    public final Character        publicFinalCharBox            = 'F';
-    // Public static final fields
-    public static final String    publicStaticFinalString       = "PublicStaticFinalString";
-    public static final String[]  publicStaticFinalStringArray  = { "StaticFinalArrayString[0]", "StaticFinalArrayString[1]", "StaticFinalArrayString[2]", "StaticFinalArrayString[3]" };
-    public static final Person    publicStaticFinalObject       = new Person(2048);
-    public static final Person[]  publicStaticFinalObjectArray  = { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) };
-    public static final boolean   publicStaticFinalBoolean      = true;
-    public static final boolean[] publicStaticFinalBooleanArray = { false, true, false, false };
-    public static final Boolean   publicStaticFinalBooleanBox   = true;
-    public static final long      publicStaticFinalLong         = 8333333333333L;
-    public static final long[]    publicStaticFinalLongArray    = { 19017383333L, -2247358L, 39773787L };
-    public static final Long      publicStaticFinalLongBox      = 9377388334L;
-    public static final int       publicStaticFinalInt          = 207182023;
-    public static final int[]     publicStaticFinalIntArray     = { 1308, 210, 340 };
-    public static final Integer   publicStaticFinalIntBox       = 2078301;
-    public static final byte      publicStaticFinalByte         = -70;
-    public static final byte[]    publicStaticFinalByteArray    = { 17, -128, 81 };
-    public static final Byte      publicStaticFinalByteBox      = 91;
-    public static final short     publicStaticFinalShort        = 8888;
-    public static final short[]   publicStaticFinalShortArray   = { 8240, 9280, -1289, 120, 812 };
-    public static final Short     publicStaticFinalShortBox     = -26;
-    public static final float     publicStaticFinalFloat        = 0.72e8f;
-    public static final float[]   publicStaticFinalFloatArray   = { -8131.012f, 9.32f, -138.32e8f, 0.72f };
-    public static final Float     publicStaticFinalFloatBox     = 1.2e4f;
-    public static final double    publicStaticFinalDouble       = 1.8e12;
-    public static final double[]  publicStaticFinalDoubleArray  = { 8.725e80, 0.82e10, 18e-3, 1.08077 };
-    public static final Double    publicStaticFinalDoubleBox    = 1.5612e-13;
-    public static final char      publicStaticFinalChar         = 'K';
-    public static final char[]    publicStaticFinalCharArray    = "StaticString".toCharArray();
-    public static final Character publicStaticFinalCharBox      = 'L';
-
-    // Special vars
-    public volatile boolean       volatileBoolean               = true;
-    public transient boolean      transientBoolean              = true;
-
-    // For methods testing
-    public boolean                isAccessed                    = false;
-    public volatile boolean       isFinished                    = false;
-
-    private ScriptEngine engine;
-
-    public ScriptEngine getEngine() {
-        return engine;
-    }
-
-    public void setEngine(final ScriptEngine engine) {
-        this.engine = engine;
-    }
-
-    public void voidMethod() {
-        isAccessed = true;
-    }
-
-    public boolean booleanMethod(final boolean arg) {
-        return !arg;
-    }
-
-    public Boolean booleanBoxingMethod(final Boolean arg) {
-        return !arg.booleanValue();
-    }
-
-    public boolean[] booleanArrayMethod(final boolean arg[]) {
-        final boolean[] res = new boolean[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = !arg[i];
-        }
-        return res;
-    }
-
-    public int intMethod(final int arg) {
-        return arg + arg;
-    }
-
-    public Integer intBoxingMethod(final Integer arg) {
-        return arg + arg;
-    }
-
-    public int[] intArrayMethod(final int arg[]) {
-        final int[] res = new int[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = arg[i] * 2;
-        }
-        return res;
-    }
-
-    public long longMethod(final long arg) {
-        return arg + arg;
-    }
-
-    public Long longBoxingMethod(final Long arg) {
-        return arg + arg;
-    }
-
-    public long[] longArrayMethod(final long[] arg) {
-        final long[] res = new long[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = arg[i] * 2;
-        }
-        return res;
-    }
-
-    public byte byteMethod(final byte arg) {
-        return (byte)(arg + arg);
-    }
-
-    public Byte byteBoxingMethod(final Byte arg) {
-        return (byte)(arg + arg);
-    }
-
-    public byte[] byteArrayMethod(final byte[] arg) {
-        final byte[] res = new byte[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = (byte)(arg[i] * 2);
-        }
-        return res;
-    }
-
-    public char charMethod(final char arg) {
-        return Character.toUpperCase(arg);
-    }
-
-    public Character charBoxingMethod(final Character arg) {
-        return Character.toUpperCase(arg);
-    }
-
-    public char[] charArrayMethod(final char[] arg) {
-        final char[] res = new char[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = Character.toUpperCase(arg[i]);
-        }
-        return res;
-    }
-
-    public short shortMethod(final short arg) {
-        return (short)(arg + arg);
-    }
-
-    public Short shortBoxingMethod(final Short arg) {
-        return (short)(arg + arg);
-    }
-
-    public short[] shortArrayMethod(final short[] arg) {
-        final short[] res = new short[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = (short)(arg[i] * 2);
-        }
-        return res;
-    }
-
-    public float floatMethod(final float arg) {
-        return arg + arg;
-    }
-
-    public Float floatBoxingMethod(final Float arg) {
-        return arg + arg;
-    }
-
-    public float[] floatArrayMethod(final float[] arg) {
-        final float[] res = new float[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = arg[i] * 2;
-        }
-        return res;
-    }
-
-    public double doubleMethod(final double arg) {
-        return arg + arg;
-    }
-
-    public Double doubleBoxingMethod(final Double arg) {
-        return arg + arg;
-    }
-
-    public double[] doubleArrayMethod(final double[] arg) {
-        final double[] res = new double[arg.length];
-        for (int i = 0; i < arg.length; i++) {
-            res[i] = arg[i] * 2;
-        }
-        return res;
-    }
-
-    public String stringMethod(final String str) {
-        return str + str;
-    }
-
-    public String[] stringArrayMethod(final String[] arr) {
-        final int l = arr.length;
-        final String[] res = new String[l];
-        for (int i = 0; i < l; i++) {
-            res[i] = arr[l - i - 1];
-        }
-        return res;
-    }
-
-    public Person[] objectArrayMethod(final Person[] arr) {
-        final Person[] res = new Person[arr.length];
-        for (int i = 0; i < arr.length; i++) {
-            res[i] = new Person(i + 100);
-        }
-        return res;
-    }
-
-    public Person objectMethod(final Person t) {
-        t.id *= 2;
-        return t;
-    }
-
-    public int twoParamMethod(final long l, final double d) {
-        return (int)(l + d);
-    }
-
-    public int threeParamMethod(final short s, final long l, final char c) {
-        return (int)(s + l + c);
-    }
-
-    public Person[] twoObjectParamMethod(final Person arg1, final Person arg2) {
-        return new Person[] { arg2, arg1 };
-    }
-
-    public Person[] threeObjectParamMethod(final Person arg1, final Person arg2, final Person arg3) {
-        return new Person[] { arg3, arg2, arg1 };
-    }
-
-    public Person[] eightObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8) {
-        return new Person[] { arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
-    }
-
-    public Person[] nineObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8, final Person arg9) {
-        return new Person[] { arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
-    }
-
-    public Person[] methodObjectEllipsis(final Person... args) {
-        final int l = args.length;
-        final Person[] res = new Person[l];
-        for (int i = 0; i < l; i++) {
-            res[i] = args[l - i - 1];
-        }
-        return res;
-    }
-
-    public Person[] methodPrimitiveEllipsis(final int... args) {
-        final int l = args.length;
-        final Person[] res = new Person[l];
-        for (int i = 0; i < l; i++) {
-            res[i] = new Person(args[i]);
-        }
-        return res;
-    }
-
-    public Object[] methodMixedEllipsis(final Object... args) {
-        return args;
-    }
-
-    public Object[] methodObjectWithEllipsis(final String arg, final int... args) {
-        final Object[] res = new Object[args.length + 1];
-        res[0] = arg;
-        for (int i = 0; i < args.length; i++) {
-            res[i + 1] = args[i];
-        }
-        return res;
-    }
-
-    public Object[] methodPrimitiveWithEllipsis(final int arg, final long... args) {
-        final Object[] res = new Object[args.length + 1];
-        res[0] = arg;
-        for (int i = 0; i < args.length; i++) {
-            res[i + 1] = args[i];
-        }
-        return res;
-    }
-
-    public Object[] methodMixedWithEllipsis(final String arg1, final int arg2, final Object... args) {
-        final Object[] res = new Object[args.length + 2];
-        res[0] = arg1;
-        res[1] = arg2;
-        System.arraycopy(args, 0, res, 2, args.length);
-        return res;
-    }
-
-    public void methodStartsThread() {
-        isFinished = false;
-
-        final Thread t = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    Thread.sleep(1000);
-                    isFinished = true;
-                } catch (final InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        });
-
-        t.start();
-    }
-
-    public String overloadedMethodDoubleVSint(final int arg) {
-        return "int";
-    }
-
-    public String overloadedMethodDoubleVSint(final double arg) {
-        return "double";
-    }
-
-    public int overloadedMethod(final int arg) {
-        return arg*2;
-    }
-
-    public int overloadedMethod(final String arg) {
-        return arg.length();
-    }
-
-    public int overloadedMethod(final boolean arg) {
-        return (arg) ? 1 : 0;
-    }
-
-    public int overloadedMethod(final Person arg) {
-        return arg.id*2;
-    }
-
-    public int firstLevelMethodInt(final int arg) throws ScriptException, NoSuchMethodException {
-        return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInt", arg);
-    }
-
-    public int thirdLevelMethodInt(final int arg) {
-        return arg*5;
-    }
-
-    public int firstLevelMethodInteger(final Integer arg) throws ScriptException, NoSuchMethodException {
-        return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInteger", arg);
-    }
-
-    public int thirdLevelMethodInteger(final Integer arg) {
-        return arg*10;
-    }
-
-    public Person firstLevelMethodObject(final Person p) throws ScriptException, NoSuchMethodException {
-        return (Person) ((Invocable)engine).invokeFunction("secondLevelMethodObject", p);
-    }
-
-    public Person thirdLevelMethodObject(final Person p) {
-        p.id *= 10;
-        return p;
-    }
-
-}
--- a/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.StringAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.StringAccessTest
- */
-@SuppressWarnings("javadoc")
-public class StringAccessTest {
-
-    private static ScriptEngine e = null;
-    private static SharedObject o = null;
-
-    public static void main(final String[] args) {
-        TestNG.main(args);
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        e = m.getEngineByName("nashorn");
-        o = new SharedObject();
-        e.put("o", o);
-        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        e = null;
-        o = null;
-    }
-
-    @Test
-    public void accessFieldString() throws ScriptException {
-        e.eval("var p_string = o.publicString;");
-        assertEquals(o.publicString, e.get("p_string"));
-        assertEquals("string", e.eval("typeof p_string;"));
-        e.eval("o.publicString = 'changedString';");
-        assertEquals("changedString", o.publicString);
-    }
-
-    @Test
-    public void accessFieldStringArray() throws ScriptException {
-        e.eval("var p_string_array = o.publicStringArray;");
-        assertEquals(o.publicStringArray[0], e.eval("o.publicStringArray[0]"));
-        assertArrayEquals(o.publicStringArray, (String[])e.get("p_string_array"));
-        e.eval("var t_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
-                "t_string_arr[0] = 'abc';" +
-                "t_string_arr[1] = '123';" +
-                "t_string_arr[2] = 'xyzzzz';" +
-                "o.publicStringArray = t_string_arr;");
-        assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, o.publicStringArray);
-        e.eval("o.publicStringArray[0] = 'nashorn';");
-        assertEquals("nashorn", o.publicStringArray[0]);
-    }
-
-    @Test
-    public void accessStaticFieldString() throws ScriptException {
-        e.eval("var ps_string = SharedObject.publicStaticString;");
-        assertEquals(SharedObject.publicStaticString, e.get("ps_string"));
-        assertEquals("string", e.eval("typeof ps_string;"));
-        e.eval("SharedObject.publicStaticString = 'changedString';");
-        assertEquals("changedString", SharedObject.publicStaticString);
-    }
-
-    @Test
-    public void accessStaticFieldStringArray() throws ScriptException {
-        e.eval("var ps_string_array = SharedObject.publicStaticStringArray;");
-        assertEquals(SharedObject.publicStaticStringArray[0], e.eval("SharedObject.publicStaticStringArray[0]"));
-        assertArrayEquals(SharedObject.publicStaticStringArray, (String[])e.get("ps_string_array"));
-        e.eval("var ts_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
-                "ts_string_arr[0] = 'abc';" +
-                "ts_string_arr[1] = '123';" +
-                "ts_string_arr[2] = 'xyzzzz';" +
-                "SharedObject.publicStaticStringArray = ts_string_arr;");
-        assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, SharedObject.publicStaticStringArray);
-        e.eval("SharedObject.publicStaticStringArray[0] = 'nashorn';");
-        assertEquals("nashorn", SharedObject.publicStaticStringArray[0]);
-    }
-
-    @Test
-    public void accessFinalFieldString() throws ScriptException {
-        e.eval("var pf_string = o.publicFinalString;");
-        assertEquals(o.publicFinalString, e.get("pf_string"));
-        assertEquals("string", e.eval("typeof pf_string;"));
-        e.eval("o.publicFinalString = 'changedString';");
-        assertEquals("PublicFinalString", o.publicFinalString);
-    }
-
-    @Test
-    public void accessFinalFieldStringArray() throws ScriptException {
-        e.eval("var pf_string_array = o.publicFinalStringArray;");
-        assertEquals(o.publicFinalStringArray[0], e.eval("o.publicFinalStringArray[0]"));
-        assertArrayEquals(o.publicFinalStringArray, (String[])e.get("pf_string_array"));
-        e.eval("var tf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
-                "tf_string_arr[0] = 'abc';" +
-                "tf_string_arr[1] = '123';" +
-                "tf_string_arr[2] = 'xyzzzz';" +
-                "o.publicFinalStringArray = tf_string_arr;");
-        assertArrayEquals(new String[] { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" }, o.publicFinalStringArray);
-        e.eval("o.publicFinalStringArray[0] = 'nashorn';");
-        assertEquals("nashorn", o.publicFinalStringArray[0]);
-    }
-
-    @Test
-    public void accessStaticFinalFieldString() throws ScriptException {
-        e.eval("var psf_string = SharedObject.publicStaticFinalString;");
-        assertEquals(SharedObject.publicStaticFinalString, e.get("psf_string"));
-        assertEquals("string", e.eval("typeof psf_string;"));
-        e.eval("SharedObject.publicStaticFinalString = 'changedString';");
-        assertEquals("PublicStaticFinalString", SharedObject.publicStaticFinalString);
-    }
-
-    @Test
-    public void accessStaticFinalFieldStringArray() throws ScriptException {
-        e.eval("var psf_string_array = SharedObject.publicStaticFinalStringArray;");
-        assertEquals(SharedObject.publicStaticFinalStringArray[0], e.eval("SharedObject.publicStaticFinalStringArray[0]"));
-        assertArrayEquals(SharedObject.publicStaticFinalStringArray, (String[])e.get("psf_string_array"));
-        e.eval("var tsf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
-                "tsf_string_arr[0] = 'abc';" +
-                "tsf_string_arr[1] = '123';" +
-                "tsf_string_arr[2] = 'xyzzzz';" +
-                "SharedObject.publicStaticFinalStringArray = tsf_string_arr;");
-        assertArrayEquals(new String[] { "StaticFinalArrayString[0]",
-                    "StaticFinalArrayString[1]",
-                    "StaticFinalArrayString[2]",
-                    "StaticFinalArrayString[3]" },
-                SharedObject.publicStaticFinalStringArray);
-        e.eval("SharedObject.publicStaticFinalStringArray[0] = 'nashorn';");
-        assertEquals("nashorn", SharedObject.publicStaticFinalStringArray[0]);
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+import java.util.Arrays;
+import java.util.List;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ArrayConversionTest {
+    private static ScriptEngine e = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+        e = new ScriptEngineManager().getEngineByName("nashorn");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+    }
+
+    @Test
+    public void testIntArrays() throws ScriptException {
+        runTest("assertNullIntArray", "null");
+        runTest("assertEmptyIntArray", "[]");
+        runTest("assertSingle42IntArray", "[42]");
+        runTest("assertSingle42IntArray", "['42']");
+        runTest("assertIntArrayConversions", "[false, true, NaN, Infinity, -Infinity, 0.4, 0.6, null, undefined, [], {}, [1], [1, 2]]");
+    }
+
+    @Test
+    public void testIntIntArrays() throws ScriptException {
+        runTest("assertNullIntIntArray", "null");
+        runTest("assertEmptyIntIntArray", "[]");
+        runTest("assertSingleEmptyIntIntArray", "[[]]");
+        runTest("assertSingleNullIntIntArray", "[null]");
+        runTest("assertLargeIntIntArray", "[[false], [1], [2, 3], [4, 5, 6], ['7', {valueOf: function() { return 8 }}]]");
+    }
+
+    @Test
+    public void testObjectObjectArrays() throws ScriptException {
+        runTest("assertLargeObjectObjectArray", "[[false], [1], ['foo', 42.3], [{x: 17}]]");
+    }
+
+    @Test
+    public void testBooleanArrays() throws ScriptException {
+        runTest("assertBooleanArrayConversions", "[false, true, '', 'false', 0, 1, 0.4, 0.6, {}, [], [false], [true], NaN, Infinity, null, undefined]");
+    }
+
+    @Test
+    public void testArrayAmbiguity() throws ScriptException {
+        runTest("x", "'abc'");
+        runTest("x", "['foo', 'bar']");
+    }
+
+    @Test
+    public void testListArrays() throws ScriptException {
+        runTest("assertListArray", "[['foo', 'bar'], ['apple', 'orange']]");
+    }
+
+    @Test
+    public void testVarArgs() throws ScriptException {
+        // Sole NativeArray in vararg position becomes vararg array itself
+        runTest("assertVarArg_42_17", "[42, 17]");
+        // NativeArray in vararg position becomes an argument if there are more arguments
+        runTest("assertVarArg_array_17", "[42], 18");
+        // Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
+        runTest("assertVarArg_function", "function() { return 'Hello' }");
+    }
+
+    private static void runTest(final String testMethodName, final String argument) throws ScriptException {
+        e.eval("Java.type('" + ArrayConversionTest.class.getName() + "')." + testMethodName + "(" + argument + ")");
+    }
+
+    public static void assertNullIntArray(final int[] array) {
+        assertNull(array);
+    }
+
+    public static void assertNullIntIntArray(final int[][] array) {
+        assertNull(array);
+    }
+
+    public static void assertEmptyIntArray(final int[] array) {
+        assertEquals(0, array.length);
+    }
+
+    public static void assertSingle42IntArray(final int[] array) {
+        assertEquals(1, array.length);
+        assertEquals(42, array[0]);
+    }
+
+
+    public static void assertIntArrayConversions(final int[] array) {
+        assertEquals(13, array.length);
+        assertEquals(0, array[0]); // false
+        assertEquals(1, array[1]); // true
+        assertEquals(0, array[2]); // NaN
+        assertEquals(0, array[3]); // Infinity
+        assertEquals(0, array[4]); // -Infinity
+        assertEquals(0, array[5]); // 0.4
+        assertEquals(0, array[6]); // 0.6 - floor, not round
+        assertEquals(0, array[7]); // null
+        assertEquals(0, array[8]); // undefined
+        assertEquals(0, array[9]); // []
+        assertEquals(0, array[10]); // {}
+        assertEquals(1, array[11]); // [1]
+        assertEquals(0, array[12]); // [1, 2]
+    }
+
+    public static void assertEmptyIntIntArray(final int[][] array) {
+        assertEquals(0, array.length);
+    }
+
+    public static void assertSingleEmptyIntIntArray(final int[][] array) {
+        assertEquals(1, array.length);
+        assertTrue(Arrays.equals(new int[0], array[0]));
+    }
+
+    public static void assertSingleNullIntIntArray(final int[][] array) {
+        assertEquals(1, array.length);
+        assertNull(null, array[0]);
+    }
+
+    public static void assertLargeIntIntArray(final int[][] array) {
+        assertEquals(5, array.length);
+        assertTrue(Arrays.equals(new int[] { 0 }, array[0]));
+        assertTrue(Arrays.equals(new int[] { 1 }, array[1]));
+        assertTrue(Arrays.equals(new int[] { 2, 3 }, array[2]));
+        assertTrue(Arrays.equals(new int[] { 4, 5, 6 }, array[3]));
+        assertTrue(Arrays.equals(new int[] { 7, 8 }, array[4]));
+    }
+
+    public static void assertLargeObjectObjectArray(final Object[][] array) throws ScriptException {
+        assertEquals(4, array.length);
+        assertTrue(Arrays.equals(new Object[] { Boolean.FALSE }, array[0]));
+        assertTrue(Arrays.equals(new Object[] { 1 }, array[1]));
+        assertTrue(Arrays.equals(new Object[] { "foo", 42.3d }, array[2]));
+        assertEquals(1, array[3].length);
+        e.getBindings(ScriptContext.ENGINE_SCOPE).put("obj", array[3][0]);
+        assertEquals(17, e.eval("obj.x"));
+    }
+
+    public static void assertBooleanArrayConversions(final boolean[] array) {
+        assertEquals(16, array.length);
+        assertFalse(array[0]); // false
+        assertTrue(array[1]); // true
+        assertFalse(array[2]); // ''
+        assertTrue(array[3]); // 'false' (yep, every non-empty string converts to true)
+        assertFalse(array[4]); // 0
+        assertTrue(array[5]); // 1
+        assertTrue(array[6]); // 0.4
+        assertTrue(array[7]); // 0.6
+        assertTrue(array[8]); // {}
+        assertTrue(array[9]); // []
+        assertTrue(array[10]); // [false]
+        assertTrue(array[11]); // [true]
+        assertFalse(array[12]); // NaN
+        assertTrue(array[13]); // Infinity
+        assertFalse(array[14]); // null
+        assertFalse(array[15]); // undefined
+    }
+
+    public static void assertListArray(final List<?>[] array) {
+        assertEquals(2, array.length);
+        assertEquals(Arrays.asList("foo", "bar"), array[0]);
+        assertEquals(Arrays.asList("apple", "orange"), array[1]);
+    }
+
+    public static void assertVarArg_42_17(final Object... args) {
+        assertEquals(2, args.length);
+        assertEquals(42, ((Number)args[0]).intValue());
+        assertEquals(17, ((Number)args[1]).intValue());
+    }
+
+    public static void assertVarArg_array_17(final Object... args) throws ScriptException {
+        assertEquals(2, args.length);
+        e.getBindings(ScriptContext.ENGINE_SCOPE).put("arr", args[0]);
+        assertTrue((Boolean)e.eval("arr instanceof Array && arr.length == 1 && arr[0] == 42"));
+        assertEquals(18, ((Number)args[1]).intValue());
+    }
+
+    public static void assertVarArg_function(final Object... args) throws ScriptException {
+        assertEquals(1, args.length);
+        e.getBindings(ScriptContext.ENGINE_SCOPE).put("fn", args[0]);
+        assertEquals("Hello", e.eval("fn()"));
+    }
+
+
+
+    public static void x(final String y) {
+        assertEquals("abc", y);
+    }
+    public static void x(final String[] y) {
+        assertTrue(Arrays.equals(new String[] { "foo", "bar"}, y));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/BooleanAccessTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import java.util.Arrays;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.BooleanAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.BooleanAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class BooleanAccessTest {
+
+    private static ScriptEngine e = null;
+    private static SharedObject o = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    @Test
+    public void accessFieldBoolean() throws ScriptException {
+        e.eval("var p_boolean = o.publicBoolean;");
+        assertEquals(o.publicBoolean, e.get("p_boolean"));
+        assertEquals("boolean", e.eval("typeof p_boolean;"));
+        e.eval("o.publicBoolean = false;");
+        assertEquals(false, o.publicBoolean);
+    }
+
+    @Test
+    public void accessFieldBooleanArray() throws ScriptException {
+        e.eval("var p_boolean_array = o.publicBooleanArray;");
+        assertEquals(o.publicBooleanArray[0], e.eval("o.publicBooleanArray[0]"));
+        assertTrue(Arrays.equals(o.publicBooleanArray, (boolean[])e.get("p_boolean_array")));
+        e.eval("var t_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+                "t_boolean_arr[0] = true;" +
+                "t_boolean_arr[1] = false;" +
+                "t_boolean_arr[2] = false;" +
+                "o.publicBooleanArray = t_boolean_arr;");
+        assertTrue(Arrays.equals(new boolean[] { true, false, false }, o.publicBooleanArray));
+        e.eval("o.publicBooleanArray[0] = false;");
+        assertEquals(false, o.publicBooleanArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldBoolean() throws ScriptException {
+        e.eval("var ps_boolean = SharedObject.publicStaticBoolean;");
+        assertEquals(SharedObject.publicStaticBoolean, e.get("ps_boolean"));
+        assertEquals("boolean", e.eval("typeof ps_boolean;"));
+        e.eval("SharedObject.publicStaticBoolean = false;");
+        assertEquals(false, SharedObject.publicStaticBoolean);
+    }
+
+    @Test
+    public void accessStaticFieldBooleanArray() throws ScriptException {
+        e.eval("var ps_boolean_array = SharedObject.publicStaticBooleanArray;");
+        assertEquals(SharedObject.publicStaticBooleanArray[0], e.eval("SharedObject.publicStaticBooleanArray[0]"));
+        assertTrue(Arrays.equals(SharedObject.publicStaticBooleanArray, (boolean[])e.get("ps_boolean_array")));
+        e.eval("var ts_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+                "ts_boolean_arr[0] = true;" +
+                "ts_boolean_arr[1] = false;" +
+                "ts_boolean_arr[2] = true;" +
+                "SharedObject.publicStaticBooleanArray = ts_boolean_arr;");
+        assertTrue(Arrays.equals(new boolean[] { true, false, true }, SharedObject.publicStaticBooleanArray));
+        e.eval("SharedObject.publicStaticBooleanArray[0] = false;");
+        assertEquals(false, SharedObject.publicStaticBooleanArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldBoolean() throws ScriptException {
+        e.eval("var pf_boolean = o.publicFinalBoolean;");
+        assertEquals(o.publicFinalBoolean, e.get("pf_boolean"));
+        assertEquals("boolean", e.eval("typeof pf_boolean;"));
+        e.eval("o.publicFinalBoolean = false;");
+        assertEquals(true, o.publicFinalBoolean);
+    }
+
+    @Test
+    public void accessFinalFieldBooleanArray() throws ScriptException {
+        e.eval("var pf_boolean_array = o.publicFinalBooleanArray;");
+        assertEquals(o.publicFinalBooleanArray[0], e.eval("o.publicFinalBooleanArray[0]"));
+        assertTrue(Arrays.equals(o.publicFinalBooleanArray, (boolean[])e.get("pf_boolean_array")));
+        e.eval("var tf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+                "tf_boolean_arr[0] = false;" +
+                "tf_boolean_arr[1] = false;" +
+                "tf_boolean_arr[2] = true;" +
+                "o.publicOFinalbjectArray = tf_boolean_arr;");
+        assertTrue(Arrays.equals(new boolean[] { false, false, true, false }, o.publicFinalBooleanArray));
+        e.eval("o.publicFinalBooleanArray[0] = true;");
+        assertEquals(true, o.publicFinalBooleanArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldBoolean() throws ScriptException {
+        e.eval("var psf_boolean = SharedObject.publicStaticFinalBoolean;");
+        assertEquals(SharedObject.publicStaticFinalBoolean, e.get("psf_boolean"));
+        assertEquals("boolean", e.eval("typeof psf_boolean;"));
+        e.eval("SharedObject.publicStaticFinalBoolean = false;");
+        assertEquals(true, SharedObject.publicStaticFinalBoolean);
+    }
+
+    @Test
+    public void accessStaticFinalFieldBooleanArray() throws ScriptException {
+        e.eval("var psf_boolean_array = SharedObject.publicStaticFinalBooleanArray;");
+        assertEquals(SharedObject.publicStaticFinalBooleanArray[0], e.eval("SharedObject.publicStaticFinalBooleanArray[0]"));
+        assertTrue(Arrays.equals(SharedObject.publicStaticFinalBooleanArray, (boolean[])e.get("psf_boolean_array")));
+        e.eval("var tsf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+                "tsf_boolean_arr[0] = false;" +
+                "tsf_boolean_arr[1] = true;" +
+                "tsf_boolean_arr[2] = false;" +
+                "SharedObject.publicStaticFinalBooleanArray = tsf_boolean_arr;");
+        assertTrue(Arrays.equals(new boolean[] { false, true, false, false }, SharedObject.publicStaticFinalBooleanArray));
+        e.eval("SharedObject.publicStaticFinalBooleanArray[0] = true;");
+        assertEquals(true, SharedObject.publicStaticFinalBooleanArray[0]);
+    }
+
+    @Test
+    public void accessFieldBooleanBoxing() throws ScriptException {
+        e.eval("var p_boolean_box = o.publicBooleanBox;");
+        assertEquals(o.publicBooleanBox, e.get("p_boolean_box"));
+        assertEquals("boolean", e.eval("typeof p_boolean_box;"));
+        e.eval("o.publicBooleanBox = false;");
+        assertEquals(false, (boolean)o.publicBooleanBox);
+    }
+
+    @Test
+    public void accessStaticFieldBooleanBoxing() throws ScriptException {
+        e.eval("var ps_boolean_box = SharedObject.publicStaticBooleanBox;");
+        assertEquals(SharedObject.publicStaticBooleanBox, e.get("ps_boolean_box"));
+        assertEquals("boolean", e.eval("typeof ps_boolean_box;"));
+        e.eval("SharedObject.publicStaticBooleanBox = false;");
+        assertEquals(false, (boolean)SharedObject.publicStaticBooleanBox);
+    }
+
+    @Test
+    public void accessFinalFieldBooleanBoxing() throws ScriptException {
+        e.eval("var pf_boolean_box = o.publicFinalBooleanBox;");
+        assertEquals(o.publicFinalBooleanBox, e.get("pf_boolean_box"));
+        assertEquals("boolean", e.eval("typeof pf_boolean_box;"));
+        e.eval("o.publicFinalBooleanBox = false;");
+        assertEquals(true, (boolean)o.publicFinalBooleanBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldBooleanBoxing() throws ScriptException {
+        e.eval("var psf_boolean_box = SharedObject.publicStaticFinalBooleanBox;");
+        assertEquals(SharedObject.publicStaticFinalBooleanBox, e.get("psf_boolean_box"));
+        assertEquals("boolean", e.eval("typeof psf_boolean_box;"));
+        e.eval("SharedObject.publicStaticFinalBooleanBox = false;");
+        assertEquals(true, (boolean)SharedObject.publicStaticFinalBooleanBox);
+    }
+
+    @Test
+    public void accessVolatileField() throws ScriptException {
+        e.eval("var pv_boolean = o.volatileBoolean;");
+        assertEquals(o.volatileBoolean, e.get("pv_boolean"));
+        assertEquals("boolean", e.eval("typeof pv_boolean;"));
+        e.eval("o.volatileBoolean = false;");
+        assertEquals(false, o.volatileBoolean);
+    }
+
+    @Test
+    public void accessTransientField() throws ScriptException {
+        e.eval("var pt_boolean = o.transientBoolean;");
+        assertEquals(o.transientBoolean, e.get("pt_boolean"));
+        assertEquals("boolean", e.eval("typeof pt_boolean;"));
+        e.eval("o.transientBoolean = false;");
+        assertEquals(false, o.transientBoolean);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/ConsStringTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import java.util.HashMap;
+import java.util.Map;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.JSObject;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ConsStringTest {
+    private static ScriptEngine e = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+        e = new ScriptEngineManager().getEngineByName("nashorn");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+    }
+
+    @Test
+    public void testConsStringFlattening() throws ScriptException {
+        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+        final Map<Object, Object> m = new HashMap<>();
+        b.put("m", m);
+        e.eval("var x = 'f'; x += 'oo'; var y = 'b'; y += 'ar'; m.put(x, y)");
+        assertEquals("bar", m.get("foo"));
+    }
+
+    @Test
+    public void testConsStringFromMirror() throws ScriptException {
+        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+        //final Map<Object, Object> m = new HashMap<>();
+        e.eval("var x = 'f'; x += 'oo'; var obj = {x: x};");
+        assertEquals("foo", ((JSObject)b.get("obj")).getMember("x"));
+    }
+
+    @Test
+    public void testArrayConsString() throws ScriptException {
+        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+        final ArrayHolder h = new ArrayHolder();
+        b.put("h", h);
+        e.eval("var x = 'f'; x += 'oo'; h.array = [x];");
+        assertEquals(1, h.array.length);
+        assertEquals("foo", h.array[0]);
+    }
+
+
+    public static class ArrayHolder {
+        private Object[] array;
+
+        public void setArray(final Object[] array) {
+            this.array = array;
+        }
+
+        public Object[] getArray() {
+            return array;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/MethodAccessTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,466 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Locale;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.MethodAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.MethodAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class MethodAccessTest {
+
+    private static ScriptEngine e = null;
+    private static SharedObject o = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        o.setEngine(e);
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+        e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    @Test
+    public void accessMethodthrowsCheckedException() throws ScriptException {
+        e.eval("try {" +
+                "    var a = java.lang.Long.parseLong('foo');" +
+                "} catch(e) {" +
+                "    var isThrown = true;" +
+                "    var isNumberException = e instanceof java.lang.NumberFormatException;" +
+                "} finally {" +
+                "    var isFinalized = true;" +
+                "}");
+        assertEquals("Exception thrown", true, e.get("isThrown"));
+        assertEquals("Finally called", true, e.get("isFinalized"));
+        assertEquals("Type is NumberFormatException", true, e.get("isNumberException"));
+    }
+
+    @Test
+    public void accessMethodthrowsUnCheckedException() throws ScriptException {
+        e.eval("try {" +
+                "    var a = java.lang.String.valueOf(null);" +
+                "} catch(e) {" +
+                "    var isThrown = true;" +
+                "    var isNumberException = e instanceof java.lang.NullPointerException;" +
+                "} finally {" +
+                "    var isFinalized = true;" +
+                "}");
+        assertEquals(true, e.get("isThrown"));
+        assertEquals(true, e.get("isFinalized"));
+        assertEquals(true, e.get("isNumberException"));
+    }
+
+    @Test
+    public void accessMethodStartsThread() throws ScriptException {
+        e.eval("o.methodStartsThread();");
+        assertEquals(false, o.isFinished);
+    }
+
+    @Test
+    public void accessStaticMethod() throws ScriptException {
+        assertEquals(10, e.eval("java.lang.Math.abs(-10);"));
+    }
+
+    @Test
+    public void accessSynchronousMethod() throws ScriptException {
+        e.eval("var v = new java.util.Vector();" + "v.add(10);" + "v.add(20);" + "v.add(30);");
+        assertEquals(10, e.eval("v[0]"));
+        assertEquals(20, e.eval("v[1]"));
+        assertEquals(30, e.eval("v[2]"));
+        assertEquals(3, e.eval("v.size()"));
+    }
+
+    @Test
+    public void accessStaticSynchronousMethod() throws ScriptException {
+        e.eval("var locales = java.util.Calendar.getAvailableLocales();");
+        final Locale[] locales = (Locale[])e.get("locales");
+        assertEquals(locales.length, Calendar.getAvailableLocales().length);
+    }
+
+    @Test
+    public void accessNativeMethod() throws ScriptException {
+        assertEquals(4.0, e.eval("java.lang.StrictMath.log10(10000);"));
+    }
+
+    @Test
+    public void accessConstructorOfAbstractClass() throws ScriptException {
+        e.eval("try {" +
+                "    var a = new java.util.AbstractList();" +
+                "    print('fail');" +
+                "} catch(e) {" +
+                "    var isThrown = true;" +
+                "}");
+        assertEquals(true, e.get("isThrown"));
+    }
+
+    @Test
+    public void accessMethodVoid() throws ScriptException {
+        o.isAccessed = false;
+        e.eval("o.voidMethod();");
+        assertTrue(o.isAccessed);
+    }
+
+    @Test
+    public void accessMethodBoolean() throws ScriptException {
+        assertEquals(true, e.eval("o.booleanMethod(false);"));
+        assertEquals(false, e.eval("o.booleanMethod(true);"));
+        assertEquals(false, e.eval("o.booleanMethod('false');"));
+        assertEquals(true, e.eval("o.booleanMethod('');"));
+        assertEquals(true, e.eval("o.booleanMethod(0);"));
+    }
+
+    @Test
+    public void accessMethodInt() throws ScriptException {
+        assertEquals(0, e.eval("o.intMethod(0);"));
+        assertEquals(-200, e.eval("o.intMethod(-100);"));
+        assertEquals(0, e.eval("o.intMethod('0');"));
+        assertEquals(-200, e.eval("o.intMethod('-100');"));
+    }
+
+    @Test
+    public void accessMethodLong() throws ScriptException {
+        assertEquals((long)0, e.eval("o.longMethod(0);"));
+        assertEquals((long)400, e.eval("o.longMethod(200);"));
+        assertEquals((long) 0, e.eval("o.longMethod('0');"));
+        assertEquals((long) 400, e.eval("o.longMethod('200');"));
+    }
+
+    @Test
+    public void accessMethodByte() throws ScriptException {
+        assertEquals((byte) 0, e.eval("o.byteMethod(0);"));
+        assertEquals((byte) 10, e.eval("o.byteMethod(5);"));
+        assertEquals((byte) 0, e.eval("o.byteMethod('0');"));
+        assertEquals((byte) 10, e.eval("o.byteMethod('5');"));
+    }
+
+    @Test
+    public void accessMethodShort() throws ScriptException {
+        assertEquals((short)0, e.eval("o.shortMethod(0);"));
+        assertEquals((short)8000, e.eval("o.shortMethod(4000);"));
+        assertEquals((short) 0, e.eval("o.shortMethod('0');"));
+        assertEquals((short) 8000, e.eval("o.shortMethod('4000');"));
+    }
+
+    @Test
+    public void accessMethodChar() throws ScriptException {
+        assertEquals('A', e.eval("o.charMethod('a');"));
+        assertEquals('Z', e.eval("o.charMethod('z');"));
+        assertEquals(o.charMethod((char)0), e.eval("o.charMethod(0);"));
+        assertEquals(o.charMethod((char)3150), e.eval("o.charMethod(3150);"));
+    }
+
+    @Test
+    public void accessMethodFloat() throws ScriptException {
+        assertEquals(0.0f, e.eval("o.floatMethod(0.0);"));
+        assertEquals(4.2f, e.eval("o.floatMethod(2.1);"));
+        assertEquals(0.0f, e.eval("o.floatMethod('0.0');"));
+        assertEquals(4.2f, e.eval("o.floatMethod('2.1');"));
+    }
+
+    @Test
+    public void accessMethodDouble() throws ScriptException {
+        assertEquals(0.0, e.eval("o.doubleMethod(0.0);"));
+        assertEquals(14.0, e.eval("o.doubleMethod(7.0);"));
+        assertEquals(0.0, e.eval("o.doubleMethod('0.0');"));
+        assertEquals(14.0, e.eval("o.doubleMethod('7.0');"));
+    }
+
+    @Test
+    public void accessMethodBooleanBoxing() throws ScriptException {
+        assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.FALSE);"));
+        assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.TRUE);"));
+        assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod('');"));
+        assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod('false');"));
+    }
+
+    @Test
+    public void accessMethodIntBoxing() throws ScriptException {
+        assertEquals(0, e.eval("o.intBoxingMethod(0);"));
+        assertEquals(-200, e.eval("o.intBoxingMethod(-100);"));
+        assertTrue((int)e.eval("(new java.lang.Integer(2)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodLongBoxing() throws ScriptException {
+        assertEquals((long) 0, e.eval("o.longBoxingMethod(0);"));
+        assertEquals((long) 400, e.eval("o.longBoxingMethod(200);"));
+        assertTrue((int)e.eval("(new java.lang.Long(2)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodByteBoxing() throws ScriptException {
+        assertEquals((byte) 0, e.eval("o.byteBoxingMethod(0);"));
+        assertEquals((byte) 10, e.eval("o.byteBoxingMethod(5);"));
+        assertTrue((int)e.eval("(new java.lang.Byte(2)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodShortBoxing() throws ScriptException {
+        assertEquals((short) 0, e.eval("o.shortBoxingMethod(0);"));
+        assertEquals((short) 8000, e.eval("o.shortBoxingMethod(4000);"));
+        assertTrue((int)e.eval("(new java.lang.Short(2)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodCharBoxing() throws ScriptException {
+        assertEquals('A', e.eval("o.charBoxingMethod('a');"));
+        assertEquals('Z', e.eval("o.charBoxingMethod('z');"));
+        assertTrue((int)e.eval("(new java.lang.Character(2)).compareTo(10)") < 0);
+    }
+
+    @Test
+    public void accessMethodFloatBoxing() throws ScriptException {
+        assertEquals(0.0f, e.eval("o.floatBoxingMethod(0.0);"));
+        assertEquals(4.2f, e.eval("o.floatBoxingMethod(2.1);"));
+        assertTrue((int)e.eval("(new java.lang.Float(2.0)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodDoubleBoxing() throws ScriptException {
+        assertEquals(0.0, e.eval("o.doubleBoxingMethod(0.0);"));
+        assertEquals(14.0, e.eval("o.doubleBoxingMethod(7.0);"));
+        assertTrue((int)e.eval("(new java.lang.Double(2)).compareTo(10.0)") < 0);
+    }
+
+    @Test
+    public void accessMethodString() throws ScriptException {
+        assertEquals("", e.eval("o.stringMethod('');"));
+        assertEquals("abcabc", e.eval("o.stringMethod('abc');"));
+    }
+
+    @Test
+    public void accessMethodObject() throws ScriptException {
+        e.put("so", new Person(5));
+        e.eval("var rso = o.objectMethod(so);");
+        assertEquals(new Person(10), e.get("rso"));
+    }
+
+    @Test
+    public void accessMethodBooleanArray() throws ScriptException {
+        assertTrue(Arrays.equals(o.booleanArrayMethod(o.publicBooleanArray), (boolean[])e.eval("o.booleanArrayMethod(o.publicBooleanArray);")));
+    }
+
+    @Test
+    public void accessMethodIntArray() throws ScriptException {
+        assertArrayEquals(o.intArrayMethod(o.publicIntArray), (int[])e.eval("o.intArrayMethod(o.publicIntArray);"));
+    }
+
+    @Test
+    public void accessMethodLongArray() throws ScriptException {
+        assertArrayEquals(o.longArrayMethod(o.publicLongArray), (long[])e.eval("o.longArrayMethod(o.publicLongArray);"));
+    }
+
+    @Test
+    public void accessMethodByteArray() throws ScriptException {
+        assertArrayEquals(o.byteArrayMethod(o.publicByteArray), (byte[])e.eval("o.byteArrayMethod(o.publicByteArray);"));
+    }
+
+    @Test
+    public void accessMethodShortArray() throws ScriptException {
+        assertArrayEquals(o.shortArrayMethod(o.publicShortArray), (short[])e.eval("o.shortArrayMethod(o.publicShortArray);"));
+    }
+
+    @Test
+    public void accessMethodCharArray() throws ScriptException {
+        assertArrayEquals(o.charArrayMethod(o.publicCharArray), (char[])e.eval("o.charArrayMethod(o.publicCharArray);"));
+    }
+
+    @Test
+    public void accessMethodFloatArray() throws ScriptException {
+        assertArrayEquals(o.floatArrayMethod(o.publicFloatArray), (float[])e.eval("o.floatArrayMethod(o.publicFloatArray);"), 1e-10f);
+    }
+
+    @Test
+    public void accessMethodDoubleArray() throws ScriptException {
+        assertArrayEquals(o.doubleArrayMethod(o.publicDoubleArray), (double[])e.eval("o.doubleArrayMethod(o.publicDoubleArray);"), 1e-10);
+    }
+
+    @Test
+    public void accessMethodStringArray() throws ScriptException {
+        assertArrayEquals(o.stringArrayMethod(o.publicStringArray), (String[])e.eval("o.stringArrayMethod(o.publicStringArray);"));
+    }
+
+    @Test
+    public void accessMethodObjectArray() throws ScriptException {
+        assertArrayEquals(o.objectArrayMethod(o.publicObjectArray), (Person[])e.eval("o.objectArrayMethod(o.publicObjectArray);"));
+    }
+
+    @Test
+    public void accessDefaultConstructor() throws ScriptException {
+        e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.test.Person()");
+        assertEquals(new Person(), e.get("dc"));
+    }
+
+    @Test
+    public void accessCustomConstructor() throws ScriptException {
+        e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.test.Person(17)");
+        assertEquals(new Person(17), e.get("cc"));
+    }
+
+    @Test
+    public void accessMethod2PrimitiveParams() throws ScriptException {
+        assertEquals(o.twoParamMethod(50, 40.0), e.eval("o.twoParamMethod(50,40);"));
+    }
+
+    @Test
+    public void accessMethod3PrimitiveParams() throws ScriptException {
+        assertEquals(o.threeParamMethod((short)10, 20L, 'b'), e.eval("o.threeParamMethod(10,20,'b');"));
+    }
+
+    @Test
+    public void accessMethod2ObjectParams() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(200), new Person(300) }, (Person[])e.eval("o.twoObjectParamMethod(new Person(300),new Person(200));"));
+    }
+
+    @Test
+    public void accessMethod3ObjectParams() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.threeObjectParamMethod(new Person(1),new Person(2),new Person(3));"));
+    }
+
+    @Test
+    public void accessMethod8ObjectParams() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.eightObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6),new Person(7),new Person(8));"));
+    }
+
+    @Test
+    public void accessMethod9ObjectParams() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.nineObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
+    }
+
+    @Test
+    public void accessMethodObjectEllipsis() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
+        assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodObjectEllipsis()"));
+        assertArrayEquals(new Person[] { new Person(9) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(9))"));
+    }
+
+    @Test
+    public void accessMethodPrimitiveEllipsis() throws ScriptException {
+        assertArrayEquals(new Person[] { new Person(1), new Person(3), new Person(2) }, (Person[])e.eval("o.methodPrimitiveEllipsis(1,3,2);"));
+        assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodPrimitiveEllipsis();"));
+        assertArrayEquals(o.methodPrimitiveEllipsis(9, 8, 7, 6, 5, 4, 3, 2, 1), (Person[])e.eval("o.methodPrimitiveEllipsis(9,8,7,6,5,4,3,2,1);"));
+    }
+
+    @Test
+    public void accessMethodMixedEllipsis() throws ScriptException {
+        assertArrayEquals(new Object[] { new Person(1), 12, "hello", true }, (Object[])e.eval("o.methodMixedEllipsis(new Person(1),12,'hello',true);"));
+        assertArrayEquals(new Object[] {}, (Object[])e.eval("o.methodMixedEllipsis();"));
+    }
+
+    @Test
+    public void accessMethodObjectWithEllipsis() throws ScriptException {
+        assertArrayEquals(new Object[] { "hello", 12, 15, 16 }, (Object[])e.eval("o.methodObjectWithEllipsis('hello',12,15,16);"));
+        assertArrayEquals(new Object[] { "hello" }, (Object[])e.eval("o.methodObjectWithEllipsis('hello');"));
+    }
+
+    @Test
+    public void accessMethodPrimitiveWithEllipsis() throws ScriptException {
+        assertArrayEquals(new Object[] { 14, 12L, 15L, 16L }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(14,12,15,16);"));
+        assertArrayEquals(new Object[] { 12 }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(12);"));
+    }
+
+    @Test
+    public void accessMethodMixedWithEllipsis() throws ScriptException {
+        assertArrayEquals(new Object[] { "Hello", 10, true, -100500, 80d }, (Object[])e.eval("o.methodMixedWithEllipsis('Hello', 10, true, -100500,80.0);"));
+        assertArrayEquals(new Object[] { "Nashorn", 15 }, (Object[])e.eval("o.methodMixedWithEllipsis('Nashorn',15);"));
+    }
+
+    @Test
+    public void accessMethodOverloaded() throws ScriptException {
+        assertEquals(0, e.eval("o.overloadedMethod(0);"));
+        assertEquals(2000, e.eval("o.overloadedMethod(1000);"));
+        assertEquals(2, e.eval("o.overloadedMethod('10');"));
+        assertEquals(7, e.eval("o.overloadedMethod('Nashorn');"));
+        assertEquals(4, e.eval("o.overloadedMethod('true');"));
+        assertEquals(1, e.eval("o.overloadedMethod(true);"));
+        assertEquals(0, e.eval("o.overloadedMethod(false);"));
+        assertEquals(44, e.eval("o.overloadedMethod(new Person(22));"));
+        assertEquals(0, e.eval("o.overloadedMethod(new Person());"));
+    }
+
+    @Test
+    public void accessMethodDoubleVSintOverloaded() throws ScriptException {
+        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.0);"));
+        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(1000.0);"));
+        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.01);"));
+        assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(100.02);"));
+        assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(0);"));
+        assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(1000);"));
+    }
+
+    @Test
+    public void accessJavaMethodIntFromJSFromJavaFromJS() throws ScriptException {
+        e.eval("function secondLevelMethodInt(a) {"
+                + "return o.thirdLevelMethodInt(a);"
+                + "}");
+        assertEquals(50, e.eval("o.firstLevelMethodInt(10);"));
+    }
+
+    @Test
+    public void accessJavaMethodIntegerFromJSFromJavaFromJS() throws ScriptException {
+        e.eval("function secondLevelMethodInteger(a) {"
+                + "return o.thirdLevelMethodInteger(a);"
+                + "}");
+        assertEquals(100, e.eval("o.firstLevelMethodInteger(10);"));
+    }
+
+    @Test
+    public void accessJavaMethodObjectFromJSFromJavaFromJS() throws ScriptException {
+        e.eval("function secondLevelMethodObject(p) {"
+                + "return o.thirdLevelMethodObject(p);"
+                + "}");
+        assertEquals(new Person(100), e.eval("o.firstLevelMethodObject(new Person(10));"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,789 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class NumberAccessTest {
+
+    private static ScriptEngine e;
+    private static SharedObject o;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    // --------------------------------long
+    // tests------------------------------------
+    @Test
+    public void accessFieldLong() throws ScriptException {
+        e.eval("var p_long = o.publicLong;");
+        assertEquals(o.publicLong, e.get("p_long"));
+        e.eval("o.publicLong = 12;");
+        assertEquals(12, o.publicLong);
+    }
+
+    @Test
+    public void accessFieldLongArray() throws ScriptException {
+        e.eval("var p_long_array = o.publicLongArray;");
+        assertEquals(o.publicLongArray[0], e.eval("o.publicLongArray[0];"));
+        assertArrayEquals(o.publicLongArray, (long[])e.get("p_long_array"));
+        e.eval("var t_long_arr = new (Java.type(\"long[]\"))(3);" +
+                "t_long_arr[0] = -189009;" +
+                "t_long_arr[1] = 456;" +
+                "t_long_arr[2] = 600000001;" +
+                "o.publicLongArray = t_long_arr;");
+        // e.eval("o.publicIntArray = [-189009,456,600000001];");
+        assertArrayEquals(new long[] { -189009, 456, 600000001 }, o.publicLongArray);
+        e.eval("o.publicLongArray[0] = 10;");
+        assertEquals(10, o.publicLongArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldLong() throws ScriptException {
+        e.eval("var ps_long = SharedObject.publicStaticLong;");
+        assertEquals(SharedObject.publicStaticLong, e.get("ps_long"));
+        e.eval("SharedObject.publicStaticLong = 120;");
+        assertEquals(120, SharedObject.publicStaticLong);
+    }
+
+    @Test
+    public void accessStaticFieldLongArray() throws ScriptException {
+        e.eval("var ps_long_array = SharedObject.publicStaticLongArray;");
+        assertEquals(SharedObject.publicStaticLongArray[0], e.eval("SharedObject.publicStaticLongArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticLongArray, (long[])e.get("ps_long_array"));
+        e.eval("var ts_long_arr = new (Java.type(\"long[]\"))(3);" +
+                "ts_long_arr[0] = -189009;" +
+                "ts_long_arr[1] = 456;" +
+                "ts_long_arr[2] = 600000001;" +
+                "SharedObject.publicStaticLongArray = ts_long_arr;");
+        // e.eval("o.publicIntArray = [-189009,456,600000001];");
+        assertArrayEquals(new long[] { -189009, 456, 600000001 }, SharedObject.publicStaticLongArray);
+        e.eval("SharedObject.publicStaticLongArray[0] = 10;");
+        assertEquals(10, SharedObject.publicStaticLongArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldLong() throws ScriptException {
+        e.eval("var pf_long = o.publicFinalLong;");
+        assertEquals(o.publicFinalLong, e.get("pf_long"));
+        e.eval("o.publicFinalLong = 120;");
+        assertEquals(13353333333333333L, o.publicFinalLong);
+    }
+
+    @Test
+    public void accessFinalFieldLongArray() throws ScriptException {
+        e.eval("var pf_long_array = o.publicFinalLongArray;");
+        assertEquals(o.publicFinalLongArray[0], e.eval("o.publicFinalLongArray[0];"));
+        assertArrayEquals(o.publicFinalLongArray, (long[])e.get("pf_long_array"));
+        e.eval("var tf_long_arr = new (Java.type(\"long[]\"))(3);" +
+                "tf_long_arr[0] = -189009;" +
+                "tf_long_arr[1] = 456;" +
+                "tf_long_arr[2] = 600000001;" +
+                "o.publicFinalLongArray = tf_long_arr;");
+        // e.eval("o.publicIntArray = [-189009,456,600000001];");
+        assertArrayEquals(new long[] { 1901733333333L, -2247355555L, 3977377777L }, o.publicFinalLongArray);
+        e.eval("o.publicFinalLongArray[0] = 10;");
+        assertEquals(10, o.publicFinalLongArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldLong() throws ScriptException {
+        e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
+        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
+        e.eval("SharedObject.publicStaticFinalLong = 120;");
+        assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
+    }
+
+    @Test
+    public void accessStaticFinalFieldLongArray() throws ScriptException {
+        e.eval("var psf_long_array = SharedObject.publicStaticFinalLongArray;");
+        assertEquals(SharedObject.publicStaticFinalLongArray[0], e.eval("SharedObject.publicStaticFinalLongArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalLongArray, (long[])e.get("psf_long_array"));
+        e.eval("var tsf_long_arr = new (Java.type(\"long[]\"))(3);" +
+                "tsf_long_arr[0] = -189009;" +
+                "tsf_long_arr[1] = 456;" +
+                "tsf_long_arr[2] = 600000001;" +
+                "SharedObject.publicStaticFinalLongArray = tsf_long_arr;");
+        // e.eval("o.publicIntArray = [-189009,456,600000001];");
+        assertArrayEquals(new long[] { 19017383333L, -2247358L, 39773787L }, SharedObject.publicStaticFinalLongArray);
+        e.eval("SharedObject.publicStaticFinalLongArray[0] = 10;");
+        assertEquals(10, SharedObject.publicStaticFinalLongArray[0]);
+    }
+
+    // --------------------------------int
+    // tests------------------------------------
+    @Test
+    public void accessFieldInt() throws ScriptException {
+        e.eval("var p_int = o.publicInt;");
+        assertEquals(o.publicInt, e.get("p_int"));
+        e.eval("o.publicInt = 14;");
+        assertEquals(14, o.publicInt);
+    }
+
+    @Test
+    public void accessFieldIntArray() throws ScriptException {
+        e.eval("var p_int_array = o.publicIntArray;");
+        assertEquals(o.publicIntArray[0], e.eval("o.publicIntArray[0];"));
+        assertArrayEquals(o.publicIntArray, (int[])e.get("p_int_array"));
+        e.eval("var t_int_arr = new (Java.type(\"int[]\"))(3);" +
+                "t_int_arr[0] = 4;" +
+                "t_int_arr[1] = 5;" +
+                "t_int_arr[2] = 6;" +
+                "o.publicIntArray = t_int_arr;");
+        assertArrayEquals(new int[] { 4, 5, 6 }, o.publicIntArray);
+        e.eval("o.publicIntArray[0] = 100;");
+        assertEquals(100, o.publicIntArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldInt() throws ScriptException {
+        e.eval("var ps_int = SharedObject.publicStaticInt;");
+        assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
+        e.eval("SharedObject.publicStaticInt = 140;");
+        assertEquals(140, SharedObject.publicStaticInt);
+    }
+
+    @Test
+    public void accessStaticFieldIntArray() throws ScriptException {
+        e.eval("var ps_int_array = SharedObject.publicStaticIntArray;");
+        assertEquals(SharedObject.publicStaticIntArray[0], e.eval("SharedObject.publicStaticIntArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticIntArray, (int[])e.get("ps_int_array"));
+        e.eval("var ts_int_arr = new (Java.type(\"int[]\"))(3);" +
+                "ts_int_arr[0] = 4;" +
+                "ts_int_arr[1] = 5;" +
+                "ts_int_arr[2] = 6;" +
+                "SharedObject.publicStaticIntArray = ts_int_arr;");
+        assertArrayEquals(new int[] { 4, 5, 6 }, SharedObject.publicStaticIntArray);
+        e.eval("SharedObject.publicStaticIntArray[0] = 100;");
+        assertEquals(100, SharedObject.publicStaticIntArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldInt() throws ScriptException {
+        e.eval("var pf_int = o.publicFinalInt;");
+        assertEquals(o.publicFinalInt, e.get("pf_int"));
+
+        e.eval("o.publicFinalInt = 10;");
+        assertEquals(20712023, o.publicFinalInt);
+    }
+
+    @Test
+    public void accessFinalFieldIntArray() throws ScriptException {
+        e.eval("var pf_int_array = o.publicFinalIntArray;");
+        assertEquals(o.publicFinalIntArray[0], e.eval("o.publicFinalIntArray[0];"));
+        assertArrayEquals(o.publicFinalIntArray, (int[])e.get("pf_int_array"));
+        e.eval("var tf_int_arr = new (Java.type(\"int[]\"))(3);" +
+                "tf_int_arr[0] = 4;" +
+                "tf_int_arr[1] = 5;" +
+                "tf_int_arr[2] = 6;" +
+                "o.publicFinalIntArray = tf_int_arr;");
+        assertArrayEquals(new int[] { 50, 80, 130, 210, 340 }, o.publicFinalIntArray);
+        e.eval("o.publicFinalIntArray[0] = 100;");
+        assertEquals(100, o.publicFinalIntArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldInt() throws ScriptException {
+        e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
+        assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
+        e.eval("SharedObject.publicStaticFinalInt = 140;");
+        assertEquals(207182023, SharedObject.publicStaticFinalInt);
+    }
+
+    @Test
+    public void accessStaticFinalFieldIntArray() throws ScriptException {
+        e.eval("var psf_int_array = SharedObject.publicStaticFinalIntArray;");
+        assertEquals(SharedObject.publicStaticFinalIntArray[0], e.eval("SharedObject.publicStaticFinalIntArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalIntArray, (int[])e.get("psf_int_array"));
+        e.eval("var tsf_int_arr = new (Java.type(\"int[]\"))(3);" +
+                "tsf_int_arr[0] = 4;" +
+                "tsf_int_arr[1] = 5;" +
+                "tsf_int_arr[2] = 6;" +
+                "SharedObject.publicStaticFinalIntArray = tsf_int_arr;");
+        assertArrayEquals(new int[] { 1308, 210, 340 }, SharedObject.publicStaticFinalIntArray);
+        e.eval("SharedObject.publicStaticFinalIntArray[0] = 100;");
+        assertEquals(100, SharedObject.publicStaticFinalIntArray[0]);
+    }
+
+    // --------------------------------byte
+    // tests------------------------------------
+    @Test
+    public void accessFieldByte() throws ScriptException {
+        e.eval("var p_byte = o.publicByte;");
+        assertEquals((double)o.publicByte, ((Number)e.get("p_byte")).doubleValue());
+        e.eval("o.publicByte = 16;");
+        assertEquals(16, o.publicByte);
+    }
+
+    @Test
+    public void accessFieldByteArray() throws ScriptException {
+        e.eval("var p_byte_array = o.publicByteArray;");
+        assertEquals(o.publicByteArray[0], e.eval("o.publicByteArray[0];"));
+        assertArrayEquals(o.publicByteArray, (byte[])e.get("p_byte_array"));
+        e.eval("var t_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+                "t_byte_arr[0] = -18;" +
+                "t_byte_arr[1] = 56;" +
+                "t_byte_arr[2] = 60;" +
+                "o.publicByteArray = t_byte_arr;");
+        assertArrayEquals(new byte[] { -18, 56, 60 }, o.publicByteArray);
+        e.eval("o.publicByteArray[0] = 100;");
+        assertEquals(100, o.publicByteArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldByte() throws ScriptException {
+        e.eval("var ps_byte = SharedObject.publicStaticByte;");
+        assertEquals((double)SharedObject.publicStaticByte, ((Number)e.get("ps_byte")).doubleValue());
+        e.eval("SharedObject.publicStaticByte = 16;");
+        assertEquals(16, SharedObject.publicStaticByte);
+    }
+
+    @Test
+    public void accessStaticFieldByteArray() throws ScriptException {
+        e.eval("var ps_byte_array = SharedObject.publicStaticByteArray;");
+        assertEquals(SharedObject.publicStaticByteArray[0], e.eval("SharedObject.publicStaticByteArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticByteArray, (byte[])e.get("ps_byte_array"));
+        e.eval("var ts_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+                "ts_byte_arr[0] = -18;" +
+                "ts_byte_arr[1] = 56;" +
+                "ts_byte_arr[2] = 60;" +
+                "SharedObject.publicStaticByteArray = ts_byte_arr;");
+        assertArrayEquals(new byte[] { -18, 56, 60 }, SharedObject.publicStaticByteArray);
+        e.eval("SharedObject.publicStaticByteArray[0] = -90;");
+        assertEquals(-90, SharedObject.publicStaticByteArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldByte() throws ScriptException {
+        e.eval("var pf_byte = o.publicFinalByte;");
+        assertEquals((double)o.publicFinalByte, ((Number)e.get("pf_byte")).doubleValue());
+        e.eval("o.publicFinalByte = 16;");
+        assertEquals(-7, o.publicFinalByte);
+    }
+
+    @Test
+    public void accessFinalFieldByteArray() throws ScriptException {
+        e.eval("var pf_byte_array = o.publicFinalByteArray;");
+        assertEquals(o.publicFinalByteArray[0], e.eval("o.publicFinalByteArray[0];"));
+        assertArrayEquals(o.publicFinalByteArray, (byte[])e.get("pf_byte_array"));
+        e.eval("var tf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+                "tf_byte_arr[0] = -18;" +
+                "tf_byte_arr[1] = 56;" +
+                "tf_byte_arr[2] = 60;" +
+                "o.publicFinalByteArray = tf_byte_arr;");
+        assertArrayEquals(new byte[] { 1, 3, 6, 17, -128 }, o.publicFinalByteArray);
+        e.eval("o.publicFinalByteArray[0] = -90;");
+        assertEquals(-90, o.publicFinalByteArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldByte() throws ScriptException {
+        e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
+        assertEquals((double)SharedObject.publicStaticFinalByte, ((Number)e.get("psf_byte")).doubleValue());
+        e.eval("SharedObject.publicStaticFinalByte = 16;");
+        assertEquals(-70, SharedObject.publicStaticFinalByte);
+    }
+
+    @Test
+    public void accessStaticFinalFieldByteArray() throws ScriptException {
+        e.eval("var psf_byte_array = SharedObject.publicStaticFinalByteArray;");
+        assertEquals(SharedObject.publicStaticFinalByteArray[0], e.eval("SharedObject.publicStaticFinalByteArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalByteArray, (byte[])e.get("psf_byte_array"));
+        e.eval("var tsf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+                "tsf_byte_arr[0] = -18;" +
+                "tsf_byte_arr[1] = 56;" +
+                "tsf_byte_arr[2] = 60;" +
+                "SharedObject.publicStaticFinalByteArray = tsf_byte_arr;");
+        assertArrayEquals(new byte[] { 17, -128, 81 }, SharedObject.publicStaticFinalByteArray);
+        e.eval("SharedObject.publicStaticFinalByteArray[0] = -90;");
+        assertEquals(-90, SharedObject.publicStaticFinalByteArray[0]);
+    }
+
+    // --------------------------------short
+    // tests------------------------------------
+    @Test
+    public void accessFieldShort() throws ScriptException {
+        e.eval("var p_short = o.publicShort;");
+        assertEquals((double)o.publicShort, ((Number)e.get("p_short")).doubleValue());
+        e.eval("o.publicShort = 18;");
+        assertEquals(18, o.publicShort);
+    }
+
+    @Test
+    public void accessFieldShortArray() throws ScriptException {
+        e.eval("var p_short_array = o.publicShortArray;");
+        assertEquals(o.publicShortArray[0], e.eval("o.publicShortArray[0];"));
+        assertArrayEquals(o.publicShortArray, (short[])e.get("p_short_array"));
+        e.eval("var t_short_arr = new (Java.type(\"short[]\"))(3);" +
+                "t_short_arr[0] = 90;" +
+                "t_short_arr[1] = 5;" +
+                "t_short_arr[2] = -6000;" +
+                "o.publicShortArray = t_short_arr;");
+        assertArrayEquals(new short[] { 90, 5, -6000 }, o.publicShortArray);
+        e.eval("o.publicShortArray[0] = -1000;");
+        assertEquals(-1000, o.publicShortArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldShort() throws ScriptException {
+        e.eval("var ps_short = SharedObject.publicStaticShort;");
+        assertEquals((double)SharedObject.publicStaticShort, ((Number)e.get("ps_short")).doubleValue());
+        e.eval("SharedObject.publicStaticShort = 180;");
+        assertEquals(180, SharedObject.publicStaticShort);
+    }
+
+    @Test
+    public void accessStaticFieldShortArray() throws ScriptException {
+        e.eval("var ps_short_array = SharedObject.publicStaticShortArray;");
+        assertEquals(SharedObject.publicStaticShortArray[0], e.eval("SharedObject.publicStaticShortArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticShortArray, (short[])e.get("ps_short_array"));
+        e.eval("var ts_short_arr = new (Java.type(\"short[]\"))(3);" +
+                "ts_short_arr[0] = 90;" +
+                "ts_short_arr[1] = 5;" +
+                "ts_short_arr[2] = -6000;" +
+                "SharedObject.publicStaticShortArray = ts_short_arr;");
+        assertArrayEquals(new short[] { 90, 5, -6000 }, SharedObject.publicStaticShortArray);
+        e.eval("SharedObject.publicStaticShortArray[0] = -1000;");
+        assertEquals(-1000, SharedObject.publicStaticShortArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldShort() throws ScriptException {
+        e.eval("var pf_short = o.publicFinalShort;");
+        assertEquals((double)o.publicFinalShort, ((Number)e.get("pf_short")).doubleValue());
+        e.eval("o.publicFinalShort = 180;");
+        assertEquals(31220, o.publicFinalShort);
+    }
+
+    @Test
+    public void accessFinalFieldShortArray() throws ScriptException {
+        e.eval("var pf_short_array = o.publicFinalShortArray;");
+        assertEquals(o.publicFinalShortArray[0], e.eval("o.publicFinalShortArray[0];"));
+        assertArrayEquals(o.publicFinalShortArray, (short[])e.get("pf_short_array"));
+        e.eval("var tf_short_arr = new (Java.type(\"short[]\"))(3);" +
+                "tf_short_arr[0] = 90;" +
+                "tf_short_arr[1] = 5;" +
+                "tf_short_arr[2] = -6000;" +
+                "o.publicFinalShortArray = tf_short_arr;");
+        assertArrayEquals(new short[] { 12240, 9200, -17289, 1200, 12 }, o.publicFinalShortArray);
+        e.eval("o.publicFinalShortArray[0] = -1000;");
+        assertEquals(-1000, o.publicFinalShortArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldShort() throws ScriptException {
+        e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
+        assertEquals((double)SharedObject.publicStaticFinalShort, ((Number)e.get("psf_short")).doubleValue());
+        e.eval("SharedObject.publicStaticFinalShort = 180;");
+        assertEquals(8888, SharedObject.publicStaticFinalShort);
+    }
+
+    @Test
+    public void accessStaticFinalFieldShortArray() throws ScriptException {
+        e.eval("var psf_short_array = SharedObject.publicStaticFinalShortArray;");
+        assertEquals(SharedObject.publicStaticFinalShortArray[0], e.eval("SharedObject.publicStaticFinalShortArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalShortArray, (short[])e.get("psf_short_array"));
+        e.eval("var tsf_short_arr = new (Java.type(\"short[]\"))(3);" +
+                "tsf_short_arr[0] = 90;" +
+                "tsf_short_arr[1] = 5;" +
+                "tsf_short_arr[2] = -6000;" +
+                "SharedObject.publicStaticFinalShortArray = tsf_short_arr;");
+        assertArrayEquals(new short[] { 8240, 9280, -1289, 120, 812 }, SharedObject.publicStaticFinalShortArray);
+        e.eval("SharedObject.publicStaticFinalShortArray[0] = -1000;");
+        assertEquals(-1000, SharedObject.publicStaticFinalShortArray[0]);
+    }
+
+    // --------------------------------char
+    // tests------------------------------------
+    @Test
+    public void accessFieldChar() throws ScriptException {
+        e.eval("var p_char = o.publicChar;");
+        assertEquals(o.publicChar, e.get("p_char"));
+        e.eval("o.publicChar = 'S';");
+        assertEquals('S', o.publicChar);
+        e.eval("o.publicChar = 10;");
+        assertEquals(10, o.publicChar);
+        e.eval("try {"
+                + "    o.publicChar = 'Big string';" +
+                "} catch(e) {" +
+                "    var isThrown = true;" +
+                "}");
+        assertEquals("Exception thrown", true, e.get("isThrown"));
+        assertEquals(10, o.publicChar);
+    }
+
+    @Test
+    public void accessFieldCharArray() throws ScriptException {
+        e.eval("var p_char_array = o.publicCharArray;");
+        assertEquals(o.publicCharArray[0], e.eval("o.publicCharArray[0];"));
+        assertArrayEquals(o.publicCharArray, (char[])e.get("p_char_array"));
+        e.eval("var t_char_arr = new (Java.type(\"char[]\"))(3);" +
+                "t_char_arr[0] = 'F';" +
+                "t_char_arr[1] = 'o';" +
+                "t_char_arr[2] = 'o';" +
+                "o.publicCharArray = t_char_arr;");
+        assertArrayEquals("Foo".toCharArray(), o.publicCharArray);
+        e.eval("o.publicCharArray[0] = 'Z';");
+        assertEquals('Z', o.publicCharArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldChar() throws ScriptException {
+        e.eval("var ps_char = SharedObject.publicStaticChar;");
+        assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
+        e.eval("SharedObject.publicStaticChar = 'Z';");
+        assertEquals('Z', SharedObject.publicStaticChar);
+    }
+
+    @Test
+    public void accessStaticFieldCharArray() throws ScriptException {
+        e.eval("var ps_char_array = SharedObject.publicStaticCharArray;");
+        assertEquals(SharedObject.publicStaticCharArray[0], e.eval("SharedObject.publicStaticCharArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticCharArray, (char[])e.get("ps_char_array"));
+        e.eval("var ts_char_arr = new (Java.type(\"char[]\"))(3);" +
+                "ts_char_arr[0] = 'G';" +
+                "ts_char_arr[1] = 'o';" +
+                "ts_char_arr[2] = 'o';" +
+                "SharedObject.publicStaticCharArray = ts_char_arr;");
+        assertArrayEquals("Goo".toCharArray(), SharedObject.publicStaticCharArray);
+        e.eval("SharedObject.publicStaticCharArray[0] = 'Z';");
+        assertEquals('Z', SharedObject.publicStaticCharArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldChar() throws ScriptException {
+        e.eval("var pf_char = o.publicFinalChar;");
+        assertEquals(o.publicFinalChar, e.get("pf_char"));
+        e.eval("o.publicFinalChar = 'S';");
+        assertEquals('E', o.publicFinalChar);
+    }
+
+    @Test
+    public void accessFinalCharArray() throws ScriptException {
+        e.eval("var pf_char_array = o.publicFinalCharArray;");
+        assertEquals(o.publicFinalCharArray[0], e.eval("o.publicFinalCharArray[0];"));
+        assertArrayEquals(o.publicFinalCharArray, (char[])e.get("pf_char_array"));
+        e.eval("var tf_char_arr = new (Java.type(\"char[]\"))(3);" +
+                "tf_char_arr[0] = 'F';" +
+                "tf_char_arr[1] = 'o';" +
+                "tf_char_arr[2] = 'o';" +
+                "o.publicFinalCharArray = tf_char_arr;");
+        assertArrayEquals("Nashorn hello".toCharArray(), o.publicFinalCharArray);
+        e.eval("o.publicFinalCharArray[0] = 'Z';");
+        assertEquals('Z', o.publicFinalCharArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldChar() throws ScriptException {
+        e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
+        assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
+        e.eval("SharedObject.publicStaticFinalChar = 'Z';");
+        assertEquals('K', SharedObject.publicStaticFinalChar);
+    }
+
+    @Test
+    public void accessStaticFinalFieldCharArray() throws ScriptException {
+        e.eval("var psf_char_array = SharedObject.publicStaticFinalCharArray;");
+        assertEquals(SharedObject.publicStaticFinalCharArray[0], e.eval("SharedObject.publicStaticFinalCharArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalCharArray, (char[])e.get("psf_char_array"));
+        e.eval("var tsf_char_arr = new (Java.type(\"char[]\"))(3);" +
+                "tsf_char_arr[0] = 'Z';" +
+                "tsf_char_arr[1] = 'o';" +
+                "tsf_char_arr[2] = 'o';" +
+                "SharedObject.publicStaticFinalCharArray = tsf_char_arr;");
+        assertArrayEquals("StaticString".toCharArray(), SharedObject.publicStaticFinalCharArray);
+        e.eval("SharedObject.publicStaticFinalCharArray[0] = 'Z';");
+        assertEquals('Z', SharedObject.publicStaticFinalCharArray[0]);
+    }
+
+    // --------------------------------float
+    // tests------------------------------------
+    @Test
+    public void accessFieldFloat() throws ScriptException {
+        e.eval("var p_float = o.publicFloat;");
+        assertEquals((double)o.publicFloat, ((Number)e.get("p_float")).doubleValue());
+        o.publicFloat = 0.0f / 0.0f;
+        assertEquals(true, e.eval("isNaN(o.publicFloat)"));
+        o.publicFloat = 1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloat"));
+        o.publicFloat = -1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloat"));
+        e.eval("o.publicFloat = 20;");
+        assertEquals(20, o.publicFloat, 1e-10);
+        e.eval("o.publicFloat = 0.0/0.0;");
+        assertTrue(Float.isNaN(o.publicFloat));
+        e.eval("o.publicFloat = 1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloat));
+        e.eval("o.publicFloat = -1.0/0.0;");
+        assertEquals(Float.NEGATIVE_INFINITY, o.publicFloat, 1e-10);
+    }
+
+    @Test
+    public void accessFieldFloatArray() throws ScriptException {
+        e.eval("var p_float_array = o.publicFloatArray;");
+        assertEquals(o.publicFloatArray[0], e.eval("o.publicFloatArray[0];"));
+        assertArrayEquals(o.publicFloatArray, (float[])e.get("p_float_array"), 1e-10f);
+        e.eval("var t_float_arr = new (Java.type(\"float[]\"))(3);" +
+                "t_float_arr[0] = 9.0;" +
+                "t_float_arr[1] = 5.12345;" +
+                "t_float_arr[2] = -60.03;" +
+                "o.publicFloatArray = t_float_arr;");
+        assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
+        e.eval("o.publicFloatArray[0] = -513.2;");
+        assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
+    }
+
+    @Test
+    public void accessStaticFieldFloat() throws ScriptException {
+        e.eval("var ps_float = SharedObject.publicStaticFloat;");
+        assertEquals((double)SharedObject.publicStaticFloat, ((Number)e.get("ps_float")).doubleValue());
+        SharedObject.publicStaticFloat = 0.0f / 0.0f;
+        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
+        SharedObject.publicStaticFloat = 1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
+        SharedObject.publicStaticFloat = -1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
+        e.eval("SharedObject.publicStaticFloat = 20.0;");
+        assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
+        e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
+        assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
+        e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+        e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+    }
+
+    @Test
+    public void accessStaticFieldFloatArray() throws ScriptException {
+        e.eval("var ps_float_array = SharedObject.publicStaticFloatArray;");
+        assertEquals(SharedObject.publicStaticFloatArray[0], e.eval("SharedObject.publicStaticFloatArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFloatArray, (float[])e.get("ps_float_array"), 1e-10f);
+        e.eval("var ts_float_arr = new (Java.type(\"float[]\"))(3);" +
+                "ts_float_arr[0] = 9.0;" +
+                "ts_float_arr[1] = 5.12345;" +
+                "ts_float_arr[2] = -60.03;" +
+                "SharedObject.publicStaticFloatArray = ts_float_arr;");
+        assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
+        e.eval("SharedObject.publicStaticFloatArray[0] = -513.2;");
+        assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
+    }
+
+    @Test
+    public void accessFinalFloat() throws ScriptException {
+        e.eval("var pf_float = o.publicFinalFloat;");
+        assertEquals((double)o.publicFinalFloat, ((Number)e.get("pf_float")).doubleValue());
+        e.eval("o.publicFinalFloat = 20.0;");
+        assertEquals(7.72e8f, o.publicFinalFloat, 1e-10);
+    }
+
+    @Test
+    public void accessFinalFloatArray() throws ScriptException {
+        e.eval("var pf_float_array = o.publicFinalFloatArray;");
+        assertEquals(o.publicFinalFloatArray[0], e.eval("o.publicFinalFloatArray[0];"));
+        assertArrayEquals(o.publicFinalFloatArray, (float[])e.get("pf_float_array"), 1e-10f);
+        e.eval("var tf_float_arr = new (Java.type(\"float[]\"))(3);" +
+                "tf_float_arr[0] = 9.0;" +
+                "tf_float_arr[1] = 5.12345;" +
+                "tf_float_arr[2] = -60.03;" +
+                "o.publicFinalFloatArray = tf_float_arr;");
+        assertArrayEquals(new float[] { -131.012f, 189.32f, -31.32e8f, 3.72f }, o.publicFinalFloatArray, 1e-10f);
+        e.eval("o.publicFinalFloatArray[0] = -513.2;");
+        assertEquals(-513.2f, o.publicFinalFloatArray[0], 1e-10f);
+    }
+
+    @Test
+    public void accessStaticFinalFieldFloat() throws ScriptException {
+        e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
+        assertEquals((double)SharedObject.publicStaticFinalFloat, ((Number)e.get("psf_float")).doubleValue());
+        e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
+        assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
+    }
+
+    @Test
+    public void accessStaticFinalFieldFloatArray() throws ScriptException {
+        e.eval("var psf_float_array = SharedObject.publicStaticFinalFloatArray;");
+        assertEquals(SharedObject.publicStaticFinalFloatArray[0], e.eval("SharedObject.publicStaticFinalFloatArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalFloatArray, (float[])e.get("psf_float_array"), 1e-10f);
+        e.eval("var tsf_float_arr = new (Java.type(\"float[]\"))(3);" +
+                "tsf_float_arr[0] = 9.0;" +
+                "tsf_float_arr[1] = 5.12345;" +
+                "tsf_float_arr[2] = -60.03;" +
+                "SharedObject.publicStaticFinalFloatArray = tsf_float_arr;");
+        assertArrayEquals(new float[] { -8131.012f, 9.32f, -138.32e8f, 0.72f }, SharedObject.publicStaticFinalFloatArray, 1e-10f);
+        e.eval("SharedObject.publicStaticFinalFloatArray[0] = -513.2;");
+        assertEquals(-513.2f, SharedObject.publicStaticFinalFloatArray[0], 1e-10f);
+    }
+
+    // --------------------------------double
+    // tests------------------------------------
+    @Test
+    public void accessFieldDouble() throws ScriptException {
+        e.eval("var p_double = o.publicDouble;");
+        assertEquals(o.publicDouble, e.get("p_double"));
+        o.publicDouble = 0.0 / 0.0;
+        assertEquals(true, e.eval("isNaN(o.publicDouble)"));
+        o.publicDouble = 1.0 / 0.0;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDouble"));
+        o.publicDouble = -1.0 / 0.0;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDouble"));
+        e.eval("o.publicDouble = 30;");
+        assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDouble));
+        e.eval("o.publicDouble = 0.0/0.0;");
+        assertTrue(Double.isNaN(o.publicDouble));
+        e.eval("o.publicDouble = 1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
+        e.eval("o.publicDouble = -1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
+    }
+
+    @Test
+    public void accessFieldDoubleArrayRead() throws ScriptException {
+        e.eval("var p_double_array = o.publicDoubleArray;");
+        assertEquals(o.publicDoubleArray[0], e.eval("o.publicDoubleArray[0];"));
+        assertArrayEquals(o.publicDoubleArray, (double[])e.get("p_double_array"), 1e-10);
+        e.eval("var t_double_arr = new (Java.type(\"double[]\"))(3);" +
+                "t_double_arr[0] = 9e10;" +
+                "t_double_arr[1] = 0.677777;" +
+                "t_double_arr[2] = -0.0000001;" +
+                "o.publicDoubleArray = t_double_arr;");
+        assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, o.publicDoubleArray, 1e-10f);
+        e.eval("o.publicDoubleArray[0] = -5.2e10;");
+        assertEquals(-5.2e10, o.publicDoubleArray[0], 1e-10f);
+    }
+
+    @Test
+    public void accessStaticFieldDouble() throws ScriptException {
+        e.eval("var ps_double = SharedObject.publicStaticDouble;");
+        assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
+        SharedObject.publicStaticDouble = 0.0 / 0.0;
+        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
+        SharedObject.publicStaticDouble = 1.0 / 0.0;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
+        SharedObject.publicStaticDouble = -1.0 / 0.0;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
+        e.eval("SharedObject.publicStaticDouble = 40.0;");
+        assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
+        assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+    }
+
+    @Test
+    public void accessStaticFieldDoubleArrayRead() throws ScriptException {
+        e.eval("var ps_double_array = SharedObject.publicStaticDoubleArray;");
+        assertEquals(SharedObject.publicStaticDoubleArray[0], e.eval("SharedObject.publicStaticDoubleArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticDoubleArray, (double[])e.get("ps_double_array"), 1e-10);
+        e.eval("var ts_double_arr = new (Java.type(\"double[]\"))(3);" +
+                "ts_double_arr[0] = 9e10;" +
+                "ts_double_arr[1] = 0.677777;" +
+                "ts_double_arr[2] = -0.0000001;" +
+                "SharedObject.publicStaticDoubleArray = ts_double_arr;");
+        assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, SharedObject.publicStaticDoubleArray, 1e-10f);
+        e.eval("SharedObject.publicStaticDoubleArray[0] = -5.2e10;");
+        assertEquals(-5.2e10, SharedObject.publicStaticDoubleArray[0], 1e-10f);
+    }
+
+    @Test
+    public void accessFinalFieldDouble() throws ScriptException {
+        e.eval("var pf_double = o.publicFinalDouble;");
+        assertEquals(o.publicFinalDouble, e.get("pf_double"));
+        e.eval("o.publicFinalDouble = 30.0;");
+        assertEquals(Double.doubleToLongBits(1.3412e20), Double.doubleToLongBits(o.publicFinalDouble));
+    }
+
+    @Test
+    public void accessFinalFieldDoubleArrayRead() throws ScriptException {
+        e.eval("var pf_double_array = o.publicFinalDoubleArray;");
+        assertEquals(o.publicFinalDoubleArray[0], e.eval("o.publicFinalDoubleArray[0];"));
+        assertArrayEquals(o.publicFinalDoubleArray, (double[])e.get("pf_double_array"), 1e-10);
+        e.eval("var tf_double_arr = new (Java.type(\"double[]\"))(3);" +
+                "tf_double_arr[0] = 9e10;" +
+                "tf_double_arr[1] = 0.677777;" +
+                "tf_double_arr[2] = -0.0000001;" +
+                "o.publicFinalDoubleArray = tf_double_arr;");
+        assertArrayEquals(new double[] { 0.725e80, 0.12e10, 8e-3, 1.00077 }, o.publicFinalDoubleArray, 1e-10f);
+        e.eval("o.publicFinalDoubleArray[0] = -5.2e10;");
+        assertEquals(-5.2e10, o.publicFinalDoubleArray[0], 1e-10f);
+    }
+
+    @Test
+    public void accessStaticFinalFieldDouble() throws ScriptException {
+        e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
+        assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
+        e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
+        assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
+    }
+
+    @Test
+    public void accessStaticFinalFieldDoubleArrayRead() throws ScriptException {
+        e.eval("var psf_double_array = SharedObject.publicStaticFinalDoubleArray;");
+        assertEquals(SharedObject.publicStaticFinalDoubleArray[0], e.eval("SharedObject.publicStaticFinalDoubleArray[0];"));
+        assertArrayEquals(SharedObject.publicStaticFinalDoubleArray, (double[])e.get("psf_double_array"), 1e-10);
+        e.eval("var tsf_double_arr = new (Java.type(\"double[]\"))(3);" +
+                "tsf_double_arr[0] = 9e10;" +
+                "tsf_double_arr[1] = 0.677777;" +
+                "tsf_double_arr[2] = -0.0000001;" +
+                "SharedObject.publicStaticFinalDoubleArray = tsf_double_arr;");
+        assertArrayEquals(new double[] { 8.725e80, 0.82e10, 18e-3, 1.08077 }, SharedObject.publicStaticFinalDoubleArray, 1e-10f);
+        e.eval("SharedObject.publicStaticFinalDoubleArray[0] = -5.2e10;");
+        assertEquals(-5.2e10, SharedObject.publicStaticFinalDoubleArray[0], 1e-10f);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,365 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberBoxingTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberBoxingTest
+ */
+@SuppressWarnings("javadoc")
+public class NumberBoxingTest {
+
+    private static ScriptEngine e;
+    private static SharedObject o;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    // --------------------------------long
+    // tests------------------------------------
+    @Test
+    public void accessFieldLongBoxing() throws ScriptException {
+        e.eval("var p_long = o.publicLongBox;");
+        assertEquals(o.publicLongBox, e.get("p_long"));
+        e.eval("o.publicLongBox = 12;");
+        assertEquals(Long.valueOf(12), o.publicLongBox);
+    }
+
+    @Test
+    public void accessStaticFieldLongBoxing() throws ScriptException {
+        e.eval("var ps_long = SharedObject.publicStaticLongBox;");
+        assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long"));
+        e.eval("SharedObject.publicStaticLongBox = 120;");
+        assertEquals(120L, SharedObject.publicStaticLongBox.longValue());
+    }
+
+    @Test
+    public void accessFinalFieldLongBoxing() throws ScriptException {
+        e.eval("var pf_long = o.publicFinalLongBox;");
+        assertEquals(o.publicFinalLongBox, e.get("pf_long"));
+        e.eval("o.publicFinalLongBox = 120;");
+        assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldLongBoxing() throws ScriptException {
+        e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
+        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
+        e.eval("SharedObject.publicStaticFinalLong = 120;");
+        assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
+    }
+
+    // --------------------------------int
+    // tests------------------------------------
+    @Test
+    public void accessFieldIntBoxing() throws ScriptException {
+        e.eval("var p_int = o.publicIntBox;");
+        assertEquals(o.publicIntBox, e.get("p_int"));
+        e.eval("o.publicIntBox = 14;");
+        assertEquals(Integer.valueOf(14), o.publicIntBox);
+    }
+
+    @Test
+    public void accessStaticFieldIntBoxing() throws ScriptException {
+        e.eval("var ps_int = SharedObject.publicStaticInt;");
+        assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
+        e.eval("SharedObject.publicStaticInt = 140;");
+        assertEquals(140, SharedObject.publicStaticInt);
+    }
+
+    @Test
+    public void accessFinalFieldIntBoxing() throws ScriptException {
+        e.eval("var pf_int = o.publicFinalIntBox;");
+        assertEquals(o.publicFinalIntBox, e.get("pf_int"));
+        e.eval("o.publicFinalIntBox = 10;");
+        assertEquals(Integer.valueOf(207512301), o.publicFinalIntBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldIntBoxing() throws ScriptException {
+        e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
+        assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
+        e.eval("SharedObject.publicStaticFinalInt = 140;");
+        assertEquals(207182023, SharedObject.publicStaticFinalInt);
+    }
+
+    // --------------------------------byte
+    // tests------------------------------------
+    @Test
+    public void accessFieldByteBoxing() throws ScriptException {
+        e.eval("var p_byte = o.publicByteBox;");
+        assertEqualsDouble(o.publicByteBox, "p_byte");
+        e.eval("o.publicByteBox = 16;");
+        assertEquals(Byte.valueOf((byte)16), o.publicByteBox);
+    }
+
+    @Test
+    public void accessStaticFieldByteBoxing() throws ScriptException {
+        e.eval("var ps_byte = SharedObject.publicStaticByte;");
+        assertEqualsDouble(SharedObject.publicStaticByte, "ps_byte");
+        e.eval("SharedObject.publicStaticByte = 16;");
+        assertEquals(16, SharedObject.publicStaticByte);
+    }
+
+    @Test
+    public void accessFinalFieldByteBoxing() throws ScriptException {
+        e.eval("var pf_byte = o.publicFinalByteBox;");
+        assertEqualsDouble(o.publicFinalByteBox, "pf_byte");
+        e.eval("o.publicFinalByteBox = 16;");
+        assertEquals(Byte.valueOf((byte)19), o.publicFinalByteBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldByteBoxing() throws ScriptException {
+        e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
+        assertEqualsDouble(SharedObject.publicStaticFinalByte, "psf_byte");
+        e.eval("SharedObject.publicStaticFinalByte = 16;");
+        assertEquals(-70, SharedObject.publicStaticFinalByte);
+    }
+
+    // --------------------------------short
+    // tests------------------------------------
+    @Test
+    public void accessFieldShortBoxing() throws ScriptException {
+        e.eval("var p_short = o.publicShortBox;");
+        assertEqualsDouble(o.publicShortBox, "p_short");
+        e.eval("o.publicShortBox = 18;");
+        assertEquals(Short.valueOf((short)18), o.publicShortBox);
+    }
+
+    private static void assertEqualsDouble(final Number n, final String name) {
+        assertEquals(n.doubleValue(), ((Number)e.get(name)).doubleValue());
+    }
+
+    @Test
+    public void accessStaticFieldShortBoxing() throws ScriptException {
+        e.eval("var ps_short = SharedObject.publicStaticShort;");
+        assertEqualsDouble(SharedObject.publicStaticShort, "ps_short");
+        e.eval("SharedObject.publicStaticShort = 180;");
+        assertEquals(180, SharedObject.publicStaticShort);
+    }
+
+    @Test
+    public void accessFinalFieldShortBoxing() throws ScriptException {
+        e.eval("var pf_short = o.publicFinalShortBox;");
+        assertEqualsDouble(o.publicFinalShortBox, "pf_short");
+        e.eval("o.publicFinalShortBox = 180;");
+        assertEquals(Short.valueOf((short)-26777), o.publicFinalShortBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldShortBoxing() throws ScriptException {
+        e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
+        assertEqualsDouble(SharedObject.publicStaticFinalShort, "psf_short");
+        e.eval("SharedObject.publicStaticFinalShort = 180;");
+        assertEquals(8888, SharedObject.publicStaticFinalShort);
+    }
+
+    // --------------------------------char
+    // tests------------------------------------
+    @Test
+    public void accessFieldCharBoxing() throws ScriptException {
+        e.eval("var p_char = o.publicCharBox;");
+        assertEquals(o.publicCharBox, e.get("p_char"));
+        e.eval("o.publicCharBox = 'S';");
+        assertEquals(Character.valueOf('S'), o.publicCharBox);
+        e.eval("try {" +
+                "    o.publicCharBox = 'Big string';" +
+                "} catch(e) {" +
+                "    var isThrown = true;" +
+                "}");
+        assertEquals("Exception thrown", true, e.get("isThrown"));
+        assertEquals(Character.valueOf('S'), o.publicCharBox);
+    }
+
+    @Test
+    public void accessStaticFieldCharBoxing() throws ScriptException {
+        e.eval("var ps_char = SharedObject.publicStaticChar;");
+        assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
+        e.eval("SharedObject.publicStaticChar = 'Z';");
+        assertEquals('Z', SharedObject.publicStaticChar);
+    }
+
+    @Test
+    public void accessFinalFieldCharBoxing() throws ScriptException {
+        e.eval("var pf_char = o.publicFinalCharBox;");
+        assertEquals(o.publicFinalCharBox, e.get("pf_char"));
+        e.eval("o.publicFinalCharBox = 'S';");
+        assertEquals(Character.valueOf('F'), o.publicFinalCharBox);
+    }
+
+    @Test
+    public void accessStaticFinalFieldCharBoxing() throws ScriptException {
+        e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
+        assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
+        e.eval("SharedObject.publicStaticFinalChar = 'Z';");
+        assertEquals('K', SharedObject.publicStaticFinalChar);
+    }
+
+    // --------------------------------float
+    // tests------------------------------------
+    @Test
+    public void accessFieldFloatBoxing() throws ScriptException {
+        e.eval("var p_float = o.publicFloatBox;");
+        assertEqualsDouble(o.publicFloatBox, "p_float");
+        o.publicFloatBox = 0.0f / 0.0f;
+        assertEquals(true, e.eval("isNaN(o.publicFloatBox)"));
+        o.publicFloatBox = 1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloatBox"));
+        o.publicFloatBox = -1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloatBox"));
+        e.eval("o.publicFloatBox = 20;");
+        assertEquals(20, o.publicFloatBox, 1e-10);
+        e.eval("o.publicFloatBox = 0.0/0.0;");
+        assertTrue(Float.isNaN(o.publicFloatBox));
+        e.eval("o.publicFloatBox = 1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloatBox));
+        e.eval("o.publicFloatBox = -1.0/0.0;");
+        assertEquals(Float.NEGATIVE_INFINITY, o.publicFloatBox, 1e-10);
+    }
+
+    @Test
+    public void accessStaticFieldFloatBoxing() throws ScriptException {
+        e.eval("var ps_float = SharedObject.publicStaticFloat;");
+        assertEqualsDouble(SharedObject.publicStaticFloat, "ps_float");
+        SharedObject.publicStaticFloat = 0.0f / 0.0f;
+        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
+        SharedObject.publicStaticFloat = 1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
+        SharedObject.publicStaticFloat = -1.0f / 0.0f;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
+        e.eval("SharedObject.publicStaticFloat = 20.0;");
+        assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
+        e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
+        assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
+        e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+        e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
+        assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+    }
+
+    @Test
+    public void accessFinalFloatBoxing() throws ScriptException {
+        e.eval("var pf_float = o.publicFinalFloatBox;");
+        assertEqualsDouble(o.publicFinalFloatBox, "pf_float");
+        e.eval("o.publicFinalFloatBox = 20.0;");
+        assertEquals(1.372e4f, o.publicFinalFloatBox, 1e-10);
+    }
+
+    @Test
+    public void accessStaticFinalFieldFloatBoxing() throws ScriptException {
+        e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
+        assertEqualsDouble(SharedObject.publicStaticFinalFloat, "psf_float");
+        e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
+        assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
+    }
+
+    // --------------------------------double
+    // tests------------------------------------
+    @Test
+    public void accessFieldDoubleBoxing() throws ScriptException {
+        e.eval("var p_double = o.publicDoubleBox;");
+        assertEquals(o.publicDoubleBox, e.get("p_double"));
+        o.publicDoubleBox = 0.0 / 0.0;
+        assertEquals(true, e.eval("isNaN(o.publicDoubleBox)"));
+        o.publicDoubleBox = 1.0 / 0.0;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDoubleBox"));
+        o.publicDoubleBox = -1.0 / 0.0;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDoubleBox"));
+        e.eval("o.publicDoubleBox = 30;");
+        assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDoubleBox));
+        e.eval("o.publicDoubleBox = 0.0/0.0;");
+        assertTrue(Double.isNaN(o.publicDoubleBox));
+        e.eval("o.publicDoubleBox = 1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
+        e.eval("o.publicDoubleBox = -1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
+    }
+
+    @Test
+    public void accessStaticFieldDoubleBoxing() throws ScriptException {
+        e.eval("var ps_double = SharedObject.publicStaticDouble;");
+        assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
+        SharedObject.publicStaticDouble = 0.0 / 0.0;
+        assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
+        SharedObject.publicStaticDouble = 1.0 / 0.0;
+        assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
+        SharedObject.publicStaticDouble = -1.0 / 0.0;
+        assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
+        e.eval("SharedObject.publicStaticDouble = 40.0;");
+        assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
+        assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+        e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
+        assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+    }
+
+    @Test
+    public void accessFinalFieldDoubleBoxing() throws ScriptException {
+        e.eval("var pf_double = o.publicFinalDoubleBox;");
+        assertEquals(o.publicFinalDoubleBox, e.get("pf_double"));
+        e.eval("o.publicFinalDoubleBox = 30.0;");
+        assertEquals(Double.doubleToLongBits(1.412e-12), Double.doubleToLongBits(o.publicFinalDoubleBox));
+    }
+
+    @Test
+    public void accessStaticFinalFieldDoubleBoxing() throws ScriptException {
+        e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
+        assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
+        e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
+        assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/ObjectAccessTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.ObjectAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.ObjectAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class ObjectAccessTest {
+
+    private static ScriptEngine e = null;
+    private static SharedObject o = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+        e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    @Test
+    public void accessFieldObject() throws ScriptException {
+        e.eval("var p_object = o.publicObject;");
+        assertEquals(o.publicObject, e.get("p_object"));
+        assertEquals("object", e.eval("typeof p_object;"));
+        e.eval("o.publicObject = new Person(14);");
+        assertEquals(new Person(14), o.publicObject);
+    }
+
+    @Test
+    public void accessFieldObjectArray() throws ScriptException {
+        e.eval("var p_object_array = o.publicObjectArray;");
+        assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]"));
+        assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array"));
+        e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+                "t_object_arr[0] = new Person(100);" +
+                "t_object_arr[1] = new Person(120);" +
+                "t_object_arr[2] = new Person(140);" +
+                "o.publicObjectArray = t_object_arr;");
+        assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, o.publicObjectArray);
+        e.eval("o.publicObjectArray[0] = new Person(10);");
+        assertEquals(new Person(10), o.publicObjectArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldObject() throws ScriptException {
+        e.eval("var ps_object = SharedObject.publicStaticObject;");
+        assertEquals(SharedObject.publicStaticObject, e.get("ps_object"));
+        assertEquals("object", e.eval("typeof ps_object;"));
+        e.eval("SharedObject.publicStaticObject = new Person(16);");
+        assertEquals(new Person(16), SharedObject.publicStaticObject);
+    }
+
+    @Test
+    public void accessStaticFieldObjectArray() throws ScriptException {
+        e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;");
+        assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]"));
+        assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array"));
+        e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+                "ts_object_arr[0] = new Person(100);" +
+                "ts_object_arr[1] = new Person(120);" +
+                "ts_object_arr[2] = new Person(140);" +
+                "SharedObject.publicStaticObjectArray = ts_object_arr;");
+        assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, SharedObject.publicStaticObjectArray);
+        e.eval("SharedObject.publicStaticObjectArray[0] = new Person(10);");
+        assertEquals(new Person(10), SharedObject.publicStaticObjectArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldObject() throws ScriptException {
+        e.eval("var pf_object = o.publicFinalObject;");
+        assertEquals(o.publicFinalObject, e.get("pf_object"));
+        assertEquals("object", e.eval("typeof pf_object;"));
+        e.eval("o.publicFinalObject = new Person(-999);");
+        assertEquals(new Person(1024), o.publicFinalObject);
+    }
+
+    @Test
+    public void accessFinalFieldObjectArray() throws ScriptException {
+        e.eval("var pf_object_array = o.publicFinalObjectArray;");
+        assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]"));
+        assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array"));
+        e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+                "tf_object_arr[0] = new Person(100);" +
+                "tf_object_arr[1] = new Person(120);" +
+                "tf_object_arr[2] = new Person(140);" +
+                "o.publicOFinalbjectArray = tf_object_arr;");
+        assertArrayEquals(new Person[] { new Person(-900), new Person(1000), new Person(180) }, o.publicFinalObjectArray);
+        e.eval("o.publicFinalObjectArray[0] = new Person(10);");
+        assertEquals(new Person(10), o.publicFinalObjectArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldObject() throws ScriptException {
+        e.eval("var psf_object = SharedObject.publicStaticFinalObject;");
+        assertEquals(SharedObject.publicStaticFinalObject, e.get("psf_object"));
+        assertEquals("object", e.eval("typeof psf_object;"));
+        e.eval("SharedObject.publicStaticFinalObject = new Person(6);");
+        assertEquals(new Person(2048), SharedObject.publicStaticFinalObject);
+    }
+
+    @Test
+    public void accessStaticFinalFieldObjectArray() throws ScriptException {
+        e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;");
+        assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]"));
+        assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array"));
+        e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+                "tsf_object_arr[0] = new Person(100);" +
+                "tsf_object_arr[1] = new Person(120);" +
+                "tsf_object_arr[2] = new Person(140);" +
+                "SharedObject.publicStaticFinalObjectArray = tsf_object_arr;");
+        assertArrayEquals(new Person[] { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) }, SharedObject.publicStaticFinalObjectArray);
+        e.eval("SharedObject.publicStaticFinalObjectArray[0] = new Person(90);");
+        assertEquals(new Person(90), SharedObject.publicStaticFinalObjectArray[0]);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/Person.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+@SuppressWarnings("javadoc")
+public class Person {
+
+    public int id = 0;
+
+    public Person() {
+    }
+
+    public Person(final int code) {
+        this.id = code;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj != null && obj instanceof Person) {
+            final Person o = (Person)obj;
+            return this.id == o.id;
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return id;
+    }
+
+    @Override
+    public String toString() {
+        return "Person(" + id + ")";
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,467 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+@SuppressWarnings("javadoc")
+public class SharedObject {
+
+    // Public fields
+    public String                 publicString                  = "PublicString";
+    public String[]               publicStringArray             = { "ArrayString[0]", "ArrayString[1]", "ArrayString[2]", "ArrayString[3]" };
+    public Person                 publicObject                  = new Person(256);
+    public Person[]               publicObjectArray             = { new Person(4), new Person(-422), new Person(14) };
+    public boolean                publicBoolean                 = true;
+    public boolean[]              publicBooleanArray            = { true, false, false, true };
+    public Boolean                publicBooleanBox              = true;
+    public long                   publicLong                    = 933333333333333333L;
+    public long[]                 publicLongArray               = { 99012333333333L, -124355555L, 89777777777L };
+    public Long                   publicLongBox                 = 9333333333L;
+    public int                    publicInt                     = 2076543123;
+    public int[]                  publicIntArray                = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
+    public Integer                publicIntBox                  = 20765123;
+    public byte                   publicByte                    = -128;
+    public byte[]                 publicByteArray               = { 1, 2, 4, 8, 16, 32, 64, 127, -128 };
+    public Byte                   publicByteBox                 = 127;
+    public short                  publicShort                   = 32000;
+    public short[]                publicShortArray              = { 3240, 8900, -16789, 1, 12 };
+    public Short                  publicShortBox                = Short.MIN_VALUE;
+    public float                  publicFloat                   = 0.7f;
+    public float[]                publicFloatArray              = { -32.01f, 89.3f, -1.3e8f, 3.1f };
+    public Float                  publicFloatBox                = 1.377e4f;
+    public double                 publicDouble                  = 1.34e20;
+    public double[]               publicDoubleArray             = { 0.75e80, 8e-43, 1.000077, 0.123e10 };
+    public Double                 publicDoubleBox               = 1.4e-19;
+    public char                   publicChar                    = 'A';
+    public char[]                 publicCharArray               = "Hello Nashorn".toCharArray();
+    public Character              publicCharBox                 = 'B';
+    // Public static fields
+    public static String          publicStaticString            = "PublicStaticString";
+    public static String[]        publicStaticStringArray       = { "StaticArrayString[0]", "StaticArrayString[1]", "StaticArrayString[2]", "StaticArrayString[3]" };
+    public static Person          publicStaticObject            = new Person(512);
+    public static Person[]        publicStaticObjectArray       = { new Person(40), new Person(-22), new Person(18) };
+    public static boolean         publicStaticBoolean           = true;
+    public static boolean[]       publicStaticBooleanArray      = { false, false, false, true };
+    public static Boolean         publicStaticBooleanBox        = true;
+    public static long            publicStaticLong              = 13333333333333333L;
+    public static long[]          publicStaticLongArray         = { 19012333333333L, -224355555L, 39777777777L };
+    public static Long            publicStaticLongBox           = 9333333334L;
+    public static int             publicStaticInt               = 207654323;
+    public static int[]           publicStaticIntArray          = { 5, 8, 13, 21, 34 };
+    public static Integer         publicStaticIntBox            = 2075123;
+    public static byte            publicStaticByte              = -12;
+    public static byte[]          publicStaticByteArray         = { 16, 32, 64, 127, -128 };
+    public static Byte            publicStaticByteBox           = 17;
+    public static short           publicStaticShort             = 320;
+    public static short[]         publicStaticShortArray        = { 1240, 900, -1789, 100, 12 };
+    public static Short           publicStaticShortBox          = -16777;
+    public static float           publicStaticFloat             = 7.7e8f;
+    public static float[]         publicStaticFloatArray        = { -131.01f, 189.3f, -31.3e8f, 3.7f };
+    public static Float           publicStaticFloatBox          = 1.37e4f;
+    public static double          publicStaticDouble            = 1.341e20;
+    public static double[]        publicStaticDoubleArray       = { 0.75e80, 0.123e10, 8e-43, 1.000077 };
+    public static Double          publicStaticDoubleBox         = 1.41e-12;
+    public static char            publicStaticChar              = 'C';
+    public static char[]          publicStaticCharArray         = "Nashorn".toCharArray();
+    public static Character       publicStaticCharBox           = 'D';
+    // Public final fields
+    public final String           publicFinalString             = "PublicFinalString";
+    public final String[]         publicFinalStringArray        = { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" };
+    public final Person           publicFinalObject             = new Person(1024);
+    public final Person[]         publicFinalObjectArray        = { new Person(-900), new Person(1000), new Person(180) };
+    public final boolean          publicFinalBoolean            = true;
+    public final boolean[]        publicFinalBooleanArray       = { false, false, true, false };
+    public final Boolean          publicFinalBooleanBox         = true;
+    public final long             publicFinalLong               = 13353333333333333L;
+    public final long[]           publicFinalLongArray          = { 1901733333333L, -2247355555L, 3977377777L };
+    public final Long             publicFinalLongBox            = 9377333334L;
+    public final int              publicFinalInt                = 20712023;
+    public final int[]            publicFinalIntArray           = { 50, 80, 130, 210, 340 };
+    public final Integer          publicFinalIntBox             = 207512301;
+    public final byte             publicFinalByte               = -7;
+    public final byte[]           publicFinalByteArray          = { 1, 3, 6, 17, -128 };
+    public final Byte             publicFinalByteBox            = 19;
+    public final short            publicFinalShort              = 31220;
+    public final short[]          publicFinalShortArray         = { 12240, 9200, -17289, 1200, 12 };
+    public final Short            publicFinalShortBox           = -26777;
+    public final float            publicFinalFloat              = 7.72e8f;
+    public final float[]          publicFinalFloatArray         = { -131.012f, 189.32f, -31.32e8f, 3.72f };
+    public final Float            publicFinalFloatBox           = 1.372e4f;
+    public final double           publicFinalDouble             = 1.3412e20;
+    public final double[]         publicFinalDoubleArray        = { 0.725e80, 0.12e10, 8e-3, 1.00077 };
+    public final Double           publicFinalDoubleBox          = 1.412e-12;
+    public final char             publicFinalChar               = 'E';
+    public final char[]           publicFinalCharArray          = "Nashorn hello".toCharArray();
+    public final Character        publicFinalCharBox            = 'F';
+    // Public static final fields
+    public static final String    publicStaticFinalString       = "PublicStaticFinalString";
+    public static final String[]  publicStaticFinalStringArray  = { "StaticFinalArrayString[0]", "StaticFinalArrayString[1]", "StaticFinalArrayString[2]", "StaticFinalArrayString[3]" };
+    public static final Person    publicStaticFinalObject       = new Person(2048);
+    public static final Person[]  publicStaticFinalObjectArray  = { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) };
+    public static final boolean   publicStaticFinalBoolean      = true;
+    public static final boolean[] publicStaticFinalBooleanArray = { false, true, false, false };
+    public static final Boolean   publicStaticFinalBooleanBox   = true;
+    public static final long      publicStaticFinalLong         = 8333333333333L;
+    public static final long[]    publicStaticFinalLongArray    = { 19017383333L, -2247358L, 39773787L };
+    public static final Long      publicStaticFinalLongBox      = 9377388334L;
+    public static final int       publicStaticFinalInt          = 207182023;
+    public static final int[]     publicStaticFinalIntArray     = { 1308, 210, 340 };
+    public static final Integer   publicStaticFinalIntBox       = 2078301;
+    public static final byte      publicStaticFinalByte         = -70;
+    public static final byte[]    publicStaticFinalByteArray    = { 17, -128, 81 };
+    public static final Byte      publicStaticFinalByteBox      = 91;
+    public static final short     publicStaticFinalShort        = 8888;
+    public static final short[]   publicStaticFinalShortArray   = { 8240, 9280, -1289, 120, 812 };
+    public static final Short     publicStaticFinalShortBox     = -26;
+    public static final float     publicStaticFinalFloat        = 0.72e8f;
+    public static final float[]   publicStaticFinalFloatArray   = { -8131.012f, 9.32f, -138.32e8f, 0.72f };
+    public static final Float     publicStaticFinalFloatBox     = 1.2e4f;
+    public static final double    publicStaticFinalDouble       = 1.8e12;
+    public static final double[]  publicStaticFinalDoubleArray  = { 8.725e80, 0.82e10, 18e-3, 1.08077 };
+    public static final Double    publicStaticFinalDoubleBox    = 1.5612e-13;
+    public static final char      publicStaticFinalChar         = 'K';
+    public static final char[]    publicStaticFinalCharArray    = "StaticString".toCharArray();
+    public static final Character publicStaticFinalCharBox      = 'L';
+
+    // Special vars
+    public volatile boolean       volatileBoolean               = true;
+    public transient boolean      transientBoolean              = true;
+
+    // For methods testing
+    public boolean                isAccessed                    = false;
+    public volatile boolean       isFinished                    = false;
+
+    private ScriptEngine engine;
+
+    public ScriptEngine getEngine() {
+        return engine;
+    }
+
+    public void setEngine(final ScriptEngine engine) {
+        this.engine = engine;
+    }
+
+    public void voidMethod() {
+        isAccessed = true;
+    }
+
+    public boolean booleanMethod(final boolean arg) {
+        return !arg;
+    }
+
+    public Boolean booleanBoxingMethod(final Boolean arg) {
+        return !arg.booleanValue();
+    }
+
+    public boolean[] booleanArrayMethod(final boolean arg[]) {
+        final boolean[] res = new boolean[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = !arg[i];
+        }
+        return res;
+    }
+
+    public int intMethod(final int arg) {
+        return arg + arg;
+    }
+
+    public Integer intBoxingMethod(final Integer arg) {
+        return arg + arg;
+    }
+
+    public int[] intArrayMethod(final int arg[]) {
+        final int[] res = new int[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = arg[i] * 2;
+        }
+        return res;
+    }
+
+    public long longMethod(final long arg) {
+        return arg + arg;
+    }
+
+    public Long longBoxingMethod(final Long arg) {
+        return arg + arg;
+    }
+
+    public long[] longArrayMethod(final long[] arg) {
+        final long[] res = new long[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = arg[i] * 2;
+        }
+        return res;
+    }
+
+    public byte byteMethod(final byte arg) {
+        return (byte)(arg + arg);
+    }
+
+    public Byte byteBoxingMethod(final Byte arg) {
+        return (byte)(arg + arg);
+    }
+
+    public byte[] byteArrayMethod(final byte[] arg) {
+        final byte[] res = new byte[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = (byte)(arg[i] * 2);
+        }
+        return res;
+    }
+
+    public char charMethod(final char arg) {
+        return Character.toUpperCase(arg);
+    }
+
+    public Character charBoxingMethod(final Character arg) {
+        return Character.toUpperCase(arg);
+    }
+
+    public char[] charArrayMethod(final char[] arg) {
+        final char[] res = new char[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = Character.toUpperCase(arg[i]);
+        }
+        return res;
+    }
+
+    public short shortMethod(final short arg) {
+        return (short)(arg + arg);
+    }
+
+    public Short shortBoxingMethod(final Short arg) {
+        return (short)(arg + arg);
+    }
+
+    public short[] shortArrayMethod(final short[] arg) {
+        final short[] res = new short[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = (short)(arg[i] * 2);
+        }
+        return res;
+    }
+
+    public float floatMethod(final float arg) {
+        return arg + arg;
+    }
+
+    public Float floatBoxingMethod(final Float arg) {
+        return arg + arg;
+    }
+
+    public float[] floatArrayMethod(final float[] arg) {
+        final float[] res = new float[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = arg[i] * 2;
+        }
+        return res;
+    }
+
+    public double doubleMethod(final double arg) {
+        return arg + arg;
+    }
+
+    public Double doubleBoxingMethod(final Double arg) {
+        return arg + arg;
+    }
+
+    public double[] doubleArrayMethod(final double[] arg) {
+        final double[] res = new double[arg.length];
+        for (int i = 0; i < arg.length; i++) {
+            res[i] = arg[i] * 2;
+        }
+        return res;
+    }
+
+    public String stringMethod(final String str) {
+        return str + str;
+    }
+
+    public String[] stringArrayMethod(final String[] arr) {
+        final int l = arr.length;
+        final String[] res = new String[l];
+        for (int i = 0; i < l; i++) {
+            res[i] = arr[l - i - 1];
+        }
+        return res;
+    }
+
+    public Person[] objectArrayMethod(final Person[] arr) {
+        final Person[] res = new Person[arr.length];
+        for (int i = 0; i < arr.length; i++) {
+            res[i] = new Person(i + 100);
+        }
+        return res;
+    }
+
+    public Person objectMethod(final Person t) {
+        t.id *= 2;
+        return t;
+    }
+
+    public int twoParamMethod(final long l, final double d) {
+        return (int)(l + d);
+    }
+
+    public int threeParamMethod(final short s, final long l, final char c) {
+        return (int)(s + l + c);
+    }
+
+    public Person[] twoObjectParamMethod(final Person arg1, final Person arg2) {
+        return new Person[] { arg2, arg1 };
+    }
+
+    public Person[] threeObjectParamMethod(final Person arg1, final Person arg2, final Person arg3) {
+        return new Person[] { arg3, arg2, arg1 };
+    }
+
+    public Person[] eightObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8) {
+        return new Person[] { arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
+    }
+
+    public Person[] nineObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8, final Person arg9) {
+        return new Person[] { arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
+    }
+
+    public Person[] methodObjectEllipsis(final Person... args) {
+        final int l = args.length;
+        final Person[] res = new Person[l];
+        for (int i = 0; i < l; i++) {
+            res[i] = args[l - i - 1];
+        }
+        return res;
+    }
+
+    public Person[] methodPrimitiveEllipsis(final int... args) {
+        final int l = args.length;
+        final Person[] res = new Person[l];
+        for (int i = 0; i < l; i++) {
+            res[i] = new Person(args[i]);
+        }
+        return res;
+    }
+
+    public Object[] methodMixedEllipsis(final Object... args) {
+        return args;
+    }
+
+    public Object[] methodObjectWithEllipsis(final String arg, final int... args) {
+        final Object[] res = new Object[args.length + 1];
+        res[0] = arg;
+        for (int i = 0; i < args.length; i++) {
+            res[i + 1] = args[i];
+        }
+        return res;
+    }
+
+    public Object[] methodPrimitiveWithEllipsis(final int arg, final long... args) {
+        final Object[] res = new Object[args.length + 1];
+        res[0] = arg;
+        for (int i = 0; i < args.length; i++) {
+            res[i + 1] = args[i];
+        }
+        return res;
+    }
+
+    public Object[] methodMixedWithEllipsis(final String arg1, final int arg2, final Object... args) {
+        final Object[] res = new Object[args.length + 2];
+        res[0] = arg1;
+        res[1] = arg2;
+        System.arraycopy(args, 0, res, 2, args.length);
+        return res;
+    }
+
+    public void methodStartsThread() {
+        isFinished = false;
+
+        final Thread t = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    Thread.sleep(1000);
+                    isFinished = true;
+                } catch (final InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+
+        t.start();
+    }
+
+    public String overloadedMethodDoubleVSint(final int arg) {
+        return "int";
+    }
+
+    public String overloadedMethodDoubleVSint(final double arg) {
+        return "double";
+    }
+
+    public int overloadedMethod(final int arg) {
+        return arg*2;
+    }
+
+    public int overloadedMethod(final String arg) {
+        return arg.length();
+    }
+
+    public int overloadedMethod(final boolean arg) {
+        return (arg) ? 1 : 0;
+    }
+
+    public int overloadedMethod(final Person arg) {
+        return arg.id*2;
+    }
+
+    public int firstLevelMethodInt(final int arg) throws ScriptException, NoSuchMethodException {
+        return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInt", arg);
+    }
+
+    public int thirdLevelMethodInt(final int arg) {
+        return arg*5;
+    }
+
+    public int firstLevelMethodInteger(final Integer arg) throws ScriptException, NoSuchMethodException {
+        return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInteger", arg);
+    }
+
+    public int thirdLevelMethodInteger(final Integer arg) {
+        return arg*10;
+    }
+
+    public Person firstLevelMethodObject(final Person p) throws ScriptException, NoSuchMethodException {
+        return (Person) ((Invocable)engine).invokeFunction("secondLevelMethodObject", p);
+    }
+
+    public Person thirdLevelMethodObject(final Person p) {
+        p.id *= 10;
+        return p;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/javaaccess/test/StringAccessTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.StringAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.StringAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class StringAccessTest {
+
+    private static ScriptEngine e = null;
+    private static SharedObject o = null;
+
+    public static void main(final String[] args) {
+        TestNG.main(args);
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        e = m.getEngineByName("nashorn");
+        o = new SharedObject();
+        e.put("o", o);
+        e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        e = null;
+        o = null;
+    }
+
+    @Test
+    public void accessFieldString() throws ScriptException {
+        e.eval("var p_string = o.publicString;");
+        assertEquals(o.publicString, e.get("p_string"));
+        assertEquals("string", e.eval("typeof p_string;"));
+        e.eval("o.publicString = 'changedString';");
+        assertEquals("changedString", o.publicString);
+    }
+
+    @Test
+    public void accessFieldStringArray() throws ScriptException {
+        e.eval("var p_string_array = o.publicStringArray;");
+        assertEquals(o.publicStringArray[0], e.eval("o.publicStringArray[0]"));
+        assertArrayEquals(o.publicStringArray, (String[])e.get("p_string_array"));
+        e.eval("var t_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+                "t_string_arr[0] = 'abc';" +
+                "t_string_arr[1] = '123';" +
+                "t_string_arr[2] = 'xyzzzz';" +
+                "o.publicStringArray = t_string_arr;");
+        assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, o.publicStringArray);
+        e.eval("o.publicStringArray[0] = 'nashorn';");
+        assertEquals("nashorn", o.publicStringArray[0]);
+    }
+
+    @Test
+    public void accessStaticFieldString() throws ScriptException {
+        e.eval("var ps_string = SharedObject.publicStaticString;");
+        assertEquals(SharedObject.publicStaticString, e.get("ps_string"));
+        assertEquals("string", e.eval("typeof ps_string;"));
+        e.eval("SharedObject.publicStaticString = 'changedString';");
+        assertEquals("changedString", SharedObject.publicStaticString);
+    }
+
+    @Test
+    public void accessStaticFieldStringArray() throws ScriptException {
+        e.eval("var ps_string_array = SharedObject.publicStaticStringArray;");
+        assertEquals(SharedObject.publicStaticStringArray[0], e.eval("SharedObject.publicStaticStringArray[0]"));
+        assertArrayEquals(SharedObject.publicStaticStringArray, (String[])e.get("ps_string_array"));
+        e.eval("var ts_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+                "ts_string_arr[0] = 'abc';" +
+                "ts_string_arr[1] = '123';" +
+                "ts_string_arr[2] = 'xyzzzz';" +
+                "SharedObject.publicStaticStringArray = ts_string_arr;");
+        assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, SharedObject.publicStaticStringArray);
+        e.eval("SharedObject.publicStaticStringArray[0] = 'nashorn';");
+        assertEquals("nashorn", SharedObject.publicStaticStringArray[0]);
+    }
+
+    @Test
+    public void accessFinalFieldString() throws ScriptException {
+        e.eval("var pf_string = o.publicFinalString;");
+        assertEquals(o.publicFinalString, e.get("pf_string"));
+        assertEquals("string", e.eval("typeof pf_string;"));
+        e.eval("o.publicFinalString = 'changedString';");
+        assertEquals("PublicFinalString", o.publicFinalString);
+    }
+
+    @Test
+    public void accessFinalFieldStringArray() throws ScriptException {
+        e.eval("var pf_string_array = o.publicFinalStringArray;");
+        assertEquals(o.publicFinalStringArray[0], e.eval("o.publicFinalStringArray[0]"));
+        assertArrayEquals(o.publicFinalStringArray, (String[])e.get("pf_string_array"));
+        e.eval("var tf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+                "tf_string_arr[0] = 'abc';" +
+                "tf_string_arr[1] = '123';" +
+                "tf_string_arr[2] = 'xyzzzz';" +
+                "o.publicFinalStringArray = tf_string_arr;");
+        assertArrayEquals(new String[] { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" }, o.publicFinalStringArray);
+        e.eval("o.publicFinalStringArray[0] = 'nashorn';");
+        assertEquals("nashorn", o.publicFinalStringArray[0]);
+    }
+
+    @Test
+    public void accessStaticFinalFieldString() throws ScriptException {
+        e.eval("var psf_string = SharedObject.publicStaticFinalString;");
+        assertEquals(SharedObject.publicStaticFinalString, e.get("psf_string"));
+        assertEquals("string", e.eval("typeof psf_string;"));
+        e.eval("SharedObject.publicStaticFinalString = 'changedString';");
+        assertEquals("PublicStaticFinalString", SharedObject.publicStaticFinalString);
+    }
+
+    @Test
+    public void accessStaticFinalFieldStringArray() throws ScriptException {
+        e.eval("var psf_string_array = SharedObject.publicStaticFinalStringArray;");
+        assertEquals(SharedObject.publicStaticFinalStringArray[0], e.eval("SharedObject.publicStaticFinalStringArray[0]"));
+        assertArrayEquals(SharedObject.publicStaticFinalStringArray, (String[])e.get("psf_string_array"));
+        e.eval("var tsf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+                "tsf_string_arr[0] = 'abc';" +
+                "tsf_string_arr[1] = '123';" +
+                "tsf_string_arr[2] = 'xyzzzz';" +
+                "SharedObject.publicStaticFinalStringArray = tsf_string_arr;");
+        assertArrayEquals(new String[] { "StaticFinalArrayString[0]",
+                    "StaticFinalArrayString[1]",
+                    "StaticFinalArrayString[2]",
+                    "StaticFinalArrayString[3]" },
+                SharedObject.publicStaticFinalStringArray);
+        e.eval("SharedObject.publicStaticFinalStringArray[0] = 'nashorn';");
+        assertEquals("nashorn", SharedObject.publicStaticFinalStringArray[0]);
+    }
+
+}
--- a/test/src/jdk/nashorn/api/scripting/InvocableTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,539 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-import java.util.Objects;
-import java.util.function.Function;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for javax.script.Invocable implementation of nashorn.
- */
-@SuppressWarnings("javadoc")
-public class InvocableTest {
-
-    private static void log(final String msg) {
-        org.testng.Reporter.log(msg, true);
-    }
-
-    @Test
-    public void invokeMethodTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            e.eval("var Example = function() { this.hello = function() { return 'Hello World!'; };}; myExample = new Example();");
-            final Object obj = e.get("myExample");
-            final Object res = ((Invocable) e).invokeMethod(obj, "hello");
-            assertEquals(res, "Hello World!");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    /**
-     * Check that we can call invokeMethod on an object that we got by
-     * evaluating script with different Context set.
-     */
-    public void invokeMethodDifferentContextTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            // define an object with method on it
-            final Object obj = e.eval("({ hello: function() { return 'Hello World!'; } })");
-
-            final ScriptContext ctxt = new SimpleScriptContext();
-            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
-            e.setContext(ctxt);
-
-            // invoke 'func' on obj - but with current script context changed
-            final Object res = ((Invocable) e).invokeMethod(obj, "hello");
-            assertEquals(res, "Hello World!");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    /**
-     * Check that invokeMethod throws NPE on null method name.
-     */
-    public void invokeMethodNullNameTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            final Object obj = e.eval("({})");
-            ((Invocable) e).invokeMethod(obj, null);
-            fail("should have thrown NPE");
-        } catch (final Exception exp) {
-            if (!(exp instanceof NullPointerException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that invokeMethod throws NoSuchMethodException on missing method.
-     */
-    public void invokeMethodMissingTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            final Object obj = e.eval("({})");
-            ((Invocable) e).invokeMethod(obj, "nonExistentMethod");
-            fail("should have thrown NoSuchMethodException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof NoSuchMethodException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that calling method on non-script object 'thiz' results in
-     * IllegalArgumentException.
-     */
-    public void invokeMethodNonScriptObjectThizTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable) e).invokeMethod(new Object(), "toString");
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that calling method on null 'thiz' results in
-     * IllegalArgumentException.
-     */
-    public void invokeMethodNullThizTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable) e).invokeMethod(null, "toString");
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that calling method on mirror created by another engine results in
-     * IllegalArgumentException.
-     */
-    public void invokeMethodMixEnginesTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine engine1 = m.getEngineByName("nashorn");
-        final ScriptEngine engine2 = m.getEngineByName("nashorn");
-
-        try {
-            final Object obj = engine1.eval("({ run: function() {} })");
-            // pass object from engine1 to engine2 as 'thiz' for invokeMethod
-            ((Invocable) engine2).invokeMethod(obj, "run");
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void getInterfaceTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Invocable inv = (Invocable) e;
-
-        // try to get interface from global functions
-        try {
-            e.eval("function run() { print('run'); };");
-            final Runnable runnable = inv.getInterface(Runnable.class);
-            runnable.run();
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-
-        // try interface on specific script object
-        try {
-            e.eval("var obj = { run: function() { print('run from obj'); } };");
-            final Object obj = e.get("obj");
-            final Runnable runnable = inv.getInterface(obj, Runnable.class);
-            runnable.run();
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    public interface Foo {
-
-        public void bar();
-    }
-
-    public interface Foo2 extends Foo {
-
-        public void bar2();
-    }
-
-    @Test
-    public void getInterfaceMissingTest() {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine engine = manager.getEngineByName("nashorn");
-
-        // don't define any function.
-        try {
-            engine.eval("");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-
-        Runnable runnable = ((Invocable) engine).getInterface(Runnable.class);
-        if (runnable != null) {
-            fail("runnable is not null!");
-        }
-
-        // now define "run"
-        try {
-            engine.eval("function run() { print('this is run function'); }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-        runnable = ((Invocable) engine).getInterface(Runnable.class);
-        // should not return null now!
-        runnable.run();
-
-        // define only one method of "Foo2"
-        try {
-            engine.eval("function bar() { print('bar function'); }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-
-        Foo2 foo2 = ((Invocable) engine).getInterface(Foo2.class);
-        if (foo2 != null) {
-            throw new RuntimeException("foo2 is not null!");
-        }
-
-        // now define other method of "Foo2"
-        try {
-            engine.eval("function bar2() { print('bar2 function'); }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-        foo2 = ((Invocable) engine).getInterface(Foo2.class);
-        foo2.bar();
-        foo2.bar2();
-    }
-
-    @Test
-    /**
-     * Try passing non-interface Class object for interface implementation.
-     */
-    public void getNonInterfaceGetInterfaceTest() {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine engine = manager.getEngineByName("nashorn");
-        try {
-            log(Objects.toString(((Invocable) engine).getInterface(Object.class)));
-            fail("Should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                fail("IllegalArgumentException expected, got " + exp);
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that we can get interface out of a script object even after
-     * switching to use different ScriptContext.
-     */
-    public void getInterfaceDifferentContext() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            final Object obj = e.eval("({ run: function() { } })");
-
-            // change script context
-            final ScriptContext ctxt = new SimpleScriptContext();
-            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
-            e.setContext(ctxt);
-
-            final Runnable r = ((Invocable) e).getInterface(obj, Runnable.class);
-            r.run();
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    /**
-     * Check that getInterface on non-script object 'thiz' results in
-     * IllegalArgumentException.
-     */
-    public void getInterfaceNonScriptObjectThizTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable) e).getInterface(new Object(), Runnable.class);
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that getInterface on null 'thiz' results in
-     * IllegalArgumentException.
-     */
-    public void getInterfaceNullThizTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable) e).getInterface(null, Runnable.class);
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that calling getInterface on mirror created by another engine
-     * results in IllegalArgumentException.
-     */
-    public void getInterfaceMixEnginesTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine engine1 = m.getEngineByName("nashorn");
-        final ScriptEngine engine2 = m.getEngineByName("nashorn");
-
-        try {
-            final Object obj = engine1.eval("({ run: function() {} })");
-            // pass object from engine1 to engine2 as 'thiz' for getInterface
-            ((Invocable) engine2).getInterface(obj, Runnable.class);
-            fail("should have thrown IllegalArgumentException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof IllegalArgumentException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * check that null function name results in NPE.
-     */
-    public void invokeFunctionNullNameTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable)e).invokeFunction(null);
-            fail("should have thrown NPE");
-        } catch (final Exception exp) {
-            if (!(exp instanceof NullPointerException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that attempt to call missing function results in
-     * NoSuchMethodException.
-     */
-    public void invokeFunctionMissingTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            ((Invocable)e).invokeFunction("NonExistentFunc");
-            fail("should have thrown NoSuchMethodException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof NoSuchMethodException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    /**
-     * Check that invokeFunction calls functions only from current context's
-     * Bindings.
-     */
-    public void invokeFunctionDifferentContextTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            // define an object with method on it
-            e.eval("function hello() { return 'Hello World!'; }");
-            final ScriptContext ctxt = new SimpleScriptContext();
-            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
-            // change engine's current context
-            e.setContext(ctxt);
-
-            ((Invocable) e).invokeFunction("hello"); // no 'hello' in new context!
-            fail("should have thrown NoSuchMethodException");
-        } catch (final Exception exp) {
-            if (!(exp instanceof NoSuchMethodException)) {
-                exp.printStackTrace();
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void invokeFunctionExceptionTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("function func() { throw new TypeError(); }");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-
-        try {
-            ((Invocable) e).invokeFunction("func");
-            fail("should have thrown exception");
-        } catch (final ScriptException se) {
-            // ECMA TypeError property wrapped as a ScriptException
-            log("got " + se + " as expected");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-    }
-
-    @Test
-    public void invokeMethodExceptionTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("var sobj = {}; sobj.foo = function func() { throw new TypeError(); }");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-
-        try {
-            final Object sobj = e.get("sobj");
-            ((Invocable) e).invokeMethod(sobj, "foo");
-            fail("should have thrown exception");
-        } catch (final ScriptException se) {
-            // ECMA TypeError property wrapped as a ScriptException
-            log("got " + se + " as expected");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-    }
-
-    @Test
-    /**
-     * Tests whether invocation of a JavaScript method through a variable arity
-     * Java method will pass the vararg array. Both non-vararg and vararg
-     * JavaScript methods are tested.
-     *
-     * @throws ScriptException
-     */
-    public void variableArityInterfaceTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.eval(
-                "function test1(i, strings) {"
-                + "    return 'i == ' + i + ', strings instanceof java.lang.String[] == ' + (strings instanceof Java.type('java.lang.String[]')) + ', strings == ' + java.util.Arrays.toString(strings)"
-                + "}"
-                + "function test2() {"
-                + "    return 'arguments[0] == ' + arguments[0] + ', arguments[1] instanceof java.lang.String[] == ' + (arguments[1] instanceof Java.type('java.lang.String[]')) + ', arguments[1] == ' + java.util.Arrays.toString(arguments[1])"
-                + "}");
-        final VariableArityTestInterface itf = ((Invocable) e).getInterface(VariableArityTestInterface.class);
-        Assert.assertEquals(itf.test1(42, "a", "b"), "i == 42, strings instanceof java.lang.String[] == true, strings == [a, b]");
-        Assert.assertEquals(itf.test2(44, "c", "d", "e"), "arguments[0] == 44, arguments[1] instanceof java.lang.String[] == true, arguments[1] == [c, d, e]");
-    }
-
-    @Test
-    public void defaultMethodTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Invocable inv = (Invocable) e;
-
-        final Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})");
-        @SuppressWarnings("unchecked")
-        final Function<String, String> func = inv.getInterface(obj, Function.class);
-        assertEquals(func.apply("hello"), "HELLO");
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/JSONCompatibleTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class JSONCompatibleTest {
+
+    /**
+     * Wrap a top-level array as a list.
+     */
+    @Test
+    public void testWrapArray() throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        final Object val = engine.eval("Java.asJSONCompatible([1, 2, 3])");
+        assertEquals(asList(val), Arrays.asList(1, 2, 3));
+    }
+
+    /**
+     * Wrap an embedded array as a list.
+     */
+    @Test
+    public void testWrapObjectWithArray() throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        final Object val = engine.eval("Java.asJSONCompatible({x: [1, 2, 3]})");
+        assertEquals(asList(asMap(val).get("x")), Arrays.asList(1, 2, 3));
+    }
+
+    /**
+     * Check it all works transitively several more levels down.
+     */
+    @Test
+    public void testDeepWrapping() throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        final Object val = engine.eval("Java.asJSONCompatible({x: [1, {y: [2, {z: [3]}]}, [4, 5]]})");
+        final Map<String, Object> root = asMap(val);
+        final List<Object> x = asList(root.get("x"));
+        assertEquals(x.get(0), 1);
+        final Map<String, Object> x1 = asMap(x.get(1));
+        final List<Object> y = asList(x1.get("y"));
+        assertEquals(y.get(0), 2);
+        final Map<String, Object> y1 = asMap(y.get(1));
+        assertEquals(asList(y1.get("z")), Arrays.asList(3));
+        assertEquals(asList(x.get(2)), Arrays.asList(4, 5));
+    }
+
+    /**
+     * Ensure that the old behaviour (every object is a Map) is unchanged.
+     */
+    @Test
+    public void testNonWrapping() throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        final Object val = engine.eval("({x: [1, {y: [2, {z: [3]}]}, [4, 5]]})");
+        final Map<String, Object> root = asMap(val);
+        final Map<String, Object> x = asMap(root.get("x"));
+        assertEquals(x.get("0"), 1);
+        final Map<String, Object> x1 = asMap(x.get("1"));
+        final Map<String, Object> y = asMap(x1.get("y"));
+        assertEquals(y.get("0"), 2);
+        final Map<String, Object> y1 = asMap(y.get("1"));
+        final Map<String, Object> z = asMap(y1.get("z"));
+        assertEquals(z.get("0"), 3);
+        final Map<String, Object> x2 = asMap(x.get("2"));
+        assertEquals(x2.get("0"), 4);
+        assertEquals(x2.get("1"), 5);
+    }
+
+    @SuppressWarnings("unchecked")
+    private static List<Object> asList(final Object obj) {
+        assertJSObject(obj);
+        Assert.assertTrue(obj instanceof List);
+        return (List)obj;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Map<String, Object> asMap(final Object obj) {
+        assertJSObject(obj);
+        Assert.assertTrue(obj instanceof Map);
+        return (Map)obj;
+    }
+
+    private static void assertJSObject(final Object obj) {
+        assertTrue(obj instanceof JSObject);
+    }
+}
--- a/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * Test that we can create multiple, independent script engines and use those
- * independently.
- *
- * @test
- * @run testng jdk.nashorn.api.scripting.MultipleEngineTest
- */
-@SuppressWarnings("javadoc")
-public class MultipleEngineTest {
-    @Test
-    public void createAndUseManyEngine() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-
-        final ScriptEngine e1 = m.getEngineByName("nashorn");
-        e1.eval("var  x = 33; print(x);");
-
-        final ScriptEngine e2 = m.getEngineByName("nashorn");
-        e2.eval("try { print(x) } catch(e) { print(e); }");
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,259 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.fail;
-
-import java.nio.IntBuffer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Set;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import org.testng.annotations.Test;
-
-/**
- * Tests for pluggable external impls. of jdk.nashorn.api.scripting.JSObject.
- *
- * JDK-8024615: Refactor ScriptObjectMirror and JSObject to support external
- * JSObject implementations.
- */
-@SuppressWarnings("javadoc")
-public class PluggableJSObjectTest {
-    public static class MapWrapperObject extends AbstractJSObject {
-        private final HashMap<String, Object> map = new LinkedHashMap<>();
-
-        public HashMap<String, Object> getMap() {
-            return map;
-        }
-
-        @Override
-        public Object getMember(final String name) {
-            return map.get(name);
-        }
-
-        @Override
-        public void setMember(final String name, final Object value) {
-            map.put(name, value);
-        }
-
-        @Override
-        public boolean hasMember(final String name) {
-            return map.containsKey(name);
-        }
-
-        @Override
-        public void removeMember(final String name) {
-            map.remove(name);
-        }
-
-        @Override
-        public Set<String> keySet() {
-            return map.keySet();
-        }
-
-        @Override
-        public Collection<Object> values() {
-            return map.values();
-        }
-    }
-
-    @Test
-    // Named property access on a JSObject
-    public void namedAccessTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            final MapWrapperObject obj = new MapWrapperObject();
-            e.put("obj", obj);
-            obj.getMap().put("foo", "bar");
-
-            // property-like access on MapWrapperObject objects
-            assertEquals(e.eval("obj.foo"), "bar");
-            e.eval("obj.foo = 'hello'");
-            assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
-            assertEquals(e.eval("obj.foo"), "hello");
-            assertEquals(obj.getMap().get("foo"), "hello");
-            e.eval("delete obj.foo");
-            assertFalse(obj.getMap().containsKey("foo"));
-            assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    public static class BufferObject extends AbstractJSObject {
-        private final IntBuffer buf;
-
-        public BufferObject(final int size) {
-            buf = IntBuffer.allocate(size);
-        }
-
-        public IntBuffer getBuffer() {
-            return buf;
-        }
-
-        @Override
-        public Object getMember(final String name) {
-            return name.equals("length")? buf.capacity() : null;
-        }
-
-        @Override
-        public boolean hasSlot(final int i) {
-            return i > -1 && i < buf.capacity();
-        }
-
-        @Override
-        public Object getSlot(final int i) {
-            return buf.get(i);
-        }
-
-        @Override
-        public void setSlot(final int i, final Object value) {
-            buf.put(i, ((Number)value).intValue());
-        }
-
-        @Override
-        public boolean isArray() {
-            return true;
-        }
-    }
-
-    @Test
-    // array-like indexed access for a JSObject
-    public void indexedAccessTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            final BufferObject buf = new BufferObject(2);
-            e.put("buf", buf);
-
-            // array-like access on BufferObject objects
-            assertEquals(e.eval("buf.length"), buf.getBuffer().capacity());
-            e.eval("buf[0] = 23");
-            assertEquals(buf.getBuffer().get(0), 23);
-            assertEquals(e.eval("buf[0]"), 23);
-            assertEquals(e.eval("buf[1]"), 0);
-            buf.getBuffer().put(1, 42);
-            assertEquals(e.eval("buf[1]"), 42);
-            assertEquals(e.eval("Array.isArray(buf)"), Boolean.TRUE);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    public static class Adder extends AbstractJSObject {
-        @Override
-        public Object call(final Object thiz, final Object... args) {
-            double res = 0.0;
-            for (final Object arg : args) {
-                res += ((Number)arg).doubleValue();
-            }
-            return res;
-        }
-
-        @Override
-        public boolean isFunction() {
-            return true;
-        }
-    }
-
-    @Test
-    // a callable JSObject
-    public void callableJSObjectTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.put("sum", new Adder());
-            // check callability of Adder objects
-            assertEquals(e.eval("typeof sum"), "function");
-            assertEquals(((Number)e.eval("sum(1, 2, 3, 4, 5)")).intValue(), 15);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    public static class Factory extends AbstractJSObject {
-        @SuppressWarnings("unused")
-        @Override
-        public Object newObject(final Object... args) {
-            return new HashMap<Object, Object>();
-        }
-
-        @Override
-        public boolean isFunction() {
-            return true;
-        }
-    }
-
-    @Test
-    // a factory JSObject
-    public void factoryJSObjectTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.put("Factory", new Factory());
-
-            // check new on Factory
-            assertEquals(e.eval("typeof Factory"), "function");
-            assertEquals(e.eval("typeof new Factory()"), "object");
-            assertEquals(e.eval("(new Factory()) instanceof java.util.Map"), Boolean.TRUE);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    // iteration tests
-    public void iteratingJSObjectTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            final MapWrapperObject obj = new MapWrapperObject();
-            obj.setMember("foo", "hello");
-            obj.setMember("bar", "world");
-            e.put("obj", obj);
-
-            // check for..in
-            Object val = e.eval("var str = ''; for (i in obj) str += i; str");
-            assertEquals(val.toString(), "foobar");
-
-            // check for..each..in
-            val = e.eval("var str = ''; for each (i in obj) str += i; str");
-            assertEquals(val.toString(), "helloworld");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/ScopeTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,709 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-import javax.script.SimpleScriptContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for jsr223 Bindings "scope" (engine, global scopes)
- */
-@SuppressWarnings("javadoc")
-public class ScopeTest {
-
-    @Test
-    public void createBindingsTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        b.put("foo", 42.0);
-        Object res = null;
-        try {
-            res = e.eval("foo == 42.0", b);
-        } catch (final ScriptException | NullPointerException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-
-        assertEquals(res, Boolean.TRUE);
-    }
-
-    @Test
-    public void engineScopeTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings engineScope = e.getBindings(ScriptContext.ENGINE_SCOPE);
-
-        // check few ECMA standard built-in global properties
-        assertNotNull(engineScope.get("Object"));
-        assertNotNull(engineScope.get("TypeError"));
-        assertNotNull(engineScope.get("eval"));
-
-        // can access via ScriptEngine.get as well
-        assertNotNull(e.get("Object"));
-        assertNotNull(e.get("TypeError"));
-        assertNotNull(e.get("eval"));
-
-        // Access by either way should return same object
-        assertEquals(engineScope.get("Array"), e.get("Array"));
-        assertEquals(engineScope.get("EvalError"), e.get("EvalError"));
-        assertEquals(engineScope.get("undefined"), e.get("undefined"));
-
-        // try exposing a new variable from scope
-        engineScope.put("myVar", "foo");
-        try {
-            assertEquals(e.eval("myVar"), "foo");
-        } catch (final ScriptException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-
-        // update "myVar" in script an check the value from scope
-        try {
-            e.eval("myVar = 'nashorn';");
-        } catch (final ScriptException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-
-        // now check modified value from scope and engine
-        assertEquals(engineScope.get("myVar"), "nashorn");
-        assertEquals(e.get("myVar"), "nashorn");
-    }
-
-    @Test
-    public void multiGlobalTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        try {
-            final Object obj1 = e.eval("Object");
-            final Object obj2 = e.eval("Object", newCtxt);
-            Assert.assertNotEquals(obj1, obj2);
-            Assert.assertNotNull(obj1);
-            Assert.assertNotNull(obj2);
-            Assert.assertEquals(obj1.toString(), obj2.toString());
-
-            e.eval("x = 'hello'");
-            e.eval("x = 'world'", newCtxt);
-            Object x1 = e.getContext().getAttribute("x");
-            Object x2 = newCtxt.getAttribute("x");
-            Assert.assertNotEquals(x1, x2);
-            Assert.assertEquals(x1, "hello");
-            Assert.assertEquals(x2, "world");
-
-            x1 = e.eval("x");
-            x2 = e.eval("x", newCtxt);
-            Assert.assertNotEquals(x1, x2);
-            Assert.assertEquals(x1, "hello");
-            Assert.assertEquals(x2, "world");
-
-            final ScriptContext origCtxt = e.getContext();
-            e.setContext(newCtxt);
-            e.eval("y = new Object()");
-            e.eval("y = new Object()", origCtxt);
-
-            final Object y1 = origCtxt.getAttribute("y");
-            final Object y2 = newCtxt.getAttribute("y");
-            Assert.assertNotEquals(y1, y2);
-            final Object yeval1 = e.eval("y");
-            final Object yeval2 = e.eval("y", origCtxt);
-            Assert.assertNotEquals(yeval1, yeval2);
-            Assert.assertEquals("[object Object]", y1.toString());
-            Assert.assertEquals("[object Object]", y2.toString());
-        } catch (final ScriptException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-    }
-
-    @Test
-    public void userEngineScopeBindingsTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.eval("function func() {}");
-
-        final ScriptContext newContext = new SimpleScriptContext();
-        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
-        // we are using a new bindings - so it should have 'func' defined
-        final Object value = e.eval("typeof func", newContext);
-        assertTrue(value.equals("undefined"));
-    }
-
-    @Test
-    public void userEngineScopeBindingsNoLeakTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptContext newContext = new SimpleScriptContext();
-        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
-        e.eval("function foo() {}", newContext);
-
-        // in the default context's ENGINE_SCOPE, 'foo' shouldn't exist
-        assertTrue(e.eval("typeof foo").equals("undefined"));
-    }
-
-    @Test
-    public void userEngineScopeBindingsRetentionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptContext newContext = new SimpleScriptContext();
-        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
-        e.eval("function foo() {}", newContext);
-
-        // definition retained with user's ENGINE_SCOPE Binding
-        assertTrue(e.eval("typeof foo", newContext).equals("function"));
-
-        final Bindings oldBindings = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
-        // but not in another ENGINE_SCOPE binding
-        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
-        assertTrue(e.eval("typeof foo", newContext).equals("undefined"));
-
-        // restore ENGINE_SCOPE and check again
-        newContext.setBindings(oldBindings, ScriptContext.ENGINE_SCOPE);
-        assertTrue(e.eval("typeof foo", newContext).equals("function"));
-    }
-
-    @Test
-    // check that engine.js definitions are visible in all new global instances
-    public void checkBuiltinsInNewBindingsTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        // check default global instance has engine.js definitions
-        final Bindings g = (Bindings) e.eval("this");
-        Object value = g.get("__noSuchProperty__");
-        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-        value = g.get("print");
-        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-
-        // check new global instance created has engine.js definitions
-        final Bindings b = e.createBindings();
-        value = b.get("__noSuchProperty__");
-        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-        value = b.get("print");
-        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-
-        // put a mapping into GLOBAL_SCOPE
-        final Bindings globalScope = e.getContext().getBindings(ScriptContext.GLOBAL_SCOPE);
-        globalScope.put("x", "hello");
-
-        // GLOBAL_SCOPE mapping should be visible from default ScriptContext eval
-        assertTrue(e.eval("x").equals("hello"));
-
-        final ScriptContext ctx = new SimpleScriptContext();
-        ctx.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
-        ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
-        assertTrue(e.eval("x", ctx).equals("hello"));
-
-        // try some arbitray Bindings for ENGINE_SCOPE
-        final Bindings sb = new SimpleBindings();
-        ctx.setBindings(sb, ScriptContext.ENGINE_SCOPE);
-
-        // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
-        assertTrue(e.eval("x", ctx).equals("hello"));
-
-        // engine.js builtins are still defined even with arbitrary Bindings
-        assertTrue(e.eval("typeof print", ctx).equals("function"));
-        assertTrue(e.eval("typeof __noSuchProperty__", ctx).equals("function"));
-
-        // ENGINE_SCOPE definition should 'hide' GLOBAL_SCOPE definition
-        sb.put("x", "newX");
-        assertTrue(e.eval("x", ctx).equals("newX"));
-    }
-
-    /**
-     * Test multi-threaded access to defined global variables for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedVarTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        final String sharedScript = "foo";
-
-        assertEquals(e.eval("var foo = 'original context';", origContext), null);
-        assertEquals(e.eval("var foo = 'new context';", newCtxt), null);
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        assertEquals(e.eval("var foo = 'newer context';", newCtxt), null);
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-
-        assertEquals(e.eval(sharedScript), "original context");
-        assertEquals(e.eval(sharedScript, newCtxt), "newer context");
-    }
-
-    /**
-     * Test multi-threaded access to undefined global variables for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedGlobalTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        assertEquals(e.eval("foo = 'original context';", origContext), "original context");
-        assertEquals(e.eval("foo = 'new context';", newCtxt), "new context");
-        final String sharedScript = "foo";
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        final Object obj3 = e.eval("delete foo; foo = 'newer context';", newCtxt);
-        assertEquals(obj3, "newer context");
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-
-        Assert.assertEquals(e.eval(sharedScript), "original context");
-        Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
-    }
-
-    /**
-     * Test multi-threaded access using the postfix ++ operator for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedIncTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        assertEquals(e.eval("var x = 0;", origContext), null);
-        assertEquals(e.eval("var x = 2;", newCtxt), null);
-        final String sharedScript = "x++;";
-
-        final Thread t1 = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    for (int i = 0; i < 1000; i++) {
-                        assertEquals(e.eval(sharedScript, origContext), (double)i);
-                    }
-                } catch (final ScriptException se) {
-                    fail(se.toString());
-                }
-            }
-        });
-        final Thread t2 = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    for (int i = 2; i < 1000; i++) {
-                        assertEquals(e.eval(sharedScript, newCtxt), (double)i);
-                    }
-                } catch (final ScriptException se) {
-                    fail(se.toString());
-                }
-            }
-        });
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-    }
-
-    /**
-     * Test multi-threaded access to primitive prototype properties for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedPrimitiveTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        final Object obj1 = e.eval("String.prototype.foo = 'original context';", origContext);
-        final Object obj2 = e.eval("String.prototype.foo = 'new context';", newCtxt);
-        assertEquals(obj1, "original context");
-        assertEquals(obj2, "new context");
-        final String sharedScript = "''.foo";
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
-        assertEquals(obj3, "newer context");
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-
-        Assert.assertEquals(e.eval(sharedScript), "original context");
-        Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
-    }
-
-
-    /**
-     * Test multi-threaded access to prototype user accessor properties for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedAccessorTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'original context' })", origContext);
-        e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'new context', configurable: true })", newCtxt);
-        final String sharedScript = "({}).foo";
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        final Object obj3 = e.eval("delete Object.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
-        assertEquals(obj3, "newer context");
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-    }
-
-    /**
-     * Test multi-threaded access to primitive prototype user accessor properties for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedPrimitiveAccessorTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'original context' })", origContext);
-        e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'new context' })", newCtxt);
-        final String sharedScript = "''.foo";
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
-        assertEquals(obj3, "newer context");
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-    }
-
-    /**
-     * Test multi-threaded scope function invocation for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedFunctionTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), origContext);
-        assertEquals(origContext.getAttribute("scopeVar"), 1);
-        assertEquals(e.eval("scopeTest()"), 1);
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), newCtxt);
-        assertEquals(newCtxt.getAttribute("scopeVar"), 1);
-        assertEquals(e.eval("scopeTest();", newCtxt), 1);
-
-        assertEquals(e.eval("scopeVar = 3;", newCtxt), 3);
-        assertEquals(newCtxt.getAttribute("scopeVar"), 3);
-
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, "scopeTest()", 1, 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, "scopeTest()", 3, 1000));
-
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-    }
-
-    /**
-     * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
-     */
-    @Test
-    public static void getterSetterTest() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        final String sharedScript = "accessor1";
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
-        assertEquals(e.eval("accessor1 = 1;"), 1);
-        assertEquals(e.eval(sharedScript), 1);
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
-        assertEquals(e.eval("accessor1 = 2;", newCtxt), 2);
-        assertEquals(e.eval(sharedScript, newCtxt), 2);
-
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
-
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        assertEquals(e.eval(sharedScript), 1);
-        assertEquals(e.eval(sharedScript, newCtxt), 2);
-        assertEquals(e.eval("v"), 1);
-        assertEquals(e.eval("v", newCtxt), 2);
-    }
-
-    /**
-     * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
-     */
-    @Test
-    public static void getterSetter2Test() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        final String sharedScript = "accessor2";
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
-        assertEquals(e.eval("accessor2 = 1;"), 1);
-        assertEquals(e.eval(sharedScript), 1);
-
-        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
-        assertEquals(e.eval("accessor2 = 2;", newCtxt), 2);
-        assertEquals(e.eval(sharedScript, newCtxt), 2);
-
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
-
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        assertEquals(e.eval(sharedScript), 1);
-        assertEquals(e.eval(sharedScript, newCtxt), 2);
-        assertEquals(e.eval("x"), 1);
-        assertEquals(e.eval("x", newCtxt), 2);
-    }
-
-    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
-    @Test
-    public static void contextOverwriteTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = new SimpleBindings();
-        b.put("context", "hello");
-        b.put("foo", 32);
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        e.setContext(newCtxt);
-        assertEquals(e.eval("context"), "hello");
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-    }
-
-    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
-    @Test
-    public static void contextOverwriteInScriptTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.put("foo", 32);
-
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-        assertEquals(e.eval("context = 'bar'"), "bar");
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-    }
-
-    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
-    @Test
-    public static void engineOverwriteTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Bindings b = new SimpleBindings();
-        b.put("engine", "hello");
-        b.put("foo", 32);
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        e.setContext(newCtxt);
-        assertEquals(e.eval("engine"), "hello");
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-    }
-
-    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
-    @Test
-    public static void engineOverwriteInScriptTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.put("foo", 32);
-
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-        assertEquals(e.eval("engine = 'bar'"), "bar");
-        assertEquals(((Number)e.eval("foo")).intValue(), 32);
-    }
-
-    // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
-    @Test
-    public static void testMegamorphicGetInGlobal() throws Exception {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine engine = m.getEngineByName("nashorn");
-        final String script = "foo";
-        // "foo" is megamorphic because of different global scopes.
-        // Make sure ScriptContext variable search works even after
-        // it becomes megamorphic.
-        for (int index = 0; index < 25; index++) {
-            final Bindings bindings = new SimpleBindings();
-            bindings.put("foo", index);
-            final Number value = (Number)engine.eval(script, bindings);
-            assertEquals(index, value.intValue());
-        }
-    }
-
-    /**
-     * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals.
-     * @throws ScriptException
-     * @throws InterruptedException
-     */
-    @Test
-    public static void testSlowScope() throws ScriptException, InterruptedException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        for (int i = 0; i < 100; i++) {
-            final Bindings b = e.createBindings();
-            final ScriptContext ctxt = new SimpleScriptContext();
-            ctxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
-            e.eval(new URLReader(ScopeTest.class.getResource("resources/witheval.js")), ctxt);
-            assertEquals(e.eval("a", ctxt), 1);
-            assertEquals(b.get("a"), 1);
-            assertEquals(e.eval("b", ctxt), 3);
-            assertEquals(b.get("b"), 3);
-            assertEquals(e.eval("c", ctxt), 10);
-            assertEquals(b.get("c"), 10);
-        }
-    }
-
-    private static class ScriptRunner implements Runnable {
-
-        final ScriptEngine engine;
-        final ScriptContext context;
-        final String source;
-        final Object expected;
-        final int iterations;
-
-        ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
-            this.engine = engine;
-            this.context = context;
-            this.source = source;
-            this.expected = expected;
-            this.iterations = iterations;
-        }
-
-        @Override
-        public void run() {
-            try {
-                for (int i = 0; i < iterations; i++) {
-                    assertEquals(engine.eval(source, context), expected);
-                }
-            } catch (final ScriptException se) {
-                throw new RuntimeException(se);
-            }
-        }
-    }
-
-}
--- a/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.fail;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * jsr223 tests for security access checks.
- */
-@SuppressWarnings("javadoc")
-public class ScriptEngineSecurityTest {
-
-    private static void log(final String msg) {
-        org.testng.Reporter.log(msg, true);
-    }
-
-    @Test
-    public void securityPackagesTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("var v = Packages.sun.misc.Unsafe;");
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (exp instanceof SecurityException) {
-                log("got " + exp + " as expected");
-            } else {
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void securityJavaTypeTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("var v = Java.type('sun.misc.Unsafe');");
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (exp instanceof SecurityException) {
-                log("got " + exp + " as expected");
-            } else {
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void securityClassForNameTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("var v = java.lang.Class.forName('sun.misc.Unsafe');");
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (exp instanceof SecurityException) {
-                log("got " + exp + " as expected");
-            } else {
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void securitySystemExit() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("java.lang.System.exit(0);");
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (exp instanceof SecurityException) {
-                log("got " + exp + " as expected");
-            } else {
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-
-    @Test
-    public void securitySystemExitFromFinalizerThread() throws ScriptException {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.eval("var o = Java.extend(Java.type('javax.imageio.spi.ServiceRegistry'), { deregisterAll: this.exit.bind(null, 1234)});\n" +
-                "new o(new java.util.ArrayList().iterator())");
-        System.gc();
-        System.runFinalization();
-        // NOTE: this test just exits the VM if it fails.
-    }
-
-    @Test
-    public void securitySystemLoadLibrary() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("java.lang.System.loadLibrary('foo');");
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (exp instanceof SecurityException) {
-                log("got " + exp + " as expected");
-            } else {
-                fail(exp.getMessage());
-            }
-        }
-    }
-
-    // @bug 8032948: Nashorn linkages awry
-    @SuppressWarnings("serial")
-    public static class FakeProxy extends Proxy {
-        public FakeProxy(final InvocationHandler ih) {
-            super(ih);
-        }
-
-        public static Class<?> makeProxyClass(final ClassLoader cl, final Class<?>... ifaces) {
-            return Proxy.getProxyClass(cl, ifaces);
-        }
-    }
-
-    @Test
-    public void fakeProxySubclassAccessCheckTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        e.put("name", ScriptEngineSecurityTest.class.getName());
-        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
-        e.put("intfs", new Class[] { Runnable.class });
-
-        final String getClass = "Java.type(name + '$FakeProxy').getProxyClass(cl, intfs);";
-
-        // Should not be able to call static methods of Proxy via fake subclass
-        try {
-            e.eval(getClass);
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (! (exp instanceof SecurityException)) {
-                fail("SecurityException expected, got " + exp);
-            }
-        }
-    }
-
-    @Test
-    public void fakeProxySubclassAccessCheckTest2() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        e.put("name", ScriptEngineSecurityTest.class.getName());
-        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
-        e.put("intfs", new Class[] { Runnable.class });
-
-        final String getClass = "Java.type(name + '$FakeProxy').makeProxyClass(cl, intfs);";
-
-        // Should not be able to call static methods of Proxy via fake subclass
-        try {
-            e.eval(getClass);
-            fail("should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (! (exp instanceof SecurityException)) {
-                fail("SecurityException expected, got " + exp);
-            }
-        }
-    }
-
-    @Test
-    public static void proxyStaticAccessCheckTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Runnable r = (Runnable)Proxy.newProxyInstance(
-            ScriptEngineTest.class.getClassLoader(),
-            new Class[] { Runnable.class },
-            new InvocationHandler() {
-                @Override
-                public Object invoke(final Object p, final Method mtd, final Object[] a) {
-                    return null;
-                }
-            });
-
-        e.put("rc", r.getClass());
-        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
-        e.put("intfs", new Class[] { Runnable.class });
-
-        // make sure static methods of Proxy is not accessible via subclass
-        try {
-            e.eval("rc.static.getProxyClass(cl, intfs)");
-            fail("Should have thrown SecurityException");
-        } catch (final Exception exp) {
-            if (! (exp instanceof SecurityException)) {
-                fail("SecurityException expected, got " + exp);
-            }
-        }
-    }
-
-
-    @Test
-    public void nashornConfigSecurityTest() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(new ClassFilter() {
-               @Override
-               public boolean exposeToScripts(final String name) {
-                   return true;
-               }
-            });
-            fail("SecurityException should have been thrown");
-        } catch (final SecurityException e) {
-            //empty
-        }
-    }
-
-    @Test
-    public void nashornConfigSecurityTest2() {
-        if (System.getSecurityManager() == null) {
-            // pass vacuously
-            return;
-        }
-
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(new String[0], null, new ClassFilter() {
-               @Override
-               public boolean exposeToScripts(final String name) {
-                   return true;
-               }
-            });
-            fail("SecurityException should have been thrown");
-        } catch (final SecurityException e) {
-            //empty
-        }
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,724 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import javax.script.Compilable;
-import javax.script.CompiledScript;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSR-223 script engine for Nashorn.
- *
- * @test
- * @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest
- * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest
- */
-@SuppressWarnings("javadoc")
-public class ScriptEngineTest {
-
-    private static void log(final String msg) {
-        org.testng.Reporter.log(msg, true);
-    }
-
-    @Test
-    public void argumentsTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        final String[] args = new String[] { "hello", "world" };
-        try {
-            e.put("arguments", args);
-            final Object arg0 = e.eval("arguments[0]");
-            final Object arg1 = e.eval("arguments[1]");
-            assertEquals(args[0], arg0);
-            assertEquals(args[1], arg1);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void argumentsWithTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        final String[] args = new String[] { "hello", "world" };
-        try {
-            e.put("arguments", args);
-            final Object arg0 = e.eval("var imports = new JavaImporter(java.io); " +
-                    " with(imports) { arguments[0] }");
-            final Object arg1 = e.eval("var imports = new JavaImporter(java.util, java.io); " +
-                    " with(imports) { arguments[1] }");
-            assertEquals(args[0], arg0);
-            assertEquals(args[1], arg1);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void argumentsEmptyTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            assertEquals(e.eval("arguments instanceof Array"), true);
-            assertEquals(e.eval("arguments.length == 0"), true);
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void factoryTests() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        assertNotNull(e);
-
-        final ScriptEngineFactory fac = e.getFactory();
-
-        assertEquals(fac.getLanguageName(), "ECMAScript");
-        assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
-        assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
-        assertEquals(fac.getEngineName(), "Oracle Nashorn");
-        assertEquals(fac.getOutputStatement("context"), "print(context)");
-        assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
-        assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
-
-        boolean seenJS = false;
-        for (final String ext : fac.getExtensions()) {
-            if (ext.equals("js")) {
-                seenJS = true;
-            }
-        }
-
-        assertEquals(seenJS, true);
-        final String str = fac.getMethodCallSyntax("obj", "foo", "x");
-        assertEquals(str, "obj.foo(x)");
-
-        boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
-        for (final String name : fac.getNames()) {
-            switch (name) {
-                case "nashorn": seenNashorn = true; break;
-                case "javascript": seenJavaScript = true; break;
-                case "ECMAScript": seenECMAScript = true; break;
-            default:
-                break;
-            }
-        }
-
-        assertTrue(seenNashorn);
-        assertTrue(seenJavaScript);
-        assertTrue(seenECMAScript);
-
-        boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
-        for (final String mime : fac.getMimeTypes()) {
-            switch (mime) {
-                case "application/javascript": seenAppJS = true; break;
-                case "application/ecmascript": seenAppECMA = true; break;
-                case "text/javascript": seenTextJS = true; break;
-                case "text/ecmascript": seenTextECMA = true; break;
-            default:
-                break;
-            }
-        }
-
-        assertTrue(seenAppJS);
-        assertTrue(seenAppECMA);
-        assertTrue(seenTextJS);
-        assertTrue(seenTextECMA);
-    }
-
-    @Test
-    public void evalTests() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.put(ScriptEngine.FILENAME, "myfile.js");
-
-        try {
-            e.eval("print('hello')");
-        } catch (final ScriptException se) {
-            fail(se.getMessage());
-        }
-        try {
-            e.eval("print('hello)");
-            fail("script exception expected");
-        } catch (final ScriptException se) {
-            assertEquals(se.getLineNumber(), 1);
-            assertEquals(se.getColumnNumber(), 13);
-            assertEquals(se.getFileName(), "myfile.js");
-            // se.printStackTrace();
-        }
-
-        try {
-            Object obj = e.eval("34 + 41");
-            assertTrue(34.0 + 41.0 == ((Number)obj).doubleValue());
-            obj = e.eval("x = 5");
-            assertTrue(5.0 == ((Number)obj).doubleValue());
-        } catch (final ScriptException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-    }
-
-    @Test
-    public void compileTests() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        CompiledScript script = null;
-
-        try {
-            script = ((Compilable)e).compile("print('hello')");
-        } catch (final ScriptException se) {
-            fail(se.getMessage());
-        }
-
-        try {
-            script.eval();
-        } catch (final ScriptException | NullPointerException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-
-        // try to compile from a Reader
-        try {
-            script = ((Compilable)e).compile(new StringReader("print('world')"));
-        } catch (final ScriptException se) {
-            fail(se.getMessage());
-        }
-
-        try {
-            script.eval();
-        } catch (final ScriptException | NullPointerException se) {
-            se.printStackTrace();
-            fail(se.getMessage());
-        }
-    }
-
-    @Test
-    public void compileAndEvalInDiffContextTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine engine = m.getEngineByName("js");
-        final Compilable compilable = (Compilable) engine;
-        final CompiledScript compiledScript = compilable.compile("foo");
-        final ScriptContext ctxt = new SimpleScriptContext();
-        ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
-        assertEquals(compiledScript.eval(ctxt), "hello");
-    }
-
-    @Test
-    public void accessGlobalTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            e.eval("var x = 'hello'");
-            assertEquals(e.get("x"), "hello");
-        } catch (final ScriptException exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void exposeGlobalTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            e.put("y", "foo");
-            e.eval("print(y)");
-        } catch (final ScriptException exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void putGlobalFunctionTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        e.put("callable", new Callable<String>() {
-            @Override
-            public String call() throws Exception {
-                return "callable was called";
-            }
-        });
-
-        try {
-            e.eval("print(callable.call())");
-        } catch (final ScriptException exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void windowAlertTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Window window = new Window();
-
-        try {
-            e.put("window", window);
-            e.eval("print(window.alert)");
-            e.eval("window.alert('calling window.alert...')");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void windowLocationTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Window window = new Window();
-
-        try {
-            e.put("window", window);
-            e.eval("print(window.location)");
-            final Object locationValue = e.eval("window.getLocation()");
-            assertEquals(locationValue, "http://localhost:8080/window");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void windowItemTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Window window = new Window();
-
-        try {
-            e.put("window", window);
-            final String item1 = (String)e.eval("window.item(65535)");
-            assertEquals(item1, "ffff");
-            final String item2 = (String)e.eval("window.item(255)");
-            assertEquals(item2, "ff");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void windowEventTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Window window = new Window();
-
-        try {
-            e.put("window", window);
-            e.eval("window.onload = function() { print('window load event fired'); return true }");
-            assertTrue((Boolean)e.eval("window.onload.loaded()"));
-            final WindowEventHandler handler = window.getOnload();
-            assertNotNull(handler);
-            assertTrue(handler.loaded());
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void throwTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.put(ScriptEngine.FILENAME, "throwtest.js");
-
-        try {
-            e.eval("throw 'foo'");
-        } catch (final ScriptException exp) {
-            log(exp.getMessage());
-            assertEquals(exp.getMessage(), "foo in throwtest.js at line number 1 at column number 0");
-            assertEquals(exp.getFileName(), "throwtest.js");
-            assertEquals(exp.getLineNumber(), 1);
-        }
-    }
-
-    @Test
-    public void setTimeoutTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final Window window = new Window();
-
-        try {
-            final Class<?> setTimeoutParamTypes[] = { Window.class, String.class, int.class };
-            final Method setTimeout = Window.class.getDeclaredMethod("setTimeout", setTimeoutParamTypes);
-            assertNotNull(setTimeout);
-            e.put("window", window);
-            e.eval("window.setTimeout('foo()', 100)");
-
-            // try to make setTimeout global
-            e.put("setTimeout", setTimeout);
-            // TODO: java.lang.ClassCastException: required class
-            // java.lang.Integer but encountered class java.lang.Double
-            // e.eval("setTimeout('foo2()', 200)");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void setWriterTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final StringWriter sw = new StringWriter();
-        e.getContext().setWriter(sw);
-
-        try {
-            e.eval("print('hello world')");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-        assertEquals(sw.toString(), println("hello world"));
-    }
-
-    @Test
-    public void redefineEchoTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            e.eval("var echo = {}; if (typeof echo !== 'object') { throw 'echo is a '+typeof echo; }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-    @Test
-    public void noEnumerablePropertiesTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("for (i in this) { throw 'found property: ' + i }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void noRefErrorForGlobalThisAccessTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("this.foo");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void refErrorForUndeclaredAccessTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("try { print(foo); throw 'no ref error' } catch (e) { if (!(e instanceof ReferenceError)) throw e; }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void typeErrorForGlobalThisCallTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("try { this.foo() } catch(e) { if (! (e instanceof TypeError)) throw 'no type error' }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void refErrorForUndeclaredCallTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("try { foo() } catch(e) { if (! (e instanceof ReferenceError)) throw 'no ref error' }");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    // check that print function prints arg followed by newline char
-    public void printTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final StringWriter sw = new StringWriter();
-        e.getContext().setWriter(sw);
-        try {
-            e.eval("print('hello')");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-
-        assertEquals(sw.toString(), println("hello"));
-    }
-
-    @Test
-    // check that print prints all arguments (more than one)
-    public void printManyTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final StringWriter sw = new StringWriter();
-        e.getContext().setWriter(sw);
-        try {
-            e.eval("print(34, true, 'hello')");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-
-        assertEquals(sw.toString(), println("34 true hello"));
-    }
-
-    @Test
-    public void scriptObjectAutoConversionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.eval("obj = { foo: 'hello' }");
-        e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.Window"));
-        assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
-        assertEquals(e.eval("Window.funcScriptObjectMirror(obj)"), "hello");
-        assertEquals(e.eval("Window.funcMap(obj)"), "hello");
-        assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
-    }
-
-    // @bug 8032948: Nashorn linkages awry
-    @Test
-    public void checkProxyAccess() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final boolean[] reached = new boolean[1];
-        final Runnable r = (Runnable)Proxy.newProxyInstance(
-            ScriptEngineTest.class.getClassLoader(),
-            new Class[] { Runnable.class },
-            new InvocationHandler() {
-                @Override
-                public Object invoke(final Object p, final Method mtd, final Object[] a) {
-                    reached[0] = true;
-                    return null;
-                }
-            });
-
-        e.put("r", r);
-        e.eval("r.run()");
-
-        assertTrue(reached[0]);
-    }
-
-    // properties that can be read by any code
-    private static String[] propNames = {
-        "java.version",
-        "java.vendor",
-        "java.vendor.url",
-        "java.class.version",
-        "os.name",
-        "os.version",
-        "os.arch",
-        "file.separator",
-        "path.separator",
-        "line.separator",
-        "java.specification.version",
-        "java.specification.vendor",
-        "java.specification.name",
-        "java.vm.specification.version",
-        "java.vm.specification.vendor",
-        "java.vm.specification.name",
-        "java.vm.version",
-        "java.vm.vendor",
-        "java.vm.name"
-    };
-
-    // @bug 8033924: Default permissions are not given for eval code
-    @Test
-    public void checkPropertyReadPermissions() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        for (final String name : propNames) {
-            checkProperty(e, name);
-        }
-    }
-
-    // @bug 8046013: TypeError: Cannot apply "with" to non script object
-    @Test
-    public void withOnMirrorTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        final Object obj = e.eval("({ foo: 'hello'})");
-        final Object[] arr = new Object[1];
-        arr[0] = obj;
-        e.put("arr", arr);
-        final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res");
-        assertEquals(res, "hello");
-    }
-
-    // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()
-    @Test
-    public void check__DIR__Test() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        e.eval("__DIR__");
-    }
-
-    // @bug 8050432:javax.script.filename variable should not be enumerable
-    // with nashorn engine's ENGINE_SCOPE bindings
-    @Test
-    public void enumerableGlobalsTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        e.put(ScriptEngine.FILENAME, "test");
-        final Object enumerable = e.eval(
-            "Object.getOwnPropertyDescriptor(this, " +
-            " 'javax.script.filename').enumerable");
-        assertEquals(enumerable, Boolean.FALSE);
-    }
-
-    public static class Context {
-        private Object myobj;
-
-        public void set(final Object o) {
-            myobj = o;
-        }
-
-        public Object get() {
-            return myobj;
-        }
-    }
-
-    // @bug 8050977: Java8 Javascript Nashorn exception:
-    // no current Global instance for nashorn
-    @Test
-    public void currentGlobalMissingTest() throws Exception {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine e = manager.getEngineByName("nashorn");
-
-        final Context ctx = new Context();
-        e.put("ctx", ctx);
-        e.eval("var obj = { foo: function(str) { return str.toUpperCase() } }");
-        e.eval("ctx.set(obj)");
-        final Invocable inv = (Invocable)e;
-        assertEquals("HELLO", inv.invokeMethod(ctx.get(), "foo", "hello"));
-        // try object literal
-        e.eval("ctx.set({ bar: function(str) { return str.toLowerCase() } })");
-        assertEquals("hello", inv.invokeMethod(ctx.get(), "bar", "HELLO"));
-        // try array literal
-        e.eval("var arr = [ 'hello', 'world' ]");
-        e.eval("ctx.set(arr)");
-        assertEquals("helloworld", inv.invokeMethod(ctx.get(), "join", ""));
-    }
-
-    // @bug JDK-8068889: ConsString arguments to a functional interface wasn't converted to string.
-    @Test
-    public void functionalInterfaceStringTest() throws Exception {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine e = manager.getEngineByName("nashorn");
-        final AtomicBoolean invoked = new AtomicBoolean(false);
-        e.put("f", new Function<String, String>() {
-            @Override
-            public String apply(String t) {
-                invoked.set(true);
-                return t;
-            }
-        });
-        assertEquals(e.eval("var x = 'a'; x += 'b'; f(x)"), "ab");
-        assertTrue(invoked.get());
-    }
-
-    // @bug JDK-8068889: ScriptObject arguments to a functional interface wasn't converted to a mirror.
-    @Test
-    public void functionalInterfaceObjectTest() throws Exception {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine e = manager.getEngineByName("nashorn");
-        final AtomicBoolean invoked = new AtomicBoolean(false);
-        e.put("c", new Consumer<Object>() {
-            @Override
-            public void accept(Object t) {
-                assertTrue(t instanceof ScriptObjectMirror);
-                assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
-                invoked.set(true);
-            }
-        });
-        e.eval("var x = 'xy'; x += 'z';c({a:x})");
-        assertTrue(invoked.get());
-    }
-
-    private static void checkProperty(final ScriptEngine e, final String name)
-        throws ScriptException {
-        final String value = System.getProperty(name);
-        e.put("name", name);
-        assertEquals(value, e.eval("java.lang.System.getProperty(name)"));
-    }
-
-    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
-    // Returns String that would be the result of calling PrintWriter.println
-    // of the given String. (This is to handle platform specific newline).
-    private static String println(final String str) {
-        return str + LINE_SEPARATOR;
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import javax.script.Bindings;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * Tests to check jdk.nashorn.api.scripting.ScriptObjectMirror API.
- */
-@SuppressWarnings("javadoc")
-public class ScriptObjectMirrorTest {
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void reflectionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        e.eval("var obj = { x: 344, y: 'nashorn' }");
-
-        int count = 0;
-        Map<Object, Object> map = (Map<Object, Object>) e.get("obj");
-        assertFalse(map.isEmpty());
-        assertTrue(map.keySet().contains("x"));
-        assertTrue(map.containsKey("x"));
-        assertTrue(map.values().contains("nashorn"));
-        assertTrue(map.containsValue("nashorn"));
-        for (final Map.Entry<?, ?> ex : map.entrySet()) {
-            final Object key = ex.getKey();
-            if (key.equals("x")) {
-                assertTrue(344 == ((Number) ex.getValue()).doubleValue());
-                count++;
-            } else if (key.equals("y")) {
-                assertEquals(ex.getValue(), "nashorn");
-                count++;
-            }
-        }
-        assertEquals(2, count);
-        assertEquals(2, map.size());
-
-        // add property
-        map.put("z", "hello");
-        assertEquals(e.eval("obj.z"), "hello");
-        assertEquals(map.get("z"), "hello");
-        assertTrue(map.keySet().contains("z"));
-        assertTrue(map.containsKey("z"));
-        assertTrue(map.values().contains("hello"));
-        assertTrue(map.containsValue("hello"));
-        assertEquals(map.size(), 3);
-
-        final Map<Object, Object> newMap = new HashMap<>();
-        newMap.put("foo", 23.0);
-        newMap.put("bar", true);
-        map.putAll(newMap);
-
-        assertEquals(e.eval("obj.foo"), 23.0);
-        assertEquals(e.eval("obj.bar"), true);
-
-        // remove using map method
-        map.remove("foo");
-        assertEquals(e.eval("typeof obj.foo"), "undefined");
-
-        count = 0;
-        e.eval("var arr = [ true, 'hello' ]");
-        map = (Map<Object, Object>) e.get("arr");
-        assertFalse(map.isEmpty());
-        assertTrue(map.containsKey("length"));
-        assertTrue(map.containsValue("hello"));
-        for (final Map.Entry<?, ?> ex : map.entrySet()) {
-            final Object key = ex.getKey();
-            if (key.equals("0")) {
-                assertEquals(ex.getValue(), Boolean.TRUE);
-                count++;
-            } else if (key.equals("1")) {
-                assertEquals(ex.getValue(), "hello");
-                count++;
-            }
-        }
-        assertEquals(count, 2);
-        assertEquals(map.size(), 2);
-
-        // add element
-        map.put("2", "world");
-        assertEquals(map.get("2"), "world");
-        assertEquals(map.size(), 3);
-
-        // remove all
-        map.clear();
-        assertTrue(map.isEmpty());
-        assertEquals(e.eval("typeof arr[0]"), "undefined");
-        assertEquals(e.eval("typeof arr[1]"), "undefined");
-        assertEquals(e.eval("typeof arr[2]"), "undefined");
-    }
-
-    @Test
-    public void jsobjectTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            e.eval("var obj = { '1': 'world', func: function() { return this.bar; }, bar: 'hello' }");
-            final ScriptObjectMirror obj = (ScriptObjectMirror) e.get("obj");
-
-            // try basic get on existing properties
-            if (!obj.getMember("bar").equals("hello")) {
-                fail("obj.bar != 'hello'");
-            }
-
-            if (!obj.getSlot(1).equals("world")) {
-                fail("obj[1] != 'world'");
-            }
-
-            if (!obj.callMember("func", new Object[0]).equals("hello")) {
-                fail("obj.func() != 'hello'");
-            }
-
-            // try setting properties
-            obj.setMember("bar", "new-bar");
-            obj.setSlot(1, "new-element-1");
-            if (!obj.getMember("bar").equals("new-bar")) {
-                fail("obj.bar != 'new-bar'");
-            }
-
-            if (!obj.getSlot(1).equals("new-element-1")) {
-                fail("obj[1] != 'new-element-1'");
-            }
-
-            // try adding properties
-            obj.setMember("prop", "prop-value");
-            obj.setSlot(12, "element-12");
-            if (!obj.getMember("prop").equals("prop-value")) {
-                fail("obj.prop != 'prop-value'");
-            }
-
-            if (!obj.getSlot(12).equals("element-12")) {
-                fail("obj[12] != 'element-12'");
-            }
-
-            // delete properties
-            obj.removeMember("prop");
-            if ("prop-value".equals(obj.getMember("prop"))) {
-                fail("obj.prop is not deleted!");
-            }
-
-            // Simple eval tests
-            assertEquals(obj.eval("typeof Object"), "function");
-            assertEquals(obj.eval("'nashorn'.substring(3)"), "horn");
-        } catch (final Exception exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
-    @Test
-    public void scriptObjectMirrorToStringTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        try {
-            final Object obj = e.eval("new TypeError('wrong type')");
-            assertEquals(obj.toString(), "TypeError: wrong type", "toString returns wrong value");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-
-        try {
-            final Object obj = e.eval("function func() { print('hello'); }");
-            assertEquals(obj.toString(), "function func() { print('hello'); }", "toString returns wrong value");
-        } catch (final Throwable t) {
-            t.printStackTrace();
-            fail(t.getMessage());
-        }
-    }
-
-    @Test
-    public void mirrorNewObjectGlobalFunctionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptEngine e2 = m.getEngineByName("nashorn");
-
-        e.eval("function func() {}");
-        e2.put("foo", e.get("func"));
-        final ScriptObjectMirror e2global = (ScriptObjectMirror)e2.eval("this");
-        final Object newObj = ((ScriptObjectMirror)e2global.getMember("foo")).newObject();
-        assertTrue(newObj instanceof ScriptObjectMirror);
-    }
-
-    @Test
-    public void mirrorNewObjectInstanceFunctionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptEngine e2 = m.getEngineByName("nashorn");
-
-        e.eval("function func() {}");
-        e2.put("func", e.get("func"));
-        final ScriptObjectMirror e2obj = (ScriptObjectMirror)e2.eval("({ foo: func })");
-        final Object newObj = ((ScriptObjectMirror)e2obj.getMember("foo")).newObject();
-        assertTrue(newObj instanceof ScriptObjectMirror);
-    }
-
-    @Test
-    public void indexPropertiesExternalBufferTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptObjectMirror obj = (ScriptObjectMirror)e.eval("var obj = {}; obj");
-        final ByteBuffer buf = ByteBuffer.allocate(5);
-        int i;
-        for (i = 0; i < 5; i++) {
-            buf.put(i, (byte)(i+10));
-        }
-        obj.setIndexedPropertiesToExternalArrayData(buf);
-
-        for (i = 0; i < 5; i++) {
-            assertEquals((byte)(i+10), ((Number)e.eval("obj[" + i + "]")).byteValue());
-        }
-
-        e.eval("for (i = 0; i < 5; i++) obj[i] = 0");
-        for (i = 0; i < 5; i++) {
-            assertEquals((byte)0, ((Number)e.eval("obj[" + i + "]")).byteValue());
-            assertEquals((byte)0, buf.get(i));
-        }
-    }
-
-    @Test
-    public void conversionTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        final ScriptObjectMirror arr = (ScriptObjectMirror)e.eval("[33, 45, 23]");
-        final int[] intArr = arr.to(int[].class);
-        assertEquals(intArr[0], 33);
-        assertEquals(intArr[1], 45);
-        assertEquals(intArr[2], 23);
-
-        final List<?> list = arr.to(List.class);
-        assertEquals(list.get(0), 33);
-        assertEquals(list.get(1), 45);
-        assertEquals(list.get(2), 23);
-
-        ScriptObjectMirror obj = (ScriptObjectMirror)e.eval(
-            "({ valueOf: function() { return 42 } })");
-        assertEquals(Double.valueOf(42.0), obj.to(Double.class));
-
-        obj = (ScriptObjectMirror)e.eval(
-            "({ toString: function() { return 'foo' } })");
-        assertEquals("foo", obj.to(String.class));
-    }
-
-    // @bug 8044000: Access to undefined property yields "null" instead of "undefined"
-    @Test
-    public void mapScriptObjectMirrorCallsiteTest() throws ScriptException {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine engine = m.getEngineByName("nashorn");
-        final String TEST_SCRIPT = "typeof obj.foo";
-
-        final Bindings global = engine.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
-        engine.eval("var obj = java.util.Collections.emptyMap()");
-        // this will drive callsite "obj.foo" of TEST_SCRIPT
-        // to use "obj instanceof Map" as it's guard
-        engine.eval(TEST_SCRIPT, global);
-        // redefine 'obj' to be a script object
-        engine.eval("obj = {}");
-
-        final Bindings newGlobal = engine.createBindings();
-        // transfer 'obj' from default global to new global
-        // new global will get a ScriptObjectMirror wrapping 'obj'
-        newGlobal.put("obj", global.get("obj"));
-
-        // Every ScriptObjectMirror is a Map! If callsite "obj.foo"
-        // does not see the new 'obj' is a ScriptObjectMirror, it'll
-        // continue to use Map's get("obj.foo") instead of ScriptObjectMirror's
-        // getMember("obj.foo") - thereby getting null instead of undefined
-        assertEquals("undefined", engine.eval(TEST_SCRIPT, newGlobal));
-    }
-
-    public interface MirrorCheckExample {
-        Object test1(Object arg);
-        Object test2(Object arg);
-        boolean compare(Object o1, Object o2);
-    }
-
-    // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
-    @Test
-    public void checkMirrorToObject() throws Exception {
-        final ScriptEngineManager engineManager = new ScriptEngineManager();
-        final ScriptEngine engine = engineManager.getEngineByName("nashorn");
-        final Invocable invocable = (Invocable)engine;
-
-        engine.eval("function test1(arg) { return { arg: arg }; }");
-        engine.eval("function test2(arg) { return arg; }");
-        engine.eval("function compare(arg1, arg2) { return arg1 == arg2; }");
-
-        final Map<String, Object> map = new HashMap<>();
-        map.put("option", true);
-
-        final MirrorCheckExample example = invocable.getInterface(MirrorCheckExample.class);
-
-        final Object value1 = invocable.invokeFunction("test1", map);
-        final Object value2 = example.test1(map);
-        final Object value3 = invocable.invokeFunction("test2", value2);
-        final Object value4 = example.test2(value2);
-
-        // check that Object type argument receives a ScriptObjectMirror
-        // when ScriptObject is passed
-        assertEquals(ScriptObjectMirror.class, value1.getClass());
-        assertEquals(ScriptObjectMirror.class, value2.getClass());
-        assertEquals(ScriptObjectMirror.class, value3.getClass());
-        assertEquals(ScriptObjectMirror.class, value4.getClass());
-        assertTrue((boolean)invocable.invokeFunction("compare", value1, value1));
-        assertTrue(example.compare(value1, value1));
-        assertTrue((boolean)invocable.invokeFunction("compare", value3, value4));
-        assertTrue(example.compare(value3, value4));
-    }
-
-    // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
-    @Test
-    public void mirrorUnwrapInterfaceMethod() throws Exception {
-        final ScriptEngineManager engineManager = new ScriptEngineManager();
-        final ScriptEngine engine = engineManager.getEngineByName("nashorn");
-        final Invocable invocable = (Invocable)engine;
-        engine.eval("function apply(obj) { " +
-            " return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " +
-            "}");
-        @SuppressWarnings("unchecked")
-        final Function<Object,Object> func = invocable.getInterface(Function.class);
-        assertFalse((boolean)func.apply(engine.eval("({ x: 2 })")));
-    }
-
-    // @bug 8055687: Wrong "this" passed to JSObject.eval call
-    @Test
-    public void checkThisForJSObjectEval() throws Exception {
-        final ScriptEngineManager engineManager = new ScriptEngineManager();
-        final ScriptEngine e = engineManager.getEngineByName("nashorn");
-        final JSObject jsobj = (JSObject)e.eval("({foo: 23, bar: 'hello' })");
-        assertEquals(((Number)jsobj.eval("this.foo")).intValue(), 23);
-        assertEquals(jsobj.eval("this.bar"), "hello");
-        assertEquals(jsobj.eval("String(this)"), "[object Object]");
-        final Object global = e.eval("this");
-        assertFalse(global.equals(jsobj.eval("this")));
-    }
-
-    @Test
-    public void topLevelAnonFuncStatement() throws Exception {
-        final ScriptEngineManager engineManager = new ScriptEngineManager();
-        final ScriptEngine e = engineManager.getEngineByName("nashorn");
-        final JSObject func = (JSObject)e.eval("function(x) { return x + ' world' }");
-        assertTrue(func.isFunction());
-        assertEquals(func.call(e.eval("this"), "hello"), "hello world");
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-@SuppressWarnings("javadoc")
-public interface VariableArityTestInterface {
-    public String test1(int i, String... strings);
-    public String test2(int i, String... strings);
-}
--- a/test/src/jdk/nashorn/api/scripting/Window.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import java.util.Map;
-import javax.script.Bindings;
-
-@SuppressWarnings("javadoc")
-public class Window {
-
-    private String location = "http://localhost:8080/window";
-
-    private WindowEventHandler onload   = null;
-
-    public void alert(final String message) {
-        System.out.println("alert: " + message);
-    }
-
-    public String getLocation() {
-        return location;
-    }
-
-    public void setLocation(final String location) {
-        this.location = location;
-    }
-
-    public String item(final int index) {
-        return Integer.toHexString(index);
-    }
-
-    public WindowEventHandler getOnload() {
-        return onload;
-    }
-
-    public void setOnload(final WindowEventHandler onload) {
-        this.onload = onload;
-    }
-
-    public static int setTimeout(final Window self, final String code, final int delay) {
-        return self.setTimeout(code, delay);
-    }
-
-    public int setTimeout(final String code, final int delay) {
-        System.out.println("window.setTimeout: " + delay + ", code: " + code);
-        return 0;
-    }
-
-    public static Object funcJSObject(final JSObject jsobj) {
-        return jsobj.getMember("foo");
-    }
-
-    public static Object funcScriptObjectMirror(final ScriptObjectMirror sobj) {
-        return sobj.get("foo");
-    }
-
-    public static Object funcMap(final Map<?,?> map) {
-        return map.get("foo");
-    }
-
-    public static Object funcBindings(final Bindings bindings) {
-        return bindings.get("foo");
-    }
-}
--- a/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-@SuppressWarnings("javadoc")
-public interface WindowEventHandler {
-    public boolean loaded();
-}
--- a/test/src/jdk/nashorn/api/scripting/resources/func.js	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var scopeVar = 1;
-var global = this;
-undefGlobal = this;
-
-function scopeTest() {
-    if (this !== global) {
-        throw new Error("this !== global");
-    }
-    if (this !== undefGlobal) {
-        throw new Error("this !== undefinedGlobal")
-    }
-    return scopeVar;
-}
-
-scopeTest();
--- a/test/src/jdk/nashorn/api/scripting/resources/gettersetter.js	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var v;
-
-Object.defineProperty(this, "accessor1", {
-    get: function() { return v; },
-    set: function(n) { v = n; }
-});
-
-Object.defineProperty(this, "accessor2", {
-    get: function() { return x; },
-    set: function(n) { x = n; }
-});
--- a/test/src/jdk/nashorn/api/scripting/resources/witheval.js	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var a;
-
-function outer(p, e) {
-    eval(e);
-    with(p) {
-        function inner() {
-            a = 1;
-            c = 10;
-            if (a !== 1) {
-                throw new Error("a !== 1");
-            }
-            if (b !== 3) {
-                throw new Error("b !== 3");
-            }
-            if (c !== 10) {
-                throw new Error("c !== 10");
-            }
-        }
-        inner();
-    }
-}
-
-outer({}, "b = 3;");
-
-if (a !== 1) {
-    throw new Error("a !== 1");
-}
-if (b !== 3) {
-    throw new Error("b !== 3");
-}
-if (c !== 10) {
-    throw new Error("c !== 10");
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/InvocableTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,539 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+import java.util.Objects;
+import java.util.function.Function;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for javax.script.Invocable implementation of nashorn.
+ */
+@SuppressWarnings("javadoc")
+public class InvocableTest {
+
+    private static void log(final String msg) {
+        org.testng.Reporter.log(msg, true);
+    }
+
+    @Test
+    public void invokeMethodTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            e.eval("var Example = function() { this.hello = function() { return 'Hello World!'; };}; myExample = new Example();");
+            final Object obj = e.get("myExample");
+            final Object res = ((Invocable) e).invokeMethod(obj, "hello");
+            assertEquals(res, "Hello World!");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    /**
+     * Check that we can call invokeMethod on an object that we got by
+     * evaluating script with different Context set.
+     */
+    public void invokeMethodDifferentContextTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            // define an object with method on it
+            final Object obj = e.eval("({ hello: function() { return 'Hello World!'; } })");
+
+            final ScriptContext ctxt = new SimpleScriptContext();
+            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+            e.setContext(ctxt);
+
+            // invoke 'func' on obj - but with current script context changed
+            final Object res = ((Invocable) e).invokeMethod(obj, "hello");
+            assertEquals(res, "Hello World!");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    /**
+     * Check that invokeMethod throws NPE on null method name.
+     */
+    public void invokeMethodNullNameTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            final Object obj = e.eval("({})");
+            ((Invocable) e).invokeMethod(obj, null);
+            fail("should have thrown NPE");
+        } catch (final Exception exp) {
+            if (!(exp instanceof NullPointerException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that invokeMethod throws NoSuchMethodException on missing method.
+     */
+    public void invokeMethodMissingTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            final Object obj = e.eval("({})");
+            ((Invocable) e).invokeMethod(obj, "nonExistentMethod");
+            fail("should have thrown NoSuchMethodException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof NoSuchMethodException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that calling method on non-script object 'thiz' results in
+     * IllegalArgumentException.
+     */
+    public void invokeMethodNonScriptObjectThizTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable) e).invokeMethod(new Object(), "toString");
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that calling method on null 'thiz' results in
+     * IllegalArgumentException.
+     */
+    public void invokeMethodNullThizTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable) e).invokeMethod(null, "toString");
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that calling method on mirror created by another engine results in
+     * IllegalArgumentException.
+     */
+    public void invokeMethodMixEnginesTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine1 = m.getEngineByName("nashorn");
+        final ScriptEngine engine2 = m.getEngineByName("nashorn");
+
+        try {
+            final Object obj = engine1.eval("({ run: function() {} })");
+            // pass object from engine1 to engine2 as 'thiz' for invokeMethod
+            ((Invocable) engine2).invokeMethod(obj, "run");
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void getInterfaceTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Invocable inv = (Invocable) e;
+
+        // try to get interface from global functions
+        try {
+            e.eval("function run() { print('run'); };");
+            final Runnable runnable = inv.getInterface(Runnable.class);
+            runnable.run();
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+
+        // try interface on specific script object
+        try {
+            e.eval("var obj = { run: function() { print('run from obj'); } };");
+            final Object obj = e.get("obj");
+            final Runnable runnable = inv.getInterface(obj, Runnable.class);
+            runnable.run();
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    public interface Foo {
+
+        public void bar();
+    }
+
+    public interface Foo2 extends Foo {
+
+        public void bar2();
+    }
+
+    @Test
+    public void getInterfaceMissingTest() {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine engine = manager.getEngineByName("nashorn");
+
+        // don't define any function.
+        try {
+            engine.eval("");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+
+        Runnable runnable = ((Invocable) engine).getInterface(Runnable.class);
+        if (runnable != null) {
+            fail("runnable is not null!");
+        }
+
+        // now define "run"
+        try {
+            engine.eval("function run() { print('this is run function'); }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+        runnable = ((Invocable) engine).getInterface(Runnable.class);
+        // should not return null now!
+        runnable.run();
+
+        // define only one method of "Foo2"
+        try {
+            engine.eval("function bar() { print('bar function'); }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+
+        Foo2 foo2 = ((Invocable) engine).getInterface(Foo2.class);
+        if (foo2 != null) {
+            throw new RuntimeException("foo2 is not null!");
+        }
+
+        // now define other method of "Foo2"
+        try {
+            engine.eval("function bar2() { print('bar2 function'); }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+        foo2 = ((Invocable) engine).getInterface(Foo2.class);
+        foo2.bar();
+        foo2.bar2();
+    }
+
+    @Test
+    /**
+     * Try passing non-interface Class object for interface implementation.
+     */
+    public void getNonInterfaceGetInterfaceTest() {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine engine = manager.getEngineByName("nashorn");
+        try {
+            log(Objects.toString(((Invocable) engine).getInterface(Object.class)));
+            fail("Should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                fail("IllegalArgumentException expected, got " + exp);
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that we can get interface out of a script object even after
+     * switching to use different ScriptContext.
+     */
+    public void getInterfaceDifferentContext() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final Object obj = e.eval("({ run: function() { } })");
+
+            // change script context
+            final ScriptContext ctxt = new SimpleScriptContext();
+            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+            e.setContext(ctxt);
+
+            final Runnable r = ((Invocable) e).getInterface(obj, Runnable.class);
+            r.run();
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    /**
+     * Check that getInterface on non-script object 'thiz' results in
+     * IllegalArgumentException.
+     */
+    public void getInterfaceNonScriptObjectThizTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable) e).getInterface(new Object(), Runnable.class);
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that getInterface on null 'thiz' results in
+     * IllegalArgumentException.
+     */
+    public void getInterfaceNullThizTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable) e).getInterface(null, Runnable.class);
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that calling getInterface on mirror created by another engine
+     * results in IllegalArgumentException.
+     */
+    public void getInterfaceMixEnginesTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine1 = m.getEngineByName("nashorn");
+        final ScriptEngine engine2 = m.getEngineByName("nashorn");
+
+        try {
+            final Object obj = engine1.eval("({ run: function() {} })");
+            // pass object from engine1 to engine2 as 'thiz' for getInterface
+            ((Invocable) engine2).getInterface(obj, Runnable.class);
+            fail("should have thrown IllegalArgumentException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof IllegalArgumentException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * check that null function name results in NPE.
+     */
+    public void invokeFunctionNullNameTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable)e).invokeFunction(null);
+            fail("should have thrown NPE");
+        } catch (final Exception exp) {
+            if (!(exp instanceof NullPointerException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that attempt to call missing function results in
+     * NoSuchMethodException.
+     */
+    public void invokeFunctionMissingTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            ((Invocable)e).invokeFunction("NonExistentFunc");
+            fail("should have thrown NoSuchMethodException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof NoSuchMethodException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    /**
+     * Check that invokeFunction calls functions only from current context's
+     * Bindings.
+     */
+    public void invokeFunctionDifferentContextTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            // define an object with method on it
+            e.eval("function hello() { return 'Hello World!'; }");
+            final ScriptContext ctxt = new SimpleScriptContext();
+            ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+            // change engine's current context
+            e.setContext(ctxt);
+
+            ((Invocable) e).invokeFunction("hello"); // no 'hello' in new context!
+            fail("should have thrown NoSuchMethodException");
+        } catch (final Exception exp) {
+            if (!(exp instanceof NoSuchMethodException)) {
+                exp.printStackTrace();
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void invokeFunctionExceptionTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("function func() { throw new TypeError(); }");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+
+        try {
+            ((Invocable) e).invokeFunction("func");
+            fail("should have thrown exception");
+        } catch (final ScriptException se) {
+            // ECMA TypeError property wrapped as a ScriptException
+            log("got " + se + " as expected");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+    }
+
+    @Test
+    public void invokeMethodExceptionTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("var sobj = {}; sobj.foo = function func() { throw new TypeError(); }");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+
+        try {
+            final Object sobj = e.get("sobj");
+            ((Invocable) e).invokeMethod(sobj, "foo");
+            fail("should have thrown exception");
+        } catch (final ScriptException se) {
+            // ECMA TypeError property wrapped as a ScriptException
+            log("got " + se + " as expected");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+    }
+
+    @Test
+    /**
+     * Tests whether invocation of a JavaScript method through a variable arity
+     * Java method will pass the vararg array. Both non-vararg and vararg
+     * JavaScript methods are tested.
+     *
+     * @throws ScriptException
+     */
+    public void variableArityInterfaceTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval(
+                "function test1(i, strings) {"
+                + "    return 'i == ' + i + ', strings instanceof java.lang.String[] == ' + (strings instanceof Java.type('java.lang.String[]')) + ', strings == ' + java.util.Arrays.toString(strings)"
+                + "}"
+                + "function test2() {"
+                + "    return 'arguments[0] == ' + arguments[0] + ', arguments[1] instanceof java.lang.String[] == ' + (arguments[1] instanceof Java.type('java.lang.String[]')) + ', arguments[1] == ' + java.util.Arrays.toString(arguments[1])"
+                + "}");
+        final VariableArityTestInterface itf = ((Invocable) e).getInterface(VariableArityTestInterface.class);
+        Assert.assertEquals(itf.test1(42, "a", "b"), "i == 42, strings instanceof java.lang.String[] == true, strings == [a, b]");
+        Assert.assertEquals(itf.test2(44, "c", "d", "e"), "arguments[0] == 44, arguments[1] instanceof java.lang.String[] == true, arguments[1] == [c, d, e]");
+    }
+
+    @Test
+    public void defaultMethodTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Invocable inv = (Invocable) e;
+
+        final Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})");
+        @SuppressWarnings("unchecked")
+        final Function<String, String> func = inv.getInterface(obj, Function.class);
+        assertEquals(func.apply("hello"), "HELLO");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/MultipleEngineTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.annotations.Test;
+
+/**
+ * Test that we can create multiple, independent script engines and use those
+ * independently.
+ *
+ * @test
+ * @run testng jdk.nashorn.api.scripting.test.MultipleEngineTest
+ */
+@SuppressWarnings("javadoc")
+public class MultipleEngineTest {
+    @Test
+    public void createAndUseManyEngine() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+
+        final ScriptEngine e1 = m.getEngineByName("nashorn");
+        e1.eval("var  x = 33; print(x);");
+
+        final ScriptEngine e2 = m.getEngineByName("nashorn");
+        e2.eval("try { print(x) } catch(e) { print(e); }");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/PluggableJSObjectTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
+import java.nio.IntBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import jdk.nashorn.api.scripting.AbstractJSObject;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for pluggable external impls. of jdk.nashorn.api.scripting.JSObject.
+ *
+ * JDK-8024615: Refactor ScriptObjectMirror and JSObject to support external
+ * JSObject implementations.
+ */
+@SuppressWarnings("javadoc")
+public class PluggableJSObjectTest {
+    public static class MapWrapperObject extends AbstractJSObject {
+        private final HashMap<String, Object> map = new LinkedHashMap<>();
+
+        public HashMap<String, Object> getMap() {
+            return map;
+        }
+
+        @Override
+        public Object getMember(final String name) {
+            return map.get(name);
+        }
+
+        @Override
+        public void setMember(final String name, final Object value) {
+            map.put(name, value);
+        }
+
+        @Override
+        public boolean hasMember(final String name) {
+            return map.containsKey(name);
+        }
+
+        @Override
+        public void removeMember(final String name) {
+            map.remove(name);
+        }
+
+        @Override
+        public Set<String> keySet() {
+            return map.keySet();
+        }
+
+        @Override
+        public Collection<Object> values() {
+            return map.values();
+        }
+    }
+
+    @Test
+    // Named property access on a JSObject
+    public void namedAccessTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final MapWrapperObject obj = new MapWrapperObject();
+            e.put("obj", obj);
+            obj.getMap().put("foo", "bar");
+
+            // property-like access on MapWrapperObject objects
+            assertEquals(e.eval("obj.foo"), "bar");
+            e.eval("obj.foo = 'hello'");
+            assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
+            assertEquals(e.eval("obj.foo"), "hello");
+            assertEquals(obj.getMap().get("foo"), "hello");
+            e.eval("delete obj.foo");
+            assertFalse(obj.getMap().containsKey("foo"));
+            assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    // @bug 8062030: Nashorn bug retrieving array property after key string concatenation
+    @Test
+    // ConsString attribute access on a JSObject
+    public void consStringTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final MapWrapperObject obj = new MapWrapperObject();
+            e.put("obj", obj);
+            e.put("f", "f");
+            e.eval("obj[f + 'oo'] = 'bar';");
+
+            assertEquals(obj.getMap().get("foo"), "bar");
+            assertEquals(e.eval("obj[f + 'oo']"), "bar");
+            assertEquals(e.eval("obj['foo']"), "bar");
+            assertEquals(e.eval("f + 'oo' in obj"), Boolean.TRUE);
+            assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
+            e.eval("delete obj[f + 'oo']");
+            assertFalse(obj.getMap().containsKey("foo"));
+            assertEquals(e.eval("obj[f + 'oo']"), null);
+            assertEquals(e.eval("obj['foo']"), null);
+            assertEquals(e.eval("f + 'oo' in obj"), Boolean.FALSE);
+            assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    public static class BufferObject extends AbstractJSObject {
+        private final IntBuffer buf;
+
+        public BufferObject(final int size) {
+            buf = IntBuffer.allocate(size);
+        }
+
+        public IntBuffer getBuffer() {
+            return buf;
+        }
+
+        @Override
+        public Object getMember(final String name) {
+            return name.equals("length")? buf.capacity() : null;
+        }
+
+        @Override
+        public boolean hasSlot(final int i) {
+            return i > -1 && i < buf.capacity();
+        }
+
+        @Override
+        public Object getSlot(final int i) {
+            return buf.get(i);
+        }
+
+        @Override
+        public void setSlot(final int i, final Object value) {
+            buf.put(i, ((Number)value).intValue());
+        }
+
+        @Override
+        public boolean isArray() {
+            return true;
+        }
+    }
+
+    @Test
+    // array-like indexed access for a JSObject
+    public void indexedAccessTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final BufferObject buf = new BufferObject(2);
+            e.put("buf", buf);
+
+            // array-like access on BufferObject objects
+            assertEquals(e.eval("buf.length"), buf.getBuffer().capacity());
+            e.eval("buf[0] = 23");
+            assertEquals(buf.getBuffer().get(0), 23);
+            assertEquals(e.eval("buf[0]"), 23);
+            assertEquals(e.eval("buf[1]"), 0);
+            buf.getBuffer().put(1, 42);
+            assertEquals(e.eval("buf[1]"), 42);
+            assertEquals(e.eval("Array.isArray(buf)"), Boolean.TRUE);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    public static class Adder extends AbstractJSObject {
+        @Override
+        public Object call(final Object thiz, final Object... args) {
+            double res = 0.0;
+            for (final Object arg : args) {
+                res += ((Number)arg).doubleValue();
+            }
+            return res;
+        }
+
+        @Override
+        public boolean isFunction() {
+            return true;
+        }
+    }
+
+    @Test
+    // a callable JSObject
+    public void callableJSObjectTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.put("sum", new Adder());
+            // check callability of Adder objects
+            assertEquals(e.eval("typeof sum"), "function");
+            assertEquals(((Number)e.eval("sum(1, 2, 3, 4, 5)")).intValue(), 15);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    public static class Factory extends AbstractJSObject {
+        @SuppressWarnings("unused")
+        @Override
+        public Object newObject(final Object... args) {
+            return new HashMap<Object, Object>();
+        }
+
+        @Override
+        public boolean isFunction() {
+            return true;
+        }
+    }
+
+    @Test
+    // a factory JSObject
+    public void factoryJSObjectTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.put("Factory", new Factory());
+
+            // check new on Factory
+            assertEquals(e.eval("typeof Factory"), "function");
+            assertEquals(e.eval("typeof new Factory()"), "object");
+            assertEquals(e.eval("(new Factory()) instanceof java.util.Map"), Boolean.TRUE);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    // iteration tests
+    public void iteratingJSObjectTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final MapWrapperObject obj = new MapWrapperObject();
+            obj.setMember("foo", "hello");
+            obj.setMember("bar", "world");
+            e.put("obj", obj);
+
+            // check for..in
+            Object val = e.eval("var str = ''; for (i in obj) str += i; str");
+            assertEquals(val.toString(), "foobar");
+
+            // check for..each..in
+            val = e.eval("var str = ''; for each (i in obj) str += i; str");
+            assertEquals(val.toString(), "helloworld");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,823 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.api.scripting.URLReader;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for jsr223 Bindings "scope" (engine, global scopes)
+ */
+@SuppressWarnings("javadoc")
+public class ScopeTest {
+
+    @Test
+    public void createBindingsTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        b.put("foo", 42.0);
+        Object res = null;
+        try {
+            res = e.eval("foo == 42.0", b);
+        } catch (final ScriptException | NullPointerException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+
+        assertEquals(res, Boolean.TRUE);
+    }
+
+    @Test
+    public void engineScopeTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings engineScope = e.getBindings(ScriptContext.ENGINE_SCOPE);
+
+        // check few ECMA standard built-in global properties
+        assertNotNull(engineScope.get("Object"));
+        assertNotNull(engineScope.get("TypeError"));
+        assertNotNull(engineScope.get("eval"));
+
+        // can access via ScriptEngine.get as well
+        assertNotNull(e.get("Object"));
+        assertNotNull(e.get("TypeError"));
+        assertNotNull(e.get("eval"));
+
+        // Access by either way should return same object
+        assertEquals(engineScope.get("Array"), e.get("Array"));
+        assertEquals(engineScope.get("EvalError"), e.get("EvalError"));
+        assertEquals(engineScope.get("undefined"), e.get("undefined"));
+
+        // try exposing a new variable from scope
+        engineScope.put("myVar", "foo");
+        try {
+            assertEquals(e.eval("myVar"), "foo");
+        } catch (final ScriptException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+
+        // update "myVar" in script an check the value from scope
+        try {
+            e.eval("myVar = 'nashorn';");
+        } catch (final ScriptException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+
+        // now check modified value from scope and engine
+        assertEquals(engineScope.get("myVar"), "nashorn");
+        assertEquals(e.get("myVar"), "nashorn");
+    }
+
+    @Test
+    public void multiGlobalTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        try {
+            final Object obj1 = e.eval("Object");
+            final Object obj2 = e.eval("Object", newCtxt);
+            Assert.assertNotEquals(obj1, obj2);
+            Assert.assertNotNull(obj1);
+            Assert.assertNotNull(obj2);
+            Assert.assertEquals(obj1.toString(), obj2.toString());
+
+            e.eval("x = 'hello'");
+            e.eval("x = 'world'", newCtxt);
+            Object x1 = e.getContext().getAttribute("x");
+            Object x2 = newCtxt.getAttribute("x");
+            Assert.assertNotEquals(x1, x2);
+            Assert.assertEquals(x1, "hello");
+            Assert.assertEquals(x2, "world");
+
+            x1 = e.eval("x");
+            x2 = e.eval("x", newCtxt);
+            Assert.assertNotEquals(x1, x2);
+            Assert.assertEquals(x1, "hello");
+            Assert.assertEquals(x2, "world");
+
+            final ScriptContext origCtxt = e.getContext();
+            e.setContext(newCtxt);
+            e.eval("y = new Object()");
+            e.eval("y = new Object()", origCtxt);
+
+            final Object y1 = origCtxt.getAttribute("y");
+            final Object y2 = newCtxt.getAttribute("y");
+            Assert.assertNotEquals(y1, y2);
+            final Object yeval1 = e.eval("y");
+            final Object yeval2 = e.eval("y", origCtxt);
+            Assert.assertNotEquals(yeval1, yeval2);
+            Assert.assertEquals("[object Object]", y1.toString());
+            Assert.assertEquals("[object Object]", y2.toString());
+        } catch (final ScriptException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+    }
+
+    @Test
+    public void userEngineScopeBindingsTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval("function func() {}");
+
+        final ScriptContext newContext = new SimpleScriptContext();
+        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+        // we are using a new bindings - so it should have 'func' defined
+        final Object value = e.eval("typeof func", newContext);
+        assertTrue(value.equals("undefined"));
+    }
+
+    @Test
+    public void userEngineScopeBindingsNoLeakTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptContext newContext = new SimpleScriptContext();
+        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+        e.eval("function foo() {}", newContext);
+
+        // in the default context's ENGINE_SCOPE, 'foo' shouldn't exist
+        assertTrue(e.eval("typeof foo").equals("undefined"));
+    }
+
+    @Test
+    public void userEngineScopeBindingsRetentionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptContext newContext = new SimpleScriptContext();
+        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+        e.eval("function foo() {}", newContext);
+
+        // definition retained with user's ENGINE_SCOPE Binding
+        assertTrue(e.eval("typeof foo", newContext).equals("function"));
+
+        final Bindings oldBindings = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
+        // but not in another ENGINE_SCOPE binding
+        newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+        assertTrue(e.eval("typeof foo", newContext).equals("undefined"));
+
+        // restore ENGINE_SCOPE and check again
+        newContext.setBindings(oldBindings, ScriptContext.ENGINE_SCOPE);
+        assertTrue(e.eval("typeof foo", newContext).equals("function"));
+    }
+
+    @Test
+    // check that engine.js definitions are visible in all new global instances
+    public void checkBuiltinsInNewBindingsTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        // check default global instance has engine.js definitions
+        final Bindings g = (Bindings) e.eval("this");
+        Object value = g.get("__noSuchProperty__");
+        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+        value = g.get("print");
+        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+
+        // check new global instance created has engine.js definitions
+        final Bindings b = e.createBindings();
+        value = b.get("__noSuchProperty__");
+        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+        value = b.get("print");
+        assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+
+        // put a mapping into GLOBAL_SCOPE
+        final Bindings globalScope = e.getContext().getBindings(ScriptContext.GLOBAL_SCOPE);
+        globalScope.put("x", "hello");
+
+        // GLOBAL_SCOPE mapping should be visible from default ScriptContext eval
+        assertTrue(e.eval("x").equals("hello"));
+
+        final ScriptContext ctx = new SimpleScriptContext();
+        ctx.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
+        ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
+        assertTrue(e.eval("x", ctx).equals("hello"));
+
+        // try some arbitray Bindings for ENGINE_SCOPE
+        final Bindings sb = new SimpleBindings();
+        ctx.setBindings(sb, ScriptContext.ENGINE_SCOPE);
+
+        // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
+        assertTrue(e.eval("x", ctx).equals("hello"));
+
+        // engine.js builtins are still defined even with arbitrary Bindings
+        assertTrue(e.eval("typeof print", ctx).equals("function"));
+        assertTrue(e.eval("typeof __noSuchProperty__", ctx).equals("function"));
+
+        // ENGINE_SCOPE definition should 'hide' GLOBAL_SCOPE definition
+        sb.put("x", "newX");
+        assertTrue(e.eval("x", ctx).equals("newX"));
+    }
+
+    /**
+     * Test multi-threaded access to defined global variables for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedVarTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        final String sharedScript = "foo";
+
+        assertEquals(e.eval("var foo = 'original context';", origContext), null);
+        assertEquals(e.eval("var foo = 'new context';", newCtxt), null);
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        assertEquals(e.eval("var foo = 'newer context';", newCtxt), null);
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+
+        assertEquals(e.eval(sharedScript), "original context");
+        assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+    }
+
+    /**
+     * Test multi-threaded access to undefined global variables for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedGlobalTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        assertEquals(e.eval("foo = 'original context';", origContext), "original context");
+        assertEquals(e.eval("foo = 'new context';", newCtxt), "new context");
+        final String sharedScript = "foo";
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        final Object obj3 = e.eval("delete foo; foo = 'newer context';", newCtxt);
+        assertEquals(obj3, "newer context");
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+
+        Assert.assertEquals(e.eval(sharedScript), "original context");
+        Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+    }
+
+    /**
+     * Test multi-threaded access using the postfix ++ operator for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedIncTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        assertEquals(e.eval("var x = 0;", origContext), null);
+        assertEquals(e.eval("var x = 2;", newCtxt), null);
+        final String sharedScript = "x++;";
+
+        final Thread t1 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    for (int i = 0; i < 1000; i++) {
+                        assertEquals(e.eval(sharedScript, origContext), (double)i);
+                    }
+                } catch (final ScriptException se) {
+                    fail(se.toString());
+                }
+            }
+        });
+        final Thread t2 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    for (int i = 2; i < 1000; i++) {
+                        assertEquals(e.eval(sharedScript, newCtxt), (double)i);
+                    }
+                } catch (final ScriptException se) {
+                    fail(se.toString());
+                }
+            }
+        });
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+    }
+
+    /**
+     * Test multi-threaded access to primitive prototype properties for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedPrimitiveTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        final Object obj1 = e.eval("String.prototype.foo = 'original context';", origContext);
+        final Object obj2 = e.eval("String.prototype.foo = 'new context';", newCtxt);
+        assertEquals(obj1, "original context");
+        assertEquals(obj2, "new context");
+        final String sharedScript = "''.foo";
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+        assertEquals(obj3, "newer context");
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+
+        Assert.assertEquals(e.eval(sharedScript), "original context");
+        Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+    }
+
+
+    /**
+     * Test multi-threaded access to prototype user accessor properties for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedAccessorTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'original context' })", origContext);
+        e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'new context', configurable: true })", newCtxt);
+        final String sharedScript = "({}).foo";
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        final Object obj3 = e.eval("delete Object.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+        assertEquals(obj3, "newer context");
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+    }
+
+    /**
+     * Test multi-threaded access to primitive prototype user accessor properties for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedPrimitiveAccessorTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'original context' })", origContext);
+        e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'new context' })", newCtxt);
+        final String sharedScript = "''.foo";
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+        assertEquals(obj3, "newer context");
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+    }
+
+    /**
+     * Test multi-threaded scope function invocation for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedFunctionTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), origContext);
+        assertEquals(origContext.getAttribute("scopeVar"), 1);
+        assertEquals(e.eval("scopeTest()"), 1);
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), newCtxt);
+        assertEquals(newCtxt.getAttribute("scopeVar"), 1);
+        assertEquals(e.eval("scopeTest();", newCtxt), 1);
+
+        assertEquals(e.eval("scopeVar = 3;", newCtxt), 3);
+        assertEquals(newCtxt.getAttribute("scopeVar"), 3);
+
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, "scopeTest()", 1, 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, "scopeTest()", 3, 1000));
+
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+    }
+
+    /**
+     * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
+     */
+    @Test
+    public static void getterSetterTest() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        final String sharedScript = "accessor1";
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
+        assertEquals(e.eval("accessor1 = 1;"), 1);
+        assertEquals(e.eval(sharedScript), 1);
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
+        assertEquals(e.eval("accessor1 = 2;", newCtxt), 2);
+        assertEquals(e.eval(sharedScript, newCtxt), 2);
+
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
+
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        assertEquals(e.eval(sharedScript), 1);
+        assertEquals(e.eval(sharedScript, newCtxt), 2);
+        assertEquals(e.eval("v"), 1);
+        assertEquals(e.eval("v", newCtxt), 2);
+    }
+
+    /**
+     * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
+     */
+    @Test
+    public static void getterSetter2Test() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        final String sharedScript = "accessor2";
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
+        assertEquals(e.eval("accessor2 = 1;"), 1);
+        assertEquals(e.eval(sharedScript), 1);
+
+        e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
+        assertEquals(e.eval("accessor2 = 2;", newCtxt), 2);
+        assertEquals(e.eval(sharedScript, newCtxt), 2);
+
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
+
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        assertEquals(e.eval(sharedScript), 1);
+        assertEquals(e.eval(sharedScript, newCtxt), 2);
+        assertEquals(e.eval("x"), 1);
+        assertEquals(e.eval("x", newCtxt), 2);
+    }
+
+    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+    @Test
+    public static void contextOverwriteTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = new SimpleBindings();
+        b.put("context", "hello");
+        b.put("foo", 32);
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        e.setContext(newCtxt);
+        assertEquals(e.eval("context"), "hello");
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+    }
+
+    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+    @Test
+    public static void contextOverwriteInScriptTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.put("foo", 32);
+
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+        assertEquals(e.eval("context = 'bar'"), "bar");
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+    }
+
+    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+    @Test
+    public static void engineOverwriteTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Bindings b = new SimpleBindings();
+        b.put("engine", "hello");
+        b.put("foo", 32);
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        e.setContext(newCtxt);
+        assertEquals(e.eval("engine"), "hello");
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+    }
+
+    // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+    @Test
+    public static void engineOverwriteInScriptTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.put("foo", 32);
+
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+        assertEquals(e.eval("engine = 'bar'"), "bar");
+        assertEquals(((Number)e.eval("foo")).intValue(), 32);
+    }
+
+    // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
+    @Test
+    public static void testMegamorphicGetInGlobal() throws Exception {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine = m.getEngineByName("nashorn");
+        final String script = "foo";
+        // "foo" is megamorphic because of different global scopes.
+        // Make sure ScriptContext variable search works even after
+        // it becomes megamorphic.
+        for (int index = 0; index < 25; index++) {
+            final Bindings bindings = new SimpleBindings();
+            bindings.put("foo", index);
+            final Number value = (Number)engine.eval(script, bindings);
+            assertEquals(index, value.intValue());
+        }
+    }
+
+    /**
+     * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals.
+     * @throws ScriptException
+     * @throws InterruptedException
+     */
+    @Test
+    public static void testSlowScope() throws ScriptException, InterruptedException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        for (int i = 0; i < 100; i++) {
+            final Bindings b = e.createBindings();
+            final ScriptContext ctxt = new SimpleScriptContext();
+            ctxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+            e.eval(new URLReader(ScopeTest.class.getResource("resources/witheval.js")), ctxt);
+            assertEquals(e.eval("a", ctxt), 1);
+            assertEquals(b.get("a"), 1);
+            assertEquals(e.eval("b", ctxt), 3);
+            assertEquals(b.get("b"), 3);
+            assertEquals(e.eval("c", ctxt), 10);
+            assertEquals(b.get("c"), 10);
+        }
+    }
+
+    private static class ScriptRunner implements Runnable {
+
+        final ScriptEngine engine;
+        final ScriptContext context;
+        final String source;
+        final Object expected;
+        final int iterations;
+
+        ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
+            this.engine = engine;
+            this.context = context;
+            this.source = source;
+            this.expected = expected;
+            this.iterations = iterations;
+        }
+
+        @Override
+        public void run() {
+            try {
+                for (int i = 0; i < iterations; i++) {
+                    assertEquals(engine.eval(source, context), expected);
+                }
+            } catch (final ScriptException se) {
+                throw new RuntimeException(se);
+            }
+        }
+    }
+
+    // @bug 8071678: NashornScriptEngine returns javax.script.ScriptContext instance
+    // with get/setAttribute methods insonsistent for GLOBAL_SCOPE
+    @Test
+    public void testGlobalScopeSearch() throws Exception {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptContext c = e.getContext();
+        c.setAttribute("name1234", "value", ScriptContext.GLOBAL_SCOPE);
+        assertEquals(c.getAttribute("name1234"), "value");
+        assertEquals(c.getAttributesScope("name1234"),
+            ScriptContext.GLOBAL_SCOPE);
+    }
+
+    // @bug 8071594: NashornScriptEngine returns javax.script.ScriptContext instance
+    // which doesn't completely conform to the spec regarding exceptions throwing
+    @Test
+    public void testScriptContext_NPE_IAE() throws Exception {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptContext c = e.getContext();
+        try {
+            c.getAttribute("");
+            throw new AssertionError("should have thrown IAE");
+        } catch (IllegalArgumentException iae1) {}
+
+        try {
+            c.getAttribute(null);
+            throw new AssertionError("should have thrown NPE");
+        } catch (NullPointerException npe1) {}
+
+        try {
+            c.getAttribute("", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown IAE");
+        } catch (IllegalArgumentException iae2) {}
+
+        try {
+            c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown NPE");
+        } catch (NullPointerException npe2) {}
+
+        try {
+            c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown IAE");
+        } catch (IllegalArgumentException iae3) {}
+
+        try {
+            c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown NPE");
+        } catch (NullPointerException npe3) {}
+
+        try {
+            c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown IAE");
+        } catch (IllegalArgumentException iae4) {}
+
+        try {
+            c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("should have thrown NPE");
+        } catch (NullPointerException npe4) {}
+
+        try {
+            c.getAttributesScope("");
+            throw new AssertionError("should have thrown IAE");
+        } catch (IllegalArgumentException iae5) {}
+
+        try {
+            c.getAttributesScope(null);
+            throw new AssertionError("should have thrown NPE");
+        } catch (NullPointerException npe5) {}
+    }
+
+    public static class RecursiveEval {
+        private final ScriptEngineFactory factory = new NashornScriptEngineFactory();
+        private final ScriptEngine engine = factory.getScriptEngine();
+        private final Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
+
+        public void program() throws ScriptException {
+            ScriptContext sc = new SimpleScriptContext();
+            Bindings global = new SimpleBindings();
+            sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
+            sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
+            global.put("text", "programText");
+            String value = engine.eval("text", sc).toString();
+            Assert.assertEquals(value, "programText");
+            engine.put("program", this);
+            engine.eval("program.method()");
+            // eval again from here!
+            value = engine.eval("text", sc).toString();
+            Assert.assertEquals(value, "programText");
+        }
+
+        public void method() throws ScriptException {
+            // a context with a new global bindings, same engine bindings
+            final ScriptContext sc = new SimpleScriptContext();
+            final Bindings global = new SimpleBindings();
+            sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
+            sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
+            global.put("text", "methodText");
+            String value = engine.eval("text", sc).toString();
+            Assert.assertEquals(value, "methodText");
+        }
+    }
+
+    // @bug 8081609: engine.eval call from a java method which
+    // was called from a previous engine.eval results in wrong
+    // ScriptContext being used.
+    @Test
+    public void recursiveEvalCallScriptContextTest() throws ScriptException {
+        new RecursiveEval().program();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.fail;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+/**
+ * jsr223 tests for security access checks.
+ */
+@SuppressWarnings("javadoc")
+public class ScriptEngineSecurityTest {
+
+    private static void log(final String msg) {
+        org.testng.Reporter.log(msg, true);
+    }
+
+    @Test
+    public void securityPackagesTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("var v = Packages.sun.misc.Unsafe;");
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (exp instanceof SecurityException) {
+                log("got " + exp + " as expected");
+            } else {
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void securityJavaTypeTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("var v = Java.type('sun.misc.Unsafe');");
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (exp instanceof SecurityException) {
+                log("got " + exp + " as expected");
+            } else {
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void securityClassForNameTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("var v = java.lang.Class.forName('sun.misc.Unsafe');");
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (exp instanceof SecurityException) {
+                log("got " + exp + " as expected");
+            } else {
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void securitySystemExit() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("java.lang.System.exit(0);");
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (exp instanceof SecurityException) {
+                log("got " + exp + " as expected");
+            } else {
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+
+    @Test
+    public void securitySystemExitFromFinalizerThread() throws ScriptException {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval("var o = Java.extend(Java.type('javax.imageio.spi.ServiceRegistry'), { deregisterAll: this.exit.bind(null, 1234)});\n" +
+                "new o(new java.util.ArrayList().iterator())");
+        System.gc();
+        System.runFinalization();
+        // NOTE: this test just exits the VM if it fails.
+    }
+
+    @Test
+    public void securitySystemLoadLibrary() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("java.lang.System.loadLibrary('foo');");
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (exp instanceof SecurityException) {
+                log("got " + exp + " as expected");
+            } else {
+                fail(exp.getMessage());
+            }
+        }
+    }
+
+    // @bug 8032948: Nashorn linkages awry
+    @SuppressWarnings("serial")
+    public static class FakeProxy extends Proxy {
+        public FakeProxy(final InvocationHandler ih) {
+            super(ih);
+        }
+
+        public static Class<?> makeProxyClass(final ClassLoader cl, final Class<?>... ifaces) {
+            return Proxy.getProxyClass(cl, ifaces);
+        }
+    }
+
+    @Test
+    public void fakeProxySubclassAccessCheckTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.put("name", ScriptEngineSecurityTest.class.getName());
+        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+        e.put("intfs", new Class[] { Runnable.class });
+
+        final String getClass = "Java.type(name + '$FakeProxy').getProxyClass(cl, intfs);";
+
+        // Should not be able to call static methods of Proxy via fake subclass
+        try {
+            e.eval(getClass);
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (! (exp instanceof SecurityException)) {
+                fail("SecurityException expected, got " + exp);
+            }
+        }
+    }
+
+    @Test
+    public void fakeProxySubclassAccessCheckTest2() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.put("name", ScriptEngineSecurityTest.class.getName());
+        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+        e.put("intfs", new Class[] { Runnable.class });
+
+        final String getClass = "Java.type(name + '$FakeProxy').makeProxyClass(cl, intfs);";
+
+        // Should not be able to call static methods of Proxy via fake subclass
+        try {
+            e.eval(getClass);
+            fail("should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (! (exp instanceof SecurityException)) {
+                fail("SecurityException expected, got " + exp);
+            }
+        }
+    }
+
+    @Test
+    public static void proxyStaticAccessCheckTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Runnable r = (Runnable)Proxy.newProxyInstance(
+            ScriptEngineTest.class.getClassLoader(),
+            new Class[] { Runnable.class },
+            new InvocationHandler() {
+                @Override
+                public Object invoke(final Object p, final Method mtd, final Object[] a) {
+                    return null;
+                }
+            });
+
+        e.put("rc", r.getClass());
+        e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+        e.put("intfs", new Class[] { Runnable.class });
+
+        // make sure static methods of Proxy is not accessible via subclass
+        try {
+            e.eval("rc.static.getProxyClass(cl, intfs)");
+            fail("Should have thrown SecurityException");
+        } catch (final Exception exp) {
+            if (! (exp instanceof SecurityException)) {
+                fail("SecurityException expected, got " + exp);
+            }
+        }
+    }
+
+
+    @Test
+    public void nashornConfigSecurityTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(new ClassFilter() {
+               @Override
+               public boolean exposeToScripts(final String name) {
+                   return true;
+               }
+            });
+            fail("SecurityException should have been thrown");
+        } catch (final SecurityException e) {
+            //empty
+        }
+    }
+
+    @Test
+    public void nashornConfigSecurityTest2() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(new String[0], null, new ClassFilter() {
+               @Override
+               public boolean exposeToScripts(final String name) {
+                   return true;
+               }
+            });
+            fail("SecurityException should have been thrown");
+        } catch (final SecurityException e) {
+            //empty
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,881 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import javax.script.Bindings;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSR-223 script engine for Nashorn.
+ *
+ * @test
+ * @build jdk.nashorn.api.scripting.test.Window jdk.nashorn.api.scripting.test.WindowEventHandler jdk.nashorn.api.scripting.test.VariableArityTestInterface jdk.nashorn.api.scripting.test.ScriptEngineTest
+ * @run testng/othervm jdk.nashorn.api.scripting.test.ScriptEngineTest
+ */
+@SuppressWarnings("javadoc")
+public class ScriptEngineTest {
+
+    private static void log(final String msg) {
+        org.testng.Reporter.log(msg, true);
+    }
+
+    @Test
+    public void argumentsTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        final String[] args = new String[] { "hello", "world" };
+        try {
+            e.put("arguments", args);
+            final Object arg0 = e.eval("arguments[0]");
+            final Object arg1 = e.eval("arguments[1]");
+            assertEquals(args[0], arg0);
+            assertEquals(args[1], arg1);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void argumentsWithTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        final String[] args = new String[] { "hello", "world" };
+        try {
+            e.put("arguments", args);
+            final Object arg0 = e.eval("var imports = new JavaImporter(java.io); " +
+                    " with(imports) { arguments[0] }");
+            final Object arg1 = e.eval("var imports = new JavaImporter(java.util, java.io); " +
+                    " with(imports) { arguments[1] }");
+            assertEquals(args[0], arg0);
+            assertEquals(args[1], arg1);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void argumentsEmptyTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            assertEquals(e.eval("arguments instanceof Array"), true);
+            assertEquals(e.eval("arguments.length == 0"), true);
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void factoryTests() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        assertNotNull(e);
+
+        final ScriptEngineFactory fac = e.getFactory();
+
+        assertEquals(fac.getLanguageName(), "ECMAScript");
+        assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
+        assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
+        assertEquals(fac.getEngineName(), "Oracle Nashorn");
+        assertEquals(fac.getOutputStatement("context"), "print(context)");
+        assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
+        assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
+
+        boolean seenJS = false;
+        for (final String ext : fac.getExtensions()) {
+            if (ext.equals("js")) {
+                seenJS = true;
+            }
+        }
+
+        assertEquals(seenJS, true);
+        final String str = fac.getMethodCallSyntax("obj", "foo", "x");
+        assertEquals(str, "obj.foo(x)");
+
+        boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
+        for (final String name : fac.getNames()) {
+            switch (name) {
+                case "nashorn": seenNashorn = true; break;
+                case "javascript": seenJavaScript = true; break;
+                case "ECMAScript": seenECMAScript = true; break;
+            default:
+                break;
+            }
+        }
+
+        assertTrue(seenNashorn);
+        assertTrue(seenJavaScript);
+        assertTrue(seenECMAScript);
+
+        boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
+        for (final String mime : fac.getMimeTypes()) {
+            switch (mime) {
+                case "application/javascript": seenAppJS = true; break;
+                case "application/ecmascript": seenAppECMA = true; break;
+                case "text/javascript": seenTextJS = true; break;
+                case "text/ecmascript": seenTextECMA = true; break;
+            default:
+                break;
+            }
+        }
+
+        assertTrue(seenAppJS);
+        assertTrue(seenAppECMA);
+        assertTrue(seenTextJS);
+        assertTrue(seenTextECMA);
+    }
+
+    @Test
+    public void evalTests() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.put(ScriptEngine.FILENAME, "myfile.js");
+
+        try {
+            e.eval("print('hello')");
+        } catch (final ScriptException se) {
+            fail(se.getMessage());
+        }
+        try {
+            e.eval("print('hello)");
+            fail("script exception expected");
+        } catch (final ScriptException se) {
+            assertEquals(se.getLineNumber(), 1);
+            assertEquals(se.getColumnNumber(), 13);
+            assertEquals(se.getFileName(), "myfile.js");
+            // se.printStackTrace();
+        }
+
+        try {
+            Object obj = e.eval("34 + 41");
+            assertTrue(34.0 + 41.0 == ((Number)obj).doubleValue());
+            obj = e.eval("x = 5");
+            assertTrue(5.0 == ((Number)obj).doubleValue());
+        } catch (final ScriptException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+    }
+
+    @Test
+    public void compileTests() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        CompiledScript script = null;
+
+        try {
+            script = ((Compilable)e).compile("print('hello')");
+        } catch (final ScriptException se) {
+            fail(se.getMessage());
+        }
+
+        try {
+            script.eval();
+        } catch (final ScriptException | NullPointerException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+
+        // try to compile from a Reader
+        try {
+            script = ((Compilable)e).compile(new StringReader("print('world')"));
+        } catch (final ScriptException se) {
+            fail(se.getMessage());
+        }
+
+        try {
+            script.eval();
+        } catch (final ScriptException | NullPointerException se) {
+            se.printStackTrace();
+            fail(se.getMessage());
+        }
+    }
+
+    @Test
+    public void compileAndEvalInDiffContextTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine = m.getEngineByName("js");
+        final Compilable compilable = (Compilable) engine;
+        final CompiledScript compiledScript = compilable.compile("foo");
+        final ScriptContext ctxt = new SimpleScriptContext();
+        ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
+        assertEquals(compiledScript.eval(ctxt), "hello");
+    }
+
+    @Test
+    public void accessGlobalTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            e.eval("var x = 'hello'");
+            assertEquals(e.get("x"), "hello");
+        } catch (final ScriptException exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void exposeGlobalTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            e.put("y", "foo");
+            e.eval("print(y)");
+        } catch (final ScriptException exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void putGlobalFunctionTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.put("callable", new Callable<String>() {
+            @Override
+            public String call() throws Exception {
+                return "callable was called";
+            }
+        });
+
+        try {
+            e.eval("print(callable.call())");
+        } catch (final ScriptException exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void windowAlertTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Window window = new Window();
+
+        try {
+            e.put("window", window);
+            e.eval("print(window.alert)");
+            e.eval("window.alert('calling window.alert...')");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void windowLocationTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Window window = new Window();
+
+        try {
+            e.put("window", window);
+            e.eval("print(window.location)");
+            final Object locationValue = e.eval("window.getLocation()");
+            assertEquals(locationValue, "http://localhost:8080/window");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void windowItemTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Window window = new Window();
+
+        try {
+            e.put("window", window);
+            final String item1 = (String)e.eval("window.item(65535)");
+            assertEquals(item1, "ffff");
+            final String item2 = (String)e.eval("window.item(255)");
+            assertEquals(item2, "ff");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void windowEventTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Window window = new Window();
+
+        try {
+            e.put("window", window);
+            e.eval("window.onload = function() { print('window load event fired'); return true }");
+            assertTrue((Boolean)e.eval("window.onload.loaded()"));
+            final WindowEventHandler handler = window.getOnload();
+            assertNotNull(handler);
+            assertTrue(handler.loaded());
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void throwTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.put(ScriptEngine.FILENAME, "throwtest.js");
+
+        try {
+            e.eval("throw 'foo'");
+        } catch (final ScriptException exp) {
+            log(exp.getMessage());
+            assertEquals(exp.getMessage(), "foo in throwtest.js at line number 1 at column number 0");
+            assertEquals(exp.getFileName(), "throwtest.js");
+            assertEquals(exp.getLineNumber(), 1);
+        }
+    }
+
+    @Test
+    public void setTimeoutTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final Window window = new Window();
+
+        try {
+            final Class<?> setTimeoutParamTypes[] = { Window.class, String.class, int.class };
+            final Method setTimeout = Window.class.getDeclaredMethod("setTimeout", setTimeoutParamTypes);
+            assertNotNull(setTimeout);
+            e.put("window", window);
+            e.eval("window.setTimeout('foo()', 100)");
+
+            // try to make setTimeout global
+            e.put("setTimeout", setTimeout);
+            // TODO: java.lang.ClassCastException: required class
+            // java.lang.Integer but encountered class java.lang.Double
+            // e.eval("setTimeout('foo2()', 200)");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void setWriterTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final StringWriter sw = new StringWriter();
+        e.getContext().setWriter(sw);
+
+        try {
+            e.eval("print('hello world')");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+        assertEquals(sw.toString(), println("hello world"));
+    }
+
+    @Test
+    public void redefineEchoTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        try {
+            e.eval("var echo = {}; if (typeof echo !== 'object') { throw 'echo is a '+typeof echo; }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+    @Test
+    public void noEnumerablePropertiesTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("for (i in this) { throw 'found property: ' + i }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void noRefErrorForGlobalThisAccessTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("this.foo");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void refErrorForUndeclaredAccessTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("try { print(foo); throw 'no ref error' } catch (e) { if (!(e instanceof ReferenceError)) throw e; }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void typeErrorForGlobalThisCallTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("try { this.foo() } catch(e) { if (! (e instanceof TypeError)) throw 'no type error' }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void refErrorForUndeclaredCallTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("try { foo() } catch(e) { if (! (e instanceof ReferenceError)) throw 'no ref error' }");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    // check that print function prints arg followed by newline char
+    public void printTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final StringWriter sw = new StringWriter();
+        e.getContext().setWriter(sw);
+        try {
+            e.eval("print('hello')");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+
+        assertEquals(sw.toString(), println("hello"));
+    }
+
+    @Test
+    // check that print prints all arguments (more than one)
+    public void printManyTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final StringWriter sw = new StringWriter();
+        e.getContext().setWriter(sw);
+        try {
+            e.eval("print(34, true, 'hello')");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+
+        assertEquals(sw.toString(), println("34 true hello"));
+    }
+
+    @Test
+    public void scriptObjectAutoConversionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval("obj = { foo: 'hello' }");
+        e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.test.Window"));
+        assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
+        assertEquals(e.eval("Window.funcScriptObjectMirror(obj)"), "hello");
+        assertEquals(e.eval("Window.funcMap(obj)"), "hello");
+        assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
+    }
+
+    // @bug 8032948: Nashorn linkages awry
+    @Test
+    public void checkProxyAccess() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final boolean[] reached = new boolean[1];
+        final Runnable r = (Runnable)Proxy.newProxyInstance(
+            ScriptEngineTest.class.getClassLoader(),
+            new Class[] { Runnable.class },
+            new InvocationHandler() {
+                @Override
+                public Object invoke(final Object p, final Method mtd, final Object[] a) {
+                    reached[0] = true;
+                    return null;
+                }
+            });
+
+        e.put("r", r);
+        e.eval("r.run()");
+
+        assertTrue(reached[0]);
+    }
+
+    // properties that can be read by any code
+    private static String[] propNames = {
+        "java.version",
+        "java.vendor",
+        "java.vendor.url",
+        "java.class.version",
+        "os.name",
+        "os.version",
+        "os.arch",
+        "file.separator",
+        "path.separator",
+        "line.separator",
+        "java.specification.version",
+        "java.specification.vendor",
+        "java.specification.name",
+        "java.vm.specification.version",
+        "java.vm.specification.vendor",
+        "java.vm.specification.name",
+        "java.vm.version",
+        "java.vm.vendor",
+        "java.vm.name"
+    };
+
+    // @bug 8033924: Default permissions are not given for eval code
+    @Test
+    public void checkPropertyReadPermissions() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        for (final String name : propNames) {
+            checkProperty(e, name);
+        }
+    }
+
+    // @bug 8046013: TypeError: Cannot apply "with" to non script object
+    @Test
+    public void withOnMirrorTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        final Object obj = e.eval("({ foo: 'hello'})");
+        final Object[] arr = new Object[1];
+        arr[0] = obj;
+        e.put("arr", arr);
+        final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res");
+        assertEquals(res, "hello");
+    }
+
+    // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()
+    @Test
+    public void check__DIR__Test() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval("__DIR__");
+    }
+
+    // @bug 8050432:javax.script.filename variable should not be enumerable
+    // with nashorn engine's ENGINE_SCOPE bindings
+    @Test
+    public void enumerableGlobalsTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.put(ScriptEngine.FILENAME, "test");
+        final Object enumerable = e.eval(
+            "Object.getOwnPropertyDescriptor(this, " +
+            " 'javax.script.filename').enumerable");
+        assertEquals(enumerable, Boolean.FALSE);
+    }
+
+    public static class Context {
+        private Object myobj;
+
+        public void set(final Object o) {
+            myobj = o;
+        }
+
+        public Object get() {
+            return myobj;
+        }
+    }
+
+    // @bug 8050977: Java8 Javascript Nashorn exception:
+    // no current Global instance for nashorn
+    @Test
+    public void currentGlobalMissingTest() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+
+        final Context ctx = new Context();
+        e.put("ctx", ctx);
+        e.eval("var obj = { foo: function(str) { return str.toUpperCase() } }");
+        e.eval("ctx.set(obj)");
+        final Invocable inv = (Invocable)e;
+        assertEquals("HELLO", inv.invokeMethod(ctx.get(), "foo", "hello"));
+        // try object literal
+        e.eval("ctx.set({ bar: function(str) { return str.toLowerCase() } })");
+        assertEquals("hello", inv.invokeMethod(ctx.get(), "bar", "HELLO"));
+        // try array literal
+        e.eval("var arr = [ 'hello', 'world' ]");
+        e.eval("ctx.set(arr)");
+        assertEquals("helloworld", inv.invokeMethod(ctx.get(), "join", ""));
+    }
+
+    // @bug 8068524: NashornScriptEngineFactory.getParameter() throws IAE
+    // for an unknown key, doesn't conform to the general spec
+    @Test
+    public void getParameterInvalidKeyTest() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+        // no exception expected here!
+        Object value = e.getFactory().getParameter("no value assigned to this key");
+        assertNull(value);
+    }
+
+    // @bug JDK-8068889: ConsString arguments to a functional interface wasn't converted to string.
+    @Test
+    public void functionalInterfaceStringTest() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+        final AtomicBoolean invoked = new AtomicBoolean(false);
+        e.put("f", new Function<String, String>() {
+            @Override
+            public String apply(String t) {
+                invoked.set(true);
+                return t;
+            }
+        });
+        assertEquals(e.eval("var x = 'a'; x += 'b'; f(x)"), "ab");
+        assertTrue(invoked.get());
+    }
+
+    // @bug JDK-8068889: ScriptObject arguments to a functional interface wasn't converted to a mirror.
+    @Test
+    public void functionalInterfaceObjectTest() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+        final AtomicBoolean invoked = new AtomicBoolean(false);
+        e.put("c", new Consumer<Object>() {
+            @Override
+            public void accept(Object t) {
+                assertTrue(t instanceof ScriptObjectMirror);
+                assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
+                invoked.set(true);
+            }
+        });
+        e.eval("var x = 'xy'; x += 'z';c({a:x})");
+        assertTrue(invoked.get());
+    }
+
+    @Test
+    public void testLengthOnArrayLikeObjects() throws Exception {
+        final ScriptEngine e = new ScriptEngineManager().getEngineByName("nashorn");
+        final Object val = e.eval("var arr = { length: 1, 0: 1}; arr.length");
+
+        assertTrue(Number.class.isAssignableFrom(val.getClass()));
+        assertTrue(((Number)val).intValue() == 1);
+    }
+
+    // @bug JDK-8068603: NashornScriptEngine.put/get() impls don't conform to NPE, IAE spec assertions
+    @Test
+    public void illegalBindingsValuesTest() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+
+        try {
+            e.put(null, "null-value");
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            e.put("", "empty-value");
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+
+        final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+        assertTrue(b instanceof ScriptObjectMirror);
+
+        try {
+            b.put(null, "null-value");
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.put("", "empty-value");
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+
+        try {
+            b.get(null);
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.get("");
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+
+        try {
+            b.get(1);
+            fail();
+        } catch (ClassCastException x) {
+            // expected
+        }
+
+        try {
+            b.remove(null);
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.remove("");
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+
+        try {
+            b.remove(1);
+            fail();
+        } catch (ClassCastException x) {
+            // expected
+        }
+
+        try {
+            b.containsKey(null);
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.containsKey("");
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+
+        try {
+            b.containsKey(1);
+            fail();
+        } catch (ClassCastException x) {
+            // expected
+        }
+
+        try {
+            b.putAll(null);
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.putAll(Collections.singletonMap((String)null, "null-value"));
+            fail();
+        } catch (NullPointerException x) {
+            // expected
+        }
+
+        try {
+            b.putAll(Collections.singletonMap("", "empty-value"));
+            fail();
+        } catch (IllegalArgumentException x) {
+            // expected
+        }
+    }
+
+    // @bug 8071989: NashornScriptEngine returns javax.script.ScriptContext instance
+    // with insonsistent get/remove methods behavior for undefined attributes
+    @Test
+    public void testScriptContextGetRemoveUndefined() throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine e = manager.getEngineByName("nashorn");
+        final ScriptContext ctx = e.getContext();
+        assertNull(ctx.getAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+        assertNull(ctx.removeAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+    }
+
+    private static void checkProperty(final ScriptEngine e, final String name)
+        throws ScriptException {
+        final String value = System.getProperty(name);
+        e.put("name", name);
+        assertEquals(value, e.eval("java.lang.System.getProperty(name)"));
+    }
+
+    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+    // Returns String that would be the result of calling PrintWriter.println
+    // of the given String. (This is to handle platform specific newline).
+    private static String println(final String str) {
+        return str + LINE_SEPARATOR;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import javax.script.Bindings;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.testng.annotations.Test;
+
+/**
+ * Tests to check jdk.nashorn.api.scripting.ScriptObjectMirror API.
+ */
+@SuppressWarnings("javadoc")
+public class ScriptObjectMirrorTest {
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void reflectionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.eval("var obj = { x: 344, y: 'nashorn' }");
+
+        int count = 0;
+        Map<Object, Object> map = (Map<Object, Object>) e.get("obj");
+        assertFalse(map.isEmpty());
+        assertTrue(map.keySet().contains("x"));
+        assertTrue(map.containsKey("x"));
+        assertTrue(map.values().contains("nashorn"));
+        assertTrue(map.containsValue("nashorn"));
+        for (final Map.Entry<?, ?> ex : map.entrySet()) {
+            final Object key = ex.getKey();
+            if (key.equals("x")) {
+                assertTrue(344 == ((Number) ex.getValue()).doubleValue());
+                count++;
+            } else if (key.equals("y")) {
+                assertEquals(ex.getValue(), "nashorn");
+                count++;
+            }
+        }
+        assertEquals(2, count);
+        assertEquals(2, map.size());
+
+        // add property
+        map.put("z", "hello");
+        assertEquals(e.eval("obj.z"), "hello");
+        assertEquals(map.get("z"), "hello");
+        assertTrue(map.keySet().contains("z"));
+        assertTrue(map.containsKey("z"));
+        assertTrue(map.values().contains("hello"));
+        assertTrue(map.containsValue("hello"));
+        assertEquals(map.size(), 3);
+
+        final Map<Object, Object> newMap = new HashMap<>();
+        newMap.put("foo", 23.0);
+        newMap.put("bar", true);
+        map.putAll(newMap);
+
+        assertEquals(e.eval("obj.foo"), 23.0);
+        assertEquals(e.eval("obj.bar"), true);
+
+        // remove using map method
+        map.remove("foo");
+        assertEquals(e.eval("typeof obj.foo"), "undefined");
+
+        count = 0;
+        e.eval("var arr = [ true, 'hello' ]");
+        map = (Map<Object, Object>) e.get("arr");
+        assertFalse(map.isEmpty());
+        assertTrue(map.containsKey("length"));
+        assertTrue(map.containsValue("hello"));
+        for (final Map.Entry<?, ?> ex : map.entrySet()) {
+            final Object key = ex.getKey();
+            if (key.equals("0")) {
+                assertEquals(ex.getValue(), Boolean.TRUE);
+                count++;
+            } else if (key.equals("1")) {
+                assertEquals(ex.getValue(), "hello");
+                count++;
+            }
+        }
+        assertEquals(count, 2);
+        assertEquals(map.size(), 2);
+
+        // add element
+        map.put("2", "world");
+        assertEquals(map.get("2"), "world");
+        assertEquals(map.size(), 3);
+
+        // remove all
+        map.clear();
+        assertTrue(map.isEmpty());
+        assertEquals(e.eval("typeof arr[0]"), "undefined");
+        assertEquals(e.eval("typeof arr[1]"), "undefined");
+        assertEquals(e.eval("typeof arr[2]"), "undefined");
+    }
+
+    @Test
+    public void jsobjectTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            e.eval("var obj = { '1': 'world', func: function() { return this.bar; }, bar: 'hello' }");
+            final ScriptObjectMirror obj = (ScriptObjectMirror) e.get("obj");
+
+            // try basic get on existing properties
+            if (!obj.getMember("bar").equals("hello")) {
+                fail("obj.bar != 'hello'");
+            }
+
+            if (!obj.getSlot(1).equals("world")) {
+                fail("obj[1] != 'world'");
+            }
+
+            if (!obj.callMember("func", new Object[0]).equals("hello")) {
+                fail("obj.func() != 'hello'");
+            }
+
+            // try setting properties
+            obj.setMember("bar", "new-bar");
+            obj.setSlot(1, "new-element-1");
+            if (!obj.getMember("bar").equals("new-bar")) {
+                fail("obj.bar != 'new-bar'");
+            }
+
+            if (!obj.getSlot(1).equals("new-element-1")) {
+                fail("obj[1] != 'new-element-1'");
+            }
+
+            // try adding properties
+            obj.setMember("prop", "prop-value");
+            obj.setSlot(12, "element-12");
+            if (!obj.getMember("prop").equals("prop-value")) {
+                fail("obj.prop != 'prop-value'");
+            }
+
+            if (!obj.getSlot(12).equals("element-12")) {
+                fail("obj[12] != 'element-12'");
+            }
+
+            // delete properties
+            obj.removeMember("prop");
+            if ("prop-value".equals(obj.getMember("prop"))) {
+                fail("obj.prop is not deleted!");
+            }
+
+            // Simple eval tests
+            assertEquals(obj.eval("typeof Object"), "function");
+            assertEquals(obj.eval("'nashorn'.substring(3)"), "horn");
+        } catch (final Exception exp) {
+            exp.printStackTrace();
+            fail(exp.getMessage());
+        }
+    }
+
+    @Test
+    public void scriptObjectMirrorToStringTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        try {
+            final Object obj = e.eval("new TypeError('wrong type')");
+            assertEquals(obj.toString(), "TypeError: wrong type", "toString returns wrong value");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+
+        try {
+            final Object obj = e.eval("function func() { print('hello'); }");
+            assertEquals(obj.toString(), "function func() { print('hello'); }", "toString returns wrong value");
+        } catch (final Throwable t) {
+            t.printStackTrace();
+            fail(t.getMessage());
+        }
+    }
+
+    @Test
+    public void mirrorNewObjectGlobalFunctionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptEngine e2 = m.getEngineByName("nashorn");
+
+        e.eval("function func() {}");
+        e2.put("foo", e.get("func"));
+        final ScriptObjectMirror e2global = (ScriptObjectMirror)e2.eval("this");
+        final Object newObj = ((ScriptObjectMirror)e2global.getMember("foo")).newObject();
+        assertTrue(newObj instanceof ScriptObjectMirror);
+    }
+
+    @Test
+    public void mirrorNewObjectInstanceFunctionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptEngine e2 = m.getEngineByName("nashorn");
+
+        e.eval("function func() {}");
+        e2.put("func", e.get("func"));
+        final ScriptObjectMirror e2obj = (ScriptObjectMirror)e2.eval("({ foo: func })");
+        final Object newObj = ((ScriptObjectMirror)e2obj.getMember("foo")).newObject();
+        assertTrue(newObj instanceof ScriptObjectMirror);
+    }
+
+    @Test
+    public void indexPropertiesExternalBufferTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptObjectMirror obj = (ScriptObjectMirror)e.eval("var obj = {}; obj");
+        final ByteBuffer buf = ByteBuffer.allocate(5);
+        int i;
+        for (i = 0; i < 5; i++) {
+            buf.put(i, (byte)(i+10));
+        }
+        obj.setIndexedPropertiesToExternalArrayData(buf);
+
+        for (i = 0; i < 5; i++) {
+            assertEquals((byte)(i+10), ((Number)e.eval("obj[" + i + "]")).byteValue());
+        }
+
+        e.eval("for (i = 0; i < 5; i++) obj[i] = 0");
+        for (i = 0; i < 5; i++) {
+            assertEquals((byte)0, ((Number)e.eval("obj[" + i + "]")).byteValue());
+            assertEquals((byte)0, buf.get(i));
+        }
+    }
+
+    @Test
+    public void conversionTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        final ScriptObjectMirror arr = (ScriptObjectMirror)e.eval("[33, 45, 23]");
+        final int[] intArr = arr.to(int[].class);
+        assertEquals(intArr[0], 33);
+        assertEquals(intArr[1], 45);
+        assertEquals(intArr[2], 23);
+
+        final List<?> list = arr.to(List.class);
+        assertEquals(list.get(0), 33);
+        assertEquals(list.get(1), 45);
+        assertEquals(list.get(2), 23);
+
+        ScriptObjectMirror obj = (ScriptObjectMirror)e.eval(
+            "({ valueOf: function() { return 42 } })");
+        assertEquals(Double.valueOf(42.0), obj.to(Double.class));
+
+        obj = (ScriptObjectMirror)e.eval(
+            "({ toString: function() { return 'foo' } })");
+        assertEquals("foo", obj.to(String.class));
+    }
+
+    // @bug 8044000: Access to undefined property yields "null" instead of "undefined"
+    @Test
+    public void mapScriptObjectMirrorCallsiteTest() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine engine = m.getEngineByName("nashorn");
+        final String TEST_SCRIPT = "typeof obj.foo";
+
+        final Bindings global = engine.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
+        engine.eval("var obj = java.util.Collections.emptyMap()");
+        // this will drive callsite "obj.foo" of TEST_SCRIPT
+        // to use "obj instanceof Map" as it's guard
+        engine.eval(TEST_SCRIPT, global);
+        // redefine 'obj' to be a script object
+        engine.eval("obj = {}");
+
+        final Bindings newGlobal = engine.createBindings();
+        // transfer 'obj' from default global to new global
+        // new global will get a ScriptObjectMirror wrapping 'obj'
+        newGlobal.put("obj", global.get("obj"));
+
+        // Every ScriptObjectMirror is a Map! If callsite "obj.foo"
+        // does not see the new 'obj' is a ScriptObjectMirror, it'll
+        // continue to use Map's get("obj.foo") instead of ScriptObjectMirror's
+        // getMember("obj.foo") - thereby getting null instead of undefined
+        assertEquals("undefined", engine.eval(TEST_SCRIPT, newGlobal));
+    }
+
+    public interface MirrorCheckExample {
+        Object test1(Object arg);
+        Object test2(Object arg);
+        boolean compare(Object o1, Object o2);
+    }
+
+    // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
+    @Test
+    public void checkMirrorToObject() throws Exception {
+        final ScriptEngineManager engineManager = new ScriptEngineManager();
+        final ScriptEngine engine = engineManager.getEngineByName("nashorn");
+        final Invocable invocable = (Invocable)engine;
+
+        engine.eval("function test1(arg) { return { arg: arg }; }");
+        engine.eval("function test2(arg) { return arg; }");
+        engine.eval("function compare(arg1, arg2) { return arg1 == arg2; }");
+
+        final Map<String, Object> map = new HashMap<>();
+        map.put("option", true);
+
+        final MirrorCheckExample example = invocable.getInterface(MirrorCheckExample.class);
+
+        final Object value1 = invocable.invokeFunction("test1", map);
+        final Object value2 = example.test1(map);
+        final Object value3 = invocable.invokeFunction("test2", value2);
+        final Object value4 = example.test2(value2);
+
+        // check that Object type argument receives a ScriptObjectMirror
+        // when ScriptObject is passed
+        assertEquals(ScriptObjectMirror.class, value1.getClass());
+        assertEquals(ScriptObjectMirror.class, value2.getClass());
+        assertEquals(ScriptObjectMirror.class, value3.getClass());
+        assertEquals(ScriptObjectMirror.class, value4.getClass());
+        assertTrue((boolean)invocable.invokeFunction("compare", value1, value1));
+        assertTrue(example.compare(value1, value1));
+        assertTrue((boolean)invocable.invokeFunction("compare", value3, value4));
+        assertTrue(example.compare(value3, value4));
+    }
+
+    // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
+    @Test
+    public void mirrorUnwrapInterfaceMethod() throws Exception {
+        final ScriptEngineManager engineManager = new ScriptEngineManager();
+        final ScriptEngine engine = engineManager.getEngineByName("nashorn");
+        final Invocable invocable = (Invocable)engine;
+        engine.eval("function apply(obj) { " +
+            " return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " +
+            "}");
+        @SuppressWarnings("unchecked")
+        final Function<Object,Object> func = invocable.getInterface(Function.class);
+        assertFalse((boolean)func.apply(engine.eval("({ x: 2 })")));
+    }
+
+    // @bug 8055687: Wrong "this" passed to JSObject.eval call
+    @Test
+    public void checkThisForJSObjectEval() throws Exception {
+        final ScriptEngineManager engineManager = new ScriptEngineManager();
+        final ScriptEngine e = engineManager.getEngineByName("nashorn");
+        final JSObject jsobj = (JSObject)e.eval("({foo: 23, bar: 'hello' })");
+        assertEquals(((Number)jsobj.eval("this.foo")).intValue(), 23);
+        assertEquals(jsobj.eval("this.bar"), "hello");
+        assertEquals(jsobj.eval("String(this)"), "[object Object]");
+        final Object global = e.eval("this");
+        assertFalse(global.equals(jsobj.eval("this")));
+    }
+
+    @Test
+    public void topLevelAnonFuncStatement() throws Exception {
+        final ScriptEngineManager engineManager = new ScriptEngineManager();
+        final ScriptEngine e = engineManager.getEngineByName("nashorn");
+        final JSObject func = (JSObject)e.eval("function(x) { return x + ' world' }");
+        assertTrue(func.isFunction());
+        assertEquals(func.call(e.eval("this"), "hello"), "hello world");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/VariableArityTestInterface.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+@SuppressWarnings("javadoc")
+public interface VariableArityTestInterface {
+    public String test1(int i, String... strings);
+    public String test2(int i, String... strings);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/Window.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import java.util.Map;
+import javax.script.Bindings;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+
+@SuppressWarnings("javadoc")
+public class Window {
+
+    private String location = "http://localhost:8080/window";
+
+    private WindowEventHandler onload   = null;
+
+    public void alert(final String message) {
+        System.out.println("alert: " + message);
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(final String location) {
+        this.location = location;
+    }
+
+    public String item(final int index) {
+        return Integer.toHexString(index);
+    }
+
+    public WindowEventHandler getOnload() {
+        return onload;
+    }
+
+    public void setOnload(final WindowEventHandler onload) {
+        this.onload = onload;
+    }
+
+    public static int setTimeout(final Window self, final String code, final int delay) {
+        return self.setTimeout(code, delay);
+    }
+
+    public int setTimeout(final String code, final int delay) {
+        System.out.println("window.setTimeout: " + delay + ", code: " + code);
+        return 0;
+    }
+
+    public static Object funcJSObject(final JSObject jsobj) {
+        return jsobj.getMember("foo");
+    }
+
+    public static Object funcScriptObjectMirror(final ScriptObjectMirror sobj) {
+        return sobj.get("foo");
+    }
+
+    public static Object funcMap(final Map<?,?> map) {
+        return map.get("foo");
+    }
+
+    public static Object funcBindings(final Bindings bindings) {
+        return bindings.get("foo");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/WindowEventHandler.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+@SuppressWarnings("javadoc")
+public interface WindowEventHandler {
+    public boolean loaded();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/resources/func.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var scopeVar = 1;
+var global = this;
+undefGlobal = this;
+
+function scopeTest() {
+    if (this !== global) {
+        throw new Error("this !== global");
+    }
+    if (this !== undefGlobal) {
+        throw new Error("this !== undefinedGlobal")
+    }
+    return scopeVar;
+}
+
+scopeTest();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/resources/gettersetter.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var v;
+
+Object.defineProperty(this, "accessor1", {
+    get: function() { return v; },
+    set: function(n) { v = n; }
+});
+
+Object.defineProperty(this, "accessor2", {
+    get: function() { return x; },
+    set: function(n) { x = n; }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/scripting/test/resources/witheval.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var a;
+
+function outer(p, e) {
+    eval(e);
+    with(p) {
+        function inner() {
+            a = 1;
+            c = 10;
+            if (a !== 1) {
+                throw new Error("a !== 1");
+            }
+            if (b !== 3) {
+                throw new Error("b !== 3");
+            }
+            if (c !== 10) {
+                throw new Error("c !== 10");
+            }
+        }
+        inner();
+    }
+}
+
+outer({}, "b = 3;");
+
+if (a !== 1) {
+    throw new Error("a !== 1");
+}
+if (b !== 3) {
+    throw new Error("b !== 3");
+}
+if (c !== 10) {
+    throw new Error("c !== 10");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/test/NashornSQLDriver.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.test;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * A dummy SQL driver for testing purpose.
+ */
+public final class NashornSQLDriver implements Driver {
+    static {
+        try {
+            DriverManager.registerDriver(new NashornSQLDriver(), null);
+        } catch (final SQLException se) {
+            throw new RuntimeException(se);
+        }
+    }
+
+    @Override
+    public boolean acceptsURL(final String url) {
+        return url.startsWith("jdbc:nashorn:");
+    }
+
+    @Override
+    public Connection connect(final String url, final Properties info) {
+        throw new UnsupportedOperationException("I am a dummy!!");
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return -1;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return -1;
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
+        return new DriverPropertyInfo[0];
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        // no way!
+        return false;
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new SQLFeatureNotSupportedException();
+    }
+}
--- a/test/src/jdk/nashorn/internal/codegen/CompilerTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.codegen;
-
-import static jdk.nashorn.internal.runtime.Source.readFully;
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import jdk.nashorn.internal.objects.Global;
-import jdk.nashorn.internal.runtime.Context;
-import jdk.nashorn.internal.runtime.ErrorManager;
-import jdk.nashorn.internal.runtime.ScriptFunction;
-import jdk.nashorn.internal.runtime.Source;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests to check Nashorn JS compiler - just compiler and not execution of scripts.
- */
-@SuppressWarnings("javadoc")
-public class CompilerTest {
-    private static final boolean VERBOSE  = Boolean.valueOf(System.getProperty("compilertest.verbose"));
-    private static final boolean TEST262  = Boolean.valueOf(System.getProperty("compilertest.test262"));
-    private static final String TEST_BASIC_DIR  = System.getProperty("test.basic.dir");
-    private static final String TEST_NODE_DIR  = System.getProperty("test.node.dir");
-    private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
-
-    interface TestFilter {
-        public boolean exclude(File file, String content);
-    }
-
-    private static void log(final String msg) {
-        org.testng.Reporter.log(msg, true);
-    }
-
-    private Context context;
-    private Global  global;
-
-    @BeforeClass
-    public void setupTest() {
-        final Options options = new Options("nashorn");
-        options.set("anon.functions", true);
-        options.set("compile.only", true);
-        options.set("print.ast", true);
-        options.set("print.parse", true);
-        options.set("scripting", true);
-        options.set("const.as.var", true);
-        options.set("verify.code", true);
-
-        final ErrorManager errors = new ErrorManager() {
-            @Override
-            public void error(final String msg) {
-                log(msg);
-            }
-        };
-
-        final StringWriter sw = new StringWriter();
-        final PrintWriter pw = new PrintWriter(sw);
-        this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
-        this.global = context.createGlobal();
-    }
-
-    @AfterClass
-    public void tearDownTest() {
-        this.context = null;
-        this.global = null;
-    }
-
-    @Test
-    public void compileAllTests() {
-        if (TEST262) {
-            compileTestSet(new File(TEST262_SUITE_DIR), new TestFilter() {
-                @Override
-                public boolean exclude(final File file, final String content) {
-                    return content != null && content.contains("@negative");
-                }
-            });
-        }
-        compileTestSet(new File(TEST_BASIC_DIR), new TestFilter() {
-            @Override
-            public boolean exclude(final File file, final String content) {
-                return file.getName().equals("es6");
-            }
-        });
-        compileTestSet(new File(TEST_NODE_DIR, "node"), null);
-        compileTestSet(new File(TEST_NODE_DIR, "src"), null);
-    }
-
-    private void compileTestSet(final File testSetDir, final TestFilter filter) {
-        passed = 0;
-        failed = 0;
-        skipped = 0;
-        if (! testSetDir.isDirectory()) {
-            log("WARNING: " + testSetDir + " not found or not a directory");
-            return;
-        }
-        log(testSetDir.getAbsolutePath());
-        compileJSDirectory(testSetDir, filter);
-
-        log(testSetDir + " compile done!");
-        log("compile ok: " + passed);
-        log("compile failed: " + failed);
-        log("compile skipped: " + skipped);
-        if (failed != 0) {
-            Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
-        }
-    }
-
-    // number of scripts that compiled fine
-    private int passed;
-    // number of scripts resulting in compile failure
-    private int failed;
-    // scripts that were skipped - all tests with @negative are
-    // skipped for now.
-    private int skipped;
-
-    private void compileJSDirectory(final File dir, final TestFilter filter) {
-        if (filter != null && filter.exclude(dir, null)) {
-            return;
-        }
-        for (final File f : dir.listFiles()) {
-            if (f.isDirectory()) {
-                compileJSDirectory(f, filter);
-            } else if (f.getName().endsWith(".js")) {
-                compileJSFile(f, filter);
-            }
-        }
-    }
-
-    private void compileJSFile(final File file, final TestFilter filter) {
-        if (VERBOSE) {
-            log("Begin compiling " + file.getAbsolutePath());
-        }
-
-        final Global oldGlobal = Context.getGlobal();
-        final boolean globalChanged = (oldGlobal != global);
-
-        try {
-            final char[] buffer = readFully(file);
-            boolean excluded = false;
-
-            if (filter != null) {
-                final String content = new String(buffer);
-                excluded = filter.exclude(file, content);
-            }
-
-            if (excluded) {
-                if (VERBOSE) {
-                    log("Skipping " + file.getAbsolutePath());
-                }
-                skipped++;
-                return;
-            }
-
-            if (globalChanged) {
-                Context.setGlobal(global);
-            }
-            final Source source = sourceFor(file.getAbsolutePath(), buffer);
-            final ScriptFunction script = context.compileScript(source, global);
-            if (script == null || context.getErrorManager().getNumberOfErrors() > 0) {
-                log("Compile failed: " + file.getAbsolutePath());
-                failed++;
-            } else {
-                passed++;
-            }
-        } catch (final Throwable t) {
-            log("Compile failed: " + file.getAbsolutePath() + " : " + t);
-            if (VERBOSE) {
-                t.printStackTrace(System.out);
-            }
-            failed++;
-        } finally {
-            if (globalChanged) {
-                Context.setGlobal(oldGlobal);
-            }
-        }
-
-        if (VERBOSE) {
-            log("Done compiling " + file.getAbsolutePath());
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/codegen/test/CompilerTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.codegen.test;
+
+import static jdk.nashorn.internal.runtime.Source.readFully;
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.ScriptFunction;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests to check Nashorn JS compiler - just compiler and not execution of scripts.
+ */
+@SuppressWarnings("javadoc")
+public class CompilerTest {
+    private static final boolean VERBOSE  = Boolean.valueOf(System.getProperty("compilertest.verbose"));
+    private static final boolean TEST262  = Boolean.valueOf(System.getProperty("compilertest.test262"));
+    private static final String TEST_BASIC_DIR  = System.getProperty("test.basic.dir");
+    private static final String TEST_NODE_DIR  = System.getProperty("test.node.dir");
+    private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
+
+    interface TestFilter {
+        public boolean exclude(File file, String content);
+    }
+
+    private static void log(final String msg) {
+        org.testng.Reporter.log(msg, true);
+    }
+
+    private Context context;
+    private Global  global;
+
+    @BeforeClass
+    public void setupTest() {
+        final Options options = new Options("nashorn");
+        options.set("anon.functions", true);
+        options.set("compile.only", true);
+        options.set("print.ast", true);
+        options.set("print.parse", true);
+        options.set("scripting", true);
+        options.set("const.as.var", true);
+        options.set("verify.code", true);
+
+        final ErrorManager errors = new ErrorManager() {
+            @Override
+            public void error(final String msg) {
+                log(msg);
+            }
+        };
+
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+        this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
+        this.global = context.createGlobal();
+    }
+
+    @AfterClass
+    public void tearDownTest() {
+        this.context = null;
+        this.global = null;
+    }
+
+    @Test
+    public void compileAllTests() {
+        if (TEST262) {
+            compileTestSet(new File(TEST262_SUITE_DIR), new TestFilter() {
+                @Override
+                public boolean exclude(final File file, final String content) {
+                    return content != null && content.contains("@negative");
+                }
+            });
+        }
+        compileTestSet(new File(TEST_BASIC_DIR), new TestFilter() {
+            @Override
+            public boolean exclude(final File file, final String content) {
+                return file.getName().equals("es6");
+            }
+        });
+        compileTestSet(new File(TEST_NODE_DIR, "node"), null);
+        compileTestSet(new File(TEST_NODE_DIR, "src"), null);
+    }
+
+    private void compileTestSet(final File testSetDir, final TestFilter filter) {
+        passed = 0;
+        failed = 0;
+        skipped = 0;
+        if (! testSetDir.isDirectory()) {
+            log("WARNING: " + testSetDir + " not found or not a directory");
+            return;
+        }
+        log(testSetDir.getAbsolutePath());
+        compileJSDirectory(testSetDir, filter);
+
+        log(testSetDir + " compile done!");
+        log("compile ok: " + passed);
+        log("compile failed: " + failed);
+        log("compile skipped: " + skipped);
+        if (failed != 0) {
+            Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
+        }
+    }
+
+    // number of scripts that compiled fine
+    private int passed;
+    // number of scripts resulting in compile failure
+    private int failed;
+    // scripts that were skipped - all tests with @negative are
+    // skipped for now.
+    private int skipped;
+
+    private void compileJSDirectory(final File dir, final TestFilter filter) {
+        if (filter != null && filter.exclude(dir, null)) {
+            return;
+        }
+        for (final File f : dir.listFiles()) {
+            if (f.isDirectory()) {
+                compileJSDirectory(f, filter);
+            } else if (f.getName().endsWith(".js")) {
+                compileJSFile(f, filter);
+            }
+        }
+    }
+
+    private void compileJSFile(final File file, final TestFilter filter) {
+        if (VERBOSE) {
+            log("Begin compiling " + file.getAbsolutePath());
+        }
+
+        final Global oldGlobal = Context.getGlobal();
+        final boolean globalChanged = (oldGlobal != global);
+
+        try {
+            final char[] buffer = readFully(file);
+            boolean excluded = false;
+
+            if (filter != null) {
+                final String content = new String(buffer);
+                excluded = filter.exclude(file, content);
+            }
+
+            if (excluded) {
+                if (VERBOSE) {
+                    log("Skipping " + file.getAbsolutePath());
+                }
+                skipped++;
+                return;
+            }
+
+            if (globalChanged) {
+                Context.setGlobal(global);
+            }
+            final Source source = sourceFor(file.getAbsolutePath(), buffer);
+            final ScriptFunction script = context.compileScript(source, global);
+            if (script == null || context.getErrorManager().getNumberOfErrors() > 0) {
+                log("Compile failed: " + file.getAbsolutePath());
+                failed++;
+            } else {
+                passed++;
+            }
+        } catch (final Throwable t) {
+            log("Compile failed: " + file.getAbsolutePath() + " : " + t);
+            if (VERBOSE) {
+                t.printStackTrace(System.out);
+            }
+            failed++;
+        } finally {
+            if (globalChanged) {
+                Context.setGlobal(oldGlobal);
+            }
+        }
+
+        if (VERBOSE) {
+            log("Done compiling " + file.getAbsolutePath());
+        }
+    }
+}
--- a/test/src/jdk/nashorn/internal/parser/ParserTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.parser;
-
-import static jdk.nashorn.internal.runtime.Source.readFully;
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import java.io.File;
-import jdk.nashorn.internal.runtime.Context;
-import jdk.nashorn.internal.runtime.ErrorManager;
-import jdk.nashorn.internal.runtime.Source;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Run tests to check Nashorn's parser.
- */
-@SuppressWarnings("javadoc")
-public class ParserTest {
-    private static final boolean VERBOSE   = Boolean.valueOf(System.getProperty("parsertest.verbose"));
-    private static final boolean TEST262   = Boolean.valueOf(System.getProperty("parsertest.test262"));
-
-    private static final String TEST_BASIC_DIR  = System.getProperty("test.basic.dir");
-    private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
-
-
-    interface TestFilter {
-        public boolean exclude(File file, String content);
-    }
-
-    private static void log(final String msg) {
-        org.testng.Reporter.log(msg, true);
-    }
-
-    private Context context;
-
-    @BeforeClass
-    public void setupTest() {
-        final Options options = new Options("nashorn");
-        options.set("anon.functions", true);
-        options.set("parse.only", true);
-        options.set("scripting", true);
-        options.set("const.as.var", true);
-
-        final ErrorManager errors = new ErrorManager();
-        this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
-    }
-
-    @AfterClass
-    public void tearDownTest() {
-        this.context = null;
-    }
-
-    @Test
-    public void parseAllTests() {
-        if (TEST262) {
-            parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
-                @Override
-                public boolean exclude(final File file, final String content) {
-                    return content != null && content.contains("@negative");
-                }
-            });
-        }
-        parseTestSet(TEST_BASIC_DIR,  new TestFilter() {
-            @Override
-            public boolean exclude(final File file, final String content) {
-                return file.getName().equals("es6");
-            }
-        });
-    }
-
-    private void parseTestSet(final String testSet, final TestFilter filter) {
-        passed  = 0;
-        failed  = 0;
-        skipped = 0;
-
-        final File testSetDir = new File(testSet);
-        if (! testSetDir.isDirectory()) {
-            log("WARNING: " + testSetDir + " not found or not a directory");
-            return;
-        }
-        log(testSetDir.getAbsolutePath());
-        parseJSDirectory(testSetDir, filter);
-
-        log(testSet + " parse done!");
-        log("parse ok: " + passed);
-        log("parse failed: " + failed);
-        log("parse skipped: " + skipped);
-        if (failed != 0) {
-            Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
-        }
-    }
-
-    // number of scripts that parsed fine
-    private int passed;
-    // number of scripts resulting in parse failure
-    private int failed;
-    // scripts that were skipped - all tests with @negative are
-    // skipped for now.
-    private int skipped;
-
-    private void parseJSDirectory(final File dir, final TestFilter filter) {
-        if (filter != null && filter.exclude(dir, null)) {
-            return;
-        }
-        for (final File f : dir.listFiles()) {
-            if (f.isDirectory()) {
-                parseJSDirectory(f, filter);
-            } else if (f.getName().endsWith(".js")) {
-                parseJSFile(f, filter);
-            }
-        }
-    }
-
-    private void parseJSFile(final File file, final TestFilter filter) {
-        if (VERBOSE) {
-            log("Begin parsing " + file.getAbsolutePath());
-        }
-
-        try {
-            final char[] buffer = readFully(file);
-            boolean excluded = false;
-            if (filter != null) {
-                final String content = new String(buffer);
-                excluded = filter.exclude(file, content);
-            }
-
-            if (excluded) {
-                if (VERBOSE) {
-                    log("Skipping " + file.getAbsolutePath());
-                }
-                skipped++;
-                return;
-            }
-
-            final ErrorManager errors = new ErrorManager() {
-                @Override
-                public void error(final String msg) {
-                    log(msg);
-                }
-            };
-            errors.setLimit(0);
-            final Source source = sourceFor(file.getAbsolutePath(), buffer);
-            new Parser(context.getEnv(), source, errors, context.getEnv()._strict, null).parse();
-            if (errors.getNumberOfErrors() > 0) {
-                log("Parse failed: " + file.getAbsolutePath());
-                failed++;
-            } else {
-                passed++;
-            }
-        } catch (final Throwable exp) {
-            exp.printStackTrace();
-            log("Parse failed: " + file.getAbsolutePath() + " : " + exp);
-            if (VERBOSE) {
-                exp.printStackTrace(System.out);
-            }
-            failed++;
-        }
-
-        if (VERBOSE) {
-            log("Done parsing " + file.getAbsolutePath());
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/parser/test/ParserTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.parser.test;
+
+import static jdk.nashorn.internal.runtime.Source.readFully;
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import java.io.File;
+import jdk.nashorn.internal.parser.Parser;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Run tests to check Nashorn's parser.
+ */
+@SuppressWarnings("javadoc")
+public class ParserTest {
+    private static final boolean VERBOSE   = Boolean.valueOf(System.getProperty("parsertest.verbose"));
+    private static final boolean TEST262   = Boolean.valueOf(System.getProperty("parsertest.test262"));
+
+    private static final String TEST_BASIC_DIR  = System.getProperty("test.basic.dir");
+    private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
+
+
+    interface TestFilter {
+        public boolean exclude(File file, String content);
+    }
+
+    private static void log(final String msg) {
+        org.testng.Reporter.log(msg, true);
+    }
+
+    private Context context;
+
+    @BeforeClass
+    public void setupTest() {
+        final Options options = new Options("nashorn");
+        options.set("anon.functions", true);
+        options.set("parse.only", true);
+        options.set("scripting", true);
+        options.set("const.as.var", true);
+
+        final ErrorManager errors = new ErrorManager();
+        this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+    }
+
+    @AfterClass
+    public void tearDownTest() {
+        this.context = null;
+    }
+
+    @Test
+    public void parseAllTests() {
+        if (TEST262) {
+            parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
+                @Override
+                public boolean exclude(final File file, final String content) {
+                    return content != null && content.contains("@negative");
+                }
+            });
+        }
+        parseTestSet(TEST_BASIC_DIR,  new TestFilter() {
+            @Override
+            public boolean exclude(final File file, final String content) {
+                return file.getName().equals("es6");
+            }
+        });
+    }
+
+    private void parseTestSet(final String testSet, final TestFilter filter) {
+        passed  = 0;
+        failed  = 0;
+        skipped = 0;
+
+        final File testSetDir = new File(testSet);
+        if (! testSetDir.isDirectory()) {
+            log("WARNING: " + testSetDir + " not found or not a directory");
+            return;
+        }
+        log(testSetDir.getAbsolutePath());
+        parseJSDirectory(testSetDir, filter);
+
+        log(testSet + " parse done!");
+        log("parse ok: " + passed);
+        log("parse failed: " + failed);
+        log("parse skipped: " + skipped);
+        if (failed != 0) {
+            Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
+        }
+    }
+
+    // number of scripts that parsed fine
+    private int passed;
+    // number of scripts resulting in parse failure
+    private int failed;
+    // scripts that were skipped - all tests with @negative are
+    // skipped for now.
+    private int skipped;
+
+    private void parseJSDirectory(final File dir, final TestFilter filter) {
+        if (filter != null && filter.exclude(dir, null)) {
+            return;
+        }
+        for (final File f : dir.listFiles()) {
+            if (f.isDirectory()) {
+                parseJSDirectory(f, filter);
+            } else if (f.getName().endsWith(".js")) {
+                parseJSFile(f, filter);
+            }
+        }
+    }
+
+    private void parseJSFile(final File file, final TestFilter filter) {
+        if (VERBOSE) {
+            log("Begin parsing " + file.getAbsolutePath());
+        }
+
+        try {
+            final char[] buffer = readFully(file);
+            boolean excluded = false;
+            if (filter != null) {
+                final String content = new String(buffer);
+                excluded = filter.exclude(file, content);
+            }
+
+            if (excluded) {
+                if (VERBOSE) {
+                    log("Skipping " + file.getAbsolutePath());
+                }
+                skipped++;
+                return;
+            }
+
+            final ErrorManager errors = new ErrorManager() {
+                @Override
+                public void error(final String msg) {
+                    log(msg);
+                }
+            };
+            errors.setLimit(0);
+            final Source source = sourceFor(file.getAbsolutePath(), buffer);
+            new Parser(context.getEnv(), source, errors, context.getEnv()._strict, null).parse();
+            if (errors.getNumberOfErrors() > 0) {
+                log("Parse failed: " + file.getAbsolutePath());
+                failed++;
+            } else {
+                passed++;
+            }
+        } catch (final Throwable exp) {
+            exp.printStackTrace();
+            log("Parse failed: " + file.getAbsolutePath() + " : " + exp);
+            if (VERBOSE) {
+                exp.printStackTrace(System.out);
+            }
+            failed++;
+        }
+
+        if (VERBOSE) {
+            log("Done parsing " + file.getAbsolutePath());
+        }
+    }
+}
--- a/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.fail;
-import java.io.File;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.ClassFilter;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import jdk.nashorn.api.scripting.URLReader;
-import jdk.nashorn.internal.test.framework.TestFinder;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ClassFilterTest {
-    private static final String NASHORN_CODE_CACHE = "nashorn.persistent.code.cache";
-    private static final String CLASSFILTER_CODE_CACHE = "build/classfilter_nashorn_code_cache";
-
-    // @Test
-    // This test takes too much time for basic "ant clean test" run.
-    // Given that "allow-all-java-classes" is equivalent to no java class
-    // filter and external tests don't access any java, not sure if this
-    // test contributes much. We need faster "ant clean test" cycle for
-    // developers.
-    public void runExternalJsTest() {
-        final String[] paths = new String[]{
-                "test/script/basic/compile-octane.js",
-                "test/script/basic/jquery.js",
-                "test/script/basic/prototype.js",
-                "test/script/basic/runsunspider.js",
-                "test/script/basic/underscore.js",
-                "test/script/basic/yui.js",
-                "test/script/basic/run-octane.js"
-        };
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        for (final String path : paths) {
-            final ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter());
-            try {
-                engine.eval(new URLReader(new File(path).toURI().toURL()));
-            } catch (final Exception e) {
-                fail("Script " + path + " fails with exception :" + e.getMessage());
-            }
-        }
-    }
-
-    @Test
-    public void noJavaOptionTest() {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter());
-        try {
-            engine.eval("var str = Java.type('java.lang.String');");
-            fail("TypeError should have been thrown");
-        } catch (final ScriptException e) {
-            //emtpy
-        }
-    }
-
-    @Test
-    public void securityTest() {
-        if (System.getSecurityManager() == null) {
-            return;
-        }
-
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine engine = factory.getScriptEngine(getClassFilter());
-        try {
-            engine.eval("var thread = Java.type('sun.misc.Unsafe')");
-            fail("SecurityException should have been thrown");
-        } catch (final Exception e) {
-            //empty
-        }
-        try {
-            engine.eval("var thread = new sun.misc.Unsafe()");
-            fail("SecurityException should have been thrown");
-        } catch (final Exception e) {
-            //empty
-        }
-        try {
-            engine.eval("var thread = Java.extend(sun.misc.Unsafe, {})");
-            fail("TypeError should have been thrown");
-        } catch (final Exception e) {
-            //empty
-        }
-        try {
-            engine.eval("java.lang.System.exit(0)");
-            fail("SecurityException should have been thrown");
-        } catch (final Exception e) {
-            //empty
-        }
-
-    }
-
-    @Test
-    public void persistentCacheTest() {
-        final String oldCodeCache = System.getProperty(NASHORN_CODE_CACHE);
-        System.setProperty(NASHORN_CODE_CACHE, CLASSFILTER_CODE_CACHE);
-        try {
-            persistentCacheTestImpl();
-        } finally {
-            if (oldCodeCache != null) {
-                System.setProperty(NASHORN_CODE_CACHE, oldCodeCache);
-            }
-        }
-    }
-
-    private void persistentCacheTestImpl() {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine engine = factory.getScriptEngine(
-              TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
-                  getClass().getClassLoader(),
-                  getClassFilter()
-        );
-        final String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore();
-        try {
-            engine.eval(testScript);
-        } catch (final ScriptException exc) {
-            fail(exc.getMessage());
-        }
-        final ScriptEngine engineSafe = factory.getScriptEngine(
-                TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
-                getClass().getClassLoader(),
-                new ClassFilter() {
-                    @Override
-                    public boolean exposeToScripts(final String s) {
-                        return false;
-                    }
-                }
-        );
-        try {
-            engineSafe.eval(testScript);
-            fail("ClassNotFoundException should have been thrown");
-        } catch (final Exception exc) {
-            if (!(exc.getCause() instanceof ClassNotFoundException)) {
-                fail("ClassNotFoundException expected, got " + exc.getClass());
-            }
-        }
-    }
-
-    private static String generateCodeForPersistentStore() {
-        final StringBuilder stringBuilder = new StringBuilder();
-        for (int i=0; i < 100; i++) {
-            stringBuilder.append("function i")
-                    .append(i)
-                    .append("(y, z) { var x")
-                    .append(i)
-                    .append(" = ")
-                    .append(i)
-                    .append(";}");
-        }
-        return stringBuilder.toString();
-    }
-
-    private static ClassFilter getClassFilter() {
-        return new ClassFilter() {
-            @Override
-            public boolean exposeToScripts(final String s) {
-                return true;
-            }
-        };
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @bug 8039185 8039403
- * @summary  Test for persistent code cache and path handling
- * @run testng jdk.nashorn.internal.runtime.CodeStoreAndPathTest
- */
-@SuppressWarnings("javadoc")
-public class CodeStoreAndPathTest {
-
-    final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
-                + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
-                + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
-                + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
-                + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';"
-                + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}";
-    final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
-                + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
-                + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
-                + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
-                + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';"
-                + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}"
-                + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
-                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
-                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
-                + "var x10 = 'Hello Script';}";
-    // Script size < Default minimum size for storing a compiled script class
-    final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
-    final String codeCache = "build/nashorn_code_cache";
-    final String oldUserDir = System.getProperty("user.dir");
-
-    private static final String[] ENGINE_OPTIONS_OPT   = new String[]{"--persistent-code-cache", "--optimistic-types=true"};
-    private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"};
-
-    @Test
-    public void pathHandlingTest() {
-        System.setProperty("nashorn.persistent.code.cache", codeCache);
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-
-        fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
-
-        final Path expectedCodeCachePath = FileSystems.getDefault().getPath(oldUserDir + File.separator + codeCache);
-        final Path actualCodeCachePath = FileSystems.getDefault().getPath(System.getProperty(
-                            "nashorn.persistent.code.cache")).toAbsolutePath();
-        // Check that nashorn code cache is created in current working directory
-        assertEquals(actualCodeCachePath, expectedCodeCachePath);
-        // Check that code cache dir exists and it's not empty
-        final File file = new File(actualCodeCachePath.toUri());
-        assertFalse(!file.isDirectory(), "No code cache directory was created!");
-        assertFalse(file.list().length == 0, "Code cache directory is empty!");
-    }
-
-    @Test
-    public void changeUserDirTest() throws ScriptException, IOException {
-        System.setProperty("nashorn.persistent.code.cache", codeCache);
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
-        final Path codeCachePath = getCodeCachePath(false);
-        final String newUserDir = "build/newUserDir";
-        // Now changing current working directory
-        System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir);
-        try {
-            // Check that a new compiled script is stored in existing code cache
-            e.eval(code1);
-            final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
-            checkCompiledScripts(stream, 1);
-            // Setting to default current working dir
-        } finally {
-            System.setProperty("user.dir", oldUserDir);
-        }
-    }
-
-    @Test
-    public void codeCacheTest() throws ScriptException, IOException {
-        System.setProperty("nashorn.persistent.code.cache", codeCache);
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
-        final Path codeCachePath = getCodeCachePath(false);
-        e.eval(code1);
-        e.eval(code2);
-        e.eval(code3);// less than minimum size for storing
-        // adding code1 and code2.
-        final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
-        checkCompiledScripts(stream, 2);
-    }
-
-    @Test
-    public void codeCacheTestOpt() throws ScriptException, IOException {
-        System.setProperty("nashorn.persistent.code.cache", codeCache);
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_OPT);
-        final Path codeCachePath = getCodeCachePath(true);
-        e.eval(code1);
-        e.eval(code2);
-        e.eval(code3);// less than minimum size for storing
-        // adding code1 and code2.
-        final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
-        checkCompiledScripts(stream, 2);
-    }
-
-    private static Path getCodeCachePath(final boolean optimistic) {
-        final String codeCache = System.getProperty("nashorn.persistent.code.cache");
-        final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath();
-        final String[] files = codeCachePath.toFile().list();
-        for (final String file : files) {
-            if (file.endsWith("_opt") == optimistic) {
-                return codeCachePath.resolve(file);
-            }
-        }
-        throw new AssertionError("Code cache path not found");
-    }
-
-    private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException {
-        int n = numberOfScripts;
-        for (@SuppressWarnings("unused") final Path file : stream) {
-            n--;
-        }
-        stream.close();
-        assertEquals(n, 0);
-    }
-
-}
--- a/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSType methods.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ConsStringTest
- */
-public class ConsStringTest {
-
-    /**
-     * Test toString conversion
-     */
-    @Test
-    public void testConsStringToString() {
-        final ConsString cs1 = new ConsString("b", "c");
-        final ConsString cs2 = new ConsString("d", "e");
-        final ConsString cs3 = new ConsString(cs1, cs2);
-        final ConsString cs4 = new ConsString(cs3, "f");
-        final ConsString cs5 = new ConsString("a", cs4);
-        assertEquals(cs5.toString(), "abcdef");
-        assertEquals(cs4.toString(), "bcdef");
-        assertEquals(cs3.toString(), "bcde");
-        assertEquals(cs2.toString(), "de");
-        assertEquals(cs1.toString(), "bc");
-        // ConsStrings should be flattened now
-        assertEquals(cs1.getComponents()[0], "bc");
-        assertEquals(cs1.getComponents()[1], "");
-        assertEquals(cs2.getComponents()[0], "de");
-        assertEquals(cs2.getComponents()[1], "");
-        assertEquals(cs3.getComponents()[0], "bcde");
-        assertEquals(cs3.getComponents()[1], "");
-        assertEquals(cs4.getComponents()[0], "bcdef");
-        assertEquals(cs4.getComponents()[1], "");
-        assertEquals(cs5.getComponents()[0], "abcdef");
-        assertEquals(cs5.getComponents()[1], "");
-    }
-
-    /**
-     * Test charAt
-     */
-    @Test
-    public void testConsStringCharAt() {
-        final ConsString cs1 = new ConsString("b", "c");
-        final ConsString cs2 = new ConsString("d", "e");
-        final ConsString cs3 = new ConsString(cs1, cs2);
-        final ConsString cs4 = new ConsString(cs3, "f");
-        final ConsString cs5 = new ConsString("a", cs4);
-        assertEquals(cs1.charAt(1), 'c');
-        assertEquals(cs2.charAt(0), 'd');
-        assertEquals(cs3.charAt(3), 'e');
-        assertEquals(cs4.charAt(1), 'c');
-        assertEquals(cs5.charAt(2), 'c');
-        // ConsStrings should be flattened now
-        assertEquals(cs1.getComponents()[0], "bc");
-        assertEquals(cs1.getComponents()[1], "");
-        assertEquals(cs2.getComponents()[0], "de");
-        assertEquals(cs2.getComponents()[1], "");
-        assertEquals(cs3.getComponents()[0], "bcde");
-        assertEquals(cs3.getComponents()[1], "");
-        assertEquals(cs4.getComponents()[0], "bcdef");
-        assertEquals(cs4.getComponents()[1], "");
-        assertEquals(cs5.getComponents()[0], "abcdef");
-        assertEquals(cs5.getComponents()[1], "");
-    }
-
-
-    /**
-     * Test flattening of top-level and internal ConsStrings
-     */
-    @Test
-    public void testConsStringFlattening() {
-        final ConsString cs1 = new ConsString("b", "c");
-        final ConsString cs2 = new ConsString("d", "e");
-        final ConsString cs3 = new ConsString(cs1, cs2);
-        final ConsString cs4 = new ConsString(cs3, "f");
-
-        final ConsString cs5 = new ConsString("a", cs4);
-        // top-level ConsString should not yet be flattened
-        assert(cs5.getComponents()[0] == "a");
-        assert(cs5.getComponents()[1] == cs4);
-        assertEquals(cs5.toString(), "abcdef");
-        // top-level ConsString should be flattened
-        assertEquals(cs5.getComponents()[0], "abcdef");
-        assertEquals(cs5.getComponents()[1], "");
-        // internal ConsString should not yet be flattened after first traversal
-        assertEquals(cs4.getComponents()[0], cs3);
-        assertEquals(cs4.getComponents()[1], "f");
-
-        final ConsString cs6 = new ConsString("a", cs4);
-        // top-level ConsString should not yet be flattened
-        assertEquals(cs6.getComponents()[0], "a");
-        assertEquals(cs6.getComponents()[1], cs4);
-        assertEquals(cs6.toString(), "abcdef");
-        // top-level ConsString should be flattened
-        assertEquals(cs6.getComponents()[0], "abcdef");
-        assertEquals(cs6.getComponents()[1], "");
-        // internal ConsString should have been flattened after second traversal
-        assertEquals(cs4.getComponents()[0], "bcdef");
-        assertEquals(cs4.getComponents()[1], "");
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/ContextTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import java.util.Map;
-import jdk.nashorn.internal.objects.Global;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.annotations.Test;
-
-/**
- * Basic Context API tests.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ContextTest
- */
-@SuppressWarnings("javadoc")
-public class ContextTest {
-    // basic context eval test
-    @Test
-    public void evalTest() {
-        final Options options = new Options("");
-        final ErrorManager errors = new ErrorManager();
-        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
-        final Global oldGlobal = Context.getGlobal();
-        Context.setGlobal(cx.createGlobal());
-        try {
-            String code = "22 + 10";
-            assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
-
-            code = "obj = { js: 'nashorn' }; obj.js";
-            assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
-        } finally {
-            Context.setGlobal(oldGlobal);
-        }
-    }
-
-    // Make sure trying to compile an invalid script returns null - see JDK-8046215.
-    @Test
-    public void compileErrorTest() {
-        final Options options = new Options("");
-        final ErrorManager errors = new ErrorManager();
-        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
-        final Global oldGlobal = Context.getGlobal();
-        Context.setGlobal(cx.createGlobal());
-        try {
-            final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
-            if (script != null) {
-                fail("Invalid script compiled without errors");
-            }
-            if (errors.getNumberOfErrors() != 1) {
-                fail("Wrong number of errors: " + errors.getNumberOfErrors());
-            }
-        } finally {
-            Context.setGlobal(oldGlobal);
-        }
-    }
-
-    // basic check for JS reflection access - java.util.Map-like access on ScriptObject
-    @Test
-    public void reflectionTest() {
-        final Options options = new Options("");
-        final ErrorManager errors = new ErrorManager();
-        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
-        final boolean strict = cx.getEnv()._strict;
-        final Global oldGlobal = Context.getGlobal();
-        Context.setGlobal(cx.createGlobal());
-
-        try {
-            final String code = "var obj = { x: 344, y: 42 }";
-            eval(cx, "<reflectionTest>", code);
-
-            final Object obj = Context.getGlobal().get("obj");
-
-            assertTrue(obj instanceof ScriptObject);
-
-            final ScriptObject sobj = (ScriptObject)obj;
-            int count = 0;
-            for (final Map.Entry<?, ?> ex : sobj.entrySet()) {
-                final Object key = ex.getKey();
-                if (key.equals("x")) {
-                    assertTrue(ex.getValue() instanceof Number);
-                    assertTrue(344.0 == ((Number)ex.getValue()).doubleValue());
-
-                    count++;
-                } else if (key.equals("y")) {
-                    assertTrue(ex.getValue() instanceof Number);
-                    assertTrue(42.0 == ((Number)ex.getValue()).doubleValue());
-
-                    count++;
-                }
-            }
-            assertEquals(count, 2);
-            assertEquals(sobj.size(), 2);
-
-            // add property
-            sobj.put("zee", "hello", strict);
-            assertEquals(sobj.get("zee"), "hello");
-            assertEquals(sobj.size(), 3);
-
-        } finally {
-            Context.setGlobal(oldGlobal);
-        }
-    }
-
-    private static Object eval(final Context cx, final String name, final String code) {
-        final Source source = sourceFor(name, code);
-        final ScriptObject global = Context.getGlobal();
-        final ScriptFunction func = cx.compileScript(source, global);
-        return func != null ? ScriptRuntime.apply(func, global) : null;
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.io.ObjectOutputStream;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * JDK-8044518: Ensure exceptions related to optimistic recompilation are not serializable
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ExceptionsNotSerializable
- */
-@SuppressWarnings("javadoc")
-public class ExceptionsNotSerializable {
-    @Test
-    public void rewriteExceptionNotSerializable() throws ScriptException {
-        // NOTE: we must create a RewriteException in a context of a Nashorn engine, as it uses Global.newIntance()
-        // internally.
-        final ScriptEngine e = new NashornScriptEngineFactory().getScriptEngine();
-        e.put("f", new Runnable() {
-            @Override
-            public void run() {
-                tryToSerialize(RewriteException.create(null, new Object[0], new String[0]));
-            }
-        });
-        e.eval("f()");
-    }
-
-    @Test
-    public void unwarrantedOptimismExceptionNotSerializable() {
-        tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128));
-    }
-
-    private static void tryToSerialize(final Object obj) {
-        try {
-            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(obj);
-            fail();
-        } catch (final NotSerializableException e) {
-            assertEquals(e.getMessage(), obj.getClass().getName());
-        } catch (final IOException e) {
-            fail("", e);
-        }
-
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/JSTypeTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSType methods.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.JSTypeTest
- */
-public class JSTypeTest {
-    /**
-     * Test of isPrimitive method, of class Runtime.
-     */
-    @Test
-    public void testIsPrimitive() {
-        assertTrue(JSType.isPrimitive(null));
-        assertTrue(JSType.isPrimitive(ScriptRuntime.UNDEFINED));
-        assertTrue(JSType.isPrimitive(Double.NaN));
-        assertTrue(JSType.isPrimitive(Double.NEGATIVE_INFINITY));
-        assertTrue(JSType.isPrimitive(Double.POSITIVE_INFINITY));
-        assertTrue(JSType.isPrimitive(0.0));
-        assertTrue(JSType.isPrimitive(3.14));
-        assertTrue(JSType.isPrimitive("hello"));
-        assertTrue(JSType.isPrimitive(""));
-        assertFalse(JSType.isPrimitive(new Object()));
-    }
-
-    /**
-     * Test of toBoolean method, of class Runtime.
-     */
-    @Test
-    public void testToBoolean() {
-        assertFalse(JSType.toBoolean(ScriptRuntime.UNDEFINED));
-        assertFalse(JSType.toBoolean(null));
-        assertFalse(JSType.toBoolean(Boolean.FALSE));
-        assertTrue(JSType.toBoolean(Boolean.TRUE));
-        assertFalse(JSType.toBoolean(-0.0));
-        assertFalse(JSType.toBoolean(0.0));
-        assertFalse(JSType.toBoolean(Double.NaN));
-        assertTrue(JSType.toBoolean(3.14));
-        assertFalse(JSType.toBoolean(""));
-        assertTrue(JSType.toBoolean("javascript"));
-        assertTrue(JSType.toBoolean(new Object()));
-    }
-
-    /**
-     * Test of toNumber method, of class Runtime.
-     */
-    @Test
-    public void testToNumber_Object() {
-        assertTrue(Double.isNaN(JSType.toNumber(ScriptRuntime.UNDEFINED)));
-        assertEquals(JSType.toNumber((Object)null), 0.0, 0.0);
-        assertEquals(JSType.toNumber(Boolean.TRUE), 1.0, 0.0);
-        assertEquals(JSType.toNumber(Boolean.FALSE), 0.0, 0.0);
-        assertEquals(JSType.toNumber(3.14), 3.14, 0.0);
-        // FIXME: add more assertions for specific String to number cases
-        // FIXME: add case for Object type (JSObject with getDefaultValue)
-    }
-
-    /**
-     * Test of toString method, of class Runtime.
-     */
-    @Test
-    public void testToString_Object() {
-        assertEquals(JSType.toString(ScriptRuntime.UNDEFINED), "undefined");
-        assertEquals(JSType.toString(null), "null");
-        assertEquals(JSType.toString(Boolean.TRUE), "true");
-        assertEquals(JSType.toString(Boolean.FALSE), "false");
-        assertEquals(JSType.toString(""), "");
-        assertEquals(JSType.toString("nashorn"), "nashorn");
-        assertEquals(JSType.toString(Double.NaN), "NaN");
-        assertEquals(JSType.toString(Double.POSITIVE_INFINITY), "Infinity");
-        assertEquals(JSType.toString(Double.NEGATIVE_INFINITY), "-Infinity");
-        assertEquals(JSType.toString(0.0), "0");
-        // FIXME: add more number-to-string test cases
-        // FIXME: add case for Object type (JSObject with getDefaultValue)
-    }
-
-    /**
-     * Test of JSType.toUint32(double)
-     */
-    @Test
-    public void testToUint32() {
-        assertEquals(JSType.toUint32(+0.0), 0);
-        assertEquals(JSType.toUint32(-0.0), 0);
-        assertEquals(JSType.toUint32(Double.NaN), 0);
-        assertEquals(JSType.toUint32(Double.POSITIVE_INFINITY), 0);
-        assertEquals(JSType.toUint32(Double.NEGATIVE_INFINITY), 0);
-        assertEquals(JSType.toUint32(9223372036854775807.0d), 0);
-        assertEquals(JSType.toUint32(-9223372036854775807.0d), 0);
-        assertEquals(JSType.toUint32(1099511627776.0d), 0);
-        assertEquals(JSType.toUint32(-1099511627776.0d), 0);
-        assertEquals(JSType.toUint32(4294967295.0d), 4294967295l);
-        assertEquals(JSType.toUint32(4294967296.0d), 0);
-        assertEquals(JSType.toUint32(4294967297.0d), 1);
-        assertEquals(JSType.toUint32(-4294967295.0d), 1);
-        assertEquals(JSType.toUint32(-4294967296.0d), 0);
-        assertEquals(JSType.toUint32(-4294967297.0d), 4294967295l);
-        assertEquals(JSType.toUint32(4294967295.6d), 4294967295l);
-        assertEquals(JSType.toUint32(4294967296.6d), 0);
-        assertEquals(JSType.toUint32(4294967297.6d), 1);
-        assertEquals(JSType.toUint32(-4294967295.6d), 1);
-        assertEquals(JSType.toUint32(-4294967296.6d), 0);
-        assertEquals(JSType.toUint32(-4294967297.6d), 4294967295l);
-    }
-
-    /**
-     * Test of JSType.toInt32(double)
-     */
-    @Test
-    public void testToInt32() {
-        assertEquals(JSType.toInt32(+0.0), 0);
-        assertEquals(JSType.toInt32(-0.0), 0);
-        assertEquals(JSType.toInt32(Double.NaN), 0);
-        assertEquals(JSType.toInt32(Double.POSITIVE_INFINITY), 0);
-        assertEquals(JSType.toInt32(Double.NEGATIVE_INFINITY), 0);
-        assertEquals(JSType.toInt32(9223372036854775807.0d), 0);
-        assertEquals(JSType.toInt32(-9223372036854775807.0d), 0);
-        assertEquals(JSType.toInt32(1099511627776.0d), 0);
-        assertEquals(JSType.toInt32(-1099511627776.0d), 0);
-        assertEquals(JSType.toInt32(4294967295.0d), -1);
-        assertEquals(JSType.toInt32(4294967296.0d), 0);
-        assertEquals(JSType.toInt32(4294967297.0d), 1);
-        assertEquals(JSType.toInt32(-4294967295.0d), 1);
-        assertEquals(JSType.toInt32(-4294967296.0d), 0);
-        assertEquals(JSType.toInt32(-4294967297.d), -1);
-        assertEquals(JSType.toInt32(4294967295.6d), -1);
-        assertEquals(JSType.toInt32(4294967296.6d), 0);
-        assertEquals(JSType.toInt32(4294967297.6d), 1);
-        assertEquals(JSType.toInt32(-4294967295.6d), 1);
-        assertEquals(JSType.toInt32(-4294967296.6d), 0);
-        assertEquals(JSType.toInt32(-4294967297.6d), -1);
-    }
-
-    /**
-     * Test of JSType.toUint16(double)
-     */
-    @Test
-    public void testToUint16() {
-        assertEquals(JSType.toUint16(+0.0), 0);
-        assertEquals(JSType.toUint16(-0.0), 0);
-        assertEquals(JSType.toUint16(Double.NaN), 0);
-        assertEquals(JSType.toUint16(Double.POSITIVE_INFINITY), 0);
-        assertEquals(JSType.toUint16(Double.NEGATIVE_INFINITY), 0);
-        assertEquals(JSType.toUint16(9223372036854775807.0d), 0);
-        assertEquals(JSType.toUint16(-9223372036854775807.0d), 0);
-        assertEquals(JSType.toUint16(1099511627776.0d), 0);
-        assertEquals(JSType.toUint16(-1099511627776.0d), 0);
-        assertEquals(JSType.toUint16(4294967295.0d), 65535);
-        assertEquals(JSType.toUint16(4294967296.0d), 0);
-        assertEquals(JSType.toUint16(4294967297.0d), 1);
-        assertEquals(JSType.toUint16(-4294967295.0d), 1);
-        assertEquals(JSType.toUint16(-4294967296.0d), 0);
-        assertEquals(JSType.toUint16(-4294967297.0d), 65535);
-        assertEquals(JSType.toUint16(4294967295.6d), 65535);
-        assertEquals(JSType.toUint16(4294967296.6d), 0);
-        assertEquals(JSType.toUint16(4294967297.6d), 1);
-        assertEquals(JSType.toUint16(-4294967295.6d), 1);
-        assertEquals(JSType.toUint16(-4294967296.6d), 0);
-        assertEquals(JSType.toUint16(-4294967297.6d), 65535);
-    }
-
-}
--- a/test/src/jdk/nashorn/internal/runtime/LexicalBindingTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Top-level lexical binding tests.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.LexicalBindingTest
- */
-@SuppressWarnings("javadoc")
-public class LexicalBindingTest {
-
-    final static String LANGUAGE_ES6 = "--language=es6";
-    final static int NUMBER_OF_CONTEXTS = 20;
-    final static int MEGAMORPHIC_LOOP_COUNT = 20;
-
-    /**
-     * Test access to global var-declared variables for shared script classes with multiple globals.
-     */
-    @Test
-    public static void megamorphicVarTest() throws ScriptException, InterruptedException {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine e = factory.getScriptEngine();
-        final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
-        final String sharedScript = "foo";
-
-
-        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
-            final ScriptContext context = contexts[i] = new SimpleScriptContext();
-            final Bindings b = e.createBindings();
-            context.setBindings(b, ScriptContext.ENGINE_SCOPE);
-            assertEquals(e.eval("var foo = '" + i + "';", context), null);
-        }
-
-        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
-            final ScriptContext context = contexts[i];
-            assertEquals(e.eval(sharedScript, context), String.valueOf(i));
-        }
-    }
-
-    /**
-     * Test access to global lexically declared variables for shared script classes with multiple globals.
-     */
-    @Test
-    public static void megamorphicMultiGlobalLetTest() throws ScriptException, InterruptedException {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
-        final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
-        final String sharedScript = "foo";
-
-
-        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
-            final ScriptContext context = contexts[i] = new SimpleScriptContext();
-            final Bindings b = e.createBindings();
-            context.setBindings(b, ScriptContext.ENGINE_SCOPE);
-            assertEquals(e.eval("let foo = '" + i + "';", context), null);
-        }
-
-        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
-            final ScriptContext context = contexts[i];
-            assertEquals(e.eval(sharedScript, context), String.valueOf(i));
-        }
-    }
-
-
-    /**
-     * Test access to global lexically declared variables for shared script classes with single global.
-     */
-    @Test
-    public static void megamorphicSingleGlobalLetTest() throws ScriptException, InterruptedException {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
-        final String sharedGetterScript = "foo";
-        final String sharedSetterScript = "foo = 1";
-
-        for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
-            assertEquals(e.eval(sharedSetterScript), 1);
-            assertEquals(e.eval(sharedGetterScript), 1);
-            assertEquals(e.eval("delete foo; a" + i + " = 1; foo = " + i + ";"), i);
-            assertEquals(e.eval(sharedGetterScript), i);
-        }
-
-        assertEquals(e.eval("let foo = 'foo';"), null);
-        assertEquals(e.eval(sharedGetterScript), "foo");
-        assertEquals(e.eval(sharedSetterScript), 1);
-        assertEquals(e.eval(sharedGetterScript), 1);
-        assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
-    }
-
-    /**
-     * Test access to global lexically declared variables for shared script classes with single global.
-     */
-    @Test
-    public static void megamorphicInheritedGlobalLetTest() throws ScriptException, InterruptedException {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
-        final String sharedGetterScript = "foo";
-        final String sharedSetterScript = "foo = 1";
-
-        for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
-            assertEquals(e.eval(sharedSetterScript), 1);
-            assertEquals(e.eval(sharedGetterScript), 1);
-            assertEquals(e.eval("delete foo; a" + i + " = 1; Object.prototype.foo = " + i + ";"), i);
-            assertEquals(e.eval(sharedGetterScript), i);
-        }
-
-        assertEquals(e.eval("let foo = 'foo';"), null);
-        assertEquals(e.eval(sharedGetterScript), "foo");
-        assertEquals(e.eval(sharedSetterScript), 1);
-        assertEquals(e.eval(sharedGetterScript), 1);
-        assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
-    }
-
-    /**
-     * Test multi-threaded access to global lexically declared variables for shared script classes with multiple globals.
-     */
-    @Test
-    public static void multiThreadedLetTest() throws ScriptException, InterruptedException {
-        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
-        final Bindings b = e.createBindings();
-        final ScriptContext origContext = e.getContext();
-        final ScriptContext newCtxt = new SimpleScriptContext();
-        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-        final String sharedScript = "foo";
-
-        assertEquals(e.eval("let foo = 'original context';", origContext), null);
-        assertEquals(e.eval("let foo = 'new context';", newCtxt), null);
-
-        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
-        t1.start();
-        t2.start();
-        t1.join();
-        t2.join();
-
-        assertEquals(e.eval("foo = 'newer context';", newCtxt), "newer context");
-        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
-        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
-        t3.start();
-        t4.start();
-        t3.join();
-        t4.join();
-
-        assertEquals(e.eval(sharedScript), "original context");
-        assertEquals(e.eval(sharedScript, newCtxt), "newer context");
-    }
-
-    private static class ScriptRunner implements Runnable {
-
-        final ScriptEngine engine;
-        final ScriptContext context;
-        final String source;
-        final Object expected;
-        final int iterations;
-
-        ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
-            this.engine = engine;
-            this.context = context;
-            this.source = source;
-            this.expected = expected;
-            this.iterations = iterations;
-        }
-
-        @Override
-        public void run() {
-            try {
-                for (int i = 0; i < iterations; i++) {
-                    assertEquals(engine.eval(source, context), expected);
-                }
-            } catch (final ScriptException se) {
-                throw new RuntimeException(se);
-            }
-        }
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.fail;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.SimpleScriptContext;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @bug 8037378
- * @summary Sanity tests for no persistence caching
- * @run testng/othervm jdk.nashorn.internal.runtime.NoPersistenceCachingTest
- */
-@SuppressWarnings("javadoc")
-public class NoPersistenceCachingTest {
-
-   private ScriptEngine engine;
-   private ScriptContext context1, context2, context3;
-   private ByteArrayOutputStream stderr;
-   private PrintStream prevStderr;
-
-   @BeforeTest
-   public void setupTest() {
-      stderr = new ByteArrayOutputStream();
-      prevStderr = System.err;
-      System.setErr(new PrintStream(stderr));
-      NashornScriptEngineFactory nashornFactory = null;
-      final ScriptEngineManager sm = new ScriptEngineManager();
-      for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-         if (fac instanceof NashornScriptEngineFactory) {
-            nashornFactory = (NashornScriptEngineFactory) fac;
-            break;
-         }
-      }
-      if (nashornFactory == null) {
-         fail("Cannot find nashorn factory!");
-      }
-      // fine is enough for cache hits, finest produces way too much information
-      // TODO this should be ported to use the RuntimeEvents instead of screen scraping
-      // logs, as obviously this is very brittle
-      final String[] options = new String[]{"--log=compiler:fine"};
-      engine = nashornFactory.getScriptEngine(options);
-      context1 = engine.getContext();
-      context2 = new SimpleScriptContext();
-      context2.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
-      context3 = new SimpleScriptContext();
-      context3.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
-   }
-
-   @AfterTest
-   public void setErrTest() {
-      System.setErr(prevStderr);
-   }
-
-   public void runTest(final int numberOfContext, final String expectedOutputPattern,
-                       final int expectedPatternOccurrence) {
-
-      try {
-         switch (numberOfContext) {
-         case 2:
-            final String scriptTwoContexts = "print('HelloTwoContexts')";
-            engine.eval(scriptTwoContexts, context1);
-            engine.eval(scriptTwoContexts, context2);
-            break;
-         case 3:
-            final String scriptThreeContexts = "print('HelloThreeContexts')";
-            engine.eval(scriptThreeContexts, context1);
-            engine.eval(scriptThreeContexts, context2);
-            engine.eval(scriptThreeContexts, context3);
-            break;
-        default:
-            break;
-         }
-      } catch (final Exception se) {
-         se.printStackTrace();
-         fail(se.getMessage());
-      }
-      final Pattern deoptimizing = Pattern.compile(expectedOutputPattern);
-      final Matcher matcher = deoptimizing.matcher(stderr.toString());
-      int matches = 0;
-      while (matcher.find()) {
-         matches++;
-      }
-      if (matches != expectedPatternOccurrence) {
-         fail("Number of cache hit is not correct, expected: "
-                    + expectedPatternOccurrence + " and found: " + matches + "\n"
-              + stderr);
-      }
-      stderr.reset();
-   }
-
-   private static String getCodeCachePattern() {
-      return ("\\[compiler\\]\\sCode\\scache\\shit\\sfor\\s<eval>\\savoiding\\srecompile.");
-   }
-
-    @Test
-    public void twoContextTest() {
-       runTest(2, getCodeCachePattern(), 1);
-
-    }
-
-    @Test
-    public void threeContextTest() {
-       runTest(3, getCodeCachePattern(), 2);
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/SourceTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.util.Arrays;
-import jdk.nashorn.api.scripting.URLReader;
-import org.testng.annotations.Test;
-
-/**
- * Tests different Source representations.
- */
-@SuppressWarnings("javadoc")
-public class SourceTest {
-
-    final private static String SOURCE_NAME = "source.js";
-    final private static String SOURCE_STRING = "var x = 1;";
-    final private static char[] SOURCE_CHARS = SOURCE_STRING.toCharArray();
-    final private static String RESOURCE_PATH = "resources/load_test.js";
-    final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/" + RESOURCE_PATH);
-    final private static URL  SOURCE_URL = SourceTest.class.getResource(RESOURCE_PATH);
-
-
-    @Test
-    public void testStringSource() {
-        testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_STRING));
-        testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_CHARS));
-    }
-
-    @Test
-    public void testCharArraySource() {
-        testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_CHARS));
-        testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_STRING));
-    }
-
-    @Test
-    public void testURLSource() {
-        try {
-            testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, SOURCE_URL));
-            testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
-
-        } catch (final IOException e) {
-            fail(e.toString());
-        }
-    }
-
-    @Test
-    public void testURLReaderSource() {
-        try {
-            System.err.println(SourceTest.class.getResource(""));
-            testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
-            testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, SOURCE_URL));
-        } catch (final IOException e) {
-            fail(e.toString());
-        }
-    }
-
-    @Test
-    public void testReaderSource() {
-        try {
-            testSources(sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)), sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)));
-        } catch (final IOException e) {
-            fail(e.toString());
-        }
-    }
-
-    @Test
-    public void testFileSource() {
-        try {
-            testSources(sourceFor(SOURCE_NAME, SOURCE_FILE), sourceFor(SOURCE_NAME, SOURCE_FILE));
-        } catch (final IOException e) {
-            fail(e.toString());
-        }
-    }
-
-    private static Reader getReader(final String path) {
-        return new InputStreamReader(SourceTest.class.getResourceAsStream(path));
-    }
-
-    private static void testSources(final Source source1, final Source source2) {
-        final char[] chars1 = source1.getContent();
-        final char[] chars2 = source2.getContent();
-        final String str1 = source1.getString();
-        final String str2 = source2.getString();
-        assertTrue(Arrays.equals(chars1, chars2));
-        assertEquals(str1, str2);
-        assertEquals(source1.hashCode(), source2.hashCode());
-        assertTrue(source1.equals(source2));
-        assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
-        assertTrue(Arrays.equals(source1.getContent(), chars1));
-        assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import jdk.nashorn.api.scripting.ClassFilter;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * Tests for trusted client usage of nashorn script engine factory extension API
- */
-@SuppressWarnings("javadoc")
-public class TrustedScriptEngineTest {
-    @Test
-    public void versionTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        assertEquals(e.getFactory().getEngineVersion(), Version.version());
-    }
-
-    private static class MyClassLoader extends ClassLoader {
-        // to check if script engine uses the specified class loader
-        private final boolean[] reached = new boolean[1];
-
-        @Override
-        protected Class<?> findClass(final String name) throws ClassNotFoundException {
-            // flag that it reached here
-            reached[0] = true;
-            return super.findClass(name);
-        }
-
-        public boolean reached() {
-            return reached[0];
-        }
-    }
-
-    // These are for "private" extension API of NashornScriptEngineFactory that
-    // accepts a ClassLoader and/or command line options.
-
-    @Test
-    public void factoryClassLoaderTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                final MyClassLoader loader = new MyClassLoader();
-                // set the classloader as app class loader
-                final ScriptEngine e = nfac.getScriptEngine(loader);
-                try {
-                    e.eval("Packages.foo");
-                    // check that the class loader was attempted
-                    assertTrue(loader.reached(), "did not reach class loader!");
-                } catch (final ScriptException se) {
-                    se.printStackTrace();
-                    fail(se.getMessage());
-                }
-                return;
-            }
-        }
-
-        fail("Cannot find nashorn factory!");
-    }
-
-    @Test
-    public void factoryClassLoaderAndOptionsTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                final String[] options = new String[] { "-strict" };
-                final MyClassLoader loader = new MyClassLoader();
-                // set the classloader as app class loader
-                final ScriptEngine e = nfac.getScriptEngine(options, loader);
-                try {
-                    e.eval("Packages.foo");
-                    // check that the class loader was attempted
-                    assertTrue(loader.reached(), "did not reach class loader!");
-                } catch (final ScriptException se) {
-                    se.printStackTrace();
-                    fail(se.getMessage());
-                }
-
-                try {
-                    // strict mode - delete of a var should throw SyntaxError
-                    e.eval("var d = 2; delete d;");
-                } catch (final ScriptException se) {
-                    // check that the error message contains "SyntaxError"
-                    assertTrue(se.getMessage().contains("SyntaxError"));
-                }
-
-                return;
-            }
-        }
-
-        fail("Cannot find nashorn factory!");
-    }
-
-    @Test
-    public void factoryOptionsTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                // specify --no-syntax-extensions flag
-                final String[] options = new String[] { "--no-syntax-extensions" };
-                final ScriptEngine e = nfac.getScriptEngine(options);
-                try {
-                    // try nashorn specific extension
-                    e.eval("var f = funtion(x) 2*x;");
-                    fail("should have thrown exception!");
-                } catch (final Exception ex) {
-                    //empty
-                }
-                return;
-            }
-        }
-
-        fail("Cannot find nashorn factory!");
-    }
-
-    @Test
-    /**
-     * Test repeated evals with --loader-per-compile=false
-     * We used to get "class redefinition error".
-     */
-    public void noLoaderPerCompilerTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                final String[] options = new String[] { "--loader-per-compile=false" };
-                final ScriptEngine e = nfac.getScriptEngine(options);
-                try {
-                    e.eval("2 + 3");
-                    e.eval("4 + 4");
-                } catch (final ScriptException se) {
-                    se.printStackTrace();
-                    fail(se.getMessage());
-                }
-                return;
-            }
-        }
-        fail("Cannot find nashorn factory!");
-    }
-
-    @Test
-    /**
-     * Test that we can use same script name in repeated evals with --loader-per-compile=false
-     * We used to get "class redefinition error" as name was derived from script name.
-     */
-    public void noLoaderPerCompilerWithSameNameTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                final String[] options = new String[] { "--loader-per-compile=false" };
-                final ScriptEngine e = nfac.getScriptEngine(options);
-                e.put(ScriptEngine.FILENAME, "test.js");
-                try {
-                    e.eval("2 + 3");
-                    e.eval("4 + 4");
-                } catch (final ScriptException se) {
-                    se.printStackTrace();
-                    fail(se.getMessage());
-                }
-                return;
-            }
-        }
-        fail("Cannot find nashorn factory!");
-    }
-
-    @Test
-    public void globalPerEngineTest() throws ScriptException {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final String[] options = new String[] { "--global-per-engine" };
-        final ScriptEngine e = fac.getScriptEngine(options);
-
-        e.eval("function foo() {}");
-
-        final ScriptContext newCtx = new SimpleScriptContext();
-        newCtx.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
-
-        // all global definitions shared and so 'foo' should be
-        // visible in new Bindings as well.
-        assertTrue(e.eval("typeof foo", newCtx).equals("function"));
-
-        e.eval("function bar() {}", newCtx);
-
-        // bar should be visible in default context
-        assertTrue(e.eval("typeof bar").equals("function"));
-    }
-
-    @Test
-    public void classFilterTest() throws ScriptException {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine e = fac.getScriptEngine(new ClassFilter() {
-            @Override
-            public boolean exposeToScripts(final String fullName) {
-                // don't allow anything that is not "java."
-                return fullName.startsWith("java.");
-            }
-        });
-
-        assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
-        assertEquals(e.eval("typeof java.util.Vector"), "function");
-
-        try {
-            e.eval("Java.type('javax.script.ScriptContext')");
-            fail("should not reach here");
-        } catch (final ScriptException | RuntimeException se) {
-            if (! (se.getCause() instanceof ClassNotFoundException)) {
-                fail("ClassNotFoundException expected");
-            }
-        }
-    }
-
-    @Test
-    public void classFilterTest2() throws ScriptException {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(),
-            new ClassFilter() {
-                @Override
-                public boolean exposeToScripts(final String fullName) {
-                    // don't allow anything that is not "java."
-                    return fullName.startsWith("java.");
-                }
-            });
-
-        assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
-        assertEquals(e.eval("typeof java.util.Vector"), "function");
-
-        try {
-            e.eval("Java.type('javax.script.ScriptContext')");
-            fail("should not reach here");
-        } catch (final ScriptException | RuntimeException se) {
-            if (! (se.getCause() instanceof ClassNotFoundException)) {
-                fail("ClassNotFoundException expected");
-            }
-        }
-    }
-
-    @Test
-    public void nullClassFilterTest() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine((ClassFilter)null);
-            fail("should have thrown NPE");
-        } catch (final NullPointerException e) {
-            //empty
-        }
-    }
-
-    @Test
-    public void nullClassFilterTest2() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(new String[0], null, null);
-            fail("should have thrown NPE");
-        } catch (final NullPointerException e) {
-            //empty
-        }
-    }
-
-    @Test
-    public void nullArgsTest() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine((String[])null);
-            fail("should have thrown NPE");
-        } catch (final NullPointerException e) {
-            //empty
-        }
-    }
-
-    @Test
-    public void nullArgsTest2() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(null, null, new ClassFilter() {
-                @Override
-                public boolean exposeToScripts(final String name) {
-                    return true;
-                }
-            });
-            fail("should have thrown NPE");
-        } catch (final NullPointerException e) {
-            //empty
-        }
-    }
-
-    @Test
-    public void nashornSwallowsConstKeyword() throws Exception {
-        final NashornScriptEngineFactory f = new NashornScriptEngineFactory();
-        final String[] args = new String[] { "--const-as-var" };
-        final ScriptEngine engine = f.getScriptEngine(args);
-
-        final Object ret = engine.eval(""
-            + "(function() {\n"
-            + "  const x = 10;\n"
-            + "  return x;\n"
-            + "})();"
-        );
-        assertEquals(ret, 10, "Parsed and executed OK");
-    }
-
-    @Test
-    public void evalDefaultFileNameTest() throws ScriptException {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
-        // default FILENAME being "<eval>" make sure generated code bytecode verifies.
-        engine.eval("var a = 3;");
-    }
-
-    @Test
-    public void evalFileNameWithSpecialCharsTest() throws ScriptException {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
-        final ScriptContext ctxt = new SimpleScriptContext();
-        // use file name with "dangerous" chars.
-        ctxt.setAttribute(ScriptEngine.FILENAME, "<myscript>", ScriptContext.ENGINE_SCOPE);
-        engine.eval("var a = 3;");
-        ctxt.setAttribute(ScriptEngine.FILENAME, "[myscript]", ScriptContext.ENGINE_SCOPE);
-        engine.eval("var h = 'hello';");
-        ctxt.setAttribute(ScriptEngine.FILENAME, ";/\\$.", ScriptContext.ENGINE_SCOPE);
-        engine.eval("var foo = 'world';");
-        // name used by jjs shell tool for the interactive mode
-        ctxt.setAttribute(ScriptEngine.FILENAME, "<shell>", ScriptContext.ENGINE_SCOPE);
-        engine.eval("var foo = 'world';");
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime.regexp;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.Test;
-
-/**
- * Basic tests for the JDK based RegExp implementation.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.regexp.JdkRegExpTest
- */
-public class JdkRegExpTest {
-
-    /**
-     * Compile a regular expression using the JDK implementation
-     */
-    @Test
-    public void testMatcher() {
-        final RegExp regexp = new RegExpFactory().compile("f(o)o", "");
-        final RegExpMatcher matcher = regexp.match("foo");
-        assertNotNull(matcher);
-        assertTrue(matcher.search(0));
-        assertEquals(matcher.getInput(), "foo");
-        assertEquals(matcher.groupCount(), 1);
-        assertEquals(matcher.group(), "foo");
-        assertEquals(matcher.start(), 0);
-        assertEquals(matcher.end(), 3);
-        assertEquals(matcher.group(1), "o");
-        assertEquals(matcher.start(1), 1);
-        assertEquals(matcher.end(1), 2);
-    }
-}
--- a/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime.regexp.joni;
-
-import org.testng.annotations.Test;
-
-/**
- * Joni coverage tests
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest
- */
-@SuppressWarnings("javadoc")
-public class JoniTest {
-
-    @Test
-    public void testDump() {
-        new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree();
-        new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode();
-        new Regex("(abc){4,}{2,5}").dumpTree();
-        new Regex("(abc){4,}{2,5}").dumpByteCode();
-        new Regex("aaa|aa|bbbb|ccc").dumpTree();
-        new Regex("aaa|aa|bbbb|ccc").dumpByteCode();
-        new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree();
-        new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/regexp/joni/test/JoniTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.regexp.joni.test;
+
+import jdk.nashorn.internal.runtime.regexp.joni.Regex;
+import org.testng.annotations.Test;
+
+/**
+ * Joni coverage tests
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.regexp.joni.test.JoniTest
+ */
+@SuppressWarnings("javadoc")
+public class JoniTest {
+
+    @Test
+    public void testDump() {
+        new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree();
+        new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode();
+        new Regex("(abc){4,}{2,5}").dumpTree();
+        new Regex("(abc){4,}{2,5}").dumpByteCode();
+        new Regex("aaa|aa|bbbb|ccc").dumpTree();
+        new Regex("aaa|aa|bbbb|ccc").dumpByteCode();
+        new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree();
+        new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/regexp/test/JdkRegExpTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.regexp.test;
+
+import jdk.nashorn.internal.runtime.regexp.RegExp;
+import jdk.nashorn.internal.runtime.regexp.RegExpFactory;
+import jdk.nashorn.internal.runtime.regexp.RegExpMatcher;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Basic tests for the JDK based RegExp implementation.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.regexp.test.JdkRegExpTest
+ */
+public class JdkRegExpTest {
+
+    /**
+     * Compile a regular expression using the JDK implementation
+     */
+    @Test
+    public void testMatcher() {
+        final RegExp regexp = new RegExpFactory().compile("f(o)o", "");
+        final RegExpMatcher matcher = regexp.match("foo");
+        assertNotNull(matcher);
+        assertTrue(matcher.search(0));
+        assertEquals(matcher.getInput(), "foo");
+        assertEquals(matcher.groupCount(), 1);
+        assertEquals(matcher.group(), "foo");
+        assertEquals(matcher.start(), 0);
+        assertEquals(matcher.end(), 3);
+        assertEquals(matcher.group(1), "o");
+        assertEquals(matcher.start(1), 1);
+        assertEquals(matcher.end(1), 2);
+    }
+}
--- a/test/src/jdk/nashorn/internal/runtime/resources/load_test.js	Wed Nov 11 20:47:37 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-function loadedFunc(arg) {
-    return arg.toUpperCase();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/AddAndRemoveOnListAdapterOutsideOfJavaScriptContextTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.List;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+/**
+ * @bug 8081204
+ * @summary adding and removing elements to a ListAdapter outside of JS context should work.
+ */
+@SuppressWarnings("javadoc")
+public class AddAndRemoveOnListAdapterOutsideOfJavaScriptContextTest {
+
+    @SuppressWarnings("unchecked")
+    private static <T> T getListAdapter() throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        return (T)engine.eval("Java.to([1, 2, 3, 4], 'java.util.List')");
+    }
+
+    @Test
+    public void testInvokePush() throws ScriptException {
+        final Deque<Object> l = getListAdapter();
+        l.addLast(5);
+        assertEquals(l.size(), 5);
+        assertEquals(l.getLast(), 5);
+        assertEquals(l.getFirst(), 1);
+    }
+
+    @Test
+    public void testPop() throws ScriptException {
+        final Deque<Object> l = getListAdapter();
+        assertEquals(l.removeLast(), 4);
+        assertEquals(l.size(), 3);
+        assertEquals(l.getLast(), 3);
+    }
+
+    @Test
+    public void testUnshift() throws ScriptException {
+        final Deque<Object> l = getListAdapter();
+        l.addFirst(0);
+        assertEquals(l.getFirst(), 0);
+        assertEquals(l.getLast(), 4);
+        assertEquals(l.size(), 5);
+    }
+
+    @Test
+    public void testShift() throws ScriptException {
+        final Deque<Object> l = getListAdapter();
+        l.removeFirst();
+        assertEquals(l.getFirst(), 2);
+        assertEquals(l.getLast(), 4);
+        assertEquals(l.size(), 3);
+    }
+
+    @Test
+    public void testSpliceAdd() throws ScriptException {
+        final List<Object> l = getListAdapter();
+        assertEquals(l, Arrays.asList(1, 2, 3, 4));
+        l.add(2, "foo");
+        assertEquals(l, Arrays.asList(1, 2, "foo", 3, 4));
+    }
+
+
+    @Test
+    public void testSpliceRemove() throws ScriptException {
+        final List<Object> l = getListAdapter();
+        assertEquals(l, Arrays.asList(1, 2, 3, 4));
+        l.remove(2);
+        assertEquals(l, Arrays.asList(1, 2, 4));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/ClassFilterTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.fail;
+import java.io.File;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.api.scripting.URLReader;
+import jdk.nashorn.internal.test.framework.TestFinder;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ClassFilterTest {
+    private static final String NASHORN_CODE_CACHE = "nashorn.persistent.code.cache";
+    private static final String CLASSFILTER_CODE_CACHE = "build/classfilter_nashorn_code_cache";
+
+    // @Test
+    // This test takes too much time for basic "ant clean test" run.
+    // Given that "allow-all-java-classes" is equivalent to no java class
+    // filter and external tests don't access any java, not sure if this
+    // test contributes much. We need faster "ant clean test" cycle for
+    // developers.
+    public void runExternalJsTest() {
+        final String[] paths = new String[]{
+                "test/script/basic/compile-octane.js",
+                "test/script/basic/jquery.js",
+                "test/script/basic/prototype.js",
+                "test/script/basic/runsunspider.js",
+                "test/script/basic/underscore.js",
+                "test/script/basic/yui.js",
+                "test/script/basic/run-octane.js"
+        };
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        for (final String path : paths) {
+            final ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter());
+            try {
+                engine.eval(new URLReader(new File(path).toURI().toURL()));
+            } catch (final Exception e) {
+                fail("Script " + path + " fails with exception :" + e.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void noJavaOptionTest() {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter());
+        try {
+            engine.eval("var str = Java.type('java.lang.String');");
+            fail("TypeError should have been thrown");
+        } catch (final ScriptException e) {
+            //emtpy
+        }
+    }
+
+    @Test
+    public void securityTest() {
+        if (System.getSecurityManager() == null) {
+            return;
+        }
+
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine engine = factory.getScriptEngine(getClassFilter());
+        try {
+            engine.eval("var thread = Java.type('sun.misc.Unsafe')");
+            fail("SecurityException should have been thrown");
+        } catch (final Exception e) {
+            //empty
+        }
+        try {
+            engine.eval("var thread = new sun.misc.Unsafe()");
+            fail("SecurityException should have been thrown");
+        } catch (final Exception e) {
+            //empty
+        }
+        try {
+            engine.eval("var thread = Java.extend(sun.misc.Unsafe, {})");
+            fail("TypeError should have been thrown");
+        } catch (final Exception e) {
+            //empty
+        }
+        try {
+            engine.eval("java.lang.System.exit(0)");
+            fail("SecurityException should have been thrown");
+        } catch (final Exception e) {
+            //empty
+        }
+
+    }
+
+    @Test
+    public void persistentCacheTest() {
+        final String oldCodeCache = System.getProperty(NASHORN_CODE_CACHE);
+        System.setProperty(NASHORN_CODE_CACHE, CLASSFILTER_CODE_CACHE);
+        try {
+            persistentCacheTestImpl();
+        } finally {
+            if (oldCodeCache != null) {
+                System.setProperty(NASHORN_CODE_CACHE, oldCodeCache);
+            }
+        }
+    }
+
+    private void persistentCacheTestImpl() {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine engine = factory.getScriptEngine(
+              TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
+                  getClass().getClassLoader(),
+                  getClassFilter()
+        );
+        final String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore();
+        try {
+            engine.eval(testScript);
+        } catch (final ScriptException exc) {
+            fail(exc.getMessage());
+        }
+        final ScriptEngine engineSafe = factory.getScriptEngine(
+                TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
+                getClass().getClassLoader(),
+                new ClassFilter() {
+                    @Override
+                    public boolean exposeToScripts(final String s) {
+                        return false;
+                    }
+                }
+        );
+        try {
+            engineSafe.eval(testScript);
+            fail("ClassNotFoundException should have been thrown");
+        } catch (final Exception exc) {
+            if (!(exc.getCause() instanceof ClassNotFoundException)) {
+                fail("ClassNotFoundException expected, got " + exc.getClass());
+            }
+        }
+    }
+
+    private static String generateCodeForPersistentStore() {
+        final StringBuilder stringBuilder = new StringBuilder();
+        for (int i=0; i < 100; i++) {
+            stringBuilder.append("function i")
+                    .append(i)
+                    .append("(y, z) { var x")
+                    .append(i)
+                    .append(" = ")
+                    .append(i)
+                    .append(";}");
+        }
+        return stringBuilder.toString();
+    }
+
+    private static ClassFilter getClassFilter() {
+        return new ClassFilter() {
+            @Override
+            public boolean exposeToScripts(final String s) {
+                return true;
+            }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+/**
+ * @ignore Fails with jtreg, but passes with ant test run. Ignore for now.
+ * @test
+ * @bug 8039185 8039403
+ * @summary  Test for persistent code cache and path handling
+ * @run testng jdk.nashorn.internal.runtime.test.CodeStoreAndPathTest
+ */
+@SuppressWarnings("javadoc")
+public class CodeStoreAndPathTest {
+
+    final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+                + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
+                + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
+                + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
+                + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';"
+                + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}";
+    final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+                + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
+                + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
+                + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
+                + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';"
+                + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}"
+                + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+                + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+                + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+                + "var x10 = 'Hello Script';}";
+    // Script size < Default minimum size for storing a compiled script class
+    final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
+    final String codeCache = "build/nashorn_code_cache";
+    final String oldUserDir = System.getProperty("user.dir");
+
+    private static final String[] ENGINE_OPTIONS_OPT   = new String[]{"--persistent-code-cache", "--optimistic-types=true"};
+    private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"};
+
+    @Test
+    public void pathHandlingTest() {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+
+        fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+
+        final Path expectedCodeCachePath = FileSystems.getDefault().getPath(oldUserDir + File.separator + codeCache);
+        final Path actualCodeCachePath = FileSystems.getDefault().getPath(System.getProperty(
+                            "nashorn.persistent.code.cache")).toAbsolutePath();
+        // Check that nashorn code cache is created in current working directory
+        assertEquals(actualCodeCachePath, expectedCodeCachePath);
+        // Check that code cache dir exists and it's not empty
+        final File file = new File(actualCodeCachePath.toUri());
+        assertFalse(!file.isDirectory(), "No code cache directory was created!");
+        assertFalse(file.list().length == 0, "Code cache directory is empty!");
+    }
+
+    @Test
+    public void changeUserDirTest() throws ScriptException, IOException {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+        final Path codeCachePath = getCodeCachePath(false);
+        final String newUserDir = "build/newUserDir";
+        // Now changing current working directory
+        System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir);
+        try {
+            // Check that a new compiled script is stored in existing code cache
+            e.eval(code1);
+            final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+            checkCompiledScripts(stream, 1);
+            // Setting to default current working dir
+        } finally {
+            System.setProperty("user.dir", oldUserDir);
+        }
+    }
+
+    @Test
+    public void codeCacheTest() throws ScriptException, IOException {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+        final Path codeCachePath = getCodeCachePath(false);
+        e.eval(code1);
+        e.eval(code2);
+        e.eval(code3);// less than minimum size for storing
+        // adding code1 and code2.
+        final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+        checkCompiledScripts(stream, 2);
+    }
+
+    @Test
+    public void codeCacheTestOpt() throws ScriptException, IOException {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_OPT);
+        final Path codeCachePath = getCodeCachePath(true);
+        e.eval(code1);
+        e.eval(code2);
+        e.eval(code3);// less than minimum size for storing
+        // adding code1 and code2.
+        final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+        checkCompiledScripts(stream, 4);
+    }
+
+    private static Path getCodeCachePath(final boolean optimistic) {
+        final String codeCache = System.getProperty("nashorn.persistent.code.cache");
+        final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath();
+        final String[] files = codeCachePath.toFile().list();
+        for (final String file : files) {
+            if (file.endsWith("_opt") == optimistic) {
+                return codeCachePath.resolve(file);
+            }
+        }
+        throw new AssertionError("Code cache path not found");
+    }
+
+    private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException {
+        int n = numberOfScripts;
+        for (@SuppressWarnings("unused") final Path file : stream) {
+            n--;
+        }
+        stream.close();
+        assertEquals(n, 0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/ConsStringTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.internal.runtime.ConsString;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSType methods.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ConsStringTest
+ */
+public class ConsStringTest {
+
+    /**
+     * Test toString conversion
+     */
+    @Test
+    public void testConsStringToString() {
+        final ConsString cs1 = new ConsString("b", "c");
+        final ConsString cs2 = new ConsString("d", "e");
+        final ConsString cs3 = new ConsString(cs1, cs2);
+        final ConsString cs4 = new ConsString(cs3, "f");
+        final ConsString cs5 = new ConsString("a", cs4);
+        assertEquals(cs5.toString(), "abcdef");
+        assertEquals(cs4.toString(), "bcdef");
+        assertEquals(cs3.toString(), "bcde");
+        assertEquals(cs2.toString(), "de");
+        assertEquals(cs1.toString(), "bc");
+        // ConsStrings should be flattened now
+        assertEquals(cs1.getComponents()[0], "bc");
+        assertEquals(cs1.getComponents()[1], "");
+        assertEquals(cs2.getComponents()[0], "de");
+        assertEquals(cs2.getComponents()[1], "");
+        assertEquals(cs3.getComponents()[0], "bcde");
+        assertEquals(cs3.getComponents()[1], "");
+        assertEquals(cs4.getComponents()[0], "bcdef");
+        assertEquals(cs4.getComponents()[1], "");
+        assertEquals(cs5.getComponents()[0], "abcdef");
+        assertEquals(cs5.getComponents()[1], "");
+    }
+
+    /**
+     * Test charAt
+     */
+    @Test
+    public void testConsStringCharAt() {
+        final ConsString cs1 = new ConsString("b", "c");
+        final ConsString cs2 = new ConsString("d", "e");
+        final ConsString cs3 = new ConsString(cs1, cs2);
+        final ConsString cs4 = new ConsString(cs3, "f");
+        final ConsString cs5 = new ConsString("a", cs4);
+        assertEquals(cs1.charAt(1), 'c');
+        assertEquals(cs2.charAt(0), 'd');
+        assertEquals(cs3.charAt(3), 'e');
+        assertEquals(cs4.charAt(1), 'c');
+        assertEquals(cs5.charAt(2), 'c');
+        // ConsStrings should be flattened now
+        assertEquals(cs1.getComponents()[0], "bc");
+        assertEquals(cs1.getComponents()[1], "");
+        assertEquals(cs2.getComponents()[0], "de");
+        assertEquals(cs2.getComponents()[1], "");
+        assertEquals(cs3.getComponents()[0], "bcde");
+        assertEquals(cs3.getComponents()[1], "");
+        assertEquals(cs4.getComponents()[0], "bcdef");
+        assertEquals(cs4.getComponents()[1], "");
+        assertEquals(cs5.getComponents()[0], "abcdef");
+        assertEquals(cs5.getComponents()[1], "");
+    }
+
+
+    /**
+     * Test flattening of top-level and internal ConsStrings
+     */
+    @Test
+    public void testConsStringFlattening() {
+        final ConsString cs1 = new ConsString("b", "c");
+        final ConsString cs2 = new ConsString("d", "e");
+        final ConsString cs3 = new ConsString(cs1, cs2);
+        final ConsString cs4 = new ConsString(cs3, "f");
+
+        final ConsString cs5 = new ConsString("a", cs4);
+        // top-level ConsString should not yet be flattened
+        assert(cs5.getComponents()[0] == "a");
+        assert(cs5.getComponents()[1] == cs4);
+        assertEquals(cs5.toString(), "abcdef");
+        // top-level ConsString should be flattened
+        assertEquals(cs5.getComponents()[0], "abcdef");
+        assertEquals(cs5.getComponents()[1], "");
+        // internal ConsString should not yet be flattened after first traversal
+        assertEquals(cs4.getComponents()[0], cs3);
+        assertEquals(cs4.getComponents()[1], "f");
+
+        final ConsString cs6 = new ConsString("a", cs4);
+        // top-level ConsString should not yet be flattened
+        assertEquals(cs6.getComponents()[0], "a");
+        assertEquals(cs6.getComponents()[1], cs4);
+        assertEquals(cs6.toString(), "abcdef");
+        // top-level ConsString should be flattened
+        assertEquals(cs6.getComponents()[0], "abcdef");
+        assertEquals(cs6.getComponents()[1], "");
+        // internal ConsString should have been flattened after second traversal
+        assertEquals(cs4.getComponents()[0], "bcdef");
+        assertEquals(cs4.getComponents()[1], "");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/ContextTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import java.util.Map;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.ScriptFunction;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.annotations.Test;
+
+/**
+ * Basic Context API tests.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ContextTest
+ */
+@SuppressWarnings("javadoc")
+public class ContextTest {
+    // basic context eval test
+    @Test
+    public void evalTest() {
+        final Options options = new Options("");
+        final ErrorManager errors = new ErrorManager();
+        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+        final Global oldGlobal = Context.getGlobal();
+        Context.setGlobal(cx.createGlobal());
+        try {
+            String code = "22 + 10";
+            assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
+
+            code = "obj = { js: 'nashorn' }; obj.js";
+            assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
+        } finally {
+            Context.setGlobal(oldGlobal);
+        }
+    }
+
+    // Make sure trying to compile an invalid script returns null - see JDK-8046215.
+    @Test
+    public void compileErrorTest() {
+        final Options options = new Options("");
+        final ErrorManager errors = new ErrorManager();
+        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+        final Global oldGlobal = Context.getGlobal();
+        Context.setGlobal(cx.createGlobal());
+        try {
+            final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
+            if (script != null) {
+                fail("Invalid script compiled without errors");
+            }
+            if (errors.getNumberOfErrors() != 1) {
+                fail("Wrong number of errors: " + errors.getNumberOfErrors());
+            }
+        } finally {
+            Context.setGlobal(oldGlobal);
+        }
+    }
+
+    // basic check for JS reflection access - java.util.Map-like access on ScriptObject
+    @Test
+    public void reflectionTest() {
+        final Options options = new Options("");
+        final ErrorManager errors = new ErrorManager();
+        final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+        final boolean strict = cx.getEnv()._strict;
+        final Global oldGlobal = Context.getGlobal();
+        Context.setGlobal(cx.createGlobal());
+
+        try {
+            final String code = "var obj = { x: 344, y: 42 }";
+            eval(cx, "<reflectionTest>", code);
+
+            final Object obj = Context.getGlobal().get("obj");
+
+            assertTrue(obj instanceof ScriptObject);
+
+            final ScriptObject sobj = (ScriptObject)obj;
+            int count = 0;
+            for (final Map.Entry<?, ?> ex : sobj.entrySet()) {
+                final Object key = ex.getKey();
+                if (key.equals("x")) {
+                    assertTrue(ex.getValue() instanceof Number);
+                    assertTrue(344.0 == ((Number)ex.getValue()).doubleValue());
+
+                    count++;
+                } else if (key.equals("y")) {
+                    assertTrue(ex.getValue() instanceof Number);
+                    assertTrue(42.0 == ((Number)ex.getValue()).doubleValue());
+
+                    count++;
+                }
+            }
+            assertEquals(count, 2);
+            assertEquals(sobj.size(), 2);
+
+            // add property
+            sobj.put("zee", "hello", strict);
+            assertEquals(sobj.get("zee"), "hello");
+            assertEquals(sobj.size(), 3);
+
+        } finally {
+            Context.setGlobal(oldGlobal);
+        }
+    }
+
+    private static Object eval(final Context cx, final String name, final String code) {
+        final Source source = sourceFor(name, code);
+        final ScriptObject global = Context.getGlobal();
+        final ScriptFunction func = cx.compileScript(source, global);
+        return func != null ? ScriptRuntime.apply(func, global) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.internal.runtime.RewriteException;
+import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
+import org.testng.annotations.Test;
+
+/**
+ * JDK-8044518: Ensure exceptions related to optimistic recompilation are not serializable
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ExceptionsNotSerializable
+ */
+@SuppressWarnings("javadoc")
+public class ExceptionsNotSerializable {
+    @Test
+    public void rewriteExceptionNotSerializable() throws ScriptException {
+        // NOTE: we must create a RewriteException in a context of a Nashorn engine, as it uses Global.newIntance()
+        // internally.
+        final ScriptEngine e = new NashornScriptEngineFactory().getScriptEngine();
+        e.put("f", new Runnable() {
+            @Override
+            public void run() {
+                tryToSerialize(RewriteException.create(null, new Object[0], new String[0]));
+            }
+        });
+        e.eval("f()");
+    }
+
+    @Test
+    public void unwarrantedOptimismExceptionNotSerializable() {
+        tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128));
+    }
+
+    private static void tryToSerialize(final Object obj) {
+        try {
+            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(obj);
+            fail();
+        } catch (final NotSerializableException e) {
+            assertEquals(e.getMessage(), obj.getClass().getName());
+        } catch (final IOException e) {
+            fail("", e);
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/JDK_8078414_Test.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import javax.script.Bindings;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.objects.NativeArray;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import jdk.nashorn.internal.runtime.linker.Bootstrap;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @bug 8078414
+ * @summary Test that arbitrary classes can't be converted to mirror's superclasses/interfaces.
+ * @run testng jdk.nashorn.internal.runtime.test.JDK_8078414_Test
+ */
+public class JDK_8078414_Test {
+    @Test
+    public void testCanNotConvertArbitraryClassToMirror() {
+        assertCanNotConvert(Double.class, Map.class);
+        assertCanNotConvert(Double.class, Bindings.class);
+        assertCanNotConvert(Double.class, JSObject.class);
+        assertCanNotConvert(Double.class, ScriptObjectMirror.class);
+    }
+
+    @Test
+    public void testCanConvertObjectToMirror() {
+        assertCanConvertToMirror(Object.class);
+    }
+
+    @Test
+    public void testCanConvertScriptObjectToMirror() {
+        assertCanConvertToMirror(ScriptObject.class);
+    }
+
+    @Test
+    public void testCanConvertScriptObjectSubclassToMirror() {
+        assertCanConvertToMirror(NativeArray.class);
+    }
+
+    @Test
+    public void testCanConvertArbitraryInterfaceToMirror() {
+        // We allow arbitrary interface classes, depending on what implements them, to end up being
+        // convertible to ScriptObjectMirror, as an implementation can theoretically pass an
+        // "instanceof ScriptObject" guard.
+        assertCanConvertToMirror(TestInterface.class);
+    }
+
+    public static interface TestInterface {
+    }
+
+    private static boolean canConvert(final Class<?> from, final Class<?> to) {
+        return Bootstrap.getLinkerServices().canConvert(from, to);
+    }
+
+    private static void assertCanConvert(final Class<?> from, final Class<?> to) {
+        assertTrue(canConvert(from, to));
+    }
+
+    private static void assertCanNotConvert(final Class<?> from, final Class<?> to) {
+        assertFalse(canConvert(from, to));
+    }
+
+    private static void assertCanConvertToMirror(final Class<?> from) {
+        assertCanConvert(from, Map.class);
+        assertCanConvert(from, Bindings.class);
+        assertCanConvert(from, JSObject.class);
+        assertCanConvert(from, ScriptObjectMirror.class);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/JDK_8081015_Test.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import java.util.Collection;
+import java.util.Queue;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.test.models.JDK_8081015_TestModel;
+import org.testng.annotations.Test;
+
+/**
+ * @bug 8081015
+ * @summary Test that native arrays get converted to {@link Queue} and {@link Collection}.
+ */
+@SuppressWarnings("javadoc")
+public class JDK_8081015_Test {
+    @Test
+    public void testConvertToCollection() throws ScriptException {
+        test("receiveCollection");
+    }
+
+    @Test
+    public void testConvertToDeque() throws ScriptException {
+        test("receiveDeque");
+    }
+
+    @Test
+    public void testConvertToList() throws ScriptException {
+        test("receiveList");
+    }
+
+    @Test
+    public void testConvertToQueue() throws ScriptException {
+        test("receiveQueue");
+    }
+
+    private static void test(final String methodName) throws ScriptException {
+        final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
+        final JDK_8081015_TestModel model = new JDK_8081015_TestModel();
+        engine.put("test", model);
+
+        assertNull(model.getLastInvoked());
+        engine.eval("test." + methodName + "([1, 2, 3.3, 'foo'])");
+        assertEquals(model.getLastInvoked(), methodName );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/JSTypeTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSType methods.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.JSTypeTest
+ */
+public class JSTypeTest {
+    /**
+     * Test of isPrimitive method, of class Runtime.
+     */
+    @Test
+    public void testIsPrimitive() {
+        assertTrue(JSType.isPrimitive(null));
+        assertTrue(JSType.isPrimitive(ScriptRuntime.UNDEFINED));
+        assertTrue(JSType.isPrimitive(Double.NaN));
+        assertTrue(JSType.isPrimitive(Double.NEGATIVE_INFINITY));
+        assertTrue(JSType.isPrimitive(Double.POSITIVE_INFINITY));
+        assertTrue(JSType.isPrimitive(0.0));
+        assertTrue(JSType.isPrimitive(3.14));
+        assertTrue(JSType.isPrimitive("hello"));
+        assertTrue(JSType.isPrimitive(""));
+        assertFalse(JSType.isPrimitive(new Object()));
+    }
+
+    /**
+     * Test of toBoolean method, of class Runtime.
+     */
+    @Test
+    public void testToBoolean() {
+        assertFalse(JSType.toBoolean(ScriptRuntime.UNDEFINED));
+        assertFalse(JSType.toBoolean(null));
+        assertFalse(JSType.toBoolean(Boolean.FALSE));
+        assertTrue(JSType.toBoolean(Boolean.TRUE));
+        assertFalse(JSType.toBoolean(-0.0));
+        assertFalse(JSType.toBoolean(0.0));
+        assertFalse(JSType.toBoolean(Double.NaN));
+        assertTrue(JSType.toBoolean(3.14));
+        assertFalse(JSType.toBoolean(""));
+        assertTrue(JSType.toBoolean("javascript"));
+        assertTrue(JSType.toBoolean(new Object()));
+    }
+
+    /**
+     * Test of toNumber method, of class Runtime.
+     */
+    @Test
+    public void testToNumber_Object() {
+        assertTrue(Double.isNaN(JSType.toNumber(ScriptRuntime.UNDEFINED)));
+        assertEquals(JSType.toNumber((Object)null), 0.0, 0.0);
+        assertEquals(JSType.toNumber(Boolean.TRUE), 1.0, 0.0);
+        assertEquals(JSType.toNumber(Boolean.FALSE), 0.0, 0.0);
+        assertEquals(JSType.toNumber(3.14), 3.14, 0.0);
+        // FIXME: add more assertions for specific String to number cases
+        // FIXME: add case for Object type (JSObject with getDefaultValue)
+    }
+
+    /**
+     * Test of toString method, of class Runtime.
+     */
+    @Test
+    public void testToString_Object() {
+        assertEquals(JSType.toString(ScriptRuntime.UNDEFINED), "undefined");
+        assertEquals(JSType.toString(null), "null");
+        assertEquals(JSType.toString(Boolean.TRUE), "true");
+        assertEquals(JSType.toString(Boolean.FALSE), "false");
+        assertEquals(JSType.toString(""), "");
+        assertEquals(JSType.toString("nashorn"), "nashorn");
+        assertEquals(JSType.toString(Double.NaN), "NaN");
+        assertEquals(JSType.toString(Double.POSITIVE_INFINITY), "Infinity");
+        assertEquals(JSType.toString(Double.NEGATIVE_INFINITY), "-Infinity");
+        assertEquals(JSType.toString(0.0), "0");
+        // FIXME: add more number-to-string test cases
+        // FIXME: add case for Object type (JSObject with getDefaultValue)
+    }
+
+    /**
+     * Test of JSType.toUint32(double)
+     */
+    @Test
+    public void testToUint32() {
+        assertEquals(JSType.toUint32(+0.0), 0);
+        assertEquals(JSType.toUint32(-0.0), 0);
+        assertEquals(JSType.toUint32(Double.NaN), 0);
+        assertEquals(JSType.toUint32(Double.POSITIVE_INFINITY), 0);
+        assertEquals(JSType.toUint32(Double.NEGATIVE_INFINITY), 0);
+        assertEquals(JSType.toUint32(9223372036854775807.0d), 0);
+        assertEquals(JSType.toUint32(-9223372036854775807.0d), 0);
+        assertEquals(JSType.toUint32(1099511627776.0d), 0);
+        assertEquals(JSType.toUint32(-1099511627776.0d), 0);
+        assertEquals(JSType.toUint32(4294967295.0d), 4294967295l);
+        assertEquals(JSType.toUint32(4294967296.0d), 0);
+        assertEquals(JSType.toUint32(4294967297.0d), 1);
+        assertEquals(JSType.toUint32(-4294967295.0d), 1);
+        assertEquals(JSType.toUint32(-4294967296.0d), 0);
+        assertEquals(JSType.toUint32(-4294967297.0d), 4294967295l);
+        assertEquals(JSType.toUint32(4294967295.6d), 4294967295l);
+        assertEquals(JSType.toUint32(4294967296.6d), 0);
+        assertEquals(JSType.toUint32(4294967297.6d), 1);
+        assertEquals(JSType.toUint32(-4294967295.6d), 1);
+        assertEquals(JSType.toUint32(-4294967296.6d), 0);
+        assertEquals(JSType.toUint32(-4294967297.6d), 4294967295l);
+    }
+
+    /**
+     * Test of JSType.toInt32(double)
+     */
+    @Test
+    public void testToInt32() {
+        assertEquals(JSType.toInt32(+0.0), 0);
+        assertEquals(JSType.toInt32(-0.0), 0);
+        assertEquals(JSType.toInt32(Double.NaN), 0);
+        assertEquals(JSType.toInt32(Double.POSITIVE_INFINITY), 0);
+        assertEquals(JSType.toInt32(Double.NEGATIVE_INFINITY), 0);
+        assertEquals(JSType.toInt32(9223372036854775807.0d), 0);
+        assertEquals(JSType.toInt32(-9223372036854775807.0d), 0);
+        assertEquals(JSType.toInt32(1099511627776.0d), 0);
+        assertEquals(JSType.toInt32(-1099511627776.0d), 0);
+        assertEquals(JSType.toInt32(4294967295.0d), -1);
+        assertEquals(JSType.toInt32(4294967296.0d), 0);
+        assertEquals(JSType.toInt32(4294967297.0d), 1);
+        assertEquals(JSType.toInt32(-4294967295.0d), 1);
+        assertEquals(JSType.toInt32(-4294967296.0d), 0);
+        assertEquals(JSType.toInt32(-4294967297.d), -1);
+        assertEquals(JSType.toInt32(4294967295.6d), -1);
+        assertEquals(JSType.toInt32(4294967296.6d), 0);
+        assertEquals(JSType.toInt32(4294967297.6d), 1);
+        assertEquals(JSType.toInt32(-4294967295.6d), 1);
+        assertEquals(JSType.toInt32(-4294967296.6d), 0);
+        assertEquals(JSType.toInt32(-4294967297.6d), -1);
+    }
+
+    /**
+     * Test of JSType.toUint16(double)
+     */
+    @Test
+    public void testToUint16() {
+        assertEquals(JSType.toUint16(+0.0), 0);
+        assertEquals(JSType.toUint16(-0.0), 0);
+        assertEquals(JSType.toUint16(Double.NaN), 0);
+        assertEquals(JSType.toUint16(Double.POSITIVE_INFINITY), 0);
+        assertEquals(JSType.toUint16(Double.NEGATIVE_INFINITY), 0);
+        assertEquals(JSType.toUint16(9223372036854775807.0d), 0);
+        assertEquals(JSType.toUint16(-9223372036854775807.0d), 0);
+        assertEquals(JSType.toUint16(1099511627776.0d), 0);
+        assertEquals(JSType.toUint16(-1099511627776.0d), 0);
+        assertEquals(JSType.toUint16(4294967295.0d), 65535);
+        assertEquals(JSType.toUint16(4294967296.0d), 0);
+        assertEquals(JSType.toUint16(4294967297.0d), 1);
+        assertEquals(JSType.toUint16(-4294967295.0d), 1);
+        assertEquals(JSType.toUint16(-4294967296.0d), 0);
+        assertEquals(JSType.toUint16(-4294967297.0d), 65535);
+        assertEquals(JSType.toUint16(4294967295.6d), 65535);
+        assertEquals(JSType.toUint16(4294967296.6d), 0);
+        assertEquals(JSType.toUint16(4294967297.6d), 1);
+        assertEquals(JSType.toUint16(-4294967295.6d), 1);
+        assertEquals(JSType.toUint16(-4294967296.6d), 0);
+        assertEquals(JSType.toUint16(-4294967297.6d), 65535);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Top-level lexical binding tests.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.LexicalBindingTest
+ */
+@SuppressWarnings("javadoc")
+public class LexicalBindingTest {
+
+    final static String LANGUAGE_ES6 = "--language=es6";
+    final static int NUMBER_OF_CONTEXTS = 20;
+    final static int MEGAMORPHIC_LOOP_COUNT = 20;
+
+    /**
+     * Test access to global var-declared variables for shared script classes with multiple globals.
+     */
+    @Test
+    public static void megamorphicVarTest() throws ScriptException, InterruptedException {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine e = factory.getScriptEngine();
+        final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
+        final String sharedScript = "foo";
+
+
+        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+            final ScriptContext context = contexts[i] = new SimpleScriptContext();
+            final Bindings b = e.createBindings();
+            context.setBindings(b, ScriptContext.ENGINE_SCOPE);
+            assertEquals(e.eval("var foo = '" + i + "';", context), null);
+        }
+
+        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+            final ScriptContext context = contexts[i];
+            assertEquals(e.eval(sharedScript, context), String.valueOf(i));
+        }
+    }
+
+    /**
+     * Test access to global lexically declared variables for shared script classes with multiple globals.
+     */
+    @Test
+    public static void megamorphicMultiGlobalLetTest() throws ScriptException, InterruptedException {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+        final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
+        final String sharedScript = "foo";
+
+
+        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+            final ScriptContext context = contexts[i] = new SimpleScriptContext();
+            final Bindings b = e.createBindings();
+            context.setBindings(b, ScriptContext.ENGINE_SCOPE);
+            assertEquals(e.eval("let foo = '" + i + "';", context), null);
+        }
+
+        for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+            final ScriptContext context = contexts[i];
+            assertEquals(e.eval(sharedScript, context), String.valueOf(i));
+        }
+    }
+
+
+    /**
+     * Test access to global lexically declared variables for shared script classes with single global.
+     */
+    @Test
+    public static void megamorphicSingleGlobalLetTest() throws ScriptException, InterruptedException {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+        final String sharedGetterScript = "foo";
+        final String sharedSetterScript = "foo = 1";
+
+        for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
+            assertEquals(e.eval(sharedSetterScript), 1);
+            assertEquals(e.eval(sharedGetterScript), 1);
+            assertEquals(e.eval("delete foo; a" + i + " = 1; foo = " + i + ";"), i);
+            assertEquals(e.eval(sharedGetterScript), i);
+        }
+
+        assertEquals(e.eval("let foo = 'foo';"), null);
+        assertEquals(e.eval(sharedGetterScript), "foo");
+        assertEquals(e.eval(sharedSetterScript), 1);
+        assertEquals(e.eval(sharedGetterScript), 1);
+        assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
+    }
+
+    /**
+     * Test access to global lexically declared variables for shared script classes with single global.
+     */
+    @Test
+    public static void megamorphicInheritedGlobalLetTest() throws ScriptException, InterruptedException {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+        final String sharedGetterScript = "foo";
+        final String sharedSetterScript = "foo = 1";
+
+        for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
+            assertEquals(e.eval(sharedSetterScript), 1);
+            assertEquals(e.eval(sharedGetterScript), 1);
+            assertEquals(e.eval("delete foo; a" + i + " = 1; Object.prototype.foo = " + i + ";"), i);
+            assertEquals(e.eval(sharedGetterScript), i);
+        }
+
+        assertEquals(e.eval("let foo = 'foo';"), null);
+        assertEquals(e.eval(sharedGetterScript), "foo");
+        assertEquals(e.eval(sharedSetterScript), 1);
+        assertEquals(e.eval(sharedGetterScript), 1);
+        assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
+    }
+
+    /**
+     * Test multi-threaded access to global lexically declared variables for shared script classes with multiple globals.
+     */
+    @Test
+    public static void multiThreadedLetTest() throws ScriptException, InterruptedException {
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+        final Bindings b = e.createBindings();
+        final ScriptContext origContext = e.getContext();
+        final ScriptContext newCtxt = new SimpleScriptContext();
+        newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+        final String sharedScript = "foo";
+
+        assertEquals(e.eval("let foo = 'original context';", origContext), null);
+        assertEquals(e.eval("let foo = 'new context';", newCtxt), null);
+
+        final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+
+        assertEquals(e.eval("foo = 'newer context';", newCtxt), "newer context");
+        final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+        final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+        t3.start();
+        t4.start();
+        t3.join();
+        t4.join();
+
+        assertEquals(e.eval(sharedScript), "original context");
+        assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+    }
+
+    private static class ScriptRunner implements Runnable {
+
+        final ScriptEngine engine;
+        final ScriptContext context;
+        final String source;
+        final Object expected;
+        final int iterations;
+
+        ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
+            this.engine = engine;
+            this.context = context;
+            this.source = source;
+            this.expected = expected;
+            this.iterations = iterations;
+        }
+
+        @Override
+        public void run() {
+            try {
+                for (int i = 0; i < iterations; i++) {
+                    assertEquals(engine.eval(source, context), expected);
+                }
+            } catch (final ScriptException se) {
+                throw new RuntimeException(se);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/NoPersistenceCachingTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.fail;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @bug 8037378
+ * @summary Sanity tests for no persistence caching
+ * @run testng/othervm jdk.nashorn.internal.runtime.test.NoPersistenceCachingTest
+ */
+@SuppressWarnings("javadoc")
+public class NoPersistenceCachingTest {
+
+   private ScriptEngine engine;
+   private ScriptContext context1, context2, context3;
+   private ByteArrayOutputStream stderr;
+   private PrintStream prevStderr;
+
+   @BeforeTest
+   public void setupTest() {
+      stderr = new ByteArrayOutputStream();
+      prevStderr = System.err;
+      System.setErr(new PrintStream(stderr));
+      NashornScriptEngineFactory nashornFactory = null;
+      final ScriptEngineManager sm = new ScriptEngineManager();
+      for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+         if (fac instanceof NashornScriptEngineFactory) {
+            nashornFactory = (NashornScriptEngineFactory) fac;
+            break;
+         }
+      }
+      if (nashornFactory == null) {
+         fail("Cannot find nashorn factory!");
+      }
+      // fine is enough for cache hits, finest produces way too much information
+      // TODO this should be ported to use the RuntimeEvents instead of screen scraping
+      // logs, as obviously this is very brittle
+      final String[] options = new String[]{"--log=compiler:fine"};
+      engine = nashornFactory.getScriptEngine(options);
+      context1 = engine.getContext();
+      context2 = new SimpleScriptContext();
+      context2.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
+      context3 = new SimpleScriptContext();
+      context3.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
+   }
+
+   @AfterTest
+   public void setErrTest() {
+      System.setErr(prevStderr);
+   }
+
+   public void runTest(final int numberOfContext, final String expectedOutputPattern,
+                       final int expectedPatternOccurrence) {
+
+      try {
+         switch (numberOfContext) {
+         case 2:
+            final String scriptTwoContexts = "print('HelloTwoContexts')";
+            engine.eval(scriptTwoContexts, context1);
+            engine.eval(scriptTwoContexts, context2);
+            break;
+         case 3:
+            final String scriptThreeContexts = "print('HelloThreeContexts')";
+            engine.eval(scriptThreeContexts, context1);
+            engine.eval(scriptThreeContexts, context2);
+            engine.eval(scriptThreeContexts, context3);
+            break;
+        default:
+            break;
+         }
+      } catch (final Exception se) {
+         se.printStackTrace();
+         fail(se.getMessage());
+      }
+      final Pattern deoptimizing = Pattern.compile(expectedOutputPattern);
+      final Matcher matcher = deoptimizing.matcher(stderr.toString());
+      int matches = 0;
+      while (matcher.find()) {
+         matches++;
+      }
+      if (matches != expectedPatternOccurrence) {
+         fail("Number of cache hit is not correct, expected: "
+                    + expectedPatternOccurrence + " and found: " + matches + "\n"
+              + stderr);
+      }
+      stderr.reset();
+   }
+
+   private static String getCodeCachePattern() {
+      return ("\\[compiler\\]\\sCode\\scache\\shit\\sfor\\s<eval>\\savoiding\\srecompile.");
+   }
+
+    @Test
+    public void twoContextTest() {
+       runTest(2, getCodeCachePattern(), 1);
+
+    }
+
+    @Test
+    public void threeContextTest() {
+       runTest(3, getCodeCachePattern(), 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/SourceTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Arrays;
+import jdk.nashorn.api.scripting.URLReader;
+import jdk.nashorn.internal.runtime.Source;
+import org.testng.annotations.Test;
+
+/**
+ * Tests different Source representations.
+ */
+@SuppressWarnings("javadoc")
+public class SourceTest {
+
+    final private static String SOURCE_NAME = "source.js";
+    final private static String SOURCE_STRING = "var x = 1;";
+    final private static char[] SOURCE_CHARS = SOURCE_STRING.toCharArray();
+    final private static String RESOURCE_PATH = "resources/load_test.js";
+    final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/test/" + RESOURCE_PATH);
+    final private static URL  SOURCE_URL = SourceTest.class.getResource(RESOURCE_PATH);
+
+
+    @Test
+    public void testStringSource() {
+        testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_STRING));
+        testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_CHARS));
+    }
+
+    @Test
+    public void testCharArraySource() {
+        testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_CHARS));
+        testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_STRING));
+    }
+
+    @Test
+    public void testURLSource() {
+        try {
+            testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, SOURCE_URL));
+            testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
+
+        } catch (final IOException e) {
+            fail(e.toString());
+        }
+    }
+
+    @Test
+    public void testURLReaderSource() {
+        try {
+            System.err.println(SourceTest.class.getResource(""));
+            testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
+            testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, SOURCE_URL));
+        } catch (final IOException e) {
+            fail(e.toString());
+        }
+    }
+
+    @Test
+    public void testReaderSource() {
+        try {
+            testSources(sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)), sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)));
+        } catch (final IOException e) {
+            fail(e.toString());
+        }
+    }
+
+    @Test
+    public void testFileSource() {
+        try {
+            testSources(sourceFor(SOURCE_NAME, SOURCE_FILE), sourceFor(SOURCE_NAME, SOURCE_FILE));
+        } catch (final IOException e) {
+            fail(e.toString());
+        }
+    }
+
+    private static Reader getReader(final String path) {
+        return new InputStreamReader(SourceTest.class.getResourceAsStream(path));
+    }
+
+    private static void testSources(final Source source1, final Source source2) {
+        final char[] chars1 = source1.getContent();
+        final char[] chars2 = source2.getContent();
+        final String str1 = source1.getString();
+        final String str2 = source2.getString();
+        assertTrue(Arrays.equals(chars1, chars2));
+        assertEquals(str1, str2);
+        assertEquals(source1.hashCode(), source2.hashCode());
+        assertTrue(source1.equals(source2));
+        assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
+        assertTrue(Arrays.equals(source1.getContent(), chars1));
+        assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/TrustedScriptEngineTest.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.internal.runtime.Version;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for trusted client usage of nashorn script engine factory extension API
+ */
+@SuppressWarnings("javadoc")
+public class TrustedScriptEngineTest {
+    @Test
+    public void versionTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        assertEquals(e.getFactory().getEngineVersion(), Version.version());
+    }
+
+    private static class MyClassLoader extends ClassLoader {
+        // to check if script engine uses the specified class loader
+        private final boolean[] reached = new boolean[1];
+
+        @Override
+        protected Class<?> findClass(final String name) throws ClassNotFoundException {
+            // flag that it reached here
+            reached[0] = true;
+            return super.findClass(name);
+        }
+
+        public boolean reached() {
+            return reached[0];
+        }
+    }
+
+    // These are for "private" extension API of NashornScriptEngineFactory that
+    // accepts a ClassLoader and/or command line options.
+
+    @Test
+    public void factoryClassLoaderTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                final MyClassLoader loader = new MyClassLoader();
+                // set the classloader as app class loader
+                final ScriptEngine e = nfac.getScriptEngine(loader);
+                try {
+                    e.eval("Packages.foo");
+                    // check that the class loader was attempted
+                    assertTrue(loader.reached(), "did not reach class loader!");
+                } catch (final ScriptException se) {
+                    se.printStackTrace();
+                    fail(se.getMessage());
+                }
+                return;
+            }
+        }
+
+        fail("Cannot find nashorn factory!");
+    }
+
+    @Test
+    public void factoryClassLoaderAndOptionsTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                final String[] options = new String[] { "-strict" };
+                final MyClassLoader loader = new MyClassLoader();
+                // set the classloader as app class loader
+                final ScriptEngine e = nfac.getScriptEngine(options, loader);
+                try {
+                    e.eval("Packages.foo");
+                    // check that the class loader was attempted
+                    assertTrue(loader.reached(), "did not reach class loader!");
+                } catch (final ScriptException se) {
+                    se.printStackTrace();
+                    fail(se.getMessage());
+                }
+
+                try {
+                    // strict mode - delete of a var should throw SyntaxError
+                    e.eval("var d = 2; delete d;");
+                } catch (final ScriptException se) {
+                    // check that the error message contains "SyntaxError"
+                    assertTrue(se.getMessage().contains("SyntaxError"));
+                }
+
+                return;
+            }
+        }
+
+        fail("Cannot find nashorn factory!");
+    }
+
+    @Test
+    public void factoryOptionsTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                // specify --no-syntax-extensions flag
+                final String[] options = new String[] { "--no-syntax-extensions" };
+                final ScriptEngine e = nfac.getScriptEngine(options);
+                try {
+                    // try nashorn specific extension
+                    e.eval("var f = funtion(x) 2*x;");
+                    fail("should have thrown exception!");
+                } catch (final Exception ex) {
+                    //empty
+                }
+                return;
+            }
+        }
+
+        fail("Cannot find nashorn factory!");
+    }
+
+    @Test
+    /**
+     * Test repeated evals with --loader-per-compile=false
+     * We used to get "class redefinition error".
+     */
+    public void noLoaderPerCompilerTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                final String[] options = new String[] { "--loader-per-compile=false" };
+                final ScriptEngine e = nfac.getScriptEngine(options);
+                try {
+                    e.eval("2 + 3");
+                    e.eval("4 + 4");
+                } catch (final ScriptException se) {
+                    se.printStackTrace();
+                    fail(se.getMessage());
+                }
+                return;
+            }
+        }
+        fail("Cannot find nashorn factory!");
+    }
+
+    @Test
+    /**
+     * Test that we can use same script name in repeated evals with --loader-per-compile=false
+     * We used to get "class redefinition error" as name was derived from script name.
+     */
+    public void noLoaderPerCompilerWithSameNameTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                final String[] options = new String[] { "--loader-per-compile=false" };
+                final ScriptEngine e = nfac.getScriptEngine(options);
+                e.put(ScriptEngine.FILENAME, "test.js");
+                try {
+                    e.eval("2 + 3");
+                    e.eval("4 + 4");
+                } catch (final ScriptException se) {
+                    se.printStackTrace();
+                    fail(se.getMessage());
+                }
+                return;
+            }
+        }
+        fail("Cannot find nashorn factory!");
+    }
+
+    @Test
+    public void globalPerEngineTest() throws ScriptException {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final String[] options = new String[] { "--global-per-engine" };
+        final ScriptEngine e = fac.getScriptEngine(options);
+
+        e.eval("function foo() {}");
+
+        final ScriptContext newCtx = new SimpleScriptContext();
+        newCtx.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+
+        // all global definitions shared and so 'foo' should be
+        // visible in new Bindings as well.
+        assertTrue(e.eval("typeof foo", newCtx).equals("function"));
+
+        e.eval("function bar() {}", newCtx);
+
+        // bar should be visible in default context
+        assertTrue(e.eval("typeof bar").equals("function"));
+    }
+
+    @Test
+    public void classFilterTest() throws ScriptException {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine e = fac.getScriptEngine(new ClassFilter() {
+            @Override
+            public boolean exposeToScripts(final String fullName) {
+                // don't allow anything that is not "java."
+                return fullName.startsWith("java.");
+            }
+        });
+
+        assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
+        assertEquals(e.eval("typeof java.util.Vector"), "function");
+
+        try {
+            e.eval("Java.type('javax.script.ScriptContext')");
+            fail("should not reach here");
+        } catch (final ScriptException | RuntimeException se) {
+            if (! (se.getCause() instanceof ClassNotFoundException)) {
+                fail("ClassNotFoundException expected");
+            }
+        }
+    }
+
+    @Test
+    public void classFilterTest2() throws ScriptException {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(),
+            new ClassFilter() {
+                @Override
+                public boolean exposeToScripts(final String fullName) {
+                    // don't allow anything that is not "java."
+                    return fullName.startsWith("java.");
+                }
+            });
+
+        assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
+        assertEquals(e.eval("typeof java.util.Vector"), "function");
+
+        try {
+            e.eval("Java.type('javax.script.ScriptContext')");
+            fail("should not reach here");
+        } catch (final ScriptException | RuntimeException se) {
+            if (! (se.getCause() instanceof ClassNotFoundException)) {
+                fail("ClassNotFoundException expected");
+            }
+        }
+    }
+
+    @Test
+    public void nullClassFilterTest() {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine((ClassFilter)null);
+            fail("should have thrown NPE");
+        } catch (final NullPointerException e) {
+            //empty
+        }
+    }
+
+    @Test
+    public void nullClassFilterTest2() {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(new String[0], null, null);
+            fail("should have thrown NPE");
+        } catch (final NullPointerException e) {
+            //empty
+        }
+    }
+
+    @Test
+    public void nullArgsTest() {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine((String[])null);
+            fail("should have thrown NPE");
+        } catch (final NullPointerException e) {
+            //empty
+        }
+    }
+
+    @Test
+    public void nullArgsTest2() {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(null, null, new ClassFilter() {
+                @Override
+                public boolean exposeToScripts(final String name) {
+                    return true;
+                }
+            });
+            fail("should have thrown NPE");
+        } catch (final NullPointerException e) {
+            //empty
+        }
+    }
+
+    @Test
+    public void nashornSwallowsConstKeyword() throws Exception {
+        final NashornScriptEngineFactory f = new NashornScriptEngineFactory();
+        final String[] args = new String[] { "--const-as-var" };
+        final ScriptEngine engine = f.getScriptEngine(args);
+
+        final Object ret = engine.eval(""
+            + "(function() {\n"
+            + "  const x = 10;\n"
+            + "  return x;\n"
+            + "})();"
+        );
+        assertEquals(ret, 10, "Parsed and executed OK");
+    }
+
+    @Test
+    public void evalDefaultFileNameTest() throws ScriptException {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
+        // default FILENAME being "<eval>" make sure generated code bytecode verifies.
+        engine.eval("var a = 3;");
+    }
+
+    @Test
+    public void evalFileNameWithSpecialCharsTest() throws ScriptException {
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
+        final ScriptContext ctxt = new SimpleScriptContext();
+        // use file name with "dangerous" chars.
+        ctxt.setAttribute(ScriptEngine.FILENAME, "<myscript>", ScriptContext.ENGINE_SCOPE);
+        engine.eval("var a = 3;");
+        ctxt.setAttribute(ScriptEngine.FILENAME, "[myscript]", ScriptContext.ENGINE_SCOPE);
+        engine.eval("var h = 'hello';");
+        ctxt.setAttribute(ScriptEngine.FILENAME, ";/\\$.", ScriptContext.ENGINE_SCOPE);
+        engine.eval("var foo = 'world';");
+        // name used by jjs shell tool for the interactive mode
+        ctxt.setAttribute(ScriptEngine.FILENAME, "<shell>", ScriptContext.ENGINE_SCOPE);
+        engine.eval("var foo = 'world';");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/internal/runtime/test/resources/load_test.js	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+function loadedFunc(arg) {
+    return arg.toUpperCase();
+}
--- a/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Fri Nov 13 15:38:44 2015 -0800
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package jdk.nashorn.internal.test.framework;
 
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_CHECK_COMPILE_MSG;
@@ -61,14 +60,15 @@
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Scanner;
 import java.util.Set;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
+import jdk.nashorn.internal.runtime.ScriptingFunctions;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
@@ -78,28 +78,33 @@
  */
 @SuppressWarnings("javadoc")
 public final class TestFinder {
-    private TestFinder() {}
+
+    private TestFinder() {
+    }
 
     interface TestFactory<T> {
+
         // 'test' instance type is decided by the client.
+
         T createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> arguments);
+
         // place to log messages from TestFinder
+
         void log(String mg);
     }
 
-
     // finds all tests from configuration and calls TestFactory to create 'test' instance for each script test found
     static <T> void findAllTests(final List<T> tests, final Set<String> orphans, final TestFactory<T> testFactory) throws Exception {
         final String framework = System.getProperty(TEST_JS_FRAMEWORK);
         final String testList = System.getProperty(TEST_JS_LIST);
         final String failedTestFileName = System.getProperty(TEST_FAILED_LIST_FILE);
-        if(failedTestFileName != null) {
+        if (failedTestFileName != null) {
             final File failedTestFile = new File(failedTestFileName);
-            if(failedTestFile.exists() && failedTestFile.length() > 0L) {
-                try(final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) {
-                    for(;;) {
+            if (failedTestFile.exists() && failedTestFile.length() > 0L) {
+                try (final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) {
+                    for (;;) {
                         final String testFileName = r.readLine();
-                        if(testFileName == null) {
+                        if (testFileName == null) {
                             break;
                         }
                         handleOneTest(framework, new File(testFileName).toPath(), tests, orphans, testFactory);
@@ -151,7 +156,7 @@
         final Exception[] exceptions = new Exception[1];
         final List<String> excludedActualTests = new ArrayList<>();
 
-        if (! dir.toFile().isDirectory()) {
+        if (!dir.toFile().isDirectory()) {
             factory.log("WARNING: " + dir + " not found or not a directory");
         }
 
@@ -219,27 +224,28 @@
 
         boolean explicitOptimistic = false;
 
-        try (Scanner scanner = new Scanner(testFile)) {
-            while (scanner.hasNext()) {
-                // TODO: Scan for /ref=file qualifiers, etc, to determine run
-                // behavior
-                String token = scanner.next();
-                if (token.startsWith("/*")) {
-                    inComment = true;
-                } else if (token.endsWith(("*/"))) {
-                    inComment = false;
-                } else if (!inComment) {
-                    continue;
-                }
+        String allContent = new String(Files.readAllBytes(testFile));
+        Iterator<String> scanner = ScriptingFunctions.tokenizeString(allContent).iterator();
+        while (scanner.hasNext()) {
+            // TODO: Scan for /ref=file qualifiers, etc, to determine run
+            // behavior
+            String token = scanner.next();
+            if (token.startsWith("/*")) {
+                inComment = true;
+            } else if (token.endsWith(("*/"))) {
+                inComment = false;
+            } else if (!inComment) {
+                continue;
+            }
 
-                // remove whitespace and trailing semicolons, if any
-                // (trailing semicolons are found in some sputnik tests)
-                token = token.trim();
-                final int semicolon = token.indexOf(';');
-                if (semicolon > 0) {
-                    token = token.substring(0, semicolon);
-                }
-                switch (token) {
+            // remove whitespace and trailing semicolons, if any
+            // (trailing semicolons are found in some sputnik tests)
+            token = token.trim();
+            final int semicolon = token.indexOf(';');
+            if (semicolon > 0) {
+                token = token.substring(0, semicolon);
+            }
+            switch (token) {
                 case "@test":
                     isTest = true;
                     break;
@@ -308,24 +314,21 @@
                     break;
                 default:
                     break;
-                }
+            }
 
-                // negative tests are expected to fail at runtime only
-                // for those tests that are expected to fail at compile time,
-                // add @test/compile-error
-                if (token.equals("@negative") || token.equals("@strict_mode_negative")) {
-                    shouldRun = true;
-                    runFailure = true;
-                }
+            // negative tests are expected to fail at runtime only
+            // for those tests that are expected to fail at compile time,
+            // add @test/compile-error
+            if (token.equals("@negative") || token.equals("@strict_mode_negative")) {
+                shouldRun = true;
+                runFailure = true;
+            }
 
-                if (token.equals("@strict_mode") || token.equals("@strict_mode_negative") || token.equals("@onlyStrict") || token.equals("@noStrict")) {
-                    if (!strictModeEnabled()) {
-                        return;
-                    }
+            if (token.equals("@strict_mode") || token.equals("@strict_mode_negative") || token.equals("@onlyStrict") || token.equals("@noStrict")) {
+                if (!strictModeEnabled()) {
+                    return;
                 }
             }
-        } catch (final Exception ignored) {
-            return;
         }
 
         if (isTest) {
@@ -369,8 +372,8 @@
     private static final boolean OPTIMISTIC_OVERRIDE = true;
 
     /**
-     * Check if there is an optimistic override, that disables the default
-     * false optimistic types and sets them to true, for testing purposes
+     * Check if there is an optimistic override, that disables the default false
+     * optimistic types and sets them to true, for testing purposes
      *
      * @return true if optimistic type override has been set by test suite
      */
@@ -379,10 +382,9 @@
     }
 
     /**
-     * Add an optimistic-types=true option to an argument list if this
-     * is set to override the default false. Add an optimistic-types=true
-     * options to an argument list if this is set to override the default
-     * true
+     * Add an optimistic-types=true option to an argument list if this is set to
+     * override the default false. Add an optimistic-types=true options to an
+     * argument list if this is set to override the default true
      *
      * @args new argument list array
      */
@@ -396,8 +398,8 @@
     }
 
     /**
-     * Add an optimistic-types=true option to an argument list if this
-     * is set to override the default false
+     * Add an optimistic-types=true option to an argument list if this is set to
+     * override the default false
      *
      * @args argument list
      */
@@ -438,7 +440,7 @@
 
     private static void loadExcludesFile(final String testExcludesFile, final Set<String> testExcludeSet) throws XPathExpressionException {
         final XPath xpath = XPathFactory.newInstance().newXPath();
-        final NodeList testIds = (NodeList)xpath.evaluate("/excludeList/test/@id", new InputSource(testExcludesFile), XPathConstants.NODESET);
+        final NodeList testIds = (NodeList) xpath.evaluate("/excludeList/test/@id", new InputSource(testExcludesFile), XPathConstants.NODESET);
         for (int i = testIds.getLength() - 1; i >= 0; i--) {
             testExcludeSet.add(testIds.item(i).getNodeValue());
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/test/models/BigAbstract.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,4709 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public abstract class BigAbstract {
+    public static void accept(BigAbstract ba) {
+    }
+
+    public abstract void f0();
+    public abstract void f1();
+    public abstract void f2();
+    public abstract void f3();
+    public abstract void f4();
+    public abstract void f5();
+    public abstract void f6();
+    public abstract void f7();
+    public abstract void f8();
+    public abstract void f9();
+    public abstract void f10();
+    public abstract void f11();
+    public abstract void f12();
+    public abstract void f13();
+    public abstract void f14();
+    public abstract void f15();
+    public abstract void f16();
+    public abstract void f17();
+    public abstract void f18();
+    public abstract void f19();
+    public abstract void f20();
+    public abstract void f21();
+    public abstract void f22();
+    public abstract void f23();
+    public abstract void f24();
+    public abstract void f25();
+    public abstract void f26();
+    public abstract void f27();
+    public abstract void f28();
+    public abstract void f29();
+    public abstract void f30();
+    public abstract void f31();
+    public abstract void f32();
+    public abstract void f33();
+    public abstract void f34();
+    public abstract void f35();
+    public abstract void f36();
+    public abstract void f37();
+    public abstract void f38();
+    public abstract void f39();
+    public abstract void f40();
+    public abstract void f41();
+    public abstract void f42();
+    public abstract void f43();
+    public abstract void f44();
+    public abstract void f45();
+    public abstract void f46();
+    public abstract void f47();
+    public abstract void f48();
+    public abstract void f49();
+    public abstract void f50();
+    public abstract void f51();
+    public abstract void f52();
+    public abstract void f53();
+    public abstract void f54();
+    public abstract void f55();
+    public abstract void f56();
+    public abstract void f57();
+    public abstract void f58();
+    public abstract void f59();
+    public abstract void f60();
+    public abstract void f61();
+    public abstract void f62();
+    public abstract void f63();
+    public abstract void f64();
+    public abstract void f65();
+    public abstract void f66();
+    public abstract void f67();
+    public abstract void f68();
+    public abstract void f69();
+    public abstract void f70();
+    public abstract void f71();
+    public abstract void f72();
+    public abstract void f73();
+    public abstract void f74();
+    public abstract void f75();
+    public abstract void f76();
+    public abstract void f77();
+    public abstract void f78();
+    public abstract void f79();
+    public abstract void f80();
+    public abstract void f81();
+    public abstract void f82();
+    public abstract void f83();
+    public abstract void f84();
+    public abstract void f85();
+    public abstract void f86();
+    public abstract void f87();
+    public abstract void f88();
+    public abstract void f89();
+    public abstract void f90();
+    public abstract void f91();
+    public abstract void f92();
+    public abstract void f93();
+    public abstract void f94();
+    public abstract void f95();
+    public abstract void f96();
+    public abstract void f97();
+    public abstract void f98();
+    public abstract void f99();
+    public abstract void f100();
+    public abstract void f101();
+    public abstract void f102();
+    public abstract void f103();
+    public abstract void f104();
+    public abstract void f105();
+    public abstract void f106();
+    public abstract void f107();
+    public abstract void f108();
+    public abstract void f109();
+    public abstract void f110();
+    public abstract void f111();
+    public abstract void f112();
+    public abstract void f113();
+    public abstract void f114();
+    public abstract void f115();
+    public abstract void f116();
+    public abstract void f117();
+    public abstract void f118();
+    public abstract void f119();
+    public abstract void f120();
+    public abstract void f121();
+    public abstract void f122();
+    public abstract void f123();
+    public abstract void f124();
+    public abstract void f125();
+    public abstract void f126();
+    public abstract void f127();
+    public abstract void f128();
+    public abstract void f129();
+    public abstract void f130();
+    public abstract void f131();
+    public abstract void f132();
+    public abstract void f133();
+    public abstract void f134();
+    public abstract void f135();
+    public abstract void f136();
+    public abstract void f137();
+    public abstract void f138();
+    public abstract void f139();
+    public abstract void f140();
+    public abstract void f141();
+    public abstract void f142();
+    public abstract void f143();
+    public abstract void f144();
+    public abstract void f145();
+    public abstract void f146();
+    public abstract void f147();
+    public abstract void f148();
+    public abstract void f149();
+    public abstract void f150();
+    public abstract void f151();
+    public abstract void f152();
+    public abstract void f153();
+    public abstract void f154();
+    public abstract void f155();
+    public abstract void f156();
+    public abstract void f157();
+    public abstract void f158();
+    public abstract void f159();
+    public abstract void f160();
+    public abstract void f161();
+    public abstract void f162();
+    public abstract void f163();
+    public abstract void f164();
+    public abstract void f165();
+    public abstract void f166();
+    public abstract void f167();
+    public abstract void f168();
+    public abstract void f169();
+    public abstract void f170();
+    public abstract void f171();
+    public abstract void f172();
+    public abstract void f173();
+    public abstract void f174();
+    public abstract void f175();
+    public abstract void f176();
+    public abstract void f177();
+    public abstract void f178();
+    public abstract void f179();
+    public abstract void f180();
+    public abstract void f181();
+    public abstract void f182();
+    public abstract void f183();
+    public abstract void f184();
+    public abstract void f185();
+    public abstract void f186();
+    public abstract void f187();
+    public abstract void f188();
+    public abstract void f189();
+    public abstract void f190();
+    public abstract void f191();
+    public abstract void f192();
+    public abstract void f193();
+    public abstract void f194();
+    public abstract void f195();
+    public abstract void f196();
+    public abstract void f197();
+    public abstract void f198();
+    public abstract void f199();
+    public abstract void f200();
+    public abstract void f201();
+    public abstract void f202();
+    public abstract void f203();
+    public abstract void f204();
+    public abstract void f205();
+    public abstract void f206();
+    public abstract void f207();
+    public abstract void f208();
+    public abstract void f209();
+    public abstract void f210();
+    public abstract void f211();
+    public abstract void f212();
+    public abstract void f213();
+    public abstract void f214();
+    public abstract void f215();
+    public abstract void f216();
+    public abstract void f217();
+    public abstract void f218();
+    public abstract void f219();
+    public abstract void f220();
+    public abstract void f221();
+    public abstract void f222();
+    public abstract void f223();
+    public abstract void f224();
+    public abstract void f225();
+    public abstract void f226();
+    public abstract void f227();
+    public abstract void f228();
+    public abstract void f229();
+    public abstract void f230();
+    public abstract void f231();
+    public abstract void f232();
+    public abstract void f233();
+    public abstract void f234();
+    public abstract void f235();
+    public abstract void f236();
+    public abstract void f237();
+    public abstract void f238();
+    public abstract void f239();
+    public abstract void f240();
+    public abstract void f241();
+    public abstract void f242();
+    public abstract void f243();
+    public abstract void f244();
+    public abstract void f245();
+    public abstract void f246();
+    public abstract void f247();
+    public abstract void f248();
+    public abstract void f249();
+    public abstract void f250();
+    public abstract void f251();
+    public abstract void f252();
+    public abstract void f253();
+    public abstract void f254();
+    public abstract void f255();
+    public abstract void f256();
+    public abstract void f257();
+    public abstract void f258();
+    public abstract void f259();
+    public abstract void f260();
+    public abstract void f261();
+    public abstract void f262();
+    public abstract void f263();
+    public abstract void f264();
+    public abstract void f265();
+    public abstract void f266();
+    public abstract void f267();
+    public abstract void f268();
+    public abstract void f269();
+    public abstract void f270();
+    public abstract void f271();
+    public abstract void f272();
+    public abstract void f273();
+    public abstract void f274();
+    public abstract void f275();
+    public abstract void f276();
+    public abstract void f277();
+    public abstract void f278();
+    public abstract void f279();
+    public abstract void f280();
+    public abstract void f281();
+    public abstract void f282();
+    public abstract void f283();
+    public abstract void f284();
+    public abstract void f285();
+    public abstract void f286();
+    public abstract void f287();
+    public abstract void f288();
+    public abstract void f289();
+    public abstract void f290();
+    public abstract void f291();
+    public abstract void f292();
+    public abstract void f293();
+    public abstract void f294();
+    public abstract void f295();
+    public abstract void f296();
+    public abstract void f297();
+    public abstract void f298();
+    public abstract void f299();
+    public abstract void f300();
+    public abstract void f301();
+    public abstract void f302();
+    public abstract void f303();
+    public abstract void f304();
+    public abstract void f305();
+    public abstract void f306();
+    public abstract void f307();
+    public abstract void f308();
+    public abstract void f309();
+    public abstract void f310();
+    public abstract void f311();
+    public abstract void f312();
+    public abstract void f313();
+    public abstract void f314();
+    public abstract void f315();
+    public abstract void f316();
+    public abstract void f317();
+    public abstract void f318();
+    public abstract void f319();
+    public abstract void f320();
+    public abstract void f321();
+    public abstract void f322();
+    public abstract void f323();
+    public abstract void f324();
+    public abstract void f325();
+    public abstract void f326();
+    public abstract void f327();
+    public abstract void f328();
+    public abstract void f329();
+    public abstract void f330();
+    public abstract void f331();
+    public abstract void f332();
+    public abstract void f333();
+    public abstract void f334();
+    public abstract void f335();
+    public abstract void f336();
+    public abstract void f337();
+    public abstract void f338();
+    public abstract void f339();
+    public abstract void f340();
+    public abstract void f341();
+    public abstract void f342();
+    public abstract void f343();
+    public abstract void f344();
+    public abstract void f345();
+    public abstract void f346();
+    public abstract void f347();
+    public abstract void f348();
+    public abstract void f349();
+    public abstract void f350();
+    public abstract void f351();
+    public abstract void f352();
+    public abstract void f353();
+    public abstract void f354();
+    public abstract void f355();
+    public abstract void f356();
+    public abstract void f357();
+    public abstract void f358();
+    public abstract void f359();
+    public abstract void f360();
+    public abstract void f361();
+    public abstract void f362();
+    public abstract void f363();
+    public abstract void f364();
+    public abstract void f365();
+    public abstract void f366();
+    public abstract void f367();
+    public abstract void f368();
+    public abstract void f369();
+    public abstract void f370();
+    public abstract void f371();
+    public abstract void f372();
+    public abstract void f373();
+    public abstract void f374();
+    public abstract void f375();
+    public abstract void f376();
+    public abstract void f377();
+    public abstract void f378();
+    public abstract void f379();
+    public abstract void f380();
+    public abstract void f381();
+    public abstract void f382();
+    public abstract void f383();
+    public abstract void f384();
+    public abstract void f385();
+    public abstract void f386();
+    public abstract void f387();
+    public abstract void f388();
+    public abstract void f389();
+    public abstract void f390();
+    public abstract void f391();
+    public abstract void f392();
+    public abstract void f393();
+    public abstract void f394();
+    public abstract void f395();
+    public abstract void f396();
+    public abstract void f397();
+    public abstract void f398();
+    public abstract void f399();
+    public abstract void f400();
+    public abstract void f401();
+    public abstract void f402();
+    public abstract void f403();
+    public abstract void f404();
+    public abstract void f405();
+    public abstract void f406();
+    public abstract void f407();
+    public abstract void f408();
+    public abstract void f409();
+    public abstract void f410();
+    public abstract void f411();
+    public abstract void f412();
+    public abstract void f413();
+    public abstract void f414();
+    public abstract void f415();
+    public abstract void f416();
+    public abstract void f417();
+    public abstract void f418();
+    public abstract void f419();
+    public abstract void f420();
+    public abstract void f421();
+    public abstract void f422();
+    public abstract void f423();
+    public abstract void f424();
+    public abstract void f425();
+    public abstract void f426();
+    public abstract void f427();
+    public abstract void f428();
+    public abstract void f429();
+    public abstract void f430();
+    public abstract void f431();
+    public abstract void f432();
+    public abstract void f433();
+    public abstract void f434();
+    public abstract void f435();
+    public abstract void f436();
+    public abstract void f437();
+    public abstract void f438();
+    public abstract void f439();
+    public abstract void f440();
+    public abstract void f441();
+    public abstract void f442();
+    public abstract void f443();
+    public abstract void f444();
+    public abstract void f445();
+    public abstract void f446();
+    public abstract void f447();
+    public abstract void f448();
+    public abstract void f449();
+    public abstract void f450();
+    public abstract void f451();
+    public abstract void f452();
+    public abstract void f453();
+    public abstract void f454();
+    public abstract void f455();
+    public abstract void f456();
+    public abstract void f457();
+    public abstract void f458();
+    public abstract void f459();
+    public abstract void f460();
+    public abstract void f461();
+    public abstract void f462();
+    public abstract void f463();
+    public abstract void f464();
+    public abstract void f465();
+    public abstract void f466();
+    public abstract void f467();
+    public abstract void f468();
+    public abstract void f469();
+    public abstract void f470();
+    public abstract void f471();
+    public abstract void f472();
+    public abstract void f473();
+    public abstract void f474();
+    public abstract void f475();
+    public abstract void f476();
+    public abstract void f477();
+    public abstract void f478();
+    public abstract void f479();
+    public abstract void f480();
+    public abstract void f481();
+    public abstract void f482();
+    public abstract void f483();
+    public abstract void f484();
+    public abstract void f485();
+    public abstract void f486();
+    public abstract void f487();
+    public abstract void f488();
+    public abstract void f489();
+    public abstract void f490();
+    public abstract void f491();
+    public abstract void f492();
+    public abstract void f493();
+    public abstract void f494();
+    public abstract void f495();
+    public abstract void f496();
+    public abstract void f497();
+    public abstract void f498();
+    public abstract void f499();
+    public abstract void f500();
+    public abstract void f501();
+    public abstract void f502();
+    public abstract void f503();
+    public abstract void f504();
+    public abstract void f505();
+    public abstract void f506();
+    public abstract void f507();
+    public abstract void f508();
+    public abstract void f509();
+    public abstract void f510();
+    public abstract void f511();
+    public abstract void f512();
+    public abstract void f513();
+    public abstract void f514();
+    public abstract void f515();
+    public abstract void f516();
+    public abstract void f517();
+    public abstract void f518();
+    public abstract void f519();
+    public abstract void f520();
+    public abstract void f521();
+    public abstract void f522();
+    public abstract void f523();
+    public abstract void f524();
+    public abstract void f525();
+    public abstract void f526();
+    public abstract void f527();
+    public abstract void f528();
+    public abstract void f529();
+    public abstract void f530();
+    public abstract void f531();
+    public abstract void f532();
+    public abstract void f533();
+    public abstract void f534();
+    public abstract void f535();
+    public abstract void f536();
+    public abstract void f537();
+    public abstract void f538();
+    public abstract void f539();
+    public abstract void f540();
+    public abstract void f541();
+    public abstract void f542();
+    public abstract void f543();
+    public abstract void f544();
+    public abstract void f545();
+    public abstract void f546();
+    public abstract void f547();
+    public abstract void f548();
+    public abstract void f549();
+    public abstract void f550();
+    public abstract void f551();
+    public abstract void f552();
+    public abstract void f553();
+    public abstract void f554();
+    public abstract void f555();
+    public abstract void f556();
+    public abstract void f557();
+    public abstract void f558();
+    public abstract void f559();
+    public abstract void f560();
+    public abstract void f561();
+    public abstract void f562();
+    public abstract void f563();
+    public abstract void f564();
+    public abstract void f565();
+    public abstract void f566();
+    public abstract void f567();
+    public abstract void f568();
+    public abstract void f569();
+    public abstract void f570();
+    public abstract void f571();
+    public abstract void f572();
+    public abstract void f573();
+    public abstract void f574();
+    public abstract void f575();
+    public abstract void f576();
+    public abstract void f577();
+    public abstract void f578();
+    public abstract void f579();
+    public abstract void f580();
+    public abstract void f581();
+    public abstract void f582();
+    public abstract void f583();
+    public abstract void f584();
+    public abstract void f585();
+    public abstract void f586();
+    public abstract void f587();
+    public abstract void f588();
+    public abstract void f589();
+    public abstract void f590();
+    public abstract void f591();
+    public abstract void f592();
+    public abstract void f593();
+    public abstract void f594();
+    public abstract void f595();
+    public abstract void f596();
+    public abstract void f597();
+    public abstract void f598();
+    public abstract void f599();
+    public abstract void f600();
+    public abstract void f601();
+    public abstract void f602();
+    public abstract void f603();
+    public abstract void f604();
+    public abstract void f605();
+    public abstract void f606();
+    public abstract void f607();
+    public abstract void f608();
+    public abstract void f609();
+    public abstract void f610();
+    public abstract void f611();
+    public abstract void f612();
+    public abstract void f613();
+    public abstract void f614();
+    public abstract void f615();
+    public abstract void f616();
+    public abstract void f617();
+    public abstract void f618();
+    public abstract void f619();
+    public abstract void f620();
+    public abstract void f621();
+    public abstract void f622();
+    public abstract void f623();
+    public abstract void f624();
+    public abstract void f625();
+    public abstract void f626();
+    public abstract void f627();
+    public abstract void f628();
+    public abstract void f629();
+    public abstract void f630();
+    public abstract void f631();
+    public abstract void f632();
+    public abstract void f633();
+    public abstract void f634();
+    public abstract void f635();
+    public abstract void f636();
+    public abstract void f637();
+    public abstract void f638();
+    public abstract void f639();
+    public abstract void f640();
+    public abstract void f641();
+    public abstract void f642();
+    public abstract void f643();
+    public abstract void f644();
+    public abstract void f645();
+    public abstract void f646();
+    public abstract void f647();
+    public abstract void f648();
+    public abstract void f649();
+    public abstract void f650();
+    public abstract void f651();
+    public abstract void f652();
+    public abstract void f653();
+    public abstract void f654();
+    public abstract void f655();
+    public abstract void f656();
+    public abstract void f657();
+    public abstract void f658();
+    public abstract void f659();
+    public abstract void f660();
+    public abstract void f661();
+    public abstract void f662();
+    public abstract void f663();
+    public abstract void f664();
+    public abstract void f665();
+    public abstract void f666();
+    public abstract void f667();
+    public abstract void f668();
+    public abstract void f669();
+    public abstract void f670();
+    public abstract void f671();
+    public abstract void f672();
+    public abstract void f673();
+    public abstract void f674();
+    public abstract void f675();
+    public abstract void f676();
+    public abstract void f677();
+    public abstract void f678();
+    public abstract void f679();
+    public abstract void f680();
+    public abstract void f681();
+    public abstract void f682();
+    public abstract void f683();
+    public abstract void f684();
+    public abstract void f685();
+    public abstract void f686();
+    public abstract void f687();
+    public abstract void f688();
+    public abstract void f689();
+    public abstract void f690();
+    public abstract void f691();
+    public abstract void f692();
+    public abstract void f693();
+    public abstract void f694();
+    public abstract void f695();
+    public abstract void f696();
+    public abstract void f697();
+    public abstract void f698();
+    public abstract void f699();
+    public abstract void f700();
+    public abstract void f701();
+    public abstract void f702();
+    public abstract void f703();
+    public abstract void f704();
+    public abstract void f705();
+    public abstract void f706();
+    public abstract void f707();
+    public abstract void f708();
+    public abstract void f709();
+    public abstract void f710();
+    public abstract void f711();
+    public abstract void f712();
+    public abstract void f713();
+    public abstract void f714();
+    public abstract void f715();
+    public abstract void f716();
+    public abstract void f717();
+    public abstract void f718();
+    public abstract void f719();
+    public abstract void f720();
+    public abstract void f721();
+    public abstract void f722();
+    public abstract void f723();
+    public abstract void f724();
+    public abstract void f725();
+    public abstract void f726();
+    public abstract void f727();
+    public abstract void f728();
+    public abstract void f729();
+    public abstract void f730();
+    public abstract void f731();
+    public abstract void f732();
+    public abstract void f733();
+    public abstract void f734();
+    public abstract void f735();
+    public abstract void f736();
+    public abstract void f737();
+    public abstract void f738();
+    public abstract void f739();
+    public abstract void f740();
+    public abstract void f741();
+    public abstract void f742();
+    public abstract void f743();
+    public abstract void f744();
+    public abstract void f745();
+    public abstract void f746();
+    public abstract void f747();
+    public abstract void f748();
+    public abstract void f749();
+    public abstract void f750();
+    public abstract void f751();
+    public abstract void f752();
+    public abstract void f753();
+    public abstract void f754();
+    public abstract void f755();
+    public abstract void f756();
+    public abstract void f757();
+    public abstract void f758();
+    public abstract void f759();
+    public abstract void f760();
+    public abstract void f761();
+    public abstract void f762();
+    public abstract void f763();
+    public abstract void f764();
+    public abstract void f765();
+    public abstract void f766();
+    public abstract void f767();
+    public abstract void f768();
+    public abstract void f769();
+    public abstract void f770();
+    public abstract void f771();
+    public abstract void f772();
+    public abstract void f773();
+    public abstract void f774();
+    public abstract void f775();
+    public abstract void f776();
+    public abstract void f777();
+    public abstract void f778();
+    public abstract void f779();
+    public abstract void f780();
+    public abstract void f781();
+    public abstract void f782();
+    public abstract void f783();
+    public abstract void f784();
+    public abstract void f785();
+    public abstract void f786();
+    public abstract void f787();
+    public abstract void f788();
+    public abstract void f789();
+    public abstract void f790();
+    public abstract void f791();
+    public abstract void f792();
+    public abstract void f793();
+    public abstract void f794();
+    public abstract void f795();
+    public abstract void f796();
+    public abstract void f797();
+    public abstract void f798();
+    public abstract void f799();
+    public abstract void f800();
+    public abstract void f801();
+    public abstract void f802();
+    public abstract void f803();
+    public abstract void f804();
+    public abstract void f805();
+    public abstract void f806();
+    public abstract void f807();
+    public abstract void f808();
+    public abstract void f809();
+    public abstract void f810();
+    public abstract void f811();
+    public abstract void f812();
+    public abstract void f813();
+    public abstract void f814();
+    public abstract void f815();
+    public abstract void f816();
+    public abstract void f817();
+    public abstract void f818();
+    public abstract void f819();
+    public abstract void f820();
+    public abstract void f821();
+    public abstract void f822();
+    public abstract void f823();
+    public abstract void f824();
+    public abstract void f825();
+    public abstract void f826();
+    public abstract void f827();
+    public abstract void f828();
+    public abstract void f829();
+    public abstract void f830();
+    public abstract void f831();
+    public abstract void f832();
+    public abstract void f833();
+    public abstract void f834();
+    public abstract void f835();
+    public abstract void f836();
+    public abstract void f837();
+    public abstract void f838();
+    public abstract void f839();
+    public abstract void f840();
+    public abstract void f841();
+    public abstract void f842();
+    public abstract void f843();
+    public abstract void f844();
+    public abstract void f845();
+    public abstract void f846();
+    public abstract void f847();
+    public abstract void f848();
+    public abstract void f849();
+    public abstract void f850();
+    public abstract void f851();
+    public abstract void f852();
+    public abstract void f853();
+    public abstract void f854();
+    public abstract void f855();
+    public abstract void f856();
+    public abstract void f857();
+    public abstract void f858();
+    public abstract void f859();
+    public abstract void f860();
+    public abstract void f861();
+    public abstract void f862();
+    public abstract void f863();
+    public abstract void f864();
+    public abstract void f865();
+    public abstract void f866();
+    public abstract void f867();
+    public abstract void f868();
+    public abstract void f869();
+    public abstract void f870();
+    public abstract void f871();
+    public abstract void f872();
+    public abstract void f873();
+    public abstract void f874();
+    public abstract void f875();
+    public abstract void f876();
+    public abstract void f877();
+    public abstract void f878();
+    public abstract void f879();
+    public abstract void f880();
+    public abstract void f881();
+    public abstract void f882();
+    public abstract void f883();
+    public abstract void f884();
+    public abstract void f885();
+    public abstract void f886();
+    public abstract void f887();
+    public abstract void f888();
+    public abstract void f889();
+    public abstract void f890();
+    public abstract void f891();
+    public abstract void f892();
+    public abstract void f893();
+    public abstract void f894();
+    public abstract void f895();
+    public abstract void f896();
+    public abstract void f897();
+    public abstract void f898();
+    public abstract void f899();
+    public abstract void f900();
+    public abstract void f901();
+    public abstract void f902();
+    public abstract void f903();
+    public abstract void f904();
+    public abstract void f905();
+    public abstract void f906();
+    public abstract void f907();
+    public abstract void f908();
+    public abstract void f909();
+    public abstract void f910();
+    public abstract void f911();
+    public abstract void f912();
+    public abstract void f913();
+    public abstract void f914();
+    public abstract void f915();
+    public abstract void f916();
+    public abstract void f917();
+    public abstract void f918();
+    public abstract void f919();
+    public abstract void f920();
+    public abstract void f921();
+    public abstract void f922();
+    public abstract void f923();
+    public abstract void f924();
+    public abstract void f925();
+    public abstract void f926();
+    public abstract void f927();
+    public abstract void f928();
+    public abstract void f929();
+    public abstract void f930();
+    public abstract void f931();
+    public abstract void f932();
+    public abstract void f933();
+    public abstract void f934();
+    public abstract void f935();
+    public abstract void f936();
+    public abstract void f937();
+    public abstract void f938();
+    public abstract void f939();
+    public abstract void f940();
+    public abstract void f941();
+    public abstract void f942();
+    public abstract void f943();
+    public abstract void f944();
+    public abstract void f945();
+    public abstract void f946();
+    public abstract void f947();
+    public abstract void f948();
+    public abstract void f949();
+    public abstract void f950();
+    public abstract void f951();
+    public abstract void f952();
+    public abstract void f953();
+    public abstract void f954();
+    public abstract void f955();
+    public abstract void f956();
+    public abstract void f957();
+    public abstract void f958();
+    public abstract void f959();
+    public abstract void f960();
+    public abstract void f961();
+    public abstract void f962();
+    public abstract void f963();
+    public abstract void f964();
+    public abstract void f965();
+    public abstract void f966();
+    public abstract void f967();
+    public abstract void f968();
+    public abstract void f969();
+    public abstract void f970();
+    public abstract void f971();
+    public abstract void f972();
+    public abstract void f973();
+    public abstract void f974();
+    public abstract void f975();
+    public abstract void f976();
+    public abstract void f977();
+    public abstract void f978();
+    public abstract void f979();
+    public abstract void f980();
+    public abstract void f981();
+    public abstract void f982();
+    public abstract void f983();
+    public abstract void f984();
+    public abstract void f985();
+    public abstract void f986();
+    public abstract void f987();
+    public abstract void f988();
+    public abstract void f989();
+    public abstract void f990();
+    public abstract void f991();
+    public abstract void f992();
+    public abstract void f993();
+    public abstract void f994();
+    public abstract void f995();
+    public abstract void f996();
+    public abstract void f997();
+    public abstract void f998();
+    public abstract void f999();
+    public abstract void f1000();
+    public abstract void f1001();
+    public abstract void f1002();
+    public abstract void f1003();
+    public abstract void f1004();
+    public abstract void f1005();
+    public abstract void f1006();
+    public abstract void f1007();
+    public abstract void f1008();
+    public abstract void f1009();
+    public abstract void f1010();
+    public abstract void f1011();
+    public abstract void f1012();
+    public abstract void f1013();
+    public abstract void f1014();
+    public abstract void f1015();
+    public abstract void f1016();
+    public abstract void f1017();
+    public abstract void f1018();
+    public abstract void f1019();
+    public abstract void f1020();
+    public abstract void f1021();
+    public abstract void f1022();
+    public abstract void f1023();
+    public abstract void f1024();
+    public abstract void f1025();
+    public abstract void f1026();
+    public abstract void f1027();
+    public abstract void f1028();
+    public abstract void f1029();
+    public abstract void f1030();
+    public abstract void f1031();
+    public abstract void f1032();
+    public abstract void f1033();
+    public abstract void f1034();
+    public abstract void f1035();
+    public abstract void f1036();
+    public abstract void f1037();
+    public abstract void f1038();
+    public abstract void f1039();
+    public abstract void f1040();
+    public abstract void f1041();
+    public abstract void f1042();
+    public abstract void f1043();
+    public abstract void f1044();
+    public abstract void f1045();
+    public abstract void f1046();
+    public abstract void f1047();
+    public abstract void f1048();
+    public abstract void f1049();
+    public abstract void f1050();
+    public abstract void f1051();
+    public abstract void f1052();
+    public abstract void f1053();
+    public abstract void f1054();
+    public abstract void f1055();
+    public abstract void f1056();
+    public abstract void f1057();
+    public abstract void f1058();
+    public abstract void f1059();
+    public abstract void f1060();
+    public abstract void f1061();
+    public abstract void f1062();
+    public abstract void f1063();
+    public abstract void f1064();
+    public abstract void f1065();
+    public abstract void f1066();
+    public abstract void f1067();
+    public abstract void f1068();
+    public abstract void f1069();
+    public abstract void f1070();
+    public abstract void f1071();
+    public abstract void f1072();
+    public abstract void f1073();
+    public abstract void f1074();
+    public abstract void f1075();
+    public abstract void f1076();
+    public abstract void f1077();
+    public abstract void f1078();
+    public abstract void f1079();
+    public abstract void f1080();
+    public abstract void f1081();
+    public abstract void f1082();
+    public abstract void f1083();
+    public abstract void f1084();
+    public abstract void f1085();
+    public abstract void f1086();
+    public abstract void f1087();
+    public abstract void f1088();
+    public abstract void f1089();
+    public abstract void f1090();
+    public abstract void f1091();
+    public abstract void f1092();
+    public abstract void f1093();
+    public abstract void f1094();
+    public abstract void f1095();
+    public abstract void f1096();
+    public abstract void f1097();
+    public abstract void f1098();
+    public abstract void f1099();
+    public abstract void f1100();
+    public abstract void f1101();
+    public abstract void f1102();
+    public abstract void f1103();
+    public abstract void f1104();
+    public abstract void f1105();
+    public abstract void f1106();
+    public abstract void f1107();
+    public abstract void f1108();
+    public abstract void f1109();
+    public abstract void f1110();
+    public abstract void f1111();
+    public abstract void f1112();
+    public abstract void f1113();
+    public abstract void f1114();
+    public abstract void f1115();
+    public abstract void f1116();
+    public abstract void f1117();
+    public abstract void f1118();
+    public abstract void f1119();
+    public abstract void f1120();
+    public abstract void f1121();
+    public abstract void f1122();
+    public abstract void f1123();
+    public abstract void f1124();
+    public abstract void f1125();
+    public abstract void f1126();
+    public abstract void f1127();
+    public abstract void f1128();
+    public abstract void f1129();
+    public abstract void f1130();
+    public abstract void f1131();
+    public abstract void f1132();
+    public abstract void f1133();
+    public abstract void f1134();
+    public abstract void f1135();
+    public abstract void f1136();
+    public abstract void f1137();
+    public abstract void f1138();
+    public abstract void f1139();
+    public abstract void f1140();
+    public abstract void f1141();
+    public abstract void f1142();
+    public abstract void f1143();
+    public abstract void f1144();
+    public abstract void f1145();
+    public abstract void f1146();
+    public abstract void f1147();
+    public abstract void f1148();
+    public abstract void f1149();
+    public abstract void f1150();
+    public abstract void f1151();
+    public abstract void f1152();
+    public abstract void f1153();
+    public abstract void f1154();
+    public abstract void f1155();
+    public abstract void f1156();
+    public abstract void f1157();
+    public abstract void f1158();
+    public abstract void f1159();
+    public abstract void f1160();
+    public abstract void f1161();
+    public abstract void f1162();
+    public abstract void f1163();
+    public abstract void f1164();
+    public abstract void f1165();
+    public abstract void f1166();
+    public abstract void f1167();
+    public abstract void f1168();
+    public abstract void f1169();
+    public abstract void f1170();
+    public abstract void f1171();
+    public abstract void f1172();
+    public abstract void f1173();
+    public abstract void f1174();
+    public abstract void f1175();
+    public abstract void f1176();
+    public abstract void f1177();
+    public abstract void f1178();
+    public abstract void f1179();
+    public abstract void f1180();
+    public abstract void f1181();
+    public abstract void f1182();
+    public abstract void f1183();
+    public abstract void f1184();
+    public abstract void f1185();
+    public abstract void f1186();
+    public abstract void f1187();
+    public abstract void f1188();
+    public abstract void f1189();
+    public abstract void f1190();
+    public abstract void f1191();
+    public abstract void f1192();
+    public abstract void f1193();
+    public abstract void f1194();
+    public abstract void f1195();
+    public abstract void f1196();
+    public abstract void f1197();
+    public abstract void f1198();
+    public abstract void f1199();
+    public abstract void f1200();
+    public abstract void f1201();
+    public abstract void f1202();
+    public abstract void f1203();
+    public abstract void f1204();
+    public abstract void f1205();
+    public abstract void f1206();
+    public abstract void f1207();
+    public abstract void f1208();
+    public abstract void f1209();
+    public abstract void f1210();
+    public abstract void f1211();
+    public abstract void f1212();
+    public abstract void f1213();
+    public abstract void f1214();
+    public abstract void f1215();
+    public abstract void f1216();
+    public abstract void f1217();
+    public abstract void f1218();
+    public abstract void f1219();
+    public abstract void f1220();
+    public abstract void f1221();
+    public abstract void f1222();
+    public abstract void f1223();
+    public abstract void f1224();
+    public abstract void f1225();
+    public abstract void f1226();
+    public abstract void f1227();
+    public abstract void f1228();
+    public abstract void f1229();
+    public abstract void f1230();
+    public abstract void f1231();
+    public abstract void f1232();
+    public abstract void f1233();
+    public abstract void f1234();
+    public abstract void f1235();
+    public abstract void f1236();
+    public abstract void f1237();
+    public abstract void f1238();
+    public abstract void f1239();
+    public abstract void f1240();
+    public abstract void f1241();
+    public abstract void f1242();
+    public abstract void f1243();
+    public abstract void f1244();
+    public abstract void f1245();
+    public abstract void f1246();
+    public abstract void f1247();
+    public abstract void f1248();
+    public abstract void f1249();
+    public abstract void f1250();
+    public abstract void f1251();
+    public abstract void f1252();
+    public abstract void f1253();
+    public abstract void f1254();
+    public abstract void f1255();
+    public abstract void f1256();
+    public abstract void f1257();
+    public abstract void f1258();
+    public abstract void f1259();
+    public abstract void f1260();
+    public abstract void f1261();
+    public abstract void f1262();
+    public abstract void f1263();
+    public abstract void f1264();
+    public abstract void f1265();
+    public abstract void f1266();
+    public abstract void f1267();
+    public abstract void f1268();
+    public abstract void f1269();
+    public abstract void f1270();
+    public abstract void f1271();
+    public abstract void f1272();
+    public abstract void f1273();
+    public abstract void f1274();
+    public abstract void f1275();
+    public abstract void f1276();
+    public abstract void f1277();
+    public abstract void f1278();
+    public abstract void f1279();
+    public abstract void f1280();
+    public abstract void f1281();
+    public abstract void f1282();
+    public abstract void f1283();
+    public abstract void f1284();
+    public abstract void f1285();
+    public abstract void f1286();
+    public abstract void f1287();
+    public abstract void f1288();
+    public abstract void f1289();
+    public abstract void f1290();
+    public abstract void f1291();
+    public abstract void f1292();
+    public abstract void f1293();
+    public abstract void f1294();
+    public abstract void f1295();
+    public abstract void f1296();
+    public abstract void f1297();
+    public abstract void f1298();
+    public abstract void f1299();
+    public abstract void f1300();
+    public abstract void f1301();
+    public abstract void f1302();
+    public abstract void f1303();
+    public abstract void f1304();
+    public abstract void f1305();
+    public abstract void f1306();
+    public abstract void f1307();
+    public abstract void f1308();
+    public abstract void f1309();
+    public abstract void f1310();
+    public abstract void f1311();
+    public abstract void f1312();
+    public abstract void f1313();
+    public abstract void f1314();
+    public abstract void f1315();
+    public abstract void f1316();
+    public abstract void f1317();
+    public abstract void f1318();
+    public abstract void f1319();
+    public abstract void f1320();
+    public abstract void f1321();
+    public abstract void f1322();
+    public abstract void f1323();
+    public abstract void f1324();
+    public abstract void f1325();
+    public abstract void f1326();
+    public abstract void f1327();
+    public abstract void f1328();
+    public abstract void f1329();
+    public abstract void f1330();
+    public abstract void f1331();
+    public abstract void f1332();
+    public abstract void f1333();
+    public abstract void f1334();
+    public abstract void f1335();
+    public abstract void f1336();
+    public abstract void f1337();
+    public abstract void f1338();
+    public abstract void f1339();
+    public abstract void f1340();
+    public abstract void f1341();
+    public abstract void f1342();
+    public abstract void f1343();
+    public abstract void f1344();
+    public abstract void f1345();
+    public abstract void f1346();
+    public abstract void f1347();
+    public abstract void f1348();
+    public abstract void f1349();
+    public abstract void f1350();
+    public abstract void f1351();
+    public abstract void f1352();
+    public abstract void f1353();
+    public abstract void f1354();
+    public abstract void f1355();
+    public abstract void f1356();
+    public abstract void f1357();
+    public abstract void f1358();
+    public abstract void f1359();
+    public abstract void f1360();
+    public abstract void f1361();
+    public abstract void f1362();
+    public abstract void f1363();
+    public abstract void f1364();
+    public abstract void f1365();
+    public abstract void f1366();
+    public abstract void f1367();
+    public abstract void f1368();
+    public abstract void f1369();
+    public abstract void f1370();
+    public abstract void f1371();
+    public abstract void f1372();
+    public abstract void f1373();
+    public abstract void f1374();
+    public abstract void f1375();
+    public abstract void f1376();
+    public abstract void f1377();
+    public abstract void f1378();
+    public abstract void f1379();
+    public abstract void f1380();
+    public abstract void f1381();
+    public abstract void f1382();
+    public abstract void f1383();
+    public abstract void f1384();
+    public abstract void f1385();
+    public abstract void f1386();
+    public abstract void f1387();
+    public abstract void f1388();
+    public abstract void f1389();
+    public abstract void f1390();
+    public abstract void f1391();
+    public abstract void f1392();
+    public abstract void f1393();
+    public abstract void f1394();
+    public abstract void f1395();
+    public abstract void f1396();
+    public abstract void f1397();
+    public abstract void f1398();
+    public abstract void f1399();
+    public abstract void f1400();
+    public abstract void f1401();
+    public abstract void f1402();
+    public abstract void f1403();
+    public abstract void f1404();
+    public abstract void f1405();
+    public abstract void f1406();
+    public abstract void f1407();
+    public abstract void f1408();
+    public abstract void f1409();
+    public abstract void f1410();
+    public abstract void f1411();
+    public abstract void f1412();
+    public abstract void f1413();
+    public abstract void f1414();
+    public abstract void f1415();
+    public abstract void f1416();
+    public abstract void f1417();
+    public abstract void f1418();
+    public abstract void f1419();
+    public abstract void f1420();
+    public abstract void f1421();
+    public abstract void f1422();
+    public abstract void f1423();
+    public abstract void f1424();
+    public abstract void f1425();
+    public abstract void f1426();
+    public abstract void f1427();
+    public abstract void f1428();
+    public abstract void f1429();
+    public abstract void f1430();
+    public abstract void f1431();
+    public abstract void f1432();
+    public abstract void f1433();
+    public abstract void f1434();
+    public abstract void f1435();
+    public abstract void f1436();
+    public abstract void f1437();
+    public abstract void f1438();
+    public abstract void f1439();
+    public abstract void f1440();
+    public abstract void f1441();
+    public abstract void f1442();
+    public abstract void f1443();
+    public abstract void f1444();
+    public abstract void f1445();
+    public abstract void f1446();
+    public abstract void f1447();
+    public abstract void f1448();
+    public abstract void f1449();
+    public abstract void f1450();
+    public abstract void f1451();
+    public abstract void f1452();
+    public abstract void f1453();
+    public abstract void f1454();
+    public abstract void f1455();
+    public abstract void f1456();
+    public abstract void f1457();
+    public abstract void f1458();
+    public abstract void f1459();
+    public abstract void f1460();
+    public abstract void f1461();
+    public abstract void f1462();
+    public abstract void f1463();
+    public abstract void f1464();
+    public abstract void f1465();
+    public abstract void f1466();
+    public abstract void f1467();
+    public abstract void f1468();
+    public abstract void f1469();
+    public abstract void f1470();
+    public abstract void f1471();
+    public abstract void f1472();
+    public abstract void f1473();
+    public abstract void f1474();
+    public abstract void f1475();
+    public abstract void f1476();
+    public abstract void f1477();
+    public abstract void f1478();
+    public abstract void f1479();
+    public abstract void f1480();
+    public abstract void f1481();
+    public abstract void f1482();
+    public abstract void f1483();
+    public abstract void f1484();
+    public abstract void f1485();
+    public abstract void f1486();
+    public abstract void f1487();
+    public abstract void f1488();
+    public abstract void f1489();
+    public abstract void f1490();
+    public abstract void f1491();
+    public abstract void f1492();
+    public abstract void f1493();
+    public abstract void f1494();
+    public abstract void f1495();
+    public abstract void f1496();
+    public abstract void f1497();
+    public abstract void f1498();
+    public abstract void f1499();
+    public abstract void f1500();
+    public abstract void f1501();
+    public abstract void f1502();
+    public abstract void f1503();
+    public abstract void f1504();
+    public abstract void f1505();
+    public abstract void f1506();
+    public abstract void f1507();
+    public abstract void f1508();
+    public abstract void f1509();
+    public abstract void f1510();
+    public abstract void f1511();
+    public abstract void f1512();
+    public abstract void f1513();
+    public abstract void f1514();
+    public abstract void f1515();
+    public abstract void f1516();
+    public abstract void f1517();
+    public abstract void f1518();
+    public abstract void f1519();
+    public abstract void f1520();
+    public abstract void f1521();
+    public abstract void f1522();
+    public abstract void f1523();
+    public abstract void f1524();
+    public abstract void f1525();
+    public abstract void f1526();
+    public abstract void f1527();
+    public abstract void f1528();
+    public abstract void f1529();
+    public abstract void f1530();
+    public abstract void f1531();
+    public abstract void f1532();
+    public abstract void f1533();
+    public abstract void f1534();
+    public abstract void f1535();
+    public abstract void f1536();
+    public abstract void f1537();
+    public abstract void f1538();
+    public abstract void f1539();
+    public abstract void f1540();
+    public abstract void f1541();
+    public abstract void f1542();
+    public abstract void f1543();
+    public abstract void f1544();
+    public abstract void f1545();
+    public abstract void f1546();
+    public abstract void f1547();
+    public abstract void f1548();
+    public abstract void f1549();
+    public abstract void f1550();
+    public abstract void f1551();
+    public abstract void f1552();
+    public abstract void f1553();
+    public abstract void f1554();
+    public abstract void f1555();
+    public abstract void f1556();
+    public abstract void f1557();
+    public abstract void f1558();
+    public abstract void f1559();
+    public abstract void f1560();
+    public abstract void f1561();
+    public abstract void f1562();
+    public abstract void f1563();
+    public abstract void f1564();
+    public abstract void f1565();
+    public abstract void f1566();
+    public abstract void f1567();
+    public abstract void f1568();
+    public abstract void f1569();
+    public abstract void f1570();
+    public abstract void f1571();
+    public abstract void f1572();
+    public abstract void f1573();
+    public abstract void f1574();
+    public abstract void f1575();
+    public abstract void f1576();
+    public abstract void f1577();
+    public abstract void f1578();
+    public abstract void f1579();
+    public abstract void f1580();
+    public abstract void f1581();
+    public abstract void f1582();
+    public abstract void f1583();
+    public abstract void f1584();
+    public abstract void f1585();
+    public abstract void f1586();
+    public abstract void f1587();
+    public abstract void f1588();
+    public abstract void f1589();
+    public abstract void f1590();
+    public abstract void f1591();
+    public abstract void f1592();
+    public abstract void f1593();
+    public abstract void f1594();
+    public abstract void f1595();
+    public abstract void f1596();
+    public abstract void f1597();
+    public abstract void f1598();
+    public abstract void f1599();
+    public abstract void f1600();
+    public abstract void f1601();
+    public abstract void f1602();
+    public abstract void f1603();
+    public abstract void f1604();
+    public abstract void f1605();
+    public abstract void f1606();
+    public abstract void f1607();
+    public abstract void f1608();
+    public abstract void f1609();
+    public abstract void f1610();
+    public abstract void f1611();
+    public abstract void f1612();
+    public abstract void f1613();
+    public abstract void f1614();
+    public abstract void f1615();
+    public abstract void f1616();
+    public abstract void f1617();
+    public abstract void f1618();
+    public abstract void f1619();
+    public abstract void f1620();
+    public abstract void f1621();
+    public abstract void f1622();
+    public abstract void f1623();
+    public abstract void f1624();
+    public abstract void f1625();
+    public abstract void f1626();
+    public abstract void f1627();
+    public abstract void f1628();
+    public abstract void f1629();
+    public abstract void f1630();
+    public abstract void f1631();
+    public abstract void f1632();
+    public abstract void f1633();
+    public abstract void f1634();
+    public abstract void f1635();
+    public abstract void f1636();
+    public abstract void f1637();
+    public abstract void f1638();
+    public abstract void f1639();
+    public abstract void f1640();
+    public abstract void f1641();
+    public abstract void f1642();
+    public abstract void f1643();
+    public abstract void f1644();
+    public abstract void f1645();
+    public abstract void f1646();
+    public abstract void f1647();
+    public abstract void f1648();
+    public abstract void f1649();
+    public abstract void f1650();
+    public abstract void f1651();
+    public abstract void f1652();
+    public abstract void f1653();
+    public abstract void f1654();
+    public abstract void f1655();
+    public abstract void f1656();
+    public abstract void f1657();
+    public abstract void f1658();
+    public abstract void f1659();
+    public abstract void f1660();
+    public abstract void f1661();
+    public abstract void f1662();
+    public abstract void f1663();
+    public abstract void f1664();
+    public abstract void f1665();
+    public abstract void f1666();
+    public abstract void f1667();
+    public abstract void f1668();
+    public abstract void f1669();
+    public abstract void f1670();
+    public abstract void f1671();
+    public abstract void f1672();
+    public abstract void f1673();
+    public abstract void f1674();
+    public abstract void f1675();
+    public abstract void f1676();
+    public abstract void f1677();
+    public abstract void f1678();
+    public abstract void f1679();
+    public abstract void f1680();
+    public abstract void f1681();
+    public abstract void f1682();
+    public abstract void f1683();
+    public abstract void f1684();
+    public abstract void f1685();
+    public abstract void f1686();
+    public abstract void f1687();
+    public abstract void f1688();
+    public abstract void f1689();
+    public abstract void f1690();
+    public abstract void f1691();
+    public abstract void f1692();
+    public abstract void f1693();
+    public abstract void f1694();
+    public abstract void f1695();
+    public abstract void f1696();
+    public abstract void f1697();
+    public abstract void f1698();
+    public abstract void f1699();
+    public abstract void f1700();
+    public abstract void f1701();
+    public abstract void f1702();
+    public abstract void f1703();
+    public abstract void f1704();
+    public abstract void f1705();
+    public abstract void f1706();
+    public abstract void f1707();
+    public abstract void f1708();
+    public abstract void f1709();
+    public abstract void f1710();
+    public abstract void f1711();
+    public abstract void f1712();
+    public abstract void f1713();
+    public abstract void f1714();
+    public abstract void f1715();
+    public abstract void f1716();
+    public abstract void f1717();
+    public abstract void f1718();
+    public abstract void f1719();
+    public abstract void f1720();
+    public abstract void f1721();
+    public abstract void f1722();
+    public abstract void f1723();
+    public abstract void f1724();
+    public abstract void f1725();
+    public abstract void f1726();
+    public abstract void f1727();
+    public abstract void f1728();
+    public abstract void f1729();
+    public abstract void f1730();
+    public abstract void f1731();
+    public abstract void f1732();
+    public abstract void f1733();
+    public abstract void f1734();
+    public abstract void f1735();
+    public abstract void f1736();
+    public abstract void f1737();
+    public abstract void f1738();
+    public abstract void f1739();
+    public abstract void f1740();
+    public abstract void f1741();
+    public abstract void f1742();
+    public abstract void f1743();
+    public abstract void f1744();
+    public abstract void f1745();
+    public abstract void f1746();
+    public abstract void f1747();
+    public abstract void f1748();
+    public abstract void f1749();
+    public abstract void f1750();
+    public abstract void f1751();
+    public abstract void f1752();
+    public abstract void f1753();
+    public abstract void f1754();
+    public abstract void f1755();
+    public abstract void f1756();
+    public abstract void f1757();
+    public abstract void f1758();
+    public abstract void f1759();
+    public abstract void f1760();
+    public abstract void f1761();
+    public abstract void f1762();
+    public abstract void f1763();
+    public abstract void f1764();
+    public abstract void f1765();
+    public abstract void f1766();
+    public abstract void f1767();
+    public abstract void f1768();
+    public abstract void f1769();
+    public abstract void f1770();
+    public abstract void f1771();
+    public abstract void f1772();
+    public abstract void f1773();
+    public abstract void f1774();
+    public abstract void f1775();
+    public abstract void f1776();
+    public abstract void f1777();
+    public abstract void f1778();
+    public abstract void f1779();
+    public abstract void f1780();
+    public abstract void f1781();
+    public abstract void f1782();
+    public abstract void f1783();
+    public abstract void f1784();
+    public abstract void f1785();
+    public abstract void f1786();
+    public abstract void f1787();
+    public abstract void f1788();
+    public abstract void f1789();
+    public abstract void f1790();
+    public abstract void f1791();
+    public abstract void f1792();
+    public abstract void f1793();
+    public abstract void f1794();
+    public abstract void f1795();
+    public abstract void f1796();
+    public abstract void f1797();
+    public abstract void f1798();
+    public abstract void f1799();
+    public abstract void f1800();
+    public abstract void f1801();
+    public abstract void f1802();
+    public abstract void f1803();
+    public abstract void f1804();
+    public abstract void f1805();
+    public abstract void f1806();
+    public abstract void f1807();
+    public abstract void f1808();
+    public abstract void f1809();
+    public abstract void f1810();
+    public abstract void f1811();
+    public abstract void f1812();
+    public abstract void f1813();
+    public abstract void f1814();
+    public abstract void f1815();
+    public abstract void f1816();
+    public abstract void f1817();
+    public abstract void f1818();
+    public abstract void f1819();
+    public abstract void f1820();
+    public abstract void f1821();
+    public abstract void f1822();
+    public abstract void f1823();
+    public abstract void f1824();
+    public abstract void f1825();
+    public abstract void f1826();
+    public abstract void f1827();
+    public abstract void f1828();
+    public abstract void f1829();
+    public abstract void f1830();
+    public abstract void f1831();
+    public abstract void f1832();
+    public abstract void f1833();
+    public abstract void f1834();
+    public abstract void f1835();
+    public abstract void f1836();
+    public abstract void f1837();
+    public abstract void f1838();
+    public abstract void f1839();
+    public abstract void f1840();
+    public abstract void f1841();
+    public abstract void f1842();
+    public abstract void f1843();
+    public abstract void f1844();
+    public abstract void f1845();
+    public abstract void f1846();
+    public abstract void f1847();
+    public abstract void f1848();
+    public abstract void f1849();
+    public abstract void f1850();
+    public abstract void f1851();
+    public abstract void f1852();
+    public abstract void f1853();
+    public abstract void f1854();
+    public abstract void f1855();
+    public abstract void f1856();
+    public abstract void f1857();
+    public abstract void f1858();
+    public abstract void f1859();
+    public abstract void f1860();
+    public abstract void f1861();
+    public abstract void f1862();
+    public abstract void f1863();
+    public abstract void f1864();
+    public abstract void f1865();
+    public abstract void f1866();
+    public abstract void f1867();
+    public abstract void f1868();
+    public abstract void f1869();
+    public abstract void f1870();
+    public abstract void f1871();
+    public abstract void f1872();
+    public abstract void f1873();
+    public abstract void f1874();
+    public abstract void f1875();
+    public abstract void f1876();
+    public abstract void f1877();
+    public abstract void f1878();
+    public abstract void f1879();
+    public abstract void f1880();
+    public abstract void f1881();
+    public abstract void f1882();
+    public abstract void f1883();
+    public abstract void f1884();
+    public abstract void f1885();
+    public abstract void f1886();
+    public abstract void f1887();
+    public abstract void f1888();
+    public abstract void f1889();
+    public abstract void f1890();
+    public abstract void f1891();
+    public abstract void f1892();
+    public abstract void f1893();
+    public abstract void f1894();
+    public abstract void f1895();
+    public abstract void f1896();
+    public abstract void f1897();
+    public abstract void f1898();
+    public abstract void f1899();
+    public abstract void f1900();
+    public abstract void f1901();
+    public abstract void f1902();
+    public abstract void f1903();
+    public abstract void f1904();
+    public abstract void f1905();
+    public abstract void f1906();
+    public abstract void f1907();
+    public abstract void f1908();
+    public abstract void f1909();
+    public abstract void f1910();
+    public abstract void f1911();
+    public abstract void f1912();
+    public abstract void f1913();
+    public abstract void f1914();
+    public abstract void f1915();
+    public abstract void f1916();
+    public abstract void f1917();
+    public abstract void f1918();
+    public abstract void f1919();
+    public abstract void f1920();
+    public abstract void f1921();
+    public abstract void f1922();
+    public abstract void f1923();
+    public abstract void f1924();
+    public abstract void f1925();
+    public abstract void f1926();
+    public abstract void f1927();
+    public abstract void f1928();
+    public abstract void f1929();
+    public abstract void f1930();
+    public abstract void f1931();
+    public abstract void f1932();
+    public abstract void f1933();
+    public abstract void f1934();
+    public abstract void f1935();
+    public abstract void f1936();
+    public abstract void f1937();
+    public abstract void f1938();
+    public abstract void f1939();
+    public abstract void f1940();
+    public abstract void f1941();
+    public abstract void f1942();
+    public abstract void f1943();
+    public abstract void f1944();
+    public abstract void f1945();
+    public abstract void f1946();
+    public abstract void f1947();
+    public abstract void f1948();
+    public abstract void f1949();
+    public abstract void f1950();
+    public abstract void f1951();
+    public abstract void f1952();
+    public abstract void f1953();
+    public abstract void f1954();
+    public abstract void f1955();
+    public abstract void f1956();
+    public abstract void f1957();
+    public abstract void f1958();
+    public abstract void f1959();
+    public abstract void f1960();
+    public abstract void f1961();
+    public abstract void f1962();
+    public abstract void f1963();
+    public abstract void f1964();
+    public abstract void f1965();
+    public abstract void f1966();
+    public abstract void f1967();
+    public abstract void f1968();
+    public abstract void f1969();
+    public abstract void f1970();
+    public abstract void f1971();
+    public abstract void f1972();
+    public abstract void f1973();
+    public abstract void f1974();
+    public abstract void f1975();
+    public abstract void f1976();
+    public abstract void f1977();
+    public abstract void f1978();
+    public abstract void f1979();
+    public abstract void f1980();
+    public abstract void f1981();
+    public abstract void f1982();
+    public abstract void f1983();
+    public abstract void f1984();
+    public abstract void f1985();
+    public abstract void f1986();
+    public abstract void f1987();
+    public abstract void f1988();
+    public abstract void f1989();
+    public abstract void f1990();
+    public abstract void f1991();
+    public abstract void f1992();
+    public abstract void f1993();
+    public abstract void f1994();
+    public abstract void f1995();
+    public abstract void f1996();
+    public abstract void f1997();
+    public abstract void f1998();
+    public abstract void f1999();
+    public abstract void f2000();
+    public abstract void f2001();
+    public abstract void f2002();
+    public abstract void f2003();
+    public abstract void f2004();
+    public abstract void f2005();
+    public abstract void f2006();
+    public abstract void f2007();
+    public abstract void f2008();
+    public abstract void f2009();
+    public abstract void f2010();
+    public abstract void f2011();
+    public abstract void f2012();
+    public abstract void f2013();
+    public abstract void f2014();
+    public abstract void f2015();
+    public abstract void f2016();
+    public abstract void f2017();
+    public abstract void f2018();
+    public abstract void f2019();
+    public abstract void f2020();
+    public abstract void f2021();
+    public abstract void f2022();
+    public abstract void f2023();
+    public abstract void f2024();
+    public abstract void f2025();
+    public abstract void f2026();
+    public abstract void f2027();
+    public abstract void f2028();
+    public abstract void f2029();
+    public abstract void f2030();
+    public abstract void f2031();
+    public abstract void f2032();
+    public abstract void f2033();
+    public abstract void f2034();
+    public abstract void f2035();
+    public abstract void f2036();
+    public abstract void f2037();
+    public abstract void f2038();
+    public abstract void f2039();
+    public abstract void f2040();
+    public abstract void f2041();
+    public abstract void f2042();
+    public abstract void f2043();
+    public abstract void f2044();
+    public abstract void f2045();
+    public abstract void f2046();
+    public abstract void f2047();
+    public abstract void f2048();
+    public abstract void f2049();
+    public abstract void f2050();
+    public abstract void f2051();
+    public abstract void f2052();
+    public abstract void f2053();
+    public abstract void f2054();
+    public abstract void f2055();
+    public abstract void f2056();
+    public abstract void f2057();
+    public abstract void f2058();
+    public abstract void f2059();
+    public abstract void f2060();
+    public abstract void f2061();
+    public abstract void f2062();
+    public abstract void f2063();
+    public abstract void f2064();
+    public abstract void f2065();
+    public abstract void f2066();
+    public abstract void f2067();
+    public abstract void f2068();
+    public abstract void f2069();
+    public abstract void f2070();
+    public abstract void f2071();
+    public abstract void f2072();
+    public abstract void f2073();
+    public abstract void f2074();
+    public abstract void f2075();
+    public abstract void f2076();
+    public abstract void f2077();
+    public abstract void f2078();
+    public abstract void f2079();
+    public abstract void f2080();
+    public abstract void f2081();
+    public abstract void f2082();
+    public abstract void f2083();
+    public abstract void f2084();
+    public abstract void f2085();
+    public abstract void f2086();
+    public abstract void f2087();
+    public abstract void f2088();
+    public abstract void f2089();
+    public abstract void f2090();
+    public abstract void f2091();
+    public abstract void f2092();
+    public abstract void f2093();
+    public abstract void f2094();
+    public abstract void f2095();
+    public abstract void f2096();
+    public abstract void f2097();
+    public abstract void f2098();
+    public abstract void f2099();
+    public abstract void f2100();
+    public abstract void f2101();
+    public abstract void f2102();
+    public abstract void f2103();
+    public abstract void f2104();
+    public abstract void f2105();
+    public abstract void f2106();
+    public abstract void f2107();
+    public abstract void f2108();
+    public abstract void f2109();
+    public abstract void f2110();
+    public abstract void f2111();
+    public abstract void f2112();
+    public abstract void f2113();
+    public abstract void f2114();
+    public abstract void f2115();
+    public abstract void f2116();
+    public abstract void f2117();
+    public abstract void f2118();
+    public abstract void f2119();
+    public abstract void f2120();
+    public abstract void f2121();
+    public abstract void f2122();
+    public abstract void f2123();
+    public abstract void f2124();
+    public abstract void f2125();
+    public abstract void f2126();
+    public abstract void f2127();
+    public abstract void f2128();
+    public abstract void f2129();
+    public abstract void f2130();
+    public abstract void f2131();
+    public abstract void f2132();
+    public abstract void f2133();
+    public abstract void f2134();
+    public abstract void f2135();
+    public abstract void f2136();
+    public abstract void f2137();
+    public abstract void f2138();
+    public abstract void f2139();
+    public abstract void f2140();
+    public abstract void f2141();
+    public abstract void f2142();
+    public abstract void f2143();
+    public abstract void f2144();
+    public abstract void f2145();
+    public abstract void f2146();
+    public abstract void f2147();
+    public abstract void f2148();
+    public abstract void f2149();
+    public abstract void f2150();
+    public abstract void f2151();
+    public abstract void f2152();
+    public abstract void f2153();
+    public abstract void f2154();
+    public abstract void f2155();
+    public abstract void f2156();
+    public abstract void f2157();
+    public abstract void f2158();
+    public abstract void f2159();
+    public abstract void f2160();
+    public abstract void f2161();
+    public abstract void f2162();
+    public abstract void f2163();
+    public abstract void f2164();
+    public abstract void f2165();
+    public abstract void f2166();
+    public abstract void f2167();
+    public abstract void f2168();
+    public abstract void f2169();
+    public abstract void f2170();
+    public abstract void f2171();
+    public abstract void f2172();
+    public abstract void f2173();
+    public abstract void f2174();
+    public abstract void f2175();
+    public abstract void f2176();
+    public abstract void f2177();
+    public abstract void f2178();
+    public abstract void f2179();
+    public abstract void f2180();
+    public abstract void f2181();
+    public abstract void f2182();
+    public abstract void f2183();
+    public abstract void f2184();
+    public abstract void f2185();
+    public abstract void f2186();
+    public abstract void f2187();
+    public abstract void f2188();
+    public abstract void f2189();
+    public abstract void f2190();
+    public abstract void f2191();
+    public abstract void f2192();
+    public abstract void f2193();
+    public abstract void f2194();
+    public abstract void f2195();
+    public abstract void f2196();
+    public abstract void f2197();
+    public abstract void f2198();
+    public abstract void f2199();
+    public abstract void f2200();
+    public abstract void f2201();
+    public abstract void f2202();
+    public abstract void f2203();
+    public abstract void f2204();
+    public abstract void f2205();
+    public abstract void f2206();
+    public abstract void f2207();
+    public abstract void f2208();
+    public abstract void f2209();
+    public abstract void f2210();
+    public abstract void f2211();
+    public abstract void f2212();
+    public abstract void f2213();
+    public abstract void f2214();
+    public abstract void f2215();
+    public abstract void f2216();
+    public abstract void f2217();
+    public abstract void f2218();
+    public abstract void f2219();
+    public abstract void f2220();
+    public abstract void f2221();
+    public abstract void f2222();
+    public abstract void f2223();
+    public abstract void f2224();
+    public abstract void f2225();
+    public abstract void f2226();
+    public abstract void f2227();
+    public abstract void f2228();
+    public abstract void f2229();
+    public abstract void f2230();
+    public abstract void f2231();
+    public abstract void f2232();
+    public abstract void f2233();
+    public abstract void f2234();
+    public abstract void f2235();
+    public abstract void f2236();
+    public abstract void f2237();
+    public abstract void f2238();
+    public abstract void f2239();
+    public abstract void f2240();
+    public abstract void f2241();
+    public abstract void f2242();
+    public abstract void f2243();
+    public abstract void f2244();
+    public abstract void f2245();
+    public abstract void f2246();
+    public abstract void f2247();
+    public abstract void f2248();
+    public abstract void f2249();
+    public abstract void f2250();
+    public abstract void f2251();
+    public abstract void f2252();
+    public abstract void f2253();
+    public abstract void f2254();
+    public abstract void f2255();
+    public abstract void f2256();
+    public abstract void f2257();
+    public abstract void f2258();
+    public abstract void f2259();
+    public abstract void f2260();
+    public abstract void f2261();
+    public abstract void f2262();
+    public abstract void f2263();
+    public abstract void f2264();
+    public abstract void f2265();
+    public abstract void f2266();
+    public abstract void f2267();
+    public abstract void f2268();
+    public abstract void f2269();
+    public abstract void f2270();
+    public abstract void f2271();
+    public abstract void f2272();
+    public abstract void f2273();
+    public abstract void f2274();
+    public abstract void f2275();
+    public abstract void f2276();
+    public abstract void f2277();
+    public abstract void f2278();
+    public abstract void f2279();
+    public abstract void f2280();
+    public abstract void f2281();
+    public abstract void f2282();
+    public abstract void f2283();
+    public abstract void f2284();
+    public abstract void f2285();
+    public abstract void f2286();
+    public abstract void f2287();
+    public abstract void f2288();
+    public abstract void f2289();
+    public abstract void f2290();
+    public abstract void f2291();
+    public abstract void f2292();
+    public abstract void f2293();
+    public abstract void f2294();
+    public abstract void f2295();
+    public abstract void f2296();
+    public abstract void f2297();
+    public abstract void f2298();
+    public abstract void f2299();
+    public abstract void f2300();
+    public abstract void f2301();
+    public abstract void f2302();
+    public abstract void f2303();
+    public abstract void f2304();
+    public abstract void f2305();
+    public abstract void f2306();
+    public abstract void f2307();
+    public abstract void f2308();
+    public abstract void f2309();
+    public abstract void f2310();
+    public abstract void f2311();
+    public abstract void f2312();
+    public abstract void f2313();
+    public abstract void f2314();
+    public abstract void f2315();
+    public abstract void f2316();
+    public abstract void f2317();
+    public abstract void f2318();
+    public abstract void f2319();
+    public abstract void f2320();
+    public abstract void f2321();
+    public abstract void f2322();
+    public abstract void f2323();
+    public abstract void f2324();
+    public abstract void f2325();
+    public abstract void f2326();
+    public abstract void f2327();
+    public abstract void f2328();
+    public abstract void f2329();
+    public abstract void f2330();
+    public abstract void f2331();
+    public abstract void f2332();
+    public abstract void f2333();
+    public abstract void f2334();
+    public abstract void f2335();
+    public abstract void f2336();
+    public abstract void f2337();
+    public abstract void f2338();
+    public abstract void f2339();
+    public abstract void f2340();
+    public abstract void f2341();
+    public abstract void f2342();
+    public abstract void f2343();
+    public abstract void f2344();
+    public abstract void f2345();
+    public abstract void f2346();
+    public abstract void f2347();
+    public abstract void f2348();
+    public abstract void f2349();
+    public abstract void f2350();
+    public abstract void f2351();
+    public abstract void f2352();
+    public abstract void f2353();
+    public abstract void f2354();
+    public abstract void f2355();
+    public abstract void f2356();
+    public abstract void f2357();
+    public abstract void f2358();
+    public abstract void f2359();
+    public abstract void f2360();
+    public abstract void f2361();
+    public abstract void f2362();
+    public abstract void f2363();
+    public abstract void f2364();
+    public abstract void f2365();
+    public abstract void f2366();
+    public abstract void f2367();
+    public abstract void f2368();
+    public abstract void f2369();
+    public abstract void f2370();
+    public abstract void f2371();
+    public abstract void f2372();
+    public abstract void f2373();
+    public abstract void f2374();
+    public abstract void f2375();
+    public abstract void f2376();
+    public abstract void f2377();
+    public abstract void f2378();
+    public abstract void f2379();
+    public abstract void f2380();
+    public abstract void f2381();
+    public abstract void f2382();
+    public abstract void f2383();
+    public abstract void f2384();
+    public abstract void f2385();
+    public abstract void f2386();
+    public abstract void f2387();
+    public abstract void f2388();
+    public abstract void f2389();
+    public abstract void f2390();
+    public abstract void f2391();
+    public abstract void f2392();
+    public abstract void f2393();
+    public abstract void f2394();
+    public abstract void f2395();
+    public abstract void f2396();
+    public abstract void f2397();
+    public abstract void f2398();
+    public abstract void f2399();
+    public abstract void f2400();
+    public abstract void f2401();
+    public abstract void f2402();
+    public abstract void f2403();
+    public abstract void f2404();
+    public abstract void f2405();
+    public abstract void f2406();
+    public abstract void f2407();
+    public abstract void f2408();
+    public abstract void f2409();
+    public abstract void f2410();
+    public abstract void f2411();
+    public abstract void f2412();
+    public abstract void f2413();
+    public abstract void f2414();
+    public abstract void f2415();
+    public abstract void f2416();
+    public abstract void f2417();
+    public abstract void f2418();
+    public abstract void f2419();
+    public abstract void f2420();
+    public abstract void f2421();
+    public abstract void f2422();
+    public abstract void f2423();
+    public abstract void f2424();
+    public abstract void f2425();
+    public abstract void f2426();
+    public abstract void f2427();
+    public abstract void f2428();
+    public abstract void f2429();
+    public abstract void f2430();
+    public abstract void f2431();
+    public abstract void f2432();
+    public abstract void f2433();
+    public abstract void f2434();
+    public abstract void f2435();
+    public abstract void f2436();
+    public abstract void f2437();
+    public abstract void f2438();
+    public abstract void f2439();
+    public abstract void f2440();
+    public abstract void f2441();
+    public abstract void f2442();
+    public abstract void f2443();
+    public abstract void f2444();
+    public abstract void f2445();
+    public abstract void f2446();
+    public abstract void f2447();
+    public abstract void f2448();
+    public abstract void f2449();
+    public abstract void f2450();
+    public abstract void f2451();
+    public abstract void f2452();
+    public abstract void f2453();
+    public abstract void f2454();
+    public abstract void f2455();
+    public abstract void f2456();
+    public abstract void f2457();
+    public abstract void f2458();
+    public abstract void f2459();
+    public abstract void f2460();
+    public abstract void f2461();
+    public abstract void f2462();
+    public abstract void f2463();
+    public abstract void f2464();
+    public abstract void f2465();
+    public abstract void f2466();
+    public abstract void f2467();
+    public abstract void f2468();
+    public abstract void f2469();
+    public abstract void f2470();
+    public abstract void f2471();
+    public abstract void f2472();
+    public abstract void f2473();
+    public abstract void f2474();
+    public abstract void f2475();
+    public abstract void f2476();
+    public abstract void f2477();
+    public abstract void f2478();
+    public abstract void f2479();
+    public abstract void f2480();
+    public abstract void f2481();
+    public abstract void f2482();
+    public abstract void f2483();
+    public abstract void f2484();
+    public abstract void f2485();
+    public abstract void f2486();
+    public abstract void f2487();
+    public abstract void f2488();
+    public abstract void f2489();
+    public abstract void f2490();
+    public abstract void f2491();
+    public abstract void f2492();
+    public abstract void f2493();
+    public abstract void f2494();
+    public abstract void f2495();
+    public abstract void f2496();
+    public abstract void f2497();
+    public abstract void f2498();
+    public abstract void f2499();
+    public abstract void f2500();
+    public abstract void f2501();
+    public abstract void f2502();
+    public abstract void f2503();
+    public abstract void f2504();
+    public abstract void f2505();
+    public abstract void f2506();
+    public abstract void f2507();
+    public abstract void f2508();
+    public abstract void f2509();
+    public abstract void f2510();
+    public abstract void f2511();
+    public abstract void f2512();
+    public abstract void f2513();
+    public abstract void f2514();
+    public abstract void f2515();
+    public abstract void f2516();
+    public abstract void f2517();
+    public abstract void f2518();
+    public abstract void f2519();
+    public abstract void f2520();
+    public abstract void f2521();
+    public abstract void f2522();
+    public abstract void f2523();
+    public abstract void f2524();
+    public abstract void f2525();
+    public abstract void f2526();
+    public abstract void f2527();
+    public abstract void f2528();
+    public abstract void f2529();
+    public abstract void f2530();
+    public abstract void f2531();
+    public abstract void f2532();
+    public abstract void f2533();
+    public abstract void f2534();
+    public abstract void f2535();
+    public abstract void f2536();
+    public abstract void f2537();
+    public abstract void f2538();
+    public abstract void f2539();
+    public abstract void f2540();
+    public abstract void f2541();
+    public abstract void f2542();
+    public abstract void f2543();
+    public abstract void f2544();
+    public abstract void f2545();
+    public abstract void f2546();
+    public abstract void f2547();
+    public abstract void f2548();
+    public abstract void f2549();
+    public abstract void f2550();
+    public abstract void f2551();
+    public abstract void f2552();
+    public abstract void f2553();
+    public abstract void f2554();
+    public abstract void f2555();
+    public abstract void f2556();
+    public abstract void f2557();
+    public abstract void f2558();
+    public abstract void f2559();
+    public abstract void f2560();
+    public abstract void f2561();
+    public abstract void f2562();
+    public abstract void f2563();
+    public abstract void f2564();
+    public abstract void f2565();
+    public abstract void f2566();
+    public abstract void f2567();
+    public abstract void f2568();
+    public abstract void f2569();
+    public abstract void f2570();
+    public abstract void f2571();
+    public abstract void f2572();
+    public abstract void f2573();
+    public abstract void f2574();
+    public abstract void f2575();
+    public abstract void f2576();
+    public abstract void f2577();
+    public abstract void f2578();
+    public abstract void f2579();
+    public abstract void f2580();
+    public abstract void f2581();
+    public abstract void f2582();
+    public abstract void f2583();
+    public abstract void f2584();
+    public abstract void f2585();
+    public abstract void f2586();
+    public abstract void f2587();
+    public abstract void f2588();
+    public abstract void f2589();
+    public abstract void f2590();
+    public abstract void f2591();
+    public abstract void f2592();
+    public abstract void f2593();
+    public abstract void f2594();
+    public abstract void f2595();
+    public abstract void f2596();
+    public abstract void f2597();
+    public abstract void f2598();
+    public abstract void f2599();
+    public abstract void f2600();
+    public abstract void f2601();
+    public abstract void f2602();
+    public abstract void f2603();
+    public abstract void f2604();
+    public abstract void f2605();
+    public abstract void f2606();
+    public abstract void f2607();
+    public abstract void f2608();
+    public abstract void f2609();
+    public abstract void f2610();
+    public abstract void f2611();
+    public abstract void f2612();
+    public abstract void f2613();
+    public abstract void f2614();
+    public abstract void f2615();
+    public abstract void f2616();
+    public abstract void f2617();
+    public abstract void f2618();
+    public abstract void f2619();
+    public abstract void f2620();
+    public abstract void f2621();
+    public abstract void f2622();
+    public abstract void f2623();
+    public abstract void f2624();
+    public abstract void f2625();
+    public abstract void f2626();
+    public abstract void f2627();
+    public abstract void f2628();
+    public abstract void f2629();
+    public abstract void f2630();
+    public abstract void f2631();
+    public abstract void f2632();
+    public abstract void f2633();
+    public abstract void f2634();
+    public abstract void f2635();
+    public abstract void f2636();
+    public abstract void f2637();
+    public abstract void f2638();
+    public abstract void f2639();
+    public abstract void f2640();
+    public abstract void f2641();
+    public abstract void f2642();
+    public abstract void f2643();
+    public abstract void f2644();
+    public abstract void f2645();
+    public abstract void f2646();
+    public abstract void f2647();
+    public abstract void f2648();
+    public abstract void f2649();
+    public abstract void f2650();
+    public abstract void f2651();
+    public abstract void f2652();
+    public abstract void f2653();
+    public abstract void f2654();
+    public abstract void f2655();
+    public abstract void f2656();
+    public abstract void f2657();
+    public abstract void f2658();
+    public abstract void f2659();
+    public abstract void f2660();
+    public abstract void f2661();
+    public abstract void f2662();
+    public abstract void f2663();
+    public abstract void f2664();
+    public abstract void f2665();
+    public abstract void f2666();
+    public abstract void f2667();
+    public abstract void f2668();
+    public abstract void f2669();
+    public abstract void f2670();
+    public abstract void f2671();
+    public abstract void f2672();
+    public abstract void f2673();
+    public abstract void f2674();
+    public abstract void f2675();
+    public abstract void f2676();
+    public abstract void f2677();
+    public abstract void f2678();
+    public abstract void f2679();
+    public abstract void f2680();
+    public abstract void f2681();
+    public abstract void f2682();
+    public abstract void f2683();
+    public abstract void f2684();
+    public abstract void f2685();
+    public abstract void f2686();
+    public abstract void f2687();
+    public abstract void f2688();
+    public abstract void f2689();
+    public abstract void f2690();
+    public abstract void f2691();
+    public abstract void f2692();
+    public abstract void f2693();
+    public abstract void f2694();
+    public abstract void f2695();
+    public abstract void f2696();
+    public abstract void f2697();
+    public abstract void f2698();
+    public abstract void f2699();
+    public abstract void f2700();
+    public abstract void f2701();
+    public abstract void f2702();
+    public abstract void f2703();
+    public abstract void f2704();
+    public abstract void f2705();
+    public abstract void f2706();
+    public abstract void f2707();
+    public abstract void f2708();
+    public abstract void f2709();
+    public abstract void f2710();
+    public abstract void f2711();
+    public abstract void f2712();
+    public abstract void f2713();
+    public abstract void f2714();
+    public abstract void f2715();
+    public abstract void f2716();
+    public abstract void f2717();
+    public abstract void f2718();
+    public abstract void f2719();
+    public abstract void f2720();
+    public abstract void f2721();
+    public abstract void f2722();
+    public abstract void f2723();
+    public abstract void f2724();
+    public abstract void f2725();
+    public abstract void f2726();
+    public abstract void f2727();
+    public abstract void f2728();
+    public abstract void f2729();
+    public abstract void f2730();
+    public abstract void f2731();
+    public abstract void f2732();
+    public abstract void f2733();
+    public abstract void f2734();
+    public abstract void f2735();
+    public abstract void f2736();
+    public abstract void f2737();
+    public abstract void f2738();
+    public abstract void f2739();
+    public abstract void f2740();
+    public abstract void f2741();
+    public abstract void f2742();
+    public abstract void f2743();
+    public abstract void f2744();
+    public abstract void f2745();
+    public abstract void f2746();
+    public abstract void f2747();
+    public abstract void f2748();
+    public abstract void f2749();
+    public abstract void f2750();
+    public abstract void f2751();
+    public abstract void f2752();
+    public abstract void f2753();
+    public abstract void f2754();
+    public abstract void f2755();
+    public abstract void f2756();
+    public abstract void f2757();
+    public abstract void f2758();
+    public abstract void f2759();
+    public abstract void f2760();
+    public abstract void f2761();
+    public abstract void f2762();
+    public abstract void f2763();
+    public abstract void f2764();
+    public abstract void f2765();
+    public abstract void f2766();
+    public abstract void f2767();
+    public abstract void f2768();
+    public abstract void f2769();
+    public abstract void f2770();
+    public abstract void f2771();
+    public abstract void f2772();
+    public abstract void f2773();
+    public abstract void f2774();
+    public abstract void f2775();
+    public abstract void f2776();
+    public abstract void f2777();
+    public abstract void f2778();
+    public abstract void f2779();
+    public abstract void f2780();
+    public abstract void f2781();
+    public abstract void f2782();
+    public abstract void f2783();
+    public abstract void f2784();
+    public abstract void f2785();
+    public abstract void f2786();
+    public abstract void f2787();
+    public abstract void f2788();
+    public abstract void f2789();
+    public abstract void f2790();
+    public abstract void f2791();
+    public abstract void f2792();
+    public abstract void f2793();
+    public abstract void f2794();
+    public abstract void f2795();
+    public abstract void f2796();
+    public abstract void f2797();
+    public abstract void f2798();
+    public abstract void f2799();
+    public abstract void f2800();
+    public abstract void f2801();
+    public abstract void f2802();
+    public abstract void f2803();
+    public abstract void f2804();
+    public abstract void f2805();
+    public abstract void f2806();
+    public abstract void f2807();
+    public abstract void f2808();
+    public abstract void f2809();
+    public abstract void f2810();
+    public abstract void f2811();
+    public abstract void f2812();
+    public abstract void f2813();
+    public abstract void f2814();
+    public abstract void f2815();
+    public abstract void f2816();
+    public abstract void f2817();
+    public abstract void f2818();
+    public abstract void f2819();
+    public abstract void f2820();
+    public abstract void f2821();
+    public abstract void f2822();
+    public abstract void f2823();
+    public abstract void f2824();
+    public abstract void f2825();
+    public abstract void f2826();
+    public abstract void f2827();
+    public abstract void f2828();
+    public abstract void f2829();
+    public abstract void f2830();
+    public abstract void f2831();
+    public abstract void f2832();
+    public abstract void f2833();
+    public abstract void f2834();
+    public abstract void f2835();
+    public abstract void f2836();
+    public abstract void f2837();
+    public abstract void f2838();
+    public abstract void f2839();
+    public abstract void f2840();
+    public abstract void f2841();
+    public abstract void f2842();
+    public abstract void f2843();
+    public abstract void f2844();
+    public abstract void f2845();
+    public abstract void f2846();
+    public abstract void f2847();
+    public abstract void f2848();
+    public abstract void f2849();
+    public abstract void f2850();
+    public abstract void f2851();
+    public abstract void f2852();
+    public abstract void f2853();
+    public abstract void f2854();
+    public abstract void f2855();
+    public abstract void f2856();
+    public abstract void f2857();
+    public abstract void f2858();
+    public abstract void f2859();
+    public abstract void f2860();
+    public abstract void f2861();
+    public abstract void f2862();
+    public abstract void f2863();
+    public abstract void f2864();
+    public abstract void f2865();
+    public abstract void f2866();
+    public abstract void f2867();
+    public abstract void f2868();
+    public abstract void f2869();
+    public abstract void f2870();
+    public abstract void f2871();
+    public abstract void f2872();
+    public abstract void f2873();
+    public abstract void f2874();
+    public abstract void f2875();
+    public abstract void f2876();
+    public abstract void f2877();
+    public abstract void f2878();
+    public abstract void f2879();
+    public abstract void f2880();
+    public abstract void f2881();
+    public abstract void f2882();
+    public abstract void f2883();
+    public abstract void f2884();
+    public abstract void f2885();
+    public abstract void f2886();
+    public abstract void f2887();
+    public abstract void f2888();
+    public abstract void f2889();
+    public abstract void f2890();
+    public abstract void f2891();
+    public abstract void f2892();
+    public abstract void f2893();
+    public abstract void f2894();
+    public abstract void f2895();
+    public abstract void f2896();
+    public abstract void f2897();
+    public abstract void f2898();
+    public abstract void f2899();
+    public abstract void f2900();
+    public abstract void f2901();
+    public abstract void f2902();
+    public abstract void f2903();
+    public abstract void f2904();
+    public abstract void f2905();
+    public abstract void f2906();
+    public abstract void f2907();
+    public abstract void f2908();
+    public abstract void f2909();
+    public abstract void f2910();
+    public abstract void f2911();
+    public abstract void f2912();
+    public abstract void f2913();
+    public abstract void f2914();
+    public abstract void f2915();
+    public abstract void f2916();
+    public abstract void f2917();
+    public abstract void f2918();
+    public abstract void f2919();
+    public abstract void f2920();
+    public abstract void f2921();
+    public abstract void f2922();
+    public abstract void f2923();
+    public abstract void f2924();
+    public abstract void f2925();
+    public abstract void f2926();
+    public abstract void f2927();
+    public abstract void f2928();
+    public abstract void f2929();
+    public abstract void f2930();
+    public abstract void f2931();
+    public abstract void f2932();
+    public abstract void f2933();
+    public abstract void f2934();
+    public abstract void f2935();
+    public abstract void f2936();
+    public abstract void f2937();
+    public abstract void f2938();
+    public abstract void f2939();
+    public abstract void f2940();
+    public abstract void f2941();
+    public abstract void f2942();
+    public abstract void f2943();
+    public abstract void f2944();
+    public abstract void f2945();
+    public abstract void f2946();
+    public abstract void f2947();
+    public abstract void f2948();
+    public abstract void f2949();
+    public abstract void f2950();
+    public abstract void f2951();
+    public abstract void f2952();
+    public abstract void f2953();
+    public abstract void f2954();
+    public abstract void f2955();
+    public abstract void f2956();
+    public abstract void f2957();
+    public abstract void f2958();
+    public abstract void f2959();
+    public abstract void f2960();
+    public abstract void f2961();
+    public abstract void f2962();
+    public abstract void f2963();
+    public abstract void f2964();
+    public abstract void f2965();
+    public abstract void f2966();
+    public abstract void f2967();
+    public abstract void f2968();
+    public abstract void f2969();
+    public abstract void f2970();
+    public abstract void f2971();
+    public abstract void f2972();
+    public abstract void f2973();
+    public abstract void f2974();
+    public abstract void f2975();
+    public abstract void f2976();
+    public abstract void f2977();
+    public abstract void f2978();
+    public abstract void f2979();
+    public abstract void f2980();
+    public abstract void f2981();
+    public abstract void f2982();
+    public abstract void f2983();
+    public abstract void f2984();
+    public abstract void f2985();
+    public abstract void f2986();
+    public abstract void f2987();
+    public abstract void f2988();
+    public abstract void f2989();
+    public abstract void f2990();
+    public abstract void f2991();
+    public abstract void f2992();
+    public abstract void f2993();
+    public abstract void f2994();
+    public abstract void f2995();
+    public abstract void f2996();
+    public abstract void f2997();
+    public abstract void f2998();
+    public abstract void f2999();
+    public abstract void f3000();
+    public abstract void f3001();
+    public abstract void f3002();
+    public abstract void f3003();
+    public abstract void f3004();
+    public abstract void f3005();
+    public abstract void f3006();
+    public abstract void f3007();
+    public abstract void f3008();
+    public abstract void f3009();
+    public abstract void f3010();
+    public abstract void f3011();
+    public abstract void f3012();
+    public abstract void f3013();
+    public abstract void f3014();
+    public abstract void f3015();
+    public abstract void f3016();
+    public abstract void f3017();
+    public abstract void f3018();
+    public abstract void f3019();
+    public abstract void f3020();
+    public abstract void f3021();
+    public abstract void f3022();
+    public abstract void f3023();
+    public abstract void f3024();
+    public abstract void f3025();
+    public abstract void f3026();
+    public abstract void f3027();
+    public abstract void f3028();
+    public abstract void f3029();
+    public abstract void f3030();
+    public abstract void f3031();
+    public abstract void f3032();
+    public abstract void f3033();
+    public abstract void f3034();
+    public abstract void f3035();
+    public abstract void f3036();
+    public abstract void f3037();
+    public abstract void f3038();
+    public abstract void f3039();
+    public abstract void f3040();
+    public abstract void f3041();
+    public abstract void f3042();
+    public abstract void f3043();
+    public abstract void f3044();
+    public abstract void f3045();
+    public abstract void f3046();
+    public abstract void f3047();
+    public abstract void f3048();
+    public abstract void f3049();
+    public abstract void f3050();
+    public abstract void f3051();
+    public abstract void f3052();
+    public abstract void f3053();
+    public abstract void f3054();
+    public abstract void f3055();
+    public abstract void f3056();
+    public abstract void f3057();
+    public abstract void f3058();
+    public abstract void f3059();
+    public abstract void f3060();
+    public abstract void f3061();
+    public abstract void f3062();
+    public abstract void f3063();
+    public abstract void f3064();
+    public abstract void f3065();
+    public abstract void f3066();
+    public abstract void f3067();
+    public abstract void f3068();
+    public abstract void f3069();
+    public abstract void f3070();
+    public abstract void f3071();
+    public abstract void f3072();
+    public abstract void f3073();
+    public abstract void f3074();
+    public abstract void f3075();
+    public abstract void f3076();
+    public abstract void f3077();
+    public abstract void f3078();
+    public abstract void f3079();
+    public abstract void f3080();
+    public abstract void f3081();
+    public abstract void f3082();
+    public abstract void f3083();
+    public abstract void f3084();
+    public abstract void f3085();
+    public abstract void f3086();
+    public abstract void f3087();
+    public abstract void f3088();
+    public abstract void f3089();
+    public abstract void f3090();
+    public abstract void f3091();
+    public abstract void f3092();
+    public abstract void f3093();
+    public abstract void f3094();
+    public abstract void f3095();
+    public abstract void f3096();
+    public abstract void f3097();
+    public abstract void f3098();
+    public abstract void f3099();
+    public abstract void f3100();
+    public abstract void f3101();
+    public abstract void f3102();
+    public abstract void f3103();
+    public abstract void f3104();
+    public abstract void f3105();
+    public abstract void f3106();
+    public abstract void f3107();
+    public abstract void f3108();
+    public abstract void f3109();
+    public abstract void f3110();
+    public abstract void f3111();
+    public abstract void f3112();
+    public abstract void f3113();
+    public abstract void f3114();
+    public abstract void f3115();
+    public abstract void f3116();
+    public abstract void f3117();
+    public abstract void f3118();
+    public abstract void f3119();
+    public abstract void f3120();
+    public abstract void f3121();
+    public abstract void f3122();
+    public abstract void f3123();
+    public abstract void f3124();
+    public abstract void f3125();
+    public abstract void f3126();
+    public abstract void f3127();
+    public abstract void f3128();
+    public abstract void f3129();
+    public abstract void f3130();
+    public abstract void f3131();
+    public abstract void f3132();
+    public abstract void f3133();
+    public abstract void f3134();
+    public abstract void f3135();
+    public abstract void f3136();
+    public abstract void f3137();
+    public abstract void f3138();
+    public abstract void f3139();
+    public abstract void f3140();
+    public abstract void f3141();
+    public abstract void f3142();
+    public abstract void f3143();
+    public abstract void f3144();
+    public abstract void f3145();
+    public abstract void f3146();
+    public abstract void f3147();
+    public abstract void f3148();
+    public abstract void f3149();
+    public abstract void f3150();
+    public abstract void f3151();
+    public abstract void f3152();
+    public abstract void f3153();
+    public abstract void f3154();
+    public abstract void f3155();
+    public abstract void f3156();
+    public abstract void f3157();
+    public abstract void f3158();
+    public abstract void f3159();
+    public abstract void f3160();
+    public abstract void f3161();
+    public abstract void f3162();
+    public abstract void f3163();
+    public abstract void f3164();
+    public abstract void f3165();
+    public abstract void f3166();
+    public abstract void f3167();
+    public abstract void f3168();
+    public abstract void f3169();
+    public abstract void f3170();
+    public abstract void f3171();
+    public abstract void f3172();
+    public abstract void f3173();
+    public abstract void f3174();
+    public abstract void f3175();
+    public abstract void f3176();
+    public abstract void f3177();
+    public abstract void f3178();
+    public abstract void f3179();
+    public abstract void f3180();
+    public abstract void f3181();
+    public abstract void f3182();
+    public abstract void f3183();
+    public abstract void f3184();
+    public abstract void f3185();
+    public abstract void f3186();
+    public abstract void f3187();
+    public abstract void f3188();
+    public abstract void f3189();
+    public abstract void f3190();
+    public abstract void f3191();
+    public abstract void f3192();
+    public abstract void f3193();
+    public abstract void f3194();
+    public abstract void f3195();
+    public abstract void f3196();
+    public abstract void f3197();
+    public abstract void f3198();
+    public abstract void f3199();
+    public abstract void f3200();
+    public abstract void f3201();
+    public abstract void f3202();
+    public abstract void f3203();
+    public abstract void f3204();
+    public abstract void f3205();
+    public abstract void f3206();
+    public abstract void f3207();
+    public abstract void f3208();
+    public abstract void f3209();
+    public abstract void f3210();
+    public abstract void f3211();
+    public abstract void f3212();
+    public abstract void f3213();
+    public abstract void f3214();
+    public abstract void f3215();
+    public abstract void f3216();
+    public abstract void f3217();
+    public abstract void f3218();
+    public abstract void f3219();
+    public abstract void f3220();
+    public abstract void f3221();
+    public abstract void f3222();
+    public abstract void f3223();
+    public abstract void f3224();
+    public abstract void f3225();
+    public abstract void f3226();
+    public abstract void f3227();
+    public abstract void f3228();
+    public abstract void f3229();
+    public abstract void f3230();
+    public abstract void f3231();
+    public abstract void f3232();
+    public abstract void f3233();
+    public abstract void f3234();
+    public abstract void f3235();
+    public abstract void f3236();
+    public abstract void f3237();
+    public abstract void f3238();
+    public abstract void f3239();
+    public abstract void f3240();
+    public abstract void f3241();
+    public abstract void f3242();
+    public abstract void f3243();
+    public abstract void f3244();
+    public abstract void f3245();
+    public abstract void f3246();
+    public abstract void f3247();
+    public abstract void f3248();
+    public abstract void f3249();
+    public abstract void f3250();
+    public abstract void f3251();
+    public abstract void f3252();
+    public abstract void f3253();
+    public abstract void f3254();
+    public abstract void f3255();
+    public abstract void f3256();
+    public abstract void f3257();
+    public abstract void f3258();
+    public abstract void f3259();
+    public abstract void f3260();
+    public abstract void f3261();
+    public abstract void f3262();
+    public abstract void f3263();
+    public abstract void f3264();
+    public abstract void f3265();
+    public abstract void f3266();
+    public abstract void f3267();
+    public abstract void f3268();
+    public abstract void f3269();
+    public abstract void f3270();
+    public abstract void f3271();
+    public abstract void f3272();
+    public abstract void f3273();
+    public abstract void f3274();
+    public abstract void f3275();
+    public abstract void f3276();
+    public abstract void f3277();
+    public abstract void f3278();
+    public abstract void f3279();
+    public abstract void f3280();
+    public abstract void f3281();
+    public abstract void f3282();
+    public abstract void f3283();
+    public abstract void f3284();
+    public abstract void f3285();
+    public abstract void f3286();
+    public abstract void f3287();
+    public abstract void f3288();
+    public abstract void f3289();
+    public abstract void f3290();
+    public abstract void f3291();
+    public abstract void f3292();
+    public abstract void f3293();
+    public abstract void f3294();
+    public abstract void f3295();
+    public abstract void f3296();
+    public abstract void f3297();
+    public abstract void f3298();
+    public abstract void f3299();
+    public abstract void f3300();
+    public abstract void f3301();
+    public abstract void f3302();
+    public abstract void f3303();
+    public abstract void f3304();
+    public abstract void f3305();
+    public abstract void f3306();
+    public abstract void f3307();
+    public abstract void f3308();
+    public abstract void f3309();
+    public abstract void f3310();
+    public abstract void f3311();
+    public abstract void f3312();
+    public abstract void f3313();
+    public abstract void f3314();
+    public abstract void f3315();
+    public abstract void f3316();
+    public abstract void f3317();
+    public abstract void f3318();
+    public abstract void f3319();
+    public abstract void f3320();
+    public abstract void f3321();
+    public abstract void f3322();
+    public abstract void f3323();
+    public abstract void f3324();
+    public abstract void f3325();
+    public abstract void f3326();
+    public abstract void f3327();
+    public abstract void f3328();
+    public abstract void f3329();
+    public abstract void f3330();
+    public abstract void f3331();
+    public abstract void f3332();
+    public abstract void f3333();
+    public abstract void f3334();
+    public abstract void f3335();
+    public abstract void f3336();
+    public abstract void f3337();
+    public abstract void f3338();
+    public abstract void f3339();
+    public abstract void f3340();
+    public abstract void f3341();
+    public abstract void f3342();
+    public abstract void f3343();
+    public abstract void f3344();
+    public abstract void f3345();
+    public abstract void f3346();
+    public abstract void f3347();
+    public abstract void f3348();
+    public abstract void f3349();
+    public abstract void f3350();
+    public abstract void f3351();
+    public abstract void f3352();
+    public abstract void f3353();
+    public abstract void f3354();
+    public abstract void f3355();
+    public abstract void f3356();
+    public abstract void f3357();
+    public abstract void f3358();
+    public abstract void f3359();
+    public abstract void f3360();
+    public abstract void f3361();
+    public abstract void f3362();
+    public abstract void f3363();
+    public abstract void f3364();
+    public abstract void f3365();
+    public abstract void f3366();
+    public abstract void f3367();
+    public abstract void f3368();
+    public abstract void f3369();
+    public abstract void f3370();
+    public abstract void f3371();
+    public abstract void f3372();
+    public abstract void f3373();
+    public abstract void f3374();
+    public abstract void f3375();
+    public abstract void f3376();
+    public abstract void f3377();
+    public abstract void f3378();
+    public abstract void f3379();
+    public abstract void f3380();
+    public abstract void f3381();
+    public abstract void f3382();
+    public abstract void f3383();
+    public abstract void f3384();
+    public abstract void f3385();
+    public abstract void f3386();
+    public abstract void f3387();
+    public abstract void f3388();
+    public abstract void f3389();
+    public abstract void f3390();
+    public abstract void f3391();
+    public abstract void f3392();
+    public abstract void f3393();
+    public abstract void f3394();
+    public abstract void f3395();
+    public abstract void f3396();
+    public abstract void f3397();
+    public abstract void f3398();
+    public abstract void f3399();
+    public abstract void f3400();
+    public abstract void f3401();
+    public abstract void f3402();
+    public abstract void f3403();
+    public abstract void f3404();
+    public abstract void f3405();
+    public abstract void f3406();
+    public abstract void f3407();
+    public abstract void f3408();
+    public abstract void f3409();
+    public abstract void f3410();
+    public abstract void f3411();
+    public abstract void f3412();
+    public abstract void f3413();
+    public abstract void f3414();
+    public abstract void f3415();
+    public abstract void f3416();
+    public abstract void f3417();
+    public abstract void f3418();
+    public abstract void f3419();
+    public abstract void f3420();
+    public abstract void f3421();
+    public abstract void f3422();
+    public abstract void f3423();
+    public abstract void f3424();
+    public abstract void f3425();
+    public abstract void f3426();
+    public abstract void f3427();
+    public abstract void f3428();
+    public abstract void f3429();
+    public abstract void f3430();
+    public abstract void f3431();
+    public abstract void f3432();
+    public abstract void f3433();
+    public abstract void f3434();
+    public abstract void f3435();
+    public abstract void f3436();
+    public abstract void f3437();
+    public abstract void f3438();
+    public abstract void f3439();
+    public abstract void f3440();
+    public abstract void f3441();
+    public abstract void f3442();
+    public abstract void f3443();
+    public abstract void f3444();
+    public abstract void f3445();
+    public abstract void f3446();
+    public abstract void f3447();
+    public abstract void f3448();
+    public abstract void f3449();
+    public abstract void f3450();
+    public abstract void f3451();
+    public abstract void f3452();
+    public abstract void f3453();
+    public abstract void f3454();
+    public abstract void f3455();
+    public abstract void f3456();
+    public abstract void f3457();
+    public abstract void f3458();
+    public abstract void f3459();
+    public abstract void f3460();
+    public abstract void f3461();
+    public abstract void f3462();
+    public abstract void f3463();
+    public abstract void f3464();
+    public abstract void f3465();
+    public abstract void f3466();
+    public abstract void f3467();
+    public abstract void f3468();
+    public abstract void f3469();
+    public abstract void f3470();
+    public abstract void f3471();
+    public abstract void f3472();
+    public abstract void f3473();
+    public abstract void f3474();
+    public abstract void f3475();
+    public abstract void f3476();
+    public abstract void f3477();
+    public abstract void f3478();
+    public abstract void f3479();
+    public abstract void f3480();
+    public abstract void f3481();
+    public abstract void f3482();
+    public abstract void f3483();
+    public abstract void f3484();
+    public abstract void f3485();
+    public abstract void f3486();
+    public abstract void f3487();
+    public abstract void f3488();
+    public abstract void f3489();
+    public abstract void f3490();
+    public abstract void f3491();
+    public abstract void f3492();
+    public abstract void f3493();
+    public abstract void f3494();
+    public abstract void f3495();
+    public abstract void f3496();
+    public abstract void f3497();
+    public abstract void f3498();
+    public abstract void f3499();
+    public abstract void f3500();
+    public abstract void f3501();
+    public abstract void f3502();
+    public abstract void f3503();
+    public abstract void f3504();
+    public abstract void f3505();
+    public abstract void f3506();
+    public abstract void f3507();
+    public abstract void f3508();
+    public abstract void f3509();
+    public abstract void f3510();
+    public abstract void f3511();
+    public abstract void f3512();
+    public abstract void f3513();
+    public abstract void f3514();
+    public abstract void f3515();
+    public abstract void f3516();
+    public abstract void f3517();
+    public abstract void f3518();
+    public abstract void f3519();
+    public abstract void f3520();
+    public abstract void f3521();
+    public abstract void f3522();
+    public abstract void f3523();
+    public abstract void f3524();
+    public abstract void f3525();
+    public abstract void f3526();
+    public abstract void f3527();
+    public abstract void f3528();
+    public abstract void f3529();
+    public abstract void f3530();
+    public abstract void f3531();
+    public abstract void f3532();
+    public abstract void f3533();
+    public abstract void f3534();
+    public abstract void f3535();
+    public abstract void f3536();
+    public abstract void f3537();
+    public abstract void f3538();
+    public abstract void f3539();
+    public abstract void f3540();
+    public abstract void f3541();
+    public abstract void f3542();
+    public abstract void f3543();
+    public abstract void f3544();
+    public abstract void f3545();
+    public abstract void f3546();
+    public abstract void f3547();
+    public abstract void f3548();
+    public abstract void f3549();
+    public abstract void f3550();
+    public abstract void f3551();
+    public abstract void f3552();
+    public abstract void f3553();
+    public abstract void f3554();
+    public abstract void f3555();
+    public abstract void f3556();
+    public abstract void f3557();
+    public abstract void f3558();
+    public abstract void f3559();
+    public abstract void f3560();
+    public abstract void f3561();
+    public abstract void f3562();
+    public abstract void f3563();
+    public abstract void f3564();
+    public abstract void f3565();
+    public abstract void f3566();
+    public abstract void f3567();
+    public abstract void f3568();
+    public abstract void f3569();
+    public abstract void f3570();
+    public abstract void f3571();
+    public abstract void f3572();
+    public abstract void f3573();
+    public abstract void f3574();
+    public abstract void f3575();
+    public abstract void f3576();
+    public abstract void f3577();
+    public abstract void f3578();
+    public abstract void f3579();
+    public abstract void f3580();
+    public abstract void f3581();
+    public abstract void f3582();
+    public abstract void f3583();
+    public abstract void f3584();
+    public abstract void f3585();
+    public abstract void f3586();
+    public abstract void f3587();
+    public abstract void f3588();
+    public abstract void f3589();
+    public abstract void f3590();
+    public abstract void f3591();
+    public abstract void f3592();
+    public abstract void f3593();
+    public abstract void f3594();
+    public abstract void f3595();
+    public abstract void f3596();
+    public abstract void f3597();
+    public abstract void f3598();
+    public abstract void f3599();
+    public abstract void f3600();
+    public abstract void f3601();
+    public abstract void f3602();
+    public abstract void f3603();
+    public abstract void f3604();
+    public abstract void f3605();
+    public abstract void f3606();
+    public abstract void f3607();
+    public abstract void f3608();
+    public abstract void f3609();
+    public abstract void f3610();
+    public abstract void f3611();
+    public abstract void f3612();
+    public abstract void f3613();
+    public abstract void f3614();
+    public abstract void f3615();
+    public abstract void f3616();
+    public abstract void f3617();
+    public abstract void f3618();
+    public abstract void f3619();
+    public abstract void f3620();
+    public abstract void f3621();
+    public abstract void f3622();
+    public abstract void f3623();
+    public abstract void f3624();
+    public abstract void f3625();
+    public abstract void f3626();
+    public abstract void f3627();
+    public abstract void f3628();
+    public abstract void f3629();
+    public abstract void f3630();
+    public abstract void f3631();
+    public abstract void f3632();
+    public abstract void f3633();
+    public abstract void f3634();
+    public abstract void f3635();
+    public abstract void f3636();
+    public abstract void f3637();
+    public abstract void f3638();
+    public abstract void f3639();
+    public abstract void f3640();
+    public abstract void f3641();
+    public abstract void f3642();
+    public abstract void f3643();
+    public abstract void f3644();
+    public abstract void f3645();
+    public abstract void f3646();
+    public abstract void f3647();
+    public abstract void f3648();
+    public abstract void f3649();
+    public abstract void f3650();
+    public abstract void f3651();
+    public abstract void f3652();
+    public abstract void f3653();
+    public abstract void f3654();
+    public abstract void f3655();
+    public abstract void f3656();
+    public abstract void f3657();
+    public abstract void f3658();
+    public abstract void f3659();
+    public abstract void f3660();
+    public abstract void f3661();
+    public abstract void f3662();
+    public abstract void f3663();
+    public abstract void f3664();
+    public abstract void f3665();
+    public abstract void f3666();
+    public abstract void f3667();
+    public abstract void f3668();
+    public abstract void f3669();
+    public abstract void f3670();
+    public abstract void f3671();
+    public abstract void f3672();
+    public abstract void f3673();
+    public abstract void f3674();
+    public abstract void f3675();
+    public abstract void f3676();
+    public abstract void f3677();
+    public abstract void f3678();
+    public abstract void f3679();
+    public abstract void f3680();
+    public abstract void f3681();
+    public abstract void f3682();
+    public abstract void f3683();
+    public abstract void f3684();
+    public abstract void f3685();
+    public abstract void f3686();
+    public abstract void f3687();
+    public abstract void f3688();
+    public abstract void f3689();
+    public abstract void f3690();
+    public abstract void f3691();
+    public abstract void f3692();
+    public abstract void f3693();
+    public abstract void f3694();
+    public abstract void f3695();
+    public abstract void f3696();
+    public abstract void f3697();
+    public abstract void f3698();
+    public abstract void f3699();
+    public abstract void f3700();
+    public abstract void f3701();
+    public abstract void f3702();
+    public abstract void f3703();
+    public abstract void f3704();
+    public abstract void f3705();
+    public abstract void f3706();
+    public abstract void f3707();
+    public abstract void f3708();
+    public abstract void f3709();
+    public abstract void f3710();
+    public abstract void f3711();
+    public abstract void f3712();
+    public abstract void f3713();
+    public abstract void f3714();
+    public abstract void f3715();
+    public abstract void f3716();
+    public abstract void f3717();
+    public abstract void f3718();
+    public abstract void f3719();
+    public abstract void f3720();
+    public abstract void f3721();
+    public abstract void f3722();
+    public abstract void f3723();
+    public abstract void f3724();
+    public abstract void f3725();
+    public abstract void f3726();
+    public abstract void f3727();
+    public abstract void f3728();
+    public abstract void f3729();
+    public abstract void f3730();
+    public abstract void f3731();
+    public abstract void f3732();
+    public abstract void f3733();
+    public abstract void f3734();
+    public abstract void f3735();
+    public abstract void f3736();
+    public abstract void f3737();
+    public abstract void f3738();
+    public abstract void f3739();
+    public abstract void f3740();
+    public abstract void f3741();
+    public abstract void f3742();
+    public abstract void f3743();
+    public abstract void f3744();
+    public abstract void f3745();
+    public abstract void f3746();
+    public abstract void f3747();
+    public abstract void f3748();
+    public abstract void f3749();
+    public abstract void f3750();
+    public abstract void f3751();
+    public abstract void f3752();
+    public abstract void f3753();
+    public abstract void f3754();
+    public abstract void f3755();
+    public abstract void f3756();
+    public abstract void f3757();
+    public abstract void f3758();
+    public abstract void f3759();
+    public abstract void f3760();
+    public abstract void f3761();
+    public abstract void f3762();
+    public abstract void f3763();
+    public abstract void f3764();
+    public abstract void f3765();
+    public abstract void f3766();
+    public abstract void f3767();
+    public abstract void f3768();
+    public abstract void f3769();
+    public abstract void f3770();
+    public abstract void f3771();
+    public abstract void f3772();
+    public abstract void f3773();
+    public abstract void f3774();
+    public abstract void f3775();
+    public abstract void f3776();
+    public abstract void f3777();
+    public abstract void f3778();
+    public abstract void f3779();
+    public abstract void f3780();
+    public abstract void f3781();
+    public abstract void f3782();
+    public abstract void f3783();
+    public abstract void f3784();
+    public abstract void f3785();
+    public abstract void f3786();
+    public abstract void f3787();
+    public abstract void f3788();
+    public abstract void f3789();
+    public abstract void f3790();
+    public abstract void f3791();
+    public abstract void f3792();
+    public abstract void f3793();
+    public abstract void f3794();
+    public abstract void f3795();
+    public abstract void f3796();
+    public abstract void f3797();
+    public abstract void f3798();
+    public abstract void f3799();
+    public abstract void f3800();
+    public abstract void f3801();
+    public abstract void f3802();
+    public abstract void f3803();
+    public abstract void f3804();
+    public abstract void f3805();
+    public abstract void f3806();
+    public abstract void f3807();
+    public abstract void f3808();
+    public abstract void f3809();
+    public abstract void f3810();
+    public abstract void f3811();
+    public abstract void f3812();
+    public abstract void f3813();
+    public abstract void f3814();
+    public abstract void f3815();
+    public abstract void f3816();
+    public abstract void f3817();
+    public abstract void f3818();
+    public abstract void f3819();
+    public abstract void f3820();
+    public abstract void f3821();
+    public abstract void f3822();
+    public abstract void f3823();
+    public abstract void f3824();
+    public abstract void f3825();
+    public abstract void f3826();
+    public abstract void f3827();
+    public abstract void f3828();
+    public abstract void f3829();
+    public abstract void f3830();
+    public abstract void f3831();
+    public abstract void f3832();
+    public abstract void f3833();
+    public abstract void f3834();
+    public abstract void f3835();
+    public abstract void f3836();
+    public abstract void f3837();
+    public abstract void f3838();
+    public abstract void f3839();
+    public abstract void f3840();
+    public abstract void f3841();
+    public abstract void f3842();
+    public abstract void f3843();
+    public abstract void f3844();
+    public abstract void f3845();
+    public abstract void f3846();
+    public abstract void f3847();
+    public abstract void f3848();
+    public abstract void f3849();
+    public abstract void f3850();
+    public abstract void f3851();
+    public abstract void f3852();
+    public abstract void f3853();
+    public abstract void f3854();
+    public abstract void f3855();
+    public abstract void f3856();
+    public abstract void f3857();
+    public abstract void f3858();
+    public abstract void f3859();
+    public abstract void f3860();
+    public abstract void f3861();
+    public abstract void f3862();
+    public abstract void f3863();
+    public abstract void f3864();
+    public abstract void f3865();
+    public abstract void f3866();
+    public abstract void f3867();
+    public abstract void f3868();
+    public abstract void f3869();
+    public abstract void f3870();
+    public abstract void f3871();
+    public abstract void f3872();
+    public abstract void f3873();
+    public abstract void f3874();
+    public abstract void f3875();
+    public abstract void f3876();
+    public abstract void f3877();
+    public abstract void f3878();
+    public abstract void f3879();
+    public abstract void f3880();
+    public abstract void f3881();
+    public abstract void f3882();
+    public abstract void f3883();
+    public abstract void f3884();
+    public abstract void f3885();
+    public abstract void f3886();
+    public abstract void f3887();
+    public abstract void f3888();
+    public abstract void f3889();
+    public abstract void f3890();
+    public abstract void f3891();
+    public abstract void f3892();
+    public abstract void f3893();
+    public abstract void f3894();
+    public abstract void f3895();
+    public abstract void f3896();
+    public abstract void f3897();
+    public abstract void f3898();
+    public abstract void f3899();
+    public abstract void f3900();
+    public abstract void f3901();
+    public abstract void f3902();
+    public abstract void f3903();
+    public abstract void f3904();
+    public abstract void f3905();
+    public abstract void f3906();
+    public abstract void f3907();
+    public abstract void f3908();
+    public abstract void f3909();
+    public abstract void f3910();
+    public abstract void f3911();
+    public abstract void f3912();
+    public abstract void f3913();
+    public abstract void f3914();
+    public abstract void f3915();
+    public abstract void f3916();
+    public abstract void f3917();
+    public abstract void f3918();
+    public abstract void f3919();
+    public abstract void f3920();
+    public abstract void f3921();
+    public abstract void f3922();
+    public abstract void f3923();
+    public abstract void f3924();
+    public abstract void f3925();
+    public abstract void f3926();
+    public abstract void f3927();
+    public abstract void f3928();
+    public abstract void f3929();
+    public abstract void f3930();
+    public abstract void f3931();
+    public abstract void f3932();
+    public abstract void f3933();
+    public abstract void f3934();
+    public abstract void f3935();
+    public abstract void f3936();
+    public abstract void f3937();
+    public abstract void f3938();
+    public abstract void f3939();
+    public abstract void f3940();
+    public abstract void f3941();
+    public abstract void f3942();
+    public abstract void f3943();
+    public abstract void f3944();
+    public abstract void f3945();
+    public abstract void f3946();
+    public abstract void f3947();
+    public abstract void f3948();
+    public abstract void f3949();
+    public abstract void f3950();
+    public abstract void f3951();
+    public abstract void f3952();
+    public abstract void f3953();
+    public abstract void f3954();
+    public abstract void f3955();
+    public abstract void f3956();
+    public abstract void f3957();
+    public abstract void f3958();
+    public abstract void f3959();
+    public abstract void f3960();
+    public abstract void f3961();
+    public abstract void f3962();
+    public abstract void f3963();
+    public abstract void f3964();
+    public abstract void f3965();
+    public abstract void f3966();
+    public abstract void f3967();
+    public abstract void f3968();
+    public abstract void f3969();
+    public abstract void f3970();
+    public abstract void f3971();
+    public abstract void f3972();
+    public abstract void f3973();
+    public abstract void f3974();
+    public abstract void f3975();
+    public abstract void f3976();
+    public abstract void f3977();
+    public abstract void f3978();
+    public abstract void f3979();
+    public abstract void f3980();
+    public abstract void f3981();
+    public abstract void f3982();
+    public abstract void f3983();
+    public abstract void f3984();
+    public abstract void f3985();
+    public abstract void f3986();
+    public abstract void f3987();
+    public abstract void f3988();
+    public abstract void f3989();
+    public abstract void f3990();
+    public abstract void f3991();
+    public abstract void f3992();
+    public abstract void f3993();
+    public abstract void f3994();
+    public abstract void f3995();
+    public abstract void f3996();
+    public abstract void f3997();
+    public abstract void f3998();
+    public abstract void f3999();
+    public abstract void f4000();
+    public abstract void f4001();
+    public abstract void f4002();
+    public abstract void f4003();
+    public abstract void f4004();
+    public abstract void f4005();
+    public abstract void f4006();
+    public abstract void f4007();
+    public abstract void f4008();
+    public abstract void f4009();
+    public abstract void f4010();
+    public abstract void f4011();
+    public abstract void f4012();
+    public abstract void f4013();
+    public abstract void f4014();
+    public abstract void f4015();
+    public abstract void f4016();
+    public abstract void f4017();
+    public abstract void f4018();
+    public abstract void f4019();
+    public abstract void f4020();
+    public abstract void f4021();
+    public abstract void f4022();
+    public abstract void f4023();
+    public abstract void f4024();
+    public abstract void f4025();
+    public abstract void f4026();
+    public abstract void f4027();
+    public abstract void f4028();
+    public abstract void f4029();
+    public abstract void f4030();
+    public abstract void f4031();
+    public abstract void f4032();
+    public abstract void f4033();
+    public abstract void f4034();
+    public abstract void f4035();
+    public abstract void f4036();
+    public abstract void f4037();
+    public abstract void f4038();
+    public abstract void f4039();
+    public abstract void f4040();
+    public abstract void f4041();
+    public abstract void f4042();
+    public abstract void f4043();
+    public abstract void f4044();
+    public abstract void f4045();
+    public abstract void f4046();
+    public abstract void f4047();
+    public abstract void f4048();
+    public abstract void f4049();
+    public abstract void f4050();
+    public abstract void f4051();
+    public abstract void f4052();
+    public abstract void f4053();
+    public abstract void f4054();
+    public abstract void f4055();
+    public abstract void f4056();
+    public abstract void f4057();
+    public abstract void f4058();
+    public abstract void f4059();
+    public abstract void f4060();
+    public abstract void f4061();
+    public abstract void f4062();
+    public abstract void f4063();
+    public abstract void f4064();
+    public abstract void f4065();
+    public abstract void f4066();
+    public abstract void f4067();
+    public abstract void f4068();
+    public abstract void f4069();
+    public abstract void f4070();
+    public abstract void f4071();
+    public abstract void f4072();
+    public abstract void f4073();
+    public abstract void f4074();
+    public abstract void f4075();
+    public abstract void f4076();
+    public abstract void f4077();
+    public abstract void f4078();
+    public abstract void f4079();
+    public abstract void f4080();
+    public abstract void f4081();
+    public abstract void f4082();
+    public abstract void f4083();
+    public abstract void f4084();
+    public abstract void f4085();
+    public abstract void f4086();
+    public abstract void f4087();
+    public abstract void f4088();
+    public abstract void f4089();
+    public abstract void f4090();
+    public abstract void f4091();
+    public abstract void f4092();
+    public abstract void f4093();
+    public abstract void f4094();
+    public abstract void f4095();
+    public abstract void f4096();
+    public abstract void f4097();
+    public abstract void f4098();
+    public abstract void f4099();
+    public abstract void f4100();
+    public abstract void f4101();
+    public abstract void f4102();
+    public abstract void f4103();
+    public abstract void f4104();
+    public abstract void f4105();
+    public abstract void f4106();
+    public abstract void f4107();
+    public abstract void f4108();
+    public abstract void f4109();
+    public abstract void f4110();
+    public abstract void f4111();
+    public abstract void f4112();
+    public abstract void f4113();
+    public abstract void f4114();
+    public abstract void f4115();
+    public abstract void f4116();
+    public abstract void f4117();
+    public abstract void f4118();
+    public abstract void f4119();
+    public abstract void f4120();
+    public abstract void f4121();
+    public abstract void f4122();
+    public abstract void f4123();
+    public abstract void f4124();
+    public abstract void f4125();
+    public abstract void f4126();
+    public abstract void f4127();
+    public abstract void f4128();
+    public abstract void f4129();
+    public abstract void f4130();
+    public abstract void f4131();
+    public abstract void f4132();
+    public abstract void f4133();
+    public abstract void f4134();
+    public abstract void f4135();
+    public abstract void f4136();
+    public abstract void f4137();
+    public abstract void f4138();
+    public abstract void f4139();
+    public abstract void f4140();
+    public abstract void f4141();
+    public abstract void f4142();
+    public abstract void f4143();
+    public abstract void f4144();
+    public abstract void f4145();
+    public abstract void f4146();
+    public abstract void f4147();
+    public abstract void f4148();
+    public abstract void f4149();
+    public abstract void f4150();
+    public abstract void f4151();
+    public abstract void f4152();
+    public abstract void f4153();
+    public abstract void f4154();
+    public abstract void f4155();
+    public abstract void f4156();
+    public abstract void f4157();
+    public abstract void f4158();
+    public abstract void f4159();
+    public abstract void f4160();
+    public abstract void f4161();
+    public abstract void f4162();
+    public abstract void f4163();
+    public abstract void f4164();
+    public abstract void f4165();
+    public abstract void f4166();
+    public abstract void f4167();
+    public abstract void f4168();
+    public abstract void f4169();
+    public abstract void f4170();
+    public abstract void f4171();
+    public abstract void f4172();
+    public abstract void f4173();
+    public abstract void f4174();
+    public abstract void f4175();
+    public abstract void f4176();
+    public abstract void f4177();
+    public abstract void f4178();
+    public abstract void f4179();
+    public abstract void f4180();
+    public abstract void f4181();
+    public abstract void f4182();
+    public abstract void f4183();
+    public abstract void f4184();
+    public abstract void f4185();
+    public abstract void f4186();
+    public abstract void f4187();
+    public abstract void f4188();
+    public abstract void f4189();
+    public abstract void f4190();
+    public abstract void f4191();
+    public abstract void f4192();
+    public abstract void f4193();
+    public abstract void f4194();
+    public abstract void f4195();
+    public abstract void f4196();
+    public abstract void f4197();
+    public abstract void f4198();
+    public abstract void f4199();
+    public abstract void f4200();
+    public abstract void f4201();
+    public abstract void f4202();
+    public abstract void f4203();
+    public abstract void f4204();
+    public abstract void f4205();
+    public abstract void f4206();
+    public abstract void f4207();
+    public abstract void f4208();
+    public abstract void f4209();
+    public abstract void f4210();
+    public abstract void f4211();
+    public abstract void f4212();
+    public abstract void f4213();
+    public abstract void f4214();
+    public abstract void f4215();
+    public abstract void f4216();
+    public abstract void f4217();
+    public abstract void f4218();
+    public abstract void f4219();
+    public abstract void f4220();
+    public abstract void f4221();
+    public abstract void f4222();
+    public abstract void f4223();
+    public abstract void f4224();
+    public abstract void f4225();
+    public abstract void f4226();
+    public abstract void f4227();
+    public abstract void f4228();
+    public abstract void f4229();
+    public abstract void f4230();
+    public abstract void f4231();
+    public abstract void f4232();
+    public abstract void f4233();
+    public abstract void f4234();
+    public abstract void f4235();
+    public abstract void f4236();
+    public abstract void f4237();
+    public abstract void f4238();
+    public abstract void f4239();
+    public abstract void f4240();
+    public abstract void f4241();
+    public abstract void f4242();
+    public abstract void f4243();
+    public abstract void f4244();
+    public abstract void f4245();
+    public abstract void f4246();
+    public abstract void f4247();
+    public abstract void f4248();
+    public abstract void f4249();
+    public abstract void f4250();
+    public abstract void f4251();
+    public abstract void f4252();
+    public abstract void f4253();
+    public abstract void f4254();
+    public abstract void f4255();
+    public abstract void f4256();
+    public abstract void f4257();
+    public abstract void f4258();
+    public abstract void f4259();
+    public abstract void f4260();
+    public abstract void f4261();
+    public abstract void f4262();
+    public abstract void f4263();
+    public abstract void f4264();
+    public abstract void f4265();
+    public abstract void f4266();
+    public abstract void f4267();
+    public abstract void f4268();
+    public abstract void f4269();
+    public abstract void f4270();
+    public abstract void f4271();
+    public abstract void f4272();
+    public abstract void f4273();
+    public abstract void f4274();
+    public abstract void f4275();
+    public abstract void f4276();
+    public abstract void f4277();
+    public abstract void f4278();
+    public abstract void f4279();
+    public abstract void f4280();
+    public abstract void f4281();
+    public abstract void f4282();
+    public abstract void f4283();
+    public abstract void f4284();
+    public abstract void f4285();
+    public abstract void f4286();
+    public abstract void f4287();
+    public abstract void f4288();
+    public abstract void f4289();
+    public abstract void f4290();
+    public abstract void f4291();
+    public abstract void f4292();
+    public abstract void f4293();
+    public abstract void f4294();
+    public abstract void f4295();
+    public abstract void f4296();
+    public abstract void f4297();
+    public abstract void f4298();
+    public abstract void f4299();
+    public abstract void f4300();
+    public abstract void f4301();
+    public abstract void f4302();
+    public abstract void f4303();
+    public abstract void f4304();
+    public abstract void f4305();
+    public abstract void f4306();
+    public abstract void f4307();
+    public abstract void f4308();
+    public abstract void f4309();
+    public abstract void f4310();
+    public abstract void f4311();
+    public abstract void f4312();
+    public abstract void f4313();
+    public abstract void f4314();
+    public abstract void f4315();
+    public abstract void f4316();
+    public abstract void f4317();
+    public abstract void f4318();
+    public abstract void f4319();
+    public abstract void f4320();
+    public abstract void f4321();
+    public abstract void f4322();
+    public abstract void f4323();
+    public abstract void f4324();
+    public abstract void f4325();
+    public abstract void f4326();
+    public abstract void f4327();
+    public abstract void f4328();
+    public abstract void f4329();
+    public abstract void f4330();
+    public abstract void f4331();
+    public abstract void f4332();
+    public abstract void f4333();
+    public abstract void f4334();
+    public abstract void f4335();
+    public abstract void f4336();
+    public abstract void f4337();
+    public abstract void f4338();
+    public abstract void f4339();
+    public abstract void f4340();
+    public abstract void f4341();
+    public abstract void f4342();
+    public abstract void f4343();
+    public abstract void f4344();
+    public abstract void f4345();
+    public abstract void f4346();
+    public abstract void f4347();
+    public abstract void f4348();
+    public abstract void f4349();
+    public abstract void f4350();
+    public abstract void f4351();
+    public abstract void f4352();
+    public abstract void f4353();
+    public abstract void f4354();
+    public abstract void f4355();
+    public abstract void f4356();
+    public abstract void f4357();
+    public abstract void f4358();
+    public abstract void f4359();
+    public abstract void f4360();
+    public abstract void f4361();
+    public abstract void f4362();
+    public abstract void f4363();
+    public abstract void f4364();
+    public abstract void f4365();
+    public abstract void f4366();
+    public abstract void f4367();
+    public abstract void f4368();
+    public abstract void f4369();
+    public abstract void f4370();
+    public abstract void f4371();
+    public abstract void f4372();
+    public abstract void f4373();
+    public abstract void f4374();
+    public abstract void f4375();
+    public abstract void f4376();
+    public abstract void f4377();
+    public abstract void f4378();
+    public abstract void f4379();
+    public abstract void f4380();
+    public abstract void f4381();
+    public abstract void f4382();
+    public abstract void f4383();
+    public abstract void f4384();
+    public abstract void f4385();
+    public abstract void f4386();
+    public abstract void f4387();
+    public abstract void f4388();
+    public abstract void f4389();
+    public abstract void f4390();
+    public abstract void f4391();
+    public abstract void f4392();
+    public abstract void f4393();
+    public abstract void f4394();
+    public abstract void f4395();
+    public abstract void f4396();
+    public abstract void f4397();
+    public abstract void f4398();
+    public abstract void f4399();
+    public abstract void f4400();
+    public abstract void f4401();
+    public abstract void f4402();
+    public abstract void f4403();
+    public abstract void f4404();
+    public abstract void f4405();
+    public abstract void f4406();
+    public abstract void f4407();
+    public abstract void f4408();
+    public abstract void f4409();
+    public abstract void f4410();
+    public abstract void f4411();
+    public abstract void f4412();
+    public abstract void f4413();
+    public abstract void f4414();
+    public abstract void f4415();
+    public abstract void f4416();
+    public abstract void f4417();
+    public abstract void f4418();
+    public abstract void f4419();
+    public abstract void f4420();
+    public abstract void f4421();
+    public abstract void f4422();
+    public abstract void f4423();
+    public abstract void f4424();
+    public abstract void f4425();
+    public abstract void f4426();
+    public abstract void f4427();
+    public abstract void f4428();
+    public abstract void f4429();
+    public abstract void f4430();
+    public abstract void f4431();
+    public abstract void f4432();
+    public abstract void f4433();
+    public abstract void f4434();
+    public abstract void f4435();
+    public abstract void f4436();
+    public abstract void f4437();
+    public abstract void f4438();
+    public abstract void f4439();
+    public abstract void f4440();
+    public abstract void f4441();
+    public abstract void f4442();
+    public abstract void f4443();
+    public abstract void f4444();
+    public abstract void f4445();
+    public abstract void f4446();
+    public abstract void f4447();
+    public abstract void f4448();
+    public abstract void f4449();
+    public abstract void f4450();
+    public abstract void f4451();
+    public abstract void f4452();
+    public abstract void f4453();
+    public abstract void f4454();
+    public abstract void f4455();
+    public abstract void f4456();
+    public abstract void f4457();
+    public abstract void f4458();
+    public abstract void f4459();
+    public abstract void f4460();
+    public abstract void f4461();
+    public abstract void f4462();
+    public abstract void f4463();
+    public abstract void f4464();
+    public abstract void f4465();
+    public abstract void f4466();
+    public abstract void f4467();
+    public abstract void f4468();
+    public abstract void f4469();
+    public abstract void f4470();
+    public abstract void f4471();
+    public abstract void f4472();
+    public abstract void f4473();
+    public abstract void f4474();
+    public abstract void f4475();
+    public abstract void f4476();
+    public abstract void f4477();
+    public abstract void f4478();
+    public abstract void f4479();
+    public abstract void f4480();
+    public abstract void f4481();
+    public abstract void f4482();
+    public abstract void f4483();
+    public abstract void f4484();
+    public abstract void f4485();
+    public abstract void f4486();
+    public abstract void f4487();
+    public abstract void f4488();
+    public abstract void f4489();
+    public abstract void f4490();
+    public abstract void f4491();
+    public abstract void f4492();
+    public abstract void f4493();
+    public abstract void f4494();
+    public abstract void f4495();
+    public abstract void f4496();
+    public abstract void f4497();
+    public abstract void f4498();
+    public abstract void f4499();
+    public abstract void f4500();
+    public abstract void f4501();
+    public abstract void f4502();
+    public abstract void f4503();
+    public abstract void f4504();
+    public abstract void f4505();
+    public abstract void f4506();
+    public abstract void f4507();
+    public abstract void f4508();
+    public abstract void f4509();
+    public abstract void f4510();
+    public abstract void f4511();
+    public abstract void f4512();
+    public abstract void f4513();
+    public abstract void f4514();
+    public abstract void f4515();
+    public abstract void f4516();
+    public abstract void f4517();
+    public abstract void f4518();
+    public abstract void f4519();
+    public abstract void f4520();
+    public abstract void f4521();
+    public abstract void f4522();
+    public abstract void f4523();
+    public abstract void f4524();
+    public abstract void f4525();
+    public abstract void f4526();
+    public abstract void f4527();
+    public abstract void f4528();
+    public abstract void f4529();
+    public abstract void f4530();
+    public abstract void f4531();
+    public abstract void f4532();
+    public abstract void f4533();
+    public abstract void f4534();
+    public abstract void f4535();
+    public abstract void f4536();
+    public abstract void f4537();
+    public abstract void f4538();
+    public abstract void f4539();
+    public abstract void f4540();
+    public abstract void f4541();
+    public abstract void f4542();
+    public abstract void f4543();
+    public abstract void f4544();
+    public abstract void f4545();
+    public abstract void f4546();
+    public abstract void f4547();
+    public abstract void f4548();
+    public abstract void f4549();
+    public abstract void f4550();
+    public abstract void f4551();
+    public abstract void f4552();
+    public abstract void f4553();
+    public abstract void f4554();
+    public abstract void f4555();
+    public abstract void f4556();
+    public abstract void f4557();
+    public abstract void f4558();
+    public abstract void f4559();
+    public abstract void f4560();
+    public abstract void f4561();
+    public abstract void f4562();
+    public abstract void f4563();
+    public abstract void f4564();
+    public abstract void f4565();
+    public abstract void f4566();
+    public abstract void f4567();
+    public abstract void f4568();
+    public abstract void f4569();
+    public abstract void f4570();
+    public abstract void f4571();
+    public abstract void f4572();
+    public abstract void f4573();
+    public abstract void f4574();
+    public abstract void f4575();
+    public abstract void f4576();
+    public abstract void f4577();
+    public abstract void f4578();
+    public abstract void f4579();
+    public abstract void f4580();
+    public abstract void f4581();
+    public abstract void f4582();
+    public abstract void f4583();
+    public abstract void f4584();
+    public abstract void f4585();
+    public abstract void f4586();
+    public abstract void f4587();
+    public abstract void f4588();
+    public abstract void f4589();
+    public abstract void f4590();
+    public abstract void f4591();
+    public abstract void f4592();
+    public abstract void f4593();
+    public abstract void f4594();
+    public abstract void f4595();
+    public abstract void f4596();
+    public abstract void f4597();
+    public abstract void f4598();
+    public abstract void f4599();
+    public abstract void f4600();
+    public abstract void f4601();
+    public abstract void f4602();
+    public abstract void f4603();
+    public abstract void f4604();
+    public abstract void f4605();
+    public abstract void f4606();
+    public abstract void f4607();
+    public abstract void f4608();
+    public abstract void f4609();
+    public abstract void f4610();
+    public abstract void f4611();
+    public abstract void f4612();
+    public abstract void f4613();
+    public abstract void f4614();
+    public abstract void f4615();
+    public abstract void f4616();
+    public abstract void f4617();
+    public abstract void f4618();
+    public abstract void f4619();
+    public abstract void f4620();
+    public abstract void f4621();
+    public abstract void f4622();
+    public abstract void f4623();
+    public abstract void f4624();
+    public abstract void f4625();
+    public abstract void f4626();
+    public abstract void f4627();
+    public abstract void f4628();
+    public abstract void f4629();
+    public abstract void f4630();
+    public abstract void f4631();
+    public abstract void f4632();
+    public abstract void f4633();
+    public abstract void f4634();
+    public abstract void f4635();
+    public abstract void f4636();
+    public abstract void f4637();
+    public abstract void f4638();
+    public abstract void f4639();
+    public abstract void f4640();
+    public abstract void f4641();
+    public abstract void f4642();
+    public abstract void f4643();
+    public abstract void f4644();
+    public abstract void f4645();
+    public abstract void f4646();
+    public abstract void f4647();
+    public abstract void f4648();
+    public abstract void f4649();
+    public abstract void f4650();
+    public abstract void f4651();
+    public abstract void f4652();
+    public abstract void f4653();
+    public abstract void f4654();
+    public abstract void f4655();
+    public abstract void f4656();
+    public abstract void f4657();
+    public abstract void f4658();
+    public abstract void f4659();
+    public abstract void f4660();
+    public abstract void f4661();
+    public abstract void f4662();
+    public abstract void f4663();
+    public abstract void f4664();
+    public abstract void f4665();
+    public abstract void f4666();
+    public abstract void f4667();
+    public abstract void f4668();
+    public abstract void f4669();
+    public abstract void f4670();
+    public abstract void f4671();
+    public abstract void f4672();
+    public abstract void f4673();
+    public abstract void f4674();
+    public abstract void f4675();
+    public abstract void f4676();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/test/models/JDK_8081015_TestModel.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
+import java.util.Collection;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Queue;
+
+@SuppressWarnings("javadoc")
+public class JDK_8081015_TestModel {
+    private String lastInvoked;
+
+    public void receiveCollection(final Collection<Object> c) {
+        lastInvoked = "receiveCollection";
+        walkCollection(c);
+    }
+
+    public void receiveDeque(final Deque<Object> d) {
+        lastInvoked = "receiveDeque";
+        walkCollection(d);
+    }
+
+    public void receiveList(final List<Object> l) {
+        lastInvoked = "receiveList";
+        walkCollection(l);
+    }
+
+    public void receiveQueue(final Queue<Object> q) {
+        lastInvoked = "receiveQueue";
+        walkCollection(q);
+    }
+
+    public String getLastInvoked() {
+        return lastInvoked;
+    }
+
+    private static void walkCollection(final Collection<Object> c) {
+        final Iterator<Object> it = c.iterator();
+        assertEquals(it.next(), Integer.valueOf(1));
+        assertEquals(it.next(), Integer.valueOf(2));
+        assertEquals(it.next(), Double.valueOf(3.3));
+        assertEquals(it.next(), "foo");
+        assertFalse(it.hasNext());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java	Fri Nov 13 15:38:44 2015 -0800
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+import java.util.List;
+import java.util.Map;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import org.testng.Assert;
+
+public class Jdk8072596TestSubject {
+
+    public Jdk8072596TestSubject(final Object x) {
+        Assert.assertTrue(x instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)x).get("bar"), 0);
+    }
+
+    // Test having to wrap some arguments but not others
+    public void test1(final String x, final Object y, final ScriptObject w) {
+        Assert.assertEquals(x, "true");
+
+        Assert.assertTrue(y instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)y).get("foo"), 1);
+
+        Assert.assertEquals(w.get("bar"), 2);
+    }
+
+    // Test having to wrap some arguments but not others, and a vararg array
+    public void test2(String x, final Object y, final ScriptObject w, final Object... z) {
+        test1(x, y, w);
+
+        Assert.assertEquals(z.length, 2);
+
+        Assert.assertTrue(z[0] instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)z[0]).get("baz"), 3);
+
+        Assert.assertTrue(z[1] instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)z[1]).get("bing"), 4);
+    }
+
+    // Test mixed (wrappable and non-wrappable) elements in a vararg array
+    public void test3(final Object... z) {
+        Assert.assertEquals(z.length, 5);
+
+        Assert.assertEquals(z[0], true);
+
+        Assert.assertTrue(z[1] instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)z[1]).get("foo"), 5);
+
+        Assert.assertEquals(z[2], "hello");
+
+        Assert.assertTrue(z[3] instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)z[3]).getSlot(0), 6);
+        Assert.assertEquals(((ScriptObjectMirror)z[3]).getSlot(1), 7);
+
+        Assert.assertEquals(z[4], 8);
+    }
+
+    // test wrapping the first argument of a static method
+    public static void test4(final Object x) {
+        Assert.assertTrue(x instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)x).get("foo"), 9);
+    }
+
+    public void testListHasWrappedObject(final List<?> l) {
+        Assert.assertEquals(l.size(), 1);
+        Assert.assertTrue(l.get(0) instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)l.get(0)).get("foo"), 10);
+    }
+
+    public void testArrayHasWrappedObject(final Object[] a) {
+        Assert.assertEquals(a.length, 1);
+        Assert.assertTrue(a[0] instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)a[0]).get("bar"), 11);
+    }
+
+    public void testMapHasWrappedObject(final Map<?, ?> m, final Object key) {
+        Assert.assertEquals(m.size(), 1);
+        Assert.assertTrue(key instanceof ScriptObjectMirror);
+        Assert.assertTrue(m.get(key) instanceof ScriptObjectMirror);
+        Assert.assertEquals(((ScriptObjectMirror)m.get(key)).get("bar"), 12);
+    }
+}
--- a/test/src/jdk/nashorn/test/models/NullProvider.java	Wed Nov 11 20:47:37 2015 -0800
+++ b/test/src/jdk/nashorn/test/models/NullProvider.java	Fri Nov 13 15:38:44 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it