<div dir="ltr"><div dir="ltr">Am Mi., 3. Aug. 2022 um 17:59 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 lang="en-CZ" style="overflow-wrap: break-word;">
<div class="gmail-m_-6095484618703634479WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">StackMapGenerator is now providing more detailed info about root cause of the failure and appends bytecode print directly in the exception.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">All the critical information should be now visible in the provided exception message.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Alternatively, a system variable switch can enable debug print, or it can be printed to a logger (which may cause issues with JDK bootstrap), or attached as another suppressed exception.</span></p></div></div></blockquote><div><br></div><div>Using the prior example of CodeBuilder.ifThenElse() inserting a GOTO to nowhere,</div><div>I now get this extremely helpful output:</div><div><br></div><div> ERROR  at tcljc.switch-test/int-cmp-test:45<br>java.lang.VerifyError: Detected branch target out of bytecode range at bytecode offset 26 of method fnbody~1(int)<br>  - max stack: 65535<br>    max locals: 65535<br>    attributes: []<br>    //stack map frame @0: {locals: [int], stack: []}<br>    0: {opcode: ILOAD_0, slot: 0}<br>    1: {opcode: ICONST_1, constant value: 1}<br>    2: {opcode: IADD}<br>    3: {opcode: ISTORE_1, slot: 1}<br>    4: {opcode: ILOAD_0, slot: 0}<br>    5: {opcode: ICONST_2, constant value: 2}<br>    6: {opcode: IADD}<br>    7: {opcode: ISTORE_2, slot: 2}<br>    8: {opcode: ILOAD_0, slot: 0}<br>    9: {opcode: ICONST_3, constant value: 3}<br>    10: {opcode: IADD}<br>    11: {opcode: ISTORE_3, slot: 3}<br>    12: {opcode: ILOAD_1, slot: 1}<br>    13: {opcode: ILOAD_2, slot: 2}<br>    14: {opcode: IF_ICMPGE, target: 29}<br>    17: {opcode: ILOAD_2, slot: 2}<br>    18: {opcode: ILOAD_3, slot: 3}<br>    19: {opcode: IF_ICMPGE, target: 24}<br>    22: {opcode: ICONST_1, constant value: 1}<br>    23: {opcode: IRETURN}<br>    24: {opcode: ICONST_0, constant value: 0}<br>    25: {opcode: IRETURN}<br>    26: {opcode: GOTO, target: 31}<br>    29: {opcode: ICONST_0, constant value: 0}<br>    30: {opcode: IRETURN}<br><br> at java.base/jdk.classfile.impl.StackMapGenerator.generatorError(StackMapGenerator.java:867)<br>  at java.base/jdk.classfile.impl.StackMapGenerator.detectFrameOffsets(StackMapGenerator.java:932)<br>      at java.base/jdk.classfile.impl.StackMapGenerator.generate(StackMapGenerator.java:284)<br></div><div>[...]</div><div><br></div><div>Thank you very much!</div><div><br></div><div>-- mva</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="en-CZ" style="overflow-wrap: break-word;"><div class="gmail-m_-6095484618703634479WordSection1"><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Please test it and send me your feedback.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Adam<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">On 21.07.2022 13:21, "Michael van Acken" <<a href="mailto:michael.van.acken@gmail.com" target="_blank">michael.van.acken@gmail.com</a>> wrote:<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">Related but geared towards the builder side of things:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">Is there a way to print out a trace of parts fed to CodeBuilder instances?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">Just this morning I had Classfile die on me because of a stack underflow,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">and it was quite hard to find out which parts were missing from the Code<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">attribute.  And that with a Code totalling just 5 instructions...<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">If there would have been bytes output, then I could have inspected the<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">situation with javap.  But if I mess up and pass inconsistent data to<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">CodeBuilder, causing it to throw instead of producing a byte array, then<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">I have an observability gap.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt">-- mva<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
</div>
</div>
</div>

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