First use FINDBUGS
I. Overview
Findbugs is a static analysis tool that analyzes the Class file without running, compares the bytecode with a set of defects, trying to find real defects or potential performance issues.
Second, installation and operation
To use Findbugs, please install the version after JDK1.4.
1. installation
a. Downloading the latest Findbugs from http://sourceforge.net/, UNIX platform is tar.gz file, the Windows platform is a zip file.
b. Unwrite the downloaded compressed package, such as (UNIX platform):
$ tar xzvf findbugs-0.8.4.tar.gz
C. Set FindBugs_Home, write under the UNIX platform, you can write the user's.profile file:
Findbugs_home = / home / docomo / findbugs-0.8.4 (assumed installation directory)
Export Findbugs_HOME
2. run
Perform a Findbugs graphical interface to execute $ {FINDBUGS_HOME} / bin / findbugs, due to the simple graphical interface operation, no longer described again.
Third, use Findbugs in Ant
1. Copy the Findbugs Ant task to the LIB directory of Ant, so Ant knows the new task.
$ cp $ {findbugs_home} /lib/findbugs_ant.jar $ {ant_home} / lib
2. Because Findbugs is a custom task, you will need to use the taskdef task to make the ANT know which class loaded.
Add the following in the build.xml of Ant:
After defining the taskdef, you can use the name FINDBUGS to reference.
3. Using new task Findbugs in Build files
Findbugs>
target>
described as follows:
a. Findbugs processes class files instead of source files, so you need to compile first, dependS = "compile", FindBugs can flexibly accept multiple inputs, including a set of class files, JAR files, or a set of directories;
b. Optional Properties OUTPUT Specifies the output format used by the results of Findbugs, the format can be XML, TXT, Emacs.
C. Class elements are used to specify which jar, class files, or directories to find findbugs. When analyzing multiple JAR or class files, you want to specify a separate Class element for each file. d. AuxclassPath lists the applications need but do not want Findbugs to analyze classes, such as compiling the required JAR packets.
e. If the sourcePath element is specified, the Path property should indicate a directory containing the application source code. The specified directory allows FindBugs to highlight the source code in the event of XML results in the GUI. This element is optional.
Use the Findbugs graphical interface to open the output file /Home/docomo/report/findbugs.xml, you can see the bugs analyzed by Findbugs.