<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Aleksei,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>thank you for reposting to the "right" mailing list, and everybody thank you for contribution to this discussion, but please note that it was *not me* who posted to the "wrong" list: In fact, I just opened this issue <a href="https://bugs.openjdk.org/browse/JDK-8309726">https://bugs.openjdk.org/browse/JDK-8309726</a>, and it was *the OpenJDK infrastructure* which in turn posted to the "wrong" list. I am not aware who is in charge to fix this, but *I* cannot change this behvior. Maybe the one in charge is reading this and can fix it?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Thanks                                                                                             <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>-Markus<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span style='color:#1F497D'><o:p> </o:p></span></a></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Aleksei Ivanov [mailto:alexey.ivanov@oracle.com] <br><b>Gesendet:</b> Donnerstag, 5. Oktober 2023 14:16<br><b>An:</b> Markus Karg; core-libs<br><b>Cc:</b> client-libs-dev@openjdk.org<br><b>Betreff:</b> Re: RFC: 8309726: Reader::readString<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Hi Markus,<br><br>You posted it to the wrong list, it belongs on core-libs-dev.<br><br>-- <br>Regards,<br>Alexey<o:p></o:p></p><div><p class=MsoNormal>On 10/06/2023 12:35, Markus Karg wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='color:#172B4D;background:white'>By analyzing several existing applications I noticed that many of them need to read a String from an input source (be it an input stream or a reader), and there are a lot of solutions applied which all are more or less suboptimal:</span><span style='color:#172B4D'><br><br><span style='background:white'>* Files.readString(Path) - Fast, convenient, uses JLA.newStringNoRepl, only works with files (not with sockets or other sources).</span><br><span style='background:white'>* new String(inputStream.readAllBytes()) - Fast, complex, enforces dealing with an array in user code, cannot use JLA.newStringNoRepl.</span><br><span style='background:white'>* bufferedReader.lines().collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString(); - Complex, enforces dealing with a stream in user code, doesn't use JLA.newStringNoRepl.</span><br><span style='background:white'>* reader.transferTo(stringWriter); stringWriter.toString(); - Medium convient, medium performance, synchronized as it relies on StringBuffer instead of StringBuilder.</span><br><span style='background:white'>* Custom loop using char[] of various default sizes (some 8k, some 16k, some configurable) - Slow, complex, doesn't use JLA.newStringNoRepl.</span><br><span style='background:white'>* etc.</span><br><br><span style='background:white'>Checking back with the particular authors of these applications I noticed that what they all miss is (a) guidance which solution is "best" (mostly thinking in speed, but also in reduced GC stress and memory consumption), (b) something convenient like Files.readString() but working with any reader implementation, not just with files.</span><br><br><span style='background:white'>I think we can do better, hence I'd like to propose the introduction of a new Reader::readString method. The benefits are:</span><br><span style='background:white'>* Guidance. The introduction of this method is a clear signal to all application programmers to use *this* one by default.</span><br><span style='background:white'>* Convenience. It couldn't be any easier for the caller.</span><br><span style='background:white'>* Performance. OpenJDK committers can optimize it for both, convenience, speed, reduced GC stress, and memory consumption, at the very same time.</span><br><span style='background:white'>* Optimizable. Each Reader implementation can choose an algorithm fitting best its own needs, while java.io.Reader itself provides a convenient default implementation based on a loop over this.read().</span></span><o:p></o:p></p></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p></div></body></html>