-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
minimal
-
-
Java API
Summary
Change so that out-of-bounds invocations of MethodHandles.byteArrayViewVarHandle
throw ArrayIndexOutOfBoundsException
rather than the more generic IndexOutOfBoundsException
.
Problem
Code doing array operations in a way such that using MethodHandles.byteArrayViewVarHandle
would be a good fit will currently have to accept that the specific AIOOBE
thrown natively on out-of-bounds errors on arrays is replaced by the more generic IOOBE
. This might be a challenge for picking up such VarHandles
due creating a subtle behavioral mismatch, and adapting the code to throw the specific and more naturally fitting AIOOBE
would ease migration.
Solution
Change the implementation internally so that AIOOBE
is thrown when accessing an out-of-bounds index of a byte array via a MethodHandles.byteArrayViewVarHandle
.
Specification
The specification of MethodHandles.byteArrayViewVarHandle
is updated to specify that ArrayIndexOutOfBoundsException
will be thrown:
* <p>
* Access of bytes at a given index will result in an
* {@code ArrayIndexOutOfBoundsException} if the index is less than {@code 0}
* or greater than the {@code byte[]} array length minus the size (in bytes)
* of {@code T}.
* <p>
- csr of
-
JDK-8259911 byteArrayViewVarHandle should throw ArrayIndexOutOfBoundsException
-
- Resolved
-