From 1989ef7e28d5d037796fd3afba46ab0958f7378f Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Wed, 26 Sep 2018 15:48:54 -0700 Subject: [PATCH] [eradicate] add example false positive caused by not finding the attributes Reviewed By: ezgicicek Differential Revision: D10046612 fbshipit-source-id: 95cf509cf --- .../java/eradicate/ParameterNotNullable.java | 10 ++++++++++ infer/tests/codetoanalyze/java/eradicate/issues.exp | 1 + 2 files changed, 11 insertions(+) diff --git a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java index b206f4c8b..672070712 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java @@ -100,4 +100,14 @@ public class ParameterNotNullable { this(3, null); // NPE } } + + void indirectSignatureLookup_FP(SomeClass c) { + c.acceptsNullableParameter(null); + } } + +interface SomeInterface { + void acceptsNullableParameter(@Nullable Object object); +} + +abstract class SomeClass implements SomeInterface {} diff --git a/infer/tests/codetoanalyze/java/eradicate/issues.exp b/infer/tests/codetoanalyze/java/eradicate/issues.exp index 1887b33be..28a51338e 100644 --- a/infer/tests/codetoanalyze/java/eradicate/issues.exp +++ b/infer/tests/codetoanalyze/java/eradicate/issues.exp @@ -65,6 +65,7 @@ codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.N codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable$ConstructorCall.(codetoanalyze.java.eradicate.ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 100)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNull():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: null constant at line 36)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNullable(java.lang.String):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.indirectSignatureLookup_FP(codetoanalyze.java.eradicate.SomeClass):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`SomeClass.acceptsNullableParameter(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 105)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testClassGetResourceArgument(java.lang.Class):java.net.URL, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Class.getResource(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 78)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetPropertyArgument():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 69)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetenvBad():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 74)]