RFR: 8318966: Some methods make promises about Java array element alignment that are too strong

Chen Liang liach at openjdk.org
Tue Jan 23 20:35:29 UTC 2024


On Tue, 23 Jan 2024 18:24:59 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Should we make these unaligned access modes throw ISE like before, when the given index is unaligned?
>
> You mean `get` and `set`? They should never throw, as unaligned access is fine. For other access modes, we can never guarantee that an access is aligned, so UOE is appropriate. (IIRC this is mandated by existing spec. I'll try to find it again)
> 
> P.S. See e.g. the javadoc of `VarHandle::getVolatile`:
> 
>>     @throws UnsupportedOperationException if the access mode is unsupported for this VarHandle.
> 
> P.P.S. Also remembering that we can not have any implementation for the access methods, in order for `isAccessModeSupported` to work correctly. And the logic that handles unsupported methods throws UOE (see `VarForm::getMemberName`)

Good point, so previous behavior of throwing ISE is out of spec

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16681#discussion_r1463958704


More information about the core-libs-dev mailing list