Merge
authorjlaskey
Thu, 23 May 2013 09:49:03 -0300
changeset 17768 048649aefa69
parent 17759 2eecf3628da2 (current diff)
parent 17767 3511ef0be4c9 (diff)
child 17769 14ea7feaf658
Merge
--- a/nashorn/.hgignore	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/.hgignore	Thu May 23 09:49:03 2013 -0300
@@ -24,3 +24,4 @@
 .idea/*
 test/lib/testng.jar
 test/script/external/*
+.project
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu May 23 09:49:03 2013 -0300
@@ -2295,7 +2295,7 @@
     @Override
     public boolean enterADD(final UnaryNode unaryNode) {
         load(unaryNode.rhs());
-        assert unaryNode.rhs().getType().isNumber();
+        assert unaryNode.rhs().getType().isNumber() : unaryNode.rhs().getType() + " "+ unaryNode.getSymbol();
         method.store(unaryNode.getSymbol());
 
         return false;
--- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java	Thu May 23 09:49:03 2013 -0300
@@ -800,7 +800,7 @@
 
         Node resultNode = node;
 
-        if (node instanceof LiteralNode && !to.isObject()) {
+        if (node instanceof LiteralNode && !(node instanceof ArrayLiteralNode) && !to.isObject()) {
             final LiteralNode<?> newNode = new LiteralNodeConstantEvaluator((LiteralNode<?>)node, to).eval();
             if (newNode != null) {
                 resultNode = newNode;
--- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java	Thu May 23 09:49:03 2013 -0300
@@ -34,6 +34,7 @@
 import jdk.nashorn.internal.ir.FunctionNode.CompilationState;
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
 import jdk.nashorn.internal.ir.Node;
 import jdk.nashorn.internal.ir.TernaryNode;
 import jdk.nashorn.internal.ir.UnaryNode;
@@ -141,6 +142,10 @@
                 return null;
             }
 
+            if (rhsNode instanceof ArrayLiteralNode) {
+                return null;
+            }
+
             final LiteralNode<?> rhs = (LiteralNode<?>)rhsNode;
             final boolean rhsInteger = rhs.getType().isInteger();
 
@@ -212,6 +217,10 @@
             final LiteralNode<?> lhs = (LiteralNode<?>)parent.lhs();
             final LiteralNode<?> rhs = (LiteralNode<?>)parent.rhs();
 
+            if (lhs instanceof ArrayLiteralNode || rhs instanceof ArrayLiteralNode) {
+                return null;
+            }
+
             final Type widest = Type.widest(lhs.getType(), rhs.getType());
 
             boolean isInteger = widest.isInteger();
@@ -279,9 +288,9 @@
             isLong    &= value != 0.0 && JSType.isRepresentableAsLong(value);
 
             if (isInteger) {
-                return LiteralNode.newInstance(token, finish, JSType.toInt32(value));
+                return LiteralNode.newInstance(token, finish, (int)value);
             } else if (isLong) {
-                return LiteralNode.newInstance(token, finish, JSType.toLong(value));
+                return LiteralNode.newInstance(token, finish, (long)value);
             }
 
             return LiteralNode.newInstance(token, finish, value);
--- a/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Thu May 23 09:49:03 2013 -0300
@@ -28,6 +28,7 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Getter;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -59,11 +60,6 @@
     }
 
     @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
-    public static Object BYTES_PER_ELEMENT(final Object self) {
-        return ((ArrayBufferView)self).bytesPerElement();
-    }
-
-    @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
     public static Object buffer(final Object self) {
         return ((ArrayDataImpl)((ArrayBufferView)self).getArray()).buffer;
     }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java	Thu May 23 09:49:03 2013 -0300
@@ -754,25 +754,11 @@
         final Object       obj                 = Global.toObject(self);
         final ScriptObject sobj                = (ScriptObject)obj;
         final long         len                 = JSType.toUint32(sobj.getLength());
-        final double       startNum            = JSType.toNumber(start);
-        final long         relativeStartUint32 = JSType.toUint32(startNum);
-        final long         relativeStart       = JSType.toInteger(startNum);
-
-        long k = relativeStart < 0 ?
-                Math.max(len + relativeStart, 0) :
-                Math.min(
-                    Math.max(relativeStartUint32, relativeStart),
-                    len);
+        final long         relativeStart       = JSType.toLong(start);
+        final long         relativeEnd         = (end == ScriptRuntime.UNDEFINED) ? len : JSType.toLong(end);
 
-        final double endNum = (end == ScriptRuntime.UNDEFINED)? Double.NaN : JSType.toNumber(end);
-        final long relativeEndUint32 = (end == ScriptRuntime.UNDEFINED)? len : JSType.toUint32(endNum);
-        final long relativeEnd       = (end == ScriptRuntime.UNDEFINED)? len : JSType.toInteger(endNum);
-
-        final long finale = relativeEnd < 0 ?
-                Math.max(len + relativeEnd, 0) :
-                Math.min(
-                    Math.max(relativeEndUint32, relativeEnd),
-                    len);
+        long k = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
+        final long finale = relativeEnd < 0 ? Math.max(len + relativeEnd, 0) : Math.min(relativeEnd, len);
 
         if (k >= finale) {
             return new NativeArray(0);
@@ -909,21 +895,10 @@
         final ScriptObject sobj                = (ScriptObject)obj;
         final boolean      strict              = Global.isStrict();
         final long         len                 = JSType.toUint32(sobj.getLength());
-        final double       startNum            = JSType.toNumber(start);
-        final long         relativeStartUint32 = JSType.toUint32(startNum);
-        final long         relativeStart       = JSType.toInteger(startNum);
+        final long         relativeStart       = JSType.toLong(start);
 
-        //TODO: workaround overflow of relativeStart for start > Integer.MAX_VALUE
-        final long actualStart = relativeStart < 0 ?
-            Math.max(len + relativeStart, 0) :
-            Math.min(
-                Math.max(relativeStartUint32, relativeStart),
-                len);
-
-        final long actualDeleteCount =
-            Math.min(
-                Math.max(JSType.toInteger(deleteCount), 0),
-                len - actualStart);
+        final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
+        final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);
 
         final NativeArray array = new NativeArray(actualDeleteCount);
 
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java	Thu May 23 09:49:03 2013 -0300
@@ -770,7 +770,7 @@
             nd.setTime(NaN);
             return nd.getTime();
         }
-        int yearInt = JSType.toInteger(yearNum);
+        int yearInt = (int)yearNum;
         if (0 <= yearInt && yearInt <= 99) {
             yearInt += 1900;
         }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -38,7 +40,9 @@
  */
 @ScriptClass("Float32Array")
 public final class NativeFloat32Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 4;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 4;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -38,7 +40,9 @@
  */
 @ScriptClass("Float64Array")
 public final class NativeFloat64Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 8;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 8;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -37,7 +39,9 @@
  */
 @ScriptClass("Int16Array")
 public final class NativeInt16Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 2;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 2;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -37,7 +39,9 @@
  */
 @ScriptClass("Int32Array")
 public final class NativeInt32Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 4;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 4;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -37,7 +39,9 @@
  */
 @ScriptClass("Int8Array")
 public final class NativeInt8Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 1;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 1;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Thu May 23 09:49:03 2013 -0300
