From df191c4084d414ebdddfc5a25a8f6194b6e9adec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Mon, 29 Mar 2021 04:53:05 -0700 Subject: [PATCH] [biabduction] Make test independent of Java specific concat Summary: This addresses a test difference between java versions. Infer's java tests are recorded with Java8 where string concat with a constant string uses `toString`. However, if tests are run on a machine where Java 11 is used, string concat is done via `makeConcatWithConstants` which causes tests to fail. As a workaround, we replace the test so that Java version dependent string concat is not used. Reviewed By: ngorogiannis Differential Revision: D27394621 fbshipit-source-id: dfe1af2ac --- .../codetoanalyze/java/biabduction/NullPointerExceptions.java | 4 ++-- infer/tests/codetoanalyze/java/biabduction/issues.exp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/infer/tests/codetoanalyze/java/biabduction/NullPointerExceptions.java b/infer/tests/codetoanalyze/java/biabduction/NullPointerExceptions.java index 0dceefb77..24abf878b 100644 --- a/infer/tests/codetoanalyze/java/biabduction/NullPointerExceptions.java +++ b/infer/tests/codetoanalyze/java/biabduction/NullPointerExceptions.java @@ -599,12 +599,12 @@ public class NullPointerExceptions { } String getString2() { - return "string 2"; + return "Test string 2"; } void stringVarEqualsFalseNPE() { final String c1 = "Test string 1"; - String c2 = "Test " + getString2(); + String c2 = getString2(); String s = null; if (!c1.equals(c2)) { s.toString(); // NPE diff --git a/infer/tests/codetoanalyze/java/biabduction/issues.exp b/infer/tests/codetoanalyze/java/biabduction/issues.exp index 5d72f5bbf..180e31e9b 100644 --- a/infer/tests/codetoanalyze/java/biabduction/issues.exp +++ b/infer/tests/codetoanalyze/java/biabduction/issues.exp @@ -129,7 +129,7 @@ codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.in codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.preconditionCheckStateTest(codetoanalyze.java.infer.NullPointerExceptions$D):int, 1, PRECONDITION_NOT_MET, no_bucket, WARNING, [start of procedure preconditionCheckStateTest(...),Taking false branch] codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.someNPEAfterResourceLeak():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure someNPEAfterResourceLeak(),start of procedure sourceOfNullWithResourceLeakBad(),start of procedure SomeResource(),return from a call to SomeResource.(),return from a call to T CloseableAsResourceExample.sourceOfNullWithResourceLeakBad()] codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.stringConstantEqualsFalseNotNPE_FP():void, 10, NULL_DEREFERENCE, B1, ERROR, [start of procedure stringConstantEqualsFalseNotNPE_FP(),Taking false branch] -codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.stringVarEqualsFalseNPE():void, 5, NULL_DEREFERENCE, B1, ERROR, [start of procedure stringVarEqualsFalseNPE(),start of procedure getString2(),return from a call to String NullPointerExceptions.getString2(),Skipping toString(): unknown method,Taking true branch] +codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.stringVarEqualsFalseNPE():void, 5, NULL_DEREFERENCE, B1, ERROR, [start of procedure stringVarEqualsFalseNPE(),start of procedure getString2(),return from a call to String NullPointerExceptions.getString2(),Taking true branch] codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.testSystemGetPropertyArgument():java.lang.String, 1, NULL_DEREFERENCE, B1, ERROR, [start of procedure testSystemGetPropertyArgument()] codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.testSystemGetPropertyReturn():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure testSystemGetPropertyReturn()] codetoanalyze/java/biabduction/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.tryLockThrows(java.nio.channels.FileChannel):java.lang.String, 6, NULL_DEREFERENCE, B1, ERROR, [start of procedure tryLockThrows(...),exception java.io.IOException,Switch condition is true. Entering switch case]