<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 31/03/2025 16:51, Engebretson, John wrote:<br>
<blockquote type="cite" cite="mid:8d453b79099b4675bce7f3902e3cd74f@amazon.com">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>@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;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}span.EmailStyle22
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}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]-->
<div class="WordSection1">
<p class="MsoNormal"> Alan – is this what you have in mind:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">ByteArrayOutputStream.getInstance() //
returns existing class<o:p></o:p></p>
<p class="MsoNormal">ByteArrayOutputStream.getUnsynchronizedInstance()
// returns subclass of BAOS that overrides the synchronization<o:p></o:p></p>
<p class="MsoNormal">ByteArrayOutputStream.get<Scalable|Memory|Fast|Segmented>Instance()
// returns the new class<o:p></o:p></p>
<br>
</div>
</blockquote>
<br>
BAOS has been synchronized since JDK 1.0. While undocumented, it's
possible that existing code depends on this 30 year behavior so I
think we are stuck with it.<br>
<br>
The removal of biased locking has spurred on a few complaints that
the class is needlessly synchronized. A static factory to return an
unsynchronized BOAS would help but only if it isn't used with code
that assumes all operations are synchronized. So I think we will
have to look at the API docs for this.<br>
<br>
It's not clear that we need to have several implementation with
different performance tradeoffs. So I think part of the exploration
will be to see what usages perform better or worse, and whether
having a parameter to specify the initial size or some hint of the
max size would help the discussion.<br>
<br>
-Alan<br>
<br>
<br>
</body>
</html>