jdk
jdk copied to clipboard
8341566: Add Reader.of(CharSequence)
This Pull Requests proposes an implementation for 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 ofReader.of()
, then stripped synchronized from it on the left hand, but kept just a synchronized wrapper on the right hand. Then added aswitch
for optimizations within the original code, at the exact location where previously just an optimization forString
lived in. - ...added tests for all methods (
Of.java
), and applied that test upon the modifiedStringBuilder
.
Wherever new JavaDocs were added, existing phrases from other code locations have been copied and adapted, to best match the same wording.
Progress
- [x] Change must not contain extraneous whitespace
- [x] Commit message must refer to an issue
- [x] Change requires CSR request JDK-8341596 to be approved
- [x] Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)
Issues
- JDK-8341566: Add Reader.of(CharSequence) (Enhancement - P4)
- JDK-8341596: Add Reader.of(CharSequence) (CSR)
Reviewers
- Roger Riggs (@RogerRiggs - Reviewer)
- Jaikiran Pai (@jaikiran - Reviewer)
- Chen Liang (@liach - Reviewer)
- Alan Bateman (@AlanBateman - Reviewer)
Reviewing
Using git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21371/head:pull/21371
$ git checkout pull/21371
Update a local copy of the PR:
$ git checkout pull/21371
$ git pull https://git.openjdk.org/jdk.git pull/21371/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21371
View PR using the GUI difftool:
$ git pr show -t 21371
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21371.diff