ByteBuffer views, alignment, word tearing

Andrew Haley aph at
Mon Jul 11 16:34:28 UTC 2016

On 11/07/16 17:04, Paul Sandoz wrote:

> I opted to directly use Unsafe rather than defer. I am not sure it’s
> always possible to defer to the underlying buffer since its
> positional and order state is mutable.

Eww.  The view has its own position, and the byte ordering is fixed
when the view is created.  The wrapped byte buffer is in a protected
field, and the view is a package-private class so it can't be
subclassed by the user.  So I would have thought that could be made to
work, but but never mind, I can see you've gone a long way down this
road already.

The SPARC regression is very odd: I would have thought that if it's
broken here it would also be broken in HeapByteBuffer.getLong().


More information about the core-libs-dev mailing list