<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>I think I agree. While coupling the notion of enhanced swith with
      that of exhaustiveness has been a good way to define some kind of
      line between old and new behavior, I think it might perhaps be
      wiser to enforce exhaustiveness on a more data-dependent way -
      e.g. what is the type we're switching on? If it's an enum, or a
      sealed class, I see some value in enforcing some kind of
      exhaustiveness analysis. But for strings and numbers, it is not
      clear to me that enforcing exhaustiveness at the statement level
      makes sense.</p>
    <p><br>
    </p>
    <p>Sure, if I define a class that interprets all the JVM bytecodes,
      I could always forget to handle one of them if my interpreter
      logic is a big int switch.</p>
    <p><br>
    </p>
    <p>But perhaps, in such cases, we would suggest a design where the
      opcodes are modelled using records implementing a single sealed
      interface, or some enum (thereby also getting exhaustiveness
      checks for free) ?</p>
    <p><br>
    </p>
    <p>Unfortunately enum is that one case where compatibility dictates
      that we can't be exhaustive, which is a little sad... but I think
      that's the best we can do?<br>
      <br>
    </p>
    <p>Maurizio<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 24/10/2023 23:49, Angelos Bimpoudis
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:IA1PR10MB75156317B7B4CC3DB21D71AA82DFA@IA1PR10MB7515.namprd10.prod.outlook.com">
      
      <style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        Hello all!</div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        <br>
      </div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        <span style="font-family: Calibri, sans-serif; display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted0">Yuriy pointed out a valid point.</span><br>
      </div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        <span style="font-family: Calibri, sans-serif; display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted0"><br>
        </span></div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        <span style="font-family: Calibri, sans-serif; display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted0">1) Should we treat
          float/double/boolean/longs as a new addition to the
          <span style="display: inline !important; background-color: rgb(255, 255, 255);">non-enhanced</span>
          switch (old switch) and support anything new that comes with
          that?</span></div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
        <span style="font-family: Calibri, sans-serif; display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted0"><br>
        </span></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif">or</font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif"><br>
        </font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif">2)
          Should we treat those data types equally with all the
          pre-existing ones?</font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif"><br>
        </font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif">I am
          strongly in favour of the
          <span style="display: inline !important; background-color: rgb(255, 255, 255);">2)</span>
          for the shake of symmetry and uniformity in what the user will
          assume, thus I will fix the bug.</font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif"><br>
        </font></div>
      <div style="font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof"><font face="Calibri, sans-serif">What do
          others think?</font></div>
      <div style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
        <br>
      </div>
      <hr tabindex="-1" style="display:inline-block; width:98%">
      <div id="divRplyFwdMsg" dir="ltr"><font style="font-size: 11pt; color: rgb(0, 0, 0);" face="Calibri, sans-serif"><b>From:</b> Yuriy Maslyanko
          <a class="moz-txt-link-rfc2396E" href="mailto:yuriy.maslyanko@oracle.com"><yuriy.maslyanko@oracle.com></a><br>
          <b>Sent:</b> 24 October 2023 21:57<br>
          <b>To:</b> Angelos Bimpoudis
          <a class="moz-txt-link-rfc2396E" href="mailto:angelos.bimpoudis@oracle.com"><angelos.bimpoudis@oracle.com></a><br>
          <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:compiler-dev@openjdk.org">compiler-dev@openjdk.org</a>
          <a class="moz-txt-link-rfc2396E" href="mailto:compiler-dev@openjdk.org"><compiler-dev@openjdk.org></a><br>
          <b>Subject:</b> JEP 455: Non-enhanced switch statements</font>
        <div> </div>
      </div>
      <div style="word-wrap:break-word" lang="EN-US">
        <div class="x_WordSection1">
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
            Hi Angelos,</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
             </p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
            Section 14.11.2 of <a href="https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html#jls-14.11.2" data-auth="NotApplicable" id="OWA8a7ff157-bb46-c408-0d8c-3100cc911996" class="OWAAutoLink moz-txt-link-freetext" moz-do-not-send="true">
https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html#jls-14.11.2</a>
            has this note:</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
             </p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;margin-left:.5in">
            For compatibility reasons, <code style="font-family: "Courier New";"><span style="font-size:10.0pt">switch</span></code> statements
            that are not enhanced
            <code style="font-family: "Courier New";"><span style="font-size:10.0pt">switch</span></code> statements
            are not required to be exhaustive.</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
             </p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
            Noticed that if the switch selector statement is
            float/double/boolean (in this case it’s a non-enhanced
            switch statement), the code shown below fails with â€œerror:
            the switch statement does not cover all possible input
            values”:</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
             </p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                static boolean check = false;</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                public static boolean testMethod() {</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                    double v1 = 1d;</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                    switch ( v1 ) {</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                        case 1d:</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                            check = true;</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                            break;</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                    }</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                    return check;</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
                }</p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
             </p>
          <p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
            <br>
          </p>
        </div>
      </div>
    </blockquote>
  </body>
</html>