diff --git a/infer/src/checkers/modelTables.ml b/infer/src/checkers/modelTables.ml index 51f005b85..1f5d33e3c 100644 --- a/infer/src/checkers/modelTables.ml +++ b/infer/src/checkers/modelTables.ml @@ -140,6 +140,7 @@ let annotated_list_nullable = o1, "com.google.common.util.concurrent.SettableFuture.setException(java.lang.Throwable):boolean"; o1, "java.io.File.(java.lang.String)"; n1, "java.io.PrintStream.print(java.lang.String):void"; + (n, [o]), "java.lang.Class.getResource(java.lang.String):java.net.URL"; o1, "java.lang.Class.isAssignableFrom(java.lang.Class):boolean"; n1, "java.lang.Integer.equals(java.lang.Object):boolean"; n2, "java.lang.RuntimeException.(java.lang.String,java.lang.Throwable)"; diff --git a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java index 5c5c413c9..1823476a2 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java @@ -10,6 +10,7 @@ package codetoanalyze.java.eradicate; import java.lang.System; +import java.net.URL; import javax.annotation.Nullable; import android.annotation.SuppressLint; @@ -71,4 +72,8 @@ public class ParameterNotNullable { return s; } + static @Nullable URL testClassGetResourceArgument(Class cls) { + return cls.getResource(null); + } + } diff --git a/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java index e6c902d2c..22fc245a1 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java @@ -11,6 +11,7 @@ package codetoanalyze.java.eradicate; import com.google.common.base.Optional; +import java.net.URL; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; @@ -115,4 +116,9 @@ public class ReturnNotNullable { return null; } } + + URL getResourceNullable(Class cls, String name) { + return cls.getResource(name); + } + } diff --git a/infer/tests/endtoend/java/eradicate/ParameterNotNullableTest.java b/infer/tests/endtoend/java/eradicate/ParameterNotNullableTest.java index efc39b155..7fe015a31 100644 --- a/infer/tests/endtoend/java/eradicate/ParameterNotNullableTest.java +++ b/infer/tests/endtoend/java/eradicate/ParameterNotNullableTest.java @@ -43,6 +43,7 @@ public class ParameterNotNullableTest { "callNull", "callNullable", "testSystemGetPropertyArgument", + "testClassGetResourceArgument", }; assertThat( "Results should contain " + PARAMETER_NOT_NULLABLE, diff --git a/infer/tests/endtoend/java/eradicate/ReturnNotNullableTest.java b/infer/tests/endtoend/java/eradicate/ReturnNotNullableTest.java index 238c2859f..1209b98f2 100644 --- a/infer/tests/endtoend/java/eradicate/ReturnNotNullableTest.java +++ b/infer/tests/endtoend/java/eradicate/ReturnNotNullableTest.java @@ -58,6 +58,7 @@ public class ReturnNotNullableTest { "returnNullable", "return_null_in_catch", "return_null_in_catch_after_throw", + "getResourceNullable", }; List errorPatterns = createPatterns( RETURN_NOT_NULLABLE,