[Checkers] Declarative specification of qualifier hierarchy
Telmo
telmo at MIT.EDU
Wed Mar 26 18:07:38 EDT 2008
(Sorry about not participating on earlier on this discussion; currently my
sleep schedule has little correlation with the sun.)
I'm not sure I agree with the need for a GraphSubtypeRelation.
Javari extends SubtypeRelation with JavariSubtypeRelation; overriding
isSubtypeIgnoringTypeParameters to check annotation hierarchy at simple
annotation level, and JavariChecker isSubtype to just return
relation.isSubtype seems to have been enough to express the following
partial order:
ReadOnly > (no annotation) > Mutable
ReadOnly > RoMaybe > Mutable
all in the same method. This requires subclassing SubtypeRelation for each
new checker, but that seems easier than specifying relationships with
metaannotations at each annotation level.
-Telmo
On Wed, 26 Mar 2008, Matt Papi wrote:
>
>
> 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.
>
>
>
> _______________________________________________
> checkers mailing list
> checkers at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/checkers
>
More information about the checkers
mailing list