Reviewed By: jeremydubreil Differential Revision: D3791189 fbshipit-source-id: ce0b7d6master
parent
674f30de2c
commit
257f4976f0
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"never_returning_null": [
|
||||||
|
{
|
||||||
|
"language": "Java",
|
||||||
|
"source_contains": "_AUTOMATICALLY_GENERATED_"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "Java",
|
||||||
|
"class": "codetoanalyze.java.infer.SomeLibrary",
|
||||||
|
"method": "get"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"infer-blacklist-files-containing": [
|
||||||
|
"@generated"
|
||||||
|
],
|
||||||
|
"enable_checks": [
|
||||||
|
"UNSAFE_GUARDED_BY_ACCESS"
|
||||||
|
],
|
||||||
|
"skip_translation": [
|
||||||
|
{
|
||||||
|
"language": "Java",
|
||||||
|
"source_contains": "_SHOULD_BE_SKIPPED_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
../infer/ArrayOutOfBounds.java
|
@ -1,42 +0,0 @@
|
|||||||
sources = glob(['**/*.java'])
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
'//infer/annotations:annotations',
|
|
||||||
]
|
|
||||||
|
|
||||||
java_library(
|
|
||||||
name = 'tracing',
|
|
||||||
srcs = sources,
|
|
||||||
deps = dependencies,
|
|
||||||
visibility = [
|
|
||||||
'PUBLIC'
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
out = 'out'
|
|
||||||
clean_cmd = ' '.join(['rm', '-rf', out])
|
|
||||||
classpath = ':'.join([('$(classpath ' + path + ')') for path in dependencies])
|
|
||||||
infer_cmd = ' '.join([
|
|
||||||
'infer',
|
|
||||||
'--no-progress-bar',
|
|
||||||
'--absolute-paths',
|
|
||||||
'-o', out,
|
|
||||||
'-a', 'tracing',
|
|
||||||
'--',
|
|
||||||
'javac',
|
|
||||||
'-cp', classpath,
|
|
||||||
'$SRCS',
|
|
||||||
])
|
|
||||||
copy_cmd = ' '.join(['cp', out + '/report.csv', '$OUT'])
|
|
||||||
command = ' && '.join([clean_cmd, infer_cmd, copy_cmd])
|
|
||||||
|
|
||||||
genrule(
|
|
||||||
name = 'analyze',
|
|
||||||
srcs = sources,
|
|
||||||
out = 'report.csv',
|
|
||||||
cmd = command,
|
|
||||||
deps = dependencies + [':tracing'],
|
|
||||||
visibility = [
|
|
||||||
'PUBLIC',
|
|
||||||
]
|
|
||||||
)
|
|
@ -0,0 +1 @@
|
|||||||
|
../infer/ClassCastExceptions.java
|
@ -0,0 +1 @@
|
|||||||
|
../infer/CloseableAsResourceExample.java
|
@ -0,0 +1,42 @@
|
|||||||
|
# Copyright (c) 2016 - present Facebook, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the BSD style license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
|
include ../Makefile
|
||||||
|
|
||||||
|
ANALYZER = tracing
|
||||||
|
|
||||||
|
FILES_FOR_TRACING = \
|
||||||
|
T2.java \
|
||||||
|
\
|
||||||
|
ArrayIndexOutOfBoundsExceptionExample.java \
|
||||||
|
ClassCastExceptionExample.java \
|
||||||
|
LazyDynamicDispatchExample.java \
|
||||||
|
LocallyDefinedExceptionExample.java \
|
||||||
|
NullPointerExceptionExample.java \
|
||||||
|
ReportOnMainExample.java \
|
||||||
|
UnavoidableExceptionExample.java \
|
||||||
|
\
|
||||||
|
|
||||||
|
FILES_LINKED_FROM_INFER = \
|
||||||
|
T.java \
|
||||||
|
SkippedSourceFile.java \
|
||||||
|
SomeLibrary.java \
|
||||||
|
Utils.java \
|
||||||
|
CloseableAsResourceExample.java \
|
||||||
|
NeverNullSource.java \
|
||||||
|
\
|
||||||
|
ArrayOutOfBounds.java \
|
||||||
|
ClassCastExceptions.java \
|
||||||
|
NullPointerExceptions.java \
|
||||||
|
|
||||||
|
FILES = $(FILES_FOR_TRACING) $(FILES_LINKED_FROM_INFER)
|
||||||
|
|
||||||
|
compile:
|
||||||
|
javac -cp $(CLASSPATH) $(FILES)
|
||||||
|
|
||||||
|
analyze:
|
||||||
|
$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null
|
@ -0,0 +1 @@
|
|||||||
|
../infer/NeverNullSource.java
|
@ -0,0 +1 @@
|
|||||||
|
../infer/NullPointerExceptions.java
|
@ -0,0 +1 @@
|
|||||||
|
../infer/SkippedSourceFile.java
|
@ -0,0 +1 @@
|
|||||||
|
../infer/SomeLibrary.java
|
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package codetoanalyze.java.tracing;
|
|
||||||
|
|
||||||
public class T {
|
|
||||||
int x;
|
|
||||||
void f() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1 @@
|
|||||||
|
../infer/T.java
|
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package codetoanalyze.java.tracing;
|
||||||
|
|
||||||
|
public class T2 {
|
||||||
|
int x;
|
||||||
|
void f() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
../infer/Utils.java
|
@ -0,0 +1,57 @@
|
|||||||
|
ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.arrayIndexOutOfBoundsInCallee(), 3, java.lang.ArrayIndexOutOfBoundsException
|
||||||
|
ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.callOutOfBound(), 3, java.lang.ArrayIndexOutOfBoundsException
|
||||||
|
ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.missingCheckOnIndex(codetoanalyze.java.tracing.T2[],int), 6, java.lang.ArrayIndexOutOfBoundsException
|
||||||
|
ArrayOutOfBounds.java, int ArrayOutOfBounds.arrayOutOfBounds(), 2, java.lang.ArrayIndexOutOfBoundsException
|
||||||
|
ClassCastExceptionExample.java, S ClassCastExceptionExample.bar(int), 4, java.lang.ClassCastException
|
||||||
|
ClassCastExceptionExample.java, void ClassCastExceptionExample.foo(), 4, java.lang.ClassCastException
|
||||||
|
ClassCastExceptions.java, int ClassCastExceptions.classCastExceptionImplementsInterface(), 0, java.lang.ClassCastException
|
||||||
|
ClassCastExceptions.java, void ClassCastExceptions.classCastException(), 3, java.lang.ClassCastException
|
||||||
|
ClassCastExceptions.java, void ClassCastExceptions.openHttpURLConnection(), 4, java.lang.ClassCastException
|
||||||
|
CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK
|
||||||
|
CloseableAsResourceExample.java, void CloseableAsResourceExample.withException(), 4, RESOURCE_LEAK
|
||||||
|
LazyDynamicDispatchExample.java, void LazyDynamicDispatchExample.callWithSubtype(), 3, java.lang.NullPointerException
|
||||||
|
LazyDynamicDispatchExample.java, void LazyDynamicDispatchExample.shouldReportLocalVarTypeIsKnown(), 3, java.lang.NullPointerException
|
||||||
|
LocallyDefinedExceptionExample.java, void LocallyDefinedExceptionExample.fieldInvariant(), 8, codetoanalyze.java.tracing.LocallyDefinedException
|
||||||
|
NullPointerExceptionExample.java, void NullPointerExceptionExample.callDeref(T2,boolean), 4, java.lang.NullPointerException
|
||||||
|
NullPointerExceptionExample.java, void NullPointerExceptionExample.callLeadToNpe(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptionExample.java, void NullPointerExceptionExample.npeOnBothBranches(int), 6, java.lang.NullPointerException
|
||||||
|
NullPointerExceptionExample.java, void NullPointerExceptionExample.npeOnBothBranches(int), 6, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, String NullPointerExceptions.testSystemGetPropertyArgument(), 1, NULL_DEREFERENCE
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullListFiles(String), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerException(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionInterProc(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithArray(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithExceptionHandling(boolean), 5, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions$$$Class$Name$With$Dollars.npeWithDollars(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.badCheckShouldCauseNPE(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.derefNonThisGetterAfterCheckShouldNotCauseNPE(), 5, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.derefNull(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRetWrapper(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 5, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 5, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 7, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 7, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionArrayLength(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFailingFileOutputStreamConstructor(), 9, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFaillingResourceConstructor(), 8, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionUnlessFrameFails(), 6, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullArrayParameter(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullObjectParameter(), 2, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.someNPEAfterResourceLeak(), 3, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.stringConstantEqualsFalseNotNPE_FP(), 11, java.lang.NullPointerException
|
||||||
|
NullPointerExceptions.java, void NullPointerExceptions.testSystemGetPropertyReturn(), 3, java.lang.NullPointerException
|
||||||
|
ReportOnMainExample.java, void ReportOnMainExample.main(java.lang.String[]), 3, java.lang.NullPointerException
|
||||||
|
UnavoidableExceptionExample.java, void UnavoidableExceptionExample.cannotAvoidNPE(), 3, java.lang.NullPointerException
|
||||||
|
UnavoidableExceptionExample.java, void UnavoidableExceptionExample.unavoidableNPEWithParameter(boolean), 3, java.lang.NullPointerException
|
||||||
|
UnavoidableExceptionExample.java, void UnavoidableExceptionExample.virtualMethodWithUnavoidableNPE(boolean), 3, java.lang.NullPointerException
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.comparison;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class ArrayIndexOutOfBoundsExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java";
|
|
||||||
|
|
||||||
public static final String ARRAY_OUT_OF_BOUNDS = "java.lang.ArrayIndexOutOfBoundsException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingComparisonResults(
|
|
||||||
ArrayIndexOutOfBoundsExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnArrayOutOfBoundsThenErrorIsFound()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"arrayOutOfBounds",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain out of bounds error.", inferResults,
|
|
||||||
containsExactly(
|
|
||||||
ARRAY_OUT_OF_BOUNDS,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
java_test(
|
|
||||||
name='comparison',
|
|
||||||
srcs=glob(['*.java']),
|
|
||||||
deps=[
|
|
||||||
'//dependencies/java/guava:guava',
|
|
||||||
'//dependencies/java/junit:hamcrest',
|
|
||||||
'//dependencies/java/junit:junit',
|
|
||||||
'//infer/tests/utils:utils',
|
|
||||||
],
|
|
||||||
resources=[
|
|
||||||
'//infer/tests/codetoanalyze/java/infer:tracing',
|
|
||||||
],
|
|
||||||
visibility=[
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
)
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.java.comparison;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class ClassCastExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java";
|
|
||||||
|
|
||||||
public static final String CLASS_CAST_EXCEPTION =
|
|
||||||
"java.lang.ClassCastException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingComparisonResults(
|
|
||||||
ClassCastExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"classCastException",
|
|
||||||
"classCastExceptionImplementsInterface",
|
|
||||||
"openHttpURLConnection",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + CLASS_CAST_EXCEPTION,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
CLASS_CAST_EXCEPTION,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.comparison;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsTheseErrors.contains;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class NullPointerExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java";
|
|
||||||
|
|
||||||
public static final String NPE =
|
|
||||||
"java.lang.NullPointerException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingComparisonResults(
|
|
||||||
NullPointerExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void errorsFoundByInferExpectedToBeFoundInTracingMode()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"nullPointerException",
|
|
||||||
"nullPointerExceptionInterProc",
|
|
||||||
"nullPointerExceptionWithExceptionHandling",
|
|
||||||
"nullPointerExceptionWithArray",
|
|
||||||
"nullPointerExceptionWithNullObjectParameter",
|
|
||||||
"nullPointerExceptionWithNullArrayParameter",
|
|
||||||
"nullPointerExceptionFromFaillingResourceConstructor",
|
|
||||||
"nullPointerExceptionFromFailingFileOutputStreamConstructor",
|
|
||||||
"nullPointerExceptionUnlessFrameFails",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + NPE,
|
|
||||||
inferResults,
|
|
||||||
contains(
|
|
||||||
NPE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class ArrayIndexOutOfBoundsExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java";
|
|
||||||
|
|
||||||
public static final String ARRAY_OUT_OF_BOUND =
|
|
||||||
"java.lang.ArrayIndexOutOfBoundsException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
ArrayIndexOutOfBoundsExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"callOutOfBound",
|
|
||||||
"missingCheckOnIndex",
|
|
||||||
"arrayIndexOutOfBoundsInCallee",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + ARRAY_OUT_OF_BOUND,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
ARRAY_OUT_OF_BOUND,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
java_test(
|
|
||||||
name='tracing',
|
|
||||||
srcs=glob(['*.java']),
|
|
||||||
deps=[
|
|
||||||
'//dependencies/java/guava:guava',
|
|
||||||
'//dependencies/java/junit:hamcrest',
|
|
||||||
'//dependencies/java/junit:junit',
|
|
||||||
'//infer/tests/utils:utils',
|
|
||||||
],
|
|
||||||
resources=[
|
|
||||||
'//infer/tests/codetoanalyze/java/tracing:analyze',
|
|
||||||
],
|
|
||||||
visibility=[
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
)
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class ClassCastExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java";
|
|
||||||
|
|
||||||
public static final String CLASS_CAST_EXCEPTION =
|
|
||||||
"java.lang.ClassCastException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
ClassCastExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {"foo", "bar"};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + CLASS_CAST_EXCEPTION,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
CLASS_CAST_EXCEPTION,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class LazyDynamicDispatchTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java";
|
|
||||||
|
|
||||||
public static final String NPE =
|
|
||||||
"java.lang.NullPointerException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
LazyDynamicDispatchTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"callWithSubtype",
|
|
||||||
"shouldReportLocalVarTypeIsKnown",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + NPE,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NPE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class LocallyDefinedExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java";
|
|
||||||
|
|
||||||
public static final String LOCALLY_DEFINED_EXCEPTION =
|
|
||||||
"codetoanalyze.java.tracing.LocallyDefinedException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
LocallyDefinedExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"fieldInvariant"
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + LOCALLY_DEFINED_EXCEPTION,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
LOCALLY_DEFINED_EXCEPTION,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class NullPointerExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java";
|
|
||||||
|
|
||||||
public static final String NPE =
|
|
||||||
"java.lang.NullPointerException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
NullPointerExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"callDeref",
|
|
||||||
"callLeadToNpe",
|
|
||||||
"npeOnBothBranches",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + NPE,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NPE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class ReportOnMainTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java";
|
|
||||||
|
|
||||||
public static final String NPE =
|
|
||||||
"java.lang.NullPointerException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
ReportOnMainTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"main"
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + NPE,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NPE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package endtoend.java.tracing;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
|
|
||||||
public class UnavoidableExceptionTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java";
|
|
||||||
|
|
||||||
public static final String NPE =
|
|
||||||
"java.lang.NullPointerException";
|
|
||||||
|
|
||||||
private static InferResults inferResults;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void loadResults() throws InterruptedException, IOException {
|
|
||||||
inferResults = InferResults.loadTracingResults(
|
|
||||||
UnavoidableExceptionTest.class,
|
|
||||||
SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void matchErrors()
|
|
||||||
throws IOException, InterruptedException, InferException {
|
|
||||||
String[] methods = {
|
|
||||||
"cannotAvoidNPE",
|
|
||||||
"unavoidableNPEWithParameter",
|
|
||||||
"virtualMethodWithUnavoidableNPE",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain " + NPE,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NPE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
methods
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in new issue