<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Ah, for "consistency" I do not mean their structural consistency, but the consistency of the ClassFile.DebugElementsOption policy. For other debug like locals and CRT they are dropped both from reading and writing; type annotations are only dropped from reading,
 but not for writing.</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> Brian Goetz <brian.goetz@oracle.com><br>
<b>Sent:</b> Thursday, February 27, 2025 2:52 PM<br>
<b>To:</b> Chen Liang <chen.l.liang@oracle.com>; classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Subject:</b> Re: Proposal: Start delivering CustomAttribute and UnknownAttribute in CodeModel traversal as CompoundModel</font>
<div> </div>
</div>
<div><font size="4" face="monospace">I think there really is nothing to be done about type annotation consistency, and the cost of trying to do so would be really high (both in effort and in runtime cost.) 
</font><br>
<br>
<div class="x_moz-cite-prefix">On 2/27/2025 3:44 PM, Chen Liang wrote:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
In the recent documentation cleanup for the ClassFile API, I noted there are a few inconsistencies in the handling of attributes on the Code attribute.</div>
<ol start="1" data-editing-info="{"applyListStyleFromLevel":false,"orderedStyleType":1}" style="list-style-type:decimal">
<li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">CustomAttribute or UnknownAttribute are not streamed; they can only be discovered via AttributedElement methods.</div>
</li><li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">While most attributes with LABELS AttributeStability is not directly writable, StackMapTable is; yet it does not recompute the BCI offsets if they are no longer compatible.</div>
</li><li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">Type annotations in Code are not streamed if debug elements are off; yet CodeBuilder accepts them if users provide them. Other debug elements like local vars are dropped on both sides.</div>
</li></ol>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
Here are my proposals:</div>
<ol start="1" data-editing-info="{"applyListStyleFromLevel":false,"orderedStyleType":1}" style="list-style-type:decimal">
<li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">To make both CustomAttribute and UnknownAttribute CodeElement, and deliver them in traversals, like as if they are class, method, or field elements.</div>
</li><li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">Inflate and recompute offsets if a bound StackMapTable is written to another code body (such as one with head injection)</div>
</li><li style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div class="x_elementToProof">Do nothing for type annotation inconsistency for now. This one is a bit hard to determine the best course of action.</div>
</li></ol>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
What do you think of my proposals for #1 and #2? FYI I have a pull request open for the proposals at
<a href="https://github.com/openjdk/jdk/pull/23521" class="x_moz-txt-link-freetext">
https://github.com/openjdk/jdk/pull/23521</a>, feel free to review.</div>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
Also, I understand there is a demand for Labels in user attributes. That topic is a bit more complex, and I wish to address in another mail thread. (Feel free to start a thread about it, too!)</div>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
Regards,</div>
<div class="x_elementToProof" style="font-family:"Calibri Light","Helvetica Light",sans-serif; font-size:12pt; color:rgb(0,0,0)">
Chen Liang</div>
</blockquote>
<br>
</div>
</body>
</html>