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

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

XMLWordPrintable

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

        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.

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

                Created:
                Updated:
                Resolved: