<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<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 Ella,
<div><br>
</div>
<div>Indeed. The bullet you showed is now deleted from both. The line you have put in bold, replaces the other two.
</div>
<div><br>
</div>
<div>Thanks for bringing this up.</div>
Aggelos<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amber-dev <amber-dev-retn@openjdk.org> on behalf of Ella Ananeva <ella.ananeva@oracle.com><br>
<b>Sent:</b> 08 November 2023 19:18<br>
<b>To:</b> amber-dev@openjdk.org <amber-dev@openjdk.org><br>
<b>Subject:</b> instanceof with primitive type</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:Wingdings}
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
code
        {font-family:"Courier New"}
.x_MsoChpDefault
        {font-size:10.0pt;
        font-family:"Calibri",sans-serif}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
ol
        {margin-bottom:0in}
ul
        {margin-bottom:0in}
-->
</style>
<div lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi team,</p>
<p class="x_MsoNormal">Reading <a href="https://cr.openjdk.org/~abimpoudis/instanceof/jep455-20231030/specs/instanceof-jls.html#jls-15.20.2">
JEP 455 spec</a>, I see this:</p>
<p><strong><span style="font-family:"Calibri",sans-serif">The type of the expression
</span></strong><em><b><span style="font-family:"Calibri",sans-serif">RelationalExpression</span></b></em><strong><span style="font-family:"Calibri",sans-serif"> can be a reference type, a primitive type</span></strong>
<strong><span style="font-family:"Calibri",sans-serif">or the null type.</span></strong></p>
<p class="x_MsoNormal">And then, later:</p>
<p>The following rules apply when <code><span style="font-size:10.0pt">instanceof</span></code> is the pattern match operator:</p>
<ul type="disc">
<li class="x_MsoNormal" style=""><span style="">The type of the expression <em><span style="font-family:"Calibri",sans-serif">RelationalExpression</span></em> must be a reference type or the null type, or a compile-time error occurs.</span></li></ul>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">But I would expect that primitive types in patterns should be good, too. And in the freshest version of
<a href="https://mach5.us.oracle.com/mdash/buildIds/2023-11-06-1633093.angelos.bimpoudis.dev">
JEP_455 JDK</a>, both examples compile and print “Yes”:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal" style="background:white"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Integer x
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">=
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#1750EB">5</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">;<br>
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#0033B3">if
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">(</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">x
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#0033B3">instanceof int
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">y)
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">System</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">.</span><i><span style="font-size:10.0pt; font-family:"Courier New"; color:#871094">out</span></i><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">.println(</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#067D17">"Yes"</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">);</span></p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal" style="background:white"><span style="font-size:10.0pt; font-family:"Courier New"; color:#0033B3">int
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">x </span>
<span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">= </span>
<span style="font-size:10.0pt; font-family:"Courier New"; color:#1750EB">5</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">;<br>
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#0033B3">if
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">(</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">x
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#0033B3">instanceof
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Integer
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">y)
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">System</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">.</span><i><span style="font-size:10.0pt; font-family:"Courier New"; color:#871094">out</span></i><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">.println(</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#067D17">"Yes"</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#080808">);</span></p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Shouldn’t the spec be updated?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thank you,</p>
<p class="x_MsoNormal">Ella Ananeva</p>
</div>
</div>
</body>
</html>