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

MemorySegment::asByteBuffer does not respect spatial bounds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 16, 17
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
      None
    • Resolved In Build:
      b32

      Backports

        Description

        The Javadoc of MemorySegment::asByteBuffer says:

        " The returned buffer's position (see Buffer.position() is initially set to zero, while the returned buffer's capacity and limit (see Buffer.capacity() and Buffer.limit(), respectively) are set to this segment' size (see byteSize()). For this reason, a byte buffer cannot be returned if this segment' size is greater than Integer.MAX_VALUE. "

        That said, while this contract is respected by native segment, it does not hold for heap segments, where the resulting buffer has always the size of the underlying array.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                mcimadamore Maurizio Cimadamore
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: