RFR: 8341566: Add Reader.of(CharSequence) [v7]

Chen Liang liach at openjdk.org
Wed Oct 9 18:09:03 UTC 2024


On Wed, 9 Oct 2024 11:49:47 GMT, Markus KARG <duke at openjdk.org> wrote:

>> This Pull Requests proposes an implementation for [JDK-8341566](https://bugs.openjdk.org/browse/JDK-8341566): Adding the new method `public static Reader Reader.of(CharSequence)` will return an anonymous, non-synchronized implementation of a `Reader` for each kind of `CharSequence` implementation. It is optimized for `String`, `StringBuilder`, `StringBuffer` and `CharBuffer`.
>> 
>> In addition, this Pull Request proposes to replace the implementation of `StringReader` to become a simple synchronized wrapper around `Reader.of(CharSequence)` for the case of `String` sources. To ensure correctness, this PR...
>> * ...simply moved the **original code** of `StringBuilder` to become the de-facto implementation of `Reader.of()`, then stripped synchronized from it on the left hand, but kept just a synchronized wrapper on the right hand. Then added a `switch` for optimizations within the original code, at the exact location where previously just an optimization for `String` lived in.
>> * ...added tests for all methods (`Of.java`), and applied that test upon the modified `StringBuilder`.
>> 
>> Wherever new JavaDocs were added, existing phrases from other code locations have been copied and adapted, to best match the same wording.
>
> Markus KARG has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - assertThrows instead of expectedExceptions
>  - ordered jtreg tags according recommendation in https://openjdk.org/jtreg/tag-spec.html#ORDER

Wiki pages such as https://wiki.openjdk.org/display/csr/Fields+of+a+CSR+Request are good starting points for CSRs.

CSR review will look at CSRs listed at https://bugs.openjdk.org/secure/Dashboard.jspa?selectPageId=17313. To finalize a CSR for review, you should set your fix version; I fixed that when I marked myself as a reviewer on the CSR.

Also note that the CSR lead might be unavailable the next few days, so the review will wait for a bit. Meanwhile, it's good for other experienced reviewers like Alan to review the CSR too.

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

PR Comment: https://git.openjdk.org/jdk/pull/21371#issuecomment-2402963472


More information about the core-libs-dev mailing list