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

MemorySegment::asByteBuffer does not respect spatial bounds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 16
    • 16, 17
    • core-libs
    • None
    • b32

        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.

              mcimadamore Maurizio Cimadamore
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: