<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
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);" class="elementToProof">
<br>
</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
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);" class="elementToProof">
<br>
</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Regards, Chen</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> classfile-api-dev <classfile-api-dev-retn@openjdk.org> on behalf of David Lloyd <david.lloyd@redhat.com><br>
<b>Sent:</b> Tuesday, September 30, 2025 11:07 AM<br>
<b>To:</b> classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Cc:</b> Ladislav Thon <lthon@redhat.com><br>
<b>Subject:</b> DROP_DEBUG and the constant pool</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>
<div class="x_gmail_default" 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 class="x_gmail_default" 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 class="x_gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="x_gmail_default" 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 class="x_gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="x_gmail_default" 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 class="x_gmail_default" 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 class="x_gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="x_gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">- DML • he/him<br>
</div>
</div>
</div>
</div>
</body>
</html>