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

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

    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 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

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

                  Dates

                  Created:
                  Updated:
                  Resolved: