On Sat, 26 Jul 2025 10:10:40 GMT, Tatsunori Uchino <[email protected]> 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 four
> additional commits since the last revision:
>
> - Update `@bug` in correct file
> - Add default implementation on codePointCount in CharSequence
> - Update `@bug` entries in test class doc comments
> - Discard changes on code whose form is not `str.codePointCount(0,
> str.length())`
> Character.codePointCount(CharSequence)
> CharSequence.codePointCount
I think that the problem is which of both should be _canonical_ (the other is
just a call for the canonical one).
public class Character {
public static int codePointCount(CharSequence s) {
return s.codePointCount();
}
}
I expect that an inline expansion is applied there.
> Do we need codePointCount(int start, int end) in CharSequence too?
IMO it is fine either way. It is OK to postpone/defer it.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26461#issuecomment-3368632586