RFR: 8361842: Move input validation checks to Java for String-related intrinsics [v8]

Raffaello Giulietti rgiulietti at openjdk.org
Thu Jul 17 14:16:53 UTC 2025


On Thu, 10 Jul 2025 12:18:25 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Replace casting with `as_Region()` in `generate_string_range_check`
>
> src/java.base/share/classes/java/lang/StringCoding.java line 140:
> 
>> 138:      *
>> 139:      * @param sa the source byte array containing characters encoded in UTF-16
>> 140:      * @param sp the index of the <em>byte (not character!)</em> from the source array to start reading from
> 
> Note the `byte (not character!)` emphasis here and below.

I think this is incorrect.
This is the index of a character (two bytes).
As it is used in `encodeISOArray0()`, it is incremented by 1 and passed to `StringUTF16.getChar()`, where it is multiplied by 2 to obtain the real `byte[]` index.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25998#discussion_r2213466146


More information about the graal-dev mailing list