Storing annotations on exception parameters

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Jan 22 20:56:24 PST 2013


On 01/22/2013 08:48 PM, Jonathan Gibbons wrote:
> On 01/22/2013 08:30 PM, Werner Dietl wrote:
>> Do you know what operations happen to the exception type between the 
>> end of
>> com.sun.tools.javac.comp.Attr.attribClassBody
>> (where I call TypeAnnotations.organizeTypeAnnotationsBodies and still
>> have AnnotatedTypes)
>> and Gen.genCatch where I only see unannotated types?
>
> Well, the tree goes through TransTypes and Lower, and in a separate
> thread, this morning Maurizio warned of the possibility of losing
> annotations during erasure (TransTypes).
>
> And if you follow the supertypes involved in the erasure visitor, 
> Types.java, 2003
> you end up soon enough at the following couple of lines in 
> Types.defaultTypeVisitor,
> round about line 4199:
>
>         // Pretend annotations don't exist
>         public R visitAnnotatedType(AnnotatedType t, S s) { return 
> visit(t.underlyingType, s); }
>
> -- Jon

At a guess, I would suggest trying, in the erasure visitor, override 
visitAnnotatedType,
separate the type-annotations from the underlying type, then compose new
AnnotatedType from the erasure of the type annotations and the erasure 
of the
underlying type.

-- Jon


More information about the type-annotations-dev mailing list