RuntimeVisibleTypeAnnotations should be a Code attribute, not a Method attribute

Jonathan Gibbons jonathan.gibbons at oracle.com
Sun Feb 24 18:48:22 PST 2013


On 02/24/2013 06:17 PM, Werner Dietl wrote:
> Jon, all,
>
> Eric Bruneton mentions on the spec-comments list that
> RuntimeVisibleTypeAnnotations should be a Code attribute, not a Method
> attribute:
>
> http://mail.openjdk.java.net/pipermail/type-annotations-spec-comments/2013-February/000021.html
>
> How can I very whether this is the case or not?
>
> I looked at:
>
> com.sun.tools.classfile.ClassWriter.writeMethod(Method)
> com.sun.tools.classfile.Code_attribute.attributes
> com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute
>
> but I don't see where a decision between Code and Method is made...
> both have attributes and I don't see where
> RuntimeInvisibleTypeAnnotations_attribute is put in one or the other.
> Before I spend more time in debugging, do you know where this happens?
>
> Thanks,
> cu, WMD.
>

com.sun.tools.classfile is a simple library underpinning javap, and does not
enforce any validity constraints.

The decision where to put annotations attributes is made in javac.
Start in Names.java to find RuntimeVisibleTypeAnnotations (c. line 280)
then track from there to javac.jvm.ClassWriter in writeTypeAnnotations,
then to writeMemberAttrs (line 635).

-- Jon



More information about the type-annotations-dev mailing list