<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">
<blockquote style="margin-left: 0.8ex; padding-left: 1ex; border-left: 3px solid rgb(200, 200, 200);">
<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">
Confidential – Oracle Internal</div>
</blockquote>
<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">
This line was user error, please ignore.</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>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg">
<div style="direction: ltr; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>From:</b> Angelos Bimpoudis <angelos.bimpoudis@oracle.com><br>
<b>Sent:</b> 03 October 2025 23:48<br>
<b>To:</b> amber-spec-experts@openjdk.org <amber-spec-experts@openjdk.org><br>
<b>Subject:</b> Draft JEP: Primitive Types in Patterns, instanceof, and switch (Fourth Preview)</div>
<div style="direction: ltr;"> </div>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Dear experts,</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
We are preparing to re-preview primitive types in patterns, instanceof, and switch for a fourth time (currently previewed in JEP 507). You can read the draft JEP here:</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<a data-auth="NotApplicable" class="OWAAutoLink" id="OWA5aaeaf57-db4a-300b-2bd0-dbdb316b4552" href="https://openjdk.org/jeps/8359136">https://openjdk.org/jeps/8359136</a></div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
We are grateful for the feedback that we have received from our expert and developer communities during the previous rounds. The proposed changes enhance the definition of unconditional exactness and apply tighter dominance checks in switch. These changes enable
the compiler to identify a wider range of mistakes by developers, although a small number of switch constructs that were previously legal will now be rejected.</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
In more detail, firstly, we intend to expand the set of the existing unconditionally exact conversions (type-based unconditionally exact conversions) with value-based unconditionally exact conversions. Making unconditional exactness aware of constant expressions
and passing such information to dominance, allows to implement tighter checks:</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
int j = ...;</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
switch(j) {</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case float f -> {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case 16_777_216 -> {} // error: dominated (the conversion from int to float for that constant is unconditionally exact)</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
default -> {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
}</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Secondly, we treat switches that contain unconditional patterns that are followed by other patterns, as erroneous:</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
int x = ...;</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
switch(x) {</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case int _ -> {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case float _ -> {} // error: dominated (even if both i2f and f2i are both NP conversions)</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
int i = ...;</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
switch (i) {</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case Integer _ -> {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case byte _ -> {} // error: dominated (even if there is no byte to Integer conversion)</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
};</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
interface A {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
interface B {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
A aa = ...;</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
switch (aa) {</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case A _ -> {}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
case B _ -> {} // error: dominated (even if A and B are unrelated)</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
}</div>
<div style="direction: ltr; margin-left: 40px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Note that the last case is valid code today (prior to this JEP). A user that wrote case A followed by case B is not aware that case B is never matched; case A is unconditional for the type of the selector which is A.</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Comments welcome!</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Thanks, </div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Angelos</div>
<div style="direction: ltr; font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr;"><br>
</div>
<div style="direction: ltr; text-align: left; margin-left: 5pt; font-family: Calibri; font-size: 10pt; color: rgb(0, 0, 0);">
Confidential – Oracle Internal</div>
</body>
</html>