<html 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=Windows-1252">
<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:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Yes, this is a bug in labels inflation for older class files versions.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I’ve filled a bug <a href="https://bugs.openjdk.org/browse/JDK-8339368">
https://bugs.openjdk.org/browse/JDK-8339368</a> based on your test case and started work on a fix.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank you for discovering it!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">classfile-api-dev <classfile-api-dev-retn@openjdk.org> on behalf of david32768@btinternet.com <david32768@btinternet.com><br>
<b>Date: </b>Saturday, 31 August 2024 at 9:18<br>
<b>To: </b>classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Subject: </b>Switch targets are not inflated in CodeModel if no StackMap.<o:p></o:p></span></p>
</div>
<p>Method jdk/internal/CodeImpl.inflateJumpTargets should also inflate switch instructions.<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>Perhaps BranchInstruction, JsrInstruction, TableSwitchInstruction, LookupSwitchInstruction should implement an interface with method List<Label> targets().<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>build test method<br>
```<br>
   private static void build(CodeBuilder cob) {<br>
       Label L1 = cob.newLabel();<br>
       Label L2 = cob.newLabel();<br>
       SwitchCase sc1 = SwitchCase.of(0,L2);<br>
       List<SwitchCase> cases = new ArrayList<>();<br>
       cases.add(sc1);<br>
       cob.iload(0)<br>
          .lookupswitch(L1, cases)<br>
          .labelBinding(L2)<br>
          .iconst_1()<br>
          .ireturn()<br>
          .labelBinding(L1)<br>
          .iconst_0()<br>
          .ireturn();<br>
   }<o:p></o:p></p>
<p>```<o:p></o:p></p>
<p>print of elements in CodeModel<br>
```<br>
Load[OP=ILOAD_0, slot=0]<br>
LookupSwitch[OP=LOOKUPSWITCH]<br>
UnboundIntrinsicConstantInstruction[op=ICONST_1]<br>
Return[OP=IRETURN]<br>
UnboundIntrinsicConstantInstruction[op=ICONST_0]<br>
Return[OP=IRETURN]<o:p></o:p></p>
<p>```<o:p></o:p></p>
<p>test driver class<br>
```<br>
   public static void main(String[] args) throws IOException {<br>
       byte[] bytes = ClassFile.of()<br>
               .build(ClassDesc.of("TestSwitchInflate"),<br>
                     clb -> clb.withFlags(ClassFile.ACC_PUBLIC  | ClassFile.ACC_SUPER)<br>
               .withVersion(49,0)<br>
               .withMethodBody("Table", MethodTypeDesc.ofDescriptor("(I)I"),<br>
                    ClassFile.ACC_STATIC, SwitchInflate::build));<br>
       ClassFile.of().parse(bytes)<br>
           .methods().stream()<br>
                .flatMap(m -> m.code().stream())<br>
               .flatMap(c -> c.elementStream())<br>
               .forEach(System.out::println);<br>
   }<o:p></o:p></p>
<p>```<br>
 <o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>