RuntimeVisibleTypeAnnotations should be a Code attribute, not a Method attribute

Werner Dietl wdietl at
Sun Feb 24 20:13:57 PST 2013

Thanks for the quick reply, Jon! That was all the necessary info.

I pushed this change:

Note how now an annotation on a return type and on a local variable
looks like this in javap:

      stack=1, locals=1, args_size=0
         0: aconst_null
         1: astore_0
         2: invokedynamic #2,  0              // InvokeDynamic
         7: areturn
        line 155: 0
        line 156: 2
        0: #16(): LOCAL_VARIABLE, {start_pc=2, length=6, index=0}
      0: #23(): METHOD_RETURN

That is, there are two separate Attribute sections, first for the
Code, then for the Method.
It would be great if somebody could verify I do this according to the

Steve/SQE, I updated the referenceinfos tests, in particular:


I didn't update all the javac/classfile and javap tests for this.
In particular:


would benefit from reusing logic from


That later class needs to be adapted to also look in Code attributes.
Could you make a patch for type-annotations that I can integrate?

cu, WMD.

On Sun, Feb 24, 2013 at 6:48 PM, Jonathan Gibbons
<jonathan.gibbons at> wrote:
> 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:
>> How can I very whether this is the case or not?
>> I looked at:
>> 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.
> 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 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