Proposal: Start delivering CustomAttribute and UnknownAttribute in CodeModel traversal as CompoundModel
Chen Liang
chen.l.liang at oracle.com
Thu Feb 27 20:54:45 UTC 2025
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.
________________________________
From: Brian Goetz <brian.goetz at oracle.com>
Sent: Thursday, February 27, 2025 2:52 PM
To: Chen Liang <chen.l.liang at oracle.com>; classfile-api-dev at openjdk.org <classfile-api-dev at openjdk.org>
Subject: Re: Proposal: Start delivering CustomAttribute and UnknownAttribute in CodeModel traversal as CompoundModel
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.)
On 2/27/2025 3:44 PM, Chen Liang wrote:
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.
1.
CustomAttribute or UnknownAttribute are not streamed; they can only be discovered via AttributedElement methods.
2.
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.
3.
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.
Here are my proposals:
1.
To make both CustomAttribute and UnknownAttribute CodeElement, and deliver them in traversals, like as if they are class, method, or field elements.
2.
Inflate and recompute offsets if a bound StackMapTable is written to another code body (such as one with head injection)
3.
Do nothing for type annotation inconsistency for now. This one is a bit hard to determine the best course of action.
What do you think of my proposals for #1 and #2? FYI I have a pull request open for the proposals at https://github.com/openjdk/jdk/pull/23521, feel free to review.
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!)
Regards,
Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250227/740f01d0/attachment-0001.htm>
More information about the classfile-api-dev
mailing list