If two MappedByteBuffers are created by mapping overlapping ranges of the same file, then copying between these buffers may yield unexpected results. For example, in the attached class MappedOverlapCopy, the middle half of a file is mapped to one buffer which then puts its contents into another buffer which is mapped from the second half of the file. The third and fourth quarters of the file then end up each being equal to the second quarter of the original file contents. This is different for example from the behavior of System.arraycopy() which for overlapping contents behaves as if the source data were first copied into a separate, temporary location and then copied to the destination location. If such behavior were to obtain for MappedByteBuffer, then the result of the example would be that the upper half of the file contents would end up being equal to the middle half of the original file contents. The documentation of MappedByteBuffer should be updated to clarify that the outcome of such overlapped copying is unspecified.
- csr for
-
JDK-8242500 (bf) MappedByteBuffer should clarify copying between overlapping mappings
- Closed
- relates to
-
JDK-8245121 (bf) XBuffer.put(Xbuffer src) can give unexpected result when storage overlaps
- Resolved
-
JDK-8246282 [REDO] JDK-8245121 (bf) XBuffer.put(Xbuffer src) can give unexpected result when storage overlaps
- Resolved
-
JDK-8242253 Clarify bulk of addresses backed by same storage
- Resolved
- links to