<div dir="ltr"><div dir="ltr">Am Fr., 19. Aug. 2022 um 09:58 Uhr schrieb Adam Sotona <<a href="mailto:adam.sotona@oracle.com">adam.sotona@oracle.com</a>>:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-msg-10042075176127217">





<div lang="en-CZ" style="overflow-wrap: break-word;">
<div class="gmail-m_2056981929305636292WordSection1">
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12pt;margin-left:36pt">
<b><span style="font-size:12pt;color:black">From: </span></b><span style="font-size:12pt;color:black">Michael van Acken <<a href="mailto:michael.van.acken@gmail.com" target="_blank">michael.van.acken@gmail.com</a>></span><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36pt">I was referring to the part where the code of the finally block is duplicated <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt">into all paths right after their respective handled regions.  Looking at the<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt">CodeBuilder source code, I can't find any of this.<u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This is an example use case of CodeBuilder::trying:<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">    
</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">codeBuilder</span><span style="font-size:10pt;font-family:"Courier New";color:black">.trying(t</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">ryBuilder</span><span style="font-size:10pt;font-family:"Courier New";color:black">
 -> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">        
</span><span style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">// </span>
<span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">try block code</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">     }, catchBuilder -> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">         catchBuilder.catching(CD_IOOBE,
</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">handlerBuilder</span><span style="font-size:10pt;font-family:"Courier New";color:black"> -> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">            
</span><span style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">// </span>
<span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">catch handler code can<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">         }).catchingAll(</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">finallyBuilder</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">
</span><span style="font-size:10pt;font-family:"Courier New";color:black">-> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">            
</span><span style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">// </span>
<span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">finally handler code</span><span style="font-size:10pt;font-family:"Courier New";color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">         });<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">     });</span><span style="color:black"> </span></p></div></div></div></div></div></div></blockquote><div><br></div><div>I tried to follow your suggestion, but was not able to complete the try/finally output.</div><div>The Clojure code is probably not that helpful here, but if I put this method through</div><div>javac I get output whose [8, 16[ (right after the region covered by exceptionCatch)</div><div>I cannot emulate with the trying() construction you describe.</div><div><br></div><div><font face="monospace">  public static void tryFinally() {</font></div><font face="monospace">    try {<br>      System.out.println("Hello World!");<br>    } finally {<br>      System.out.println("Finally...");<br>    }<br>  }</font></div><div class="gmail_quote"><font face="monospace"><br></font></div><div class="gmail_quote"><div><font face="monospace">         0: getstatic     #7                  // Field java/lang/System.out:Ljava/io/PrintStream;<br>         3: ldc           #13                 // String Hello World!<br>         5: invokevirtual #15                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V<br>         8: getstatic     #7                  // Field java/lang/System.out:Ljava/io/PrintStream;<br>        11: ldc           #21                 // String Finally...<br>        13: invokevirtual #15                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V<br>        16: goto          30<br>        19: astore_0<br>        20: getstatic     #7                  // Field java/lang/System.out:Ljava/io/PrintStream;<br>        23: ldc           #21                 // String Finally...<br>        25: invokevirtual #15                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V<br>        28: aload_0<br>        29: athrow<br>        30: return<br></font></div><div><font face="monospace">      Exception table:<br>         from    to  target type<br>             0     8    19   any<br></font></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-msg-10042075176127217"><div lang="en-CZ" style="overflow-wrap: break-word;"><div class="gmail-m_2056981929305636292WordSection1"><div><div><div><p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New""><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt">This method encapsulates a BlockCodeBuilder instance, but does not<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt">provide it to the caller (the `child` below):<u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This is an example use case of CodeBuilder::block:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">    
</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">codeBuilder</span><span style="font-size:10pt;font-family:"Courier New";color:black">.</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">block</span><span style="font-size:10pt;font-family:"Courier New";color:black">(</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">blockBuilder</span><span style="font-size:10pt;font-family:"Courier New";color:black">
 -> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">        
</span><span style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">// </span>
<span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">block code<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="background:white"><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:rgb(150,150,150)">        
</span><span lang="EN-US" style="font-size:10pt;font-family:"Courier New";color:black">if( blockBuilder.isEmpty()) …<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10pt;font-family:"Courier New";color:black">     });</span><span style="color:black"> </span></p></div></div></div></div></div></div></blockquote><div><br></div><div>This is extremely helpful.  I can either transport the isEmpty() status via side-effect</div><div>out of the closure (ugly), or wrap the whole t/c/f in this block() (probably better).  In</div><div>either case I can get rid of my labelToBci calls.  Right now I have to cast to</div><div>BlockCodeBuilderImpl to get to isEmpty().<br></div><div><br></div><div>-- mva</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-msg-10042075176127217"><div lang="en-CZ" style="overflow-wrap: break-word;"><div class="gmail-m_2056981929305636292WordSection1"><div><div><div>
</div>
</div>
</div>
</div>
</div>

</div></blockquote></div></div>