Proposal: Start delivering CustomAttribute and UnknownAttribute in CodeModel traversal as CompoundModel
Brian Goetz
brian.goetz at oracle.com
Thu Feb 27 20:52:17 UTC 2025
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/785208eb/attachment.htm>
More information about the classfile-api-dev
mailing list