Class UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy
- java.lang.Object
-
- org.checkerframework.framework.type.QualifierHierarchy
-
- org.checkerframework.framework.type.ElementQualifierHierarchy
-
- org.checkerframework.checker.index.upperbound.UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy
-
- Enclosing class:
- UpperBoundAnnotatedTypeFactory
protected final class UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy extends ElementQualifierHierarchy
The qualifier hierarchy for the upperbound type system.
-
-
Field Summary
-
Fields inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
bottoms, bottomsMap, kindToElementlessQualifier, qualifierKindHierarchy, tops, topsMap
-
Fields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.lang.model.element.AnnotationMirror
greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.boolean
isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy, ignoring Java basetypes.javax.lang.model.element.AnnotationMirror
leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Determines the least upper bound of a1 and a2.int
numberOfIterationsBeforeWidening()
Returns the number of iterations dataflow should perform beforeQualifierHierarchy.widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should never be called.javax.lang.model.element.AnnotationMirror
widenedUpperBound(javax.lang.model.element.AnnotationMirror newQualifier, javax.lang.model.element.AnnotationMirror previousQualifier)
If the qualifier hierarchy has an infinite ascending chain, then the dataflow analysis might never reach a fixed point.-
Methods inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
createBottomsMap, createElementlessQualifierMap, createQualifierKindHierarchy, createTopsMap, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getBottomAnnotation, getBottomAnnotations, getPolymorphicAnnotation, getQualifierKind, getQualifierKind, getTopAnnotation, getTopAnnotations, isPolymorphicQualifier, isValid
-
Methods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsShallow, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsShallow, updateMappingToMutableSet
-
-
-
-
Method Detail
-
greatestLowerBoundQualifiers
public javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Description copied from class:QualifierHierarchy
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.- Specified by:
greatestLowerBoundQualifiers
in classQualifierHierarchy
- Parameters:
a1
- first qualifiera2
- second qualifier- Returns:
- greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
-
leastUpperBoundQualifiers
public javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Determines the least upper bound of a1 and a2. If a1 and a2 are both the same type of Value annotation, then the LUB is the result of taking the intersection of values from both a1 and a2.- Specified by:
leastUpperBoundQualifiers
in classQualifierHierarchy
- Parameters:
a1
- the first qualifier; may not be in the same hierarchy asqualifier2
a2
- the second qualifier; may not be in the same hierarchy asqualifier1
- Returns:
- the least upper bound of a1 and a2
-
widenedUpperBound
public javax.lang.model.element.AnnotationMirror widenedUpperBound(javax.lang.model.element.AnnotationMirror newQualifier, javax.lang.model.element.AnnotationMirror previousQualifier)
Description copied from class:QualifierHierarchy
If the qualifier hierarchy has an infinite ascending chain, then the dataflow analysis might never reach a fixed point. To prevent this, implement this method such that it returns an upper bound for the two qualifiers that is a strict super type of the least upper bound. If this method is implemented, also overrideQualifierHierarchy.numberOfIterationsBeforeWidening()
to return a positive number.newQualifier
is newest qualifier dataflow computed for some expression andpreviousQualifier
is the qualifier dataflow computed on the last iteration.If the qualifier hierarchy has no infinite ascending chain, returns the least upper bound of the two annotations.
- Overrides:
widenedUpperBound
in classQualifierHierarchy
- Parameters:
newQualifier
- new qualifier dataflow computed for some expression; must be in the same hierarchy aspreviousQualifier
previousQualifier
- the previous qualifier dataflow computed on the last iteration; must be in the same hierarchy aspreviousQualifier
- Returns:
- an upper bound that is higher than the least upper bound of newQualifier and previousQualifier (or the lub if the qualifier hierarchy does not require this)
-
numberOfIterationsBeforeWidening
public int numberOfIterationsBeforeWidening()
Description copied from class:QualifierHierarchy
Returns the number of iterations dataflow should perform beforeQualifierHierarchy.widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should never be called.- Overrides:
numberOfIterationsBeforeWidening
in classQualifierHierarchy
- Returns:
- the number of iterations dataflow should perform before
QualifierHierarchy.widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should never be called.
-
isSubtypeQualifiers
public boolean isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy, ignoring Java basetypes.Clients should generally call
QualifierHierarchy.isSubtypeShallow(javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror, javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror)
. However, subtypes should generally override this method (if needed).This method behaves the same as
QualifierHierarchy.isSubtypeQualifiersOnly(AnnotationMirror, AnnotationMirror)
, which calls this method. This method is for clients inside the framework, and it hasprotected
access to prevent use by clients outside the framework. This makes it easy to find places where code outside the framework is ignoring Java basetypes -- at calls toQualifierHierarchy.isSubtypeQualifiersOnly(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)
.Computes subtyping as per the subtyping in the qualifier hierarchy structure unless both annotations have the same class. In this case, rhs is a subtype of lhs iff rhs contains every element of lhs.
- Specified by:
isSubtypeQualifiers
in classQualifierHierarchy
- Parameters:
subAnno
- possible subqualifiersuperAnno
- possible superqualifier- Returns:
- true iff
subQualifier
is a subqualifier of, or equal to,superQualifier
-
-