<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">OK, shall I prepare a bug report and patch? Thanks.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Sep 30, 2025 at 2:55 PM Chen Liang <<a href="mailto:chen.l.liang@oracle.com">chen.l.liang@oracle.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 class="msg8917357031742588717">
<div dir="ltr">
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi David, this seems a legitimate bug.</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
I think we can bypass this by using the TemporaryConstantPool.INSTANCE to construct the UTF-8 entries.</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards, Chen</div>
<div id="m_-3732124551141255202appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="m_-3732124551141255202divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> classfile-api-dev <<a href="mailto:classfile-api-dev-retn@openjdk.org" target="_blank">classfile-api-dev-retn@openjdk.org</a>> on behalf of David Lloyd <<a href="mailto:david.lloyd@redhat.com" target="_blank">david.lloyd@redhat.com</a>><br>
<b>Sent:</b> Tuesday, September 30, 2025 11:07 AM<br>
<b>To:</b> <a href="mailto:classfile-api-dev@openjdk.org" target="_blank">classfile-api-dev@openjdk.org</a> <<a href="mailto:classfile-api-dev@openjdk.org" target="_blank">classfile-api-dev@openjdk.org</a>><br>
<b>Cc:</b> Ladislav Thon <<a href="mailto:lthon@redhat.com" target="_blank">lthon@redhat.com</a>><br>
<b>Subject:</b> DROP_DEBUG and the constant pool</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>
<div style="font-family:arial,helvetica,sans-serif">We've observed that when using `DROP_DEBUG` in conjunction with `CodeBuilder#localVariable` and/or `localVariableType`, some (otherwise useless) constant pool entries are still being
created (which contain, I believe, both the variable name and descriptor). This was observed using a backport of the JDK classfile API based on JDK 25.</div>
<br clear="all">
</div>
<div>
<div style="font-family:arial,helvetica,sans-serif">Would this be expected behavior? Is there a separate step needed to clean the constant pool for cases like this?</div>
</div>
<div style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div style="font-family:arial,helvetica,sans-serif">It looks to me to be the consequence of how the default methods for local variable creation are implemented, e.g.:</div>
<div style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div style="font-family:arial,helvetica,sans-serif"> default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) {<br>
return localVariable(slot,<br>
constantPool().utf8Entry(name),<br>
constantPool().utf8Entry(descriptor),<br>
startScope, endScope);<br>
}<br>
</div>
<div><br>
</div>
<div>
<div style="font-family:arial,helvetica,sans-serif">The constant pool is accessed even when `DROP_DEBUG` is enabled, because that flag is used later on in the process, and it seems that these entries are never dropped, even if they are
unused.</div>
<br>
</div>
<span>-- </span><br>
<div dir="ltr">
<div dir="ltr">- DML • he/him<br>
</div>
</div>
</div>
</div>
</div>
</div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him<br></div></div>