RFR: 8367129: Move input validation checks to Java for java.lang.StringLatin1 intrinsics [v2]

Volkan Yazici vyazici at openjdk.org
Thu Feb 12 16:15:08 UTC 2026


On Tue, 10 Feb 2026 17:10:53 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Apply review feedback
>
> src/hotspot/share/classfile/vmIntrinsics.hpp line 363:
> 
>> 361:                                                                                                                         \
>> 362:   do_intrinsic(_compressStringC,          java_lang_StringUTF16,  compressS_name, encodeISOArray_signature,      F_S)   \
>> 363:    do_name(     compressS_name,                                  "compress0")                                           \
> 
> _compressS_name doesn't seem to follow the naming pattern.

Renamed to `compressString_name` in 068eb3589a3.

> Is there a HotSpot specific namespace qualifier that can make it easier to cross reference this?

@RogerRiggs, not that I know of. I also considered following alternatives:

- `library_call.cpp:inline_string_equals`
- `vmIntrinsics::_compressStringB`

But none really qualifies as a programmatic reference and settled on `inline_string_equals`, the most convenient phrase to do find-and-jump.

@dafedafe, @TobiHartmann, do you have any suggestions/preferences?

> src/java.base/share/classes/java/lang/StringLatin1.java line 207:
> 
>> 205: 
>> 206:     /**
>> 207:      * Lexicographically compares a Latin-1 string sub-range to a UTF-16
> 
> It would be more specific to say it compares a "prefix" since the start is always 0.

Applied your suggestion in 068eb3589a3.

> src/java.base/share/classes/java/lang/StringUTF16.java line 398:
> 
>> 396: 
>> 397:     /**
>> 398:      * Exhaustively copies Latin-1 characters from a {@code char} array
> 
> The word Exhaustively does not fit here because it stops copying for > 0xff.
> Perhaps:   "Copies the prefix of Latin-1 characters".

Applied your suggestion in 068eb3589a3.

> src/java.base/share/classes/java/lang/StringUTF16.java line 457:
> 
>> 455:         Objects.requireNonNull(src);
>> 456:         checkBoundsOffCount(srcOff, len, src);
>> 457:         String.checkBoundsOffCount(dstOff, len, dst.length);    // Implicit null check on `dst`
> 
> This bouncing around between source files for methods of the same name `checkBoundsOffCout` is bound to confuse the reader.
> Be consistent, either now or later, use the local one in this file or remove the utility method.

Removed `StringUTF16::checkBoundsOffCout`, and replaced its usages with `String.checkBoundsOffCout(..., StringUTF16.length(...))` in 068eb3589a3.

> src/java.base/share/classes/java/lang/StringUTF16.java line 603:
> 
>> 601: 
>> 602:     /**
>> 603:      * Lexicographically compares a UTF-16 string sub-range to a Latin-1 one as
> 
> It isn't a full sub-range, the start index is 0, use prefix instead.

Applied your suggestion in 068eb3589a3.

> src/java.base/share/classes/java/lang/StringUTF16.java line 950:
> 
>> 948:     }
>> 949: 
>> 950: 
> 
> Extra blank line.

Removed it in 068eb3589a3.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799746361
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799751943
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799754004
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799756674
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799758583
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799759597
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799760520


More information about the core-libs-dev mailing list