diff --git a/src/checkers/inference/InferenceAnnotatedTypeFactory.java b/src/checkers/inference/InferenceAnnotatedTypeFactory.java index d2e7a975..cd0fe730 100644 --- a/src/checkers/inference/InferenceAnnotatedTypeFactory.java +++ b/src/checkers/inference/InferenceAnnotatedTypeFactory.java @@ -279,7 +279,7 @@ protected void postDirectSuperTypes( // annotateImplicit(element,type) to be called on the supertype which will overwrite the // annotations from type // with those for the declaration of the super type - Set annotations = type.getEffectiveAnnotations(); + AnnotationMirrorSet annotations = type.getEffectiveAnnotations(); for (AnnotatedTypeMirror supertype : supertypes) { if (!annotations.equals(supertype.getEffectiveAnnotations())) { supertype.clearAnnotations(); diff --git a/src/checkers/inference/InferenceQualifierHierarchy.java b/src/checkers/inference/InferenceQualifierHierarchy.java index a53c357f..8208ff52 100644 --- a/src/checkers/inference/InferenceQualifierHierarchy.java +++ b/src/checkers/inference/InferenceQualifierHierarchy.java @@ -221,7 +221,7 @@ public Set leastUpperBoundsShallow( Collection annos2, TypeMirror tm2) { if (InferenceMain.isHackMode(annos1.size() != annos2.size())) { - Set result = new AnnotationMirrorSet(); + AnnotationMirrorSet result = new AnnotationMirrorSet(); for (AnnotationMirror a1 : annos1) { for (AnnotationMirror a2 : annos2) { AnnotationMirror lub = leastUpperBoundQualifiersOnly(a1, a2); diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 9520aceb..96db2b4c 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -30,7 +30,6 @@ import java.lang.annotation.Annotation; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -84,7 +83,7 @@ public class InferenceVisitor< * Map from type-use location to a list of qualifiers which cannot be used on that location. * This is used to create the inequality constraint in inference. */ - protected final Map> locationToIllegalQuals; + protected final Map locationToIllegalQuals; public InferenceVisitor( Checker checker, InferenceChecker ichecker, Factory factory, boolean infer) { @@ -820,9 +819,9 @@ public boolean maybeAddRefinementVariableConstraints( return inferenceRefinementVariable; } - protected Set filterThrowCatchBounds( + protected AnnotationMirrorSet filterThrowCatchBounds( Set originals) { - Set throwBounds = new HashSet<>(); + AnnotationMirrorSet throwBounds = new AnnotationMirrorSet(); for (AnnotationMirror throwBound : originals) { if (atypeFactory.areSameByClass(throwBound, VarAnnot.class)) { @@ -847,7 +846,7 @@ protected void checkThrownExpression(ThrowTree node) { if (infer) { // TODO: We probably want to unify this code with BaseTypeVisitor AnnotatedTypeMirror throwType = atypeFactory.getAnnotatedType(node.getExpression()); - Set throwBounds = + AnnotationMirrorSet throwBounds = filterThrowCatchBounds(getThrowUpperBoundAnnotations()); final AnnotationMirror varAnnot = @@ -915,7 +914,7 @@ protected void checkExceptionParameter(CatchTree node) { if (infer) { // TODO: Unify with BaseTypeVisitor implementation - Set requiredAnnotations = + AnnotationMirrorSet requiredAnnotations = filterThrowCatchBounds(getExceptionParameterLowerBoundAnnotations()); AnnotatedTypeMirror exPar = atypeFactory.getAnnotatedType(node.getParameter()); @@ -983,18 +982,18 @@ protected void checkConstructorResult( * @return a mapping from type-use locations to a set of qualifiers which cannot be applied to * that location */ - protected Map> createMapForIllegalQuals() { - Map> locationToIllegalQuals = new HashMap<>(); + protected Map createMapForIllegalQuals() { + Map locationToIllegalQuals = new HashMap<>(); // First, init each type-use location to contain all type qualifiers. Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); - Set supportedAnnos = new AnnotationMirrorSet(); + AnnotationMirrorSet supportedAnnos = new AnnotationMirrorSet(); for (Class qual : supportQualifiers) { supportedAnnos.add( new AnnotationBuilder(atypeFactory.getProcessingEnv(), qual).build()); } for (TypeUseLocation location : TypeUseLocation.values()) { - locationToIllegalQuals.put(location, new HashSet<>(supportedAnnos)); + locationToIllegalQuals.put(location, new AnnotationMirrorSet(supportedAnnos)); } // Then, delete some qualifiers which can be applied to that type-use location. // this leaves only qualifiers not allowed on that location. @@ -1005,7 +1004,7 @@ protected Map> createMapForIllegalQuals() // the qualifier can be written on any type use. if (tls == null) { for (TypeUseLocation location : TypeUseLocation.values()) { - Set amSet = locationToIllegalQuals.get(location); + AnnotationMirrorSet amSet = locationToIllegalQuals.get(location); amSet.remove( AnnotationUtils.getAnnotationByName( supportedAnnos, qual.getCanonicalName())); @@ -1015,14 +1014,14 @@ protected Map> createMapForIllegalQuals() for (TypeUseLocation location : tls.value()) { if (location == TypeUseLocation.ALL) { for (TypeUseLocation val : TypeUseLocation.values()) { - Set amSet = locationToIllegalQuals.get(val); + AnnotationMirrorSet amSet = locationToIllegalQuals.get(val); amSet.remove( AnnotationUtils.getAnnotationByName( supportedAnnos, qual.getCanonicalName())); } break; } - Set amSet = locationToIllegalQuals.get(location); + AnnotationMirrorSet amSet = locationToIllegalQuals.get(location); amSet.remove( AnnotationUtils.getAnnotationByName( supportedAnnos, qual.getCanonicalName())); diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 4ad2ee9d..5b33faf3 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -284,7 +284,7 @@ public ConstantSlot createConstant(final AnnotationMirror value, final Tree tree // // } // } - Set annotations = new AnnotationMirrorSet(); + AnnotationMirrorSet annotations = new AnnotationMirrorSet(); annotations.add(constantSlot.getValue()); final IPair> varATMPair = IPair.>of(constantSlot, annotations); diff --git a/src/checkers/inference/solver/backend/maxsat/encoder/MaxSATSubtypeConstraintEncoder.java b/src/checkers/inference/solver/backend/maxsat/encoder/MaxSATSubtypeConstraintEncoder.java index 6c82dd68..c25e36b5 100644 --- a/src/checkers/inference/solver/backend/maxsat/encoder/MaxSATSubtypeConstraintEncoder.java +++ b/src/checkers/inference/solver/backend/maxsat/encoder/MaxSATSubtypeConstraintEncoder.java @@ -1,15 +1,14 @@ package checkers.inference.solver.backend.maxsat.encoder; +import org.checkerframework.javacutil.AnnotationMirrorSet; import org.checkerframework.javacutil.AnnotationUtils; import org.sat4j.core.VecInt; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import javax.lang.model.element.AnnotationMirror; @@ -33,8 +32,7 @@ public MaxSATSubtypeConstraintEncoder( * For subtype constraint, if supertype is constant slot, then the subtype cannot be the super * type of supertype, same for subtype */ - protected VecInt[] getMustNotBe( - Set mustNotBe, Slot vSlot, ConstantSlot cSlot) { + protected VecInt[] getMustNotBe(AnnotationMirrorSet mustNotBe, Slot vSlot, ConstantSlot cSlot) { List resultList = new ArrayList(); @@ -114,7 +112,7 @@ public VecInt[] encodeVariable_Variable(VariableSlot subtype, VariableSlot super @Override public VecInt[] encodeVariable_Constant(VariableSlot subtype, ConstantSlot supertype) { - final Set mustNotBe = new HashSet<>(); + final AnnotationMirrorSet mustNotBe = new AnnotationMirrorSet(); if (AnnotationUtils.areSame(supertype.getValue(), lattice.bottom)) { return VectorUtils.asVecArray( MathUtils.mapIdToMatrixEntry( @@ -132,7 +130,7 @@ public VecInt[] encodeVariable_Constant(VariableSlot subtype, ConstantSlot super @Override public VecInt[] encodeConstant_Variable(ConstantSlot subtype, VariableSlot supertype) { - final Set mustNotBe = new HashSet<>(); + final AnnotationMirrorSet mustNotBe = new AnnotationMirrorSet(); if (AnnotationUtils.areSame(subtype.getValue(), lattice.top)) { return VectorUtils.asVecArray( MathUtils.mapIdToMatrixEntry( diff --git a/src/checkers/inference/solver/frontend/LatticeBuilder.java b/src/checkers/inference/solver/frontend/LatticeBuilder.java index acc0610c..9a5f7edd 100644 --- a/src/checkers/inference/solver/frontend/LatticeBuilder.java +++ b/src/checkers/inference/solver/frontend/LatticeBuilder.java @@ -9,7 +9,6 @@ import java.lang.annotation.Annotation; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -69,7 +68,7 @@ public LatticeBuilder() { public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection slots) { clear(); - Set supportedAnnos = new AnnotationMirrorSet(); + AnnotationMirrorSet supportedAnnos = new AnnotationMirrorSet(); Set> annoClasses = InferenceMain.getInstance().getRealTypeFactory().getSupportedTypeQualifiers(); for (Class ac : annoClasses) { @@ -95,8 +94,8 @@ public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection s // Calculate subtypes map and supertypes map for (AnnotationMirror i : allTypes) { - Set subtypeOfi = new HashSet(); - Set supertypeOfi = new HashSet(); + AnnotationMirrorSet subtypeOfi = new AnnotationMirrorSet(); + AnnotationMirrorSet supertypeOfi = new AnnotationMirrorSet(); for (AnnotationMirror j : allTypes) { if (qualHierarchy.isSubtypeQualifiersOnly(j, i)) { subtypeOfi.add(j); @@ -111,7 +110,7 @@ public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection s // Calculate incomparable types map for (AnnotationMirror i : allTypes) { - Set incomparableOfi = new HashSet(); + AnnotationMirrorSet incomparableOfi = new AnnotationMirrorSet(); for (AnnotationMirror j : allTypes) { if (!subType.get(i).contains(j) && !subType.get(j).contains(i)) { incomparableOfi.add(j); @@ -145,7 +144,7 @@ public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection s */ public TwoQualifiersLattice buildTwoTypeLattice(AnnotationMirror top, AnnotationMirror bottom) { clear(); - Set tempSet = new AnnotationMirrorSet(); + AnnotationMirrorSet tempSet = new AnnotationMirrorSet(); tempSet.add(top); tempSet.add(bottom); allTypes = Collections.unmodifiableSet(tempSet); @@ -154,8 +153,8 @@ public TwoQualifiersLattice buildTwoTypeLattice(AnnotationMirror top, Annotation numTypes = 2; // Calculate subertypes map and supertypes map. - Set topSet = new AnnotationMirrorSet(); - Set bottomSet = new AnnotationMirrorSet(); + AnnotationMirrorSet topSet = new AnnotationMirrorSet(); + AnnotationMirrorSet bottomSet = new AnnotationMirrorSet(); topSet.add(top); bottomSet.add(bottom); subType.put(top, Collections.unmodifiableSet(allTypes)); diff --git a/src/checkers/inference/util/InferenceUtil.java b/src/checkers/inference/util/InferenceUtil.java index 2c076fe9..ed350aac 100644 --- a/src/checkers/inference/util/InferenceUtil.java +++ b/src/checkers/inference/util/InferenceUtil.java @@ -35,9 +35,9 @@ public class InferenceUtil { * * @return the set of cleared annotations */ - public static Set clearAnnos(final AnnotatedTypeMirror atm) { + public static AnnotationMirrorSet clearAnnos(final AnnotatedTypeMirror atm) { - final Set oldAnnos = new AnnotationMirrorSet(); + final AnnotationMirrorSet oldAnnos = new AnnotationMirrorSet(); oldAnnos.addAll(atm.getAnnotations()); atm.clearAnnotations(); diff --git a/src/dataflow/solvers/general/DataflowGraphSolvingStrategy.java b/src/dataflow/solvers/general/DataflowGraphSolvingStrategy.java index a51bd0fe..3bb15703 100644 --- a/src/dataflow/solvers/general/DataflowGraphSolvingStrategy.java +++ b/src/dataflow/solvers/general/DataflowGraphSolvingStrategy.java @@ -112,7 +112,7 @@ protected List> separateGraph( protected InferenceResult mergeInferenceResults( List, Collection>> inferenceResults) { Map solutions = new HashMap<>(); - Map> dataflowResults = new HashMap<>(); + Map dataflowResults = new HashMap<>(); for (Pair, Collection> inferenceResult : inferenceResults) { @@ -122,7 +122,7 @@ protected InferenceResult mergeInferenceResults( Integer id = entry.getKey(); AnnotationMirror dataflowAnno = entry.getValue(); if (AnnotationUtils.areSameByName(dataflowAnno, DATAFLOW_NAME)) { - Set datas = dataflowResults.get(id); + AnnotationMirrorSet datas = dataflowResults.get(id); if (datas == null) { datas = new AnnotationMirrorSet(); dataflowResults.put(id, datas); @@ -136,7 +136,7 @@ protected InferenceResult mergeInferenceResults( } } - for (Map.Entry> entry : dataflowResults.entrySet()) { + for (Map.Entry entry : dataflowResults.entrySet()) { Set dataTypes = new HashSet(); Set dataRoots = new HashSet(); for (AnnotationMirror anno : entry.getValue()) { diff --git a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java index 3d99b856..8c752060 100644 --- a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java +++ b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java @@ -149,7 +149,7 @@ public Void visitNewClass(NewClassTree node, AnnotatedTypeMirror p) { .constructorFromUse(node) .executableType .getReturnType(); - Set defaultedSet = defaulted.getAnnotations(); + AnnotationMirrorSet defaultedSet = defaulted.getAnnotations(); // The default of OTHERWISE locations such as constructor results // is {}{}, but for constructor results we really want bottom. // So if the result is {}{}, then change it to {}->ANY (bottom)