RFR: 8364007: Add overload without arguments to codePointCount in String etc.

Tatsunori Uchino duke at openjdk.org
Thu Jul 24 14:59:31 UTC 2025


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?

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

Commit messages:
 - Remove trailing spaces
 - 8364007: Add overload without arguments to codePointCount in String etc.

Changes: https://git.openjdk.org/jdk/pull/26461/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26461&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8364007
  Stats: 112 lines in 13 files changed: 95 ins; 0 del; 17 mod
  Patch: https://git.openjdk.org/jdk/pull/26461.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26461/head:pull/26461

PR: https://git.openjdk.org/jdk/pull/26461


More information about the core-libs-dev mailing list