public abstract class CFAbstractValue<V extends CFAbstractValue<V>> extends Object implements AbstractValue<V>
A value holds a set of annotations and a type mirror. The set of annotations represents the primary annotation on a type; therefore, the set of annotations must have an annotation for each hierarchy unless the type mirror is a type variable or a wildcard that extends a type variable. Both type variables and wildcards may be missing a primary annotation. For this set of annotations, there is an additional constraint that only wildcards that extend type variables can be missing annotations.
In order to compute leastUpperBound(CFAbstractValue)
and mostSpecific(CFAbstractValue, CFAbstractValue)
, the case where one value has an annotation in a
hierarchy and the other does not must be handled. For type variables, the AnnotatedTypeMirror.AnnotatedTypeVariable
for the declaration of the type variable is used. The AnnotatedTypeMirror.AnnotatedTypeVariable
is computed using the type mirror. For wildcards, it is not always
possible to get the AnnotatedTypeMirror.AnnotatedWildcardType
for the type mirror. However, a
CFAbstractValue's type mirror is only a wildcard if the type of some expression is a wildcard.
The type of an expression is only a wildcard because the Checker Framework does not implement
capture conversion. For these uses of uncaptured wildcards, only the primary annotation on the
upper bound is ever used. So, the set of annotations represents the primary annotation on the
wildcard's upper bound. If that upper bound is a type variable, then the set of annotations could
be missing an annotation in a hierarchy.
Modifier and Type | Class and Description |
---|---|
protected class |
CFAbstractValue.AnnotationSetAndTypeMirrorVisitor
Iterates through two sets of AnnotationMirrors by hierarchy and calls one of three methods
depending on whether an annotation exists for the hierarchy in each set.
|
Modifier and Type | Field and Description |
---|---|
protected CFAbstractAnalysis<V,?,?> |
analysis
The analysis class this value belongs to.
|
protected Set<AnnotationMirror> |
annotations |
protected TypeMirror |
underlyingType |
Constructor and Description |
---|
CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis,
Set<AnnotationMirror> annotations,
TypeMirror underlyingType) |
Modifier and Type | Method and Description |
---|---|
boolean |
canBeMissingAnnotations()
Returns whether or not the set of annotations can be missing an annotation for any hierarchy.
|
boolean |
equals(Object obj) |
Set<AnnotationMirror> |
getAnnotations()
Returns a set of annotations.
|
TypeMirror |
getUnderlyingType() |
int |
hashCode() |
V |
leastUpperBound(V other)
Compute the least upper bound of two stores.
|
V |
mostSpecific(V other,
V backup)
Returns the more specific version of two values
this and other . |
String |
toString() |
static boolean |
validateSet(Set<AnnotationMirror> annos,
TypeMirror typeMirror,
QualifierHierarchy hierarchy) |
V |
widenUpperBound(V other) |
protected final CFAbstractAnalysis<V extends CFAbstractValue<V>,?,?> analysis
protected final TypeMirror underlyingType
protected final Set<AnnotationMirror> annotations
public CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis, Set<AnnotationMirror> annotations, TypeMirror underlyingType)
public static boolean validateSet(Set<AnnotationMirror> annos, TypeMirror typeMirror, QualifierHierarchy hierarchy)
public boolean canBeMissingAnnotations()
@Pure public Set<AnnotationMirror> getAnnotations()
canBeMissingAnnotations()
returns true, then the
set of annotations may not have an annotation for every hierarchy.
To get the single annotation in a particular hierarchy, use QualifierHierarchy.findAnnotationInHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror>, javax.lang.model.element.AnnotationMirror)
.
@Pure public TypeMirror getUnderlyingType()
@SideEffectFree public String toString()
public V mostSpecific(V other, V backup)
this
and other
. If they do
not contain information for all hierarchies, then it is possible that information from both
this
and other
are taken.
If neither of the two is more specific for one of the hierarchies (i.e., if the two are
incomparable as determined by QualifierHierarchy.isSubtype(AnnotationMirror,
AnnotationMirror)
, then the respective value from backup
is used.
public V leastUpperBound(V other)
AbstractValue
Important: This method must fulfill the following contract:
this
.
other
.
this
, even if the signature is
more permissive.
leastUpperBound
in interface AbstractValue<V extends CFAbstractValue<V>>