RFR: 8369564: Provide a MemorySegment API to read strings with known lengths [v13]
Liam Miller-Cushon
cushon at openjdk.org
Tue Nov 25 19:10:28 UTC 2025
On Tue, 25 Nov 2025 14:00:58 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Liam Miller-Cushon has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Update discussion of truncated reads of strings containing \0
>> - Return the number of copied bytes
>
> src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 2669:
>
>> 2667: * @throws IllegalArgumentException if {@code dst} is {@linkplain #isReadOnly() read-only}
>> 2668: * @throws IndexOutOfBoundsException if {@code dstOffset > dstSegment.byteSize() - B} where {@code B} is the size,
>> 2669: * in bytes, of the string encoded using the given charset.
>
> Nit pick: this says "the size... of the string... encoded..."... which string? It might suggest we're talking about `src`, but in reality we're talking about a *substring* of `src`
Thanks, rephrased as "substring of {@code src}"
> test/micro/org/openjdk/bench/java/lang/foreign/FromJavaStringTest.java line 71:
>
>> 69:
>> 70: @Benchmark
>> 71: public void panama_setString() {
>
> I'd suggest to maybe avoid "panama" here and in the other benchmark. Maybe:
> * segment_setString
> * segment_copyStringRaw
> * segment_copyStringBytes
Done
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2561037226
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2561086681
More information about the core-libs-dev
mailing list