java.lang.classfile model enumeration order

Brian Goetz brian.goetz at oracle.com
Fri Nov 22 16:02:21 UTC 2024


This is a property of the implementation, but not something that the 
spec guarantees, though.  Also, in the middle of a transformation 
pipeline, there is no longer a "classfile order" to fall back on.  So it 
is best to not assume anything about ordering, unless the ordering is 
part of the semantics (like the bytecodes in a method body.)




On 11/22/2024 5:42 AM, Adam Sotona wrote:
>
> Hi Mark,
>
> Fields and methods are included in the ClassElement stream or iterator 
> in the same order, and this order corresponds to their order in the 
> class file.
>
> This principle is common for the whole API, except for some 
> PseudoInstructions identifying their start and stop positions  in the 
> stream by Labels. These PseudoInstructions are always streamed before 
> respective LabelTargets.
>
> Adam
>
> *From: *classfile-api-dev <classfile-api-dev-retn at openjdk.org> on 
> behalf of Mark Roberts <markro at cs.washington.edu>
> *Date: *Friday, 22 November 2024 at 1:12
> *To: *Chen Liang <chen.l.liang at oracle.com>, 
> classfile-api-dev at openjdk.org <classfile-api-dev at openjdk.org>
> *Subject: *java.lang.classfile model enumeration order
>
> Are there any rules/guarantees that the order of items in 
> ClassModel::methods() will match the order in ‘for (ClassElement ce : 
> cm)’  for the ce elements that are MethodModel?  And also for similar 
> items down the class hierarchy?
>
> Thank you, Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20241122/61cfd9c2/attachment.htm>


More information about the classfile-api-dev mailing list