<i18n dev> RFR: 8364007: Add no-argument codePointCount method to CharSequence and String [v23]

Alan Bateman alanb at openjdk.org
Tue Feb 3 12:04:40 UTC 2026


On Sun, 1 Feb 2026 12:55:29 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 two additional commits since the last revision:
> 
>  - Add comment
>  - Fix logic error

src/java.base/share/classes/java/lang/String.java line 1886:

> 1884:      * @since 27
> 1885:      */
> 1886:     public int codePointCount() {

Are you planning to override the API docs here to say that it returns the number of Unicode code points in this String? That would get the API docs consistent with the existing 3-arg codePointCount and avoid referencing the String as a character sequence in the String docs.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26461#discussion_r2758723775


More information about the i18n-dev mailing list