Class AccumulationValue
java.lang.Object
org.checkerframework.framework.flow.CFAbstractValue<AccumulationValue>
org.checkerframework.common.accumulation.AccumulationValue
- All Implemented Interfaces:
AbstractValue<AccumulationValue>
AccumulationValue holds additional information about accumulated facts ("values", not to be
confused with "Value" in the name of this class) that cannot be stored in the accumulation type,
because they are not a refinement of that type. This situation occurs for type variables and
wildcards, for which calling
AccumulationTransfer.accumulate(Node, TransferResult, String...)
would otherwise have no effect (since the types are invariant: T is not a supertype
of Accumulator(a) T unless both bounds of T are supertypes of Accumulator(a)). This enables an
accumulation checker (or, typically, a client of that accumulation checker) to resolve
accumulated facts even on types that are type variables. For example, the Resource Leak Checker
uses this facility to check that calls to close() on variables whose type is a type variable have
actually occurred, such as in this example:
public static <T extends java.io.Closeable> void close(
@Owning @MustCall("close") T value) throws Exception {
value.close();
}
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.flow.CFAbstractValue
CFAbstractValue.AnnotationSetCombiner, CFAbstractValue.ValueGlb, CFAbstractValue.ValueLub
-
Field Summary
Fields inherited from class org.checkerframework.framework.flow.CFAbstractValue
analysis, annotations, atypeFactory, qualHierarchy, underlyingType
-
Constructor Summary
ModifierConstructorDescriptionprotected
AccumulationValue
(CFAbstractAnalysis<AccumulationValue, ?, ?> analysis, AnnotationMirrorSet annotations, TypeMirror underlyingType) Creates a new CFAbstractValue. -
Method Summary
Modifier and TypeMethodDescriptionIf the underlying type is a type variable or a wildcard, then this is a set of accumulated values.leastUpperBound
(AccumulationValue other) Compute the least upper bound of two values.mostSpecific
(AccumulationValue other, AccumulationValue backup) Returns the more specific of two valuesthis
andother
.toString()
Returns the string representation.Methods inherited from class org.checkerframework.framework.flow.CFAbstractValue
canBeMissingAnnotations, equals, getAnnotations, getUnderlyingType, greatestLowerBound, hashCode, toStringFullyQualified, toStringSimple, validateSet, widenUpperBound
-
Constructor Details
-
AccumulationValue
protected AccumulationValue(CFAbstractAnalysis<AccumulationValue, ?, ?> analysis, AnnotationMirrorSet annotations, TypeMirror underlyingType) Creates a new CFAbstractValue.- Parameters:
analysis
- the analysis class this value belongs toannotations
- the annotations in this abstract valueunderlyingType
- the underlying (Java) type in this abstract value
-
-
Method Details
-
getAccumulatedValues
If the underlying type is a type variable or a wildcard, then this is a set of accumulated values. Otherwise, it is null.- Returns:
- the set (this is not a copy of the set, but an alias)
-
leastUpperBound
Description copied from interface:AbstractValue
Compute the least upper bound of two values.Important: This method must fulfill the following contract:
- Does not change
this
. - Does not change
other
. - Returns a fresh object which is not aliased yet.
- Returns an object of the same (dynamic) type as
this
, even if the signature is more permissive. - Is commutative.
- Specified by:
leastUpperBound
in interfaceAbstractValue<AccumulationValue>
- Overrides:
leastUpperBound
in classCFAbstractValue<AccumulationValue>
- Does not change
-
mostSpecific
Description copied from class:CFAbstractValue
Returns the more specific of two valuesthis
andother
. If they do not contain information for all hierarchies, then it is possible that information from boththis
andother
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.isSubtypeShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
, then the respective value frombackup
is used.- Overrides:
mostSpecific
in classCFAbstractValue<AccumulationValue>
- Parameters:
other
- the other value to obtain information frombackup
- the value to use ifthis
andother
are incomparable- Returns:
- the more specific of two values
this
andother
-
toString
Description copied from class:CFAbstractValue
Returns the string representation.- Overrides:
toString
in classCFAbstractValue<AccumulationValue>
- Returns:
- the string representation
-