are CodeElements unique?

Paul Sandoz paul.sandoz at oracle.com
Wed May 7 18:00:23 UTC 2025


Oops apologies, I thought this was a Babylon code model question, please ignore!

Paul.

On May 7, 2025, at 10:59 AM, paul.sandoz at oracle.com wrote:

Yes. All code items have identity, and their equals/hashCode is defined in terms of that identity i.e., same implementation as for Object.

A reflected method body or lambda body must have only one code model instance associated with it. (We have been fixing some a bugs to ensure this is guaranteed.)

Paul.

On May 7, 2025, at 10:43 AM, Mark Roberts <markro at cs.washington.edu> wrote:

Are the members of a CodeModel.elementList() unique?  Specifically, is it safe to use a CodeElement as the key value in a Map?

Thank you,
Mark


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250507/5f2daa72/attachment-0001.htm>


More information about the classfile-api-dev mailing list