[Checkers] @ImplicitFor meta-annotation

Matt Papi mpapi at csail.mit.edu
Sat Apr 12 16:29:54 EDT 2008


Yesterday, I made some refactorings to simplify
TreePreAnnotator/TypePostAnnotator in the type factories; they didn't
make it into the release because they broke some things and I ran out
of time. However, while working on them I realized that having
abstract pre- & post-annotators in the framework would make
@ImplicitFor almost trivial. [Aside: TreePreAnnotator and
TypePostAnnotator are bad names, since there's no longer a
super.getAnnotatedType call to come before or after.] One would write,
e.g.,

@ImplicitFor(trees={NEW_CLASS, NEW_ARRAY}, types={PACKAGE},
typeClasses={PrimitiveTree.class})
@interface NonNull {}

or

@ImplicitFor(treeClasses={LiteralTree.class}, typeClasses={PrimitiveType.class})
@interface Interned {}

(where tree/typeClasses are a convenience, so you can say
LiteralTree.class without having to write NULL_LITERAL, CHAR_LITERAL,
etc.). Even a simple implementation like the one above seems like it
would be able to remove at least:
- 2 methods from Interned
- 4 methods from Javari
- 4 from NonNull
- 1 from IGJ
and a more complex one could have an even greater effect. What do you
think of the above design?

I currently have this simple implementation in my local modifications
-- it took about 15 minutes on top of my existing refactorings for
TreePre/TypePostAnnotator -- and tried it with Interned, successfully
removing two methods from InternedAnnotatedTypeFactory. If there no
major objections to the above design, does any mind if I add my
implementation to SVN?

- Matt



More information about the checkers mailing list