Merge
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java
index 774a0be..491af86 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java
@@ -231,7 +231,7 @@
             if (symbol != null) {
                 if (hasArguments() && symbol.isParam()) {
                     symbol.setFieldIndex(paramCount++);
-                } else {
+                } else if (!isValidArrayIndex(getArrayIndex(tuple.key))) {
                     symbol.setFieldIndex(fieldCount++);
                 }
             }
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
index 03a2c9a..eb7fd63 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
@@ -439,8 +439,8 @@
 
     // current ScriptContext to use - can be null.
     private ScriptContext scontext;
-    // associated Property object for "context" property.
-    private jdk.nashorn.internal.runtime.Property scontextProperty;
+    // current ScriptEngine associated - can be null.
+    private ScriptEngine engine;
 
     /**
      * Set the current script context
@@ -448,7 +448,6 @@
      */
     public void setScriptContext(final ScriptContext scontext) {
         this.scontext = scontext;
-        scontextProperty.setValue(this, this, scontext, false);
     }
 
     // global constants for this global - they can be replaced with MethodHandle.constant until invalidated
@@ -581,6 +580,7 @@
             return;
         }
 
+        this.engine = engine;
         init(engine);
     }
 
@@ -917,6 +917,13 @@
             }
         }
 
+        switch (nameStr) {
+            case "context":
+                return sctxt;
+            case "engine":
+                return global.engine;
+        }
+
         if (self == UNDEFINED) {
             // scope access and so throw ReferenceError
             throw referenceError(global, "not.defined", nameStr);
@@ -1789,9 +1796,6 @@
         }
 
         if (engine != null) {
-            final int NOT_ENUMERABLE_NOT_CONFIG = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE;
-            scontextProperty = addOwnProperty("context", NOT_ENUMERABLE_NOT_CONFIG, null);
-            addOwnProperty("engine", NOT_ENUMERABLE_NOT_CONFIG, engine);
             // default file name
             addOwnProperty(ScriptEngine.FILENAME, Attribute.NOT_ENUMERABLE, null);
             // __noSuchProperty__ hook for ScriptContext search of missing variables
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
index 6f47c3f..3162e18 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java
@@ -54,6 +54,7 @@
 import static jdk.nashorn.internal.parser.TokenType.TERNARY;
 import static jdk.nashorn.internal.parser.TokenType.WHILE;
 
+import java.io.Serializable;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -2977,11 +2978,13 @@
      * Encapsulates part of the state of the parser, enough to reconstruct the state of both parser and lexer
      * for resuming parsing after skipping a function body.
      */
-    private static class ParserState {
+    private static class ParserState implements Serializable {
         private final int position;
         private final int line;
         private final int linePosition;
 
+        private static final long serialVersionUID = -2382565130754093694L;
+
         ParserState(final int position, final int line, final int linePosition) {
             this.position = position;
             this.line = line;
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java
index e030354..44b3c3b 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java
@@ -119,7 +119,7 @@
      *   produce different boun method handles wrapping the same access mechanism
      *   depending on callsite
      */
-    private MethodHandle[] GETTER_CACHE = new MethodHandle[NOOF_TYPES];
+    private transient MethodHandle[] GETTER_CACHE = new MethodHandle[NOOF_TYPES];
 
     /**
      * Create a new accessor property. Factory method used by nasgen generated code.
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java
index c83c453..1f9f145 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java
@@ -101,7 +101,7 @@
     private final int slot;
 
     /** SwitchPoint that is invalidated when property is changed, optional */
-    protected SwitchPoint changeCallback;
+    protected transient SwitchPoint changeCallback;
 
     private static final long serialVersionUID = 2099814273074501176L;
 
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
index 0246b53..d8e7608 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
@@ -568,9 +568,7 @@
         for (final Property property : otherProperties) {
             // This method is only safe to use with non-slotted, native getter/setter properties
             assert property.getSlot() == -1;
-            if (isValidArrayIndex(getArrayIndex(property.getKey()))) {
-                newMap.setContainsArrayKeys();
-            }
+            assert !(isValidArrayIndex(getArrayIndex(property.getKey())));
         }
 
         return newMap;
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java
index e6b8b90..f802e03 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java
@@ -125,6 +125,15 @@
 
         @Override
         public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
+            if (sourceType == ConsString.class) {
+                if (String.class == targetType1 || CharSequence.class == targetType1) {
+                    return Comparison.TYPE_1_BETTER;
+                }
+
+                if (String.class == targetType2 || CharSequence.class == targetType2) {
+                    return Comparison.TYPE_2_BETTER;
+                }
+            }
             return linkerServices.compareConversion(sourceType, targetType1, targetType2);
         }
     }
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java
index f859f7b..4ed6e3a 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java
@@ -131,11 +131,16 @@
             }
             return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc);
         case "setProp":
