RFR: 8364007: Add no-argument codePointCount method to CharSequence and String [v7]

Chen Liang liach at openjdk.org
Wed Jan 28 20:19:40 UTC 2026


On Tue, 27 Jan 2026 11:33:21 GMT, Tatsunori Uchino <duke at openjdk.org> wrote:

>> Adds `codePointCount()` overloads to `String`, `Character`, `(Abstract)StringBuilder`, and `StringBuffer` to make it possible to conveniently retrieve the length of a string as code points without extra boundary checks.
>> 
>> 
>> if (superTremendouslyLongExpressionYieldingAString().codePointCount() > limit) {
>>     throw new Exception("exceeding length");
>> }
>> 
>> 
>> Is a CSR required to this change?
>
> Tatsunori Uchino has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Replace "unpaired surrogates" with "isolated surrogate code units"
>   
>   https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G1654
>   https://www.unicode.org/charts/PDF/UDC00.pdf

I think we can remove `Character.codePointCount(char[])`: users can use `CharBuffer.wrap(char[]).codePointCount()` instead.

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

PR Comment: https://git.openjdk.org/jdk/pull/26461#issuecomment-3813712436


More information about the core-libs-dev mailing list