diff --git a/dependencies/java/jsr-330/BUCK b/dependencies/java/jsr-330/BUCK new file mode 100644 index 000000000..a0e3d0b2b --- /dev/null +++ b/dependencies/java/jsr-330/BUCK @@ -0,0 +1,7 @@ +prebuilt_jar( + name = 'jsr-330', + binary_jar = 'javax.inject.jar', + visibility = [ + 'PUBLIC', + ], +) diff --git a/dependencies/java/jsr-330/javax.inject.jar b/dependencies/java/jsr-330/javax.inject.jar new file mode 100644 index 000000000..39e92a1a0 Binary files /dev/null and b/dependencies/java/jsr-330/javax.inject.jar differ diff --git a/infer/tests/codetoanalyze/java/eradicate/BUCK b/infer/tests/codetoanalyze/java/eradicate/BUCK index dc7b9a5e1..f68d37184 100644 --- a/infer/tests/codetoanalyze/java/eradicate/BUCK +++ b/infer/tests/codetoanalyze/java/eradicate/BUCK @@ -4,6 +4,7 @@ dependencies = [ '//infer/annotations:annotations', '//infer/lib/java/android:android', '//dependencies/java/jsr-305:jsr-305', + '//dependencies/java/jsr-330:jsr-330', ] java_library( diff --git a/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java b/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java index 2045eddf9..1c0712157 100644 --- a/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java +++ b/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java @@ -11,15 +11,19 @@ package codetoanalyze.java.eradicate; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import javax.inject.Inject; public class FieldNotInitialized { - @Nullable - String x; - String y; - @Nonnull - String z; // Means: assume it's initialized to nonnull value somewhere else. + String a; + + @Nullable String b; + + @Nonnull String c; // Means: assume it will be initialized to a nonnull value somewhere else. + + @Inject String d; // Means: assume it will be initialized via dependency injection + + // Eradicate should only report one initialization error + FieldNotInitialized() {} - FieldNotInitialized() { - } } diff --git a/infer/tests/endtoend/java/eradicate/FieldNotInitializedTest.java b/infer/tests/endtoend/java/eradicate/FieldNotInitializedTest.java index e1c02c175..d92987c2b 100644 --- a/infer/tests/endtoend/java/eradicate/FieldNotInitializedTest.java +++ b/infer/tests/endtoend/java/eradicate/FieldNotInitializedTest.java @@ -10,7 +10,7 @@ package endtoend.java.eradicate; import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; +import static utils.matchers.ResultContainsNumberOfErrorsInMethod.containsNumberOfErrors; import org.junit.BeforeClass; import org.junit.Test; @@ -39,16 +39,14 @@ public class FieldNotInitializedTest { @Test public void matchErrors() throws IOException, InterruptedException, InferException { - String[] methods = { - "", - }; assertThat( "Results should contain " + FIELD_NOT_INITIALIZED, inferResults, - containsExactly( + containsNumberOfErrors( FIELD_NOT_INITIALIZED, SOURCE_FILE, - methods)); + "", + 1)); } }