RFR: 8311906: Improve robustness of String constructors with mutable array inputs [v4]

Raffaello Giulietti rgiulietti at openjdk.org
Thu Nov 16 08:56:49 UTC 2023


On Wed, 15 Nov 2023 15:25:21 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Update PPC implementation of string_compress to return the index of the non-latin1 char
>>   Patch supplied by TheRealMDoerr
>
> test/jdk/java/lang/String/StringRacyConstructor.java line 300:
> 
>> 298:      */
>> 299:     public static String racyStringConstructionCodepoints(String original) throws ConcurrentModificationException {
>> 300:         if (original.chars().max().orElseThrow() > 256) {
> 
> Suggestion:
> 
>         if (original.chars().max().getAsInt() >= 256) {

The correct comparison is `>=`, as codepoint 256 is not Latin1.

> test/jdk/java/lang/String/StringRacyConstructor.java line 347:
> 
>> 345:      */
>> 346:     public static String racyStringConstructionCodepointsSurrogates(String original) throws ConcurrentModificationException {
>> 347:         if (original.chars().max().orElseThrow() > 256) {
> 
> Suggestion:
> 
>         if (original.chars().max().getAsInt() >= 256) {

Same as above

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16425#discussion_r1395326065
PR Review Comment: https://git.openjdk.org/jdk/pull/16425#discussion_r1395326394


More information about the core-libs-dev mailing list