<div dir="ltr"><div dir="ltr">Am Do., 21. Juli 2022 um 16:15 Uhr schrieb Brian Goetz <<a href="mailto:brian.goetz@oracle.com" target="_blank">brian.goetz@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>
<div>I think the root of the problem here is that CodeBuilder combines the “build my method” with stackmap generation, and if the latter fails, nothing is produced. And when stack map generation fails, you’d like to see a javap-like output so you can see what
you did wrong. </div>
<div><br>
</div>
<div>You can suppress stack map generation with an Option, and then you’ll get a classfile out, but that is probably a little hard to discover. </div>
<div><br>
</div>
<div>This is a more general problem, not just for stack maps; there are other things that can cause code generation to fail (e.g., forward branch to a label that is never defined; invalid labels in exception tables; etc.) The main vector we have for feeding
back information is the exception message, but putting the entire javap output of the method body in the exception message might be too much (but might not be, since any exception from building a classfile will trigger a round of debugging.)</div>
<div><br>
</div>
<div>Any thoughts on how you would like to see this information fed back?</div></div></blockquote><div><br></div><div>For me as a user building a compiler, the Classfile API is a black box. When it</div><div>throws an exception that is caused by faulty input, one of the first questions I</div><div>need to answer is "What did I do?" Well, I called lots and lots of methods on</div><div>builder instances (for the most part CodeBuilder, of course). This is my primary</div><div>point of contact to the API, and a textual log of those method calls would be</div><div>helpful. Something along the lines of how Unix strace prints a log of system</div><div>calls. Symbolic information of call details that allows to piece information </div><div>together, if need be from thousands of lines of text.</div><div><br></div><div>Having such call log lines emitted on demand as part of a Classfile.build()</div><div>would be the most straightforward way to do this.</div><div><br></div><div>-- mva</div><div><br></div></div></div>