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
The annotations in this abstract value.
|
protected TypeMirror |
underlyingType
The underlying (Java) type in this abstract value.
|
Modifier | Constructor and Description |
---|---|
protected |
CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis,
Set<AnnotationMirror> annotations,
TypeMirror underlyingType)
Creates a new CFAbstractValue.
|
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(@Nullable 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()
Returns the string representation.
|
String |
toStringFullyQualified()
Returns the string representation, using fully-qualified names.
|
String |
toStringSimple()
Returns the string representation, using simple (not fully-qualified) names.
|
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
protected CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis, Set<AnnotationMirror> annotations, TypeMirror underlyingType)
analysis
- the analysis class this value belongs toannotations
- the annotations in this abstract valueunderlyingType
- the underlying (Java) type in this abstract valuepublic 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 toStringFullyQualified()
@SideEffectFree public String toStringSimple()
@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>>