RFR: 8366421: ModifiedUtf.utfLen may overflow for giant string [v2]

Chen Liang liach at openjdk.org
Thu Sep 18 15:40:57 UTC 2025


On Thu, 18 Sep 2025 15:31:50 GMT, Chen Liang <liach at openjdk.org> wrote:

>> 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 34:
> 
>> 32: import jdk.internal.util.ModifiedUtf;
>> 33: 
>> 34: public class TestUtfLen {
> 
> Please rename this to `ModifiedUtfTest`, convert to junit, and turn this into one case for overflow of `utfLen`, like `testUtfLenOverflow`, to align with other tests in the same directory.
> 
> Core libraries usually use JUnit tests instead of main tests like runtime unless there are sensitive stuff that need flagless or would be perturbed by JUnit or other framework initialization.

Correction: this test will allocate a 2GB string, so we might still have this test itself as a main and focus on `utfLen` overflow alone, and add something like `@requires os.maxMemory >= 4g`

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

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


More information about the core-libs-dev mailing list