public abstract class CFAbstractValue<V extends CFAbstractValue<V>> extends java.lang.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 java.util.Set<javax.lang.model.element.AnnotationMirror> |
annotations |
protected javax.lang.model.type.TypeMirror |
underlyingType |
Constructor and Description |
---|
CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis,
java.util.Set<javax.lang.model.element.AnnotationMirror> annotations,
javax.lang.model.type.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(java.lang.Object obj) |
java.util.Set<javax.lang.model.element.AnnotationMirror> |
getAnnotations()
Returns a set of annotations.
|
javax.lang.model.type.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 . |
java.lang.String |
toString() |
static boolean |
validateSet(java.util.Set<javax.lang.model.element.AnnotationMirror> annos,
javax.lang.model.type.TypeMirror typeMirror,
QualifierHierarchy hierarchy) |
V |
widenUpperBound(V other) |
protected final CFAbstractAnalysis<V extends CFAbstractValue<V>,?,?> analysis
protected final javax.lang.model.type.TypeMirror underlyingType
protected final java.util.Set<javax.lang.model.element.AnnotationMirror> annotations
public CFAbstractValue(CFAbstractAnalysis<V,?,?> analysis, java.util.Set<javax.lang.model.element.AnnotationMirror> annotations, javax.lang.model.type.TypeMirror underlyingType)
public static boolean validateSet(java.util.Set<javax.lang.model.element.AnnotationMirror> annos, javax.lang.model.type.TypeMirror typeMirror, QualifierHierarchy hierarchy)
public boolean canBeMissingAnnotations()
@Pure public java.util.Set<javax.lang.model.element.AnnotationMirror> getAnnotations()
canBeMissingAnnotations()
returns true, then the
set of annotations may not have an annotation for every hierarchy.@Pure public javax.lang.model.type.TypeMirror getUnderlyingType()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
@Pure public int hashCode()
hashCode
in class java.lang.Object
@SideEffectFree public java.lang.String toString()
toString
in class java.lang.Object
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>>