[Checkers] QualifierRoot and "SubtypeOf unqualified"

Mahmood Ali mahmood at MIT.EDU
Thu Jun 12 01:45:29 EDT 2008

Hi Mike,

>  @SubtypeOf({Unqualified.class})
>    * con: @Unqualified would not be used anywhere else in the  
> framework
>      (as noted in Mahmood's message) which may be confusing/ 
> inconsistent.
>    * pro: @Unqualified is an actual qualifier with an intuitive  
> meaning.
I strongly prefer this approach. I implemented this approach and  
didn't check it in yet.  I was a bit worried that a person, who is  
writing new annotations to be used by BasicChecker, will be confused  
by such meta-annotations.

Since there seems to be a concuses (if I understood Telmo correctly)  
regarding this point, I will check in my code tomorrow morning.

>    * With respect to "Void.class", Mahmood said, "it would be nice  
> to make
>      SubtypeOf accept class<? extends Annotation>".  Can you explain?
Currently, SubtypeOf is declared as:
@interface SubtypeOf { Class<? extends Annotation>[] value(); }

This ensures that users can only pass annotation classes to the value  
of SubtypeOf.  Allowing Void.class (or Object.class) would require us  
to relax the type of value to be
Class<?> value(); hence losing the java compiler typecheck benefit.

Actually, the same problem goes to Default, as its value accepts the  
fully qualified name as a String, rather than the class itself.
con: compiler does not enforce or check that the passed string is  
actually a valid class let alone an annotation
pro: It doesn't require annotation to always be in the classpath.   
This problem isn't relevant to the annotation itself.

> express that a given qualifier is the root of the
> hierarchy [...] I prefer this syntax:
>    @SubtypeOf({})
> Note that I do *not* like this syntax to mean "subtype of  
> unqualified"!

Sounds OK with me.


More information about the checkers mailing list