@@ -30,6 +30,8 @@
 
 import java.lang.reflect.Array;
 import java.util.Collection;
+import java.util.Deque;
+import java.util.List;
 import jdk.internal.dynalink.beans.StaticClass;
 import jdk.internal.dynalink.support.TypeUtilities;
 import jdk.nashorn.internal.objects.annotations.Attribute;
@@ -37,6 +39,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ListAdapter;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
 
@@ -240,8 +243,8 @@
     }
 
     /**
-     * Given a script object and a Java type, converts the script object into the desired Java type. Currently it only
-     * performs shallow creation of Java arrays, but might be extended for other types in the future. Example:
+     * 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:
      * <pre>
      * var anArray = [1, "13", false]
      * var javaIntArray = Java.to(anArray, "int[]")
@@ -250,42 +253,46 @@
      * print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
      * </pre>
      * @param self not used
-     * @param objArray the script object. Can be null.
+     * @param obj the script object. Can be null.
      * @param objType either a {@link #type(Object, Object) type object} or a String describing the type of the Java
      * 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.
-     * type. Returns null if scriptObject is null.
+     * 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.
      * @throws ClassNotFoundException if the class described by objType is not found
      */
     @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
-    public static Object to(final Object self, final Object objArray, final Object objType) throws ClassNotFoundException {
-        if (objArray == null) {
+    public static Object to(final Object self, final Object obj, final Object objType) throws ClassNotFoundException {
+        if (obj == null) {
             return null;
         }
 
-        final Class<?> componentType;
+        Global.checkObject(obj);
+
+        final Class<?> targetClass;
         if(objType == UNDEFINED) {
-            componentType = Object.class;
+            targetClass = Object[].class;
         } else {
-            final StaticClass arrayType;
+            final StaticClass targetType;
             if(objType instanceof StaticClass) {
-                arrayType = (StaticClass)objType;
+                targetType = (StaticClass)objType;
             } else {
-                arrayType = type(objType);
+                targetType = type(objType);
             }
-            final Class<?> arrayClass = arrayType.getRepresentedClass();
-            if(!arrayClass.isArray()) {
-                throw typeError("to.expects.array.type", arrayClass.getName());
-            }
-            componentType = arrayClass.getComponentType();
+            targetClass = targetType.getRepresentedClass();
         }
 
-        Global.checkObject(objArray);
+        if(targetClass.isArray()) {
+            return ((ScriptObject)obj).getArray().asArrayOfType(targetClass.getComponentType());
+        }
 
-        return ((ScriptObject)objArray).getArray().asArrayOfType(componentType);
+        if(targetClass == List.class || targetClass == Deque.class) {
+            return new ListAdapter((ScriptObject)obj);
+        }
+
+        throw typeError("unsupported.java.to.type", targetClass.getName());
     }
 
     /**
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -37,7 +39,9 @@
  */
 @ScriptClass("Uint16Array")
 public final class NativeUint16Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 2;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 2;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -38,7 +40,9 @@
  */
 @ScriptClass("Uint32Array")
 public final class NativeUint32Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 4;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 4;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -37,7 +39,9 @@
  */
 @ScriptClass("Uint8Array")
 public final class NativeUint8Array extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 1;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 1;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Thu May 23 09:49:03 2013 -0300
@@ -28,7 +28,9 @@
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
+import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
+import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -38,7 +40,9 @@
  */
 @ScriptClass("Uint8ClampedArray")
 public final class NativeUint8ClampedArray extends ArrayBufferView {
-    private static final int BYTES_PER_ELEMENT = 1;
+    @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
+    public static final int BYTES_PER_ELEMENT = 1;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/nashorn/src/jdk/nashorn/internal/runtime/JSType.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/JSType.java	Thu May 23 09:49:03 2013 -0300
@@ -565,8 +565,11 @@
     }
 
     /**
-     * JavaScript compliant Object to integer conversion
-     * See ECMA 9.4 ToInteger
+     * JavaScript compliant Object to integer conversion. See ECMA 9.4 ToInteger
+     *
+     * <p>Note that this returns {@link java.lang.Integer#MAX_VALUE} or {@link java.lang.Integer#MIN_VALUE}
+     * for double values that exceed the int range, including positive and negative Infinity. It is the
+     * caller's responsibility to handle such values correctly.</p>
      *
      * @param obj  an object
      * @return an integer
@@ -576,8 +579,11 @@
     }
 
     /**
-     * JavaScript compliant Object to long conversion
-     * See ECMA 9.4 ToInteger
+     * JavaScript compliant Object to long conversion. See ECMA 9.4 ToInteger
+     *
+     * <p>Note that this returns {@link java.lang.Long#MAX_VALUE} or {@link java.lang.Long#MIN_VALUE}
+     * for double values that exceed the long range, including positive and negative Infinity. It is the
+     * caller's responsibility to handle such values correctly.</p>
      *
      * @param obj  an object
      * @return a long
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,337 @@
+package jdk.nashorn.internal.runtime;
+
+import java.util.AbstractList;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+import java.util.RandomAccess;
+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
+ * {@code length} and having conforming {@code push}, {@code pop}, {@code shift}, {@code unshift}, and {@code splice}
+ * methods) and expose it as both a Java list and double-ended queue. While script arrays aren't necessarily efficient
+ * as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts,
+ * and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a
+ * custom script object that implements an Array-like API can have a background data representation that is optimized
+ * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array,
+ * while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)}
+ * and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively,
+ * while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}.
+ */
+public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
+    // These add to the back and front of the list
+    private static final InvokeByName PUSH    = new InvokeByName("push",    ScriptObject.class, void.class, Object.class);
+    private static final InvokeByName UNSHIFT = new InvokeByName("unshift", ScriptObject.class, void.class, Object.class);
+
+    // These remove from the back and front of the list
+    private static final InvokeByName POP   = new InvokeByName("pop",   ScriptObject.class, Object.class);
+    private static final InvokeByName SHIFT = new InvokeByName("shift", ScriptObject.class, Object.class);
+
+    // These insert and remove in the middle of the list
+    private static final InvokeByName SPLICE_ADD    = new InvokeByName("splice", ScriptObject.class, void.class, int.class, int.class, Object.class);
+    private static final InvokeByName SPLICE_REMOVE = new InvokeByName("splice", ScriptObject.class, void.class, int.class, int.class);
+
+    private final ScriptObject obj;
+
+    /**
+     * Creates a new list wrapper for the specified script object.
+     * @param obj script the object to wrap
+     */
+    public ListAdapter(ScriptObject obj) {
+        this.obj = obj;
+    }
+
+    @Override
+    public int size() {
+        return JSType.toInt32(obj.getLength());
+    }
+
+    @Override
+    public Object get(int index) {
+        checkRange(index);
+        return obj.get(index);
+    }
+
+    @Override
+    public Object set(int index, Object element) {
+        checkRange(index);
+        final Object prevValue = get(index);
+        obj.set(index, element, false);
+        return prevValue;
+    }
+
+    private void checkRange(int index) {
+        if(index < 0 || index >= size()) {
+            throw invalidIndex(index);
+        }
+    }
+
+    @Override
+    public void push(Object e) {
+        addFirst(e);
+    }
+
+    @Override
+    public boolean add(Object e) {
+        addLast(e);
+        return true;
+    }
+
+    @Override
+    public void addFirst(Object e) {
+        try {
+            final Object fn = UNSHIFT.getGetter().invokeExact(obj);
+            checkFunction(fn, UNSHIFT);
+            UNSHIFT.getInvoker().invokeExact(fn, obj, e);
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    @Override
+    public void addLast(Object e) {
+        try {
+            final Object fn = PUSH.getGetter().invokeExact(obj);
+            checkFunction(fn, PUSH);
+            PUSH.getInvoker().invokeExact(fn, obj, e);
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    @Override
+    public void add(int index, Object e) {
+        try {
+            if(index < 0) {
+                throw invalidIndex(index);
+            } else if(index == 0) {
+                addFirst(e);
+            } else {
+                final int size = size();
+                if(index < size) {
+                    final Object fn = SPLICE_ADD.getGetter().invokeExact(obj);
+                    checkFunction(fn, SPLICE_ADD);
+                    SPLICE_ADD.getInvoker().invokeExact(fn, obj, index, 0, e);
+                } else if(index == size) {
+                    addLast(e);
+                } else {
+                    throw invalidIndex(index);
+                }
+            }
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+    private static void checkFunction(Object fn, InvokeByName invoke) {
+        if(!(fn instanceof ScriptFunction)) {
+            throw new UnsupportedOperationException("The script object doesn't have a function named " + invoke.getName());
+        }
+    }
+
+    private static IndexOutOfBoundsException invalidIndex(int index) {
+        return new IndexOutOfBoundsException(String.valueOf(index));
+    }
+
+    @Override
+    public boolean offer(Object e) {
+        return offerLast(e);
+    }
+
+    @Override
+    public boolean offerFirst(Object e) {
+        addFirst(e);
+        return true;
+    }
+
+    @Override
+    public boolean offerLast(Object e) {
+        addLast(e);
+        return true;
+    }
+
+    @Override
+    public Object pop() {
+        return removeFirst();
+    }
+
+    @Override
+    public Object remove() {
+        return removeFirst();
+    }
+
+    @Override
+    public Object removeFirst() {
+        checkNonEmpty();
+        return invokeShift();
+    }
+
+    @Override
+    public Object removeLast() {
+        checkNonEmpty();
+        return invokePop();
+    }
+
+    private void checkNonEmpty() {
+        if(isEmpty()) {
+            throw new NoSuchElementException();
+        }
+    }
+
+    @Override
+    public Object remove(int index) {
+        if(index < 0) {
+            throw invalidIndex(index);
+        } else if (index == 0) {
+            return invokeShift();
+        } else {
+            final int maxIndex = size() - 1;
+            if(index < maxIndex) {
+                final Object prevValue = get(index);
+                invokeSpliceRemove(index, 1);
+                return prevValue;
+            } else if(index == maxIndex) {
+                return invokePop();
+            } else {
+                throw invalidIndex(index);
+            }
+        }
+    }
+
+    private Object invokeShift() {
+        try {
+            final Object fn = SHIFT.getGetter().invokeExact(obj);
+            checkFunction(fn, SHIFT);
+            return SHIFT.getInvoker().invokeExact(fn, obj);
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private Object invokePop() {
+        try {
+            final Object fn = POP.getGetter().invokeExact(obj);
+            checkFunction(fn, POP);
+            return POP.getInvoker().invokeExact(fn, obj);
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    @Override
+    protected void removeRange(int fromIndex, int toIndex) {
+        invokeSpliceRemove(fromIndex, toIndex - fromIndex);
+    }
+
+    private void invokeSpliceRemove(int fromIndex, int count) {
+        try {
+            final Object fn = SPLICE_REMOVE.getGetter().invokeExact(obj);
+            checkFunction(fn, SPLICE_REMOVE);
+            SPLICE_REMOVE.getInvoker().invokeExact(fn, obj, fromIndex, count);
+        } catch(RuntimeException | Error ex) {
+            throw ex;
+        } catch(Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    @Override
+    public Object poll() {
+        return pollFirst();
+    }
+
+    @Override
+    public Object pollFirst() {
+        return isEmpty() ? null : invokeShift();
+    }
+
+    @Override
+    public Object pollLast() {
+        return isEmpty() ? null : invokePop();
+    }
+
+    @Override
+    public Object peek() {
+        return peekFirst();
+    }
+
+    @Override
+    public Object peekFirst() {
+        return isEmpty() ? null : get(0);
+    }
+
+    @Override
+    public Object peekLast() {
+        return isEmpty() ? null : get(size() - 1);
+    }
+
+    @Override
+    public Object element() {
+        return getFirst();
+    }
+
+    @Override
+    public Object getFirst() {
+        checkNonEmpty();
+        return get(0);
+    }
+
+    @Override
+    public Object getLast() {
+        checkNonEmpty();
+        return get(size() - 1);
+    }
+
+    @Override
+    public Iterator<Object> descendingIterator() {
+        final ListIterator<Object> it = listIterator(size());
+        return new Iterator<Object>() {
+            @Override
+            public boolean hasNext() {
+                return it.hasPrevious();
+            }
+
+            @Override
+            public Object next() {
+                return it.previous();
+            }
+
+            @Override
+            public void remove() {
+                it.remove();
+            }
+        };
+    }
+
+    @Override
+    public boolean removeFirstOccurrence(Object o) {
+        return removeOccurrence(o, iterator());
+    }
+
+    @Override
+    public boolean removeLastOccurrence(Object o) {
+        return removeOccurrence(o, descendingIterator());
+    }
+
+    private static boolean removeOccurrence(Object o, Iterator<Object> it) {
+        while(it.hasNext()) {
+            final Object e = it.next();
+            if(o == null ? e == null : o.equals(e)) {
+                it.remove();
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Thu May 23 09:49:03 2013 -0300
@@ -25,10 +25,16 @@
 
 package jdk.nashorn.internal.runtime;
 
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
 import jdk.internal.dynalink.CallSiteDescriptor;
 import jdk.internal.dynalink.beans.StaticClass;
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.internal.dynalink.support.Guards;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
+import jdk.nashorn.internal.lookup.MethodHandleFunctionality;
 import jdk.nashorn.internal.objects.NativeJava;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Function;
@@ -65,6 +71,10 @@
  * </pre>
  */
 public final class NativeJavaPackage extends ScriptObject {
+    private static final MethodHandleFunctionality MH = MethodHandleFactory.getFunctionality();
+    private static final MethodHandle CLASS_NOT_FOUND = findOwnMH("classNotFound", Void.TYPE, NativeJavaPackage.class);
+    private static final MethodHandle TYPE_GUARD = Guards.getClassGuard(NativeJavaPackage.class);
+
     /** Full name of package (includes path.) */
     private final String name;
 
@@ -123,6 +133,30 @@
         return super.getDefaultValue(hint);
     }
 
+    @Override
+    protected GuardedInvocation findNewMethod(CallSiteDescriptor desc) {
+        return createClassNotFoundInvocation(desc);
+    }
+
+    @Override
+    protected GuardedInvocation findCallMethod(CallSiteDescriptor desc, LinkRequest request) {
+        return createClassNotFoundInvocation(desc);
+    }
+
+    private static GuardedInvocation createClassNotFoundInvocation(final CallSiteDescriptor desc) {
+        // If NativeJavaPackage is invoked either as a constructor or as a function, throw a ClassNotFoundException as
+        // we can assume the user attempted to instantiate a non-existent class.
+        final MethodType type = desc.getMethodType();
+        return new GuardedInvocation(
+                MH.dropArguments(CLASS_NOT_FOUND, 1, type.parameterList().subList(1, type.parameterCount())),
+                type.parameterType(0) == NativeJavaPackage.class ? null : TYPE_GUARD);
+    }
+
+    @SuppressWarnings("unused")
+    private static void classNotFound(final NativeJavaPackage pkg) throws ClassNotFoundException {
+        throw new ClassNotFoundException(pkg.name);
+    }
+
     /**
      * "No such property" call placeholder.
      *
@@ -188,4 +222,7 @@
         return noSuchProperty(desc, request);
     }
 
+    private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
+        return MH.findStatic(MethodHandles.lookup(), NativeJavaPackage.class, name, MH.type(rtype, types));
+    }
 }
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Thu May 23 09:49:03 2013 -0300
@@ -186,7 +186,7 @@
      * @param out output print writer
      * @param err error print writer
      */
-    ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) {
+    public ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) {
         this.out = out;
         this.err = err;
         this.namespace = new Namespace();
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Thu May 23 09:49:03 2013 -0300
@@ -46,7 +46,7 @@
 public final class ScriptingFunctions {
 
     /** Handle to implementation of {@link ScriptingFunctions#readLine} - Nashorn extension */
-    public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class);
+    public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class, Object.class);
 
     /** Handle to implementation of {@link ScriptingFunctions#readFully} - Nashorn extension */
     public static final MethodHandle READFULLY = findOwnMH("readFully",     Object.class, Object.class, Object.class);
@@ -78,13 +78,17 @@
      * Nashorn extension: global.readLine (scripting-mode-only)
      * Read one line of input from the standard input.
      *
-     * @param self self reference
+     * @param self   self reference
+     * @param prompt String used as input prompt
      *
      * @return line that was read
      *
      * @throws IOException if an exception occurs
      */
-    public static Object readLine(final Object self) throws IOException {
+    public static Object readLine(final Object self, final Object prompt) throws IOException {
+        if (prompt != UNDEFINED) {
+            System.out.print(JSType.toString(prompt));
+        }
         final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
         return reader.readLine();
     }
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java	Thu May 23 09:49:03 2013 -0300
@@ -40,7 +40,7 @@
  *     private static final InvokeByName TO_JSON = new InvokeByName("toJSON", Object.class, Object.class, Object.class);
  *     ...
  *     final Object toJSONFn = TO_JSON.getGetter().invokeExact(obj);
- *     value = TO_JSON.getInvoker().invokeExact(toJSON, obj, key);
+ *     value = TO_JSON.getInvoker().invokeExact(toJSONFn, obj, key);
  * </pre>
  * In practice, you can have stronger type assumptions if it makes sense for your code, just remember that you must use
  * the same parameter types as the formal types of the arguments for {@code invokeExact} to work:
@@ -50,7 +50,7 @@
  *     final ScriptObject sobj = (ScriptObject)obj;
  *     final Object toJSONFn = TO_JSON.getGetter().invokeExact(sobj);
  *     if(toJSONFn instanceof ScriptFunction) {
- *         value = TO_JSON.getInvoker().invokeExact(toJSON, sobj, key);
+ *         value = TO_JSON.getInvoker().invokeExact(toJSONFn, sobj, key);
  *     }
  * </pre>
  * Note that in general you will not want to reuse a single instance of this class for implementing more than one call
@@ -59,6 +59,7 @@
  * separate instance of this class for every place.
  */
 public class InvokeByName {
+    private final String name;
     private final MethodHandle getter;
     private final MethodHandle invoker;
 
@@ -81,6 +82,7 @@
      * @param ptypes the parameter types of the function.
      */
     public InvokeByName(final String name, final Class<?> targetClass, final Class<?> rtype, final Class<?>... ptypes) {
+        this.name = name;
         getter  = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getItem:" + name, Object.class, targetClass);
 
         final Class<?>[] finalPtypes;
@@ -97,6 +99,14 @@
     }
 
     /**
+     * Returns the name of the function retrieved through this invoker.
+     * @return the name of the function retrieved through this invoker.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
      * Returns the property getter that can be invoked on an object to retrieve the function object that will be
      * subsequently invoked by the invoker returned by {@link #getInvoker()}.
      * @return the property getter method handle for the function.
--- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu May 23 09:49:03 2013 -0300
@@ -125,7 +125,7 @@
 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.env.not.object=$ENV must be an Object.
-type.error.to.expects.array.type=Java.to() expects an array target type. {0} is not an array type.
+type.error.unsupported.java.to.type=Unsupported Java.to target type {0}.
 range.error.inappropriate.array.length=inappropriate array length: {0}
 range.error.invalid.fraction.digits=fractionDigits argument to {0} must be in [0, 20]
 range.error.invalid.precision=precision argument toPrecision() must be in [1, 21]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8010804.js	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8010804: Review long and integer usage conventions
+ *
+ * @test
+ * @run
+ */
+
+var x = [];
+print(x.length);
+x[4294967294] = 1;
+print(x.length);
+x[4294967295] = 1;
+print(x.length);
+print(x.slice(4294967293).length);
+print(x.slice(4294967294).length);
+print(x.slice(4294967295).length);
+print(x.slice(4294967296).length);
+
+print(x.slice(-4294967293).length);
+print(x.slice(-4294967294).length);
+print(x.slice(-4294967295).length);
+print(x.slice(-4294967296).length);
+
+print(x.slice(0, 4294967293).length);
+print(x.slice(0, 4294967294).length);
+print(x.slice(0, 4294967295).length);
+print(x.slice(0, 4294967296).length);
+
+print(x.slice(0, -4294967293).length);
+print(x.slice(0, -4294967294).length);
+print(x.slice(0, -4294967295).length);
+print(x.slice(0, -4294967296).length);
+
+print(x.slice(9223371036854775807).length);
+print(x.slice(9223372036854775807).length);
+print(x.slice(9223373036854775807).length);
+print(x.slice(9223374036854775807).length);
+
+print(x.slice(-9223371036854775807).length);
+print(x.slice(-9223372036854775807).length);
+print(x.slice(-9223373036854775807).length);
+print(x.slice(-9223374036854775807).length);
+
+print(x.slice(-9223371036854775807, 1).length);
+print(x.slice(-9223372036854775807, 1).length);
+print(x.slice(-9223373036854775807, 1).length);
+print(x.slice(-9223374036854775807, 1).length);
+
+print(x.slice(-9223371036854775807, -1).length);
+print(x.slice(-9223372036854775807, -1).length);
+print(x.slice(-9223373036854775807, -1).length);
+print(x.slice(-9223374036854775807, -1).length);
+
+print(x.slice(Infinity).length);
+print(x.slice(Infinity, Infinity).length);
+print(x.slice(Infinity, -Infinity).length);
+print(x.slice(-Infinity).length);
+print(x.slice(-Infinity, Infinity).length);
+print(x.slice(-Infinity, -Infinity).length);
+
+var d = new Date();
+d.setYear(Infinity);
+print(d);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8010804.js.EXPECTED	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,42 @@
+0
+4294967295
+4294967295
+2
+1
+0
+0
+4294967293
+4294967294
+4294967295
+4294967295
+4294967293
+4294967294
+4294967295
+4294967295
+2
+1
+0
+0
+0
+0
+0
+0
+4294967295
+4294967295
+4294967295
+4294967295
+1
+1
+1
+1
+4294967294
+4294967294
+4294967294
+4294967294
+0
+0
+0
+4294967295
+4294967295
+0
+Invalid Date
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8012083.js	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8012093 - array literals can only be subject to constant evaluation under very special
+ * circumstances.
+ *
+ * @test
+ * @run
+ */
+
+
+var w00t = 17;
+print(+[w00t]);
+
+var empty = [];
+print(empty == false);
+
+print([] == false);
+print([] === false);
+print(!![]);
+
+print(~[]);
+print(![]);
+print(![17]);
+print(![17,1,2]);
+
+var one = 1;
+var two = 2;
+var a1 = [one];
+var a2 = [two];
+print(+a1 + +a2); //3
+
+var x = 1;
+print(+["apa"]);
+print(+[]);  //0
+print(+[1]); //1
+print(+[x]); //1
+print(+[1,2,3]); //NaN
+var a = [];
+var b = [1];
+print(a/b);
+print(++[[]][+[]]+[+[]]); //10
+print(+[] == 0);
+
+var first = [![]+[]][+[]][+[]]+[![]+[]][+[]][+!+[]]+[!+[]+[]][+![]][+![]]+[![]+[]][+[]][+!+[]]+[![]+[]][+[]][+!+[]+!+[]];
+var second =(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]];
+
+print(first + " " + second);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8012083.js.EXPECTED	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,19 @@
+17
+true
+true
+false
+true
+-1
+false
+false
+false
+3
+NaN
+0
+1
+1
+NaN
+0
+10
+true
+fatal fail
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8014735.js	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8014735: Typed Array, BYTES_PER_ELEMENT should be a class property
+ *
+ * @test
+ * @run
+ */
+
+function bytesPerElement(func) {
+    print(func.name + ".BYTES_PER_ELEMENT = " + func.BYTES_PER_ELEMENT);
+}
+
+bytesPerElement(Int8Array);
+bytesPerElement(Int16Array);
+bytesPerElement(Int32Array);
+bytesPerElement(Uint8Array);
+bytesPerElement(Uint8ClampedArray);
+bytesPerElement(Uint16Array);
+bytesPerElement(Uint32Array);
+bytesPerElement(Float32Array);
+bytesPerElement(Float64Array);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8014735.js.EXPECTED	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,9 @@
+Int8Array.BYTES_PER_ELEMENT = 1
+Int16Array.BYTES_PER_ELEMENT = 2
+Int32Array.BYTES_PER_ELEMENT = 4
+Uint8Array.BYTES_PER_ELEMENT = 1
+Uint8ClampedArray.BYTES_PER_ELEMENT = 1
+Uint16Array.BYTES_PER_ELEMENT = 2
+Uint32Array.BYTES_PER_ELEMENT = 4
+Float32Array.BYTES_PER_ELEMENT = 4
+Float64Array.BYTES_PER_ELEMENT = 8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8014953.js	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8014953: Have NativeJavaPackage throw a ClassNotFoundException when invoked with "new"
+ *
+ * @test
+ * @run
+ */
+ 
+try {
+    new java.util.ArrrayList(16)
+} catch(e) {
+   print("Invoked as constructor");
+   print("e.class=" + e.class)
+   print("e.message=" + e.message);
+}
+
+try {
+    java.util.ArrrayList(16)
+} catch(e) {
+   print("Invoked as method");
+   print("e.class=" + e.class)
+   print("e.message=" + e.message);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8014953.js.EXPECTED	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,6 @@
+Invoked as constructor
+e.class=class java.lang.ClassNotFoundException
+e.message=java.util.ArrrayList
+Invoked as method
+e.class=class java.lang.ClassNotFoundException
+e.message=java.util.ArrrayList
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8015267.js	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8015267: have a List/Deque adapter for JS array-like objects
+ *
+ * @test
+ * @run
+ */
+ 
+var a = ['a', 'b', 'c', 'd']
+
+var l = Java.to(a, java.util.List)
+print(l instanceof java.util.List)
+print(l instanceof java.util.Deque)
+
+print(l[0])
+print(l[1])
+print(l[2])
+print(l[3])
+
+print(l.size())
+
+l.push('x')
+print(a)
+
+l.addLast('y')
+print(a)
+
+print(l.pop())
+print(l.removeLast())
+print(a)
+
+l.add('e')
+l.add(5, 'f')
+print(a)
+
+l.add(0, 'z')
+print(a)
+
+l.add(2, 'x')
+print(a)
+
+l[7] = 'g'
+print(a)
+
+try { l.add(15, '') } catch(e) { print(e.class) } 
+try { l.remove(15) } catch(e) { print(e.class) } 
+try { l.add(-1, '') } catch(e) { print(e.class) } 
+try { l.remove(-1) } catch(e) { print(e.class) } 
+
+l.remove(7)
+l.remove(2)
+l.remove(0)
+print(a)
+
+print(l.peek())
+print(l.peekFirst())
+print(l.peekLast())
+
+print(l.element())
+print(l.getFirst())
+print(l.getLast())
+
+l.offer('1')
+l.offerFirst('2')
+l.offerLast('3')
+print(a)
+
+a = ['1', '2', 'x', '3', '4', 'x', '5', '6', 'x', '7', '8']
+print(a)
+var l = Java.to(a, java.util.List)
+l.removeFirstOccurrence('x')
+print(a)
+l.removeLastOccurrence('x')
+print(a)
+
+var empty = Java.to([], java.util.List)
+try { empty.pop() } catch(e) { print(e.class) }
+try { empty.removeFirst() } catch(e) { print(e.class) }
+try { empty.removeLast() } catch(e) { print(e.class) }
+
+try { empty.element() } catch(e) { print(e.class) }
+try { empty.getFirst() } catch(e) { print(e.class) }
+try { empty.getLast() } catch(e) { print(e.class) }
+
+print(empty.peek())
+print(empty.peekFirst())
+print(empty.peekLast())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8015267.js.EXPECTED	Thu May 23 09:49:03 2013 -0300
@@ -0,0 +1,40 @@
+true
+true
+a
+b
+c
+d
+4
+x,a,b,c,d
+x,a,b,c,d,y
+x
+y
+a,b,c,d
+a,b,c,d,e,f
+z,a,b,c,d,e,f
+z,a,x,b,c,d,e,f
+z,a,x,b,c,d,e,g
+class java.lang.IndexOutOfBoundsException
+class java.lang.IndexOutOfBoundsException
+class java.lang.IndexOutOfBoundsException
+class java.lang.IndexOutOfBoundsException
+a,b,c,d,e
+a
+a
+e
+a
+a
+e
+2,a,b,c,d,e,1,3
+1,2,x,3,4,x,5,6,x,7,8
+1,2,3,4,x,5,6,x,7,8
+1,2,3,4,x,5,6,7,8
+class java.util.NoSuchElementException
+class java.util.NoSuchElementException
+class java.util.NoSuchElementException
+class java.util.NoSuchElementException
+class java.util.NoSuchElementException
+class java.util.NoSuchElementException
+null
+null
+null
--- a/nashorn/test/script/basic/NASHORN-377.js	Wed May 22 09:59:15 2013 -0700
+++ b/nashorn/test/script/basic/NASHORN-377.js	Thu May 23 09:49:03 2013 -0300
@@ -43,7 +43,7 @@
 function arrstr(a, n, w) {
   var s = "";
   if (typeof n == "undefined") n = a.length;
-  if (typeof w == "undefined") w = a.BYTES_PER_ELEMENT * 2;
+  if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2;
   for (var i = 0; i < n; i++) {
     s += tohex(a[i], w);
   }
@@ -96,7 +96,7 @@
   var b = new ArrayBuffer(8);
   for (var i in types) {
     var x = new types[i](b);
-    print(x.byteOffset, x.byteLength, x.length, x.BYTES_PER_ELEMENT);
+    print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT);
     assertTrue(function(){ return x.constructor === types[i] });
   }
 })();