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

Print this page

        

*** 59,71 **** public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); /** * Length of the array data. Not necessarily length of the wrapped array. * This is private to ensure that no one in a subclass is able to touch the length ! * without going through {@link setLength}. This is used to implement * {@link LengthNotWritableFilter}s, ensuring that there are no ways past ! * a {@link setLength} function replaced by a nop */ private long length; /** * Method handle to throw an {@link UnwarrantedOptimismException} when getting an element --- 59,71 ---- public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); /** * Length of the array data. Not necessarily length of the wrapped array. * This is private to ensure that no one in a subclass is able to touch the length ! * without going through {@link #setLength}. This is used to implement * {@link LengthNotWritableFilter}s, ensuring that there are no ways past ! * a {@link #setLength} function replaced by a nop */ private long length; /** * Method handle to throw an {@link UnwarrantedOptimismException} when getting an element
*** 77,91 **** * Immutable empty array to get ScriptObjects started. * Use the same array and convert it to mutable as soon as it is modified */ private static class UntouchedArrayData extends ContinuousArrayData { private UntouchedArrayData() { ! this(0); ! } ! ! private UntouchedArrayData(final int length) { ! super(length); } private ArrayData toRealArrayData() { return toRealArrayData(0); } --- 77,87 ---- * Immutable empty array to get ScriptObjects started. * Use the same array and convert it to mutable as soon as it is modified */ private static class UntouchedArrayData extends ContinuousArrayData { private UntouchedArrayData() { ! super(0); } private ArrayData toRealArrayData() { return toRealArrayData(0); }
*** 98,108 **** return new DeletedRangeArrayFilter(newData, 0, index); } @Override public ContinuousArrayData copy() { ! return new UntouchedArrayData((int)length()); } @Override public Object asArrayOfType(final Class<?> componentType) { return Array.newInstance(componentType, 0); --- 94,105 ---- return new DeletedRangeArrayFilter(newData, 0, index); } @Override public ContinuousArrayData copy() { ! assert length() == 0; ! return this; } @Override public Object asArrayOfType(final Class<?> componentType) { return Array.newInstance(componentType, 0);
*** 244,254 **** @Override public Class<?> getBoxedElementType() { return Integer.class; } ! }; /** * Constructor * @param length Virtual length of the array. */ --- 241,251 ---- @Override public Class<?> getBoxedElementType() { return Integer.class; } ! } /** * Constructor * @param length Virtual length of the array. */