RFR: 8366421: ModifiedUtf.utfLen may overflow for giant string

Chen Liang liach at openjdk.org
Wed Sep 17 13:58:23 UTC 2025


On Mon, 15 Sep 2025 07:32:13 GMT, Guanqiang Han <ghan at openjdk.org> 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

Do you think we should use `> 65535L` or `ExactConversionsSupport.isLongToCharExact`?

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

PR Comment: https://git.openjdk.org/jdk/pull/27285#issuecomment-3303123698


More information about the core-libs-dev mailing list