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

Check for buffer backed by shared segment kicks in in unexpected places

    XMLWordPrintable

Details

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

    Backports

      Description

        The following test fails:


        @Test
        public void readOnlyByteBufferFromSharedNativeSegment() {
           try (MemorySegment segment = MemorySegment.allocateNative(8).share()) {
             var byteBuffer = segment.asByteBuffer();
             // This fails for native segments, but passes for heap segments.
             // Throws UOE: ByteBuffer derived from shared segments not supported
             byteBuffer.asReadOnlyBuffer();
           }
        }

        The problem is that some of the slice constructor are using the internal DirectBuffer::address method, which is where the check for shared buffer takes place.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: