[External] : labels

Mark Roberts markro at cs.washington.edu
Thu Jan 30 02:20:16 UTC 2025


Rather than change List<CodeElement> to List<Object> to allow labels to be
included, I made a HashMap to associate a Label with the appropriate
CodeElement.  When doing the cob.with(coe) I check the map and do a
cob.labelBinding() as well, if needed.



Works nicely and made it fairly easy to solve the ExceptionCatch problem.



Thanks to all for your help.



Mark



*From:* Chen Liang <chen.l.liang at oracle.com>
*Sent:* Wednesday, January 29, 2025 10:08 AM
*To:* Mark Roberts <markro at cs.washington.edu>; classfile-api-dev at openjdk.org
*Subject:* Re: [External] : labels



Hi Mark,

An approach can be to use a List<Object>. When you process each item, you
pattern match like:



switch(item) {

    case LabelTarget lt -> {} // drop

    case CodeElement coe -> cob.with(coe);

    case Label l -> cob.labelBinding(l);

}



I think that can solve your issue.



And I see the transform problem with stack maps is caused by your inability
to handle labels. This should be able to avoid those issues in the future.



Regards,

Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250129/32d55e60/attachment.htm>


More information about the classfile-api-dev mailing list