On Wed, 19 Nov 2025 14:43:09 GMT, Maurizio Cimadamore <[email protected]>
wrote:
>> Liam Miller-Cushon has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Add a dstOffset parameter, stop using
>> StringCharBuffer/CharsetEncoder::encode
>
> src/java.base/share/classes/java/lang/String.java line 2030:
>
>> 2028: }
>> 2029:
>> 2030: void copyToSegmentRaw(MemorySegment segment, long offset, int
>> srcIndex, int numChars) {
>
> This method takes an index, expressed in chars, and uses that as a byte
> offset in a bulk copy operation. I don't think this is correct. E.g. if the
> string is UTF16 (and not LATIN1), there is a scaling factor to be applied?
In other words, it seems to me that here we have hardwired the knowledge that
we can only get here is the string is latin1. I don't think this was the
original intent of this method -- however, if that's the case, we should also
add an assertion to avoid misuse.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2542337230