On Wed, 23 Oct 2024 08:58:30 GMT, Markus KARG <d...@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: > > - Fixed wording as proposed by Alan Bateman: 'The returned reader supports > the mark and reset ... could move up to become the second paragraph.' > - Fixed wording as proposed by Alan Bateman: 'make The reader is initially > .. the second sentence of the first paragraph rather than a new paragraph.' Thanks Markus! The java.io tests succeed with repeats and the only test failures in tier 1-3 were ones problem-listed by f7a61fce949ea2d15ec09d295c643d0c2eabea1e. FYI, besides Kevin's question, there was another concern about this API's interaction with BufferedReader (as you know, many Reader users wrap any Reader into a BufferedReader, especially you want to read all lines from a reader). We currently decide that we might explore line reading capability to Reader, but anyways that will not affect this patch. And I have consulted with Kevin in private; he thinks this minor confusion is fine. Sponsoring. ------------- PR Comment: https://git.openjdk.org/jdk/pull/21371#issuecomment-2435470372