<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi Mark,</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I think this patch should be simple enough to prove it has no unexpected impacts.</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
The reader becomes the source field, which is only used in Scanner.readInput apart from closing; readInput uses buf in a non-thread-safe way, so I think it is reasonable for readInput to operate on a non-thread-safe source too.</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
In addition, now StringReader is just a synchronized wrapper of Reader.of. So there should be minimal impact from this change.</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Regards,</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Chen Liang</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Markus KARG <markus@headcrashing.eu><br>
<b>Sent:</b> Sunday, February 8, 2026 8:08 AM<br>
<b>To:</b> 'core-libs-dev' <core-libs-dev@openjdk.org><br>
<b>Subject:</b> JDK-8377388 - Replacing "new StringReader(String)" by "Reader.of(CharSequence);" in Scanner</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Core-Lib Devs,<br>
<br>
as proposed in <a href="https://bugs.openjdk.org/browse/JDK-8377388">https://bugs.openjdk.org/browse/JDK-8377388</a> I would like
<br>
to replace "new StringReader(String)" by "Reader.of(CharSequence);" in <br>
java.util.Scanner, which seems to be safe and simple:<br>
<br>
* There is no actual need for the synchronization found in StringReader, <br>
as Scanner itself is explicitly *not* synchronized, no code depends on <br>
StringReader in partiular, and the reader is not leaked.<br>
<br>
Alan, Chen and Jaikiran were already active in the JIRA ticket.<br>
<br>
I have meanwhile coded the change (see diff at <br>
<a href="https://github.com/mkarg/jdk/commit/03837bb46aeb4c907af0fef8063f461aceaf079a)">https://github.com/mkarg/jdk/commit/03837bb46aeb4c907af0fef8063f461aceaf079a)</a>
<br>
and tested it successfully using OpenJDK Github Actions (see result at <br>
<a href="https://github.com/mkarg/jdk/actions/runs/21787869983)">https://github.com/mkarg/jdk/actions/runs/21787869983)</a>.<br>
<br>
Are you fine with me opening a Pull Request on Github?<br>
<br>
Thanks!<br>
<br>
-Markus<br>
<br>
</div>
</span></font></div>
</body>
</html>