Renaming biabduction Java tests

Summary: Renaming biabduction tests in infer/tests/codetoanalyze/java/biabduction/*.java to follow our naming convention: fooOk for tests where no report is expected, fooBad when we expect a report, and FP_ or FN_ prefixes when reality doesn't match the expectation

Reviewed By: jvillard

Differential Revision: D25900575

fbshipit-source-id: ad1370085
master
Gabriela Cunha Sampaio 4 years ago committed by Facebook GitHub Bot
parent 34eb8ebafb
commit caa8bd0e39

@ -13,7 +13,7 @@ public class AnalysisStops {
private native Object externalFunc();
public void skipPointerDerefMayCauseLocalFalseNegative() {
public void skipPointerDerefMayCauseLocalFalseNegativeBad() {
Object ret = externalFunc();
ret.toString();
int i = 1 / 0;
@ -25,7 +25,7 @@ public class AnalysisStops {
return new Object();
}
public void skipPointerDerefMayCauseCalleeFalsePositive() {
public void skipPointerDerefMayCauseCalleeFalsePositiveOk() {
Object o = skipPointerDerefPreventsSpecInferenceRetObj();
o.toString();
}
@ -36,7 +36,7 @@ public class AnalysisStops {
return 0;
}
public void skipPointerDerefMayCauseCalleeFalseNegative() {
public void skipPointerDerefMayCauseCalleeFalseNegativeBad() {
int ret = skipPointerDerefPreventsSpecInferenceRetZero();
int i = 1 / ret;
}
@ -45,7 +45,7 @@ public class AnalysisStops {
int j = 1 / i;
}
public void skipPointerDerefMayCauseInterprocFalseNegative() {
public void skipPointerDerefMayCauseInterprocFalseNegativeBad() {
int i = skipPointerDerefPreventsSpecInferenceRetZero();
divideByParam(i);
}
@ -54,12 +54,12 @@ public class AnalysisStops {
return (String) externalFunc();
}
public void castFailureOnUndefinedObjMayCauseFalseNegative() {
public void castFailureOnUndefinedObjMayCauseFalseNegativeBad() {
castExternalPreventsSpecInference();
int i = 1 / 0;
}
public void callOnCastUndefinedObjMayCauseFalseNegative() {
public void callOnCastUndefinedObjMayCauseFalseNegativeBad() {
String s = castExternalPreventsSpecInference();
s.toString();
int i = 1 / 0;
@ -81,54 +81,54 @@ public class AnalysisStops {
private native MyObj externalFunc2();
public void callOnUndefinedObjMayCauseFalseNegative() {
public void callOnUndefinedObjMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
int i = 1 / ret.retZero();
}
public void callOnUndefinedObjMayCauseFalsePositive() {
public void callOnUndefinedObjMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
int i = 1 / ret.retOne();
}
public void fieldWriteOnUndefinedObjMayCauseFalseNegative() {
public void fieldWriteOnUndefinedObjMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
ret.f = new Object();
int i = 1 / 0;
}
public void fieldWriteOnUndefinedObjMayCauseFalsePositive() {
public void fieldWriteOnUndefinedObjMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
ret.f = new Object();
ret.f.toString();
}
public void fieldReadOnUndefinedObjMayCauseFalseNegative() {
public void fieldReadOnUndefinedObjMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
Object o = ret.f;
int i = 1 / 0;
}
public void fieldReadOnUndefinedObjMayCauseFalsePositive() {
public void fieldReadOnUndefinedObjMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
Object o = ret.f;
o.toString();
}
public void recursiveAngelicTypesMayCauseFalseNegative() {
public void recursiveAngelicTypesMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
MyObj rec1 = ret.rec;
MyObj rec2 = rec1.rec;
int i = 1 / 0;
}
public void recursiveAngelicTypesMayCauseFalsePositive() {
public void recursiveAngelicTypesMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
MyObj rec1 = ret.rec;
rec1.rec.toString();
}
public void infiniteMaterializationMayCauseFalseNegative(boolean b) {
public void infiniteMaterializationMayCauseFalseNegativeBad(boolean b) {
MyObj rec = externalFunc2();
while (b) {
rec = rec.rec;
@ -136,7 +136,7 @@ public class AnalysisStops {
int i = 1 / 0;
}
public void infiniteMaterializationMayCauseFalsePositive(boolean b) {
public void infiniteMaterializationMayCauseFalsePositiveOk(boolean b) {
MyObj rec = externalFunc2();
while (b) {
rec = rec.rec;
@ -144,7 +144,7 @@ public class AnalysisStops {
rec.toString();
}
public void primitiveFieldOfAngelicObjMayCauseFalseNegative() {
public void primitiveFieldOfAngelicObjMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
if (ret.i == 0) {
int i = 1 / 0;
@ -153,14 +153,14 @@ public class AnalysisStops {
}
}
public void primitiveFieldOfAngelicObjMayCauseFalsePositive() {
public void primitiveFieldOfAngelicObjMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
if (ret.i != 0) {
int i = 1 / ret.i;
}
}
public void heapFieldOfAngelicObjMayCauseFalseNegative() {
public void heapFieldOfAngelicObjMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
Object obj = ret.f;
if (obj == ret.f) {
@ -168,7 +168,7 @@ public class AnalysisStops {
}
}
public void heapFieldOfAngelicObjMayCauseFalsePositive() {
public void heapFieldOfAngelicObjMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
Object obj = ret.f;
if (obj != ret.f) {
@ -176,7 +176,7 @@ public class AnalysisStops {
}
}
public void fieldReadAferCastMayCauseFalseNegative(Iterator<MyObj> iter) {
public void fieldReadAferCastMayCauseFalseNegativeBad(Iterator<MyObj> iter) {
MyObj ret = iter.next();
Object obj = ret.f;
obj.toString();
@ -186,51 +186,51 @@ public class AnalysisStops {
}
}
public void derefParam(MyObj obj) {
public void derefParamOk(MyObj obj) {
Object f = obj.f;
f.toString();
}
public void fieldReadInCalleeMayCauseFalsePositive() {
public void fieldReadInCalleeMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
derefParam(ret);
derefParamOk(ret);
}
public void fieldReadInCalleeMayCauseFalseNegative() {
public void fieldReadInCalleeMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
ret.f = null;
derefParam(ret);
derefParamOk(ret);
}
public void fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositive() {
public void fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
derefParam(ret.rec);
derefParamOk(ret.rec);
}
public void fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegative() {
public void fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
ret.rec.f = null;
derefParam(ret.rec);
derefParamOk(ret.rec);
}
public void accessPathOnParam(MyObj obj) {
public void accessPathOnParamOk(MyObj obj) {
MyObj ret = obj.rec;
Object f = ret.f;
f.toString();
}
public void accessPathInCalleeMayCauseFalsePositive() {
public void accessPathInCalleeMayCauseFalsePositiveOk() {
MyObj ret = externalFunc2();
accessPathOnParam(ret);
accessPathOnParamOk(ret);
}
public void accessPathInCalleeMayCauseFalseNegative() {
public void accessPathInCalleeMayCauseFalseNegativeBad() {
MyObj ret = externalFunc2();
ret.rec.f = null;
accessPathOnParam(ret);
accessPathOnParamOk(ret);
}
public void skipFunctionInLoopMayCauseFalseNegative() {
public void skipFunctionInLoopMayCauseFalseNegativeBad() {
Object o = null;
for (int i = 0; i < 10; i++) {
externalFunc();
@ -239,32 +239,32 @@ public class AnalysisStops {
}
// will fail to find error unless spec inference succeeds for all callees
public void specInferenceMayFailAndCauseFalseNegative(boolean b, Iterator<MyObj> iter) {
skipPointerDerefMayCauseLocalFalseNegative();
public void specInferenceMayFailAndCauseFalseNegativeBad(boolean b, Iterator<MyObj> iter) {
skipPointerDerefMayCauseLocalFalseNegativeBad();
skipPointerDerefPreventsSpecInferenceRetObj();
skipPointerDerefPreventsSpecInferenceRetZero();
skipPointerDerefMayCauseCalleeFalseNegative();
skipPointerDerefMayCauseInterprocFalseNegative();
castFailureOnUndefinedObjMayCauseFalseNegative();
callOnCastUndefinedObjMayCauseFalseNegative();
callOnUndefinedObjMayCauseFalseNegative();
callOnUndefinedObjMayCauseFalsePositive();
fieldWriteOnUndefinedObjMayCauseFalseNegative();
fieldWriteOnUndefinedObjMayCauseFalsePositive();
fieldReadOnUndefinedObjMayCauseFalseNegative();
fieldReadOnUndefinedObjMayCauseFalsePositive();
recursiveAngelicTypesMayCauseFalseNegative();
recursiveAngelicTypesMayCauseFalsePositive();
infiniteMaterializationMayCauseFalseNegative(b);
infiniteMaterializationMayCauseFalsePositive(b);
primitiveFieldOfAngelicObjMayCauseFalsePositive();
primitiveFieldOfAngelicObjMayCauseFalseNegative();
heapFieldOfAngelicObjMayCauseFalsePositive();
heapFieldOfAngelicObjMayCauseFalseNegative();
fieldReadAferCastMayCauseFalseNegative(iter);
fieldReadInCalleeMayCauseFalsePositive();
fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositive();
accessPathInCalleeMayCauseFalsePositive();
skipPointerDerefMayCauseCalleeFalseNegativeBad();
skipPointerDerefMayCauseInterprocFalseNegativeBad();
castFailureOnUndefinedObjMayCauseFalseNegativeBad();
callOnCastUndefinedObjMayCauseFalseNegativeBad();
callOnUndefinedObjMayCauseFalseNegativeBad();
callOnUndefinedObjMayCauseFalsePositiveOk();
fieldWriteOnUndefinedObjMayCauseFalseNegativeBad();
fieldWriteOnUndefinedObjMayCauseFalsePositiveOk();
fieldReadOnUndefinedObjMayCauseFalseNegativeBad();
fieldReadOnUndefinedObjMayCauseFalsePositiveOk();
recursiveAngelicTypesMayCauseFalseNegativeBad();
recursiveAngelicTypesMayCauseFalsePositiveOk();
infiniteMaterializationMayCauseFalseNegativeBad(b);
infiniteMaterializationMayCauseFalsePositiveOk(b);
primitiveFieldOfAngelicObjMayCauseFalsePositiveOk();
primitiveFieldOfAngelicObjMayCauseFalseNegativeBad();
heapFieldOfAngelicObjMayCauseFalsePositiveOk();
heapFieldOfAngelicObjMayCauseFalseNegativeBad();
fieldReadAferCastMayCauseFalseNegativeBad(iter);
fieldReadInCalleeMayCauseFalsePositiveOk();
fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositiveOk();
accessPathInCalleeMayCauseFalsePositiveOk();
int i = 1 / 0;
}
}

@ -9,40 +9,40 @@ package codetoanalyze.java.infer;
public class ArrayOutOfBounds {
public int arrayOutOfBounds() {
public int arrayOutOfBoundsBad() {
int[] arr = new int[1];
return arr[3];
}
public int arrayInBounds() {
public int arrayInBoundsOk() {
int[] arr = new int[2];
return arr[1];
}
// tests below this line are turned off until array functionality improves
public void arrayLoopOutOfBounds(int[] arr) {
public void FN_arrayLoopOutOfBoundsBad(int[] arr) {
for (int i = 0; i <= arr.length; i++) {
int j = arr[i];
}
}
public void arrayLoopInBounds(int[] arr) {
public void arrayLoopInBoundsOk(int[] arr) {
for (int i = 0; i < arr.length; i++) {
int j = arr[i];
}
}
public void buggyIter(int[] arr1, int[] arr2) {
public void FN_buggyIterBad(int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
arr2[i] = 7;
}
}
public void switchedArrsOutOfBounds() {
buggyIter(new int[11], new int[10]);
public void FN_switchedArrsOutOfBoundsBad() {
FN_buggyIterBad(new int[11], new int[10]);
}
public void buggyNestedLoop1(int[] arr1, int[] arr2) {
public void FN_buggyNestedLoop1Bad(int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
for (int j = 0; i < arr2.length; j++) {
arr1[i] = arr1[i] + arr2[j];
@ -50,11 +50,11 @@ public class ArrayOutOfBounds {
}
}
public void nestedOutOfBounds1() {
buggyNestedLoop1(new int[11], new int[10]);
public void FN_nestedOutOfBounds1Bad() {
FN_buggyNestedLoop1Bad(new int[11], new int[10]);
}
public void buggyNestedLoop2(int[] arr1, int[] arr2) {
public void FN_buggyNestedLoop2Bad(int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
for (int j = 0; j < arr2.length; i++) {
arr1[i] = arr1[i] + arr2[j];
@ -62,11 +62,11 @@ public class ArrayOutOfBounds {
}
}
public void nestedOutOfBounds2() {
buggyNestedLoop2(new int[11], new int[10]);
public void FN_nestedOutOfBounds2Bad() {
FN_buggyNestedLoop2Bad(new int[11], new int[10]);
}
public void buggyNestedLoop3(int[] arr1, int[] arr2) {
public void FN_buggyNestedLoop3Bad(int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
for (int j = 0; j < arr2.length; j++) {
arr1[i] = 2 * arr2[i];
@ -74,11 +74,11 @@ public class ArrayOutOfBounds {
}
}
public void nestedOutOfBounds3() {
buggyNestedLoop3(new int[11], new int[10]);
public void FN_nestedOutOfBounds3Bad() {
FN_buggyNestedLoop3Bad(new int[11], new int[10]);
}
public void safeNestedLoop(int[] arr1, int[] arr2) {
public void safeNestedLoopOk(int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
for (int j = 0; j < arr2.length; j++) {
arr1[i] = arr1[i] + arr2[j];
@ -86,7 +86,7 @@ public class ArrayOutOfBounds {
}
}
public void nestedInBounds() {
safeNestedLoop(new int[11], new int[10]);
public void nestedInBoundsOk() {
safeNestedLoopOk(new int[11], new int[10]);
}
}

@ -11,7 +11,7 @@ package codetoanalyze.java.infer;
public class AutoGenerated {
void npe() {
void npeBad() {
String s = null;
int n = s.length();
}

@ -11,26 +11,26 @@ import com.facebook.infer.builtins.InferBuiltins;
public class Builtins {
void blockError() {
void blockErrorOk() {
Object x = null;
InferBuiltins.assume(x != null);
x.toString();
}
void doNotBlockError(Object x) {
void doNotBlockErrorBad(Object x) {
Object y = null;
InferBuiltins.assume(x != null);
y.toString();
}
void blockErrorIntAssume(Object x) {
void blockErrorIntAssumeOk(Object x) {
Object y = null;
int i = 0;
InferBuiltins.assume(i != 0);
y.toString();
}
void causeError(Object x) {
void causeErrorBad(Object x) {
InferBuiltins.assume(x == null);
x.toString();
}

@ -36,31 +36,31 @@ class AnotherImplementationOfInterface implements MyInterface {
public class ClassCastExceptions {
public void classCastException() {
public void classCastExceptionBad() {
SuperClass a = new SubClassA();
SubClassB b = (SubClassB) a;
}
public int classCastExceptionImplementsInterfaceCallee(MyInterface i) {
public int classCastExceptionImplementsInterfaceCalleeOk(MyInterface i) {
ImplementationOfInterface impl = (ImplementationOfInterface) i;
return impl.getInt();
}
public int classCastExceptionImplementsInterface() {
return classCastExceptionImplementsInterfaceCallee(new AnotherImplementationOfInterface());
public int classCastExceptionImplementsInterfaceBad() {
return classCastExceptionImplementsInterfaceCalleeOk(new AnotherImplementationOfInterface());
}
public String getURL() {
return "http://bla.com";
}
public void openHttpURLConnection() throws IOException {
public void openHttpURLConnectionOk() throws IOException {
URL url = new URL(getURL());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.disconnect();
}
public void castingArrayOfPrimitiveTypeOK(int[] a) {
public void castingArrayOfPrimitiveTypeOk(int[] a) {
int[] b = (int[]) a;
}
}

@ -100,28 +100,28 @@ public class CloseableAsResourceExample {
}
}
void withException() throws LocalException {
void withExceptionBad() throws LocalException {
SomeResource res = new SomeResource();
res.doSomething();
res.close();
} // should report a resource leak
void closingWrapper() {
void closingWrapperOk() {
Resource r = new Resource();
Sub s = new Sub(r);
s.close();
}
void notClosingWrapper() {
void notClosingWrapperBad() {
Sub s = new Sub(new Resource());
s.mR.close();
} // should report a resource leak
void noNeedToCloseStringReader() {
void noNeedToCloseStringReaderOk() {
StringReader stringReader = new StringReader("paf!");
}
void noNeedToCloseByteArrayOutputStream() {
void noNeedToCloseByteArrayOutputStreamOk() {
ByteArrayOutputStream stream = new ByteArrayOutputStream(42);
}
@ -130,11 +130,11 @@ public class CloseableAsResourceExample {
ByteArrayInputStreamWrapper stream2 = new ByteArrayInputStreamWrapper(array);
}
void noNeedToCloseByteArrayInputStream(byte[] array) {
void noNeedToCloseByteArrayInputStreamOk(byte[] array) {
ByteArrayInputStream stream = new ByteArrayInputStream(array);
}
void closingWithCloseQuietly() {
void closingWithCloseQuietlyOk() {
SomeResource r = null;
try {
r = new SomeResource();
@ -145,7 +145,7 @@ public class CloseableAsResourceExample {
}
}
void failToCloseWithCloseQuietly() {
void failToCloseWithCloseQuietlyBad() {
try {
SomeResource r = new SomeResource();
r.doSomething();
@ -154,17 +154,17 @@ public class CloseableAsResourceExample {
}
}
void noLeakwithExceptionOnClose() throws IOException {
void noLeakwithExceptionOnCloseOk() throws IOException {
ResourceWithException res = new ResourceWithException();
res.close();
}
void noLeakWithCloseQuietlyAndExceptionOnClose() {
void noLeakWithCloseQuietlyAndExceptionOnCloseOk() {
ResourceWithException res = new ResourceWithException();
Utils.closeQuietly(res);
}
static T sourceOfNullWithResourceLeak() {
static T sourceOfNullWithResourceLeakBad() {
SomeResource r = new SomeResource();
return null;
}
@ -175,16 +175,16 @@ public class CloseableAsResourceExample {
public void close() {}
}
void leakFoundWhenIndirectlyImplementingCloseable() {
void leakFoundWhenIndirectlyImplementingCloseableBad() {
MyResource res = new MyResource();
}
void skippedCallClosesResourceOnArgs() {
void skippedCallClosesResourceOnArgsOk() {
SomeResource res = new SomeResource();
SomeResource.bar(res);
}
void skippedVritualCallDoesNotCloseResourceOnReceiver() {
void skippedVirtualCallDoesNotCloseResourceOnReceiverOk() {
SomeResource res = new SomeResource();
res.foo(42);
}

@ -29,7 +29,7 @@ public class CursorLeaks {
}
}
public Object cursorClosedCheckNull(SQLiteDatabase sqLiteDatabase) {
public Object cursorClosedCheckNullOk(SQLiteDatabase sqLiteDatabase) {
Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null);
Object value = null;
@ -47,7 +47,7 @@ public class CursorLeaks {
return value;
}
public Object cursorClosedCheckNullCheckClosed_FP(SQLiteDatabase sqLiteDatabase) {
public Object FP_cursorClosedCheckNullCheckClosedOk(SQLiteDatabase sqLiteDatabase) {
Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null);
Object value = null;
@ -65,7 +65,7 @@ public class CursorLeaks {
return value;
}
public int cursorNotClosed(SQLiteDatabase sqLiteDatabase) {
public int cursorNotClosedBad(SQLiteDatabase sqLiteDatabase) {
Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null);
return cursor.getCount();
}
@ -73,7 +73,7 @@ public class CursorLeaks {
Context mContext;
ContentResolver mContentResolver;
public int getImageCountHelperNotClosed(String customClause) {
public int getImageCountHelperNotClosedBad(String customClause) {
String[] projection = {"COUNT(*)"};
String selectionClause = selectionClause = customClause;
@ -90,7 +90,7 @@ public class CursorLeaks {
}
}
public int getImageCountHelperClosed(String customClause) {
public int getImageCountHelperClosedOk(String customClause) {
String[] projection = {"COUNT(*)"};
String selectionClause = selectionClause = customClause;
@ -107,7 +107,7 @@ public class CursorLeaks {
}
}
public int getBucketCountNotClosed() {
public int getBucketCountNotClosedBad() {
Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null);
if (cursor == null) {
return 0;
@ -120,7 +120,7 @@ public class CursorLeaks {
}
}
public int getBucketCountClosed() {
public int getBucketCountClosedOk() {
Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null);
if (cursor == null) {
return 0;
@ -137,21 +137,21 @@ public class CursorLeaks {
}
}
private void queryUVMLegacyDbNotClosed() {
private void queryUVMLegacyDbNotClosedBad() {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables("");
Cursor cursor = builder.query(null, null, "", null, null, null, null);
if (cursor != null) cursor.moveToFirst();
}
private void queryUVMLegacyDbClosed() {
private void queryUVMLegacyDbClosedOk() {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables("");
Cursor cursor = builder.query(null, null, "", null, null, null, null);
if (cursor != null) cursor.close();
}
public int completeDownloadClosed(DownloadManager downloadManager) {
public int completeDownloadClosedOk(DownloadManager downloadManager) {
DownloadManager.Query query = new DownloadManager.Query();
Cursor cursor = (Cursor) null;
try {
@ -166,7 +166,7 @@ public class CursorLeaks {
}
}
public int completeDownloadNotClosed(DownloadManager downloadManager) {
public int completeDownloadNotClosedBad(DownloadManager downloadManager) {
DownloadManager.Query query = new DownloadManager.Query();
Cursor cursor = null;
try {
@ -181,7 +181,7 @@ public class CursorLeaks {
}
}
private void loadPrefsFromContentProviderClosed() {
private void loadPrefsFromContentProviderClosedOk() {
ContentProviderClient contentProviderClient = mContentResolver.acquireContentProviderClient("");
if (contentProviderClient != null) {
Cursor cursor = null;
@ -198,7 +198,7 @@ public class CursorLeaks {
}
}
private void loadPrefsFromContentProviderNotClosed() {
private void loadPrefsFromContentProviderNotClosedBad() {
ContentProviderClient contentProviderClient = mContentResolver.acquireContentProviderClient("");
if (contentProviderClient == null) return;
Cursor cursor = null;
@ -223,7 +223,7 @@ public class CursorLeaks {
}
}
public Cursor cursorWrapperReturned(SQLiteDatabase sqLiteDatabase) {
public Cursor cursorWrapperReturnedOk(SQLiteDatabase sqLiteDatabase) {
Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null);
return new NamedCursor(cursor, "abc");
}
@ -237,7 +237,7 @@ public class CursorLeaks {
native NamedCursor createWrapper(Cursor cursor);
public NamedCursor cursorAttachedTheWrapper(SQLiteDatabase sqLiteDatabase) {
public NamedCursor cursorAttachedTheWrapperOk(SQLiteDatabase sqLiteDatabase) {
Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null);
return createWrapper(cursor);
}

@ -31,7 +31,7 @@ public class CursorNPEs {
Context mContext;
ContentResolver mContentResolver;
public void cursorFromContentResolverNPE(String customClause) {
public void cursorFromContentResolverNPEBad(String customClause) {
String[] projection = {"COUNT(*)"};
String selectionClause = selectionClause = customClause;
@ -42,7 +42,7 @@ public class CursorNPEs {
cursor.close();
}
public void cursorFromMediaNPE() {
public void cursorFromMediaNPEBad() {
Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null);
cursor.close();
}
@ -54,7 +54,7 @@ public class CursorNPEs {
cursor.close();
}
public int cursorFromDownloadManagerNPE(DownloadManager downloadManager) {
public int cursorFromDownloadManagerNPEBad(DownloadManager downloadManager) {
DownloadManager.Query query = new DownloadManager.Query();
Cursor cursor = null;
try {

@ -68,7 +68,7 @@ public class DynamicDispatch {
o.bar().toString();
}
static void dynamicDispatchShouldNotReportWhenCallingSupertype(Supertype o) {
static void FP_dynamicDispatchShouldNotReportWhenCallingSupertype(Supertype o) {
// should not report a warning because the Supertype implementation
// of foo() does not return null
o.foo().toString();
@ -77,7 +77,7 @@ public class DynamicDispatch {
static void dynamicDispatchShouldReportWhenCalledWithSubtypeParameter(Subtype o) {
// should report a warning because the Subtype implementation
// of foo() returns null
dynamicDispatchShouldNotReportWhenCallingSupertype(o);
FP_dynamicDispatchShouldNotReportWhenCallingSupertype(o);
}
static Object dynamicDispatchWrapperFoo(Supertype o) {
@ -120,7 +120,7 @@ public class DynamicDispatch {
mField = t;
}
static void dispatchOnFieldGood() {
static void dispatchOnFieldOk() {
Supertype subtype = new Subtype();
WithField object = new WithField(subtype);
object.mField.bar().toString();

@ -33,7 +33,7 @@ public class IntegerExample {
}
}
private static void testIntegerEqualsFN() {
private static void testIntegerEqualsOk() {
Integer a = new Integer(42);
Integer b = new Integer(42);
Integer c = null;

@ -325,7 +325,7 @@ public class NullPointerExceptions {
}
void someNPEAfterResourceLeak() {
T t = CloseableAsResourceExample.sourceOfNullWithResourceLeak();
T t = CloseableAsResourceExample.sourceOfNullWithResourceLeakBad();
t.f();
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save