<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=us-ascii">
<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:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle23
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Angelos,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Section 14.11.2 of <a href="https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html#jls-14.11.2">
https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html#jls-14.11.2</a> has this note:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">For compatibility reasons, <code><span style="font-size:10.0pt">switch</span></code> statements that are not enhanced
<code><span style="font-size:10.0pt">switch</span></code> statements are not required to be exhaustive.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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”:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    static boolean check = false;<o:p></o:p></p>
<p class="MsoNormal">    public static boolean testMethod() {<o:p></o:p></p>
<p class="MsoNormal">        double v1 = 1d;<o:p></o:p></p>
<p class="MsoNormal">        switch ( v1 ) {<o:p></o:p></p>
<p class="MsoNormal">            case 1d:<o:p></o:p></p>
<p class="MsoNormal">                check = true;<o:p></o:p></p>
<p class="MsoNormal">                break;<o:p></o:p></p>
<p class="MsoNormal">        }<o:p></o:p></p>
<p class="MsoNormal">        return check;<o:p></o:p></p>
<p class="MsoNormal">    }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, it works for char, byte, short, int. Maybe this is a bug? Tried it with
<a href="https://mach5.us.oracle.com/mdash/buildIds/2023-10-18-2214011.angelos.bimpoudis.dev">
https://mach5.us.oracle.com/mdash/buildIds/2023-10-18-2214011.angelos.bimpoudis.dev</a>, with same result. Could you please check?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Yuriy<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Yuriy Maslyanko <br>
<b>Sent:</b> Wednesday, October 18, 2023 2:39 PM<br>
<b>To:</b> Angelos Bimpoudis <angelos.bimpoudis@oracle.com><br>
<b>Cc:</b> compiler-dev@openjdk.org<br>
<b>Subject:</b> JEP 455: JLS change for switch expressions<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Angelos,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">JCK team started working on JEP 455: Primitive types in Patterns, instanceof, and switch (Preview). Just noticed that in the draft spec,
<a href="https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html">
https://cr.openjdk.org/~abimpoudis/instanceof/jep443-20231010/specs/instanceof-jls.html</a>, there is a change for the switch statement:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">14.11 The switch Statement<o:p></o:p></p>
<p class="MsoNormal">The <em><span style="font-family:"Calibri",sans-serif">Expression</span></em> is called the
<em><span style="font-family:"Calibri",sans-serif">selector expression</span></em>. The type of the selector expression must be
<code><span style="font-size:10.0pt">char</span></code>, <code><span style="font-size:10.0pt">byte</span></code>,
<code><span style="font-size:10.0pt">short</span></code>, <code><span style="font-size:10.0pt">int</span></code>, or a reference type, or a compile-time error occurs. (jls-14.11-200)<o:p></o:p></p>
<p class="MsoNormal">-><o:p></o:p></p>
<p class="MsoNormal">The <em><span style="font-family:"Calibri",sans-serif">Expression</span></em> is called the
<em><span style="font-family:"Calibri",sans-serif">selector expression</span></em>. The type of the selector expression
<strong><span style="font-family:"Calibri",sans-serif">can be either a primitive or a reference type.<o:p></o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal"><o:p> </o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal">But the corresponding assertion for switch expressions is not changed:<o:p></o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal"><o:p> </o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal">15.28. switch Expressions<o:p></o:p></span></strong></p>
<p class="MsoNormal">The <em><span style="font-family:"Calibri",sans-serif">Expression</span></em> is called the
<em><span style="font-family:"Calibri",sans-serif">selector expression</span></em>. The type of the selector expression must be
<code><span style="font-size:10.0pt">char</span></code>, <code><span style="font-size:10.0pt">byte</span></code>,
<code><span style="font-size:10.0pt">short</span></code>, <code><span style="font-size:10.0pt">int</span></code>, or a reference type, or a compile-time error occurs. (jls-15.28-200)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal">Could you please take a look?<o:p></o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal"><o:p> </o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal">Thanks,<o:p></o:p></span></strong></p>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif;font-weight:normal">Yuriy<o:p></o:p></span></strong></p>
</div>
</body>
</html>