<div dir="ltr">What are you trying to do? So you are writing a class and there's a stack size error, but you don't know which method builder this stack size error is from?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2024 at 2:04 PM Øystein Myhre Andersen <<a href="mailto:o.myhre@gmail.com">o.myhre@gmail.com</a>> wrote:<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 dir="ltr">You said: 

as this error can only be detected at run time.<div>That is wrong. It occurs when building stack-map.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2024 at 7:38 PM - <<a href="mailto:liangchenblue@gmail.com" target="_blank">liangchenblue@gmail.com</a>> wrote:<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 dir="ltr">Hi Øystein,<div>ClassFile API does not always ensure the created bytecode is valid, and allowing creation of code with invalid stack size is a feature instead of a bug. A stack size mismatch problem, in essence, is closer to the error which a user forgot to call a builder method. And putting this check earlier doesn't really help, as this error can only be detected at run time. You can always use ClassFile.verify to verify your generated class files.</div><div><br></div><div>In addition, CodeBuilder supports chaining; if we add the size checking in each item of the chain, it will introduce a performance penalty.</div><div><br></div><div>Chen</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2024 at 8:42 AM Øystein Myhre Andersen <<a href="mailto:o.myhre@gmail.com" target="_blank">o.myhre@gmail.com</a>> wrote:<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 dir="ltr"><pre style="box-sizing:border-box;overflow:auto;font-family:"Helvetica Neue","Segoe UI",Arial,sans-serif-regular;font-size:14px;padding:9.5px;margin-top:0px;margin-bottom:10px;line-height:1.42857;color:rgb(51,51,51);word-break:break-all">Checking for 'Stack size mismatch' is currently done in 'java.base/jdk.internal.classfile.impl.StackMapGenerator'.
It would have been nice if this was tested earlier by Codebuilder when the instructions was created.

For example, by keeping track of the stack size curing code building.

It is good programming practice to catch errors as early as possible.</pre></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>