-        case "setElem":
+        case "setElem": {
+            final boolean strict = NashornCallSiteDescriptor.isStrict(desc);
+            if (strict) {
+                throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self));
+            }
             if (desc.getOperand() != null) {
                 return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc);
             }
             return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc);
+        }
         default:
             break;
         }
diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties
index 16b4e05..056dc87 100644
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties
@@ -92,7 +92,7 @@
 
 # other wrong usages of property
 type.error.property.has.no.setter=Cannot set property "{0}" of {1} that has only a getter
-type.error.cant.set.proto.to.non.object=Cannot set Object {0}'s __proto__ to be a non-object like {1}
+type.error.cant.set.proto.to.non.object=Cannot set Object {0}''s __proto__ to be a non-object like {1}
 type.error.no.such.function={1} has no such function "{0}"
 type.error.no.such.java.class=No such Java class: {0}
 type.error.no.such.java.constructor=No such Java constructor: {0}
@@ -125,10 +125,10 @@
 type.error.cant.load.script=Cannot load script from {0}
 type.error.JSON.stringify.cyclic=JSON.stringify got a cyclic data structure
 type.error.cant.convert.string.to.char=Cannot convert string to character; its length must be exactly 1
-type.error.cant.convert.number.to.char=Cannot convert number to character; it's out of 0-65535 range
+type.error.cant.convert.number.to.char=Cannot convert number to character; it is out of 0-65535 range
 type.error.cant.convert.to.java.string=Cannot convert object of type {0} to a Java argument of string type
 type.error.cant.convert.to.java.number=Cannot convert object of type {0} to a Java argument of number type
-type.error.cant.convert.to.javascript.array=Can only convert Java arrays and lists to JavaScript arrays. Can't convert object of type {0}.
+type.error.cant.convert.to.javascript.array=Can only convert Java arrays and lists to JavaScript arrays. Cannot convert object of type {0}.
 type.error.extend.expects.at.least.one.argument=Java.extend needs at least one argument.
 type.error.extend.expects.at.least.one.type.argument=Java.extend needs at least one type argument.
 type.error.extend.expects.java.types=Java.extend needs Java types as its arguments.
@@ -141,10 +141,10 @@
 type.error.extend.ERROR_FINAL_FINALIZER=Can not extend class because {0} has a final finalize method.
 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.method.not.constructor=Java method {0} can't be used as a constructor.
+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}.
-type.error.constructor.requires.new=Constructor {0} requires 'new'.
+type.error.constructor.requires.new=Constructor {0} requires "new".
 type.error.new.on.nonpublic.javatype=new cannot be used with non-public java type {0}.
 
 range.error.dataview.constructor.offset=Wrong offset or length in DataView constructor
diff --git a/test/script/basic/JDK-8043232.js b/test/script/basic/JDK-8043232.js
index fa46b41..d1f3d85 100644
--- a/test/script/basic/JDK-8043232.js
+++ b/test/script/basic/JDK-8043232.js
@@ -29,14 +29,14 @@
  */
 
 // call explicit constructor
-print(new (java.awt["Color(int,int,int)"])(255,0,255));
+print(new (java.lang["String(char[],int,int)"])(['a','b', 'c', 'd'], 1, 3));
 // print the constructor itself
-print(java.awt["Color(int,int,int)"]);
+print(java.lang["String(char[],int,int)"]);
 
 // store constructor to call later
-var Color = java.awt["Color(int,int,int)"];
+var Color = java.lang["String(char[],int,int)"];
 // call stored constructor
-print(new Color(33, 233, 2))
+print(new Color(['r','r', 'e', 'd'], 1, 3))
 
 // check if default constructor works
 var obj = new (java.lang["Object()"])();
diff --git a/test/script/basic/JDK-8043232.js.EXPECTED b/test/script/basic/JDK-8043232.js.EXPECTED
index 5fcfab8..0ff18b4 100644
--- a/test/script/basic/JDK-8043232.js.EXPECTED
+++ b/test/script/basic/JDK-8043232.js.EXPECTED
@@ -1,14 +1,14 @@
-java.awt.Color[r=255,g=0,b=255]
-[jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)]
-java.awt.Color[r=33,g=233,b=2]
+bcd
+[jdk.internal.dynalink.beans.SimpleDynamicMethod String java.lang.String.java.lang.String(char[],int,int)]
+red
 TypeError: No such Java class: java.lang.NonExistent
 TypeError: No such Java constructor: Object(String)
 TypeError: Java constructor signature invalid: Object()xxxxx
 TypeError: Java constructor signature invalid: Object(
 TypeError: Java constructor signature invalid: Object)
-TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.lang.System.getProperty] cant be used as a constructor.
-TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.io.PrintStream.println] cant be used as a constructor.
-TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires new.
+TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.lang.System.getProperty] cannot be used as a constructor.
+TypeError: Java method [jdk.internal.dynalink.beans.OverloadedDynamicMethod java.io.PrintStream.println] cannot be used as a constructor.
+TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod String java.lang.String.java.lang.String(char[],int,int)] requires "new".
 TypeError: No such Java constructor: Runnable()
 TypeError: No such Java constructor: Runnable(int)
 java.lang.InstantiationException: java.io.InputStream
diff --git a/test/script/basic/JDK-8049086.js b/test/script/basic/JDK-8049086.js
index da4a962..7dd7ac4 100644
--- a/test/script/basic/JDK-8049086.js
+++ b/test/script/basic/JDK-8049086.js
@@ -58,7 +58,7 @@
 // (a) Java methods (b) Java classes (as these respond to new)
 // (c) FunctionalInterface objects (d) JSObjects that are 'functions'
 
-print("java.awt.Color is java function? " + Java.isJavaFunction(java.awt.Color));
+print("java.lang.String is java function? " + Java.isJavaFunction(java.lang.String));
 print("java.lang.Runnable instance is java function? "
     + Java.isJavaFunction(new java.lang.Runnable(function() {})));
 print("eval is java function? " + Java.isJavaFunction(eval));
diff --git a/test/script/basic/JDK-8049086.js.EXPECTED b/test/script/basic/JDK-8049086.js.EXPECTED
index d67db5d..e868572 100644
--- a/test/script/basic/JDK-8049086.js.EXPECTED
+++ b/test/script/basic/JDK-8049086.js.EXPECTED
@@ -13,7 +13,7 @@
 Object is script object? true
 {} is script object? true
 /foo/ is script object? true
-java.awt.Color is java function? true
+java.lang.String is java function? true
 java.lang.Runnable instance is java function? true
 eval is java function? false
 println is java function? true
diff --git a/test/script/basic/JDK-8049242.js b/test/script/basic/JDK-8049242.js
index 3e803b3..c44e330 100644
--- a/test/script/basic/JDK-8049242.js
+++ b/test/script/basic/JDK-8049242.js
@@ -29,14 +29,14 @@
  */
 
 // call explicit constructor
-print(new (Java.type("java.awt.Color")["(int,int,int)"])(255,0,255));
+print(new (Java.type("java.lang.String")["(char[],int,int)"])(['a', 'b', 'c'],0, 3));
 // print the constructor itself
-print(Java.type("java.awt.Color")["(int,int,int)"]);
+print(Java.type("java.lang.String")["(char[],int,int)"]);
 
 // store constructor to call later
-var Color = Java.type("java.awt.Color")["(int,int,int)"];
+var Color = Java.type("java.lang.String")["(char[],int,int)"];
 // call stored constructor
-print(new Color(33, 233, 2))
+print(new Color(['j', 'a', 'v', 'a'], 1, 3))
 
 // check if default constructor works
 var obj = new (Java.type("java.lang.Object")["()"])();
diff --git a/test/script/basic/JDK-8049242.js.EXPECTED b/test/script/basic/JDK-8049242.js.EXPECTED
index 4aa4627..a5dc016 100644
--- a/test/script/basic/JDK-8049242.js.EXPECTED
+++ b/test/script/basic/JDK-8049242.js.EXPECTED
@@ -1,10 +1,10 @@
-java.awt.Color[r=255,g=0,b=255]
-[jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)]
-java.awt.Color[r=33,g=233,b=2]
+abc
+[jdk.internal.dynalink.beans.SimpleDynamicMethod String java.lang.String.java.lang.String(char[],int,int)]
+ava
 TypeError: null is not a function
 TypeError: null is not a function
 TypeError: null is not a function
-TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod Color java.awt.Color.java.awt.Color(int,int,int)] requires new.
+TypeError: Constructor [jdk.internal.dynalink.beans.SimpleDynamicMethod String java.lang.String.java.lang.String(char[],int,int)] requires "new".
 TypeError: null is not a function
 TypeError: null is not a function
 java.lang.InstantiationException: java.io.InputStream
