[Checkers] Checker Framework code review pre-comments

Mahmood Ali mahmood at MIT.EDU
Mon Jun 2 00:14:38 EDT 2008


Greetings,

I wanted to respond to some notes in an email format.

>  AnnotationRelations.isSubType(Collection, Collection)
The specification is a bit odd, since it returns true if any  
annotation in the first collection is a subtype to one annotation in  
the second collection.  I had two cases while thinking about it:
1. Javari for a while had RoMaybe along with other annotations.   
Having isSubtype(Collection, Collection) enabled us to let  
JavariChecker uses AnnotationRelations easily.  We didn't have this  
method in the first design.

2. As an implementation detail, IGJ allows @AssignsFields and @I to be  
in the same type.  A self type (type of 'this') may be @AssignsFields  
@I FOO, where AssignsFields would allow for invocation of other  
AssignsFields methods and @I would allow 'this' reference to escape as  
'@I'.  This could easily be changed.

>  For annotations (AnnotationMirror) what is the difference between
>  canonical names and qualified names?  Why are names used for equality
>  checking, rather than overriding the AnnotationMirror.equals method?
>  What is the contract of equality for AnnotationMirror?
>
>  AnnotationUtils.isSame

This is a bit complicated issue.  There are two classes of interest  
here: AnnotationMirror (and its implementation AnnotationMirrorImpl),  
AnnotationValue (and its implementation AnnotationValueImpl).  Both  
classes are symbols of annotations, but each instance represent a  
unique annotation declaration and its value; so two instances are not  
equal if they have the same annotation type and values but are for  
different declaration (e.g. annotations for different variables,  
methods).

We are interested in another form of equality, where two annotations  
are equal if their types and their values are equal.  We had multiple  
options:
1. Create a new annotation representation to wrap all annotationmirror  
coming from the compiler.
2. Create new set of equality methods.  A simple one was using the  
qualified name and the AnnotationMirrorImpl, AnnotationValueImpl,  
implement a nice toString().

- Mahmood



More information about the checkers mailing list