RFR: 8343110: Add getChars(int, int, char[], int) to CharSequence and CharBuffer [v9]

Markus KARG duke at openjdk.org
Wed Apr 30 15:37:08 UTC 2025


On Wed, 30 Apr 2025 15:33:37 GMT, Markus KARG <duke at openjdk.org> wrote:

>> This Pull Request proposes an implementation for [JDK-8343110](https://bugs.openjdk.org/browse/JDK-8343110): Adding the new method `public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` to the `CharSequence` interface, providing a **bulk-read** facility including a default implementation iterating over `charAt(int)`.
>> 
>> In addition, this Pull Request proposes to replace the implementation of `Reader.of(CharSequence).read(char[] cbuf, int off, int len)` to invoke `CharSequence.getChars(next, next + n, cbuf, off)` instead of utilizing pattern matching for switch. Also, this PR proposes to implement `CharBuffer.getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` as an alias for `CharBuffer.get(srcBegin, dst, dstBegin, srcEnd - srcBegin)`.
>> 
>> To ensure quality...
>> * ...the method signature and JavaDocs are adapted from `AbstractStringBuilder.getChars(...)`.
>> * ...this PR relies upon the existing tests for `Reader.of(CharSequence)`, as these provide sufficient coverage of all changes introduced by this PR.
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Applied changes proposed by Joe and Jaikiran: Using @inheritDoc to get JavaDocs without @since.

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

> 1737: 
> 1738:     /**
> 1739:      * {@inheritDoc CharSequence}

@jaikiran @jddarcy Sorry for bothering, but I do need your kind help here to get the code to exactly that shape that you want to have it. While `{@inheritDoc CharSequence}` does work very well for `StringBuilder` and `StringBuffer` (via `AbstractStringBuilder` to shorten code size), it simply doesn't have *any* effect when applied at `String`: `make docs` successfully finishes without warnings or errors, but `String.html` still contains just the link to `CharSequence` but *is missing* the copy of the JavaDoc main text. I simply do not see why. Any ideas? 🤔

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21730#discussion_r2068936532


More information about the core-libs-dev mailing list