[Checkers] Declarative specification of qualifier hierarchy

Matt Papi mpapi at csail.mit.edu
Wed Mar 26 15:45:25 EDT 2008



Michael Ernst wrote:
>>> I have been working on creating a new 
>>> GraphSubtypeRelation where the checkers would simply specify the subtype 
>>> graph of the annotations.  
>> A quick note: this is an important feature, and since it's been an open 
>> issue for a while, I have some thoughts on its design,
> 
> A declarative specification has a number of advantages.
> 
> Here's an idea that eliminates code from the checker itself:  specify the
> qualifier hierarchy just using meta-annotations, such as
> 
>   @Supertype(Readonly.class)
>   @interface Mutable { ... }
> 
> Also, an @IsDefaultQualifier might specify which annotation is the default
> for backward compatibility.  (This idea of using meta-annotations might
> have come from someone else; I don't remember.)
> 
> I imagine other approaches are possible.
> 
> Perhaps the others could describe their approaches, so that we can choose
> the best design before implementing.

My idea was exactly that -- using meta-annotations. (I don't remember 
whose it was either, but I certainly remember discussing it at a couple 
of meetings.)

In my notes, I had

   @SubtypeOf(ReadOnly.class)
   @interface Mutable { ... }

   @SupertypeOf(Mutable.class)
   @interface ReadOnly { ... }

   @TypeQualifiers({ReadOnly.class, Mutable.class, ROMaybe.class, ...}
   public class JavariChecker { ... }

and note about checking bidirectionality (if you had Mutable SubtypeOf 
ReadOnly but not ReadOnly SupertypeOf Mutable).

I don't really have a preference w.r.t. using Supertype vs. SubtypeOf, etc.

I like the @IsDefaultQualifier idea.


- Matt


P.S. Incidentally, I just found a note that I'd forgotten about: using 
@ImplicitFor meta-annotations to do some of the work that the overriding 
type factories do. For instance:

@ImplicitFor({STRING_LITERAL, PRIMITIVE, ...})
@interface NonNull { ... }

and the framework's type factory could apply implicit annotations 
automatically.





More information about the checkers mailing list