<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Rafael Winterhalter" <rafael.wth@gmail.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"compiler-dev" <compiler-dev@openjdk.org><br><b>Sent: </b>Friday, March 21, 2025 11:15:57 AM<br><b>Subject: </b>Re: Bug in JDK25 with switch statements<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr">(And of course, this is the right list, I originally thought to post this to the HotSpot list, but this happens in interpreted mode, so I excluded that.)</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Am Fr., 21. März 2025 um 11:14 Uhr schrieb Rafael Winterhalter <<a href="mailto:rafael.wth@gmail.com" target="_blank" rel="noopener" data-mce-href="mailto:rafael.wth@gmail.com">rafael.wth@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;" data-mce-style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;"><div dir="ltr"><div>The error is stable and can be reproduced by simply building the project. But it seems to be an issue with javac indeed. The tableswitch statement is compiled as follows.</div><br><div> 213: tableswitch { // 100 to 116<br> 100: 322<br> 101: 296<br> 102: 361<br> 103: 335<br> 104: 348<br> 105: 309<br> 106: 374<br> 107: 374<br> 108: 374<br> 109: 374<br> 110: 374<br> 111: 374<br> 112: 374<br> 113: 374<br> 114: 374<br> 115: 374<br> 116: 374<br> default: 374</div><br><div>The right branch for 'p' is included at offset 361, but 'p' is an integer value of 109. The character 102 (f) is not included in the Java source.</div></div></blockquote></div></blockquote><div><br></div><div>The table is constructed like if all the targets that correspond to a valid branches (one of the six) are all on top instead of being in front the right value (m, t, d, s, r, p).</div><div><br></div><div>Sadly, i'm not able to reproduce the issue, the following code works for me :(</div><div><br></div><div><div style="background-color: #ffffff; color: #080808;" data-mce-style="background-color: #ffffff; color: #080808;"><pre style="font-family: 'JetBrains Mono',monospace; font-size: 9.8pt;" data-mce-style="font-family: 'JetBrains Mono',monospace; font-size: 9.8pt;"><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">M_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'m'</span>;<br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">T_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'t'</span>;<br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">D_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'d'</span>;<br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">S_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'s'</span>;<br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">R_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'r'</span>;<br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">static final char </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">P_SYMBOL </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">'p'</span>;<br><br><span style="color: #0033b3;" data-mce-style="color: #0033b3;">public static void </span><span style="color: #00627a;" data-mce-style="color: #00627a;">main</span>(<span style="color: #000000;" data-mce-style="color: #000000;">String</span>[] <span style="color: #000000;" data-mce-style="color: #000000;">args</span>) {<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">var </span><span style="color: #000000;" data-mce-style="color: #000000;">text </span>= <span style="color: #067d17;" data-mce-style="color: #067d17;">"mtdsrp"</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">for</span>(<span style="color: #0033b3;" data-mce-style="color: #0033b3;">var </span><span style="color: #000000;" data-mce-style="color: #000000;">i </span>= <span style="color: #1750eb;" data-mce-style="color: #1750eb;">0</span>; <span style="color: #000000;" data-mce-style="color: #000000;">i </span>< <span style="color: #000000;" data-mce-style="color: #000000;">text</span>.length(); <span style="color: #000000;" data-mce-style="color: #000000;">i</span>++) {<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">switch </span>(<span style="color: #000000;" data-mce-style="color: #000000;">text</span>.charAt(<span style="color: #000000;" data-mce-style="color: #000000;">i</span>)) {<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">M_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"m"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">T_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"t"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">D_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"d"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">S_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"s"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">R_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"r"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">case </span><span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">P_SYMBOL</span>:<br> <span style="color: #000000;" data-mce-style="color: #000000;">System</span>.<span style="color: #871094; font-style: italic;" data-mce-style="color: #871094; font-style: italic;">out</span>.println(<span style="color: #067d17;" data-mce-style="color: #067d17;">"p"</span>);<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">break</span>;<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">default</span>:<br> <span style="color: #0033b3;" data-mce-style="color: #0033b3;">throw new </span>IllegalStateException();<br> }<br> }<br>}</pre></div></div><div><br></div><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;" data-mce-style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;"><div dir="ltr"><br><div>I guess this is the wrong mailing list in this case. I will post this to the javac list.</div><br><div>Thanks, Rafael</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Fr., 21. März 2025 um 10:54 Uhr schrieb Remi Forax <<a href="mailto:forax@univ-mlv.fr" target="_blank" rel="noopener" data-mce-href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>>:<br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;" data-mce-style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;"><div><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000;" data-mce-style="font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000;"><div>Hello Raphael,</div><div>It may be hard to reproduce,</div><div>can you do a javap -c on the class/method so it will be easier to see if the generated bytecode is wrong of if it's a VM issue.</div><br><div>regards,</div><div>Rémi</div><br><hr id="m_6833689223670212611m_3686300147316054987m_649006921082298200zwchr"><div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Rafael Winterhalter" <<a href="mailto:rafael.wth@gmail.com" target="_blank" rel="noopener" data-mce-href="mailto:rafael.wth@gmail.com">rafael.wth@gmail.com</a>><br><b>To: </b>"compiler-dev" <<a href="mailto:compiler-dev@openjdk.org" target="_blank" rel="noopener" data-mce-href="mailto:compiler-dev@openjdk.org">compiler-dev@openjdk.org</a>><br><b>Sent: </b>Friday, March 21, 2025 10:20:48 AM<br><b>Subject: </b>Bug in JDK25 with switch statements<br></blockquote></div><div><blockquote style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010ff; margin-left: 5px; padding-left: 5px; color: #000000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr"><div>Hello,</div><div>my project Byte Buddy fails to build with recent JDK 25s. I am not sure if this is a known bug, but I wanted to mention it: <a href="https://github.com/raphw/byte-buddy/actions/runs/13975513319/job/39131008617" target="_blank" rel="noopener" data-mce-href="https://github.com/raphw/byte-buddy/actions/runs/13975513319/job/39131008617">https://github.com/raphw/byte-buddy/actions/runs/13975513319/job/39131008617</a><br></div><br><div>The reason for the build failure is that this switch statement ends up in the default branch: <a href="https://github.com/raphw/byte-buddy/blob/master/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java#L3239" target="_blank" rel="noopener" data-mce-href="https://github.com/raphw/byte-buddy/blob/master/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java#L3239">https://github.com/raphw/byte-buddy/blob/master/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java#L3239</a><br></div><br><div>This is happening for the char 'p' which is the last legal branch of the switch. This does not yield an error on JDKs 5 to 24, so this must be introduced recently.</div><br><div>Thanks, Rafael</div></div><br></blockquote></div></div></div></blockquote></div></blockquote></div><br></blockquote></div></div></body></html>