From 5b191c53ae6be5259537a89d6d7a715a9e40e187 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 12 Jul 2019 03:55:41 -0700 Subject: [PATCH] [annotreach] clean up tests Summary: Move annotation reachability tests to their own directory. Clean up and complete the tests. Reviewed By: jvillard Differential Revision: D16201387 fbshipit-source-id: 8a87a25b7 --- .../java/annotreach/.inferconfig | 21 +++++ ...notationReachabilityDuplicatesExample.java | 0 .../java/{checkers => annotreach}/Branch.java | 0 .../CustomAnnotations.java | 0 .../ExpensiveCallExample.java | 0 .../ExpensiveInheritanceExample.java | 0 .../ExpensiveInterfaceExample.java | 0 .../ExpensiveSubtypingExample.java | 0 .../codetoanalyze/java/annotreach/Makefile | 13 +++ .../NoAllocationExample.java | 0 .../TwoCheckersExample.java | 0 .../{checkers => annotreach}/UiThreads.java | 88 ++++++++++++------- .../codetoanalyze/java/annotreach/issues.exp | 48 ++++++++++ .../codetoanalyze/java/checkers/.inferconfig | 18 ---- .../codetoanalyze/java/checkers/Makefile | 2 +- .../codetoanalyze/java/checkers/issues.exp | 39 -------- 16 files changed, 141 insertions(+), 88 deletions(-) create mode 100644 infer/tests/codetoanalyze/java/annotreach/.inferconfig rename infer/tests/codetoanalyze/java/{checkers => annotreach}/AnnotationReachabilityDuplicatesExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/Branch.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/CustomAnnotations.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/ExpensiveCallExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/ExpensiveInheritanceExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/ExpensiveInterfaceExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/ExpensiveSubtypingExample.java (100%) create mode 100644 infer/tests/codetoanalyze/java/annotreach/Makefile rename infer/tests/codetoanalyze/java/{checkers => annotreach}/NoAllocationExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/TwoCheckersExample.java (100%) rename infer/tests/codetoanalyze/java/{checkers => annotreach}/UiThreads.java (54%) create mode 100644 infer/tests/codetoanalyze/java/annotreach/issues.exp diff --git a/infer/tests/codetoanalyze/java/annotreach/.inferconfig b/infer/tests/codetoanalyze/java/annotreach/.inferconfig new file mode 100644 index 000000000..df54ed73d --- /dev/null +++ b/infer/tests/codetoanalyze/java/annotreach/.inferconfig @@ -0,0 +1,21 @@ +{ + "force-delete-results-dir": true, + "modeled-expensive": [ + { + "language": "Java", + "class": "android.app.Activity", + "method": "findViewById" + }, + { + "language": "Java", + "class": "android.view.View", + "method": "findViewById" + } + ], + "annotation-reachability-custom-pairs": [ + { + "sources": ["UserDefinedSource1", "UserDefinedSource2"], + "sink": "UserDefinedSink" + } + ] +} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java b/infer/tests/codetoanalyze/java/annotreach/AnnotationReachabilityDuplicatesExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java rename to infer/tests/codetoanalyze/java/annotreach/AnnotationReachabilityDuplicatesExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/Branch.java b/infer/tests/codetoanalyze/java/annotreach/Branch.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/Branch.java rename to infer/tests/codetoanalyze/java/annotreach/Branch.java diff --git a/infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java b/infer/tests/codetoanalyze/java/annotreach/CustomAnnotations.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java rename to infer/tests/codetoanalyze/java/annotreach/CustomAnnotations.java diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java b/infer/tests/codetoanalyze/java/annotreach/ExpensiveCallExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java rename to infer/tests/codetoanalyze/java/annotreach/ExpensiveCallExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java b/infer/tests/codetoanalyze/java/annotreach/ExpensiveInheritanceExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java rename to infer/tests/codetoanalyze/java/annotreach/ExpensiveInheritanceExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java b/infer/tests/codetoanalyze/java/annotreach/ExpensiveInterfaceExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java rename to infer/tests/codetoanalyze/java/annotreach/ExpensiveInterfaceExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java b/infer/tests/codetoanalyze/java/annotreach/ExpensiveSubtypingExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java rename to infer/tests/codetoanalyze/java/annotreach/ExpensiveSubtypingExample.java diff --git a/infer/tests/codetoanalyze/java/annotreach/Makefile b/infer/tests/codetoanalyze/java/annotreach/Makefile new file mode 100644 index 000000000..788409bd2 --- /dev/null +++ b/infer/tests/codetoanalyze/java/annotreach/Makefile @@ -0,0 +1,13 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +TESTS_DIR = ../../.. + +INFER_OPTIONS = --debug-exceptions --annotation-reachability-only + +INFERPRINT_OPTIONS = --issues-tests +SOURCES = $(wildcard *.java) + +include $(TESTS_DIR)/javac.make diff --git a/infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java b/infer/tests/codetoanalyze/java/annotreach/NoAllocationExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java rename to infer/tests/codetoanalyze/java/annotreach/NoAllocationExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java b/infer/tests/codetoanalyze/java/annotreach/TwoCheckersExample.java similarity index 100% rename from infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java rename to infer/tests/codetoanalyze/java/annotreach/TwoCheckersExample.java diff --git a/infer/tests/codetoanalyze/java/checkers/UiThreads.java b/infer/tests/codetoanalyze/java/annotreach/UiThreads.java similarity index 54% rename from infer/tests/codetoanalyze/java/checkers/UiThreads.java rename to infer/tests/codetoanalyze/java/annotreach/UiThreads.java index 553693807..73d28a627 100644 --- a/infer/tests/codetoanalyze/java/checkers/UiThreads.java +++ b/infer/tests/codetoanalyze/java/annotreach/UiThreads.java @@ -44,63 +44,91 @@ public class UiThreads { @ForNonUiThread void forNonUiThread() {} - @ForUiThread - void callForNonUiThreadBad1() { - forNonUiThread(); + @WorkerThread + void workerThread() {} + + void unannotated() {} + + void callUiThreadMethod() { + uiThread(); + mainThread(); + forUiThread(); } - @UiThread - void callForNonUiThreadBad2() { + void callNonUiThreadMethod() { forNonUiThread(); + workerThread(); } - @MainThread - void callForNonUiThreadBad3() { - forNonUiThread(); + @UiThread + void callsFromUiThreadBad() { + callNonUiThreadMethod(); } - @AnyThread - void callForNonUiThreadBad4() { - forNonUiThread(); + @UiThread + void callsFromUiThreadOk() { + callUiThreadMethod(); + anyThread(); + unannotated(); } - @AnyThread - void callUiThreadBad1() { - uiThread(); + @MainThread + void callsFromMainThreadBad() { + callNonUiThreadMethod(); } - @ForNonUiThread - void callUiThreadBad2() { - uiThread(); + @MainThread + void callsFromMainThreadOk() { + callUiThreadMethod(); + anyThread(); + unannotated(); } - @WorkerThread - void callUiThreadBad3() { - uiThread(); + @ForUiThread + void callsFromForUiThreadBad() { + callNonUiThreadMethod(); } @ForUiThread - void callUiThreadOk() { - uiThread(); + void callsFromForUiThreadOk() { + callUiThreadMethod(); + anyThread(); + unannotated(); } - @UiThread - void callForUiThreadOk() { - forUiThread(); + @ForNonUiThread + void callsFromNonUiThreadBad() { + callUiThreadMethod(); } @ForNonUiThread - void callAnyThreadOk1() { + void callsFromNonUiThreadOk() { + callNonUiThreadMethod(); anyThread(); + unannotated(); } - @ForUiThread - void callAnyThreadOk2() { + @WorkerThread + void callsFromWorkerThreadBad() { + callUiThreadMethod(); + } + + @WorkerThread + void callsFromWorkerThreadOk() { + callNonUiThreadMethod(); anyThread(); + unannotated(); } - @UiThread - void callAnyThreadOk3() { + @AnyThread + void callsFromAnyThreadBad() { + callUiThreadMethod(); + callNonUiThreadMethod(); + } + + @AnyThread + void callsFromAnyThreadOk() { anyThread(); + unannotated(); } } diff --git a/infer/tests/codetoanalyze/java/annotreach/issues.exp b/infer/tests/codetoanalyze/java/annotreach/issues.exp new file mode 100644 index 000000000..1def3cc25 --- /dev/null +++ b/infer/tests/codetoanalyze/java/annotreach/issues.exp @@ -0,0 +1,48 @@ +codetoanalyze/java/annotreach/AnnotationReachabilityDuplicatesExample.java, codetoanalyze.java.checkers.AnnotationReachabilityDuplicatesExample.perfCriticalBad1():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/AnnotationReachabilityDuplicatesExample.java, codetoanalyze.java.checkers.AnnotationReachabilityDuplicatesExample.perfCriticalBad2():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/CustomAnnotations.java, codetoanalyze.java.checkers.CustomAnnotations.source1Bad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/CustomAnnotations.java, codetoanalyze.java.checkers.CustomAnnotations.source2Bad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.annotatedPerformanceCriticalInInterface():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callMethodOnExpensiveClass(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callingExpensiveMethodFromInterface(codetoanalyze.java.checkers.ExpensiveInterfaceExample):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveInConditionalBranch():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveInTheUnlikelyElseBranch():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveWithDisjunctionAfterUnlikely():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveWithOverriddenUnlikelyCondition():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsFindViewByIdFromActivity(android.support.v4.app.FragmentActivity,int):android.view.View, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsFindViewByIdFromView(android.widget.ImageView,int):android.view.View, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.directlyCallingExpensiveMethod():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.indirectlyCallingExpensiveMethod():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.longerCallStackToExpensive():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.onlyOneExpensiveCallUsingUnlikely():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod1(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod2(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod3(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod1(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod2(codetoanalyze.java.checkers.ExpensiveSubclass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod3(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.doesReportBecauseTypeFlowInsensitive(codetoanalyze.java.checkers.A):void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.reportsAssumingObjectOfTypeA():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.reportsBecauseFooIsExpensiveInA(codetoanalyze.java.checkers.A):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveInterfaceExample.java, codetoanalyze.java.checkers.ExpensiveInterfaceExample$ImplementsInterface.m1():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/ExpensiveSubtypingExample.java, codetoanalyze.java.checkers.ExpensiveSubtypingExample.m3():void, 0, CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/NoAllocationExample.java, codetoanalyze.java.checkers.NoAllocationExample.directlyAllocatingMethod():void, 1, CHECKERS_ALLOCATES_MEMORY, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/NoAllocationExample.java, codetoanalyze.java.checkers.NoAllocationExample.indirectlyAllocatingMethod():void, 1, CHECKERS_ALLOCATES_MEMORY, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/TwoCheckersExample.java, codetoanalyze.java.checkers.TwoCheckersExample.shouldRaisePerformanceCriticalError():java.util.List, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromAnyThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromAnyThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromAnyThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromAnyThreadBad():void, 2, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromAnyThreadBad():void, 2, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromForUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromForUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromMainThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromMainThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromNonUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromNonUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromNonUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromUiThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromWorkerThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromWorkerThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] +codetoanalyze/java/annotreach/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callsFromWorkerThreadBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] diff --git a/infer/tests/codetoanalyze/java/checkers/.inferconfig b/infer/tests/codetoanalyze/java/checkers/.inferconfig index c3d06f43e..96c38e43d 100644 --- a/infer/tests/codetoanalyze/java/checkers/.inferconfig +++ b/infer/tests/codetoanalyze/java/checkers/.inferconfig @@ -1,23 +1,5 @@ { "force-delete-results-dir": true, - "modeled-expensive": [ - { - "language": "Java", - "class": "android.app.Activity", - "method": "findViewById" - }, - { - "language": "Java", - "class": "android.view.View", - "method": "findViewById" - } - ], - "annotation-reachability-custom-pairs": [ - { - "sources": ["UserDefinedSource1", "UserDefinedSource2"], - "sink": "UserDefinedSink" - } - ], "external-java-packages": [ "external." ] diff --git a/infer/tests/codetoanalyze/java/checkers/Makefile b/infer/tests/codetoanalyze/java/checkers/Makefile index ab82fa00f..0ce68d834 100644 --- a/infer/tests/codetoanalyze/java/checkers/Makefile +++ b/infer/tests/codetoanalyze/java/checkers/Makefile @@ -7,7 +7,7 @@ TESTS_DIR = ../../.. INFER_OPTIONS = \ --debug-exceptions --no-default-checkers \ - --annotation-reachability --fragment-retains-view --immutable-cast --printf-args --quandary \ + --fragment-retains-view --immutable-cast --printf-args --quandary \ --nullsafe --racerd \ INFERPRINT_OPTIONS = --issues-tests diff --git a/infer/tests/codetoanalyze/java/checkers/issues.exp b/infer/tests/codetoanalyze/java/checkers/issues.exp index 4271f1c25..1191c9a22 100644 --- a/infer/tests/codetoanalyze/java/checkers/issues.exp +++ b/infer/tests/codetoanalyze/java/checkers/issues.exp @@ -1,38 +1,8 @@ -codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java, codetoanalyze.java.checkers.AnnotationReachabilityDuplicatesExample.perfCriticalBad1():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java, codetoanalyze.java.checkers.AnnotationReachabilityDuplicatesExample.perfCriticalBad2():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/CustomAnnotations.java, codetoanalyze.java.checkers.CustomAnnotations.source1Bad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/CustomAnnotations.java, codetoanalyze.java.checkers.CustomAnnotations.source2Bad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.annotatedPerformanceCriticalInInterface():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callMethodOnExpensiveClass(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callingExpensiveMethodFromInterface(codetoanalyze.java.checkers.ExpensiveInterfaceExample):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveInConditionalBranch():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveInTheUnlikelyElseBranch():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveWithDisjunctionAfterUnlikely():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsExpensiveWithOverriddenUnlikelyCondition():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsFindViewByIdFromActivity(android.support.v4.app.FragmentActivity,int):android.view.View, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.callsFindViewByIdFromView(android.widget.ImageView,int):android.view.View, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.directlyCallingExpensiveMethod():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.indirectlyCallingExpensiveMethod():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.longerCallStackToExpensive():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.ExpensiveCallExample.onlyOneExpensiveCallUsingUnlikely():void, 4, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod1(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod2(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalClass.performanceCriticalMethod3(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod1(codetoanalyze.java.checkers.ExpensiveClass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod2(codetoanalyze.java.checkers.ExpensiveSubclass):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveCallExample.java, codetoanalyze.java.checkers.PerformanceCriticalSubclass.subclassPerformanceCriticalMethod3(codetoanalyze.java.checkers.Other):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.doesReportBecauseTypeFlowInsensitive(codetoanalyze.java.checkers.A):void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.reportsAssumingObjectOfTypeA():void, 2, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, codetoanalyze.java.checkers.ExpensiveInheritanceExample.reportsBecauseFooIsExpensiveInA(codetoanalyze.java.checkers.A):void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveInterfaceExample.java, codetoanalyze.java.checkers.ExpensiveInterfaceExample$ImplementsInterface.m1():void, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/ExpensiveSubtypingExample.java, codetoanalyze.java.checkers.ExpensiveSubtypingExample.m3():void, 0, CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED, no_bucket, ERROR, [] codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, [] codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCast(com.google.common.collect.ImmutableList):java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCast(...) returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.] codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCastFromField():java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCastFromField() returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.] -codetoanalyze/java/checkers/NoAllocationExample.java, codetoanalyze.java.checkers.NoAllocationExample.directlyAllocatingMethod():void, 1, CHECKERS_ALLOCATES_MEMORY, no_bucket, ERROR, [] -codetoanalyze/java/checkers/NoAllocationExample.java, codetoanalyze.java.checkers.NoAllocationExample.indirectlyAllocatingMethod():void, 1, CHECKERS_ALLOCATES_MEMORY, no_bucket, ERROR, [] codetoanalyze/java/checkers/NullableSuggest.java, codetoanalyze.java.checkers.NullableSuggest.assignNullBad():void, 1, NULLSAFE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field obj0 is assigned null here] codetoanalyze/java/checkers/NullableSuggest.java, codetoanalyze.java.checkers.NullableSuggest.assignNullToFieldInOtherClassBad():void, 2, NULLSAFE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field obj2 is assigned null here] codetoanalyze/java/checkers/NullableSuggest.java, codetoanalyze.java.checkers.NullableSuggest.assignNullToFieldTransitiveBad(boolean):void, 3, NULLSAFE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field obj0 could be assigned here,Variable could be assigned here,Variable could be assigned here,Variable is assigned null here] @@ -48,12 +18,3 @@ codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers. codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.stringInsteadOfInteger(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, [] codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.wrongNumberOfArguments(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, [] codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.SuppressedPrintfArgsChecker.classSuppressed(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, [] -codetoanalyze/java/checkers/TwoCheckersExample.java, codetoanalyze.java.checkers.TwoCheckersExample.shouldRaiseImmutableCastError():java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method shouldRaiseImmutableCastError() returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.] -codetoanalyze/java/checkers/TwoCheckersExample.java, codetoanalyze.java.checkers.TwoCheckersExample.shouldRaisePerformanceCriticalError():java.util.List, 1, CHECKERS_CALLS_EXPENSIVE_METHOD, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callForNonUiThreadBad1():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callForNonUiThreadBad2():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callForNonUiThreadBad3():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callForNonUiThreadBad4():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callUiThreadBad1():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callUiThreadBad2():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] -codetoanalyze/java/checkers/UiThreads.java, codetoanalyze.java.checkers.UiThreads.callUiThreadBad3():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, []