diff --git a/test/script/basic/JDK-8056978.js b/test/script/basic/JDK-8056978.js
new file mode 100644
index 0000000..1b3577d
--- /dev/null
+++ b/test/script/basic/JDK-8056978.js
@@ -0,0 +1,46 @@
+/*
+ * 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-8056978: ClassCastException: cannot cast jdk.nashorn.internal.scripts.JO*
+ *
+ * @test
+ * @run
+ */
+
+var obj1 = {
+    'name': 'test name',
+    '1': '1',
+    '2': '2',
+    '3': '3',
+    '4': '4',
+    '5': '5'
+};
+
+var obj2 = {
+    'name': 'hello'
+};
+
+print(obj2['name']);
+print(obj2.name);
+
diff --git a/test/script/basic/JDK-8056978.js.EXPECTED b/test/script/basic/JDK-8056978.js.EXPECTED
new file mode 100644
index 0000000..317e967
--- /dev/null
+++ b/test/script/basic/JDK-8056978.js.EXPECTED
@@ -0,0 +1,2 @@
+hello
+hello
diff --git a/test/script/basic/JDK-8058422.js b/test/script/basic/JDK-8058422.js
new file mode 100644
index 0000000..b15c7cf
--- /dev/null
+++ b/test/script/basic/JDK-8058422.js
@@ -0,0 +1,55 @@
+/*
+ * 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-8058422: Users should be able to overwrite "context" and "engine" variables
+ *
+ * @test
+ * @run
+ */
+
+var m = new javax.script.ScriptEngineManager();
+var e = m.getEngineByName("nashorn");
+e.put("foo", "hello");
+var obj = e.eval("context.getAttribute('foo')");
+if (obj != "hello") {
+    fail("Expected 'obj' to be 'hello'");
+}
+
+e.put("context", "bar");
+if (e.eval("context") != "bar") {
+    fail("Expected 'context' to be 'bar'");
+}
+
+if (e.eval("foo") != "hello") {
+    fail("Expected 'foo' to be 'hello'");
+}
+
+if (e.eval("engine") != e) {
+    fail("'engine' is not evaluaed to current engine");
+}
+
+e.put("engine", "foobar");
+if (e.eval("engine") != "foobar") {
+    fail("'engine' is not evalued to 'foobar'");
+}
diff --git a/test/script/basic/JDK-8058545.js b/test/script/basic/JDK-8058545.js
new file mode 100644
index 0000000..3b3a7c6
--- /dev/null
+++ b/test/script/basic/JDK-8058545.js
@@ -0,0 +1,41 @@
+/*
+ * 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-8058545: With strict mode, bean property assignment of a non-existent property should result in TypeError
+ *
+ * @test
+ * @run
+ */
+
+'use strict';
+var File = Java.type("java.io.File");
+var f = new File(".");
+try {
+    f.foo = 33;
+    fail("Should have thrown TypeError");
+} catch (e) {
+    if (! (e instanceof TypeError)) {
+        fail("Expected TypeError, got " + e);
+    }
+}
diff --git a/test/script/basic/JDK-8058615.js b/test/script/basic/JDK-8058615.js
new file mode 100644
index 0000000..354b5e4
--- /dev/null
+++ b/test/script/basic/JDK-8058615.js
@@ -0,0 +1,36 @@
+/*
+ * 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-8058615: Overload resolution ambiguity involving ConsString
+ *
+ * @test
+ * @run
+ */
+
+var strw = new java.io.StringWriter();
+var bufw = new java.io.BufferedWriter(strw);
+var s = "hello ";
+bufw.write(s + "world");
+bufw.close();
+print(strw.toString());
diff --git a/test/script/basic/JDK-8058615.js.EXPECTED b/test/script/basic/JDK-8058615.js.EXPECTED
new file mode 100644
index 0000000..3b18e51
--- /dev/null
+++ b/test/script/basic/JDK-8058615.js.EXPECTED
@@ -0,0 +1 @@
+hello world
diff --git a/test/src/jdk/nashorn/api/scripting/ScopeTest.java b/test/src/jdk/nashorn/api/scripting/ScopeTest.java
index 865c97d..3e2a6b6 100644
--- a/test/src/jdk/nashorn/api/scripting/ScopeTest.java
+++ b/test/src/jdk/nashorn/api/scripting/ScopeTest.java
@@ -582,6 +582,60 @@
         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 {