On Tue, 25 Aug 2026 17:46:19 GMT, Markus KARG <[email protected]> wrote:

>> This Pull Request provides an implementation for 
>> [JDK-8389573](https://bugs.openjdk.org/browse/JDK-8389573): 
>> 'InputStreamReader.readAllAsString() should override the generic Reader 
>> default implementation to avoid unnecessary buffer copies'.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Markus KARG has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Simplified approach by Alan Bateman

src/java.base/share/classes/java/io/InputStreamReader.java line 188:

> 186:     @Override
> 187:     public String readAllAsString() throws IOException {
> 188:         String s = sd.tryReadAllAsString();

I think one other thing that we would need to consider is that with this 
proposed change, unlike previously, where a call too 
`InputStreamReader.readAllAsString()` would ultimately call the `read(char[] 
cbuf, int off, int len)` on the `InputStreamReader`, that is no longer true 
with this change. The `read(cbuf, off, len)` may never get called and instead 
the new implementation will directly operate on the underlying `InputStream`. 

`InputStreamReader` is public and can also be extended by application/library 
classes. The `read(cbuf, off, len)` may have been overridden too, and there 
might be expectations that the method will be called. So this is going to be an 
observable change in behaviour. I think we would need check how common it is to 
overridde the `read(cbuf, off, len)` method in such subclasses. I'll run some 
experiments for that in the coming days.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32264#discussion_r3874425666

Reply via email to