RFR: 8364007: Add no-argument codePointCount method to CharSequence and String [v7]
Tatsunori Uchino
duke at openjdk.org
Tue Jan 27 13:58:31 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
Do we need to remove or preserve `Character.codePointCount(char[])`? I think it's inconsistent to have codePointCount(char[]) and codePointCount(CharSequence, int, int) but not codePointCount(CharSequence). We may need to update the CSR.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26461#issuecomment-3805342031
More information about the core-libs-dev
mailing list