< prev index next >

src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java

Print this page
rev 1361 : 8079145: jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion
Reviewed-by: jlaskey, hannesw

@@ -118,15 +118,15 @@
         return darray;
     }
 
     @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);
     }
 

@@ -169,11 +169,12 @@
         return this;
     }
 
     @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);
         }
 
< prev index next >