From 45dd8372f8d5aac811ae4b643dcd70ae3a5a916b Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Fri, 29 Mar 2024 15:14:02 -0400 Subject: [PATCH] Adpat to new CF version --- .ci-build-without-test.sh | 8 ++-- scripts/inference-dev | 3 +- .../ExistentialVariableInserter.java | 2 +- .../InferenceAnnotatedTypeFactory.java | 4 +- .../InferenceQualifierHierarchy.java | 39 +++++++++++-------- .../inference/InferenceTypeHierarchy.java | 2 +- src/checkers/inference/InferenceVisitor.java | 15 +++---- src/checkers/inference/VariableAnnotator.java | 21 +++++----- .../inference/dataflow/InferenceTransfer.java | 7 ++-- .../inference/dataflow/InferenceValue.java | 2 +- .../inference/model/ComparableConstraint.java | 4 +- .../inference/model/SubtypeConstraint.java | 2 +- .../inference/solver/frontend/Lattice.java | 2 +- .../solver/frontend/LatticeBuilder.java | 4 +- src/checkers/inference/util/ASTPathUtil.java | 5 ++- .../util/ConstantToVariableAnnotator.java | 2 +- src/checkers/inference/util/JaifBuilder.java | 3 +- .../DataflowAnnotatedTypeFactory.java | 2 +- .../InterningAnnotatedTypeFactory.java | 4 +- .../SimpleFlowAnnotatedTypeFactory.java | 24 ++++++------ .../inference/test/CFInferenceTest.java | 3 +- 21 files changed, 86 insertions(+), 72 deletions(-) diff --git a/.ci-build-without-test.sh b/.ci-build-without-test.sh index 3aa0f97f6..288c81c0d 100755 --- a/.ci-build-without-test.sh +++ b/.ci-build-without-test.sh @@ -24,10 +24,10 @@ export AFU="${AFU:-../annotation-tools/annotation-file-utilities}" AT=$(dirname "${AFU}") ## Build annotation-tools (Annotation File Utilities) -/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" -if [ ! -d ../annotation-tools ] ; then - ln -s "${AT}" ../annotation-tools -fi +#/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" +#if [ ! -d ../annotation-tools ] ; then +# ln -s "${AT}" ../annotation-tools +#fi echo "Running: (cd ${AT} && ./.build-without-test.sh)" (cd "${AT}" && ./.build-without-test.sh) diff --git a/scripts/inference-dev b/scripts/inference-dev index f87e0cd27..3d587e4fe 100755 --- a/scripts/inference-dev +++ b/scripts/inference-dev @@ -34,7 +34,8 @@ libDir="$cfiDir"/lib CFBuild="${cfDir}"/dataflow/"${classes}":"${cfDir}"/javacutil/"${classes}":"${cfDir}"/framework/"${classes}":"${cfDir}"/framework/"${resources}" CFBuild="${CFBuild}":"${cfDir}"/checker/"${classes}":"${cfDir}"/checker/"${resources}":"${annoToolsDir}"/scene-lib/bin -CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.25.2.jar:"${afuDir}"/annotation-file-utilities-all.jar +#CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.25.5.jar:"${afuDir}"/annotation-file-utilities-all.jar +CFDepJars="${afuDir}"/annotation-file-utilities-all.jar # sanity check: ensure each jar in CFDepJars actually exists in the file system # total number of jars diff --git a/src/checkers/inference/ExistentialVariableInserter.java b/src/checkers/inference/ExistentialVariableInserter.java index 0d61038ae..8d293ec53 100644 --- a/src/checkers/inference/ExistentialVariableInserter.java +++ b/src/checkers/inference/ExistentialVariableInserter.java @@ -159,7 +159,7 @@ public void matchAndReplacePrimary(final AnnotatedTypeMirror typeUse, final Anno } @Override - protected String defaultErrorMessage(org.checkerframework.framework.type.AnnotatedTypeMirror type1, org.checkerframework.framework.type.AnnotatedTypeMirror type2, Void aVoid) { + public String defaultErrorMessage(org.checkerframework.framework.type.AnnotatedTypeMirror type1, org.checkerframework.framework.type.AnnotatedTypeMirror type2, Void aVoid) { return "Input types should have identical structures. Input types are limited to those types" + "that can appear in a type variable bound:\n" + "type1=" + type1 + "\n" diff --git a/src/checkers/inference/InferenceAnnotatedTypeFactory.java b/src/checkers/inference/InferenceAnnotatedTypeFactory.java index 879852b71..872c7f4e3 100644 --- a/src/checkers/inference/InferenceAnnotatedTypeFactory.java +++ b/src/checkers/inference/InferenceAnnotatedTypeFactory.java @@ -228,7 +228,7 @@ protected TypeHierarchy createTypeHierarchy() { @Override protected QualifierHierarchy createQualifierHierarchy() { - return new InferenceQualifierHierarchy(getSupportedTypeQualifiers(), elements); + return new InferenceQualifierHierarchy(getSupportedTypeQualifiers(), elements, realTypeFactory); } @Override @@ -352,7 +352,7 @@ public ParameterizedExecutableType methodFromUse(final MethodInvocationTree meth // Adapt parameters, which makes parameters and arguments be the same size for later // checking. List parameters = - AnnotatedTypes.adaptParameters(this, method, methodInvocationTree.getArguments()); + AnnotatedTypes.adaptParameters(this, method, methodInvocationTree.getArguments(), null); method.setParameterTypes(parameters); inferencePoly.replacePolys(methodInvocationTree, method); diff --git a/src/checkers/inference/InferenceQualifierHierarchy.java b/src/checkers/inference/InferenceQualifierHierarchy.java index 67ca38d18..83e500ed7 100644 --- a/src/checkers/inference/InferenceQualifierHierarchy.java +++ b/src/checkers/inference/InferenceQualifierHierarchy.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.type.ElementQualifierHierarchy; +import org.checkerframework.framework.type.GenericAnnotatedTypeFactory; import org.checkerframework.framework.type.QualifierHierarchy; import org.checkerframework.framework.util.DefaultQualifierKindHierarchy; import org.checkerframework.framework.util.QualifierKind; @@ -19,6 +20,7 @@ import org.plumelib.util.StringsPlume; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import java.lang.annotation.Annotation; import java.util.Collection; @@ -42,9 +44,10 @@ public class InferenceQualifierHierarchy extends ElementQualifierHierarchy { public InferenceQualifierHierarchy( Collection> qualifierClasses, - Elements elements + Elements elements, + GenericAnnotatedTypeFactory atypeFactory ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, atypeFactory); slotMgr = inferenceMain.getSlotManager(); constraintMgr = inferenceMain.getConstraintManager(); @@ -137,8 +140,10 @@ public static AnnotationMirror findVarAnnot(final Iterable rhsAnnos, - final Collection lhsAnnos ) { + public boolean isSubtypeShallow(final Collection rhsAnnos, + TypeMirror subType, + final Collection lhsAnnos, + TypeMirror superType ) { final AnnotationMirror rhsVarAnnot = findVarAnnot(rhsAnnos); final AnnotationMirror lhsVarAnnot = findVarAnnot(lhsAnnos); @@ -156,11 +161,11 @@ public boolean isSubtype(final Collection rhsAnnos, + " rhs=" + StringsPlume.join(", ", rhsAnnos) + "\n" + " lhs=" + StringsPlume.join(", ", lhsAnnos ); - return isSubtype(rhsVarAnnot, lhsVarAnnot); + return isSubtypeQualifiers(rhsVarAnnot, lhsVarAnnot); } @Override - public boolean isSubtype(final AnnotationMirror subtype, final AnnotationMirror supertype) { + public boolean isSubtypeQualifiers(final AnnotationMirror subtype, final AnnotationMirror supertype) { // NOTE: subtype and supertype are nullable because, for example, in BaseTypeVisitor::checkConstructorInvocation, // findAnnotationInSameHierarchy may return null since @VarAnnot and some constant real qualifier @@ -187,19 +192,21 @@ public boolean isSubtype(final AnnotationMirror subtype, final AnnotationMirror } @Override - public AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) { + public AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { return merge(a1, a2, false); } @Override - public Set leastUpperBounds( + public Set leastUpperBoundsShallow( Collection annos1, - Collection annos2) { + TypeMirror tm1, + Collection annos2, + TypeMirror tm2) { if (InferenceMain.isHackMode(annos1.size() != annos2.size())) { Set result = new AnnotationMirrorSet(); for (AnnotationMirror a1 : annos1) { for (AnnotationMirror a2 : annos2) { - AnnotationMirror lub = leastUpperBound(a1, a2); + AnnotationMirror lub = leastUpperBoundQualifiersOnly(a1, a2); if (lub != null) { result.add(lub); } @@ -207,11 +214,11 @@ public Set leastUpperBounds( } return result; } - return super.leastUpperBounds(annos1, annos2); + return super.leastUpperBoundsShallow(annos1, tm1, annos2, tm2); } @Override - public AnnotationMirror leastUpperBound(final AnnotationMirror a1, final AnnotationMirror a2) { + public AnnotationMirror leastUpperBoundQualifiers(final AnnotationMirror a1, final AnnotationMirror a2) { return merge(a1, a2, true); } @@ -239,9 +246,9 @@ private AnnotationMirror merge(final AnnotationMirror a1, final AnnotationMirror if (!isA1VarAnnot && !isA2VarAnnot) { if (isLub) { - return realQualifierHierarchy.leastUpperBound(a1, a2); + return realQualifierHierarchy.leastUpperBoundQualifiersOnly(a1, a2); } else { - return realQualifierHierarchy.greatestLowerBound(a1, a2); + return realQualifierHierarchy.greatestLowerBoundQualifiersOnly(a1, a2); } } else { // two annotations are not under the same qualifier hierarchy @@ -262,9 +269,9 @@ private AnnotationMirror merge(final AnnotationMirror a1, final AnnotationMirror AnnotationMirror mergedType; if (isLub) { - mergedType = realQualifierHierarchy.leastUpperBound(realAnno1, realAnno2); + mergedType = realQualifierHierarchy.leastUpperBoundQualifiersOnly(realAnno1, realAnno2); } else { - mergedType = realQualifierHierarchy.greatestLowerBound(realAnno1, realAnno2); + mergedType = realQualifierHierarchy.greatestLowerBoundQualifiersOnly(realAnno1, realAnno2); } Slot constantSlot = slotMgr.createConstantSlot(mergedType); diff --git a/src/checkers/inference/InferenceTypeHierarchy.java b/src/checkers/inference/InferenceTypeHierarchy.java index 13c93d113..64aa32ab7 100644 --- a/src/checkers/inference/InferenceTypeHierarchy.java +++ b/src/checkers/inference/InferenceTypeHierarchy.java @@ -50,7 +50,7 @@ public boolean areEqual(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2) { public StructuralEqualityComparer createEqualityComparer() { return new InferenceEqualityComparer( this.areEqualVisitHistory, - InferenceQualifierHierarchy.findVarAnnot(qualifierHierarchy.getTopAnnotations())); + InferenceQualifierHierarchy.findVarAnnot(qualHierarchy.getTopAnnotations())); } private static class InferenceEqualityComparer extends StructuralEqualityComparer { diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index df07527fa..c24f01c88 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -489,13 +489,13 @@ protected void checkTypeArguments(Tree toptree, * @param extraArgs arguments to the error message key, before "found" and "expected" types */ @Override - protected void commonAssignmentCheck( + protected boolean commonAssignmentCheck( Tree varTree, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) { if (!validateTypeOf(varTree)) { - return; + return true; } AnnotatedTypeMirror var; @@ -516,11 +516,11 @@ protected void commonAssignmentCheck( assert var != null : "no variable found for tree: " + varTree; - commonAssignmentCheck(var, valueExp, errorKey, extraArgs); + return commonAssignmentCheck(var, valueExp, errorKey, extraArgs); } @Override - protected void commonAssignmentCheck( + protected boolean commonAssignmentCheck( AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @@ -583,7 +583,7 @@ protected void commonAssignmentCheck( mono.getCanonicalName(), mono.getCanonicalName(), valueType.toString()); - return; + return true; } } } @@ -606,6 +606,7 @@ protected void commonAssignmentCheck( errorKey, ArraysPlume.concatenate(extraArgs, valueTypeString, varTypeString)); } + return success; // ####### End Copied Code ######## } @@ -805,7 +806,7 @@ protected void checkExceptionParameter(CatchTree node) { if (exPar.getKind() != TypeKind.UNION) { if (!atypeFactory.getQualifierHierarchy() - .isSubtype(required, found)) { + .isSubtypeQualifiersOnly(required, found)) { checker.reportError(node.getParameter(), "exception.parameter.invalid", found, required); } @@ -814,7 +815,7 @@ protected void checkExceptionParameter(CatchTree node) { for (AnnotatedTypeMirror alterntive : aut.getAlternatives()) { AnnotationMirror foundAltern = alterntive .getAnnotationInHierarchy(required); - if (!atypeFactory.getQualifierHierarchy().isSubtype( + if (!atypeFactory.getQualifierHierarchy().isSubtypeQualifiersOnly( required, foundAltern)) { checker.reportError(node.getParameter(), "exception.parameter.invalid", foundAltern, required); diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 7eea07d65..124e5f9b8 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -80,6 +80,7 @@ import checkers.inference.util.ASTPathUtil; import checkers.inference.util.CopyUtil; import checkers.inference.util.InferenceUtil; +import org.checkerframework.org.plumelib.util.IPair; /** @@ -108,12 +109,12 @@ public class VariableAnnotator extends AnnotatedTypeScanner { * annotation mirror for a tree is calculated (i.e least upper bound for * binary tree), and the calculated result is cached in the set. **/ - protected final Map>> treeToVarAnnoPair; + protected final Map>> treeToVarAnnoPair; /** Store elements that have already been annotated **/ private final Map elementToAtm; - private final Map, ExistentialVariableSlot> idsToExistentialSlots; + private final Map, ExistentialVariableSlot> idsToExistentialSlots; private final AnnotatedTypeFactory realTypeFactory; private final InferrableChecker realChecker; @@ -238,7 +239,7 @@ private SourceVariableSlot createVariable(final Tree tree) { // } // } - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of(varSlot, new AnnotationMirrorSet()); treeToVarAnnoPair.put(tree, varATMPair); @@ -273,7 +274,7 @@ public ConstantSlot createConstant(final AnnotationMirror value, final Tree tree // } Set annotations = new AnnotationMirrorSet(); annotations.add(constantSlot.getValue()); - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of(constantSlot, annotations); treeToVarAnnoPair.put(tree, varATMPair); @@ -311,7 +312,7 @@ ExistentialVariableSlot getOrCreateExistentialVariable(final AnnotatedTypeMirror */ ExistentialVariableSlot getOrCreateExistentialVariable(final Slot potentialVariable, final Slot alternativeSlot) { - final Pair idPair = Pair.of(potentialVariable.getId(), alternativeSlot.getId()); + final IPair idPair = IPair.of(potentialVariable.getId(), alternativeSlot.getId()); ExistentialVariableSlot existentialVariable = idsToExistentialSlots.get(idPair); if (existentialVariable == null) { @@ -436,7 +437,7 @@ private void addExistentialVariable(final AnnotatedTypeVariable typeVar, final T } potentialVariable = createVariable(typeTree); - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of( potentialVariable, typeVar.getAnnotations()); treeToVarAnnoPair.put(typeTree, varATMPair); @@ -517,7 +518,7 @@ private Slot addPrimaryVariable(AnnotatedTypeMirror atm, final Tree tree) { ((SourceVariableSlot) variable).setInsertable(false); } - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .of(variable, new AnnotationMirrorSet()); @@ -1542,12 +1543,12 @@ public void handleBinaryTree(AnnotatedTypeMirror atm, BinaryTree binaryTree) { AnnotatedTypeMirror a = inferenceTypeFactory.getAnnotatedType(binaryTree.getLeftOperand()); AnnotatedTypeMirror b = inferenceTypeFactory.getAnnotatedType(binaryTree.getRightOperand()); Set lubs = inferenceTypeFactory - .getQualifierHierarchy().leastUpperBounds(a.getEffectiveAnnotations(), - b.getEffectiveAnnotations()); + .getQualifierHierarchy().leastUpperBoundsShallow(a.getEffectiveAnnotations(), a.getUnderlyingType(), + b.getEffectiveAnnotations(), b.getUnderlyingType()); atm.clearAnnotations(); atm.addAnnotations(lubs); if (slotManager.getSlot(atm) instanceof VariableSlot) { - final Pair> varATMPair = Pair.>of( + final IPair> varATMPair = IPair.>of( slotManager.getSlot(atm), lubs); treeToVarAnnoPair.put(binaryTree, varATMPair); } else { diff --git a/src/checkers/inference/dataflow/InferenceTransfer.java b/src/checkers/inference/dataflow/InferenceTransfer.java index 8ac9dfc19..cd0f494e4 100644 --- a/src/checkers/inference/dataflow/InferenceTransfer.java +++ b/src/checkers/inference/dataflow/InferenceTransfer.java @@ -35,6 +35,7 @@ import checkers.inference.model.Slot; import checkers.inference.model.VariableSlot; import checkers.inference.util.InferenceUtil; +import org.checkerframework.org.plumelib.util.IPair; /** * @@ -58,7 +59,7 @@ public class InferenceTransfer extends CFTransfer { // Type variables will have two refinement variables (one for each bound). This covers the // case where the correct, inferred RHS has no primary annotation - private final Map> createdTypeVarRefinementVariables = new HashMap<>(); + private final Map> createdTypeVarRefinementVariables = new HashMap<>(); private final InferenceAnnotatedTypeFactory typeFactory; @@ -320,7 +321,7 @@ private TransferResult createTypeVarRefinementVars(Node lhs, T final RefinementVariableSlot upperBoundRefVar; final RefinementVariableSlot lowerBoundRefVar; if (createdTypeVarRefinementVariables.containsKey(assignmentTree)) { - Pair ubToLb = createdTypeVarRefinementVariables.get(assignmentTree); + IPair ubToLb = createdTypeVarRefinementVariables.get(assignmentTree); upperBoundRefVar = ubToLb.first; lowerBoundRefVar = ubToLb.second; @@ -337,7 +338,7 @@ private TransferResult createTypeVarRefinementVars(Node lhs, T upperBoundSlot.getRefinedToSlots().add(upperBoundRefVar); lowerBoundSlot.getRefinedToSlots().add(lowerBoundRefVar); - createdTypeVarRefinementVariables.put(assignmentTree, Pair.of(upperBoundRefVar, lowerBoundRefVar)); + createdTypeVarRefinementVariables.put(assignmentTree, IPair.of(upperBoundRefVar, lowerBoundRefVar)); } upperBoundType.replaceAnnotation(slotManager.getAnnotation(upperBoundRefVar)); diff --git a/src/checkers/inference/dataflow/InferenceValue.java b/src/checkers/inference/dataflow/InferenceValue.java index b729a6b97..e593cbc53 100644 --- a/src/checkers/inference/dataflow/InferenceValue.java +++ b/src/checkers/inference/dataflow/InferenceValue.java @@ -68,7 +68,7 @@ public CFValue leastUpperBound(CFValue other) { // Delegate the LUB computation to inferenceQualifierHierarchy, by passing // the two VarAnnos getting from slotManager. - final AnnotationMirror lub = qualifierHierarchy.leastUpperBound(anno1, anno2); + final AnnotationMirror lub = qualifierHierarchy.leastUpperBoundQualifiersOnly(anno1, anno2); return analysis.createAbstractValue(AnnotationMirrorSet.singleton(lub), getLubType(other, null)); } diff --git a/src/checkers/inference/model/ComparableConstraint.java b/src/checkers/inference/model/ComparableConstraint.java index 443d2f3cc..0c58e32f1 100644 --- a/src/checkers/inference/model/ComparableConstraint.java +++ b/src/checkers/inference/model/ComparableConstraint.java @@ -44,8 +44,8 @@ protected static Constraint create(Slot first, Slot second, AnnotationLocation l ConstantSlot firstConst = (ConstantSlot) first; ConstantSlot secondConst = (ConstantSlot) second; - return realQualHierarchy.isSubtype(firstConst.getValue(), secondConst.getValue()) - || realQualHierarchy.isSubtype(secondConst.getValue(), firstConst.getValue()) + return realQualHierarchy.isSubtypeQualifiersOnly(firstConst.getValue(), secondConst.getValue()) + || realQualHierarchy.isSubtypeQualifiersOnly(secondConst.getValue(), firstConst.getValue()) ? AlwaysTrueConstraint.create() : AlwaysFalseConstraint.create(); } diff --git a/src/checkers/inference/model/SubtypeConstraint.java b/src/checkers/inference/model/SubtypeConstraint.java index 9b26a193d..b2f787372 100644 --- a/src/checkers/inference/model/SubtypeConstraint.java +++ b/src/checkers/inference/model/SubtypeConstraint.java @@ -66,7 +66,7 @@ protected static Constraint create(Slot subtype, Slot supertype, AnnotationLocat ConstantSlot subConstant = (ConstantSlot) subtype; ConstantSlot superConstant = (ConstantSlot) supertype; - return realQualHierarchy.isSubtype(subConstant.getValue(), superConstant.getValue()) + return realQualHierarchy.isSubtypeQualifiersOnly(subConstant.getValue(), superConstant.getValue()) ? AlwaysTrueConstraint.create() : AlwaysFalseConstraint.create(); } diff --git a/src/checkers/inference/solver/frontend/Lattice.java b/src/checkers/inference/solver/frontend/Lattice.java index d46b8c0b1..89b2a0fb7 100644 --- a/src/checkers/inference/solver/frontend/Lattice.java +++ b/src/checkers/inference/solver/frontend/Lattice.java @@ -90,7 +90,7 @@ public Lattice(Map> subType, } public boolean isSubtype(AnnotationMirror a1, AnnotationMirror a2) { - return underlyingQualifierHierarchy.isSubtype(a1, a2); + return underlyingQualifierHierarchy.isSubtypeQualifiersOnly(a1, a2); } } diff --git a/src/checkers/inference/solver/frontend/LatticeBuilder.java b/src/checkers/inference/solver/frontend/LatticeBuilder.java index b386a81d6..e0b85bd25 100644 --- a/src/checkers/inference/solver/frontend/LatticeBuilder.java +++ b/src/checkers/inference/solver/frontend/LatticeBuilder.java @@ -108,10 +108,10 @@ public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection s Set subtypeOfi = new HashSet(); Set supertypeOfi = new HashSet(); for (AnnotationMirror j : allTypes) { - if (qualHierarchy.isSubtype(j, i)) { + if (qualHierarchy.isSubtypeQualifiersOnly(j, i)) { subtypeOfi.add(j); } - if (qualHierarchy.isSubtype(i, j)) { + if (qualHierarchy.isSubtypeQualifiersOnly(i, j)) { supertypeOfi.add(j); } } diff --git a/src/checkers/inference/util/ASTPathUtil.java b/src/checkers/inference/util/ASTPathUtil.java index a825598ad..4e9d72c38 100644 --- a/src/checkers/inference/util/ASTPathUtil.java +++ b/src/checkers/inference/util/ASTPathUtil.java @@ -27,6 +27,7 @@ import org.checkerframework.afu.scenelib.io.ASTIndex; import org.checkerframework.afu.scenelib.io.ASTPath; import org.checkerframework.afu.scenelib.io.ASTRecord; +import org.checkerframework.org.plumelib.util.IPair; /** * ASTPathUtil is a collection of utilities to create ASTRecord for existing trees, as well @@ -230,7 +231,7 @@ public Void visitWildcard(AnnotatedWildcardType type, ASTRecord current) { /** * Converts fully qualified class name into a pair of Strings (packageName -> className) */ - public static Pair splitFullyQualifiedClass(String fullClassname) { + public static IPair splitFullyQualifiedClass(String fullClassname) { String pkgName; String className; int lastPeriod = fullClassname.lastIndexOf("."); @@ -243,6 +244,6 @@ public static Pair splitFullyQualifiedClass(String fullClassname className = fullClassname.substring(lastPeriod + 1, fullClassname.length()); } - return Pair.of(pkgName, className); + return IPair.of(pkgName, className); } } diff --git a/src/checkers/inference/util/ConstantToVariableAnnotator.java b/src/checkers/inference/util/ConstantToVariableAnnotator.java index 892ea765f..23ebb982c 100644 --- a/src/checkers/inference/util/ConstantToVariableAnnotator.java +++ b/src/checkers/inference/util/ConstantToVariableAnnotator.java @@ -43,7 +43,7 @@ protected Void scan(AnnotatedTypeMirror type, Void aVoid) { * @param type A type annotated in the "real qualifier hierarch" */ protected void addVariablePrimaryAnnotation(final AnnotatedTypeMirror type) { - if (type.isAnnotatedInHierarchy(varAnnot)) { + if (type.hasAnnotationInHierarchy(varAnnot)) { return; } diff --git a/src/checkers/inference/util/JaifBuilder.java b/src/checkers/inference/util/JaifBuilder.java index 03bf0b0f8..9ae245ffa 100644 --- a/src/checkers/inference/util/JaifBuilder.java +++ b/src/checkers/inference/util/JaifBuilder.java @@ -23,6 +23,7 @@ import com.sun.source.tree.Tree; import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; /** * JaifBuilder creates Jaifs from a Map of ASTRecords to AnnotationMirrors. @@ -416,7 +417,7 @@ private ClassEntry getClassEntry(ClassDeclLocation location) { private ClassEntry getClassEntry(String fullyQualified) { ClassEntry classEntry = this.classesMap.get(fullyQualified); if (classEntry == null) { - Pair packageToClass = ASTPathUtil.splitFullyQualifiedClass(fullyQualified); + IPair packageToClass = ASTPathUtil.splitFullyQualifiedClass(fullyQualified); classEntry = new ClassEntry(packageToClass.first, packageToClass.second); this.classesMap.put(fullyQualified, classEntry); } diff --git a/src/dataflow/DataflowAnnotatedTypeFactory.java b/src/dataflow/DataflowAnnotatedTypeFactory.java index f2aad8a10..56bda64a1 100644 --- a/src/dataflow/DataflowAnnotatedTypeFactory.java +++ b/src/dataflow/DataflowAnnotatedTypeFactory.java @@ -126,7 +126,7 @@ public DataFlowQualifierHierarchy( Collection> qualifierClasses, Elements elements ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, DataflowAnnotatedTypeFactory.this); DATAFLOW_KIND = getQualifierKind(DATAFLOW); } diff --git a/src/interning/InterningAnnotatedTypeFactory.java b/src/interning/InterningAnnotatedTypeFactory.java index 141efa41b..37dbff13f 100644 --- a/src/interning/InterningAnnotatedTypeFactory.java +++ b/src/interning/InterningAnnotatedTypeFactory.java @@ -90,7 +90,7 @@ protected TypeAnnotator createTypeAnnotator() { @Override public void addComputedTypeAnnotations(Element element, AnnotatedTypeMirror type) { - if (!type.isAnnotatedInHierarchy(INTERNED) && ElementUtils.isCompileTimeConstant(element)) + if (!type.hasAnnotationInHierarchy(INTERNED) && ElementUtils.isCompileTimeConstant(element)) type.addAnnotation(INTERNED); super.addComputedTypeAnnotations(element, type); } @@ -153,7 +153,7 @@ public Void visitDeclared(AnnotatedDeclaredType t, Void p) { // TODO: @Interned then the type would already receive an @Interned from the framework without // TODO: this case (I think from InheritFromClass) // TODO: IF this is true, perhaps remove item 6 I added to the class comment - } else if (typeFactory.fromElement(elt).hasAnnotation(INTERNED)) { + } else if (atypeFactory.fromElement(elt).hasAnnotation(INTERNED)) { // If the class/interface has an @Interned annotation, use it. t.replaceAnnotation(INTERNED); } diff --git a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java index 442318701..07bcc2c4a 100644 --- a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java +++ b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java @@ -300,12 +300,12 @@ public FlowQualifierHierarchy( Collection> qualifierClasses, Elements elements ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, SimpleFlowAnnotatedTypeFactory.this); } @Override - public Set getTopAnnotations() { - return Collections.singleton(checker instanceof IFlowSinkChecker ? + public AnnotationMirrorSet getTopAnnotations() { + return AnnotationMirrorSet.singleton(checker instanceof IFlowSinkChecker ? NOSINK : ANYSOURCE); } @@ -320,8 +320,8 @@ public AnnotationMirror getTopAnnotation(AnnotationMirror start) { } @Override - public Set getBottomAnnotations() { - return Collections.singleton(checker instanceof IFlowSinkChecker ? + public AnnotationMirrorSet getBottomAnnotations() { + return AnnotationMirrorSet.singleton(checker instanceof IFlowSinkChecker ? ANYSINK : NOSOURCE); } @@ -336,12 +336,12 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public @Nullable AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2) { + public @Nullable AnnotationMirror leastUpperBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { if (!AnnotationUtils.areSameByName(getTopAnnotation(a1), getTopAnnotation(a2))) { return null; - } else if (isSubtype(a1, a2)) { + } else if (isSubtypeQualifiersOnly(a1, a2)) { return a2; - } else if (isSubtype(a2, a1)) { + } else if (isSubtypeQualifiersOnly(a2, a1)) { return a1; } else if (isSourceQualifier(a1)) { // Since the two annotations are same by name, they are both source qualifier. @@ -359,12 +359,12 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) { + public @Nullable AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { if (!AnnotationUtils.areSameByName(getTopAnnotation(a1), getTopAnnotation(a2))) { return null; - } else if (isSubtype(a1, a2)) { + } else if (isSubtypeQualifiersOnly(a1, a2)) { return a1; - } else if (isSubtype(a2, a1)) { + } else if (isSubtypeQualifiersOnly(a2, a1)) { return a2; } else if (isSourceQualifier(a1)) { // Since the two annotations are same by name, they are both source qualifier. @@ -382,7 +382,7 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public boolean isSubtype(AnnotationMirror subtype, AnnotationMirror supertype) { + public boolean isSubtypeQualifiers(AnnotationMirror subtype, AnnotationMirror supertype) { if (isPolySourceQualifier(supertype) && isPolySourceQualifier(subtype)) { return true; } else if (isPolySourceQualifier(supertype) && isSourceQualifier(subtype)) { diff --git a/tests/checkers/inference/test/CFInferenceTest.java b/tests/checkers/inference/test/CFInferenceTest.java index b2ee3f9df..3b11706e1 100644 --- a/tests/checkers/inference/test/CFInferenceTest.java +++ b/tests/checkers/inference/test/CFInferenceTest.java @@ -11,6 +11,7 @@ import javax.annotation.processing.AbstractProcessor; +import org.checkerframework.org.plumelib.util.SystemPlume; import org.junit.Test; public abstract class CFInferenceTest extends CheckerFrameworkPerFileTest { @@ -27,7 +28,7 @@ public CFInferenceTest(File testFile, Class checker } public boolean useHacks() { - return SystemUtil.getBooleanSystemProperty("use.hacks"); + return SystemPlume.getBooleanSystemProperty("use.hacks"); } public abstract Pair> getSolverNameAndOptions();