<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 15 (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:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Of course, the problem with this code is that if `something()` is ever unexpectedly empty, suddenly that `MAX` value is going to get
<i>actually used</i> for something, and who knows what might happen. It’s, of course, vulnerable to the “let’s just add a little” problem, same as the other case.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It would seem safer to address the empty case explicitly… but then you don’t need `MAX` anymore, you can just initialize `min` to the first value. This way you’d have a variable that was never bogus at any time.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Of course, I am not suggesting that the potential for misuse is a sufficient argument for
<i>not</i> offering something. Only that I’m not sure this use case is motivating
<i>for</i> offering it.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Éamonn McManus <emcmanus@google.com><br>
<b>Date: </b>Thursday, September 4, 2025 at 3:03</span><span style="font-family:"Arial",sans-serif;color:black"> </span><span style="color:black">PM<br>
<b>To: </b>Roger Riggs <roger.riggs@oracle.com><br>
<b>Cc: </b>core-libs-dev@openjdk.org <core-libs-dev@openjdk.org><br>
<b>Subject: </b>Re: Duration.MAX_VALUE<o:p></o:p></span></p>
</div>
<div id="mail-editor-reference-message-container">
<div>
<div>
<p class="MsoNormal">Two typical use cases:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">// 1. Sentinel<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Duration min = Duration.MAX;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">for (var foo : something()) {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  if (foo.duration().compareTo(min) < 0) {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    min = foo.duration();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>