-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
None
-
b07
To ease portability, array view VarHandles could be adapted to throw AIOOBE rather than IOOBE:
VarHandle VH = MethodHandles.byteArrayViewVarHandle(int[].class,
ByteOrder.LITTLE_ENDIAN);
byte[] bytes = new byte[16];
VH.get(bytes, 15);
Current:
// Exception java.lang.IndexOutOfBoundsException: Index 15 out of bounds for length 13
Expected:
// Exception java.lang.ArrayIndexOutOfBoundsException: Index 15 out of bounds for length 13
Code changes are straightforward: Pass Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new) to Preconditions.checkIndex in ArrayHandle::index(byte[] ba, int index) in src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
VarHandle VH = MethodHandles.byteArrayViewVarHandle(int[].class,
ByteOrder.LITTLE_ENDIAN);
byte[] bytes = new byte[16];
VH.get(bytes, 15);
Current:
// Exception java.lang.IndexOutOfBoundsException: Index 15 out of bounds for length 13
Expected:
// Exception java.lang.ArrayIndexOutOfBoundsException: Index 15 out of bounds for length 13
Code changes are straightforward: Pass Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new) to Preconditions.checkIndex in ArrayHandle::index(byte[] ba, int index) in src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
- csr for
-
JDK-8259912 byteArrayViewVarHandle should throw ArrayIndexOutOfBoundsException
-
- Closed
-