problem with all type annotations on method parameters

Werner Dietl wdietl at gmail.com
Wed Jan 2 17:56:03 PST 2013


Thanks for these comments, Jon!

On Wed, Jan 2, 2013 at 4:47 PM, Jonathan Gibbons
<jonathan.gibbons at oracle.com> wrote:
> It seems there may be a problem with when type annotations are processed on
> a method declaration.
>
> If I read the code correctly, type annotations are separated from decl
> annotations by the code in TypeAnnotations.organizeTypeAnnotations.
> (TypeAnnotations is itself a weird class; more on that later).
>
> TypeAnnotations.organizeTypeAnnotations is called from Attr.attribClassBody,
> which is (obviously) called during Attr. This is too late, as far as javadoc
> is concerned, which expects evrything it needs (i.e. all signature info for
> classes, methods and fields) to be completed by the end of
> Enter/MemberEnter.  javadoc does not run the Attr phase, and so javadoc is
> not seeing many type annotations.  The processing of type annotations, and
> the separation of type and decl annotations therefore needs to be done
> earlier.
>
> It is also somewhat strange to have TypeAnnotations use its own internal
> TreeScanner, making it seem like an extra compiler-phase triggered within
> Attr. It would seem that, at a minimum, we need to separate the processing
> needed for any block of code (method body, initialization block, etc) from
> the processing needed for class and member declarations.

I can introduce this separation again.
There are unfortunately no test cases for the annotations in Types. Is
there a way we could test this, independently of javadoc?


> Finally, TypeAnnotations does not follow the typical javac architectural
> methodology.  It is written as a public class containing a single public
> static method, and as such, as to be passed contextual info like Symtab,
> Names and Log. It would be more obvious to make the class available from a
> Context in the standard way.

As there is only exactly one call of that single public method, it
seemed easier to just make it callable instead of requiring creating a
new instance first.
I'll see how to improve this.


> P.S. I also note the following comment at line 320, which might indicate a
> blocker for progress on javadoc.
>                 // TODO: method receiver type annotations don't work. There
> is a strange
>                 // interaction with arrays.

This is an old comment and I'm not sure it is still valid.
I will investigate.

cu, WMD.

-- 
http://www.google.com/profiles/wdietl


More information about the type-annotations-dev mailing list