NPEDetector classifies each dereference in a Java program as being safe or as having the potential to result in a null pointer exception. NPEDetector is primarily described in the following two research papers: Null dereference verification via over-approximated weakest pre-conditions analysis in OOPSLA 2011, and Two techniques to improve the precision of a demand-driven null-dereference verification approach in Science of Computer Programming, 2015.
NPEDetector is distributed as an importable Eclipse project. It is based on a modified version of WALA 1.3.4. It requires Eclipse IDE 3.6.0 or later, and JDK 1.5 or later. NPEDetector is distributed as open-source under the MIT License.
/home/npedetectvm/eclipse
./home/npedetectvm/NPEDetector
as the
workspace. It contains the NPEDetector tool project, Wala
projects and a toy Java project called NPETest. /home/npedetectvm/NPEDetector/
folder. The user is encouraged to
look into the NPETest code for better understanding of the tool
output (see class test.NPETest1
). The following two run configurations
have been provided for NPETest:
NPEDriver_NPETest
, analyzes the program in
"wholeprogram" mode, using "wholeprogram" analysis option. Run NPEDetector using the NPEDriver_NPETest
configuration.
The tool will print the output on the console, as well as produce an output file
master.log
in the folder /home/npedetectvm/NPEDetector/WALA_output/NPETest
.
NPEDriver_NPETest_DD
,
analyzes the program in "demand-driven" mode, using the
"wholeprogram" option. This configuration also
produces its output into the same file as mentioned above.
bcel.jar
file is present in the /home/npedetectvm/NPEDetector/
folder. The run
configuration NPEDriver_bcel
analyzes
the bcel.jar
file in "wholeprogram" mode with the "wholeprogram"
analysis option. The tool prints the output on the console, and produces an output file master.log
in the folder
/home/npedetectvm/NPEDetector/WALA_output/bcel
.
master.log
. The output file contains the following information:
-appJar
option.
For running successfully, the tool also requires certain
configuration files as input. These files can
be placed in a folder, and the absolute path to this folder is provided to the tool using the -dataDir
option.
The necessary files are :
"entryPoints_<jar-file-name>".txt
and should have the following
format. The first line in the entry-points file should specify the number of classes listed in the file.
The subsequent lines should contain the qualified names of the entry point classes (one per line) in the
Java bytecode format.
For a sample, see the entry-points file /home/npedetectvm/NPEDetector/NPEBugDetection/dat/entrypoints_NPETest.txt
.
Exclusion files.
The tool uses several exclusion files to make the analysis (and WALA libraries) more precise and efficient. These include
JavaRegression60Exclusions.txt
, pureExclusions.txt
, skipList.txt
and analyseList.txt
. The
JavaRegression60Exclusions.txt
specifies a set of package names that will be ignored by the WALA analyses
(see Wala Tips and Tricks for more
details). The other files are specific to our analysis and are
described in both the papers that are referred to at the beginning of
this document.
Samples of the exclusion files can be found in the directory /home/npedetectvm/NPEDetector/NPEBugDetection/dat/
. The analysis supports two modes of operation:
-mode
option should be used to specify the mode of the
analysis.
In case the "demanddriven" mode is chosen, two other
options, namely, -srcCaller
and
-tgtStmt
, are necessary. The -srcCaller
option should be used to specify the
qualified name and signature of the method containing the dereference, in the Java bytecode format.
(See this resource for the bytecode
syntax of Methods).
The WALA IR line number of the dereference to be analyzed should be specified using the -tgtStmt
option.
Refer to the WALA tutorials to learn how to get the
WALA IR line number of a statement. Also, see the run configuration
PDFWalaIR, which emits the WALA IR of a given method as
a PDF document (currently the configuration displays the IR of the test.NPETest1.printlen()
) method.
The analysis supports two analysis "options" :
-NPEAnalysisOpt
option is used to specify the type of analysis required. It should be noted that
the "wholeprogram" mode and "wholeprogram" NPE analysis options are not related to each other, and the naming is an
unfortunate coincidence. Any mode can be paired with any analysis
option.
The directory to contain the outputs of the analysis can be specified using the -outputdir
option.