On Thu, 31 Oct 2024 07:10:29 GMT, Per Minborg <pminb...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java >> line 541: >> >>> 539: >>> 540: @ForceInline >>> 541: private static AbstractMemorySegmentImpl arrayFreeSegment(Buffer >>> b, long offset, long length) { >> >> the names `arrayFreeSegment` and `arrayBackedSegments` seem a bit confusing. >> I'd suggest `ofDirectBuffer` and `ofHeapBuffer` > > I called them that initially but there is a subtle difference; there are heap > buffers that are not backed by an array. The name arrayFreeSegment could > better be arrayLessSegment. Not sure I follow. The code asks if there's a backing array (accessing base). Then: * if there is a base, it calls `arrayBackedSegment` * otherwise it calls `arrayLessSegment`. Now, `arrayBackedSegment` is only implemented for heap buffers. Direct buffers throws UOE. And, inside `arrayLessSegment` we throw if we see a non-direct (=heap) buffer. So... it seems to me that arrayBacked = heap and arrayLess = direct? Do you refer to char buffers backed by Strings? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21764#discussion_r1824221715