diff --git a/checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java b/checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java index 50e6b2f5efcb..8651cc684551 100644 --- a/checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java +++ b/checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java @@ -49,8 +49,6 @@ public static void closeSockOK2(EnsuresCalledMethodsIfTest sock) throws Exceptio void close() throws IOException {} - @SuppressWarnings( - "calledmethods") // like the JDK's isOpen methods; makes this test case self-contained @EnsuresCalledMethodsIf( expression = "this", result = false, diff --git a/checker/tests/index/ArrayIntro.java b/checker/tests/index/ArrayIntro.java index a5ab41647a51..5451ce161a9a 100644 --- a/checker/tests/index/ArrayIntro.java +++ b/checker/tests/index/ArrayIntro.java @@ -1,6 +1,5 @@ import org.checkerframework.common.value.qual.MinLen; -@SuppressWarnings("lowerbound") public class ArrayIntro { void test() { int @MinLen(5) [] arr = new int[5]; diff --git a/checker/tests/index/UpperBoundRefinement.java b/checker/tests/index/UpperBoundRefinement.java index 9209b5f25547..419c450c856c 100644 --- a/checker/tests/index/UpperBoundRefinement.java +++ b/checker/tests/index/UpperBoundRefinement.java @@ -1,6 +1,5 @@ import org.checkerframework.checker.index.qual.LTLengthOf; -@SuppressWarnings("lowerbound") public class UpperBoundRefinement { // If expression i has type @LTLengthOf(value = "f2", offset = "f1.length") int and expression // j is less than or equal to the length of f1, then the type of i + j is @LTLengthOf("f2") diff --git a/checker/tests/mustcall/PolyTests.java b/checker/tests/mustcall/PolyTests.java index 2389dc4ddc01..4b080822cea4 100644 --- a/checker/tests/mustcall/PolyTests.java +++ b/checker/tests/mustcall/PolyTests.java @@ -19,8 +19,6 @@ static void test2(@Owning @MustCall({}) Object o) { @MustCall({}) Object o2 = id(o); } - // These sort of constructors will always appear in stub files and are unverifiable for now. - @SuppressWarnings("mustcall:annotations.on.use") @PolyMustCall PolyTests(@PolyMustCall Object obj) {} static void test3(@Owning @MustCall({"close"}) Object o) { diff --git a/checker/tests/nullness-checkcastelementtype/Issue1315.java b/checker/tests/nullness-checkcastelementtype/Issue1315.java index edcbefa2182a..5617a4177bde 100644 --- a/checker/tests/nullness-checkcastelementtype/Issue1315.java +++ b/checker/tests/nullness-checkcastelementtype/Issue1315.java @@ -17,9 +17,7 @@ T test1(@Nullable Object p) { return (T) p; } - // The Nullness Checker should not issue a cast.unsafe warning, - // but the KeyFor Checker does, so suppress that warning. - @SuppressWarnings({"unchecked", "keyfor:cast.unsafe"}) + @SuppressWarnings("unchecked") T test2(Object p) { return (T) p; } diff --git a/checker/tests/nullness/FullyQualifiedAnnotation.java b/checker/tests/nullness/FullyQualifiedAnnotation.java index fda3122451d5..be0c2d02b794 100644 --- a/checker/tests/nullness/FullyQualifiedAnnotation.java +++ b/checker/tests/nullness/FullyQualifiedAnnotation.java @@ -15,13 +15,11 @@ void client2(Iterator i) { } void client3(Iterator i) { - @SuppressWarnings("nullness") @org.checkerframework.checker.nullness.qual.NonNull Object handle2 = i.next(); handle2.toString(); } void client4(Iterator i) { - @SuppressWarnings("nullness") @org.checkerframework.checker.nullness.qual.NonNull Object handle2 = i.next(); handle2.toString(); } diff --git a/checker/tests/nullness/SuppressWarningsPartialKeys.java b/checker/tests/nullness/SuppressWarningsPartialKeys.java index d7a6c424c2e7..968ade610af5 100644 --- a/checker/tests/nullness/SuppressWarningsPartialKeys.java +++ b/checker/tests/nullness/SuppressWarningsPartialKeys.java @@ -1,5 +1,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; +@SuppressWarnings("unneeded.suppression") public class SuppressWarningsPartialKeys { @SuppressWarnings("return") diff --git a/checker/tests/regex/GroupCounts.java b/checker/tests/regex/GroupCounts.java index dc9861b039bf..fbf385911148 100644 --- a/checker/tests/regex/GroupCounts.java +++ b/checker/tests/regex/GroupCounts.java @@ -43,9 +43,7 @@ void testPatternCompileGroupCount(@Regex String r, @Regex(3) String r3, @Regex(5 // Make sure Pattern.compile still works when passed an @UnknownRegex String // that's actually a regex, with the warning suppressed. - @SuppressWarnings("regex:argument") Pattern p6 = Pattern.compile("(" + r + ")"); - @SuppressWarnings("regex:argument") Pattern p6a = Pattern.compile("(" + r + ")", 0); } diff --git a/checker/tests/regex/MyMatchResult.java b/checker/tests/regex/MyMatchResult.java index e08362735b19..5bc17d4bbfa5 100644 --- a/checker/tests/regex/MyMatchResult.java +++ b/checker/tests/regex/MyMatchResult.java @@ -1,8 +1,5 @@ import java.util.regex.MatchResult; -// Outside of scope of the Regex Checker to verify an implementation of MatchResult, -// so just check for crashes. -@SuppressWarnings("regex") public class MyMatchResult implements MatchResult { @Override diff --git a/checker/tests/tainting/Issue2330.java b/checker/tests/tainting/Issue2330.java index c796c81998ec..2415b3dab958 100644 --- a/checker/tests/tainting/Issue2330.java +++ b/checker/tests/tainting/Issue2330.java @@ -3,12 +3,8 @@ import org.checkerframework.checker.tainting.qual.Untainted; public class Issue2330 { - // Checker can't verify that this creates an untainted Issue2330 - @SuppressWarnings("tainting") public @Untainted Issue2330(@PolyTainted int i) {} - // Checker can't verify that this creates an untainted Issue2330 - @SuppressWarnings("tainting") public @Untainted Issue2330() {} public static void f(@PolyTainted int i) { diff --git a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.java b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.java index bd0028dc91ff..e340b555e2c9 100644 --- a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.java +++ b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.java @@ -142,6 +142,7 @@ protected CheckerFrameworkPerDirectoryTest( this.checkerOptions = new ArrayList<>(Arrays.asList(checkerOptions)); this.checkerOptions.add("-AajavaChecks"); this.checkerOptions.add("-AconvertTypeArgInferenceCrashToWarning=false"); + this.checkerOptions.add("-AwarnUnneededSuppressions"); } /** Run the tests. */ diff --git a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.java b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.java index 102e5f08380b..48ad90ee1428 100644 --- a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.java +++ b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.java @@ -82,7 +82,8 @@ protected CheckerFrameworkPerFileTest( this.testFile = testFile; this.checker = checker; this.testDir = testDir; - this.checkerOptions = new ArrayList<>(Arrays.asList(checkerOptions)); + this.checkerOptions = new ArrayList(Arrays.asList(checkerOptions)); + this.checkerOptions.add("-AwarnUnneededSuppressions"); } @Test diff --git a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.java b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.java index 2197d495529d..b09fc0094146 100644 --- a/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.java +++ b/framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.java @@ -5,7 +5,7 @@ /** Encapsulates the directory root to search within for test files to compile. */ abstract class CheckerFrameworkRootedTest { - /** Constructs a test that will assert that can resolve its tests root directory. */ + /** Constructs a test that uses {@code @TestRootDirectory} to find its test directory. */ public CheckerFrameworkRootedTest() {} /** diff --git a/framework/tests/all-systems/ForEach.java b/framework/tests/all-systems/ForEach.java index 07c2aabf7b28..c95fa54d7c17 100644 --- a/framework/tests/all-systems/ForEach.java +++ b/framework/tests/all-systems/ForEach.java @@ -32,9 +32,10 @@ void m4(T p) { } } - @SuppressWarnings( - "nonempty") // TODO: the Non-Empty Checker requires the Side Effects Only checker to - // eliminate the false positive here. + @SuppressWarnings({ + "nonempty:argument", + "nonempty:method.invocation" + }) // generic type inference bug? public static List removeDuplicates(List l) { // There are shorter solutions that do not maintain order. HashSet hs = new HashSet<>(l.size()); diff --git a/framework/tests/all-systems/GenericNull.java b/framework/tests/all-systems/GenericNull.java index 14d9547e544e..13c8d1569636 100644 --- a/framework/tests/all-systems/GenericNull.java +++ b/framework/tests/all-systems/GenericNull.java @@ -25,7 +25,7 @@ public class GenericNull { * this test. For the Lock Checker, null's type is bottom for the @GuardedByUnknown hierarchy but * not for the @LockPossiblyHeld hierarchy. */ - @SuppressWarnings({"nullness", "lock"}) + @SuppressWarnings("nullness") T f() { return null; } diff --git a/framework/tests/all-systems/GetClassTest.java b/framework/tests/all-systems/GetClassTest.java index 37a15b627409..9e7e244b78e0 100644 --- a/framework/tests/all-systems/GetClassTest.java +++ b/framework/tests/all-systems/GetClassTest.java @@ -9,13 +9,7 @@ void context() { Integer i = 4; i.getClass(); Class a = i.getClass(); - // Type arguments don't match - @SuppressWarnings("fenum:assignment") Class b = i.getClass(); - @SuppressWarnings({ - "fenum:assignment", // Type arguments don't match - "signedness:assignment" // Type arguments don't match - }) Class c = i.getClass(); Class d = i.getClass(); @@ -24,7 +18,6 @@ void context() { } void m(Date d) { - @SuppressWarnings("fenum:assignment") Class c = d.getClass(); } } diff --git a/framework/tests/all-systems/InferAndWildcards.java b/framework/tests/all-systems/InferAndWildcards.java index fcb3f4b50663..bdcf75ac7d32 100644 --- a/framework/tests/all-systems/InferAndWildcards.java +++ b/framework/tests/all-systems/InferAndWildcards.java @@ -1,4 +1,3 @@ -@SuppressWarnings("interning") public class InferAndWildcards { Class b(Class clazz) { return clazz; diff --git a/framework/tests/all-systems/InferTypeArgs.java b/framework/tests/all-systems/InferTypeArgs.java index 9d8923466bf8..84b857130131 100644 --- a/framework/tests/all-systems/InferTypeArgs.java +++ b/framework/tests/all-systems/InferTypeArgs.java @@ -75,7 +75,7 @@ protected FlowAnalysis createFlowAnalysis() { return result; } - @SuppressWarnings({"nullness:return", "lock:return", "immutabilitysub:type.argument"}) + @SuppressWarnings({"nullness:return", "immutabilitysub:type.argument"}) public static T invokeConstructorFor() { return null; } diff --git a/framework/tests/all-systems/Issue1708.java b/framework/tests/all-systems/Issue1708.java index eea4466b5117..9eda8ea33fc9 100644 --- a/framework/tests/all-systems/Issue1708.java +++ b/framework/tests/all-systems/Issue1708.java @@ -8,7 +8,6 @@ @SuppressWarnings({ "unchecked", "ainfertest", - "value" }) // Don't issue warnings during ainfer tests, because more than one round of inference is required // for the value checker public class Issue1708 { diff --git a/framework/tests/all-systems/Issue1809.java b/framework/tests/all-systems/Issue1809.java index fc3f89d74030..46635b6f8c4e 100644 --- a/framework/tests/all-systems/Issue1809.java +++ b/framework/tests/all-systems/Issue1809.java @@ -30,7 +30,7 @@ interface S {} // The Checker Framework does not refine the type of Stream#filter based on post conditions of // the passed function. - @SuppressWarnings({"nullness", "optional"}) + // TODO: use more specific suppressions. @SuppressWarnings({"nullness", "optional"}) private Stream xrefsFor(B b) { return concat(b.g().stream().flatMap(a -> a.h().stream().map(c -> f()))) .filter(Optional::isPresent) diff --git a/framework/tests/all-systems/Issue457.java b/framework/tests/all-systems/Issue457.java index f20634ece0e2..1fa2e02a57ed 100644 --- a/framework/tests/all-systems/Issue457.java +++ b/framework/tests/all-systems/Issue457.java @@ -6,7 +6,6 @@ public class Issue457 { public void f(T t) { final T obj = t; - @SuppressWarnings("signedness:assignment") // cast Float objFloat = (obj instanceof Float) ? (Float) obj : null; // An error will be emitted on this line before the fix for Issue457 diff --git a/framework/tests/all-systems/Issue5042.java b/framework/tests/all-systems/Issue5042.java index e4d3a29b6215..0bc0e99d0a86 100644 --- a/framework/tests/all-systems/Issue5042.java +++ b/framework/tests/all-systems/Issue5042.java @@ -1,7 +1,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.Nullable; -@SuppressWarnings("initializedfields") // The fields are initialized. public class Issue5042 { interface PromptViewModel { boolean isPending(); diff --git a/framework/tests/all-systems/Issue759.java b/framework/tests/all-systems/Issue759.java index b6d23961e5b2..b3a315a80f56 100644 --- a/framework/tests/all-systems/Issue759.java +++ b/framework/tests/all-systems/Issue759.java @@ -3,8 +3,7 @@ @SuppressWarnings({ "nullness", "unchecked", - "ainfertest", - "value" + "ainfertest" }) // See checker/test/nullness/Issue759.java; ainfertest and value are suppressed because WPI // errors shouldn't be issued here, just checked for crashes public class Issue759 { @@ -28,7 +27,7 @@ T[] getConstants() { } } -@SuppressWarnings("nullness") +// @SuppressWarnings("nullness") class IncompatibleTypes { void possibleValues(final Gen genType) { lowercase(genType.getConstants()); diff --git a/framework/tests/all-systems/MissingBoundAnnotations.java b/framework/tests/all-systems/MissingBoundAnnotations.java index 2c15fde814c7..4be65187097a 100644 --- a/framework/tests/all-systems/MissingBoundAnnotations.java +++ b/framework/tests/all-systems/MissingBoundAnnotations.java @@ -4,7 +4,6 @@ import java.util.Map; public final class MissingBoundAnnotations { - @SuppressWarnings("nullness:type.argument") public static , V> Collection sortedKeySet(Map m) { ArrayList theKeys = new ArrayList<>(m.keySet()); Collections.sort(theKeys); diff --git a/framework/tests/all-systems/SetOfSet.java b/framework/tests/all-systems/SetOfSet.java index a67789071488..35df3f5e6b0c 100644 --- a/framework/tests/all-systems/SetOfSet.java +++ b/framework/tests/all-systems/SetOfSet.java @@ -1,9 +1,6 @@ package wildcards; -@SuppressWarnings({ - "initialization", - "initializedfields:contracts.postcondition" -}) // field isn't set +@SuppressWarnings("initialization") public class SetOfSet { public void addAll(SetOfSet s) { diff --git a/framework/tests/all-systems/WildcardCrash.java b/framework/tests/all-systems/WildcardCrash.java index b87351fb745c..fbeac11faedc 100644 --- a/framework/tests/all-systems/WildcardCrash.java +++ b/framework/tests/all-systems/WildcardCrash.java @@ -16,7 +16,7 @@ public SomeGen(CFAbstractAnalysis123 analysis) {} class CFValue123 extends CFAbstractValue123 {} -@SuppressWarnings({"initialization", "initializedfields:contracts.postcondition"}) +@SuppressWarnings("initialization") class CFAbstractTransfer123< V extends CFAbstractValue123, S extends CFAbstractStore123, diff --git a/framework/tests/all-systems/WildcardSuper2.java b/framework/tests/all-systems/WildcardSuper2.java index 2278ba1b5d9c..c03dfac2d542 100644 --- a/framework/tests/all-systems/WildcardSuper2.java +++ b/framework/tests/all-systems/WildcardSuper2.java @@ -8,7 +8,7 @@ interface AInterface { class B implements AInterface { // This shouldn't work for nullness as the function won't take possibly nullable values. - @SuppressWarnings({"nullness", "fenum:override.param", "aliasing"}) + // @SuppressWarnings({"nullness", "aliasing"}) @Override public int transform(List function) { return 0; diff --git a/framework/tests/all-systems/java17/Figure.java b/framework/tests/all-systems/java17/Figure.java index 7db6ea5d0923..473142d41b00 100644 --- a/framework/tests/all-systems/java17/Figure.java +++ b/framework/tests/all-systems/java17/Figure.java @@ -8,22 +8,18 @@ public sealed class Figure // defined in the same file. {} -@SuppressWarnings("initializedfields:contracts.postcondition") final class Circle extends Figure { float radius; } -@SuppressWarnings("initializedfields:contracts.postcondition") non-sealed class Square extends Figure { float side; } -@SuppressWarnings("initializedfields:contracts.postcondition") sealed class Rectangle extends Figure { float length, width; } -@SuppressWarnings("initializedfields:contracts.postcondition") final class FilledRectangle extends Rectangle { int red, green, blue, sealed; } diff --git a/framework/tests/all-systems/java17/Issue6100.java b/framework/tests/all-systems/java17/Issue6100.java index de8151f74590..1612b9b655ac 100644 --- a/framework/tests/all-systems/java17/Issue6100.java +++ b/framework/tests/all-systems/java17/Issue6100.java @@ -3,7 +3,6 @@ // @infer-jaifs-skip-test The AFU's JAIF reading/writing libraries don't support records. // @below-java17-jdk-skip-test -@SuppressWarnings("signedness") public record Issue6100(List<@NonNegative Integer> bar) { public Issue6100 { diff --git a/framework/tests/all-systems/java8inference/CollectorsToList.java b/framework/tests/all-systems/java8inference/CollectorsToList.java index a65794c91ed5..723773c2ae21 100644 --- a/framework/tests/all-systems/java8inference/CollectorsToList.java +++ b/framework/tests/all-systems/java8inference/CollectorsToList.java @@ -22,7 +22,6 @@ void m(List strings) { // This works: List<@Nullable String> collectedStrings2 = s.collect(Collectors.toList()); // This works: - @SuppressWarnings("nullness") List collectedStrings3 = s.collect(Collectors.toList()); // This assignment issues a warning due to incompatible types: diff --git a/framework/tests/all-systems/java8inference/Issue1397.java b/framework/tests/all-systems/java8inference/Issue1397.java index 8ad4572e0cb5..bca8ab1b123c 100644 --- a/framework/tests/all-systems/java8inference/Issue1397.java +++ b/framework/tests/all-systems/java8inference/Issue1397.java @@ -10,7 +10,6 @@ abstract class CrashCompound { abstract T unbox(Box p); - @SuppressWarnings("units") void foo(Box bb) { boolean res = false; res |= chk(unbox(bb)); diff --git a/framework/tests/all-systems/java8inference/Issue1407.java b/framework/tests/all-systems/java8inference/Issue1407.java index 375845d9bf39..e03207fe4b08 100644 --- a/framework/tests/all-systems/java8inference/Issue1407.java +++ b/framework/tests/all-systems/java8inference/Issue1407.java @@ -6,7 +6,6 @@ abstract class Issue1407 { abstract T bar(int p1, T p2); - @SuppressWarnings({"interning", "signedness"}) int demo() { return foo(bar(5, 3), 3); } diff --git a/framework/tests/all-systems/java8inference/Issue1416.java b/framework/tests/all-systems/java8inference/Issue1416.java index c7cae68ff39a..4b408bbdaf41 100644 --- a/framework/tests/all-systems/java8inference/Issue1416.java +++ b/framework/tests/all-systems/java8inference/Issue1416.java @@ -5,7 +5,6 @@ import java.util.stream.Stream; public class Issue1416 { - @SuppressWarnings("signedness") long order(Stream sl) { return sl.max(Comparator.naturalOrder()).orElse(0L); } diff --git a/framework/tests/all-systems/java8inference/Issue6046.java b/framework/tests/all-systems/java8inference/Issue6046.java index 55481d3e6983..38f97585f719 100644 --- a/framework/tests/all-systems/java8inference/Issue6046.java +++ b/framework/tests/all-systems/java8inference/Issue6046.java @@ -13,7 +13,7 @@ public interface Record extends Comparable, Formattable {} public interface Result extends List, Formattable {} - @SuppressWarnings({"unchecked", "nullness:new.array", "index:array.access.unsafe.high.constant"}) + @SuppressWarnings({"unchecked", "index:array.access.unsafe.high.constant"}) public static Collector>> intoResultGroups( Function keyMapper) { diff --git a/framework/tests/all-systems/java8inference/MemRefInfere.java b/framework/tests/all-systems/java8inference/MemRefInfere.java index 0ddd3bd9060e..225c70ae7ef2 100644 --- a/framework/tests/all-systems/java8inference/MemRefInfere.java +++ b/framework/tests/all-systems/java8inference/MemRefInfere.java @@ -13,7 +13,6 @@ public static MemRefInfere copyOf(Map Collector> toImmutableMap( Function keyFunction, Function valueFunction, diff --git a/framework/tests/flow/Values.java b/framework/tests/flow/Values.java index 3dd5ff46cdec..ad6a1828d682 100644 --- a/framework/tests/flow/Values.java +++ b/framework/tests/flow/Values.java @@ -52,17 +52,14 @@ void foo1(@ValueTypeAnno(1) Object o) {} void foo2(@ValueTypeAnno(2) Object o) {} - @SuppressWarnings("flowtest:return") @ValueTypeAnno Object get() { return null; } - @SuppressWarnings("flowtest:return") @ValueTypeAnno(1) Object get1() { return null; } - @SuppressWarnings("flowtest:return") @ValueTypeAnno(2) Object get2() { return null; }