On Thu, 18 Sep 2025 12:49:50 GMT, Guanqiang Han <[email protected]> wrote:

>> Please review this patch.
>> 
>> **Description:**
>> 
>> Currently, ModifiedUtf.utfLen returns a signed int. For very large strings, 
>> this may overflow and produce negative values, leading to incorrect behavior 
>> in code that relies on the UTF length. This patch changes the return type to 
>> long, which fully resolves the issue and allows safe handling of giant 
>> strings.
>> 
>> **Test:**
>> 
>> GHA
>
> Guanqiang Han has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains three additional 
> commits since the last revision:
> 
>  - add regression test
>  - Merge remote-tracking branch 'upstream/master' into 8366421
>  - Change return type of utfLen to long to prevent overflow

test/jdk/jdk/internal/util/TestUtfLen.java line 54:

> 52:         if (total != expected) {
> 53:             throw new RuntimeException("Expected total=" + expected + " 
> but got " + total);
> 54:         }

This misses the point of testing utfLen; it is always testing the same string 
testing only the inner path through the code.
The PR changes the callers of utfLen and they should be tested, not just the 
internal function.
The test really does need to create the large string and pass it to the APIs 
that have been changed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27285#discussion_r2359593518

Reply via email to