[Checkers] QualifierRoot
Mahmood Ali
mahmood at MIT.EDU
Wed Jun 11 16:44:02 EDT 2008
On Jun 11, 2008, at 4:27 PM, Telmo wrote:
>> 2. Have a non-annotation class, e.g. Void.class; so Interned would
>> be @SubtypeOf({Void.class}). But it it would be nice to make
>> SubtypeOf accept class<? extends Annotation>.
>
> I prefer the approach 2, having an annotation that counts as non-
> annotation. Can't we create a @Unqualified annotation that is seen
> on AnnotatedTypeMirrors by default if it doesn't contain any
> annotations?
>
I assume you meant by that the preffered approach as specified in the
paragraph before thw quoted two options. Void is not an annotation,
while Unqualified is.
The problem with having AnnotatedTypeMirror returning Unqualified when
not annotated, is that it would complicate the code on the client
side. Currently, the current common idiom of
if (type.getAnnotations().isEmpty()) type.addAnnotation(...)
will be broken. We would need to replace it with
// Depending on implementation choices, might need
type.removeAnnotation()
if (type.hasAnnotation(UNQUALIFIED)) { type.addAnnotation(...); }
I think the first way is clearer and more readable.
>> List<@QReadOnly Date> l = ...;
>> @ReadOnly Date roDate = ...;
>> lst.add(roDate); // invalid
>
> I believed the code above would be valid. I'm not sure about the
> current framework behavior with regards to that.
Errr... I don't think so. After thinking about, it should be
invalid. Consider:
List<@Mutable Date> mutableDates new ArrayList<@Mutable Date>();
List<@QReadOnly Date> tmpList = mutableDates;
tmpList.add(roDate);
@Mutable Date mutableReference = mutableDates.get(1);
I checked in QReadOnlys test. It passes now. Please confirm that
it's actually doing the right thing.
- Mahmood
More information about the checkers
mailing list