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

SegmentAllocator:allocateFrom(ValueLayout, MemorySegment,ValueLayout,long,long) spec mismatch in exception scenario

XMLWordPrintable

        https://download.java.net/java/early_access/jdk22/docs/api/java.base/java/lang/foreign/SegmentAllocator.html#allocateFrom(java.lang.foreign.ValueLayout,java.lang.foreign.MemorySegment,java.lang.foreign.ValueLayout,long,long) mentioning - IndexOutOfBoundsException - if either sourceOffset or elementCount are < 0

        The actual behavior is IndexOutOfBoundsException - is thrown when sourceOffset<0, and IllegalArgumentException: 'Negative array size' is thrown when elementCount < 0

        The spec mismatch to the actual behavior

        Also, the `SegmentAllocator::allocateFrom` method with 5 parameters should IndexOutOfBoundsException if sourceOffset is negative.

              pminborg Per-Ake Minborg
              kganapureddy Krushnareddy Ganapureddy
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: