JDK-8377388 - Replacing "new StringReader(String)" by "Reader.of(CharSequence);" in Scanner

Markus KARG markus at headcrashing.eu
Sun Feb 8 14:08:00 UTC 2026


Core-Lib Devs,

as proposed in https://bugs.openjdk.org/browse/JDK-8377388 I would like 
to replace "new StringReader(String)" by "Reader.of(CharSequence);" in 
java.util.Scanner, which seems to be safe and simple:

* There is no actual need for the synchronization found in StringReader, 
as Scanner itself is explicitly *not* synchronized, no code depends on 
StringReader in partiular, and the reader is not leaked.

Alan, Chen and Jaikiran were already active in the JIRA ticket.

I have meanwhile coded the change (see diff at 
https://github.com/mkarg/jdk/commit/03837bb46aeb4c907af0fef8063f461aceaf079a) 
and tested it successfully using OpenJDK Github Actions (see result at 
https://github.com/mkarg/jdk/actions/runs/21787869983).

Are you fine with me opening a Pull Request on Github?

Thanks!

-Markus



More information about the core-libs-dev mailing list