problem with all type annotations on method parameters
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Jan 2 16:47:20 PST 2013
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.
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.
-- Jon
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.
More information about the type-annotations-dev
mailing list