RFR: 8259911: byteArrayViewVarHandle should throw ArrayIndexOutOfBoundsException

Mandy Chung mchung at openjdk.java.net
Tue Jan 19 21:31:53 UTC 2021

On Tue, 19 Jan 2021 20:59:24 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> I agree the change is allowable within the current spec. The behavior change is observable, though, and however unlikely there might be code that relies on exact class of the exception being thrown.
> So while perhaps not strictly needed, the spec change makes sense coming from the other way: If I have some array-based code then that will be throwing AIOOBE on OOBs. But the `byteArrayViewVarHandle` code is specified to throw IOOBE, so a developer picking it up would have to catch and rewrap exceptions or accept the compatibility risk. Harmonizing to specify AIOOBE improves the migration story.

I don't think there is any migration story.   The exception type is an improved clarity.   The spec change is very minor and I'm okay with or without the spec change. 

> Case in point is #1855 which require changes to some tests that are expecting AIOOBE.

Yes, that's what I was about to ask too.


PR: https://git.openjdk.java.net/jdk/pull/2124

More information about the core-libs-dev mailing list