[Checkers] QualifierRoot and "SubtypeOf unqualified"

Michael Ernst mernst at csail.mit.edu
Thu Jun 12 01:22:52 EDT 2008


Mahmood-

Thanks for bringing up this point:

> __Unqualified roots, e.g. Interned __
> The Interning type system consist of one qualifier only: @Interned,  
> without its supertype @UnInterned.  To specify this behavior and make  
> the proposal work, we need to figure out a way to specify that it is a  
> subtype of unqualified.

I think there are two separate issues:


1. Should users have to explicitly specify the supertypes of all type
qualifiers, via a @SubtypeOf meta-annotation?

Right now this information is sometimes implicit.  The fact that Interned
is a subtype of unqualified is deduced from the fact that neither
@SubtypeOf nor @QualifierRoot appears on the definition of Interned.  (This
wasn't documented, and it confused me.)

This scheme means that in the common case of a subtype qualifier, the
annotation author writes one less meta-annotation.  However, I think we
should require that every annotation that is part of the type hierarchy
have an explicit @SubtypeOf meta-annotation.  I think this will be clearer
and less error-prone.  Writing one extra meta-annotation doesn't seem
overly burdensome.

So, how should we express this?  Some ideas are

  @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.
  @SubtypeOf({Void.class})  or  @SubtypeOf({Object.class})
    * con: argument is not a qualifier, so this may be confusing.
    * pro: no need to make a fake @Unqualified qualifier.
    * "Object.class" is intended to suggest unqualified Object (does it?).
    * "Void.class" suggests extending nothing.
    * With respect to "Void.class", Mahmood said, "it would be nice to make
      SubtypeOf accept class<? extends Annotation>".  Can you explain?
  @SubtypeOfUnqualified
    * con: it's unfortunate to add a new meta-annotation rather than
      re-using @SubtypeOf.

Are there other ideas, or other pros and cons?


2. How should we express that a given qualifier is the root of the
hierarchy?  Expressing this explicitly enables error-checking, as I noted
above.  But we might want to eliminate the @QualifierRoot meta-annotation
in favor of re-using @SubtypeOf, to avoid having too many different
meta-annotations.  I prefer this syntax:

    @SubtypeOf({})

Note that I do *not* like this syntax to mean "subtype of unqualified"!
We should still document the meaning of "@SubtypeOf({})", but only for
completeness, since it is the same as when the list is non-empty.


                    -Mike



More information about the checkers mailing list