RFR: 8345120: A likely bug in StringSupport::chunkedStrlenShort [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Dec 2 14:28:37 UTC 2024


On Mon, 2 Dec 2024 10:14:54 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 128:
>> 
>>> 126:      */
>>> 127:     @ForceInline
>>> 128:     public static int strlenByte(final AbstractMemorySegmentImpl segment,
>> 
>> Note: clients of this method seems to always pass `segment.byteSize()` for `toOffset`. What is the value of passing it as an explicit parameter instead of having `byteSize()` being called inside the method?
>
> As this is an internal API, I tried to keep it as similar as possible to the other bulk operations. But as you say, the value used here for the last parameter is always `segment.byteSize()`. We could easily change it. What's your preference here?

If the method works correctly on all end offsets (even when the offset is different from the segment size), then I'm ok leaving it as is. I'm mostly trying to make sure that endOffset = size is not an hidden invariant we depend on.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22451#discussion_r1865946650


More information about the core-libs-dev mailing list