RFR: 8318966: Some methods make promises about Java array element alignment that are too strong
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Nov 16 19:23:51 UTC 2023
On Thu, 16 Nov 2023 19:15:25 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> But... surely if I'm just accessing bytes the access cannot possibly be mis-aligned?
>
> Right. I think there is a difference between 'unaligned' and 'misaligned'. Unaligned means there is no effort made to align the access (so it _may_ be misaligned). Misaligned means _definitely not_ aligned. At least, that is my interpretation.
>
> This is what I wrote in the latest version:
>
>
> * For heap byte buffers, access is always unaligned. As a result, only the plain
> * {@linkplain VarHandle.AccessMode#GET get}
> * and {@linkplain VarHandle.AccessMode#SET set} access modes are supported by the
> * returned var handle. For all other access modes, an {@link IllegalStateException}
> * will be thrown.
Uhm, I think my assumption was wrong - the `byte`/`boolean` carrier is not supported by this method, so there's no case where heap access would be guaranteed to be aligned.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16681#discussion_r1396221179
More information about the nio-dev
mailing list