[infer][java] Add an example of dynamic dispatch handling on fields

Summary: This case was already working but there was no tests for it

Reviewed By: sblackshear

Differential Revision: D4529473

fbshipit-source-id: ca3ff02
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent c57323d67b
commit 0139ca211b

@ -26,6 +26,7 @@ codetoanalyze/java/infer/CursorNPEs.java, int CursorNPEs.cursorFromDownloadManag
codetoanalyze/java/infer/CursorNPEs.java, int CursorNPEs.cursorNotClosed(SQLiteDatabase), 7, RESOURCE_LEAK, [start of procedure cursorNotClosed(...),Taking false branch]
codetoanalyze/java/infer/CursorNPEs.java, void CursorNPEs.cursorFromContentResolverNPE(String), 12, NULL_DEREFERENCE, [start of procedure cursorFromContentResolverNPE(...)]
codetoanalyze/java/infer/CursorNPEs.java, void CursorNPEs.cursorFromMediaNPE(), 3, NULL_DEREFERENCE, [start of procedure cursorFromMediaNPE()]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch$WithField.dispatchOnFieldBad(), 3, NULL_DEREFERENCE, [start of procedure dispatchOnFieldBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure DynamicDispatch$WithField(...),return from a call to DynamicDispatch$WithField.<init>(DynamicDispatch$Subtype),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSubtypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSubtypeBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure dynamicDispatchWrapperFoo(...),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperFoo(DynamicDispatch$Subtype)]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSupertypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSupertypeBad(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),start of procedure dynamicDispatchWrapperBar(...),start of procedure bar(),return from a call to Object DynamicDispatch$Supertype.bar(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperBar(DynamicDispatch$Supertype)]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchShouldNotCauseFalseNegativeEasy(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]

@ -26,6 +26,7 @@ infer/tests/codetoanalyze/java/infer/CursorNPEs.java, int CursorNPEs.cursorFromD
infer/tests/codetoanalyze/java/infer/CursorNPEs.java, int CursorNPEs.cursorNotClosed(SQLiteDatabase), 7, RESOURCE_LEAK, [start of procedure cursorNotClosed(...),Taking false branch]
infer/tests/codetoanalyze/java/infer/CursorNPEs.java, void CursorNPEs.cursorFromContentResolverNPE(String), 12, NULL_DEREFERENCE, [start of procedure cursorFromContentResolverNPE(...)]
infer/tests/codetoanalyze/java/infer/CursorNPEs.java, void CursorNPEs.cursorFromMediaNPE(), 3, NULL_DEREFERENCE, [start of procedure cursorFromMediaNPE()]
infer/tests/codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch$WithField.dispatchOnFieldBad(), 3, NULL_DEREFERENCE, [start of procedure dispatchOnFieldBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure DynamicDispatch$WithField(...),return from a call to DynamicDispatch$WithField.<init>(DynamicDispatch$Subtype),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]
infer/tests/codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSubtypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSubtypeBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure dynamicDispatchWrapperFoo(...),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperFoo(DynamicDispatch$Subtype)]
infer/tests/codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSupertypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSupertypeBad(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),start of procedure dynamicDispatchWrapperBar(...),start of procedure bar(),return from a call to Object DynamicDispatch$Supertype.bar(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperBar(DynamicDispatch$Supertype)]
infer/tests/codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchShouldNotCauseFalseNegativeEasy(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]

@ -111,4 +111,26 @@ public class DynamicDispatch {
dynamicDispatchWrapperBar(o).toString();
}
static class WithField {
Supertype mField;
WithField(Supertype t) {
mField = t;
}
static void dispatchOnFieldGood() {
Supertype subtype = new Subtype();
WithField object = new WithField(subtype);
object.mField.bar().toString();
}
static void dispatchOnFieldBad() {
Supertype subtype = new Subtype();
WithField object = new WithField(subtype);
object.mField.foo().toString();
}
}
}

@ -54,6 +54,7 @@ codetoanalyze/java/infer/CursorNPEs.java, void CursorNPEs.cursorFromMediaNPE(),
codetoanalyze/java/infer/DivideByZero.java, int DivideByZero.callDivideByZeroInterProc(), 1, DIVIDE_BY_ZERO, [start of procedure callDivideByZeroInterProc(),start of procedure divideByZeroInterProc(...)]
codetoanalyze/java/infer/DivideByZero.java, int DivideByZero.divByZeroLocal(String), 3, DIVIDE_BY_ZERO, [start of procedure divByZeroLocal(...)]
codetoanalyze/java/infer/DivideByZero.java, int DivideByZero.divideByZeroWithStaticField(), 2, DIVIDE_BY_ZERO, [start of procedure divideByZeroWithStaticField(),start of procedure setXToZero(),return from a call to void DivideByZero.setXToZero(),start of procedure divideByZeroInterProc(...)]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch$WithField.dispatchOnFieldBad(), 3, NULL_DEREFERENCE, [start of procedure dispatchOnFieldBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure DynamicDispatch$WithField(...),return from a call to DynamicDispatch$WithField.<init>(DynamicDispatch$Subtype),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSubtypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSubtypeBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure dynamicDispatchWrapperFoo(...),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperFoo(DynamicDispatch$Subtype)]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchCallsWrapperWithSupertypeBad(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchCallsWrapperWithSupertypeBad(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),start of procedure dynamicDispatchWrapperBar(...),start of procedure bar(),return from a call to Object DynamicDispatch$Supertype.bar(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperBar(DynamicDispatch$Supertype)]
codetoanalyze/java/infer/DynamicDispatch.java, void DynamicDispatch.dynamicDispatchShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE, [start of procedure dynamicDispatchShouldNotCauseFalseNegativeEasy(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.<init>(),return from a call to DynamicDispatch$Subtype.<init>(),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()]

Loading…
Cancel
Save