RFR: 8369564: Provide a MemorySegment API to read strings with known lengths [v11]

Jorn Vernee jvernee at openjdk.org
Fri Nov 21 15:46:38 UTC 2025


On Fri, 21 Nov 2025 14:39:59 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 2649:
>> 
>>> 2647:      * @param dstEncoding the charset used to {@linkplain Charset#newEncoder() encode}
>>> 2648:      *                 the string bytes.
>>> 2649:      * @param srcIndex the starting index of the source string
>> 
>> Do we feel like saying words like "index" is good enough to say what we mean? E.g. by index we mean something that is compatible with `length` and `charAt`. I wonder if using a qualifier e.g. `character index` might help? (open to suggestions here, I'm not 100% sure)
>
> Thanks, I think 'character index' is probably better than just index, since there are both character and byte positions in this API. The docs for numChars also mentions characters. I don't have a better idea for avoiding confusion here.

I thought this would be clear enough since it's talking about an index of a string, where 'index' has a pretty well understood meaning.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2550188629


More information about the core-libs-dev mailing list