Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8242477

(bf) MappedByteBuffer should clarify copying between overlapping mappings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • 15
    • 15
    • core-libs
    • generic
    • generic

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              bpb Brian Burkhalter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: