The following methods:
- ByteBuffer::alignedSlice
- ByteBuffer::alignmentOffset
Make too many promises about the alignment of the underlying heap memory.
The VM only guarantees that the elements of a Java array are aligned to their natural alignment. e.g for byte[] that is 1 byte (i.e. no alignment at all, really).
However, these methods promise that accesses will be aligned for certain offsets, even though there is no hard guarantee for that.
alignedSlice depends directly on alignmentOffset, and the latter purports to be able to guarantee alignment when accessing heap memory.
The implementation currently tries to compute an alignment offset for heap buffers when the access size (unitSize) is > 1, which can not be guaranteed to be correct.
- ByteBuffer::alignedSlice
- ByteBuffer::alignmentOffset
Make too many promises about the alignment of the underlying heap memory.
The VM only guarantees that the elements of a Java array are aligned to their natural alignment. e.g for byte[] that is 1 byte (i.e. no alignment at all, really).
However, these methods promise that accesses will be aligned for certain offsets, even though there is no hard guarantee for that.
alignedSlice depends directly on alignmentOffset, and the latter purports to be able to guarantee alignment when accessing heap memory.
The implementation currently tries to compute an alignment offset for heap buffers when the access size (unitSize) is > 1, which can not be guaranteed to be correct.
- duplicates
-
JDK-8318966 Some methods make promises about Java array element alignment that are too strong
- Resolved
- relates to
-
JDK-8314882 Relax alignment of array elements
- Closed