Codebase list findbugs / c0734cc
Merge tag 'upstream/2.0.3' Upstream version 2.0.3 yesx 10 years ago
410 changed file(s) with 33072 addition(s) and 3819 deletion(s). Raw diff Collapse all Expand all
00 <?xml version="1.0" encoding="UTF-8"?>
11 <classpath>
2 <classpathentry excluding="**/CVS/*" kind="src" path="src/java"/>
3 <classpathentry excluding="**/CVS/*" kind="src" path="src/antTask"/>
4 <classpathentry excluding="**/CVS/*|edu/umd/cs/findbugs/tools/patcomp/**/*" kind="src" path="src/tools"/>
2 <classpathentry kind="src" path="src/java"/>
3 <classpathentry kind="src" path="src/antTask"/>
4 <classpathentry kind="src" path="src/tools"/>
55 <classpathentry kind="src" path="etc"/>
66 <classpathentry kind="src" path="src/xsl"/>
7 <classpathentry excluding="**/CVS/*" kind="src" path="src/junit"/>
7 <classpathentry kind="src" path="src/junit"/>
88 <classpathentry kind="src" path="src/gui"/>
99 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
1010 <accessrules>
1414 <accessrule kind="nonaccessible" pattern="com/apple/**"/>
1515 </accessrules>
1616 </classpathentry>
17 <classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
17 <classpathentry exported="true" kind="lib" path="lib/AppleJavaExtensions.jar"/>
1818 <classpathentry exported="true" kind="lib" path="lib/bcel.jar">
1919 <attributes>
2020 <attribute name="javadoc_location" value="http://jakarta.apache.org/bcel/apidocs/"/>
2525 <attribute name="javadoc_location" value="http://dom4j.org/apidocs/"/>
2626 </attributes>
2727 </classpathentry>
28 <classpathentry kind="lib" path="lib/junit.jar"/>
29 <classpathentry exported="true" kind="lib" path="lib/commons-lang-2.4.jar"/>
28 <classpathentry exported="true" kind="lib" path="lib/junit.jar"/>
29 <classpathentry exported="true" kind="lib" path="lib/commons-lang-2.6.jar"/>
3030 <classpathentry exported="true" kind="lib" path="lib/jcip-annotations.jar"/>
31 <classpathentry kind="lib" path="lib/yjp-controller-api-redist.jar"/>
31 <classpathentry exported="true" kind="lib" path="lib/yjp-controller-api-redist.jar"/>
3232 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
3333 <classpathentry exported="true" kind="lib" path="lib/jsr305.jar" sourcepath="lib/jsr305.jar"/>
34 <classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.1.jar"/>
35 <classpathentry exported="true" kind="lib" path="lib/jFormatString.jar"/>
34 <classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.6.jar"/>
35 <classpathentry exported="true" kind="lib" path="lib/jFormatString.jar"/>
3636 <classpathentry exported="true" kind="lib" path="lib/jdepend-2.9.jar"/>
3737 <classpathentry exported="true" kind="lib" path="lib/asm-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
3838 <classpathentry exported="true" kind="lib" path="lib/asm-commons-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
3939 <classpathentry exported="true" kind="lib" path="lib/asm-tree-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
40 <classpathentry kind="lib" path="lib/ant.jar"/>
40 <classpathentry exported="true" kind="lib" path="lib/ant.jar"/>
41 <classpathentry exported="true" kind="lib" path="lib/asm-analysis-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
42 <classpathentry exported="true" kind="lib" path="lib/asm-util-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
43 <classpathentry exported="true" kind="lib" path="lib/asm-xml-3.3.jar" sourcepath="lib/asm-src-3.3.zip"/>
4144 <classpathentry kind="output" path="classesEclipse"/>
4245 </classpath>
55 </projects>
66 <buildSpec>
77 <buildCommand>
8 <name>com.cenqua.clover.core.prejavabuilder</name>
9 <arguments>
10 </arguments>
11 </buildCommand>
12 <buildCommand>
813 <name>org.eclipse.jdt.core.javabuilder</name>
14 <arguments>
15 </arguments>
16 </buildCommand>
17 <buildCommand>
18 <name>com.cenqua.clover.core.postjavabuilder</name>
919 <arguments>
1020 </arguments>
1121 </buildCommand>
2838 <natures>
2939 <nature>org.eclipse.jdt.core.javanature</nature>
3040 <nature>org.eclipse.pde.PluginNature</nature>
41 <nature>com.cenqua.clover.core.clovernature</nature>
3142 <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
3243 </natures>
3344 </projectDescription>
00 #FindBugs User Preferences
1 #Thu Aug 25 18:56:29 EDT 2011
1 #Thu Nov 07 08:16:06 EST 2013
22 cloud_id=edu.umd.cs.findbugs.cloud.appengine.findbugs-cloud
33 detectorAbnormalFinallyBlockReturn=AbnormalFinallyBlockReturn|true
44 detectorAbstractClassEmptyMethods=AbstractClassEmptyMethods|true
2222 detectorCheckCalls=CheckCalls|false
2323 detectorCheckExpectedWarnings=CheckExpectedWarnings|false
2424 detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
25 detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true
2526 detectorCheckTypeQualifiers=CheckTypeQualifiers|true
2627 detectorCloneIdiom=CloneIdiom|true
2728 detectorComparatorIdiom=ComparatorIdiom|true
122123 detectorInheritanceTypeChecking=InheritanceTypeChecking|true
123124 detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
124125 detectorInitializationChain=InitializationChain|true
126 detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
125127 detectorInstantiateStaticClass=InstantiateStaticClass|true
126128 detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
127129 detectorInvalidJUnitTest=InvalidJUnitTest|true
253255 detector_threshold=2
254256 effort=default
255257 excludefilter0=findbugsExclude.xml|true
256 filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,I18N,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|15
257 filter_settings_neg=MALICIOUS_CODE,NOISE,EXPERIMENTAL|
258 filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|15
259 filter_settings_neg=MALICIOUS_CODE,NOISE|
258260 run_at_full_build=false
0 #Fri Jun 03 22:22:24 CEST 2011
10 eclipse.preferences.version=1
1 edu.umd.cs.findbugs.plugin.eclipse.findbugsMarkerOfConcern=Info
22 runAnalysisAsExtraJob=true
1818 org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
1919 org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
2020 org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
21 org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
2122 org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
2223 org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
2324 org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
3132 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
3233 org.eclipse.jdt.core.compiler.debug.localVariable=generate
3334 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
34 org.eclipse.jdt.core.compiler.doc.comment.support=disabled
35 org.eclipse.jdt.core.compiler.doc.comment.support=enabled
3536 org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
3637 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
3738 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
5657 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
5758 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
5859 org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
59 org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
60 org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
60 org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
61 org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
6162 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
6263 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
6364 org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
64 org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
65 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
6566 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
6667 org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
6768 org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
7071 org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
7172 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
7273 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
73 org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
74 org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag
7475 org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
7576 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
7677 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
8283 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
8384 org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
8485 org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
86 org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
8587 org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
8688 org.eclipse.jdt.core.compiler.problem.nullReference=warning
8789 org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
99101 org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
100102 org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
101103 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
102 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
104 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
103105 org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
104106 org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
105107 org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
106108 org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
109 org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
107110 org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
108111 org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
109112 org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
128131 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
129132 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
130133 org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
134 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
131135 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
132136 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
133137 org.eclipse.jdt.core.compiler.source=1.5
2828 sp_cleanup.make_parameters_final=false
2929 sp_cleanup.make_private_fields_final=true
3030 sp_cleanup.make_type_abstract_if_missing_method=false
31 sp_cleanup.make_variable_declarations_final=true
31 sp_cleanup.make_variable_declarations_final=false
3232 sp_cleanup.never_use_blocks=false
3333 sp_cleanup.never_use_parentheses_in_expressions=true
3434 sp_cleanup.on_save_use_additional_actions=true
4040 sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
4141 sp_cleanup.remove_private_constructors=true
4242 sp_cleanup.remove_trailing_whitespaces=true
43 sp_cleanup.remove_trailing_whitespaces_all=true
44 sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
43 sp_cleanup.remove_trailing_whitespaces_all=false
44 sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
4545 sp_cleanup.remove_unnecessary_casts=true
4646 sp_cleanup.remove_unnecessary_nls_tags=false
4747 sp_cleanup.remove_unused_imports=true
1111 lib/asm-3.3.jar,
1212 lib/asm-tree-3.3.jar,
1313 lib/asm-commons-3.3.jar,
14 lib/jaxen-1.1.1.jar,
14 lib/jaxen-1.1.6.jar,
1515 lib/jFormatString.jar,
16 lib/commons-lang-2.4.jar,
17 lib/jsr305.jar
16 lib/commons-lang-2.6.jar,
17 lib/jsr305.jar,
18 lib/ant.jar,
19 lib/asm-analysis-3.3.jar,
20 lib/asm-util-3.3.jar,
21 lib/asm-xml-3.3.jar,
22 lib/jcip-annotations.jar,
23 lib/jdepend-2.9.jar,
24 lib/yjp-controller-api-redist.jar
1825 Bundle-Localization: plugin
1926 Export-Package: edu.umd.cs.findbugs,
2027 edu.umd.cs.findbugs.annotations,
3643 edu.umd.cs.findbugs.ba.type,
3744 edu.umd.cs.findbugs.ba.vna,
3845 edu.umd.cs.findbugs.bcel,
46 edu.umd.cs.findbugs.bcel.generic,
3947 edu.umd.cs.findbugs.bugReporter,
4048 edu.umd.cs.findbugs.charsets,
4149 edu.umd.cs.findbugs.classfile,
8896 org.objectweb.asm.commons,
8997 org.objectweb.asm.signature,
9098 org.objectweb.asm.tree
91 Require-Bundle: org.apache.ant
9299 Bundle-RequiredExecutionEnvironment: J2SE-1.5
66 src/junit/,\
77 src/gui/,\
88 etc
9 local.software.home =/fs/pugh/pugh
10 #local.software.home =/user/daveho/local
119
1210 # Set this to the directory containing the DocBook Modular XSL Stylesheets
1311 # from http://docbook.sourceforge.net/projects/xsl/
3634 # Eclipse plugin.
3735 eclipse.home =${local.software.home}/java/eclipse-2.1.3
3836
39 java14.rt =/export/home/pugh/work/j2sdk1.4.0/jre/lib/rt.jar
40
4137 dblatex.img.fix=while(<>){s,([A-Za-z-]*\.png\}),manual/\1,g;print;}
4238
43 #/export/home/pugh/JSR305-ri/build/classes
4439
4540 pluginsSrc.dir=../plugins/
4641 serverSrc.dir=../server/
4949 <property name="test.jar" value="${test.dir}/dumb.jar"/>
5050 <property name="sampleoutput.dir" value="build/sampleoutput"/>
5151 <property name="junittests.jar" value="build/junittests.jar"/>
52 <property name="baseline-anttask.jar" value="${findbugs-baseline.home}/lib/findbugs-ant.jar"/>
5253 <property name="anttask.jar" value="${jar.dir}/findbugs-ant.jar"/>
5354 <property name="scripts.props" value="etc/script.properties"/>
5455 <property name="scripts.stamp" value="${build.dir}/scripts.stamp"/>
6566 <pathelement location="${jar.dir}/asm-3.3.jar"/>
6667 <pathelement location="${jar.dir}/asm-commons-3.3.jar"/>
6768 <pathelement location="${jar.dir}/asm-tree-3.3.jar"/>
68 <pathelement location="${jar.dir}/jaxen-1.1.1.jar"/>
69 <pathelement location="${jar.dir}/jaxen-1.1.6.jar"/>
6970 <pathelement location="${jar.dir}/jsr305.jar"/>
7071 <pathelement location="${jar.dir}/jFormatString.jar"/>
71 <pathelement location="${jar.dir}/commons-lang-2.4.jar"/>
72 <pathelement location="${jar.dir}/commons-lang-2.6.jar"/>
7273 <pathelement location="${jar.dir}/jcip-annotations.jar"/>
7374 </path>
7475
8081 </path>
8182
8283 <path id="svn.classpath">
83 <pathelement location="${svnant.home}/lib/svnant.jar"/>
84 <pathelement location="${svnant.home}/lib/svnClientAdapter.jar"/>
85 <pathelement location="${svnant.home}/lib/svnkit.jar"/>
86 <pathelement location="${svnant.home}/lib/ganymed.jar"/>
87 <pathelement location="${svnant.home}/lib/svnjavahl.jar"/>
88 <pathelement location="${svnant.home}/lib/jna.jar"/>
84
85 <fileset dir="${svnant.home}/lib">
86 <include name="*.jar"/>
87 </fileset>
8988 </path>
9089
9190
131130 <zipfileset src="${jar.dir}/asm-3.3.jar"/>
132131 <zipfileset src="${jar.dir}/asm-commons-3.3.jar"/>
133132 <zipfileset src="${jar.dir}/asm-tree-3.3.jar"/>
134 <zipfileset src="${jar.dir}/jaxen-1.1.1.jar"/>
133 <zipfileset src="${jar.dir}/jaxen-1.1.6.jar"/>
135134 <zipfileset src="${jar.dir}/jsr305.jar"/>
136135 <zipfileset src="${jar.dir}/jFormatString.jar"/>
137 <zipfileset src="${jar.dir}/commons-lang-2.4.jar"/>
136 <zipfileset src="${jar.dir}/commons-lang-2.6.jar"/>
138137 <zipfileset src="${jar.dir}/findbugs.jar"/>
139138 </jar>
140139 </target>
141140
142141 <!-- Compile Java source files, and copy other files (properties,
143142 images, html, XSL stylesheets) that need to be part of the codebase. -->
143 <target name="errorprone" depends="clean,init">
144 <javac
145 destdir="${classes.dir}"
146 source="1.5"
147 target="1.5"
148 includeantruntime="false"
149 encoding="ISO-8859-1"
150 deprecation="off"
151 debug="on"
152 compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"
153 >
154 <compilerarg value="-Xlint:unchecked"/>
155 <src path="${src.dir}"/>
156 <src path="${src5.dir}"/>
157 <classpath refid="findbugs.classpath"/>
158 </javac>
159 </target>
144160 <target name="classes" depends="init">
145161
146162 <!-- Compile Java source files. -->
355371 <zipfileset src="${jar.dir}/asm-xml-3.3.jar" excludes="META-INF/**"/>
356372
357373 <zipfileset src="${jar.dir}/dom4j-1.6.1.jar" excludes="META-INF/**"/>
358 <zipfileset src="${jar.dir}/jaxen-1.1.1.jar" excludes="META-INF/**"/>
374 <zipfileset src="${jar.dir}/jaxen-1.1.6.jar" excludes="META-INF/**"/>
359375 <zipfileset src="${jar.dir}/jsr305.jar" excludes="META-INF/**"/>
360376 <zipfileset src="${jar.dir}/jFormatString.jar" excludes="META-INF/**"/>
361 <zipfileset src="${jar.dir}/commons-lang-2.4.jar" excludes="META-INF/**"/>
377 <zipfileset src="${jar.dir}/commons-lang-2.6.jar" excludes="META-INF/**"/>
362378 </jar>
363379 </target>
364380
542558 />
543559 </target>
544560
561 <target name="baseline-findbugscheck" depends="jars">
562 <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpath="${baseline-anttask.jar}"/>
563 <findbugs home="${findbugs-baseline.home}"
564 output="xml:withMessages"
565 jvmargs="-ea -Xmx1200m "
566 excludeFilter="findbugsExclude.xml"
567 projectName="FindBugs"
568 maxRank="20"
569 timeout="1800000"
570 outputFile="${build.dir}/findbugs-Baseline.xml" >
571 <class location="${classes.dir}" />
572 <sourcePath path="src/java:src/gui:src/junit:src/tools:src/antTask"/>
573 <auxClasspath refid="tools.classpath"/>
574 <auxClasspath path="lib/ant.jar"/>
575 </findbugs>
576 </target>
577
578
545579 <target name="findbugscheck" depends="anttask,junittests,jars">
546580 <property name="findbugs.home" value="." />
547581 <ant dir="${pluginsSrc.dir}/findbugsCommunalCloud" target="install" inheritAll="false" />
556590 timeout="1800000"
557591 outputFile="${build.dir}/findbugscheckAll.xml" >
558592 <class location="${classes.dir}" />
559 <sourcePath path="src/java:src/gui:src/junit:src/tools"/>
593 <sourcePath path="src/java:src/gui:src/junit:src/tools:src/antTask"/>
560594 <auxClasspath refid="tools.classpath"/>
561595 <auxClasspath path="lib/ant.jar"/>
562596 </findbugs>
583617 timeout="1800000"
584618 outputFile="${build.dir}/findbugscheck.xml" >
585619 <class location="${classes.dir}" />
586 <sourcePath path="src/java:src/gui:src/junit:src/tools"/>
620 <sourcePath path="src/java:src/gui:src/junit:src/tools:src/antTask"/>
587621 <auxClasspath refid="tools.classpath"/>
588622 </findbugs>
589623 </target>
650684 </target>
651685
652686 <!-- Run JUnit test cases -->
653 <target name="test" depends="runjunit,foundFindbugsTestCases"/>
687 <target name="test" depends="runjunit,foundFindbugsTestCases" description="Run tests"/>
654688
655689 <target name="runjunit" depends="junittests,jars,compileFindbugsTestCases">
656690 <echo>Running JUnit test cases for FindBugs...</echo>
680714 <taskdef resource="checkstyletask.properties"
681715 classpath="build-lib/checkstyle-all-5.1.jar"/>
682716 <checkstyle config="etc/checkstyle.xml" failonviolation="false">
717 <fileset dir="src/antTask"/>
683718 <fileset dir="src/java"/>
684719 <fileset dir="src/gui"/>
685720 <fileset dir="src/junit"/>
720755 <target name="-get-svn-revision" if="svnant.home">
721756 <taskdef resource="org/tigris/subversion/svnant/svnantlib.xml"
722757 classpathref="svn.classpath"/>
723 <svn svnkit="false" javahl="false">
758 <svn>
724759 <status path="." revisionProperty="svnrnum"/>
725760 </svn>
726761 <echo>${svnrnum}</echo>
727762 </target>
728763
729764
730 <target name="checkdocs">
765 <target name="checkdocs" depends="clean">
731766 <!-- FIXME: check whether docs are up to date -->
732767 </target>
733768
734769 <!-- Generate formatted documentation. -->
735 <target name="docs" depends="classes,version,bugdesc,checkdocs" unless="docs.uptodate">
770 <target name="docs" depends="classes,version,bugdesc,checkdocs" unless="docs.uptodate" description="Make documentation">
736771 <loadproperties srcFile="${doc.props.file}"/>
737772
738773 <!-- Generate HTML docs (the website). -->
826861 output="${bugdesc.output}">
827862 <jvmarg value="-ea"/>
828863 <jvmarg value="-Dfindbugs.home=."/>
829 <jvmarg value="-Dfindbugs.desc.unabridged=${bugdesc.unabridged}"/>
864 <jvmarg value="-Dfindbugs.bugdesc.unabridged=${bugdesc.unabridged}"/>
830865 <classpath refid="tools.classpath"/>
831866 <arg value="${bugdesc.title}"/>
832867 <arg value="${doc.html.gen.header}"/>
855890 <!-- Filter set used for generating text substitution values for
856891 documentation. -->
857892 <filterset id="doc.filters">
893 <filter token="VERSION_BASE" value="${release.base}" />
858894 <filter token="VERSION" value="${release.number}" />
859895 <filter token="RELEASE_DATE" value="${release.date}" />
896 <filter token="FINDBUGS_SVN_REVISION" value="${findbugs.svn.revision}" />
860897 <filter token="ECLIPSE_UI_VERSION" value="${eclipse.ui.version}" />
861898 <filter token="WEBSITE" value="${findbugs.website}"/>
862899 <filter token="DOWNLOADS_WEBSITE" value="${findbugs.downloads.website}"/>
9971034 <copy todir="${jnlp.dir}" file="${jar.dir}/asm-commons-3.3.jar"/>
9981035 <copy todir="${jnlp.dir}" file="${jar.dir}/asm-tree-3.3.jar"/>
9991036 <copy todir="${jnlp.dir}" file="${jar.dir}/dom4j-1.6.1.jar"/>
1000 <copy todir="${jnlp.dir}" file="${jar.dir}/jaxen-1.1.1.jar"/>
1037 <copy todir="${jnlp.dir}" file="${jar.dir}/jaxen-1.1.6.jar"/>
10011038 <copy todir="${jnlp.dir}" file="${jar.dir}/jFormatString.jar"/>
1002 <copy todir="${jnlp.dir}" file="${jar.dir}/commons-lang-2.4.jar"/>
1039 <copy todir="${jnlp.dir}" file="${jar.dir}/commons-lang-2.6.jar"/>
10031040 <copy todir="${jnlp.dir}" file="${jar.dir}/AppleJavaExtensions.jar"/>
10041041 <copy todir="${jnlp.dir}" file="${docsrc.dir}/buggy-sm.png"/>
10051042 <copy todir="${jnlp.dir}">
11821219 </target>
11831220
11841221 <!-- Build source distribution. -->
1185 <target name="srcdist" description="Source distribution" unless="doNotExportSrc">
1222 <target name="srcdist" description="Source distribution" unless="doNotExportSrc" depends="version">
11861223 <echo>
11871224 ${svnant.home}
11881225 </echo>
11901227 <delete dir="${build.dir}/src/findbugs-${release.number}"/>
11911228 <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svn.classpath"/>
11921229
1193 <svn username="guest" password="" javahl="false">
1230 <svnSetting username="guest" password="" id="svn.settings" />
1231 <svn refid="svn.settings" >
11941232 <!-- Use 'export' rather than 'checkout' to exclude the .svn stuff -->
11951233 <export srcUrl="http://findbugs.googlecode.com/svn/trunk/findbugs"
11961234 revision="HEAD"
12641302 Windowtitle="FindBugs ${release.number} API"
12651303 bottom="&lt;font size='-1'&gt;&lt;a href='http://findbugs.sourceforge.net/' target='_parent'&gt;FindBugs&lt;/a&gt;&amp;trade; is licenced under the LGPL. Copyright &amp;copy; 2006 University of Maryland.&lt;/font&gt;"
12661304 nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar= "false" notree="false"
1267 sourcepath="src/java:src/gui" splitindex="true" use="true" version="true">
1305 sourcepath="src/java:src/gui:src/antTask" splitindex="true" use="true" version="true">
12681306 <classpath refid="findbugs.classpath"/>
12691307 </javadoc>
12701308 </target>
12761314 packagenames="edu.umd.cs.findbugs.annotations"
12771315 doctitle="FindBugs Annotation Documentation"
12781316 nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar= "false" notree="false"
1279 sourcepath="src/gui" splitindex="true" use="true" version="true"/>
1317 sourcepath="src/java:src/gui:src/antTask" splitindex="true" use="true" version="true"/>
12801318 </target>
12811319
12821320 <!-- Download, patch, and build a modified BCEL 5.2. Install resulting bcel.jar in lib. -->
0 Adding Detectors to FindBugs
1 May 12, 2003
2 Updated June 6, 2003 (detector meta-information, cleanups)
3
4 ===============
5 1. Introduction
6 ===============
7
8 FindBugs uses a plugin-based approach to adding detectors.
9 This makes it easy for users to add their own detectors alongside
10 the ones that come built in.
11
12 Basic idea: FindBugs has some Jar files in a "plugins" directory.
13 At startup, each of those jar files is checked for a "findbugs.xml"
14 file. That XML file registers instances of Detectors, as well
15 as particular "bug patterns" that the detector reports.
16
17 Additionally to the findbugs.xml, bugrank.txt and messages.xml files are
18 required for each FindBugs detector plugin.
19
20 At startup, FindBugs loads all plugin Jar files. At analysis time,
21 all detectors named in the findbugs.xml files from those plugins
22 are instantiated and applied to analyzed class files.
23
24 In order to format reported BugInstances as text for display,
25 a messages file is loaded from the plugin. In order to support multiple
26 language translations, a locale search is performed in a manner
27 similar to the handling of resource bundles. For example, if the
28 locale is "pt_BR", then the files
29
30 messages_pt_BR.xml
31 messages_pt.xml
32 messages.xml
33
34 are tried, in that order.
35
36 The "findbugs.xml" and "messages.xml" files used by the standard FindBugs
37 bug pattern detectors (coreplugin.jar) can be found in the "etc" directory
38 of the findbugs source distribution. Both files must be UTF-8 encoded.
39
40
41 ============================
42 2. Example findbugs.xml file
43 ============================
44
45 <DetectorPlugin>
46
47 <Detector class="org.foobar.findbugs.FindUnreleasedLocks" speed="slow" />
48 <Detector class="org.foobar.findbugs.ExperimentalDetector" speed="fast" disabled="true" />
49
50 <!-- More Detector elements would go here... -->
51
52 <BugPattern type="UBL_UNRELEASED_LOCK" abbrev="UL" category="MT_CORRECTNESS" />
53
54 <!-- More BugPattern elements would go here... -->
55
56 </DetectorPlugin>
57
58
59 ======================================
60 3. Meaning of elements in findbugs.xml
61 ======================================
62
63 <DetectorPlugin> a collection of <Detector> and <BugPattern> elements.
64 Each plugin Jar file can (and usually will) provide multiple detectors
65 and define multiple bug patterns.
66
67 <Detector> specifies a class which implements the edu.umd.cs.findbugs.Detector
68 interface and has a constructor that takes a single parameter of type
69 edu.umd.cs.findbugs.BugReporter. This element has three possible attributes:
70
71 1. The required "class" attribute specifies the Detector class.
72
73 2. The optional "disabled" attribute, if set to "true", means
74 that by default, the detector will be disabled at runtime.
75 This is useful for detectors that aren't quite ready for prime time.
76
77 3. The required "speed" attribute supplies a value to be shown in the
78 "Settings->Configure Detectors" dialog. It gives the user an idea of
79 how expensive the analysis will be to perform. The value of this
80 attribute should be one of "fast", "moderate", or "slow".
81
82 <BugPattern> specifies a kind of bug that will be reported.
83 It has three required attributes:
84
85 1. "type" is a unique code identifying the bug. Only one BugPattern
86 can have a a particular type.
87
88 2. "abbrev" is a short alphanumeric code for the bug.
89 Note that multiple BugPatterns can use the same abbreviation
90 if they are related. (See the BugCode element in messages.xml).
91
92 3. "category" can be one of categories defined in the core plugin's messages.xml:
93
94 CORRECTNESS - code that was probably not what the developer intended
95 BAD_PRACTICE - violations of recommended and essential coding practice
96 STYLE - code that is confusing, anomalous, or written in a way that that leads itself to errors
97 MT_CORRECTNESS - multithreaded correctness issues
98 MALICIOUS_CODE - a potential vulnerability if exposed to malicious code
99 PERFORMANCE - a performance issue
100 I18N - internationalization and locale
101
102 or you may create your own category, in which case you should define
103 it in a <BugCategory> element in _your_ messages.xml file.
104
105 ============================
106 4. Example messages.xml file
107 ============================
108
109 <MessageCollection>
110
111 <Detector class="org.foobar.findbugs.FindUnreleasedLocks" >
112 <Details>
113 <![CDATA[
114 <p> This detector looks for JSR-166 locks that are not released on all paths
115 out of a method. Because it performs dataflow analysis, it is fairly slow.
116 ]]>
117 </Details>
118 </Detector>
119
120 <!-- More Detector nodes would go here... -->
121
122 <BugPattern type="UBL_UNRELEASED_LOCK">
123 <ShortDescription>Lock not released on all paths out of method</ShortDescription>
124
125 <LongDescription>{1} does not release lock on all paths out of method</LongDescription>
126
127 <Details>
128 <![CDATA[
129 <p> A JSR-166 lock acquired in this method is not released on all paths
130 out of the method. This could result in a deadlock if another thread
131 tries to acquire the lock. Generally, you should use a finally
132 block to ensure that acquired locks are always released.
133 ]]>
134 </Details>
135 </BugPattern>
136
137 <!-- More BugPattern nodes would go here... -->
138
139 <BugCode abbrev="UL">Unreleased locks</BugCode>
140
141 <!-- More BugCode nodes would go here... -->
142
143 </MessageCollection>
144
145
146 ======================================
147 5. Meaning of elements in messages.xml
148 ======================================
149
150 <MessageCollection> is the top level element
151
152 <BugCategory> elements optionally describe any categories you
153 may have created for your bug patterns. You can skip these if
154 you are using only the categories defined by the core plugin.
155
156 The <Description> child element has a brief (a word or three)
157 description of the category. The <Abbreviation> child element
158 is typically a single capital latter. The optional <Details>
159 child element may describe it in more detail (but no markup).
160
161 <Detector> holds meta-information about a Detector in the plugin.
162 The required "class" attribute specifies the Detector class.
163 Detector elements much have the following child elements:
164
165 The <Details> child element has a brief HTML description of the Detector.
166 It should have HTML markup that would be valid in a BODY element.
167 It should be specified in a CDATA section so that the HTML
168 tags are not misinterpreted as XML.
169
170 <BugPattern> holds all of the human-readable messages for the bug pattern
171 identified by the "type" attribute. The type corresponds to the
172 type attribute of the BugPattern elements described in findbugs.xml.
173 BugPattern elements must have the following child elements:
174
175 <ShortDescription> this is used for when "View->Full Descriptions"
176 is turned off in the GUI, and it's also used as the title for
177 descriptions in the Details window.
178
179 <LongDescription> this is used for when "View->Full Descriptions"
180 is turned on in the GUI, and for output using the command line UI.
181 The placeholders in the long description ({0}, {1}, etc.)
182 refer to BugAnnotations attached to the BugInstances reported by
183 the detector for this bug pattern. You may also use constructs
184 like {1.name} or {1.returnType}.
185
186 <Details> this is the descriptive text to be used in the Details
187 window. It consists of HTML markup to appear in the BODY element of an HTML
188 document. It should be specified in a CDATA section so that the HTML
189 tags are not misinterpreted as XML.
190
191 <BugCode> is the text which describes the common characteristic of all
192 of the BugPatterns which share an abbreviation. In the example above,
193 the abbreviation "UL" is for bugs in which a lock is not released.
194 The text of a BugCode element is shown for tree nodes in the GUI
195 which group bug instances by "bug type".
196
197 ======================================
198 6. Meaning of elements in bugrank.txt
199 ======================================
200
201 For the detailed and up to date information, please read the javadoc of the
202 edu.umd.cs.findbugs.BugRanker class.
203
204 ============================================
205 7. Using 3rd party libraries in the detector
206 ============================================
207
208 FindBugs plugins may extend the default FindBugs classpath and use custom 3rd party
209 libraries during the analysis. This libraries must be part of standard jar class path
210 specified via "ClassPath" attribute in the META-INF/MANIFEST.MF file.
211
212 ======================================
213 8. Adding detectors to Eclipse plugin
214 ======================================
215
216 Since version 2.0.0 Eclipse plugin allows to configure or contribute custom detectors.
217
218 7.1. It is possible to contribute custom detectors via standard Eclipse extensions mechanism.
219 Please check the documentation of the "findBugsEclipsePlugin/schema/detectorPlugins.exsd"
220 extension point how to update the plugin.xml. Existing FindBugs detector plugins can
221 be easily "extended" to be full featured FindBugs & Eclipse detector plugins.
222 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and
223 update your build scripts to not to override the MANIFEST.MF during the build.
224
225 7.2 It is possible to configure custom detectors via Eclipse workspace preferences.
226 Go to "Window->Preferences->Java->FindBugs->Misc. Settings->Custom Detectors"
227 and specify there locations of any additional plugin libraries.
228
229 7.3 Plugins contributed via standard Eclipse extensions mechanism (see 7.1)
230 may extend the default FindBugs classpath and use custom libraries during the analysis.
231 This libraries must be part of standard Eclipse plugin dependencies specified via
232 either "Require-Bundle" or "Bundle-ClassPath" attributes in the MANIFEST.MF file.
233 In case custom detectors need access to this custom libraries at runtime, an
234 extra line must be added to the MANIFEST.MF (without quotation marks):
235 "Eclipse-RegisterBuddy: edu.umd.cs.findbugs.plugin.eclipse".
236
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1 <html>
2 <head>
3 <title>FindBugs Change Log</title>
4 <link rel="stylesheet" type="text/css" href="findbugs.css">
5
6 </head>
7
8 <body>
9
10 <table width="100%">
11 <tr>
12
13
14 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
15 <table width="100%" cellspacing="0" border="0">
16 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
17
18 <tr><td>&nbsp;</td></tr>
19
20 <tr><td><b>Docs and Info</b></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
31 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
32 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
33
34 <tr><td>&nbsp;</td></tr>
35
36 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
37
38 <tr><td>&nbsp;</td></tr>
39
40 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
41
42 <tr><td>&nbsp;</td></tr>
43
44 <tr><td><b>Development</b></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
52 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
53 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
54 </table>
55 </td>
56
57 <td align="left" valign="top">
58
59
60 <h1>FindBugs Change Log, Version 2.0.3</h1>
61 <ul>
62 <li>New Bug patterns: <a
63 href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_BOXED_PRIMITIVE_FOR_PARSING">DM_BOXED_PRIMITIVE_FOR_PARSING</a>,
64 <a
65 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_METHOD_RETURN_RELAXING_ANNOTATION">NP_METHOD_RETURN_RELAXING_ANNOTATION</a>,
66 and
67 <a
68 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION</a>
69 </li>
70 <li>Add the ability in the GUI to save the currently viewable/filtered bugs to HTML output.
71 <li>When dataflow does't terminate, make sure we continue with
72 analysis.
73
74 <li>Fix some problems that resulting in dataflow analysis not
75 terminating
76
77 <li>Get parameter annotations from default parameters
78 annotations applied to the method.
79 <li>Add subversion change number to eclipse plugin qualifier.
80
81 <li>Disabled detector for <a
82 href="http://findbugs.sourceforge.net/bugDescriptions.html#AM_CREATES_EMPTY_JAR_FILE_ENTRY">AM_CREATES_EMPTY_JAR_FILE_ENTRY</a>;
83 it complaints inappropriately about code that creates directory
84 entries.
85
86 <li>Add warnings about incompatible types passed to
87 org.testng.Assert.assertEquals</li>
88 <li>Add logic that understands more of the Google Guava APIs.
89 <li>Disable type qualifier validator execution within Eclipse plugin;
90 too many problems with class loading and security manager (see #1154 Random obscure Eclipse failures)
91 <li>Consistently check both access flags and attributes to see if something is synthetic. Compiler is
92 inconsistent about where synthetic elements are marked.
93
94 <li>Fixed false positives for the following bug patterns (17
95 occurrences in findbugsTestCases):
96 <ul>
97 <li><a
98 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC">BC</a>
99 <li><a
100 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_INSTANCEOF">BC_IMPOSSIBLE_INSTANCEOF</a>
101 <li><a
102 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST">BC_UNCONFIRMED_CAST</a>
103 <li><a
104 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_UNRELATED_TYPES">EC_UNRELATED_TYPES</a>
105 <li><a
106 href="http://findbugs.sourceforge.net/bugDescriptions.html#INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE</a>
107 <li><a
108 href="http://findbugs.sourceforge.net/bugDescriptions.html#IS2_INCONSISTENT_SYNC">IS2_INCONSISTENT_SYNC</a>
109 <li><a
110 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS</a>
111 <li><a
112 href="http://findbugs.sourceforge.net/bugDescriptions.html#OBL_UNSATISFIED_OBLIGATION">OBL_UNSATISFIED_OBLIGATION</a>
113 <li><a
114 href="http://findbugs.sourceforge.net/bugDescriptions.html#RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE</a>
115 <li><a
116 href="http://findbugs.sourceforge.net/bugDescriptions.html#SA_FIELD_SELF_COMPARISON">SA_FIELD_SELF_COMPARISON</a>
117 <li><a
118 href="http://findbugs.sourceforge.net/bugDescriptions.html#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED</a>
119 </li>
120 </ul>
121 <li>Fixed false negatives for the following bug patterns (45
122 occurrences in findbugsTestCases):
123 <ul>
124 <li><a
125 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST">BC_UNCONFIRMED_CAST</a>
126 <li><a
127 href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_NUMBER_CTOR">DM_NUMBER_CTOR</a>
128 <li><a
129 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_ARRAY_AND_NONARRAY">EC_ARRAY_AND_NONARRAY</a>
130 <li><a
131 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_INCOMPATIBLE_ARRAY_COMPARE">EC_INCOMPATIBLE_ARRAY_COMPARE</a>
132 <li><a
133 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_UNRELATED_TYPES">EC_UNRELATED_TYPES</a>
134 <li><a
135 href="http://findbugs.sourceforge.net/bugDescriptions.html#GC_UNRELATED_TYPES">GC_UNRELATED_TYPES</a>
136 <li><a
137 href="http://findbugs.sourceforge.net/bugDescriptions.html#IS_FIELD_NOT_GUARDED">IS_FIELD_NOT_GUARDED</a>
138 <li><a
139 href="http://findbugs.sourceforge.net/bugDescriptions.html#IT_NO_SUCH_ELEMENT">IT_NO_SUCH_ELEMENT</a>
140 <li><a
141 href="http://findbugs.sourceforge.net/bugDescriptions.html#JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS</a>
142 <li><a
143 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_ON_SOME_PATH">NP_NULL_ON_SOME_PATH</a>
144 <li><a
145 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NONNULL_PARAM_VIOLATION">NP_NONNULL_PARAM_VIOLATION</a>
146 <li><a
147 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE</a>
148 <li><a
149 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE</a>
150 <li><a
151 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_STORE_INTO_NONNULL_FIELD">NP_STORE_INTO_NONNULL_FIELD</a>
152 <li><a
153 href="http://findbugs.sourceforge.net/bugDescriptions.html#RE_POSSIBLE_UNINTENDED_PATTERN">RE_POSSIBLE_UNINTENDED_PATTERN</a>
154 <li><a
155 href="http://findbugs.sourceforge.net/bugDescriptions.html#SA_FIELD_SELF_COMPARISON">SA_FIELD_SELF_COMPARISON</a>
156 </ul>
157 </ul>
158 <h1>FindBugs Change Log, Version 2.0.2</h1>
159
160 <ul>
161 <li>Fix false positions for <a
162 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR</a>
163 - fixing <a
164 href="https://sourceforge.net/tracker/?func=detail&aid=3547559&group_id=96405&atid=614693">Bug3547559</a>,
165 <a
166 href="https://sourceforge.net/tracker/?func=detail&aid=3555408&group_id=96405&atid=614693">Bug3555408</a>,
167 <a
168 href="https://sourceforge.net/tracker/?func=detail&aid=3580266&group_id=96405&atid=614693">Bug3580266</a>
169 and <a
170 href="https://sourceforge.net/tracker/?func=detail&aid=3587164&group_id=96405&atid=614693">Bug3587164</a>.
171
172
173 </li>
174 <li>Fix false positives for <a
175 href="http://findbugs.sourceforge.net/bugDescriptions.html#SF_SWITCH_NO_DEFAULT">SF_SWITCH_NO_DEFAULT</a>
176 <li>Inline access methods for private fields,
177 fixing false positive in <a
178 href="https://sourceforge.net/tracker/?func=detail&aid=3484713&group_id=96405&atid=614693">Bug3484713</a>.
179
180 <li>Type qualifier annotations, including nullness
181 annotations, are now ignored on vararg parameters (including
182 default and inherited annotations), awaiting JSR308.
183 <li>Defined new bug pattern to give better explanations of
184 issues involving strict type qualifiers <a
185 href="http://findbugs.sourceforge.net/bugDescriptions.html#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED</a>
186 <li>Adjusted analysis of type qualifiers, now giving warnings
187 where a computed value is used in a place where a value with a
188 strict type qualifier is required.
189 <li>Complain about missing classes only if they are
190 encountered while analyzing application classes; ignore missing
191 classes that are encounted while analyzing classes loaded from the
192 auxclasspath. Fix for <a
193 href="https://sourceforge.net/tracker/?func=detail&aid=3588379&group_id=96405&atid=614693">Bug3588379</a>
194 <li>Fixed false positive null pointer warning coming from
195 synthetic bridge methods, fixing <a
196 href="https://sourceforge.net/tracker/?func=detail&aid=3589328&group_id=96405&atid=614693">Bug3589328</a>
197 <li>In general, suppress warnings in synthetic methods.
198 <li>Fix some false positives involving <a
199 href="http://findbugs.sourceforge.net/bugDescriptions.html#GC_UNRELATED_TYPES">GC_UNRELATED_TYPES</a>
200 on classes that extend generic collection classes.
201
202 </li>
203 <li>Combine multiple identical warnings about
204 <a
205 href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_DEFAULT_ENCODING">DM_DEFAULT_ENCODING</a>
206 that occur in the same method,
207 simplifying issue triage.
208
209 <li>Changes by Andrey Loskutov
210 <ul>
211 <li>fixed job scheduling errors in 3.8/4.2 Eclipse <a
212 href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=393748">bug
213 report</a>
214 <li>more realistic progress bar updates for jobs
215 <li>added nullness annotations for some common Eclipse API
216 methods known to usually return null values
217 <li>Added support for org.eclipse.jdt.annotation.Nullable,
218 NonNull and NonNullByDefault annotations (introduced with
219 Eclipse 3.8/4.2)</li>
220 </ul>
221 <li>Documentation improvements
222 <li><a href="http://code.google.com/p/findbugs/source/list">lots
223 of other small changes</a>
224 </ul>
225 <h1>FindBugs Change Log, Version 2.0.1</h1>
226
227 <ul>
228 <li>New bug patterns; in some cases, bugs previous reported as
229 other bug patterns are reported as instances of these new bug
230 patterns in order to make it easier for developers to understand
231 the bug reports
232 <ul>
233 <li><a
234 href="http://findbugs.sourceforge.net/bugDescriptions.html#PT_ABSOLUTE_PATH_TRAVERSAL">PT_ABSOLUTE_PATH_TRAVERSAL</a></li>
235 <li><a
236 href="http://findbugs.sourceforge.net/bugDescriptions.html#PT_RELATIVE_PATH_TRAVERSAL">PT_RELATIVE_PATH_TRAVERSAL</a></li>
237 <li><a
238 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR</a></li>
239 <li><a
240 href="http://findbugs.sourceforge.net/bugDescriptions.html#MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS_SHOULD_BE_REFACTORED_TO_BE_FINAL</a></li>
241 <li><a
242 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC_UNCONFIRMED_CAST_OF_RETURN_VALUE</a></li>
243 <li><a
244 href="http://findbugs.sourceforge.net/bugDescriptions.html#PT_ABSOLUTE_PATH_TRAVERSAL">PT_ABSOLUTE_PATH_TRAVERSAL</a></li>
245 <li><a
246 href="http://findbugs.sourceforge.net/bugDescriptions.html#TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS</a></li>
247 </ul>
248 </li>
249
250 <li>Changes to fix false negatives for the following bug
251 patterns: <a
252 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST">BC_UNCONFIRMED_CAST</a>,
253 <a
254 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_BAD_ARRAY_COMPARE">EC_BAD_ARRAY_COMPARE</a>,
255 <a
256 href="http://findbugs.sourceforge.net/bugDescriptions.html#EQ_UNUSUAL">EQ_UNUSUAL</a>,
257 <a
258 href="http://findbugs.sourceforge.net/bugDescriptions.html#GC_UNRELATED_TYPES">GC_UNRELATED_TYPES</a>,
259 and <a
260 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE</a>.
261 </li>
262
263 <li>Changes to fix false positions for the following bug
264 patterns: <a
265 href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_DOH">DMI_DOH</a>,
266 <a
267 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_UNRELATED_TYPES">EC_UNRELATED_TYPES</a>,
268 and <a
269 href="http://findbugs.sourceforge.net/bugDescriptions.html#SE_BAD_FIELD">SE_BAD_FIELD</a>.
270 </li>
271 </ul>
272
273 <h1>FindBugs Change Log, Version 2.0.0</h1>
274
275 <h2>Changes since version 1.3.8</h2>
276 <ul>
277 <li>New bug patterns; in some cases, bugs previous reported as
278 other bug patterns are reported as instances of these new bug
279 patterns in order to make it easier for developers to understand
280 the bug reports
281 <ul>
282 <li><a
283 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_DOWNCAST ">BC_IMPOSSIBLE_DOWNCAST
284 </a></li>
285 <li><a
286 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY ">BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY
287 </a></li>
288 <li><a
289 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_INCOMPATIBLE_ARRAY_COMPARE ">EC_INCOMPATIBLE_ARRAY_COMPARE
290 </a></li>
291 <li><a
292 href="http://findbugs.sourceforge.net/bugDescriptions.html#JLM_JSR166_UTILCONCURRENT_MONITORENTER ">JLM_JSR166_UTILCONCURRENT_MONITORENTER
293 </a></li>
294 <li><a
295 href="http://findbugs.sourceforge.net/bugDescriptions.html#LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE ">LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE
296 </a></li>
297 <li><a
298 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_CLOSING_NULL ">NP_CLOSING_NULL
299 </a></li>
300 <li><a
301 href="http://findbugs.sourceforge.net/bugDescriptions.html#RC_REF_COMPARISON_BAD_PRACTICE ">RC_REF_COMPARISON_BAD_PRACTICE
302 </a></li>
303 <li><a
304 href="http://findbugs.sourceforge.net/bugDescriptions.html#RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN ">RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN
305 </a></li>
306 <li><a
307 href="http://findbugs.sourceforge.net/bugDescriptions.html#RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED ">RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED
308 </a></li>
309 <li><a
310 href="http://findbugs.sourceforge.net/bugDescriptions.html#SIC_THREADLOCAL_DEADLY_EMBRACE ">SIC_THREADLOCAL_DEADLY_EMBRACE
311 </a></li>
312 <li><a
313 href="http://findbugs.sourceforge.net/bugDescriptions.html#UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR ">UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR
314 </a></li>
315 <li><a
316 href="http://findbugs.sourceforge.net/bugDescriptions.html#VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED ">VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED
317 </a></li>
318 </ul>
319 </li>
320 <li>Providing a bug rank (1-20), and the ability to filter by
321 bug rank. Eventually, it will be possible to specify your own
322 rules for ranking bugs, but the procedure for doing so hasn't been
323 specified yet.</li>
324 <li>Fixed about <a
325 href="https://sourceforge.net/search/index.php?group_id=96405&search_summary=1&search_details=1&type_of_search=artifact&group_artifact_id%5B%5D=614693&open_date_start=2009-03-16&open_date_end=2009-08-20&form_submit=Search">45
326 bugs filed</a> through SourceForge
327 </li>
328 <li>Various reclassifications and priority tweaks</li>
329 <li>Added more bug annotations to a variety of bug reports.
330 This provides more context for understanding bug reports (e.g., if
331 the value in question was is the return value of a method, the
332 method is described as the source of the value in a bug
333 annotation). This also provide more accurate tracking of issues
334 across versions of the code being analyzed, but has the downside
335 that when comparing results from FindBugs 1.3.8 and FindBugs 1.3.9
336 on the same version of code being analyzed, FindBugs may think
337 that mistakenly believe that the issue reported by 1.3.8 was fixed
338 and a new issue was introduced that was reported by FindBugs
339 1.3.9. While annoying, it would be unusual for more than a dozen
340 issues per million lines of codes to be mistracked.</li>
341 <li>Lots of internal changes moving towards FindBugs 2.0, but
342 these features are undocumented, not yet officially supported, and
343 subject to radical changes before FindBugs 2.0 is released.</li>
344 </ul>
345
346 <p>Changes since version 1.3.8</p>
347 <ul>
348 <li>New bug patterns; in some cases, bugs previous reported as
349 other bug patterns are reported as instances of these new bug
350 patterns in order to make it easier for developers to understand
351 the bug reports
352 <ul>
353 <li><a
354 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_DOWNCAST ">BC_IMPOSSIBLE_DOWNCAST
355 </a>
356 <li><a
357 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY ">BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY
358 </a>
359 <li><a
360 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_INCOMPATIBLE_ARRAY_COMPARE ">EC_INCOMPATIBLE_ARRAY_COMPARE
361 </a>
362 <li><a
363 href="http://findbugs.sourceforge.net/bugDescriptions.html#JLM_JSR166_UTILCONCURRENT_MONITORENTER ">JLM_JSR166_UTILCONCURRENT_MONITORENTER
364 </a>
365 <li><a
366 href="http://findbugs.sourceforge.net/bugDescriptions.html#LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE ">LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE
367 </a>
368 <li><a
369 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_CLOSING_NULL ">NP_CLOSING_NULL
370 </a>
371 <li><a
372 href="http://findbugs.sourceforge.net/bugDescriptions.html#RC_REF_COMPARISON_BAD_PRACTICE ">RC_REF_COMPARISON_BAD_PRACTICE
373 </a>
374 <li><a
375 href="http://findbugs.sourceforge.net/bugDescriptions.html#RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN ">RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN
376 </a>
377 <li><a
378 href="http://findbugs.sourceforge.net/bugDescriptions.html#RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED ">RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED
379 </a>
380 <li><a
381 href="http://findbugs.sourceforge.net/bugDescriptions.html#SIC_THREADLOCAL_DEADLY_EMBRACE ">SIC_THREADLOCAL_DEADLY_EMBRACE
382 </a>
383 <li><a
384 href="http://findbugs.sourceforge.net/bugDescriptions.html#UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR ">UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR
385 </a>
386 <li><a
387 href="http://findbugs.sourceforge.net/bugDescriptions.html#VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED ">VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED
388 </a>
389 </ul>
390 </li>
391 <li>Providing a bug rank (1-20), and the ability to filter by
392 bug rank. Eventually, it will be possible to specify your own
393 rules for ranking bugs, but the procedure for doing so hasn't been
394 specified yet.</li>
395 <li>Fixed about <a
396 href="https://sourceforge.net/search/index.php?group_id=96405&search_summary=1&search_details=1&type_of_search=artifact&group_artifact_id%5B%5D=614693&open_date_start=2009-03-16&open_date_end=2009-08-20&form_submit=Search">45
397 bugs filed</a> through SourceForge
398 </li>
399 <li>Various reclassifications and priority tweaks</li>
400 <li>Added more bug annotations to a variety of bug reports.
401 This provides more context for understanding bug reports (e.g., if
402 the value in question was is the return value of a method, the
403 method is described as the source of the value in a bug
404 annotation). This also provide more accurate tracking of issues
405 across versions of the code being analyzed, but has the downside
406 that when comparing results from FindBugs 1.3.8 and FindBugs 1.3.9
407 on the same version of code being analyzed, FindBugs may think
408 that mistakenly believe that the issue reported by 1.3.8 was fixed
409 and a new issue was introduced that was reported by FindBugs
410 1.3.9. While annoying, it would be unusual for more than a dozen
411 issues per million lines of codes to be mistracked.</li>
412 <li>Lots of internal changes moving towards FindBugs 2.0, but
413 these features are undocumented, not yet officially supported, and
414 subject to radical changes before FindBugs 2.0 is released.</li>
415 </ul>
416
417 <p>Changes since version 1.3.7</p>
418 <ul>
419 <li>Primarily another small bugfix release.</li>
420 <li>FindBugs base:
421 <ul>
422 <li>New Reports:
423 <ul>
424 <li>SF_SWITCH_NO_DEFAULT: missing default case in switch
425 statement.</li>
426 <li>SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW:
427 value ignored when switch fallthrough leads to thrown
428 exception.</li>
429 <li>INT_VACUOUS_BIT_OPERATION: bit operations that don't
430 do any meaningful work.</li>
431 <li>FB_UNEXPECTED_WARNING: warning generated that
432 conflicts with @NoWarning FindBugs annotation.</li>
433 <li>FB_MISSING_EXPECTED_WARNING: warning not generated
434 despite presence of @ExpectedWarning FindBugs annotation.</li>
435 <li>NOISE category: intended for use in data mining
436 experiments.
437 <ul>
438 <li>NOISE_NULL_DEREFERENCE: fake null point dereference
439 warning.</li>
440 <li>NOISE_METHOD_CALL: fake method call warning.</li>
441 <li>NOISE_FIELD_REFERENCE: fake field dereference
442 warning.</li>
443 <li>NOISE_OPERATION: fake operation warning.</li>
444 </ul>
445 </li>
446 </ul>
447 </li>
448 <li>Other:
449 <ul>
450 <li>Garvin Leclaire has created a new Apache Maven
451 repository for FindBugs at <a
452 href="http://code.google.com/p/findbugs/">the Google Code
453 FindBugs SVN repository</a>. (Thanks Garvin!)
454 </li>
455 </ul>
456 </li>
457 <li>Fixes:
458 <ul>
459 <li>[ 2317842 ] Highlighting broken in Windows</li>
460 <li>[ 2515908 ] check for oddness should track sign of
461 argument</li>
462 <li>[ 2487936 ] &quot;L B GC&quot; false pos cast from
463 Map.Entry.getKey() to Map.get()</li>
464 <li>[ 2528264 ] Ant tasks not compatible with Ant 1.7.1</li>
465 <li>[ 2539590 ] SF_SWITCH_FALLTHROUGH wrong message
466 reported</li>
467 <li>[ 2020066 ] Bug history displayed in fancy-hist.xsl is
468 incorrect</li>
469 <li>[ 2545098 ] Invalid character in analysis results file</li>
470 <li>[ 2492673 ] Plugin sites should specify &quot;requires
471 Eclipse 3.3 or newer&quot;</li>
472 <li>[ 2588044 ] a tiny typing error</li>
473 <li>[ 2589048 ] Documentation for convertXmlToText
474 insufficient</li>
475 <li>[ 2638739 ] NullPointerException when building</li>
476 </ul>
477 </li>
478 <li>Patches:
479 <ul>
480 <li>[ 2538184 ] Make BugCollection implement
481 Iterable&lt;BugInstance&gt; (thanks to Tomas Pollak)</li>
482 <li>[ 2249771 ] Add Maven2 Findbugs plugin link to the
483 Links page (thanks to Garvin Leclaire)</li>
484 <li>[ 2609526 ] Japanese manual update (thanks to K.
485 Hashimoto)</li>
486 <li>[ 2119482 ] CheckBcel checks for nonexistent classes
487 (thanks to Jerry James)</li>
488 </ul>
489 </li>
490 </ul>
491 </li>
492 <li>FindBugs Eclipse plugin:
493 <ul>
494 <li>Major feature enhancements (thanks to Andrey Loskutov).
495 See <a href="http://andrei.gmxhome.de/findbugs/index.html">this
496 overview</a> for more information.
497 </li>
498 <li>Major test improvements (thanks to Tomas Pollak).</li>
499 <li>Fixes:
500 <ul>
501 <li>[ 2532365 ] Compiler warning</li>
502 <li>[ 2522989 ] Fix filter files selection</li>
503 <li>[ 2504068 ] NullPointerException</li>
504 <li>[ 2640849 ] NPE in Eclipse plugin 1.3.7 and Eclipse
505 3.5 M5</li>
506 </ul>
507 </li>
508 <li>Patches:
509 <ul>
510 <li>[ 2143140 ] Unchecked conversion fixes for Eclipse
511 plugin (thanks to Jerry James)
512 </ul>
513 </li>
514 </ul>
515 </li>
516 </ul>
517
518 <p>Changes since version 1.3.6</p>
519 <ul>
520 <li>Overall, a small bugfix release.
521 <li>New detection of accidental vacuous/useless calls to
522 EasyMock methods, and of generic signatures that proclaim the use
523 of unhashable classes in ways that require that they be hashed.
524 <li>Eliminate some false positives where we were warning about
525 a useless call (e.g., comparing two incompatible types for
526 equality), but the only thing the code was doing with the result
527 was passing it to assertFalse.
528 <li>Japanese localization and manual by K.Hashimoto. (Thanks!)
529
530 <li>Added -exclude and -outputDir command line options to
531 rejarForAnalysis
532 <li>Extended -adjustPriorities option to FindBugs analysis
533 textui so that you can modify the priorities of individual bug
534 patterns as well as visitors, and also completely suppress
535 individual bug patterns or visitors.
536 <ul>
537 <li>e.g., -adjustPriority
538 MS_SHOULD_BE_FINAL=suppress,MS_PKGPROTECT=suppress,EI_EXPOSE_REP=suppress,EI_EXPOSE_REP2=suppress,PZLA_PREFER_ZERO_LENGTH_ARRAYS=raise
539
540 </ul>
541 </ul>
542
543
544 <p>Changes since version 1.3.5</p>
545 <ul>
546 <li>Added fairly exhaustive static analysis of uses of format
547 strings, checking for missing or extra arguements, invalid format
548 specifiers, or mismatched format specifiers and arguments (e.g,
549 passing a String value for a %d format specifier). The logic for
550 doing so is derived from Sun's java.util.Formatter class, and
551 available separately from FindBugs as part of the <a
552 href="https://jformatstring.dev.java.net/">jFormatString</a>
553 project.
554 <li>More tuning of the unsatisfied obligation detector. Since
555 this detector is still rather noisy and an unfinished research
556 project, I've moved the generated issues to a new category:
557 EXPERIMENTAL.
558 <li>Added check for <a
559 href="http://findbugs.sourceforge.net/bugDescriptions.html#BIT_ADD_OF_SIGNED_BYTE">BIT_ADD_OF_SIGNED_BYTE</a>;
560 similar to <a
561 href="http://findbugs.sourceforge.net/bugDescriptions.html#BIT_IOR_OF_SIGNED_BYTE">BIT_IOR_OF_SIGNED_BYTE</a>,
562 except that addition is being used to combine shifted signed
563 bytes.
564 <li>Changed detection of EI_EXPOSE_REP2, so we only report it
565 if the value stored is guaranteed to be the same value that was
566 passed in as a parameter.
567 <li>Added <a
568 href="http://findbugs.sourceforge.net/bugDescriptions.html#EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS</a>,
569 a warning when an equals method checks to see if an operand is an
570 instance of a class not compatible with itself. For example, if
571 the Foo class checks to see if the argument is an instance of
572 String. This is either a questionable design decision or a coding
573 mistake.
574 <li>Added <a
575 href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_INVOKING_HASHCODE_ON_ARRAY">DMI_INVOKING_HASHCODE_ON_ARRAY</a>,
576 which checks for invoking <code>hashCode()</code> on an array,
577 which returns a hash code that ignores the contents of the array.
578
579 <li>Added checks for using <code>x.removeAll(x)</code> to
580 rather than <code>x.clear()</code> to clear an array.
581 <li>Add checks for calls such as <code>x.contains(x)</code>, <code>x.remove(x)</code>
582 and <code>x.containsAll(x)</code>.
583 <li>Improvements to Eclipse plugin (thanks to Andrey
584 Loskutov):
585 <ul>
586 <li>Report separate markers for each occurrence of an issue
587 that appears multiple times in a method
588 <li>fine tuning for reported markers: add only one marker
589 for fields, add marker on right position
590 <li>link bugs selected in bug explorer view to the opened
591 editor and vice versa
592 <li>select bugs selected in editor ruler in the opened bug
593 explorer view
594 <li>consistent abbreviations used in both bug explorer and
595 bug details view
596 <li>added "Expand All" button to the bug explorer view
597 <li>added "Go Into/Go Up" buttons to the bug explorer view
598 <li>added "Copy to clipboard" menu/functionality to the
599 details view list widget
600 <li>fix for CNF exception if loading the backup solution for
601 broken browser widget
602 </ul>
603 </ul>
604
605
606
607 <p>Changes since version 1.3.4</p>
608 <ul>
609 <li>Analysis about 15% faster
610 <li><a
611 href="http://sourceforge.net/tracker/?atid=614693&group_id=96405&func=browse&status=closed">38
612 bugs closed</a></li>
613 <li>New defect warnings:
614 <ul>
615 <li>calls to methods that always throw
616 UnsupportedOperationException (DMI_UNSUPPORTED_METHOD)
617 <li>repeated conditional tests (e.g., <code>if (x
618 &lt; 0 || x &lt; 0) ...</code>) (RpC_REPEATED_CONDITIONAL_TEST)
619 <li>Complete rewrite of detector for format string problems.
620 More accurate, finds more problems, generates more descriptive
621 reports, several different bug pattern
622 (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED,
623 VA_FORMAT_STRING_ILLEGAL, VA_FORMAT_STRING_MISSING_ARGUMENT,
624 VA_FORMAT_STRING_BAD_ARGUMENT,
625 VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)
626 <li>Fairly complete implementation of JSR-305 custom type
627 qualifier analysis (no support for custom validators yet).
628 (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK
629 TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK
630 TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK)
631 <li>New detector for unsatisfied obligations such forgetting
632 to close a file (OBL_UNSATISFIED_OBLIGATION).
633 <li>Warning when a parameter is marked as nullable, but is
634 always dereferenced.
635 (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE)
636 <lI>Separate warning for dereference the result of readLine
637 (NP_DEREFERENCE_OF_READLINE_VALUE)
638 </ul>
639 <li>When XML is generated with messages, the project stats now
640 include &lt;FileStat&gt; elements. For each source file, this
641 gives the path for the file, the total number of warnings for that
642 file, and a bugHash for the file. While the instanceHash for a bug
643 is intended to be version invariant (ignoring line numbers, etc),
644 the bugHash for a file is intended to reflect all the information
645 about the warnings in that file. The intended use case is that if
646 the bugHash for a file is the same in two analysis runs, then <em>nothing</em>
647 has changed about any of the warnings reported for that file
648 between the two analysis runs.
649 <li>More merging of similar issues within a method. For
650 example, if the result of readLine() is dereferences multiple
651 times within a method, it will be reported as a single warning
652 with occurrences at multiple source lines.
653 </ul>
654 <p>Changes since version 1.3.3</p>
655
656 <ul>
657 <li>FindBugs base
658 <ul>
659 <li>New Reports:
660 <ul>
661 <li>EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC: equals method
662 overrides equals in superclass and may not be symmetric</li>
663 <li>EQ_ALWAYS_TRUE: equals method always returns true</li>
664 <li>EQ_ALWAYS_FALSE: equals method always returns false</li>
665 <li>EQ_COMPARING_CLASS_NAMES: equals method compares class
666 names rather than class objects</li>
667 <li>EQ_UNUSUAL: Unusual equals method</li>
668 <li>EQ_GETCLASS_AND_CLASS_CONSTANT: equals method fails
669 for subtypes</li>
670 <li>SE_READ_RESOLVE_IS_STATIC: The readResolve method must
671 not be declared as a static method.</li>
672 <li>SE_PRIVATE_READ_RESOLVE_NOT_INHERITED: private
673 readResolve method not inherited by subclasses</li>
674 <li>MSF_MUTABLE_SERVLET_FIELD: Mutable servlet field</li>
675 <li>XSS_REQUEST_PARAMETER_TO_SEND_ERROR: Servlet reflected
676 cross site scripting vulnerability</li>
677 <li>SKIPPED_CLASS_TOO_BIG: Class too big for analysis</li>
678 </ul>
679 </li>
680 <li>Other:
681 <ul>
682 <li>Value-number analysis now more space-efficient</li>
683 <li>Enhancements to reduce memory overhead when analyzing
684 very large classes</li>
685 <li>Now skips very large classes that would otherwise take
686 too much time and memory to analyze</li>
687 <li>Infrastructure for tracking effectively-constant/
688 effectively-final fields</li>
689 <li>Added more cweids</li>
690 <li>Enhanced taint tracking for taint-based detectors</li>
691 <li>Ignore doomed calls to equals if result is used as an
692 argument to assertFalse</li>
693 <li>EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC handles compareTo</li>
694 <li>Priority tweak for ICAST_INTEGER_MULTIPLY_CAST_TO_LONG
695 (only low priority if multiplying by 1000)</li>
696 <li>Improved tracking of fields across method calls</li>
697 </ul>
698 </li>
699 <li>Fixes:
700 <ul>
701 <li>[ 1941450 ] DLS_DEAD_LOCAL_STORE not reported</li>
702 <li>[ 1953323 ] Omitted break statement in
703 SynchronizeAndNullCheckField</li>
704 <li>[ 1942620 ] Source Directories selection dialog
705 interface confusion (partial)</li>
706 <li>[ 1948275 ] Unhelpful "Load of known null"</li>
707 <li>[ 1933922 ] MWM error in findbugs</li>
708 <li>[ 1934772 ] 1.3.3 appears to rely on JDK 1.6, JNLP
709 still specifies 1.5</li>
710 <li>[ 1933945 ] -loadbugs doesn't work</li>
711 <li>Fixed problems for class names starting with '$'</li>
712 <li>Fixed bugs and incomplete handling of annotations in
713 VersionInsensitiveBugComparator</li>
714 </ul>
715 </li>
716 <li>Patches:
717 <ul>
718 <li>[ 1955106 ] Javadoc fixes</li>
719 <li>[ 1951930 ] Superfluous import statements (thanks to
720 Jerry James)</li>
721 <li>[ 1951907 ] Missing @Deprecated annotations (thanks to
722 Jerry James)</li>
723 <li>[ 1951876 ] Infonode Docking Windows compile fix
724 (thanks to Jerry James)</li>
725 <li>[ 1936055 ] bugfix for findbugs.de.comment not working
726 (thanks to Peter Fokkinga)
727 </ul>
728 </li>
729 </ul>
730 <li>FindBugs BlueJ plugin
731 <ul>
732 <li>Updated to use FindBugs 1.3.4 (first new release since
733 1.1.3)</li>
734 </ul>
735 </li>
736 </ul>
737
738 <p>Changes since version 1.3.2</p>
739
740 <ul>
741 <li>FindBugs base
742 <ul>
743 <li>New Detectors:
744 <ul>
745 <li>FieldItemSummary: Produces summary information for
746 what is stored into fields</li>
747 <li>SynchronizeOnClassLiteralNotGetClass: Look for code
748 that synchronizes on the results of getClass rather than on
749 class literals</li>
750 <li>SynchronizingOnContentsOfFieldToProtectField: This
751 detector looks for code that seems to be synchronizing on a
752 field in order to guard updates of that field</li>
753 </ul>
754 </li>
755 <li>New BugCode:
756 <ul>
757 <li>HRS: HTTP Response splitting vulnerability</li>
758 <li>WL: Possible locking on wrong object</li>
759 </ul>
760 </li>
761 <li>New Reports:
762 <ul>
763 <li>DMI_CONSTANT_DB_PASSWORD: This code creates a database
764 connect using a hard coded, constant password</li>
765 <li>HRS_REQUEST_PARAMETER_TO_COOKIE: HTTP cookie formed
766 from untrusted input</li>
767 <li>HRS_REQUEST_PARAMETER_TO_HTTP_HEADER: HTTP parameter
768 directly written to HTTP header output</li>
769 <li>CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE: Class defines
770 clone() but doesn't implement Cloneable</li>
771 <li>DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE: Synchronization
772 on boxed primitive could lead to deadlock</li>
773 <li>DL_SYNCHRONIZATION_ON_BOOLEAN: Synchronization on
774 Boolean could lead to deadlock</li>
775 <li>ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD:
776 Synchronization on field in futile attempt to guard that field
777 </li>
778 <li>DLS_DEAD_LOCAL_STORE_IN_RETURN: Useless assignment in
779 return statement</li>
780 <li>WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL:
781 Synchronization on getClass rather than class literal</li>
782 </ul>
783 </li>
784 <li>Other:
785 <ul>
786 <li>Many enhancements to cross-site scripting detector and
787 its documentation</li>
788 <li>Enhanced switch fall through handling</li>
789 <li>Enhanced unread field handling (look for IF_ACMPEQ and
790 IF_ACMPNE)</li>
791 <li>Clarified documentation for @Nullable in manual</li>
792 <li>Fewer DeadLocalStore false positives</li>
793 <li>Fewer UnreadField false positives</li>
794 <li>Fewer StaticCalendarDetector false positives</li>
795 <li>Performance fix for slow file system IO e.g. Clearcase
796 repositories (thanks, Andrei!)</li>
797 <li>Other, general performance enhancements (thanks,
798 Andrei!)</li>
799 <li>Enhancements for using FindBugs scripts with MKS on
800 Windows (thanks, Kelly O'Hair!)</li>
801 <li>Noted in the manual that jsr305.jar must be present
802 for annotations to compile</li>
803 <li>Added and fine-tuned default-nullness annotations</li>
804 <li>More CWE IDs added</li>
805 <li>Check and warning for unexpected BCEL version in
806 classpath</li>
807 </ul>
808 </li>
809 <li>Fixes:
810 <ul>
811 <li>Bug fix to handling of local variable tables in BCEL</li>
812 <li>Refined documentation for
813 MTIA_SUSPECT_STRUTS_INSTANCE_FIELD</li>
814 <li>[ 1927295 ] NPE when called on project root</li>
815 <li>[ 1926405 ] Incorrect dead store warning</li>
816 <li>[ 1926409 ] Incorrect redundant nullcheck warning</li>
817 <li>[ 1926389 ] Wrong line number printed/highlighted in
818 bug</li>
819 <li>[ 1927040 ] typo in bug description</li>
820 <li>[ 1926263 ] Minor glitch in HTML output</li>
821 <li>[ 1926240 ] Minor error in standard options in manual</li>
822 <li>[ 1926236 ] Minor bug in installation section of
823 manual</li>
824 <li>[ 1925539 ] ZIP is default file system code base</li>
825 <li>[ 1894701 ] Livelock / memory leak in
826 ObjectTypeFactory (thanks, Andrei!)</li>
827 <li>[ 1867491 ] Doesn't reload annotations after code
828 changes in IDE (thanks, Andrei!)</li>
829 <li>[ 1921399 ] -project option not supported</li>
830 <li>[ 1913834 ] "Dead" store to variable with method call</li>
831 <li>[ 1917352 ] H B se:...field in serializable class</li>
832 <li>[ 1911617 ] CloneIdiom relies on
833 getNameConstantOperand for INSTANCEOF</li>
834 <li>[ 1911620 ] False +: DLS predecrement before return</li>
835 <li>[ 1871376 ] False negative: non-serializable Map field</li>
836 <li>[ 1871051 ] non standard clone() method</li>
837 <li>[ 1908854 ] Error in TestASM</li>
838 <li>[ 1907539 ] 22 minor errors in bug checker
839 documentation</li>
840 <li>[ 1897323 ] EJB implementation class false positives</li>
841 <li>[ 1899648 ] Crash on startup on Vista with Java
842 1.6.0_04</li>
843 </ul>
844 </li>
845 </ul>
846 </li>
847 <li>FindBugs Eclipse plugin (change log by Andrey Loskutov)
848 <ul>
849 <li>new feature: export basic FindBugs numbers for projects
850 via File-&gt;Export-&gt;Java-&gt;BugCounts (Andrey Loskutov)</li>
851 <li>new feature: jobs for different projects will be run in
852 parallel per default if running on a multi-core PC
853 ("fb.allowParallelBuild" system property not used anymore)
854 (Andrey Loskutov)</li>
855 <li>fixed performance slowdown in the multi-threaded build,
856 caused by workspace operation locks during assigning marker
857 attributes (Andrey Loskutov)</li>
858 </ul>
859 </li>
860 </ul>
861
862 <p>Changes since version 1.3.1</p>
863
864 <ul>
865 <li>FindBugs base
866 <ul>
867 <li>New Bug Category:
868 <ul>
869 <li>SECURITY (Abbrev: S), A use of untrusted input in a
870 way that could create a remotely exploitable security
871 vulnerability</li>
872 </ul>
873 </li>
874 <li>New Detectors:
875 <ul>
876 <li>CrossSiteScripting: This detector looks for
877 obvious/blatant cases of cross site scripting vulnerabilities</li>
878 </ul>
879 </li>
880 <li>New BugCode:
881 <ul>
882 <li>XSS: Cross site scripting</li>
883 </ul>
884 </li>
885 <li>New Reports:
886 <ul>
887 <li>XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER: HTTP
888 parameter directly written to Servlet output, giving XSS
889 vulnerability</li>
890 <li>XSS_REQUEST_PARAMETER_TO_JSP_WRITER: HTTP parameter
891 directly written to JSP output, giving XSS vulnerability</li>
892 <li>EQ_OTHER_USE_OBJECT: equals() method defined that
893 doesn't override Object.equals(Object)</li>
894 <li>EQ_OTHER_NO_OBJECT: equals() method inherits rather
895 than overrides equals(Object)</li>
896 <li>NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE: Possible
897 null pointer dereference on path that might be infeasible</li>
898 </ul>
899 </li>
900 <li>Other:
901 <ul>
902 <li>Added -noClassOk command-line parameter to
903 command-line and ant interfaces; when -noClassOk is specified
904 and no classfiles are given, FindBugs will print a warning
905 message and output a well- formed file with no warnings</li>
906 <li>Fewer false positives for null pointer bugs</li>
907 <li>Suppress dead-local-store false positives in .jsp code</li>
908 <li>Type fixes in warning messages</li>
909 <li>Better warning message for NP_NULL_ON_SOME_PATH</li>
910 <li>"WMI" bug code description renamed from "Wrong Map
911 Iterator" to "Inefficient Map Iterator"</li>
912 </ul>
913 </li>
914 <li>Fixes:
915 <ul>
916 <li>[ 1893048 ] FindBugs confused by a findbugs.xml file</li>
917 <li>[ 1878528 ] XSL xforms don't support history features</li>
918 <li>[ 1876584 ] two default.xsl flaws</li>
919 <li>[ 1874856 ] Format string bug detector doesn't handle
920 special operators</li>
921 <li>[ 1872645 ] computeBugHistory -
922 java.lang.IllegalArgumentException</li>
923 <li>[ 1872237 ] Ant task fails when no .class files</li>
924 <li>[ 1868670 ] Filters: include AND exclude don't allowed</li>
925 <li>[ 1868666 ] check-for-oddness reported, but array
926 length can never be negative</li>
927 <li>[ 1866108 ] SetBugDatabaseInfoTask strips dir from
928 output filename</li>
929 <li>[ 1866021 ] MineBugHistoryTask strips dir of output
930 filename</li>
931 <li>[ 1865265 ] code doesn't handle
932 StringBuffer.append([CII) right</li>
933 <li>[ 1864793 ] Warning when casting a null reference
934 compared to a String</li>
935 <li>[ 1863376 ] Typo in manual chap 8: Filter Files</li>
936 <li>[ 1862705 ] Transient fields that default to null</li>
937 <li>[ 1842545 ] DLS on catch variable (with priority
938 tweaking)</li>
939 <li>[ 1816258 ] false positive BC_IMPOSSIBLE_CAST</li>
940 <li>[ 1551732 ] Get erroneous DLS with while loop</li>
941 </ul>
942 </li>
943 </ul>
944 </li>
945 <li>FindBugs Eclipse plugin (change log by Andrey Loskutov)
946 <ul>
947 <li>new feature: added Bug explorer view (replacing Bug tree
948 view), based on Common Navigator framework (Andrey Loskutov)</li>
949 <li>bug 1873860 fixed: empty projects are no longer shown in
950 Bug tree view (Andrey Loskutov)</li>
951 <li>new feature: bug counts decorators for projects, folders
952 and files (has to be activated via Preferences -&gt; general
953 -&gt; appearance -&gt; label decorations)(Andrey Loskutov)</li>
954 <li>patch 1746499: better icons (Alessandro Nistico)</li>
955 <li>patch 1893685: Find bug actions on change sets bug
956 (Alessandro Nistico)</li>
957 <li>fixed bug 1855384: Bug configuration is broken in
958 Eclipse (Andrey Loskutov)</li>
959 <li>refactored FindBugs properties page (Andrey Loskutov)</li>
960 <li>refactored FindBugs worker/builder/run action (Andrey
961 Loskutov)</li>
962 <li>FB detects now only bugs from classes on project's
963 classpath (no double work on duplicated class files) (Andrey
964 Loskutov)</li>
965 <li>fixed bug introduced by the bad patch for 1867951: FB
966 cannot be executed incrementally on a folder of file (Andrey
967 Loskutov)</li>
968 <li>fixed job rule: now jobs for different projects may run
969 in parallel if running on a multi-core PC and
970 "fb.allowParallelBuild" system property is set to true (Andrey
971 Loskutov)</li>
972 <li>fixed FB auto-build not started if .fbprefs or
973 .classpath was changed (Andrey Loskutov)</li>
974 <li>fixed not reporting bugs on secondary types (classes
975 defined in java files with different name) (Andrey Loskutov)</li>
976 </ul>
977 </li>
978 </ul>
979
980 <p>Changes since version 1.3.0</p>
981 <ul>
982 <li>New Reports
983 <ul>
984 <li>VA_FORMAT_STRING_ARG_MISMATCH: A format-string method
985 with a variable number of arguments is called, but the number of
986 arguments passed does not match with the number of %
987 placeholders in the format string. This is probably not what the
988 author intended.
989 <li>IO_APPENDING_TO_OBJECT_OUTPUT_STREAM: This code opens a
990 file in append mode and that wraps the result in an object
991 output stream. This won't allow you to append to an existing
992 object output stream stored in a file. If you want to be able to
993 append to an object output stream, you need to keep the object
994 output stream open. The only situation in which opening a file
995 in append mode and the writing an object output stream could
996 work is if on reading the file you plan to open it in random
997 access mode and seek to the byte offset where the append
998 started.
999 <li>NP_BOOLEAN_RETURN_NULL: A method that returns either
1000 Boolean.TRUE, Boolean.FALSE or null is an accident waiting to
1001 happen. This method can be invoked as though it returned a value
1002 of type boolean, and the compiler will insert automatic unboxing
1003 of the Boolean value. If a null value is returned, this will
1004 result in a NullPointerException.
1005 </ul>
1006 </li>
1007 <li>Changes to Existing Reports
1008 <ul>
1009 <li>RV_DONT_JUST_NULL_CHECK_READLINE: CORRECTNESS -&gt;
1010 STYLE</li>
1011 <li>DMI_INVOKING_TOSTRING_ON_ARRAY: Long description
1012 mentions array name whenever possible</li>
1013 </ul>
1014 </li>
1015 <li>Fixes:
1016 <ul>
1017 <li>Updated manual to mention that Java 1.5 is now a
1018 requirement for running FindBugs
1019 <li>Applied patch 1840206 fixing issue "Ant task does not
1020 work when presetdef is used" - thanks to phejl
1021 <li>Applied patch 1778690 fixing issue "Ant task: tolerate
1022 but complain about invalid auxClasspath" - thanks to David
1023 Schmidt
1024 <li>Applied patch 1852125 adding a Chinese-language GUI
1025 bundle props file - thanks to fifi
1026 <li>Applied patch 1845903 adding ability to load XML results
1027 with the Eclipse plugin - thanks to Alex Mont
1028 <li>Fixed issue 1844671 - "FP for "reversed" null check in
1029 catch for stream close"
1030 <li>Fixed issue 1836050 - "-onlyAnalyze broken"
1031 <li>Fixed issue 1853011 - "Typo: Field names should start
1032 with aN lower case letter"
1033 <li>Fixed issue 1844181 - "JNLP file does not contain all
1034 necessary JARs"
1035 <li>Fixed issue 1840245 - "xxxException class does not
1036 derive from Exception"
1037 <li>Fixed issue 1840277 - "[M D EC] Typo in bug
1038 documentation"
1039 <li>Fixed issue 1782447 - "OutOfMemoryError if i activate
1040 Findbugs on my project"
1041 <li>Fixed issue 1830576 - "[regression] keySet/entrySet
1042 false positive"
1043 </ul>
1044 </li>
1045 <li>Other:
1046 <ul>
1047 <li>New bug code: "IO" (for
1048 IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)</li>
1049 <li>Added "-onlyMostRecent" option for computeBugHistory
1050 script/ant task
1051 <li>More explicit language in
1052 RV_RETURN_VALUE_IGNORED_BAD_PRACTICE messages
1053 <li>Modified ResourceValueAnalysis to correctly identify
1054 null == X or null != X as a null check (for issue 1844671)
1055 <li>Modified DMI_HARDCODED_ABSOLUTE_FILENAME logic in
1056 DumbMethodInvocations to ignore files from /etc or /dev and
1057 increase priority of files from /home
1058 <li>Better bug details for infinite loop warnings
1059 <li>Modified unread-fields detector to reduce false
1060 positives from reflective fields
1061 <li>build.xml "classes" target now builds all sources in one
1062 step
1063 </ul>
1064 </li>
1065 </ul>
1066
1067 <p>Changes since version 1.2.1</p>
1068 <ul>
1069 <li>New Detectors and Reports
1070 <ul>
1071 <li>SynchronizationOnSharedBuiltinConstant
1072 <ul>
1073 <li>DL_SYNCHRONIZATION_ON_SHARED_CONSTANT: The code
1074 synchronizes on a shared primitive constant, such as an
1075 interned String. Such constants are interned and shared across
1076 all other classes loaded by the JVM. Thus, this could be
1077 locking on something that other code might also be locking.
1078 This could result in very strange and hard to diagnose
1079 blocking and deadlock behavior. See <a
1080 href="http://www.javalobby.org/java/forums/t96352.html">http://www.javalobby.org/java/forums/t96352.html</a>
1081 and <a href="http://jira.codehaus.org/browse/JETTY-352">http://jira.codehaus.org/browse/JETTY-352</a>.
1082
1083 </ul>
1084 </li>
1085 <li>OverridingEqualsNotSymmetrical
1086 <ul>
1087 <li>EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC: Looks for equals
1088 methods that override equals methods in a superclass where the
1089 equivalence relationship might not be symmetrical.
1090 </ul>
1091 </li>
1092 <li>CheckTypeQualifiers
1093 <ul>
1094 <li>TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED: A value
1095 specified as carrying a type qualifier annotation is consumed
1096 in a location or locations requiring that the value not carry
1097 that annotation. More precisely, a value annotated with a type
1098 qualifier specifying when=ALWAYS is guaranteed to reach a use
1099 or uses where the same type qualifier specifies when=NEVER.</li>
1100 <li>TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED: A value
1101 specified as not carrying a type qualifier annotation is
1102 guaranteed to be consumed in a location or locations requiring
1103 that the value does carry that annotation. More precisely, a
1104 value annotated with a type qualifier specifying when=NEVER is
1105 guaranteed to reach a use or uses where the same type
1106 qualifier specifies when=ALWAYS.</li>
1107 <li>TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK: A value
1108 that might not carry a type qualifier annotation reaches a use
1109 which requires that annotation.</li>
1110 <li>TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK: A value
1111 which might carry a type qualifier annotation reaches a use
1112 which forbids values carrying that annotation.</li>
1113 </ul>
1114 </li>
1115 </ul>
1116 </li>
1117 <li>New Reports (existing detectors)
1118 <ul>
1119 <li>FindHEmismatch
1120 <ul>
1121 <li>EQ_DOESNT_OVERRIDE_EQUALS: This class extends a class
1122 that defines an equals method and adds fields, but doesn't
1123 define an equals method itself. Thus, equality on instances of
1124 this class will ignore the identity of the subclass and the
1125 added fields. Be sure this is what is intended, and that you
1126 don't need to override the equals method. Even if you don't
1127 need to override the equals method, consider overriding it
1128 anyway to document the fact that the equals method for the
1129 subclass just return the result of invoking super.equals(o).</li>
1130 </ul>
1131 </li>
1132 <li>Naming
1133 <ul>
1134 <li>NM_WRONG_PACKAGE, NM_WRONG_PACKAGE_INTENTIONAL: The
1135 method in the subclass doesn't override a similar method in a
1136 superclass because the type of a parameter doesn't exactly
1137 match the type of the corresponding parameter in the
1138 superclass.</li>
1139 <li>NM_SAME_SIMPLE_NAME_AS_SUPERCLASS: This class has a
1140 simple name that is identical to that of its superclass,
1141 except that its superclass is in a different package (e.g., <code>alpha.Foo</code>
1142 extends <code>beta.Foo</code>). This can be exceptionally
1143 confusing, create lots of situations in which you have to look
1144 at import statements to resolve references and creates many
1145 opportunities to accidently define methods that do not
1146 override methods in their superclasses.
1147 </li>
1148 <li>NM_SAME_SIMPLE_NAME_AS_INTERFACE: This class/interface
1149 has a simple name that is identical to that of an
1150 implemented/extended interface, except that the interface is
1151 in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
1152 This can be exceptionally confusing, create lots of situations
1153 in which you have to look at import statements to resolve
1154 references and creates many opportunities to accidently define
1155 methods that do not override methods in their superclasses.
1156 </li>
1157 </ul>
1158 <li>FindRefComparison
1159 <ul>
1160 <li>EC_UNRELATED_TYPES_USING_POINTER_EQUALITY: This method
1161 uses using pointer equality to compare two references that
1162 seem to be of different types. The result of this comparison
1163 will always be false at runtime.</li>
1164 </ul>
1165 </li>
1166 <li>IncompatMask
1167 <ul>
1168 <li>BIT_SIGNED_CHECK, BIT_SIGNED_CHECK_HIGH_BIT: This
1169 method compares an expression such as <tt>((event.detail
1170 &amp; SWT.SELECTED) &gt; 0)</tt>. Using bit arithmetic and then
1171 comparing with the greater than operator can lead to
1172 unexpected results (of course depending on the value of
1173 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a
1174 candidate for a bug. Even when SWT.SELECTED is not negative,
1175 it seems good practice to use '!= 0' instead of '&gt; 0'.
1176 </li>
1177 </ul>
1178 </li>
1179 <li>LazyInit
1180 <ul>
1181 <li>LI_LAZY_INIT_UPDATE_STATIC: This method contains an
1182 unsynchronized lazy initialization of a static field. After
1183 the field is set, the object stored into that location is
1184 further accessed. The setting of the field is visible to other
1185 threads as soon as it is set. If the further accesses in the
1186 method that set the field serve to initialize the object, then
1187 you have a <em>very serious</em> multithreading bug, unless
1188 something else prevents any other thread from accessing the
1189 stored object until it is fully initialized.
1190 </li>
1191 </ul>
1192 </li>
1193 <li>FindDeadLocalStores
1194 <ul>
1195 <li>DLS_DEAD_STORE_OF_CLASS_LITERAL: This instruction
1196 assigns a class literal to a variable and then never uses it.
1197 <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The
1198 behavior of this differs in Java 1.4 and in Java 5.</a> In Java
1199 1.4 and earlier, a reference to <code>Foo.class</code> would
1200 force the static initializer for <code>Foo</code> to be
1201 executed, if it has not been executed already. In Java 5 and
1202 later, it does not. See Sun's <a
1203 href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">article
1204 on Java SE compatibility</a> for more details and examples, and
1205 suggestions on how to force class initialization in Java 5.
1206 </li>
1207 </ul>
1208 </li>
1209 <li>MethodReturnCheck
1210 <ul>
1211 <li>RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: This method
1212 returns a value that is not checked. The return value should
1213 be checked since it can indication an unusual or unexpected
1214 function execution. For example, the <code>File.delete()</code>
1215 method returns false if the file could not be successfully
1216 deleted (rather than throwing an Exception). If you don't
1217 check the result, you won't notice if the method invocation
1218 signals unexpected behavior by returning an atypical return
1219 value.
1220 </li>
1221 <li>RV_EXCEPTION_NOT_THROWN: This code creates an
1222 exception (or error) object, but doesn't do anything with it.
1223 </li>
1224 </ul>
1225 </li>
1226 </ul>
1227 </li>
1228 <li>Changes to Existing Reports
1229 <ul>
1230 <li>NS_NON_SHORT_CIRCUIT: BAD_PRACTICE -&gt; STYLE</li>
1231 <li>NS_DANGEROUS_NON_SHORT_CIRCUIT: CORRECTNESS -&gt; STYLE</li>
1232 <li>RC_REF_COMPARISON: CORRECTNESS -&gt; BAD_PRACTICE</li>
1233 </ul>
1234 </li>
1235 <li>GUI Changes
1236 <ul>
1237 <li>Added importing and exporting of bug filters</li>
1238 <li>Better handling of failed analysis runs</li>
1239 <li>Added "-look" parameter for selecting look-and-feel</li>
1240 <li>Fixed incorrect package filtering</li>
1241 <li>Fixed issue where "synchronized" was not
1242 syntax-highlighted</li>
1243 </ul>
1244 </li>
1245 <li>Ant-task Changes
1246 <ul>
1247 <li>Refactored common ant-task code to AbstractFindBugsTask</li>
1248 <li>Added tasks for computeBugHistory, convertXmlToText,
1249 filterBugs, mineBugHistory, setBugDatabaseInfo</li>
1250 </ul>
1251 </li>
1252 <li>Manual
1253 <ul>
1254 <li>Updates to GUI section, including new screenshots</li>
1255 <li>Added description of rejarForAnalysis</li>
1256 <li>Revamp of data-mining section</li>
1257 </ul>
1258 </li>
1259 <li>Other Major
1260 <ul>
1261 <li>Internal restructuring for lower memory overhead</li>
1262 </ul>
1263 </li>
1264 <li>Other Minor
1265 <ul>
1266 <li>Fixed typo: was STCAL_STATIC_SIMPLE_DATA_FORMAT_INSTANCE
1267 now STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE</li>
1268 <li>-outputFile parameter became -output</li>
1269 <li>More sensitivity and specificity inLazyInit detector</li>
1270 <li>More sensitivity and specificity in Naming detector</li>
1271 <li>More sensitivity and specificity in UnreadFields
1272 detector</li>
1273 <li>More sensitivity in FindNullDeref detector</li>
1274 <li>More sensitivity in FindBadCast2 detector</li>
1275 <li>More specificity in FindReturnRef detector</li>
1276 <li>Many other tweaks and bug fixes</li>
1277 </ul>
1278 </li>
1279 </ul>
1280
1281 <p>Changes since version 1.2.0</p>
1282 <ul>
1283 <li>Bug fixes:
1284 <ul>
1285 <li><a
1286 href="http://fisheye2.cenqua.com/changelog/findbugs/?cs=8219">Fix</a>
1287 <a
1288 href="http://sourceforge.net/tracker/index.php?func=detail&aid=1726946&group_id=96405&atid=614693">bug</a>
1289 with detectors that were requested to be disabled but were
1290 enabled due to requirements of other detectors.</li>
1291 <li>Fix bugs in incremental analysis within Eclipse plugin</li>
1292 <li>Fix some analysis errors</li>
1293 <li>Fix some threading bugs in GUI2</li>
1294 <li>Report version as version when it was compiled, not when
1295 it was run</li>
1296 <li>Copy analysis time stamp when filtering or transforming
1297 analysis files.</li>
1298 </ul>
1299 <li>Enabled StaticCalendarDetector</li>
1300 <li>Reworked GUI2 to use standard FindBugs filters
1301 <ul>
1302 <li>Allow a suppression filter to be stored in a project and
1303 persisted to the XML representation of a project.</li>
1304 </ul>
1305 </li>
1306
1307 <li>Move away from old GUI2 save format (a directory
1308 containing an xml file and another file containing serialized
1309 filters).</li>
1310 <li>Support/recommend use of two new file extensions/formats:
1311 <dl>
1312 <dt>.fba - FindBugs Analysis File</dt>
1313 <dd>Exactly the same as an existing bug collection file
1314 stored in XML format, but using a distinct file extension to
1315 make it easier to figure out which xml files contain FindBugs
1316 results.</dd>
1317 <dt>.fbp - FindBugs Project File</dt>
1318 <dd>Contains just the information needed to run FindBugs and
1319 display the results (e.g., the files to be analyzed, the
1320 auxiliary class path and the location of source files)
1321 </dl>
1322 </li>
1323 </ul>
1324 <p>Changes since version 1.1.3</p>
1325 <ul>
1326 <li>Added -xml:withAbridgedMessages option to generate xml
1327 containing shorter messages. The messages will be shorted by doing
1328 things like eliding package names, and leaving off the source line
1329 from the LongMessage. These messages are appropriate if being used
1330 in a context where the non-message components of the bug
1331 annotations will be used to provide more information (e.g.,
1332 clicking on the message for a MethodAnnotation will display the
1333 source for the method).
1334 <ul>
1335 <li>FindBugsDisplayFeatures.setAbridgedMessages(true) can be
1336 used to generate abridged messages when FindBugs is being
1337 accessed directly (not via generated XML) from a GUI or IDE.</li>
1338 </ul>
1339 <li>In null pointer analysis, try to be better about always
1340 showing two locations: where it is known null and where it is
1341 dereferenced.
1342 <li>Interprocedural analysis of which methods return nonnull
1343 values
1344 <li>Use method calls to select order in which classes are
1345 analyzed, and order in which methods are analyzed, to improve
1346 interprocedural analysis results.
1347 <li>Significant improvements in memory footprint, memory
1348 allocation and CPU utilization (20-30% reduction in all three)
1349 <li>Added a project name, to provide better descriptions in
1350 the HTML output.
1351 <li>Added new bug pattern: Casting to char, or bit masking
1352 with nonnegative value, and then checking to see if the result is
1353 negative.
1354 <li>Stopped reporting transient fields of classes not marked
1355 as serializable. Transient is used by other persistence
1356 frameworks.
1357 <li>Improvements to detector for SQL injection (Thanks to <a
1358 href="http://www.clock.org/~matt">Matt Hargett</a> for his
1359 contributions
1360 <li>Changed open/save options in GUI2 to not distinguish
1361 between FindBugs projects and saved FindBugs analysis results.
1362 <li>Improvements to detection of serious non-short-circuit
1363 evaluation.
1364 <li>Updated Japanese localization (thanks to Ruimo Uno)
1365 <li>Eclipse plugin changes:
1366 <ul>
1367 <li>Created Bug User Annotations and Bug Tree Views
1368 <li>Use different icons for different bug priorities
1369 <li>Provide more information in Bug Details view
1370 </ul>
1371 </ul>
1372
1373 <p>Changes since version 1.1.2:</p>
1374 <ul>
1375 <li>Fixed broken Ant task
1376 <li>Added running ant task to smoke test
1377 <li>Added validating xml and html output to smoke test
1378 <li>Fixed some (but not all) issues with html output
1379 validation
1380 <li>Added check for x.equals(x) and x.compareTo(x)
1381 <li>Various bug fixes
1382 </ul>
1383 <p>Changes since version 1.1.1:</p>
1384 <ul>
1385 <li>Added check for infinite iterative loops</li>
1386 <li>Added check for use of incompatible types in a collection
1387 (e.g., checking to see if a Set&lt;String&gt; contains a
1388 StringBuffer).</li>
1389 <li>Added check for invocations of equals or hashCode on a
1390 URL, which, <a
1391 href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">surprising
1392 many people</a>, requires DNS resolution.
1393 </li>
1394 <li>Added check for classes that define compareTo but not
1395 equals; such classes can exhibit some anomalous behavior (e.g.,
1396 they are treated differently by PriorityQueues in Java 5 and Java
1397 6).</li>
1398 <li>Added a check for useless self operations (e.g., x &lt; x
1399 or x ^ x).</li>
1400 <li>Fixed a data race that could cause the GUI to fail on
1401 startup</li>
1402 <li>Partial internationalization of the new GUI</li>
1403 <li>Fix bug in "Redo analysis" option of new GUI</li>
1404 <li>Tuning to reduce false positives</li>
1405 <li>Fixed a bug in null pointer analysis that was generating
1406 false positive null pointer warnings on exception paths. Fixing
1407 this bug eliminates about 1/4 of the warnings on null pointer
1408 exceptions on exception paths.</li>
1409 <li>Fixed a bug in the processing of phi nodes for fields in
1410 the null pointer analysis</li>
1411 <li>Applied contributed patch that provides more quick fixes
1412 in Eclipse plugin.</li>
1413 <li>Fixed a number of bugs in the Eclipse auto update sites,
1414 and in the way date qualifiers were being used in the Eclipse
1415 plugin. You may need to manually disable your existing version of
1416 the plugin and download the 1.1.2 from the update site to get the
1417 automatic update function working correctly. The Eclipse update
1418 sites are described at <a
1419 href="http://findbugs.cs.umd.edu/eclipse/">http://findbugs.cs.umd.edu/eclipse/</a>.
1420
1421 </li>
1422 <li>Fixed progress bar in Eclipse plugin</li>
1423 <li>A number of other bug fixes.</li>
1424 </ul>
1425
1426 <p>Changes since version 1.1.0:</p>
1427 <ul>
1428 <li>less scanning of classes not on the analysis path (This
1429 was causing some performance problems.)</li>
1430 <li>no unread field warnings for fields annotated with
1431 javax.persistent or javax.ejb3</li>
1432 <li>Eclipse plugin
1433 <ul>
1434 <li>bug annotation info displayed in Bug Details tab</li>
1435 <li>.fbwarnings data file now stored in .metadata (not in
1436 the project itself)</li>
1437 </ul>
1438 </li>
1439 <li>new SE_BAD_FIELD_INNER_CLASS pattern</li>
1440 <li>updates to Japanese translation (ruimo)</li>
1441 <li>fix some internal slashed/dotted path confusion</li>
1442 <li>other minor improvements</li>
1443 </ul>
1444
1445 <p>Changes since version 1.0.0:</p>
1446
1447 <ul>
1448 <li>Overall, the change from FindBugs 1.0.0 to FindBugs 1.1.0
1449 has been a big change. We've done a lot of work in a lot of areas,
1450 and aren't even going to try to enumerate all the changes.</li>
1451 <li>We spent a lot of time reviewing the results generated by
1452 FindBugs for open source and commercial code bases, and made a
1453 number of changes, small and large, to minimize the number of
1454 false positives. Our primary focus for this was warnings reported
1455 as high and medium priority correctness warnings. Our internal
1456 evaluation is that we produce very few high/medium priority
1457 correctness warnings where the analysis is actually wrong, and
1458 that more than 75% of the high/medium priority correctness
1459 warnings correspond to real coding defects that need addressing in
1460 the source code. The remaining 25% are largely cases such as a
1461 branch or statement that if taken would lead to an error, but in
1462 fact is a dead branch or statement that can never be taken. Such
1463 coding is confusing and hard to maintain, so it should arguably be
1464 fixed, but it is unlikely to actually result in an error during
1465 execution. Thus, some might classify those warnings as false
1466 positives.</li>
1467 <li>We've substantially improved the analysis for errors that
1468 could result in null pointer dereferences. Overall, our experience
1469 has been that these changes have roughly doubled the number of
1470 null pointer errors we detect, without increasing the number of
1471 false positives (in fact, our false positive rate has gone down).
1472 The improvements are due to four factors:
1473 <ul>
1474 <li>By default, we now do some interprocedural analysis to
1475 determine methods that unconditionally dereference their
1476 parameters.</li>
1477 <li>FindBugs also comes with a model of which JDK methods
1478 unconditionally dereference their parameters.</li>
1479 <li>We do limited tracking of fields, so that we can detect
1480 null values stored in fields that lead to exceptions.</li>
1481 <li>We implemented a new analysis technique to find
1482 guaranteed dereferences. Consider the following example: <pre>public int f(Object x, boolean b) {
1483 int result = 0;
1484 if (x == null) result++;
1485 else result--;
1486 // at this point, we know x is null on a simple path
1487 if (b) {
1488 // at this point, x is only null on a complex path
1489 // we don't know if the path in which x is null and b is true is feasible
1490 return result + x.hashCode();
1491 }
1492 else {
1493 // at this point, x is only null on a complex path
1494 // we don't know if the path in which x is null and b is false is feasible
1495 return result - x.hashCode();
1496 }
1497 </pre>
1498
1499 <p>
1500 FindBugs 1.0 used forward dataflow analysis to determine
1501 whether each value is definitely null, null on a simple path,
1502 possible null on a complex path, or definitely nonnull. Thus,
1503 at the statement where
1504 <code> result </code>
1505 is decremented, we know that
1506 <code> x </code>
1507 is definitely null, and at the point before
1508 <code> if (b) </code>
1509 , we know that
1510 <code> x </code>
1511 is null on a simple path. If
1512 <code> x </code>
1513 were to be dereferenced here, we would generate a warning,
1514 because if the else branch of the
1515 <code> if (x == null) </code>
1516 were ever taken, a null pointer exception would result.
1517 </p>
1518
1519 <p>
1520 However, in both the then and else branches of the
1521 <code> if (b) </code>
1522 statement,
1523 <code> x </code>
1524 is only null on a complex path that may be infeasible. It might
1525 be that the program logic is such that if
1526 <code> x </code>
1527 is null, then
1528 <code> b </code>
1529 is never true, so generating a warning about the dereference in
1530 the then clause might be a false positive. We could try to
1531 analyze the program to determine whether it is possible for
1532 <code> x </code>
1533 to be null and
1534 <code> b </code>
1535 to be true, but that can be a hard analysis problem.
1536 </p>
1537
1538 <p>
1539 However,
1540 <code> x </code>
1541 is dereferenced in both the then <em>and</em> else branches of
1542 the
1543 <code> if (b) </code>
1544 statement. So at the point immediately before
1545 <code> if (b) </code>
1546 , we know that
1547 <code> x </code>
1548 is null on a simple path <em>and</em> that
1549 <code> x </code>
1550 is guaranteed to be dereferenced on all paths from this point
1551 forward. FindBugs 1.1 performs a backwards data flow analysis
1552 to determine the values that are guaranteed to be dereferenced,
1553 and will generate a warning in this case.
1554 </p>
1555 </li>
1556 </ul>
1557 <p>
1558 The following screen shot of our new GUI shows an example of this
1559 analysis, as well as showing off our new GUI and points out a
1560 limitation of our current plugins for Eclipse and NetBeans. The
1561 screen shot shows a null pointer bug in HelpDisplay.java. The
1562 test for
1563 <code> href!=null </code>
1564 on line 78 suggests that
1565 <code> href </code>
1566 could be null. If it is, then
1567 <code> href </code>
1568 will be dereferenced on either line 87 or on line 90, generating
1569 a NPE. Note that our analysis here also understands that passing
1570 <code> href </code>
1571 to
1572 <code> URLEncoder.encode </code>
1573 will deference it, and thus treats line 87 as a dereference, even
1574 though
1575 <code> href </code>
1576 is not actually dereferenced at that line. Within our new GUI,
1577 all of these locations are highlighted and listed in the summary
1578 panel. In the original GUI (and in HTML output) we list all of
1579 the locations, but only the primary location is highlighted by
1580 the original GUI. In the Eclipse and NetBeans plugins, only the
1581 primary location is displayed; fixing this is on our todo list
1582 (contributions welcome).
1583 </p>
1584 <p>
1585 <img src="guaranteedDereference.png" alt="">
1586
1587
1588 </p>
1589
1590 </li>
1591 <li>Preliminary support for detectors using the frameworks
1592 other than BCEL, such as the <a href="http://asm.objectweb.org/">ASM</a>
1593 bytecode framework. You may experiment with writing ASM-based
1594 detectors, but beware the API may still change (which could
1595 possibly also affect BCEL-based detectors). In general, we've
1596 started trying to move away from a deep dependence on BCEL, but
1597 that change is only partially complete. Probably best to just
1598 avoid this until we complete more work on this. This change is
1599 only visible to FindBugs plugin developers, and shouldn't be
1600 visible to FindBugs users.
1601 </li>
1602 <li>
1603 <p>Bug categories (CORRECTNESS, MT_CORRECTNESS, etc.) are no
1604 longer hard-coded, but rather defined in xml files associated
1605 with plugins, including the core plugin which defines the
1606 standard categories. Third-party plugins can define their own
1607 categories.</p>
1608 </li>
1609 <li>
1610 <p>Several bug patterns have been moved from CORRECTNESS and
1611 STYLE into a new category, BAD_PRACTICE. The English localization
1612 of STYLE has changed from "Style" to "Dodgy."</p>
1613 <p>In general, we've worked very hard to limit CORRECTNESS
1614 bugs to be real programming errors and sins of commission. We
1615 have reclassified as BAD_PRACTICE a number of bad design
1616 practices that result in overly fragile code, such as defining an
1617 equals method that doesn't accept null or defining class with a
1618 equals method that inherits hashCode from class Object.</p>
1619 <p>In general, our guidelines for deciding whether a bug
1620 should be classified as CORRECTNESS, BAD_PRACTICE or STYLE are:</p>
1621 <dl>
1622 <dt>CORRECTNESS</dt>
1623 <dd>A problem that we can recognize with high confidence and
1624 is an issue that we believe almost all developers would want to
1625 examine and address. We recommend that software teams review all
1626 high and medium priority warnings in their entire code base.</dd>
1627 <dt>BAD_PRACTICE</dt>
1628 <dd>A problem that we can recognize with high confidence and
1629 represents a clear violation of recommended and standard coding
1630 practice. We believe each software team should decide which bad
1631 practices identified by FindBugs it wants to prohibit in the
1632 team's coding standard, and take action to remedy violations of
1633 those coding standards.</dd>
1634 <dt>STYLE</dt>
1635 <dd>These are places where something strange or dodgy is
1636 going on, such as a dead store to a local variable. Typically,
1637 less than half of these represent actionable programming
1638 defects. Reviewing these warnings in any code under active
1639 development is probably a good idea, but reviewing all such
1640 warnings in your entire code base might be appropriate only in
1641 some situations. Individual or team programming styles can
1642 substantially influence the effectiveness of each of these
1643 warnings (e.g., you might have a coding practice or style in
1644 your group that confuses one of the detectors into generating a
1645 lot of STYLE warnings); you will likely want to selectively
1646 suppress or report the STYLE warnings that are effective for
1647 your group.</dd>
1648 </dl>
1649 </li>
1650 <li>Released a preliminary version of a new GUI (known
1651 internally as GUI2 -- not very creative, huh?)</li>
1652 <li>Provided standard ways to mark user designations of bug
1653 warnings (e.g., as NOT_A_BUG or SHOULD_FIX). The internal logic
1654 now records this, it is represented in the XML file, and GUI2
1655 allows the designations to be applied (along with free-form user
1656 annotations about each warning). The user designations and
1657 annotations are not yet supported by the Eclipse plugin, but we
1658 clearly want to support it in Eclipse shortly.</li>
1659 <li>Added a check for a bad comparison with a signed byte with
1660 a value not in the range -128..127. For example: <pre>boolean find200(byte b[]) {
1661 for(int i = 0; i &lt; b.length; i++) if (b[i] == 200) return i;
1662 return -1;
1663 }
1664 </pre>
1665 </li>
1666 <li>Added a checking for testing if a value is equal to
1667 Double.NaN (no value is equal to NaN, not even NaN).</li>
1668 <li>Added a check for using a class with an equals method but
1669 no hashCode method in a hashed data structure.</li>
1670 <li>Added check for uncallable method of an anonymous inner
1671 class. For example, in the following code, it is impossible to
1672 invoke the initalValue method (because the name is misspelled and
1673 as a result is doesn't override a method in ThreadLocal). <pre>private static ThreadLocal serialNum = new ThreadLocal() {
1674 protected synchronized Object initalValue() {
1675 return new Integer(nextSerialNum++);
1676 }
1677 };
1678 </pre>
1679 </li>
1680 <li>Added check for a dead local store caused by a switch
1681 statement fall through</li>
1682 <li>Added check for computing the absolute value of a random
1683 32 bit integer or of a hashcode. This is broken because <code>
1684 Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE </code> , and thus
1685 result of calling Math.abs, which is expected to be nonnegative,
1686 will in fact be negative one time out of 2 <sup> 32 </sup> , which
1687 will invariably be the time your boss is demoing the software to
1688 your customers.
1689
1690 </li>
1691 <li>More careful resolution of inherited methods and fields.
1692 Some of the shortcuts we were taking in FindBugs 1.0.0 were
1693 leading to inaccurate results, and it was fairly easy to address
1694 this by making the analysis more accurate.</li>
1695 <li>Overall, analysis times are about 1.6 times longer in
1696 FindBugs 1.1.0 than in FindBugs 1.0.0. This is because we have
1697 enabled substantial additional analysis at the default effort
1698 level (the actual analysis engine is significantly faster than in
1699 FindBugs 1.0). On a recent AMD Athlon processor, analyzing
1700 JDK1.6.0 (about 1 million lines of code) requires about 15 minutes
1701 of wall clock time.</li>
1702 <li>Provided class and script (printClass) to print classfile
1703 in the human readable format produced by BCEL</li>
1704 <li>Provided -findSource option to setBugDatabaseInfo</li>
1705 </ul>
1706
1707
1708 <p>Changes since version 0.9.7:</p>
1709
1710 <ul>
1711 <li>fix ObjectTypeFactory bug that was suppressing some bugs</li>
1712 <li>opcode stack may determine definite zeros on some paths</li>
1713 <li>opcode stack can track some constant string concatenations
1714 (dbrosius)</li>
1715 <li>default effort performs iterative opcode analysis (but min
1716 effort does not)</li>
1717 <li>default heap size upped to 384m</li>
1718 <li>schema for XML output available: bugcollection.xsd</li>
1719 <li>fixed some internal confusion between dotted and slashed
1720 class names</li>
1721 <li>New detectors
1722 <ul>
1723 <li>CheckImmutableAnnotation.java: checks JCIP annotations</li>
1724 </ul>
1725 </li>
1726 <li>Updated detectors
1727 <ul>
1728 <li>BadRegEx.java: understands Pattern.LITERAL, warns about
1729 "."</li>
1730 <li>FindUnreleasedLock.java: fewer false positives</li>
1731 <li>DumbMethods.java: check for vacuous comparisons to
1732 MAX_INTEGER or MIN_INTEGER, fix bugs detecting
1733 DM_NEXTINT_VIA_NEXTDOUBLE</li>
1734 <li>FindPuzzlers.java: detect <tt>n%2==1</tt>, detect
1735 toString() on array types
1736 </li>
1737 <li>FindInconsistentSync2.java: detects IS_FIELD_NOT_GUARDED
1738 </li>
1739 <li>MethodReturnCheck.java: add check for discarded newly
1740 constructed values, increase priority of some ignored
1741 constructed exceptions, better handling of bytecode compiled by
1742 Eclipse</li>
1743 <li>FindEmptySynchronizedBlock.java: better handling of
1744 bytecode compiled by Eclipse</li>
1745 <li>DoInsideDoPrivileged.java: warn if call to setAccessible
1746 isn't in doPriviledged, don't report private methods</li>
1747 <li>LoadOfKnownNullValue.java: fix bug that was reporting
1748 false positives on <code> finally </code> blocks
1749 </li>
1750 <li>CheckReturnAnnotationDatabase.java: better checks for
1751 unstarted threads</li>
1752 <li>ConfusionBetweenInheritedAndOuterMethod.java: fewer
1753 false positives, fixed a package-handling bug</li>
1754 <li>BadResultSetAccess.java: separate bug pattern for
1755 PreparedStatements, <code> BRZA </code> category folded into <code>
1756 SQL </code> category
1757 </li>
1758 <li>FindDeadLocalStores.java, FindBadCast2.java,
1759 DumbMethods.java, RuntimeExceptionCapture.java: coalesce similar
1760 bugs within a method into a single bug instance with multiple
1761 source lines</li>
1762 </ul>
1763 </li>
1764 <li>Eclipse plugin
1765 <ul>
1766 <li>plugin ID changed from <tt>de.tobject.findbugs</tt> to <tt>edu.umd.cs.findbugs.plugin.eclipse</tt>
1767 </li>
1768 <li>support for findbugs eclipse auto-update site</li>
1769 </ul>
1770 </li>
1771 <li>Updated test case files
1772 <ul>
1773 <li>BadRegEx.java</li>
1774 <li>JSR166.java</li>
1775 <li>ConcurrentModificationBug.java</li>
1776 <li>DeadStore.java</li>
1777 <li>InstanceOf.java</li>
1778 <li>LoadKnownNull.java</li>
1779 <li>NeedsToCheckReturnValue.java</li>
1780 <li>BadResultSetAccessTest.java</li>
1781 <li>DeadStore.java</li>
1782 <li>TestNonNull2.java</li>
1783 <li>TestImmutable.java</li>
1784 <li>TestGuardedBy.java</li>
1785 <li>BadRandomInt.java</li>
1786 <li>six test cases added to new <code> TigerTraps </code>
1787 directory
1788 </li>
1789 </ul>
1790 </li>
1791 <li>fix bug that was generating duplicate uids</li>
1792 <li>fix bug with <code> -onlyAnalyze some.package.* </code> on
1793 jdk1.4
1794 </li>
1795 <li>fix regression bug in
1796 DismantleByteCode.getRefConstantOperand()</li>
1797 <li>fix some minor bugs with the Swing GUI</li>
1798 <li>reordered some bugInstances so that source line
1799 annotations come last</li>
1800 <li>removed references to unused java system properties</li>
1801 <li>French translation updates (David Cotton)</li>
1802 <li>Japanese translation updates (Hanai Shisei)</li>
1803 <li>content cleanup for findbugs.xml and messages.xml</li>
1804 <li>references to cvs hostname updated to
1805 findbugs.cvs.sourceforge.net</li>
1806 <li>documented xdoc output options, new
1807 mineBugHistory/computeBugHistory options</li>
1808 </ul>
1809
1810 <p>Changes since version 0.9.6:</p>
1811
1812 <ul>
1813 <li>performance improvements</li>
1814 <li>ObjectType instances are cached to reduce memory footprint
1815 </li>
1816 <li>for performance and memory reasons stateless detectors are
1817 no longer cloned, must clear their own state between .class files
1818 </li>
1819 <li>fixed bug in bytecode-set lookup for methods (was causing
1820 bad results for IS2, perhaps others)</li>
1821 <li>fix some OpcodeStack bugs with integer and long
1822 operations, perform iterative analysis when effort is <tt>max</tt>
1823 </li>
1824 <li>HTML output includes LongMessage text again (regression in
1825 0.95 - 0.96)</li>
1826 <li>New detectors
1827 <ul>
1828 <li>CalledMethods.java: builds a list of invoked methods for
1829 other detectors to consult (non-reporting)</li>
1830 <li>UncallableMethodOfAnonymousClass.java: detect anonymous
1831 inner classes that define methods that are probably intended to
1832 but do not override methods in a superclass.</li>
1833 </ul>
1834 </li>
1835 <li>Updated detectors
1836 <ul>
1837 <li>FindFieldSelfAssignment.java: recognize separate fields
1838 with the same name (one from superclass)</li>
1839 <li>FindLocalSelfAssignment2.java: handles backward branches
1840 better (Dave Brosius)</li>
1841 <li>FindBadCast2.java: BC_NULL_INSTANCEOF changed to
1842 NP_NULL_INSTANCEOF</li>
1843 <li>FindPuzzlers.java: eliminate false positive on setDate()
1844 (Dave Brosius)</li>
1845 </ul>
1846 </li>
1847 <li>Eclipse plugin
1848 <ul>
1849 <li>fix serious threading bug</li>
1850 <li>preferences for Filters and effort (Peter Hendriks)</li>
1851 <li>French localization (David Cotton)</li>
1852 <li>fix bug when reporting inner classes (Peter Friese)</li>
1853 </ul>
1854 </li>
1855 <li>Updated test case files
1856 <ul>
1857 <li>Mwn.java (Carl Burke/Dave Brosius)</li>
1858 <li>DumbMethodInvocations.java (Anto paul/Dave Brosius)</li>
1859 <!--sic-->
1860 </ul>
1861 </li>
1862 <li>XML output includes garbage collection duration</li>
1863 <li>French messages updated (David Cotton)</li>
1864 <li>Swing GUI shows file name after Load Bugs command</li>
1865 <li>Ant task to launch the findbugs frame (Mark McKay)</li>
1866 <li>miscellaneous code cleanup</li>
1867 </ul>
1868
1869 <p>Changes since version 0.9.5:</p>
1870
1871 <ul>
1872 <li>Updated detectors
1873 <ul>
1874 <li>FindNullDeref.java: respect NonNull and CheckForNull
1875 field annotations</li>
1876 <li>SerializableIdiom.java: detect non-private readObject
1877 and writeObject methods</li>
1878 <li>FindRefComparison.java: smarter array comparison
1879 detection</li>
1880 <li>IsNullValueAnalysis.java: detect <tt>null
1881 instanceof</tt>
1882 </li>
1883 <li>FindLocalSelfAssignment2.java: suppress some false
1884 positives (Dave Brosius)</li>
1885 <li>FindUnreleasedLock.java: don't waste time processing
1886 classes that don't refer to java.util.concurrent.locks</li>
1887 <li>MutableStaticFields.java: report the source line (Dave
1888 Brosius)</li>
1889 <li>SwitchFallthrough.java: better handling of System.exit()
1890 (Dave Brosius)</li>
1891 <li>MultithreadedInstanceAccess.java: better handling of
1892 Servlet.init() (Dave Brosius)</li>
1893 <li>ConfusionBetweenInheritedAndOuterMethod.java: now
1894 enabled</li>
1895 </ul>
1896 </li>
1897 <li>Eclipse plugin
1898 <ul>
1899 <li>background processing (Peter Friese)</li>
1900 <li>internationalization, Japanese localization (Takashi
1901 Okamoto)</li>
1902 </ul>
1903 </li>
1904 <li>findbugs <tt>-onlyAnalyze</tt> option now works on windows
1905 platforms
1906 </li>
1907 <li>mineBugHistory <tt>-noTabs</tt> option for better
1908 alignment of output columns
1909 </li>
1910 <li>filterBugs <tt>-fixed</tt> option (also: will now
1911 recognize the most recent version string)
1912 </li>
1913 <li>XML output includes running time and memory usage data</li>
1914 <li>miscellaneous minor corrections to the manual</li>
1915 <li>better bytecode analysis of the <tt>iinc</tt> instruction
1916 </li>
1917 <li>fix bug in null pointer analysis</li>
1918 <li>improved catch block heuristics</li>
1919 <li>some type analysis tweaks</li>
1920 <li>Bug priority changes
1921 <ul>
1922 <li>DumbMethodInvocations.java: decrease priority of
1923 hard-coded <tt>/tmp</tt> filenames
1924 </li>
1925 <li>ComparatorIdiom.java: decrease priority of
1926 non-serializable anonymous comparators</li>
1927 <li>FindSqlInjection.java: decrease priority of appending a
1928 constant or a static</li>
1929 </ul>
1930 </li>
1931 <li>Updated bug explanations
1932 <ul>
1933 <li>NM_VERY_CONFUSING (Dave Brosius)</li>
1934 </ul>
1935 </li>
1936 <li>Updated test case files
1937 <ul>
1938 <li>BadStoreOfNonSerializableObject.java</li>
1939 <li>BadRandomInt.java</li>
1940 <li>TestFieldAnnotations.java</li>
1941 <li>UseInitCause.java</li>
1942 <li>SqlInjection.java</li>
1943 <li>ArrayEquality.java</li>
1944 <li>BadIntegerOperations.java</li>
1945 <li>Pilhuhn.java</li>
1946 <li>InstanceOf.java</li>
1947 <li>SwitchFallthrough.java (Dave Brosius)</li>
1948 </ul>
1949 </li>
1950 <li>fix URL decoding bug when running under Java Web Start
1951 (Dave Brosius)</li>
1952 <li>distribution includes <tt>project.xml</tt> file for
1953 NetBeans
1954 </li>
1955 </ul>
1956
1957 <p>Changes since version 0.9.4:</p>
1958 <ul>
1959 <li>New detectors
1960 <ul>
1961 <li>VarArgsProblems.java</li>
1962 <li>FindSqlInjection.java: now enabled</li>
1963 <li>ComparatorIdiom.java: comparators usually implement
1964 serializable</li>
1965 <li>Naming.java: detect methods not overridden due to
1966 eponymously typed args from different packages</li>
1967 </ul>
1968 </li>
1969 <li>Updated detectors
1970 <ul>
1971 <li>SwitchFallthrough.java: surpress some false positives</li>
1972 <li>DuplicateBranches.java: surpress some false positives</li>
1973 <li>IteratorIdioms.java: surpress some false positives</li>
1974 <li>FindHEmismatch.java: surpress some false positives</li>
1975 <li>QuestionableBooleanAssignment.java: finds more cases of
1976 <tt>if (b=true)</tt> ilk
1977 </li>
1978 <li>DumbMethods.java: detect int remainder by 1, delayed gc
1979 errors</li>
1980 <li>SerializableIdiom.java: detect store of nonserializable
1981 object into field of serializable class</li>
1982 <li>FindNullDeref.java: fix potential exception</li>
1983 <li>IsNullValue.java: fix potential exception</li>
1984 <li>MultithreadedInstanceAccess.java: fix potential
1985 exception</li>
1986 <li>PreferZeroLengthArrays.java: flag the method, not the
1987 line</li>
1988 </ul>
1989 </li>
1990 <li>Remove some inadvertent dependencies on JDK 1.5</li>
1991 <li>Sort order should be more consistent</li>
1992 <li>XML output changes
1993 <ul>
1994 <li>Option to sort XML bug output</li>
1995 <li>Now contains instance IDs</li>
1996 <li>uid no longer missing (was causing problems with fancy
1997 HTML output)</li>
1998 <li>Typo fixed</li>
1999 </ul>
2000 </li>
2001 <li>Internal changes to track source files, <tt>-sourceInfo</tt>
2002 option
2003 </li>
2004 <li>Bug matching: first try exact bug pattern matching, option
2005 to compare priorities, option to disable package moves</li>
2006 <li>Architecture documentation in <tt>design/architecture</tt>
2007 </li>
2008 <li>Test cases move into their own CVS project</li>
2009 <li>Don't report warnings that occur outside the analyzed
2010 classes</li>
2011 <li>Fixes to the build.xml files</li>
2012 <li>Better handling of @CheckReturnValue and @CheckForNull
2013 annotations (also, some additional methods searched for check
2014 return value and check for null)</li>
2015 <li>Fixed some stream-closing bugs (one by <tt>z-fb-user</tt>/Dave
2016 Brosius)
2017 </li>
2018 <li>Bug priority changes
2019 <ul>
2020 <li>increase priority of ignoring return value of
2021 java.sql.Connection methods</li>
2022 <li>increase priority of comparing classes like Integer
2023 using <tt>==</tt>
2024 </li>
2025 <li>decrease priority of IT_NO_SUCH_ELEMENT if we see any
2026 call to <tt>next()</tt>
2027 </li>
2028 <li>tweak priority of NM_METHOD_CONSTRUCTOR_CONFUSION</li>
2029 <li>decrease priority of RV_RETURN_VALUE_IGNORED for an
2030 inherited annotation that doesn't return same type as class</li>
2031 </ul>
2032 </li>
2033 <li>Updated bug explanations
2034 <ul>
2035 <li>RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE</li>
2036 <li>DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED</li>
2037 <li>IMA_INEFFICIENT_MEMBER_ACCESS (Dave Brosius)</li>
2038 <li>some Japanese improvements to messages_ja.xml ( <tt>ruimo</tt>)
2039 </li>
2040 <li>some German improvements to findbugs_de.properties (Dave
2041 Brosius, <tt>dvholten</tt>)
2042 </li>
2043 </ul>
2044 </li>
2045 <li>Updated test case files
2046 <ul>
2047 <li>BadIntegerOperations.java</li>
2048 <li>SecondKaboom.java</li>
2049 <li>OpenDatabase.java (Dave Brosius)</li>
2050 <li>FindOpenStream.java (Dave Brosius)</li>
2051 <li>BadRandomInt.java</li>
2052 </ul>
2053 </li>
2054 <li>Source-lines info maintained for methods (handy for
2055 abstract and native methods)</li>
2056 <li>Remove surrounding opcodes from source line annotations</li>
2057 <li>Better error when can't read file</li>
2058 <li>Swing GUI: removed console pane from FindBugsFrame, fix
2059 missing classes bug</li>
2060 <li>Fixes to OpcodeStack.java</li>
2061 <li>Detectors may attach a custom value to an OpcodeStack.Item
2062 (Dave Brosius)</li>
2063 <li>Filter.java: ability to add text messages to XML output,
2064 fix bug with <tt>-withMessages</tt>
2065 </li>
2066 <li>SourceInfoMap supports ranges of source lines</li>
2067 <li>Ant task supports the <tt>timestampNow</tt> attribute
2068 </li>
2069 </ul>
2070
2071 <p>Changes since version 0.9.3:</p>
2072 <ul>
2073 <li>Substantial rework of datamining code</li>
2074 <li>Removed bogus warnings about await on things other than
2075 Condition not being in a loop</li>
2076 <li>Fixed bug in OpcodeStack handling of dup2 of long/double
2077 values</li>
2078 <li>Don't report array types as missing classes</li>
2079 <li>Adjustment of some warnings on ignored return values</li>
2080 <li>Added thread safety annotations from Java Concurrency in
2081 Practice (no detectors written for these yet)</li>
2082 <li>Added annotation for methods that, if overridden, should
2083 be invoked by overriding methods via a call to super</li>
2084 <li>Updated -html:fancy.xsl (Etienne Giraudy)</li>
2085 </ul>
2086
2087 <p>Note: there was no version 0.9.2</p>
2088
2089 <p>Changes since version 0.9.1:</p>
2090 <ul>
2091 <!-- New detectors -->
2092 <li>Embellish USM to find abstract methods that implement an
2093 interface method (Dave Brosius)</li>
2094 <li>New detector to find stores of literal booleans inside if
2095 or while expressions (Dave Brosius)</li>
2096 <li>New style detector to find final classes that declare
2097 protected fields (Dave Brosius)</li>
2098 <li>New detector to find subclass methods that simply forward,
2099 verbatim, to the super class (Dave Brosius)</li>
2100 <li>Detector to find instances where code is attempting to
2101 write an object out via an implementation of DataOutput, but the
2102 object is not guaranteed to be Serializable (Jon Christiansen,
2103 Bill Pugh)</li>
2104
2105 <!-- Feature enhancements -->
2106 <li>Large (35%) analysis speedup (Bill Pugh)</li>
2107 <li>Add line numbers to Swing GUI code panel (Dave Brosius)</li>
2108 <li>Added effort options to Swing GUI (Dave Brosius)</li>
2109 <li>Add ability to specify bugs file to open from command line
2110 for GUI version, through -loadbugs (Phillip Martin)</li>
2111 <li>New stylesheet for generating HTML: use option <tt>-html:plain.xsl</tt>
2112 (Chris Nappin)
2113 </li>
2114 <li>New stylesheet for generating HTML: use option <tt>-html:fancy.xsl</tt>
2115 (Etienne Giraudy)
2116 </li>
2117 <li>Updated Japanese bug message translations (Shisei Hanai)</li>
2118
2119 <!-- Bug fixes -->
2120 <li>XHTML compliance fixes for bug details (Etienne Giraudy)</li>
2121 <li>Various detector fixes (Shisei Hanai)</li>
2122 <li>Fixed bugs in the project preferences dialog int the
2123 Eclipse plugin (Takashi Okamoto, Thomas Einwaller)</li>
2124 <li>Lowered priority of analysis thread in Swing GUI (David
2125 Hovemeyer, suggested by Shisei Hanai and Jeffrey W. Badorek)</li>
2126 <li>Fixed EclipsePlugin to correctly pick up auxclasspath
2127 entries (Jon Christiansen)</li>
2128 </ul>
2129
2130 <p>Changes since version 0.9.0:</p>
2131 <ul>
2132 <li>Fixed dependence on JRE 1.5: all features should work on
2133 JRE 1.4 again</li>
2134 <li>Fixed -effort command line option handling for Swing GUI</li>
2135 <li>Fixed conserveSpace and workHard attributes int Ant task</li>
2136 <li>Added support for effort attribute in Ant task</li>
2137 </ul>
2138
2139 <p>Changes since version 0.8.8:</p>
2140 <ul>
2141 <!-- New detectors and bug patterns -->
2142 <li>XMLFactoryBypass detector to find direct allocation of xml
2143 class implementations (Dave Brosius)</li>
2144 <li>InefficientMemberAccess detector to find accesses to
2145 owning class private members (Dave Brosius)</li>
2146 <li>DuplicateBranches detector checks switch statements too
2147 (Dave Brosius)</li>
2148
2149 <!-- Feature enhancements -->
2150 <li>FindBugs available from findbugs.sourceforge.net as Java
2151 Web Start application (Dave Brosius)</li>
2152 <li>Updated Japanese bug message translations (Shisei Hanai)</li>
2153 <li>Improved bug detail message for covariant equals() (Shisei
2154 Hanai)</li>
2155 <li>Modeling of instanceof checks is now enabled by default,
2156 making the bad cast detector much more useful (Bill Pugh, David
2157 Hovemeyer)</li>
2158 <li>Support for detector ordering constraints in plugin
2159 descriptor (David Hovemeyer)</li>
2160 <li>Simpler option to control analysis effort: -effort: <i>value</i>,
2161 where <i>value</i> is one of <code> min </code> , <code>
2162 default </code> , or <code> max </code> (David Hovemeyer)
2163 </li>
2164 <li>Using -effort:max, FindNullDeref checks for null arguments
2165 passed to methods which dereference them unconditionally (David
2166 Hovemeyer)</li>
2167 <li>FindNullDeref checks @Null and @NonNull annotations for
2168 parameters and return values (David Hovemeyer)</li>
2169
2170 <!-- Bug fixes -->
2171 </ul>
2172
2173 <p>Changes since version 0.8.7:</p>
2174
2175 <ul>
2176 <!-- New detectors and bug patterns -->
2177 <li>New detector to find duplicate code in if/else statements
2178 (Dave Brosius)</li>
2179 <li>Look for calls to wait() on Condition objects (David
2180 Hovemeyer)</li>
2181 <li>Look for java.util.concurrent.Lock objects not released on
2182 every path out of method (David Hovemeyer)</li>
2183 <li>Look for calls to Thread.sleep() with a lock held (David
2184 Hovemeyer)</li>
2185 <li>More accurate detection of impossible casts (Bill Pugh,
2186 David Hovemeyer)</li>
2187
2188 <!-- Feature enhancements -->
2189 <li>Saved XML now contains project statistics (Jay Dunning)</li>
2190 <li>Filter files can select by bug pattern type and warning
2191 priority (David Hovemeyer)</li>
2192
2193 <!-- Bug fixes -->
2194 <li>Restored some files inadvertently omitted from previous
2195 release (Rohan Lloyd, David Hovemeyer)</li>
2196 <li>Make sure detectors requiring JDK 1.5 runtime classes are
2197 only executed if those classes are available (David Hovemeyer)</li>
2198 <li>Don't display analysis error dialog unless there is really
2199 an error (David Hovemeyer)</li>
2200 <li>Updated and expanded French translations of bug patterns
2201 and Swing GUI (Olivier Parent)</li>
2202 <li>Fixed invalid character encoding in German Swing GUI
2203 translation (Olivier Parent)</li>
2204 <li>Fix locale used for date format in project stats (K.
2205 Hashimoto)</li>
2206 <li>Fixed LongDescription elements in xml:withMessages output
2207 format (K. Hashimoto)</li>
2208 </ul>
2209
2210 <p>Changes since version 0.8.6:</p>
2211
2212 <ul>
2213 <!-- new detectors -->
2214 <li>Extend Naming detector to look for classes that are named
2215 XXXException but that are not Exceptions (Dave Brosius)</li>
2216 <li>New detector to find classes that expose semaphores in the
2217 public implementation through the 'this' reference. (Dave Brosius)
2218 </li>
2219 <li>New Style detector to find Struts Action/Servlet derived
2220 classes that reference instance member variable not in
2221 synchronized blocks. (Dave Brosius)</li>
2222 <li>New Style detector to find classes that declare
2223 implementation of interfaces that are already implemented by super
2224 classes (Dave Brosius)</li>
2225 <li>New Style detector to find circular dependencies between
2226 classes (Dave Brosius)</li>
2227 <li>New Style detector to find unnecessary math on constants
2228 (Dave Brosius)</li>
2229 <li>New detector to find equality comparisons using floating
2230 point math (Jay Dunning)</li>
2231 <li>New faster detector to find local self assignments (Bill
2232 Pugh)</li>
2233 <li>New detector to find infinite recursive loops (Bill Pugh)
2234 </li>
2235 <li>New detector to find for loops with an incorrect increment
2236 (Bill Pugh)</li>
2237 <li>New detector to find suspicious uses of
2238 BufferedReader.readLine() and String.indexOf() (Bill Pugh)</li>
2239 <li>New detector to find suspicious integer to double casts
2240 (David Hovemeyer, Bill Pugh)</li>
2241 <li>New detector to find invalid regular expression patterns
2242 (Bill Pugh)</li>
2243 <li>New detector to find Bloch/Gafter Java puzzlers (Bill
2244 Pugh)</li>
2245
2246 <!-- feature enhancements -->
2247 <li>New system property to suppress reporting of DLS based on
2248 local variable name (Glenn Boysko)</li>
2249 <li>Enhancements to configuration dialog in Eclipse plugin,
2250 allow for saving enabled detectors in Eclipse projects (Phil
2251 Crosby)</li>
2252 <li>Sortable columns in detector dialog (Dave Brosius)</li>
2253 <li>New tab in gui for showing bugs grouped by category (Dave
2254 Brosius)</li>
2255 <li>Improved German translation of Swing GUI (Thomas Kuehne)</li>
2256 <li>Improved source file reporting in Emacs output format (Len
2257 Trigg)</li>
2258 <li>Improvements to redundant null comparison detector (Bill
2259 Pugh)</li>
2260 <li>Localization of run analysis and analysis error dialogs in
2261 Swing GUI (K. Hashimoto)</li>
2262
2263 <!-- Bug fixes -->
2264 <li>Don't scan equals methods in FindHEMismatch if code is
2265 native (Greg Bentz)</li>
2266 <li>French translation fixes (David Cotton)</li>
2267 <li>Internationalization report fixes (K. Hashimoto)</li>
2268 <li>Japanese translations updates (SHISEI Hanai)</li>
2269 </ul>
2270
2271 <p>Changes since version 0.8.5:</p>
2272 <ul>
2273 <!-- new detectors -->
2274 <li>New detector to find catch blocks that may inadvertently
2275 catch runtime exceptions (Brian Goetz)</li>
2276 <li>New detector to find objects that are instantiated based
2277 on classes that only have static methods and fields, using the
2278 synthesized constructor (Dave Brosius)</li>
2279 <li>New detector to find calls to Thread.interrupted() in a
2280 non static context, and especially with non currentThread()
2281 threads (Dave Brosius)</li>
2282 <li>New detector to find calls to equals() methods that use
2283 Object's version. (Dave Brosius)</li>
2284 <li>New detector to find Applets that call methods in the
2285 constructor refering to the AppletStub (Dave Brosius)</li>
2286 <li>New detector to find some cases of infinite recursion
2287 (Bill Pugh)</li>
2288 <li>New detector to find dead stores to local variables (David
2289 Hovemeyer, Bill Pugh)</li>
2290 <li>Extend Dumb Method detector for toUpperCase(),
2291 toLowerCase() without a locale, new Integer(1).toString(), new
2292 XXX().getClass(), and new Thread() without a run implementation
2293 (Dave Brosius) <!-- feature enhancements -->
2294 </li>
2295 <li>Ant task supports "errorProperty" attribute, which sets an
2296 Ant property to "true" if an error occurs running FindBugs
2297 (Michael Tamm)</li>
2298 <li>Eclipse plugin allows filtering of warnings by bug
2299 category, priority (David Hovemeyer)</li>
2300 <li>Swing GUI allows filtering of warnings by bug category
2301 (David Hovemeyer)</li>
2302 <li>Ability to annotate methods using Java 1.5 annotations
2303 that suppress FindBugs warnings (Bill Pugh)</li>
2304 <li>New -adjustExperimental for lowering priority of
2305 BugPatterns that are experimental (Dave Brosius)</li>
2306 <li>Allow for command line options 'files' using the @ symbol
2307 (David Hovemeyer)</li>
2308 <li>New -adjustPriority command line option to for adjusting
2309 bug priorites (David Hovemeyer)</li>
2310 <li>Added an Edit menu (cut/copy/paste) to Swing GUI (Dave
2311 Brosius)</li>
2312 <li>French translation supplied (David Cotton) <!-- Bug fixes -->
2313 </li>
2314 </ul>
2315
2316 <p>Changes since version 0.8.4:</p>
2317 <ul>
2318 <!-- new detectors -->
2319 <li>New detector for volatile references to arrays (Bill Pugh)
2320 </li>
2321 <li>New detector to find instanceof usage where inheritance
2322 can be determined statically (Dave Brosius)</li>
2323 <li>New detector to find ResultSet.getXXX updateXXX calls
2324 using index 0 (Dave Brosius)</li>
2325 <li>New detector to find empty zip or jar entries (Bill Pugh)
2326
2327 <!-- feature enhancements -->
2328 </li>
2329 <li>HTML output generation using built-in XSLT stylesheet or
2330 user-defined stylesheet (David Hovemeyer)</li>
2331 <li>Allow URLs to be specified to analyze zip/jar files, local
2332 directories, and single classfiles (David Hovemeyer)</li>
2333 <li>New command line option -onlyAnalyze restricts analysis to
2334 selected classes and packages without reducing accuracy (David
2335 Hovemeyer)</li>
2336 <li>Allow Swing GUI to show source code in jar files on
2337 Windows systems (Dave Brosius) <!-- Bug fixes -->
2338 </li>
2339 <li>Fix the Switch Fall Thru detector (Dave Brosius, David
2340 Hovemeyer, Bill Pugh)</li>
2341 <li>MacOS GUI fixes (Rohan Lloyd)</li>
2342 <li>Fix false positive in BOA in case where method is
2343 correctly and 'incorrectly' overridden (Dave Brosius)</li>
2344 <li>Fixed memory blowup when analyzing methods which access a
2345 large number of fields (David Hovemeyer)</li>
2346 </ul>
2347
2348 <p>Changes since version 0.8.3:</p>
2349 <ul>
2350 <li>Initial and preliminary localization of the Swing
2351 GUI.&nbsp; Translations by:
2352 <ul>
2353 <li>German - Peter D. Stout, Holger Stenzhorn</li>
2354 <li>Finnish - Juha Knuutila</li>
2355 <li>Estonian - Tanel Lebedev</li>
2356 <li>Japanese - Hanai Shisei</li>
2357 </ul>
2358 </li>
2359 <li>Eliminated debug print statements inadvertently left
2360 enabled</li>
2361 <li>Reverted some changes in the open stream detector: this
2362 should fix some false positives that were introduced in the
2363 previous release</li>
2364 <li>Fixed a couple missing class reports</li>
2365 </ul>
2366
2367 <p>Changes since version 0.8.2:</p>
2368 <ul>
2369
2370 <!-- New detectors -->
2371 <li>New detector to find improperly overridden GUI Adapter
2372 classes (Dave Brosius)</li>
2373 <li>New detector to find improperly setup JUnit TestCases
2374 (Dave Brosius)</li>
2375 <li>New detector to find variables that mask class level
2376 fields (Dave Brosius)</li>
2377 <li>New detector to find comparisons of values computed with
2378 bitwise operators that always yield the same result (Tom Truscott)
2379 </li>
2380 <li>New detector to find unsafe getClass().getResource() calls
2381 (Bill Pugh)</li>
2382 <li>New detector to find GUI changes not in GUI thread but in
2383 static main (Bill Pugh)</li>
2384 <li>New detector to find calls to Collection.toArray() with
2385 zero-length array argument; it is more efficient to pass an array
2386 the size of the collection, which can be populated and returned as
2387 the result (Dave Brosius) <!-- Analysis improvements -->
2388 </li>
2389 <li>Better suppression of false warnings in various detectors
2390 (Bill Pugh, David Hovemeyer)</li>
2391 <li>Enhancement to ReadReturnShouldBeChecked detector for
2392 skip() (Dave Brosius)</li>
2393 <li>Enhancement to DumbMethods detector (Dave Brosius)</li>
2394 <li>Open stream detector does not report wrappers of streams
2395 passed as method parameters (David Hovemeyer) <!-- Feature enhancements -->
2396 </li>
2397 <li>Cancel confirmation dialog in Swing GUI (Pete Angstadt)</li>
2398 <li>Better relative path saving in Project file (Dave Brosius)
2399 </li>
2400 <li>Detector Priority in GUI is now saved in prefs file (Dave
2401 Brosius)</li>
2402 <li>Controls in GUI to reorder source and classpath entries,
2403 and ability to flip between Project details and bugs pages (Dave
2404 Brosius)</li>
2405 <li>In Swing GUI, analysis error dialog supports "Select All"
2406 and "Copy" operations for easy generation of error reports (Dave
2407 Brosius)</li>
2408 <li>Complete translation of bug descriptions and messages into
2409 Japanese (Hanai Shisei) <!-- Bug fixes -->
2410 </li>
2411 <li>Fixed bug in DroppedException detector (Dave Brosius) <!-- Development stuff -->
2412 </li>
2413 <li>The source distribution defaults to using JDK 1.5 javac to
2414 compile, but support for compiling with JSR-14 prototype is still
2415 supported</li>
2416 </ul>
2417
2418 <p>Changes since version 0.8.1:</p>
2419 <ul>
2420 <li>Fixed a critical ClassCastException bug (triggered if the
2421 -workHard option was used, and an exception type was merged with
2422 an array type during type inference)</li>
2423 </ul>
2424
2425 <p>Changes since version 0.8.0:</p>
2426 <ul>
2427 <li>Disabled SwitchFallthrough detector to work around
2428 NullPointerExceptions</li>
2429 <li>Added some additional false positive suppression
2430 heuristics</li>
2431 </ul>
2432
2433 <p>Also, two contributors to the 0.8.0 release were
2434 inadvertently left out of the credits:</p>
2435 <ul>
2436 <li>Pete Angstadt fixed several problems in the Swing GUI</li>
2437 <li>Francis Lalonde provided a task resource file for the
2438 FindBugs Ant task</li>
2439 </ul>
2440
2441 <p>Changes since version 0.7.4:</p>
2442 <ul>
2443 <li>New detector to look for uses of "+" operator to
2444 concatenate String objects in a loop (Dave Brosius)</li>
2445 <li>Reference comparison detector looks for places where the
2446 argument passed to the equals(Object) method isn't the same type
2447 as the receiver object</li>
2448 <li>Better suppression of false warnings in many detectors</li>
2449 <li>Many improvements to Eclipse plugin (Andrey Loskutov,
2450 Peter Friese)</li>
2451 <li>Fixed problem with building Eclipse plugin on Windows
2452 (Thomas Klaeger)</li>
2453 <li>Open stream detector looks for unclosed PreparedStatement
2454 objects (Thomas Klaeger, Rohan Lloyd)</li>
2455 <li>Fix for open stream detector: it wasn't detecting close()
2456 methods called through an invokeinterface instruction (Thomas
2457 Klaeger)</li>
2458 <li>Refactoring of visitor classes to enforce use of accessors
2459 for visited class features (Brian Goetz)</li>
2460 </ul>
2461
2462 <p>Changes since version 0.7.3:</p>
2463 <ul>
2464 <li>Experimental modification of open stream detector to look
2465 for non-escaping JDBC resources (connections and statements) that
2466 aren't closed on all paths out of method</li>
2467 <li>Eclipse plugin fixed so it compiles and runs on Eclipse
2468 2.1.x (Peter Friese)</li>
2469 <li>Option to Swing GUI and command line to generate project
2470 file using relative paths for archives, source directories, and
2471 aux classpath entries (Dave Brosius)</li>
2472 <li>Improvements to findbugs.bat script for launching FindBugs
2473 on Windows (Dave Brosius)</li>
2474 <li>Updated Japanese message translations (Hiroshi Okugawa)</li>
2475 <li>Uncalled private methods are now reported as low priority,
2476 unless they have the same name as another method in the class
2477 (which is more likely to indicate an actual bug)</li>
2478 <li>Added some missing data in the bug messages XML files</li>
2479 <li>Fixed some problems building from source on Windows
2480 systems</li>
2481 <li>Various minor bug fixes</li>
2482 </ul>
2483
2484 <p>Changes since version 0.7.2:</p>
2485 <ul>
2486 <li>Enhanced Eclipse plugin, which displays the detailed bug
2487 description in a view (Phil Crosby)</li>
2488 <li>Various tweaks to existing detectors to reduce false
2489 warnings</li>
2490 <li>New command line option <code> -workHard </code> enables
2491 pruning of infeasible or unlikely exception edges, which results
2492 in better accuracy in the open stream detector, at the expense of
2493 a 30%-100% slowdown
2494 </li>
2495 <li>New website and HTML documentation design</li>
2496 <li>Documentation includes an HTML document with descriptions
2497 of all bug patterns reported by FindBugs</li>
2498 <li>Web page has a link to a <a
2499 href="http://www.simeji.com/findbugs/doc/manual_ja/index.html">Japanese
2500 translation</a> of the FindBugs manual, contributed by Hiroshi
2501 Okugawa
2502 </li>
2503 <li>Changed the Inconsistent Synchronization detector so that
2504 fields synchronized 50% of the time (or more) are reported as
2505 medium priority bugs (previously they were reported as low)</li>
2506 <li>New detector to find code that catches
2507 IllegalMonitorStateException</li>
2508 <li>New detector to find private methods that are never called
2509 </li>
2510 <li>New detector to find suspicious uses of
2511 non-short-circuiting boolean operators ( <code> &amp; </code> and
2512 <code> | </code> , rather than <code> &amp;&amp; </code> and <code>
2513 || </code> )
2514 </li>
2515 </ul>
2516
2517 <p>Changes since version 0.7.1:</p>
2518 <ul>
2519 <li>Incorporated patched version of BCEL, which allows classes
2520 compiled with JDK 1.5.0 beta to be analyzed</li>
2521 <li>Fixed some bugs related to lookups of array classes</li>
2522 <li>Fixed bug that prevented GUI from loading XML result files
2523 when running under JDK 1.5.0 beta</li>
2524 <li>Added new experimental bug detector, LazyInit, which looks
2525 for potentially buggy lazy initializations of static fields</li>
2526 <li>Because of long filenames, switched to distributing the
2527 source archive as a zip file rather than a tar file</li>
2528 <li>The 0.7.1 source tarfile was botched - 0.7.2 has a valid
2529 source archive</li>
2530 <li>Fixed some problems in the Ant build script</li>
2531 <li>Fixed NullPointerException when checking Class-Path
2532 attribute for Jar files without manifests</li>
2533 <li>Generate version numbers for the core and UI Eclipse
2534 plugins using the Version class; all version numbers are now in a
2535 common location</li>
2536 </ul>
2537
2538 <p>Changes since version 0.7.0:</p>
2539 <ul>
2540 <li>Eclipse plugin (contributed by Peter Friese)</li>
2541 <li>Source package structure rearranged: all source (other
2542 than Eclipse plugin UI) is in the edu.umd.cs.findbugs package, or
2543 a subpackage</li>
2544 <li>Class-Path attributes of manifests of analyzed jar files
2545 are used to set the aux classpath automatically (Peter D. Stout)</li>
2546 <li>GUI starts in directory specified by user.home property
2547 (Peter D. Stout)</li>
2548 <li>Added -project option to GUI (Mikko T.)</li>
2549 <li>Added -look:{plastic,gtk,native} option to GUI, for
2550 setting look and feel (Mikko T.)</li>
2551 <li>Fixed DataflowAnalysisException in inconsistent
2552 synchronization detector</li>
2553 <li>Ant task supports failOnError parameter (Rohan Lloyd)</li>
2554 <li>Serializable class warnings are downgraded to low priority
2555 for GUI classes</li>
2556 <li>MWN detector will only report calls to wait(), notify(),
2557 and notifyAll() methods that have the correct signature</li>
2558 <li>FindBugs works with latest CVS version of BCEL</li>
2559 <li>Zip and Jar files may be added to the source path</li>
2560 <li>The GUI will automatically find source files residing in
2561 analyzed Zip or Jar files</li>
2562 </ul>
2563
2564 <p>Note that the version number jumped from 0.6.6 to 0.6.9;
2565 there were no 0.6.7 or 0.6.8 releases.</p>
2566 <p>Changes since version 0.6.9:</p>
2567 <ul>
2568 <li>Added -conserveSpace option to reduce memory use at the
2569 expense of analysis precision</li>
2570 <li>Bug fixes in findbugs.bat script: JAVA_HOME handling,
2571 autodetection of FINDBUGS_HOME, missing output with -textui</li>
2572 <li>Fixed NullPointerException when a missing class is
2573 encountered</li>
2574 </ul>
2575
2576 <p>Changes since version 0.6.6:</p>
2577 <ul>
2578 <li>The null pointer dereference detector is more powerful</li>
2579 <li>Significantly improved heuristics and bug fixes in
2580 inconsistent synchronization detector</li>
2581 <li>Improved heuristics in open stream and dropped exception
2582 detectors; fewer false positives should be reported</li>
2583 <li>Save HTML summary in XML results files, rather than
2584 recomputing; this makes loading results in GUI much faster</li>
2585 <li>Report at most one String comparison using == or != per
2586 method</li>
2587 <li>The findbugs.bat script on Windows autodetects
2588 FINDBUGS_HOME, and doesn't open a DOS window when launching the
2589 GUI (contributed by TJSB)</li>
2590 <li>Emacs reporting format (contributed by David Li)</li>
2591 <li>Various bug fixes</li>
2592 </ul>
2593
2594 <p>Changes since 0.6.5:</p>
2595 <ul>
2596 <li>Rewritten inconsistent synchronization detector; accuracy
2597 is significantly improved, and bug reports are prioritized</li>
2598 <li>New detector to find self assignment (x=x) of local
2599 variables (suggested by Jeff Martin)</li>
2600 <li>New detector to find calls to wait(), notify(), and
2601 notifyAll() on an object which is not obviously locked</li>
2602 <li>Open stream detector now reports Readers and Writers</li>
2603 <li>Fixed bug in finalizer idioms detector which caused
2604 spurious warnings about failure to call super.finalize() (reported
2605 by Jim Menard)</li>
2606 <li>Fixed bug where output stream was not closed using non-XML
2607 output (reported by Sigiswald Madou)</li>
2608 <li>Fixed corrupted HTML bug detail message (reported by
2609 Trevor Harmon)</li>
2610 </ul>
2611
2612 <p>Changes since version 0.6.4:</p>
2613 <ul>
2614 <li>For redundant comparison of reference values, fixed false
2615 positives resulting from duplication of code in finally blocks</li>
2616 <li>Fixed false positives resulting from wrapped byte array
2617 streams left open</li>
2618 <li>Fixed bug in Ant task preventing output file from working
2619 properly if a relative path was used</li>
2620 </ul>
2621
2622 <p>Changes since version 0.6.3:</p>
2623 <ul>
2624 <li>Fixed bug in Ant task where output would be corrupted, and
2625 added a <code> timeout </code> attribute
2626 </li>
2627 <li>Added -outputFile option to text UI, for explicitly
2628 specifying an output file</li>
2629 <li>GUI has a summary window, for statistics about overall bug
2630 densities (contributed by Mike Fagan)</li>
2631 <li>Find redundant comparisons of reference values</li>
2632 <li>More accurate detection of Strings compared with == and !=
2633 operators</li>
2634 <li>Detection of other reference types which should generally
2635 not be compared with == and != operators; Boolean, Integer, etc.</li>
2636 <li>Find non-transient non-serializable instance fields in
2637 Serializable classes</li>
2638 <li>Source code may be compiled with latest early access
2639 generics-enabled javac (version 2.2)</li>
2640 </ul>
2641
2642 <p>Changes since version 0.6.2:</p>
2643 <ul>
2644 <li>GUI supports filtering bugs by priority</li>
2645 <li>Ant task rewritten; supports all functionality offered by
2646 Text UI (contributed by Mike Fagan)</li>
2647 <li>Ant task is fully documented in the manual</li>
2648 <li>Classes in nested archives are analyzed; this allows full
2649 support for analyzing .ear and .war files (contributed by Mike
2650 Fagan)</li>
2651 <li>DepthFirstSearch changed to use non-recursive
2652 implementation; this should fix the StackOverflowErrors that
2653 several users reported</li>
2654 <li>Various minor bugfixes and improvements</li>
2655 </ul>
2656
2657 <p>Changes since version 0.6.1:</p>
2658 <ul>
2659 <li>New detector to look for useless control flow (suggested
2660 by Richard P. King and Mike Fagan)</li>
2661 <li>Look for places where return value of
2662 java.io.File.createNewFile() is ignored (suggested by Richard P.
2663 King)</li>
2664 <li>Fixed bug in resolution of source files (only the first
2665 source directory was searched)</li>
2666 <li>Fixed a NullPointerException in the bytecode pattern
2667 matching code</li>
2668 <li>Ant task supports project files (contributed by Mike
2669 Fagan)</li>
2670 <li>Unix findbugs script honors the <code> JAVA_HOME </code>
2671 environment variable (contributed by Pedro Morais)
2672 </li>
2673 <li>Allow .war and .ear files to be analyzed</li>
2674 </ul>
2675
2676 <p>Changes since version 0.6.0:</p>
2677 <ul>
2678 <li>New bug pattern detector which looks for places where a
2679 null pointer might be dereferenced</li>
2680 <li>New bug pattern detector which looks for IO streams that
2681 are opened, do not escape the method, and are not closed on all
2682 paths out of the method</li>
2683 <li>New bug pattern detector to find methods that can return
2684 null instead of a zero-length array</li>
2685 <li>New bug pattern detector to find places where the == or !=
2686 operators are used to compare String objects</li>
2687 <li>Command line interface can save bugs as XML</li>
2688 <li>GUI can save bugs to and load bugs from XML</li>
2689 <li>An "Annotations" window in the GUI allows the user to add
2690 textual annotations to bug reports; these annotations are
2691 preserved when bugs are saved as XML</li>
2692 <li>In this release, the Japanese bug summary translations by
2693 Germano Leichsenring are really included (they were inadvertently
2694 omitted in the previous release)</li>
2695 <li>Completely rewrote the control flow graph builder,
2696 hopefully for the last time</li>
2697 <li>Simplified implementation of control flow graphs, which
2698 should reduce memory use and possibly improve performance</li>
2699 <li>Improvements to command line interface (list bug
2700 priorities, filter by priority, specify aux classpath, specify
2701 project to analyze)</li>
2702 <li>Various bug fixes and enhancements</li>
2703 </ul>
2704
2705 <p>Changes since version 0.5.4</p>
2706 <ul>
2707 <li>Added an <a href="http://ant.apache.org/">Ant</a> task for
2708 FindBugs, contributed by Mike Fagan.
2709 </li>
2710 <li>Added a GUI dialog which allows individual bug pattern
2711 detectors to be enabled or disabled.&nbsp; Disabling certain slow
2712 detectors can greatly speed up analysis of large programs, at the
2713 expense of reducing the number of potential bugs found.</li>
2714 <li>Added a new detector for finding improperly ignored return
2715 values for methods such as <code> String.trim() </code> .&nbsp;
2716 Suggested by Andreas Mandel.
2717 </li>
2718 <li>Japanese translations of the bug summaries, contributed by
2719 Germano Leichsenring.</li>
2720 <li>Filtering of results is supported in command line
2721 interface. See the <a href="manual/index.html">FindBugs manual</a>
2722 for details.
2723 </li>
2724 <li>Added "byte code patterns", a general pattern matching
2725 infrastructure for bytecode instructions.&nbsp; This feature
2726 significantly reduces the complexity of implementing new bug
2727 pattern detectors.</li>
2728 <li>Enabled a new general dataflow analysis to track values in
2729 methods.</li>
2730 <li>Switched to new control-flow graph builder implementation.
2731 </li>
2732 </ul>
2733
2734 <p>Changes since version 0.5.3</p>
2735 <ul>
2736 <li>Fixed a bug in the script used to launch FindBugs on
2737 Windows platforms.</li>
2738 <li>Fixed crashes when analyzing class files without source
2739 line information.</li>
2740 <li>All major errors are reported using an error dialog; file
2741 not found errors are more informative.</li>
2742 <li>Minor GUI improvements.</li>
2743 </ul>
2744
2745 <p>Changes since version 0.5.2</p>
2746 <ul>
2747 <li>All of the source code and related files are in a single
2748 directory tree.</li>
2749 <li>Updated some of the detectors to produce source line
2750 information.</li>
2751 <li><a href="http://ant.apache.org/">Ant</a> build script and
2752 several GUI enhancements and fixes contributed by Mike Fagan.</li>
2753 <li>Converted to use a <a href="AddingDetectors.txt">plugin
2754 architecture</a> for loading bug detectors.
2755 </li>
2756 <li>Eliminated generics-related compiler warnings.</li>
2757 <li>More complete documentation has been added.</li>
2758 </ul>
2759
2760 <p>Changes since version 0.5.1:</p>
2761 <ul>
2762 <li>Fixed a large number of bugs in the BCEL Repository and
2763 FindBugs's use of the Repository.&nbsp; With these changes,
2764 FindBugs should <em>never</em> crash or otherwise misbehave
2765 because of Repository lookup failures.&nbsp; Because of these
2766 changes, you must use a modified version of <code> bcel.jar
2767 </code> with FindBugs.&nbsp; This jar file is included in the FindBugs
2768 0.5.2 binary release.&nbsp; A complete patch containing the <a
2769 href="http://faculty.ycp.edu/~dhovemey/bcel-30-April-2003.patch">modifications
2770 against the BCEL CVS main branch as of April 30, 2003</a> is also
2771 available.
2772 </li>
2773 <li>Implemented the "auxiliary classpath entry list".&nbsp;
2774 Aux classpath entries can be added to a project to provide classes
2775 that are referenced by the analyzed application, but should not
2776 themselves be analyzed.&nbsp; Having all referenced classes
2777 available allows FindBugs to produce more accurate results.</li>
2778 </ul>
2779
2780 <p>Changes since version 0.5.0:</p>
2781 <ul>
2782 <li>Many user interface bugs have been fixed.</li>
2783 <li>Upgraded to a recent CVS version of BCEL, with some bug
2784 fixes.&nbsp; This should prevent FindBugs from crashing when there
2785 is a failure to find a class on the classpath.</li>
2786 <li>Added support for Plastic look and feel from <a
2787 href="http://www.jgoodies.com/">jgoodies.com</a>.
2788 </li>
2789 <li>Major overhaul of infrastructure for doing dataflow
2790 analysis.</li>
2791 </ul>
2792 <hr> <p>
2793 <script language="JavaScript" type="text/javascript">
2794 <!---//hide script from old browsers
2795 document.write( "Last updated "+ document.lastModified + "." );
2796 //end hiding contents --->
2797 </script>
2798 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
2799 <p>
2800 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
2801
2802 </td>
2803
2804 </tr>
2805 </table>
2806
2807 </body>
2808
2809 </html>
0 <html>
1 <head>
2 <title>FindBugs FAQ</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6
7 <body>
8
9 <table width="100%"><tr>
10
11
12 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
13 <table width="100%" cellspacing="0" border="0">
14 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
15
16 <tr><td>&nbsp;</td></tr>
17
18 <tr><td><b>Docs and Info</b></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
31
32 <tr><td>&nbsp;</td></tr>
33
34 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
35
36 <tr><td>&nbsp;</td></tr>
37
38 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
39
40 <tr><td>&nbsp;</td></tr>
41
42 <tr><td><b>Development</b></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
52 </table>
53 </td>
54
55 <td>
56 <h1>FindBugs FAQ</h1>
57
58 <p> This document contains answers to frequently asked questions about
59 <a href="index.html">FindBugs</a>.&nbsp; If you just want general
60 information about FindBugs, have a look at the
61 <a href="factSheet.html">fact sheet</a> and the
62 <a href="manual/index.html">manual</a>.
63
64 <h2>Contents</h2>
65 <ol>
66 <li> <a href="#q1">I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a>
67 <li> <a href="#q2">When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a>
68 <li> <a href="#q3">FindBugs is running out of memory, or is taking a long time to finish</a>
69 <li> <a href="#q4">What is the "auxiliary classpath"? Why should I specify it?</a>
70 <li> <a href="#q5">The Eclipse plugin doesn't load</a>
71 <li> <a href="#q6">I'm getting a lot of false "OS" and "ODR" warnings</a>
72 <li> <a href="#q7">The Eclipse plugin loads, but doesn't work correctly</a>
73 <li> <a href="#q8">Where is the Maven plugin for FindBugs?</a>
74 <li> <a href="#q9">Where is the NetBeans plugin for FindBugs?</a>
75 </ol>
76
77 <h2><a name="q1">Q1: I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a></h2>
78
79 <p> FindBugs requires JRE 1.5.0 or later to run.&nbsp; If you use an earlier version,
80 you will see an exception error message similar to the following:
81 <pre>
82 Exception in thread "main" java.lang.UnsupportedClassVersionError:
83 edu/umd/cs/findbugs/gui/FindBugsFrame (Unsupported major.minor version 48.0)
84 </pre>
85 The solution is to upgrade to JRE 1.5.0 or later.
86
87 <h2><a name="q2">Q2: When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a></h2>
88
89 <p> The symptom of this bug is that when you start the FindBugs analysis,
90 you see an exception similar to the following:
91 <pre>
92 java.lang.NoSuchMethodError: org.apache.bcel.Repository.setRepository(Lorg/apache/bcel/util/Repository;)V
93 at edu.umd.cs.findbugs.FindBugs.clearRepository(FindBugs.java:483)
94 ...
95 </pre>
96
97 or
98
99 <pre>
100 java.lang.VerifyError: Cannot inherit from final class
101 at java.lang.ClassLoader.defineClass0(Native Method)
102 at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
103 ...
104 </pre>
105
106 <p> The problem here is that the wrong version of the
107 <a href="http://jakarta.apache.org/bcel/">Apache BCEL</a>
108 library is being found.&nbsp; FindBugs requires its own
109 version of BCEL, which normally will be used automatically
110 when you invoke the <code>findbugs</code> or <code>findbugs.bat</code>
111 scripts used to launch FindBugs.&nbsp; If an old version of BCEL is installed
112 in a location, such as "lib/endorsed" in the JRE installation,
113 where it overrides classes on the application classpath,
114 FindBugs will not execute properly.&nbsp;
115 We know of several reasons this could happen
116
117 <ul>
118 <li> If you install the
119 <a href="http://java.sun.com/webservices/downloads/webservicespack.html">Java(TM) Web Services
120 Developer Pack 1.2</a>
121 in the <code>lib/endorsed</code> directory of your Java Runtime Environment (JRE).&nbsp;
122 The file <code>xsltc.jar</code> contains an old version of BCEL that is incompatible with
123 FindBugs.&nbsp;
124
125 <li> Another possibility is that you are using the IBM JDK.&nbsp;
126 Some versions include a version of BCEL which conflicts with the
127 one required by FindBugs.&nbsp; This problem is fixed in version 1.4.1 SP1,
128 so upgrading your JDK should allow FindBugs to run correctly.
129
130 <li> Some versions of the Apache Xalan XSLT processor include
131 an old version of BCEL in <code>xalan.jar</code>.
132
133 </ul>
134
135 <p> In all of these cases, you should be able to run FindBugs
136 by either removing the offending version of BCEL from your JRE,
137 or installing a clean JRE or JDK and using that to run FindBugs.
138
139 <p> Many thanks to Peter Meulmeester, Michael Levi, and Thomas Klaeger
140 for providing information on this problem.
141
142 <h2><a name="q3">Q3: FindBugs is running out of memory, or is taking a long time to finish</a></h2>
143
144 <p> In general, FindBugs requires lots of memory and a relatively
145 fast CPU. For large applications, 512M or more of heap space may be
146 required. By default, FindBugs allocates 256M of heap space.
147 You can increase this using the <code>-maxHeap <i>n</i></code> option,
148 where <i>n</i> is the number of megabytes of heap space to allocate.
149
150
151 <h2><a name="q4">Q4: What is the "auxiliary classpath"? Why should I specify it?</a></h2>
152
153 <p> Many important facts about a Java class require information about
154 the classes that it references.&nbsp; For example:
155 <ul>
156 <li> What other classes and interfaces the class inherits from
157 <li> What exceptions can be thrown by methods in external classes
158 and interfaces
159 </ul>
160
161 <p> The "auxiliary classpath" is a list of Jar files, directories, and
162 class files containing classes that are <em>used</em> by the code you
163 want FindBugs to analyze, but should not themselves be analyzed
164 by FindBugs.
165
166 <p> If FindBugs doesn't have complete information about referenced classes,
167 it will not be able to produce results that are as accurate as possible.&nbsp;
168 For example, having a complete repository of referenced classes allows
169 FindBugs to prune control flow information so it can concentrate on
170 paths through methods that are most likely to be feasible at runtime.&nbsp;
171 Also, some bug detectors (such as the suspicious reference comparison detector)
172 rely on being able to perform type inference, which requires complete
173 type hierarchy information.
174
175 <p> For these reasons, we strongly recommend that you completely specify
176 the auxiliary classpath when you run FindBugs.&nbsp; You can do this
177 by using the <code>-auxclasspath</code> command line option, or the
178 "Classpath entries" list in the GUI project editor dialog.
179
180 <p> If FindBugs cannot find a class referenced by your application, it
181 will print out a message when the analysis completes, specifying the
182 classes that were missing.&nbsp; You should modify the auxiliary classpath
183 to specify how to find the missing classes, and then run FindBugs again.
184
185 <h2><a name="q5">Q5: The Eclipse plugin doesn't load</a></h2>
186
187 <p> The symptom of this problem is that Eclipse fails to load
188 the FindBugs UI plugin with the message:
189 <blockquote>
190 Plug-in "edu.umd.cs.findbugs.plugin.eclipse" was disabled due to missing or disabled
191 prerequisite plug-in "org.eclipse.ui.ide"
192 </blockquote>
193
194 <p> The reason for this problem is that the Eclipse
195 plugin distributed with FindBugs
196 does not work with older 3.x versions of Eclipse.
197 Please use Eclipse version 3.6 (June 2010) or newer.
198
199 <h2><a name="q6">Q6: I'm getting a lot of false "OS" and "ODR" warnings</a></h2>
200
201 <p> By default, FindBugs assumes that any method invocation can
202 throw an unchecked runtime exception.&nbsp; As a result,
203 it may assume that an unchecked exception thrown out of the
204 method could bypass a call to a <code>close()</code> method
205 for a stream or database resource.
206
207 <p> You can use the <code>-workHard</code> command line argument
208 or the <code>findbugs.workHard</code> boolean analysis property
209 to make FindBugs work harder to prune unlikely exception
210 edges.&nbsp; This generally reduces the number of
211 false warnings, at the expense of slowing down the
212 analysis.
213
214 <h2><a name="q7">Q7: The Eclipse plugin loads, but doesn't work correctly</a></h2>
215
216 <p> Make sure the Java code you trying to analyze is built properly and has no
217 classpath or compile errors.
218
219 <p> Make sure the project and workspace FindBugs settings are valid - in doubt, revert them to defaults.
220
221 <p> Make sure the Error log view does not show errors.
222
223 <h2><a name="q8">Q8: Where is the Maven plugin for FindBugs?</a></h2>
224
225 <p>
226 The <a href="http://maven.apache.org/">Maven</a> Plugin for FindBugs
227 may be found <a href="http://mojo.codehaus.org/findbugs-maven-plugin/">here</a>.&nbsp;
228 Please note that the Maven plugin is not maintained by the FindBugs developers,
229 so we can't answer questions about it.
230 </p>
231
232 <h2><a name="q9">Q9: Where is the NetBeans plugin for FindBugs?</a></h2>
233
234 <p>We recommend <a href="http://kenai.com/projects/sqe/pages/Home">SQE: Software Quality Environment</a>
235 which bundles FindBugs, PMD and CheckStyle. Use the following
236 update site:
237 <a href="http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml
238 ">http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml</a>
239 <p>Pease note that the SQE plugin is not maintained by the FindBugs developers,
240 so we can't answer questions about it.
241 </p>
242
243
244 <hr> <p>
245 <script language="JavaScript" type="text/javascript">
246 <!---//hide script from old browsers
247 document.write( "Last updated "+ document.lastModified + "." );
248 //end hiding contents --->
249 </script>
250 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
251 <p>
252 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
253
254 </td>
255
256 </table>
257
258 </body>
259
260 </html>
0 =============
1 How it works:
2 =============
3
4 A filter file is an XML file with a top-level "FindBugsFilter" element
5 which has some number of "Match" elements as children. Each Match
6 element represents a predicate which is applied to generated bug instances.
7 Usually, a filter will be used to exclude bug instances. For example:
8
9 findbugs -textui -exclude myExcludeFilter.xml myApp.jar
10
11 However, a filter could also be used to select bug instances to specifically
12 report:
13
14 findbugs -textui -include myIncludeFilter.xml myApp.jar
15
16 Match has "class" and "classregex" attributes specifying what class or classes
17 the predicate applies to.
18
19 Match contains children, which are conjuncts of the predicate.
20 (I.e., each of the children must be true for the predicate to be true.)
21
22 =======================
23 Types of Match clauses:
24 =======================
25
26 <BugCode> specifies abbreviations of bugs.
27 The "name" attribute is a comma-seperated list of abbreviations.
28
29 <Method> specifies a method. The "name" attribute is the name
30 of the method. The "params" attribute is a comma separated list
31 of the types of the method's parameters. The "returns" attribute is
32 the method's return type. In "params" and "returns", class names
33 must be fully qualified. (E.g., "java.lang.String" instead of just
34 "String".) Note that "params" and "returns" are optional; you can
35 just specify "name", and the clause will match all methods with
36 that name. However, if you specify either "params" or "returns",
37 you must specify both of them.
38
39 <Or> combines Match clauses as disjuncts. I.e., you can put two
40 "Method" elements in an Or clause in order match either method.
41
42 ========
43 Caveats:
44 ========
45
46 Match clauses can only match information that is actually contained in the
47 bug instances. Every bug instance has a class, so in general, excluding
48 bugs by class will work.
49
50 Some bug instances have two classes. For example, the DE (dropped exception)
51 bugs report both the class containing the method where the dropped exception
52 happens, and the class which represents the type of the dropped exception.
53 Only the FIRST (primary) class is matched against Match clauses.
54 So, for example, if you want to suppress IC (initialization circularity)
55 reports for classes "com.foobar.A" and "com.foobar.B", you would use
56 two Match clauses:
57
58 <Match class="com.foobar.A">
59 <BugCode name="IC" />
60 </Match>
61
62 <Match class="com.foobar.B">
63 <BugCode name="IC" />
64 </Match>
65
66 Many kinds of bugs report what method they occur in. For those bug instances,
67 you can put Method clauses in the Match element and they should work
68 as expected.
69
70 =========
71 Examples:
72 =========
73
74 1. Match all bug reports for a class.
75
76 <Match class="com.foobar.MyClass" />
77
78 2. Match certain tests from a class.
79 <Match class="com.foobar.MyClass">
80 <BugCode name="DE,UrF,SIC" />
81 </Match>
82
83 3. Match certain tests from all classes.
84
85 <Match classregex=".*" >
86 <BugCode name="DE,UrF,SIC" />
87 </Match>
88
89 4. Match bug types from specified methods of a class.
90
91 <Match class="com.foobar.MyClass">
92 <Or>
93 <Method name="frob" params="int,java.lang.String" returns="void" />
94 <Method name="blat" params="" returns="boolean" />
95 </Or>
96 <BugCode name="DC" />
97 </Match>
98
99 =================
100 Complete Example:
101 =================
102
103 <FindBugsFilter>
104 <Match class="com.foobar.ClassNotToBeAnalyzed" />
105
106 <Match class="com.foobar.ClassWithSomeBugsMatched">
107 <BugCode name="DE,UrF,SIC" />
108 </Match>
109
110 <!-- Match all XYZ violations. -->
111 <Match classregex=".*" >
112 <BugCode name="XYZ" />
113 </Match>
114
115 <!-- Match all doublecheck violations in these methods of "AnotherClass". -->
116 <Match class="com.foobar.AnotherClass">
117 <Or>
118 <Method name="nonOverloadedMethod" />
119 <Method name="frob" params="int,java.lang.String" returns="void" />
120 <Method name="blat" params="" returns="boolean" />
121 </Or>
122 <BugCode name="DC" />
123 </Match>
124 </FindBugsFilter>
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1 <html><head><title>FindBugs Bug Descriptions (Unabridged)</title>
2 <link rel="stylesheet" type="text/css" href="findbugs.css"/>
3 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
4 </head><body>
5
6 <table width="100%"><tr>
7
8 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
9 <table width="100%" cellspacing="0" border="0">
10 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
11
12 <tr><td>&nbsp;</td></tr>
13
14 <tr><td><b>Docs and Info</b></td></tr>
15 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
16 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
17 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
27
28 <tr><td>&nbsp;</td></tr>
29
30 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
31
32 <tr><td>&nbsp;</td></tr>
33
34 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
35
36 <tr><td>&nbsp;</td></tr>
37
38 <tr><td><b>Development</b></td></tr>
39 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
40 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
41 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
48 </table>
49 </td>
50 <td align="left" valign="top">
51 <h1>FindBugs Bug Descriptions (Unabridged)</h1>
52 <p>This document lists all of the bug patterns reported by the
53 latest development version of
54 <a href="http://findbugs.sourceforge.net">FindBugs</a>.&nbsp; Note that this may include
55 bug patterns not available in any released version of FindBugs,
56 as well as bug patterns that are not enabled by default.
57 <h2>Summary</h2>
58 <table width="100%">
59 <tr bgcolor="#b9b9fe"><th>Description</th><th>Category</th></tr>
60 <tr bgcolor="#eeeeee"><td><a href="#AM_CREATES_EMPTY_JAR_FILE_ENTRY">AM: Creates an empty jar file entry</a></td><td>Bad practice</td></tr>
61 <tr bgcolor="#ffffff"><td><a href="#AM_CREATES_EMPTY_ZIP_FILE_ENTRY">AM: Creates an empty zip file entry</a></td><td>Bad practice</td></tr>
62 <tr bgcolor="#eeeeee"><td><a href="#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS">BC: Equals method should not assume anything about the type of its argument</a></td><td>Bad practice</td></tr>
63 <tr bgcolor="#ffffff"><td><a href="#BIT_SIGNED_CHECK">BIT: Check for sign of bitwise operation</a></td><td>Bad practice</td></tr>
64 <tr bgcolor="#eeeeee"><td><a href="#CN_IDIOM">CN: Class implements Cloneable but does not define or use clone method</a></td><td>Bad practice</td></tr>
65 <tr bgcolor="#ffffff"><td><a href="#CN_IDIOM_NO_SUPER_CALL">CN: clone method does not call super.clone()</a></td><td>Bad practice</td></tr>
66 <tr bgcolor="#eeeeee"><td><a href="#CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: Class defines clone() but doesn't implement Cloneable</a></td><td>Bad practice</td></tr>
67 <tr bgcolor="#ffffff"><td><a href="#CO_ABSTRACT_SELF">Co: Abstract class defines covariant compareTo() method</a></td><td>Bad practice</td></tr>
68 <tr bgcolor="#eeeeee"><td><a href="#CO_SELF_NO_OBJECT">Co: Covariant compareTo() method defined</a></td><td>Bad practice</td></tr>
69 <tr bgcolor="#ffffff"><td><a href="#DE_MIGHT_DROP">DE: Method might drop exception</a></td><td>Bad practice</td></tr>
70 <tr bgcolor="#eeeeee"><td><a href="#DE_MIGHT_IGNORE">DE: Method might ignore exception</a></td><td>Bad practice</td></tr>
71 <tr bgcolor="#ffffff"><td><a href="#DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI: Adding elements of an entry set may fail due to reuse of Entry objects</a></td><td>Bad practice</td></tr>
72 <tr bgcolor="#eeeeee"><td><a href="#DMI_RANDOM_USED_ONLY_ONCE">DMI: Random object created and used only once</a></td><td>Bad practice</td></tr>
73 <tr bgcolor="#ffffff"><td><a href="#DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI: Don't use removeAll to clear a collection</a></td><td>Bad practice</td></tr>
74 <tr bgcolor="#eeeeee"><td><a href="#DM_EXIT">Dm: Method invokes System.exit(...)</a></td><td>Bad practice</td></tr>
75 <tr bgcolor="#ffffff"><td><a href="#DM_RUN_FINALIZERS_ON_EXIT">Dm: Method invokes dangerous method runFinalizersOnExit</a></td><td>Bad practice</td></tr>
76 <tr bgcolor="#eeeeee"><td><a href="#ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: Comparison of String parameter using == or !=</a></td><td>Bad practice</td></tr>
77 <tr bgcolor="#ffffff"><td><a href="#ES_COMPARING_STRINGS_WITH_EQ">ES: Comparison of String objects using == or !=</a></td><td>Bad practice</td></tr>
78 <tr bgcolor="#eeeeee"><td><a href="#EQ_ABSTRACT_SELF">Eq: Abstract class defines covariant equals() method</a></td><td>Bad practice</td></tr>
79 <tr bgcolor="#ffffff"><td><a href="#EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">Eq: Equals checks for incompatible operand</a></td><td>Bad practice</td></tr>
80 <tr bgcolor="#eeeeee"><td><a href="#EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class defines compareTo(...) and uses Object.equals()</a></td><td>Bad practice</td></tr>
81 <tr bgcolor="#ffffff"><td><a href="#EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals method fails for subtypes</a></td><td>Bad practice</td></tr>
82 <tr bgcolor="#eeeeee"><td><a href="#EQ_SELF_NO_OBJECT">Eq: Covariant equals() method defined</a></td><td>Bad practice</td></tr>
83 <tr bgcolor="#ffffff"><td><a href="#FI_EMPTY">FI: Empty finalizer should be deleted</a></td><td>Bad practice</td></tr>
84 <tr bgcolor="#eeeeee"><td><a href="#FI_EXPLICIT_INVOCATION">FI: Explicit invocation of finalizer</a></td><td>Bad practice</td></tr>
85 <tr bgcolor="#ffffff"><td><a href="#FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nulls fields</a></td><td>Bad practice</td></tr>
86 <tr bgcolor="#eeeeee"><td><a href="#FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalizer only nulls fields</a></td><td>Bad practice</td></tr>
87 <tr bgcolor="#ffffff"><td><a href="#FI_MISSING_SUPER_CALL">FI: Finalizer does not call superclass finalizer</a></td><td>Bad practice</td></tr>
88 <tr bgcolor="#eeeeee"><td><a href="#FI_NULLIFY_SUPER">FI: Finalizer nullifies superclass finalizer</a></td><td>Bad practice</td></tr>
89 <tr bgcolor="#ffffff"><td><a href="#FI_USELESS">FI: Finalizer does nothing but call superclass finalizer</a></td><td>Bad practice</td></tr>
90 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_USES_NEWLINE">FS: Format string should use %n rather than \n</a></td><td>Bad practice</td></tr>
91 <tr bgcolor="#ffffff"><td><a href="#GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unchecked type in generic call</a></td><td>Bad practice</td></tr>
92 <tr bgcolor="#eeeeee"><td><a href="#HE_EQUALS_NO_HASHCODE">HE: Class defines equals() but not hashCode()</a></td><td>Bad practice</td></tr>
93 <tr bgcolor="#ffffff"><td><a href="#HE_EQUALS_USE_HASHCODE">HE: Class defines equals() and uses Object.hashCode()</a></td><td>Bad practice</td></tr>
94 <tr bgcolor="#eeeeee"><td><a href="#HE_HASHCODE_NO_EQUALS">HE: Class defines hashCode() but not equals()</a></td><td>Bad practice</td></tr>
95 <tr bgcolor="#ffffff"><td><a href="#HE_HASHCODE_USE_OBJECT_EQUALS">HE: Class defines hashCode() and uses Object.equals()</a></td><td>Bad practice</td></tr>
96 <tr bgcolor="#eeeeee"><td><a href="#HE_INHERITS_EQUALS_USE_HASHCODE">HE: Class inherits equals() and uses Object.hashCode()</a></td><td>Bad practice</td></tr>
97 <tr bgcolor="#ffffff"><td><a href="#IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION">IC: Superclass uses subclass during initialization</a></td><td>Bad practice</td></tr>
98 <tr bgcolor="#eeeeee"><td><a href="#IMSE_DONT_CATCH_IMSE">IMSE: Dubious catching of IllegalMonitorStateException</a></td><td>Bad practice</td></tr>
99 <tr bgcolor="#ffffff"><td><a href="#ISC_INSTANTIATE_STATIC_CLASS">ISC: Needless instantiation of class that only supplies static methods</a></td><td>Bad practice</td></tr>
100 <tr bgcolor="#eeeeee"><td><a href="#IT_NO_SUCH_ELEMENT">It: Iterator next() method can't throw NoSuchElementException</a></td><td>Bad practice</td></tr>
101 <tr bgcolor="#ffffff"><td><a href="#J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION">J2EE: Store of non serializable object into HttpSession</a></td><td>Bad practice</td></tr>
102 <tr bgcolor="#eeeeee"><td><a href="#JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP: Fields of immutable classes should be final</a></td><td>Bad practice</td></tr>
103 <tr bgcolor="#ffffff"><td><a href="#NP_BOOLEAN_RETURN_NULL">NP: Method with Boolean return type returns explicit null</a></td><td>Bad practice</td></tr>
104 <tr bgcolor="#eeeeee"><td><a href="#NP_CLONE_COULD_RETURN_NULL">NP: Clone method may return null</a></td><td>Bad practice</td></tr>
105 <tr bgcolor="#ffffff"><td><a href="#NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: equals() method does not check for null argument</a></td><td>Bad practice</td></tr>
106 <tr bgcolor="#eeeeee"><td><a href="#NP_TOSTRING_COULD_RETURN_NULL">NP: toString method may return null</a></td><td>Bad practice</td></tr>
107 <tr bgcolor="#ffffff"><td><a href="#NM_CLASS_NAMING_CONVENTION">Nm: Class names should start with an upper case letter</a></td><td>Bad practice</td></tr>
108 <tr bgcolor="#eeeeee"><td><a href="#NM_CLASS_NOT_EXCEPTION">Nm: Class is not derived from an Exception, even though it is named as such</a></td><td>Bad practice</td></tr>
109 <tr bgcolor="#ffffff"><td><a href="#NM_CONFUSING">Nm: Confusing method names</a></td><td>Bad practice</td></tr>
110 <tr bgcolor="#eeeeee"><td><a href="#NM_FIELD_NAMING_CONVENTION">Nm: Field names should start with a lower case letter</a></td><td>Bad practice</td></tr>
111 <tr bgcolor="#ffffff"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java</a></td><td>Bad practice</td></tr>
112 <tr bgcolor="#eeeeee"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java</a></td><td>Bad practice</td></tr>
113 <tr bgcolor="#ffffff"><td><a href="#NM_METHOD_NAMING_CONVENTION">Nm: Method names should start with a lower case letter</a></td><td>Bad practice</td></tr>
114 <tr bgcolor="#eeeeee"><td><a href="#NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class names shouldn't shadow simple name of implemented interface</a></td><td>Bad practice</td></tr>
115 <tr bgcolor="#ffffff"><td><a href="#NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class names shouldn't shadow simple name of superclass</a></td><td>Bad practice</td></tr>
116 <tr bgcolor="#eeeeee"><td><a href="#NM_VERY_CONFUSING_INTENTIONAL">Nm: Very confusing method names (but perhaps intentional)</a></td><td>Bad practice</td></tr>
117 <tr bgcolor="#ffffff"><td><a href="#NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doesn't override method in superclass due to wrong package for parameter</a></td><td>Bad practice</td></tr>
118 <tr bgcolor="#eeeeee"><td><a href="#ODR_OPEN_DATABASE_RESOURCE">ODR: Method may fail to close database resource</a></td><td>Bad practice</td></tr>
119 <tr bgcolor="#ffffff"><td><a href="#ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">ODR: Method may fail to close database resource on exception</a></td><td>Bad practice</td></tr>
120 <tr bgcolor="#eeeeee"><td><a href="#OS_OPEN_STREAM">OS: Method may fail to close stream</a></td><td>Bad practice</td></tr>
121 <tr bgcolor="#ffffff"><td><a href="#OS_OPEN_STREAM_EXCEPTION_PATH">OS: Method may fail to close stream on exception</a></td><td>Bad practice</td></tr>
122 <tr bgcolor="#eeeeee"><td><a href="#PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ: Don't reuse entry objects in iterators</a></td><td>Bad practice</td></tr>
123 <tr bgcolor="#ffffff"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicious reference comparison to constant</a></td><td>Bad practice</td></tr>
124 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC: Suspicious reference comparison of Boolean values</a></td><td>Bad practice</td></tr>
125 <tr bgcolor="#ffffff"><td><a href="#RR_NOT_CHECKED">RR: Method ignores results of InputStream.read()</a></td><td>Bad practice</td></tr>
126 <tr bgcolor="#eeeeee"><td><a href="#SR_NOT_CHECKED">RR: Method ignores results of InputStream.skip()</a></td><td>Bad practice</td></tr>
127 <tr bgcolor="#ffffff"><td><a href="#RV_NEGATING_RESULT_OF_COMPARETO">RV: Negating the result of compareTo()/compare()</a></td><td>Bad practice</td></tr>
128 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Method ignores exceptional return value</a></td><td>Bad practice</td></tr>
129 <tr bgcolor="#ffffff"><td><a href="#SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Static initializer creates instance before all static final fields assigned</a></td><td>Bad practice</td></tr>
130 <tr bgcolor="#eeeeee"><td><a href="#SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW: Certain swing methods needs to be invoked in Swing thread</a></td><td>Bad practice</td></tr>
131 <tr bgcolor="#ffffff"><td><a href="#SE_BAD_FIELD">Se: Non-transient non-serializable instance field in serializable class</a></td><td>Bad practice</td></tr>
132 <tr bgcolor="#eeeeee"><td><a href="#SE_BAD_FIELD_INNER_CLASS">Se: Non-serializable class has a serializable inner class</a></td><td>Bad practice</td></tr>
133 <tr bgcolor="#ffffff"><td><a href="#SE_BAD_FIELD_STORE">Se: Non-serializable value stored into instance field of a serializable class</a></td><td>Bad practice</td></tr>
134 <tr bgcolor="#eeeeee"><td><a href="#SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Comparator doesn't implement Serializable</a></td><td>Bad practice</td></tr>
135 <tr bgcolor="#ffffff"><td><a href="#SE_INNER_CLASS">Se: Serializable inner class</a></td><td>Bad practice</td></tr>
136 <tr bgcolor="#eeeeee"><td><a href="#SE_NONFINAL_SERIALVERSIONID">Se: serialVersionUID isn't final</a></td><td>Bad practice</td></tr>
137 <tr bgcolor="#ffffff"><td><a href="#SE_NONLONG_SERIALVERSIONID">Se: serialVersionUID isn't long</a></td><td>Bad practice</td></tr>
138 <tr bgcolor="#eeeeee"><td><a href="#SE_NONSTATIC_SERIALVERSIONID">Se: serialVersionUID isn't static</a></td><td>Bad practice</td></tr>
139 <tr bgcolor="#ffffff"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR">Se: Class is Serializable but its superclass doesn't define a void constructor</a></td><td>Bad practice</td></tr>
140 <tr bgcolor="#eeeeee"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">Se: Class is Externalizable but doesn't define a void constructor</a></td><td>Bad practice</td></tr>
141 <tr bgcolor="#ffffff"><td><a href="#SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: The readResolve method must be declared with a return type of Object. </a></td><td>Bad practice</td></tr>
142 <tr bgcolor="#eeeeee"><td><a href="#SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Transient field that isn't set by deserialization. </a></td><td>Bad practice</td></tr>
143 <tr bgcolor="#ffffff"><td><a href="#SE_NO_SERIALVERSIONID">SnVI: Class is Serializable, but doesn't define serialVersionUID</a></td><td>Bad practice</td></tr>
144 <tr bgcolor="#eeeeee"><td><a href="#UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: Usage of GetResource may be unsafe if class is extended</a></td><td>Bad practice</td></tr>
145 <tr bgcolor="#ffffff"><td><a href="#BAC_BAD_APPLET_CONSTRUCTOR">BAC: Bad Applet Constructor relies on uninitialized AppletStub</a></td><td>Correctness</td></tr>
146 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_CAST">BC: Impossible cast</a></td><td>Correctness</td></tr>
147 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downcast</a></td><td>Correctness</td></tr>
148 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impossible downcast of toArray() result</a></td><td>Correctness</td></tr>
149 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof will always return false</a></td><td>Correctness</td></tr>
150 <tr bgcolor="#eeeeee"><td><a href="#BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of signed byte value</a></td><td>Correctness</td></tr>
151 <tr bgcolor="#ffffff"><td><a href="#BIT_AND">BIT: Incompatible bit masks</a></td><td>Correctness</td></tr>
152 <tr bgcolor="#eeeeee"><td><a href="#BIT_AND_ZZ">BIT: Check to see if ((...) & 0) == 0</a></td><td>Correctness</td></tr>
153 <tr bgcolor="#ffffff"><td><a href="#BIT_IOR">BIT: Incompatible bit masks</a></td><td>Correctness</td></tr>
154 <tr bgcolor="#eeeeee"><td><a href="#BIT_IOR_OF_SIGNED_BYTE">BIT: Bitwise OR of signed byte value</a></td><td>Correctness</td></tr>
155 <tr bgcolor="#ffffff"><td><a href="#BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for sign of bitwise operation</a></td><td>Correctness</td></tr>
156 <tr bgcolor="#eeeeee"><td><a href="#BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: Class overrides a method implemented in super class Adapter wrongly</a></td><td>Correctness</td></tr>
157 <tr bgcolor="#ffffff"><td><a href="#ICAST_BAD_SHIFT_AMOUNT">BSHIFT: 32 bit int shifted by an amount not in the range -31..31</a></td><td>Correctness</td></tr>
158 <tr bgcolor="#eeeeee"><td><a href="#BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR">Bx: Primitive value is unboxed and coerced for ternary operator</a></td><td>Correctness</td></tr>
159 <tr bgcolor="#ffffff"><td><a href="#CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareTo()/compare() returns Integer.MIN_VALUE</a></td><td>Correctness</td></tr>
160 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Useless increment in return statement</a></td><td>Correctness</td></tr>
161 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead store of class literal</a></td><td>Correctness</td></tr>
162 <tr bgcolor="#eeeeee"><td><a href="#DLS_OVERWRITTEN_INCREMENT">DLS: Overwritten increment</a></td><td>Correctness</td></tr>
163 <tr bgcolor="#ffffff"><td><a href="#DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed method arguments</a></td><td>Correctness</td></tr>
164 <tr bgcolor="#eeeeee"><td><a href="#DMI_BAD_MONTH">DMI: Bad constant value for month</a></td><td>Correctness</td></tr>
165 <tr bgcolor="#ffffff"><td><a href="#DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI: BigDecimal constructed from double that isn't represented precisely</a></td><td>Correctness</td></tr>
166 <tr bgcolor="#eeeeee"><td><a href="#DMI_CALLING_NEXT_FROM_HASNEXT">DMI: hasNext method invokes next</a></td><td>Correctness</td></tr>
167 <tr bgcolor="#ffffff"><td><a href="#DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES">DMI: Collections should not contain themselves</a></td><td>Correctness</td></tr>
168 <tr bgcolor="#eeeeee"><td><a href="#DMI_DOH">DMI: D'oh! A nonsensical method invocation</a></td><td>Correctness</td></tr>
169 <tr bgcolor="#ffffff"><td><a href="#DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocation of hashCode on an array</a></td><td>Correctness</td></tr>
170 <tr bgcolor="#eeeeee"><td><a href="#DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI: Double.longBitsToDouble invoked on an int</a></td><td>Correctness</td></tr>
171 <tr bgcolor="#ffffff"><td><a href="#DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuous call to collections</a></td><td>Correctness</td></tr>
172 <tr bgcolor="#eeeeee"><td><a href="#DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">Dm: Can't use reflection to check for presence of annotation without runtime retention</a></td><td>Correctness</td></tr>
173 <tr bgcolor="#ffffff"><td><a href="#DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR">Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor</a></td><td>Correctness</td></tr>
174 <tr bgcolor="#eeeeee"><td><a href="#DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS">Dm: Creation of ScheduledThreadPoolExecutor with zero core threads</a></td><td>Correctness</td></tr>
175 <tr bgcolor="#ffffff"><td><a href="#DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Useless/vacuous call to EasyMock method</a></td><td>Correctness</td></tr>
176 <tr bgcolor="#eeeeee"><td><a href="#EC_ARRAY_AND_NONARRAY">EC: equals() used to compare array and nonarray</a></td><td>Correctness</td></tr>
177 <tr bgcolor="#ffffff"><td><a href="#EC_BAD_ARRAY_COMPARE">EC: Invocation of equals() on an array, which is equivalent to ==</a></td><td>Correctness</td></tr>
178 <tr bgcolor="#eeeeee"><td><a href="#EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(...) used to compare incompatible arrays</a></td><td>Correctness</td></tr>
179 <tr bgcolor="#ffffff"><td><a href="#EC_NULL_ARG">EC: Call to equals(null)</a></td><td>Correctness</td></tr>
180 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_CLASS_AND_INTERFACE">EC: Call to equals() comparing unrelated class and interface</a></td><td>Correctness</td></tr>
181 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_INTERFACES">EC: Call to equals() comparing different interface types</a></td><td>Correctness</td></tr>
182 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_TYPES">EC: Call to equals() comparing different types</a></td><td>Correctness</td></tr>
183 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">EC: Using pointer equality to compare different types</a></td><td>Correctness</td></tr>
184 <tr bgcolor="#eeeeee"><td><a href="#EQ_ALWAYS_FALSE">Eq: equals method always returns false</a></td><td>Correctness</td></tr>
185 <tr bgcolor="#ffffff"><td><a href="#EQ_ALWAYS_TRUE">Eq: equals method always returns true</a></td><td>Correctness</td></tr>
186 <tr bgcolor="#eeeeee"><td><a href="#EQ_COMPARING_CLASS_NAMES">Eq: equals method compares class names rather than class objects</a></td><td>Correctness</td></tr>
187 <tr bgcolor="#ffffff"><td><a href="#EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covariant equals() method defined for enum</a></td><td>Correctness</td></tr>
188 <tr bgcolor="#eeeeee"><td><a href="#EQ_OTHER_NO_OBJECT">Eq: equals() method defined that doesn't override equals(Object)</a></td><td>Correctness</td></tr>
189 <tr bgcolor="#ffffff"><td><a href="#EQ_OTHER_USE_OBJECT">Eq: equals() method defined that doesn't override Object.equals(Object)</a></td><td>Correctness</td></tr>
190 <tr bgcolor="#eeeeee"><td><a href="#EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equals method overrides equals in superclass and may not be symmetric</a></td><td>Correctness</td></tr>
191 <tr bgcolor="#ffffff"><td><a href="#EQ_SELF_USE_OBJECT">Eq: Covariant equals() method defined, Object.equals(Object) inherited</a></td><td>Correctness</td></tr>
192 <tr bgcolor="#eeeeee"><td><a href="#FB_MISSING_EXPECTED_WARNING">FB: Missing expected or desired warning from FindBugs</a></td><td>Correctness</td></tr>
193 <tr bgcolor="#ffffff"><td><a href="#FB_UNEXPECTED_WARNING">FB: Unexpected/undesired warning from FindBugs</a></td><td>Correctness</td></tr>
194 <tr bgcolor="#eeeeee"><td><a href="#FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Doomed test for equality to NaN</a></td><td>Correctness</td></tr>
195 <tr bgcolor="#ffffff"><td><a href="#FL_MATH_USING_FLOAT_PRECISION">FL: Method performs math using floating point precision</a></td><td>Correctness</td></tr>
196 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format string placeholder incompatible with passed argument</a></td><td>Correctness</td></tr>
197 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION">FS: The type of a supplied argument doesn't match format specifier</a></td><td>Correctness</td></tr>
198 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED">FS: MessageFormat supplied where printf style format expected</a></td><td>Correctness</td></tr>
199 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS: More arguments are passed than are actually used in the format string</a></td><td>Correctness</td></tr>
200 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_ILLEGAL">FS: Illegal format string</a></td><td>Correctness</td></tr>
201 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Format string references missing argument</a></td><td>Correctness</td></tr>
202 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: No previous argument for format string</a></td><td>Correctness</td></tr>
203 <tr bgcolor="#ffffff"><td><a href="#GC_UNRELATED_TYPES">GC: No relationship between generic parameter and method argument</a></td><td>Correctness</td></tr>
204 <tr bgcolor="#eeeeee"><td><a href="#HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS">HE: Signature declares use of unhashable class in hashed construct</a></td><td>Correctness</td></tr>
205 <tr bgcolor="#ffffff"><td><a href="#HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class without a hashCode() method in a hashed data structure</a></td><td>Correctness</td></tr>
206 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INT_2_LONG_AS_INSTANT">ICAST: int value converted to long and used as absolute time</a></td><td>Correctness</td></tr>
207 <tr bgcolor="#ffffff"><td><a href="#ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICAST: Integral value cast to double and then passed to Math.ceil</a></td><td>Correctness</td></tr>
208 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICAST: int value cast to float and then passed to Math.round</a></td><td>Correctness</td></tr>
209 <tr bgcolor="#ffffff"><td><a href="#IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">IJU: JUnit assertion in run method will not be noticed by JUnit</a></td><td>Correctness</td></tr>
210 <tr bgcolor="#eeeeee"><td><a href="#IJU_BAD_SUITE_METHOD">IJU: TestCase declares a bad suite method </a></td><td>Correctness</td></tr>
211 <tr bgcolor="#ffffff"><td><a href="#IJU_NO_TESTS">IJU: TestCase has no tests</a></td><td>Correctness</td></tr>
212 <tr bgcolor="#eeeeee"><td><a href="#IJU_SETUP_NO_SUPER">IJU: TestCase defines setUp that doesn't call super.setUp()</a></td><td>Correctness</td></tr>
213 <tr bgcolor="#ffffff"><td><a href="#IJU_SUITE_NOT_STATIC">IJU: TestCase implements a non-static suite method </a></td><td>Correctness</td></tr>
214 <tr bgcolor="#eeeeee"><td><a href="#IJU_TEARDOWN_NO_SUPER">IJU: TestCase defines tearDown that doesn't call super.tearDown()</a></td><td>Correctness</td></tr>
215 <tr bgcolor="#ffffff"><td><a href="#IL_CONTAINER_ADDED_TO_ITSELF">IL: A collection is added to itself</a></td><td>Correctness</td></tr>
216 <tr bgcolor="#eeeeee"><td><a href="#IL_INFINITE_LOOP">IL: An apparent infinite loop</a></td><td>Correctness</td></tr>
217 <tr bgcolor="#ffffff"><td><a href="#IL_INFINITE_RECURSIVE_LOOP">IL: An apparent infinite recursive loop</a></td><td>Correctness</td></tr>
218 <tr bgcolor="#eeeeee"><td><a href="#IM_MULTIPLYING_RESULT_OF_IREM">IM: Integer multiply of result of integer remainder</a></td><td>Correctness</td></tr>
219 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad comparison of int value with long constant</a></td><td>Correctness</td></tr>
220 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT: Bad comparison of nonnegative value with negative constant</a></td><td>Correctness</td></tr>
221 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Bad comparison of signed byte</a></td><td>Correctness</td></tr>
222 <tr bgcolor="#eeeeee"><td><a href="#IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Doomed attempt to append to an object output stream</a></td><td>Correctness</td></tr>
223 <tr bgcolor="#ffffff"><td><a href="#IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: A parameter is dead upon entry to a method but overwritten</a></td><td>Correctness</td></tr>
224 <tr bgcolor="#eeeeee"><td><a href="#MF_CLASS_MASKS_FIELD">MF: Class defines field that masks a superclass field</a></td><td>Correctness</td></tr>
225 <tr bgcolor="#ffffff"><td><a href="#MF_METHOD_MASKS_FIELD">MF: Method defines a variable that obscures a field</a></td><td>Correctness</td></tr>
226 <tr bgcolor="#eeeeee"><td><a href="#NP_ALWAYS_NULL">NP: Null pointer dereference</a></td><td>Correctness</td></tr>
227 <tr bgcolor="#ffffff"><td><a href="#NP_ALWAYS_NULL_EXCEPTION">NP: Null pointer dereference in method on exception path</a></td><td>Correctness</td></tr>
228 <tr bgcolor="#eeeeee"><td><a href="#NP_ARGUMENT_MIGHT_BE_NULL">NP: Method does not check for null argument</a></td><td>Correctness</td></tr>
229 <tr bgcolor="#ffffff"><td><a href="#NP_CLOSING_NULL">NP: close() invoked on a value that is always null</a></td><td>Correctness</td></tr>
230 <tr bgcolor="#eeeeee"><td><a href="#NP_GUARANTEED_DEREF">NP: Null value is guaranteed to be dereferenced</a></td><td>Correctness</td></tr>
231 <tr bgcolor="#ffffff"><td><a href="#NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: Value is null and guaranteed to be dereferenced on exception path</a></td><td>Correctness</td></tr>
232 <tr bgcolor="#eeeeee"><td><a href="#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP: Nonnull field is not initialized</a></td><td>Correctness</td></tr>
233 <tr bgcolor="#ffffff"><td><a href="#NP_NONNULL_PARAM_VIOLATION">NP: Method call passes null to a nonnull parameter </a></td><td>Correctness</td></tr>
234 <tr bgcolor="#eeeeee"><td><a href="#NP_NONNULL_RETURN_VIOLATION">NP: Method may return null, but is declared @NonNull</a></td><td>Correctness</td></tr>
235 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_INSTANCEOF">NP: A known null value is checked to see if it is an instance of a type</a></td><td>Correctness</td></tr>
236 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH">NP: Possible null pointer dereference</a></td><td>Correctness</td></tr>
237 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible null pointer dereference in method on exception path</a></td><td>Correctness</td></tr>
238 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_PARAM_DEREF">NP: Method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
239 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP: Method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
240 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Non-virtual method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
241 <tr bgcolor="#ffffff"><td><a href="#NP_STORE_INTO_NONNULL_FIELD">NP: Store of null value into field annotated NonNull</a></td><td>Correctness</td></tr>
242 <tr bgcolor="#eeeeee"><td><a href="#NP_UNWRITTEN_FIELD">NP: Read of unwritten field</a></td><td>Correctness</td></tr>
243 <tr bgcolor="#ffffff"><td><a href="#NM_BAD_EQUAL">Nm: Class defines equal(Object); should it be equals(Object)?</a></td><td>Correctness</td></tr>
244 <tr bgcolor="#eeeeee"><td><a href="#NM_LCASE_HASHCODE">Nm: Class defines hashcode(); should it be hashCode()?</a></td><td>Correctness</td></tr>
245 <tr bgcolor="#ffffff"><td><a href="#NM_LCASE_TOSTRING">Nm: Class defines tostring(); should it be toString()?</a></td><td>Correctness</td></tr>
246 <tr bgcolor="#eeeeee"><td><a href="#NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Apparent method/constructor confusion</a></td><td>Correctness</td></tr>
247 <tr bgcolor="#ffffff"><td><a href="#NM_VERY_CONFUSING">Nm: Very confusing method names</a></td><td>Correctness</td></tr>
248 <tr bgcolor="#eeeeee"><td><a href="#NM_WRONG_PACKAGE">Nm: Method doesn't override method in superclass due to wrong package for parameter</a></td><td>Correctness</td></tr>
249 <tr bgcolor="#ffffff"><td><a href="#QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Method assigns boolean literal in boolean expression</a></td><td>Correctness</td></tr>
250 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON">RC: Suspicious reference comparison</a></td><td>Correctness</td></tr>
251 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE">RCN: Nullcheck of value previously dereferenced</a></td><td>Correctness</td></tr>
252 <tr bgcolor="#eeeeee"><td><a href="#RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Invalid syntax for regular expression</a></td><td>Correctness</td></tr>
253 <tr bgcolor="#ffffff"><td><a href="#RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION">RE: File.separator used for regular expression</a></td><td>Correctness</td></tr>
254 <tr bgcolor="#eeeeee"><td><a href="#RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." or "|" used for regular expression</a></td><td>Correctness</td></tr>
255 <tr bgcolor="#ffffff"><td><a href="#RV_01_TO_INT">RV: Random value from 0 to 1 is coerced to the integer 0</a></td><td>Correctness</td></tr>
256 <tr bgcolor="#eeeeee"><td><a href="#RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attempt to compute absolute value of signed 32-bit hashcode </a></td><td>Correctness</td></tr>
257 <tr bgcolor="#ffffff"><td><a href="#RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad attempt to compute absolute value of signed random integer</a></td><td>Correctness</td></tr>
258 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV: Code checks for specific values returned by compareTo</a></td><td>Correctness</td></tr>
259 <tr bgcolor="#ffffff"><td><a href="#RV_EXCEPTION_NOT_THROWN">RV: Exception created and dropped rather than thrown</a></td><td>Correctness</td></tr>
260 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED">RV: Method ignores return value</a></td><td>Correctness</td></tr>
261 <tr bgcolor="#ffffff"><td><a href="#RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated conditional tests</a></td><td>Correctness</td></tr>
262 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_ASSIGNMENT">SA: Self assignment of field</a></td><td>Correctness</td></tr>
263 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_SELF_COMPARISON">SA: Self comparison of field with itself</a></td><td>Correctness</td></tr>
264 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_COMPUTATION">SA: Nonsensical self computation involving a field (e.g., x & x)</a></td><td>Correctness</td></tr>
265 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA: Self assignment of local rather than assignment to field</a></td><td>Correctness</td></tr>
266 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_SELF_COMPARISON">SA: Self comparison of value with itself</a></td><td>Correctness</td></tr>
267 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical self computation involving a variable (e.g., x & x)</a></td><td>Correctness</td></tr>
268 <tr bgcolor="#eeeeee"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF: Dead store due to switch statement fall through</a></td><td>Correctness</td></tr>
269 <tr bgcolor="#ffffff"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW">SF: Dead store due to switch statement fall through to throw</a></td><td>Correctness</td></tr>
270 <tr bgcolor="#eeeeee"><td><a href="#SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly embrace of non-static inner class and thread local</a></td><td>Correctness</td></tr>
271 <tr bgcolor="#ffffff"><td><a href="#SIO_SUPERFLUOUS_INSTANCEOF">SIO: Unnecessary type check done using instanceof operator</a></td><td>Correctness</td></tr>
272 <tr bgcolor="#eeeeee"><td><a href="#SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Method attempts to access a prepared statement parameter with index 0</a></td><td>Correctness</td></tr>
273 <tr bgcolor="#ffffff"><td><a href="#SQL_BAD_RESULTSET_ACCESS">SQL: Method attempts to access a result set field with index 0</a></td><td>Correctness</td></tr>
274 <tr bgcolor="#eeeeee"><td><a href="#STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Unneeded use of currentThread() call, to call interrupted() </a></td><td>Correctness</td></tr>
275 <tr bgcolor="#ffffff"><td><a href="#STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Static Thread.interrupted() method invoked on thread instance</a></td><td>Correctness</td></tr>
276 <tr bgcolor="#eeeeee"><td><a href="#SE_METHOD_MUST_BE_PRIVATE">Se: Method must be private in order for serialization to work</a></td><td>Correctness</td></tr>
277 <tr bgcolor="#ffffff"><td><a href="#SE_READ_RESOLVE_IS_STATIC">Se: The readResolve method must not be declared as a static method. </a></td><td>Correctness</td></tr>
278 <tr bgcolor="#eeeeee"><td><a href="#TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required</a></td><td>Correctness</td></tr>
279 <tr bgcolor="#ffffff"><td><a href="#TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ: Comparing values with incompatible type qualifiers</a></td><td>Correctness</td></tr>
280 <tr bgcolor="#eeeeee"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier</a></td><td>Correctness</td></tr>
281 <tr bgcolor="#ffffff"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier</a></td><td>Correctness</td></tr>
282 <tr bgcolor="#eeeeee"><td><a href="#TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required</a></td><td>Correctness</td></tr>
283 <tr bgcolor="#ffffff"><td><a href="#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ: Value without a type qualifier used where a value is required to have that qualifier</a></td><td>Correctness</td></tr>
284 <tr bgcolor="#eeeeee"><td><a href="#UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">UMAC: Uncallable method defined in anonymous class</a></td><td>Correctness</td></tr>
285 <tr bgcolor="#ffffff"><td><a href="#UR_UNINIT_READ">UR: Uninitialized read of field in constructor</a></td><td>Correctness</td></tr>
286 <tr bgcolor="#eeeeee"><td><a href="#UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR">UR: Uninitialized read of field method called from constructor of superclass</a></td><td>Correctness</td></tr>
287 <tr bgcolor="#ffffff"><td><a href="#DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">USELESS_STRING: Invocation of toString on an unnamed array</a></td><td>Correctness</td></tr>
288 <tr bgcolor="#eeeeee"><td><a href="#DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRING: Invocation of toString on an array</a></td><td>Correctness</td></tr>
289 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">USELESS_STRING: Array formatted in useless way using format string</a></td><td>Correctness</td></tr>
290 <tr bgcolor="#eeeeee"><td><a href="#UWF_NULL_FIELD">UwF: Field only ever set to null</a></td><td>Correctness</td></tr>
291 <tr bgcolor="#ffffff"><td><a href="#UWF_UNWRITTEN_FIELD">UwF: Unwritten field</a></td><td>Correctness</td></tr>
292 <tr bgcolor="#eeeeee"><td><a href="#VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">VA: Primitive array passed to function expecting a variable number of object arguments</a></td><td>Correctness</td></tr>
293 <tr bgcolor="#ffffff"><td><a href="#VR_UNRESOLVABLE_REFERENCE">VR: Class makes reference to unresolvable class or method</a></td><td>Correctness</td></tr>
294 <tr bgcolor="#eeeeee"><td><a href="#LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Potential lost logger changes due to weak reference in OpenJDK</a></td><td>Experimental</td></tr>
295 <tr bgcolor="#ffffff"><td><a href="#OBL_UNSATISFIED_OBLIGATION">OBL: Method may fail to clean up stream or resource</a></td><td>Experimental</td></tr>
296 <tr bgcolor="#eeeeee"><td><a href="#OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL: Method may fail to clean up stream or resource on checked exception</a></td><td>Experimental</td></tr>
297 <tr bgcolor="#ffffff"><td><a href="#TESTING">TEST: Testing</a></td><td>Experimental</td></tr>
298 <tr bgcolor="#eeeeee"><td><a href="#DM_CONVERT_CASE">Dm: Consider using Locale parameterized version of invoked method</a></td><td>Internationalization</td></tr>
299 <tr bgcolor="#ffffff"><td><a href="#DM_DEFAULT_ENCODING">Dm: Reliance on default encoding</a></td><td>Internationalization</td></tr>
300 <tr bgcolor="#eeeeee"><td><a href="#DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">DP: Classloaders should only be created inside doPrivileged block</a></td><td>Malicious code vulnerability</td></tr>
301 <tr bgcolor="#ffffff"><td><a href="#DP_DO_INSIDE_DO_PRIVILEGED">DP: Method invoked that should be only be invoked inside a doPrivileged block</a></td><td>Malicious code vulnerability</td></tr>
302 <tr bgcolor="#eeeeee"><td><a href="#EI_EXPOSE_REP">EI: May expose internal representation by returning reference to mutable object</a></td><td>Malicious code vulnerability</td></tr>
303 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_REP2">EI2: May expose internal representation by incorporating reference to mutable object</a></td><td>Malicious code vulnerability</td></tr>
304 <tr bgcolor="#eeeeee"><td><a href="#FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Finalizer should be protected, not public</a></td><td>Malicious code vulnerability</td></tr>
305 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_STATIC_REP2">MS: May expose internal static state by storing a mutable object into a static field</a></td><td>Malicious code vulnerability</td></tr>
306 <tr bgcolor="#eeeeee"><td><a href="#MS_CANNOT_BE_FINAL">MS: Field isn't final and can't be protected from malicious code</a></td><td>Malicious code vulnerability</td></tr>
307 <tr bgcolor="#ffffff"><td><a href="#MS_EXPOSE_REP">MS: Public static method may expose internal representation by returning array</a></td><td>Malicious code vulnerability</td></tr>
308 <tr bgcolor="#eeeeee"><td><a href="#MS_FINAL_PKGPROTECT">MS: Field should be both final and package protected</a></td><td>Malicious code vulnerability</td></tr>
309 <tr bgcolor="#ffffff"><td><a href="#MS_MUTABLE_ARRAY">MS: Field is a mutable array</a></td><td>Malicious code vulnerability</td></tr>
310 <tr bgcolor="#eeeeee"><td><a href="#MS_MUTABLE_HASHTABLE">MS: Field is a mutable Hashtable</a></td><td>Malicious code vulnerability</td></tr>
311 <tr bgcolor="#ffffff"><td><a href="#MS_OOI_PKGPROTECT">MS: Field should be moved out of an interface and made package protected</a></td><td>Malicious code vulnerability</td></tr>
312 <tr bgcolor="#eeeeee"><td><a href="#MS_PKGPROTECT">MS: Field should be package protected</a></td><td>Malicious code vulnerability</td></tr>
313 <tr bgcolor="#ffffff"><td><a href="#MS_SHOULD_BE_FINAL">MS: Field isn't final but should be</a></td><td>Malicious code vulnerability</td></tr>
314 <tr bgcolor="#eeeeee"><td><a href="#MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Field isn't final but should be refactored to be so</a></td><td>Malicious code vulnerability</td></tr>
315 <tr bgcolor="#ffffff"><td><a href="#AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT: Sequence of calls to concurrent abstraction may not be atomic</a></td><td>Multithreaded correctness</td></tr>
316 <tr bgcolor="#eeeeee"><td><a href="#DC_DOUBLECHECK">DC: Possible double check of field</a></td><td>Multithreaded correctness</td></tr>
317 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchronization on Boolean</a></td><td>Multithreaded correctness</td></tr>
318 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive</a></td><td>Multithreaded correctness</td></tr>
319 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: Synchronization on interned String </a></td><td>Multithreaded correctness</td></tr>
320 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive values</a></td><td>Multithreaded correctness</td></tr>
321 <tr bgcolor="#ffffff"><td><a href="#DM_MONITOR_WAIT_ON_CONDITION">Dm: Monitor wait() called on Condition</a></td><td>Multithreaded correctness</td></tr>
322 <tr bgcolor="#eeeeee"><td><a href="#DM_USELESS_THREAD">Dm: A thread was created using the default empty run method</a></td><td>Multithreaded correctness</td></tr>
323 <tr bgcolor="#ffffff"><td><a href="#ESync_EMPTY_SYNC">ESync: Empty synchronized block</a></td><td>Multithreaded correctness</td></tr>
324 <tr bgcolor="#eeeeee"><td><a href="#IS2_INCONSISTENT_SYNC">IS: Inconsistent synchronization</a></td><td>Multithreaded correctness</td></tr>
325 <tr bgcolor="#ffffff"><td><a href="#IS_FIELD_NOT_GUARDED">IS: Field not guarded against concurrent access</a></td><td>Multithreaded correctness</td></tr>
326 <tr bgcolor="#eeeeee"><td><a href="#JLM_JSR166_LOCK_MONITORENTER">JLM: Synchronization performed on Lock</a></td><td>Multithreaded correctness</td></tr>
327 <tr bgcolor="#ffffff"><td><a href="#JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM: Synchronization performed on util.concurrent instance</a></td><td>Multithreaded correctness</td></tr>
328 <tr bgcolor="#eeeeee"><td><a href="#JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JLM: Using monitor style wait methods on util.concurrent abstraction</a></td><td>Multithreaded correctness</td></tr>
329 <tr bgcolor="#ffffff"><td><a href="#LI_LAZY_INIT_STATIC">LI: Incorrect lazy initialization of static field</a></td><td>Multithreaded correctness</td></tr>
330 <tr bgcolor="#eeeeee"><td><a href="#LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect lazy initialization and update of static field</a></td><td>Multithreaded correctness</td></tr>
331 <tr bgcolor="#ffffff"><td><a href="#ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD">ML: Synchronization on field in futile attempt to guard that field</a></td><td>Multithreaded correctness</td></tr>
332 <tr bgcolor="#eeeeee"><td><a href="#ML_SYNC_ON_UPDATED_FIELD">ML: Method synchronizes on an updated field</a></td><td>Multithreaded correctness</td></tr>
333 <tr bgcolor="#ffffff"><td><a href="#MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable servlet field</a></td><td>Multithreaded correctness</td></tr>
334 <tr bgcolor="#eeeeee"><td><a href="#MWN_MISMATCHED_NOTIFY">MWN: Mismatched notify()</a></td><td>Multithreaded correctness</td></tr>
335 <tr bgcolor="#ffffff"><td><a href="#MWN_MISMATCHED_WAIT">MWN: Mismatched wait()</a></td><td>Multithreaded correctness</td></tr>
336 <tr bgcolor="#eeeeee"><td><a href="#NN_NAKED_NOTIFY">NN: Naked notify</a></td><td>Multithreaded correctness</td></tr>
337 <tr bgcolor="#ffffff"><td><a href="#NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchronize and null check on the same field.</a></td><td>Multithreaded correctness</td></tr>
338 <tr bgcolor="#eeeeee"><td><a href="#NO_NOTIFY_NOT_NOTIFYALL">No: Using notify() rather than notifyAll()</a></td><td>Multithreaded correctness</td></tr>
339 <tr bgcolor="#ffffff"><td><a href="#RS_READOBJECT_SYNC">RS: Class's readObject() method is synchronized</a></td><td>Multithreaded correctness</td></tr>
340 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused</a></td><td>Multithreaded correctness</td></tr>
341 <tr bgcolor="#ffffff"><td><a href="#RU_INVOKE_RUN">Ru: Invokes run on a thread (did you mean to start it instead?)</a></td><td>Multithreaded correctness</td></tr>
342 <tr bgcolor="#eeeeee"><td><a href="#SC_START_IN_CTOR">SC: Constructor invokes Thread.start()</a></td><td>Multithreaded correctness</td></tr>
343 <tr bgcolor="#ffffff"><td><a href="#SP_SPIN_ON_FIELD">SP: Method spins on field</a></td><td>Multithreaded correctness</td></tr>
344 <tr bgcolor="#eeeeee"><td><a href="#STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">STCAL: Call to static Calendar</a></td><td>Multithreaded correctness</td></tr>
345 <tr bgcolor="#ffffff"><td><a href="#STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE">STCAL: Call to static DateFormat</a></td><td>Multithreaded correctness</td></tr>
346 <tr bgcolor="#eeeeee"><td><a href="#STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Static Calendar field</a></td><td>Multithreaded correctness</td></tr>
347 <tr bgcolor="#ffffff"><td><a href="#STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">STCAL: Static DateFormat</a></td><td>Multithreaded correctness</td></tr>
348 <tr bgcolor="#eeeeee"><td><a href="#SWL_SLEEP_WITH_LOCK_HELD">SWL: Method calls Thread.sleep() with a lock held</a></td><td>Multithreaded correctness</td></tr>
349 <tr bgcolor="#ffffff"><td><a href="#TLW_TWO_LOCK_WAIT">TLW: Wait with two locks held</a></td><td>Multithreaded correctness</td></tr>
350 <tr bgcolor="#eeeeee"><td><a href="#UG_SYNC_SET_UNSYNC_GET">UG: Unsynchronized get method, synchronized set method</a></td><td>Multithreaded correctness</td></tr>
351 <tr bgcolor="#ffffff"><td><a href="#UL_UNRELEASED_LOCK">UL: Method does not release lock on all paths</a></td><td>Multithreaded correctness</td></tr>
352 <tr bgcolor="#eeeeee"><td><a href="#UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: Method does not release lock on all exception paths</a></td><td>Multithreaded correctness</td></tr>
353 <tr bgcolor="#ffffff"><td><a href="#UW_UNCOND_WAIT">UW: Unconditional wait</a></td><td>Multithreaded correctness</td></tr>
354 <tr bgcolor="#eeeeee"><td><a href="#VO_VOLATILE_INCREMENT">VO: An increment to a volatile field isn't atomic</a></td><td>Multithreaded correctness</td></tr>
355 <tr bgcolor="#ffffff"><td><a href="#VO_VOLATILE_REFERENCE_TO_ARRAY">VO: A volatile reference to an array doesn't treat the array elements as volatile</a></td><td>Multithreaded correctness</td></tr>
356 <tr bgcolor="#eeeeee"><td><a href="#WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL">WL: Synchronization on getClass rather than class literal</a></td><td>Multithreaded correctness</td></tr>
357 <tr bgcolor="#ffffff"><td><a href="#WS_WRITEOBJECT_SYNC">WS: Class's writeObject() method is synchronized but nothing else is</a></td><td>Multithreaded correctness</td></tr>
358 <tr bgcolor="#eeeeee"><td><a href="#WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await() not in loop </a></td><td>Multithreaded correctness</td></tr>
359 <tr bgcolor="#ffffff"><td><a href="#WA_NOT_IN_LOOP">Wa: Wait not in loop </a></td><td>Multithreaded correctness</td></tr>
360 <tr bgcolor="#eeeeee"><td><a href="#NOISE_FIELD_REFERENCE">NOISE: Bogus warning about a field reference</a></td><td>Bogus random noise</td></tr>
361 <tr bgcolor="#ffffff"><td><a href="#NOISE_METHOD_CALL">NOISE: Bogus warning about a method call</a></td><td>Bogus random noise</td></tr>
362 <tr bgcolor="#eeeeee"><td><a href="#NOISE_NULL_DEREFERENCE">NOISE: Bogus warning about a null pointer dereference</a></td><td>Bogus random noise</td></tr>
363 <tr bgcolor="#ffffff"><td><a href="#NOISE_OPERATION">NOISE: Bogus warning about an operation</a></td><td>Bogus random noise</td></tr>
364 <tr bgcolor="#eeeeee"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive value is boxed and then immediately unboxed</a></td><td>Performance</td></tr>
365 <tr bgcolor="#ffffff"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION">Bx: Primitive value is boxed then unboxed to perform primitive coercion</a></td><td>Performance</td></tr>
366 <tr bgcolor="#eeeeee"><td><a href="#BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed value is unboxed and then immediately reboxed</a></td><td>Performance</td></tr>
367 <tr bgcolor="#ffffff"><td><a href="#DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/unboxing to parse a primitive</a></td><td>Performance</td></tr>
368 <tr bgcolor="#eeeeee"><td><a href="#DM_BOXED_PRIMITIVE_TOSTRING">Bx: Method allocates a boxed primitive just to call toString</a></td><td>Performance</td></tr>
369 <tr bgcolor="#ffffff"><td><a href="#DM_FP_NUMBER_CTOR">Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead</a></td><td>Performance</td></tr>
370 <tr bgcolor="#eeeeee"><td><a href="#DM_NUMBER_CTOR">Bx: Method invokes inefficient Number constructor; use static valueOf instead</a></td><td>Performance</td></tr>
371 <tr bgcolor="#ffffff"><td><a href="#DMI_BLOCKING_METHODS_ON_URL">Dm: The equals and hashCode methods of URL are blocking</a></td><td>Performance</td></tr>
372 <tr bgcolor="#eeeeee"><td><a href="#DMI_COLLECTION_OF_URLS">Dm: Maps and sets of URLs can be performance hogs</a></td><td>Performance</td></tr>
373 <tr bgcolor="#ffffff"><td><a href="#DM_BOOLEAN_CTOR">Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead</a></td><td>Performance</td></tr>
374 <tr bgcolor="#eeeeee"><td><a href="#DM_GC">Dm: Explicit garbage collection; extremely dubious except in benchmarking code</a></td><td>Performance</td></tr>
375 <tr bgcolor="#ffffff"><td><a href="#DM_NEW_FOR_GETCLASS">Dm: Method allocates an object, only to get the class object</a></td><td>Performance</td></tr>
376 <tr bgcolor="#eeeeee"><td><a href="#DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer</a></td><td>Performance</td></tr>
377 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_CTOR">Dm: Method invokes inefficient new String(String) constructor</a></td><td>Performance</td></tr>
378 <tr bgcolor="#eeeeee"><td><a href="#DM_STRING_TOSTRING">Dm: Method invokes toString() method on a String</a></td><td>Performance</td></tr>
379 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_VOID_CTOR">Dm: Method invokes inefficient new String() constructor</a></td><td>Performance</td></tr>
380 <tr bgcolor="#eeeeee"><td><a href="#HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge string constants is duplicated across multiple class files</a></td><td>Performance</td></tr>
381 <tr bgcolor="#ffffff"><td><a href="#IMA_INEFFICIENT_MEMBER_ACCESS">IMA: Method accesses a private member variable of owning class</a></td><td>Performance</td></tr>
382 <tr bgcolor="#eeeeee"><td><a href="#ITA_INEFFICIENT_TO_ARRAY">ITA: Method uses toArray() with zero-length array argument</a></td><td>Performance</td></tr>
383 <tr bgcolor="#ffffff"><td><a href="#SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: Method concatenates strings using + in a loop</a></td><td>Performance</td></tr>
384 <tr bgcolor="#eeeeee"><td><a href="#SIC_INNER_SHOULD_BE_STATIC">SIC: Should be a static inner class</a></td><td>Performance</td></tr>
385 <tr bgcolor="#ffffff"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Could be refactored into a named static inner class</a></td><td>Performance</td></tr>
386 <tr bgcolor="#eeeeee"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC: Could be refactored into a static inner class</a></td><td>Performance</td></tr>
387 <tr bgcolor="#ffffff"><td><a href="#SS_SHOULD_BE_STATIC">SS: Unread field: should this field be static?</a></td><td>Performance</td></tr>
388 <tr bgcolor="#eeeeee"><td><a href="#UM_UNNECESSARY_MATH">UM: Method calls static Math class method on a constant value</a></td><td>Performance</td></tr>
389 <tr bgcolor="#ffffff"><td><a href="#UPM_UNCALLED_PRIVATE_METHOD">UPM: Private method is never called</a></td><td>Performance</td></tr>
390 <tr bgcolor="#eeeeee"><td><a href="#URF_UNREAD_FIELD">UrF: Unread field</a></td><td>Performance</td></tr>
391 <tr bgcolor="#ffffff"><td><a href="#UUF_UNUSED_FIELD">UuF: Unused field</a></td><td>Performance</td></tr>
392 <tr bgcolor="#eeeeee"><td><a href="#WMI_WRONG_MAP_ITERATOR">WMI: Inefficient use of keySet iterator instead of entrySet iterator</a></td><td>Performance</td></tr>
393 <tr bgcolor="#ffffff"><td><a href="#DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded constant database password</a></td><td>Security</td></tr>
394 <tr bgcolor="#eeeeee"><td><a href="#DMI_EMPTY_DB_PASSWORD">Dm: Empty database password</a></td><td>Security</td></tr>
395 <tr bgcolor="#ffffff"><td><a href="#HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP cookie formed from untrusted input</a></td><td>Security</td></tr>
396 <tr bgcolor="#eeeeee"><td><a href="#HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: HTTP Response splitting vulnerability</a></td><td>Security</td></tr>
397 <tr bgcolor="#ffffff"><td><a href="#PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute path traversal in servlet</a></td><td>Security</td></tr>
398 <tr bgcolor="#eeeeee"><td><a href="#PT_RELATIVE_PATH_TRAVERSAL">PT: Relative path traversal in servlet</a></td><td>Security</td></tr>
399 <tr bgcolor="#ffffff"><td><a href="#SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQL: Nonconstant string passed to execute method on an SQL statement</a></td><td>Security</td></tr>
400 <tr bgcolor="#eeeeee"><td><a href="#SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING">SQL: A prepared statement is generated from a nonconstant String</a></td><td>Security</td></tr>
401 <tr bgcolor="#ffffff"><td><a href="#XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JSP reflected cross site scripting vulnerability</a></td><td>Security</td></tr>
402 <tr bgcolor="#eeeeee"><td><a href="#XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Servlet reflected cross site scripting vulnerability in error page</a></td><td>Security</td></tr>
403 <tr bgcolor="#ffffff"><td><a href="#XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS: Servlet reflected cross site scripting vulnerability</a></td><td>Security</td></tr>
404 <tr bgcolor="#eeeeee"><td><a href="#BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Questionable cast to abstract collection </a></td><td>Dodgy code</td></tr>
405 <tr bgcolor="#ffffff"><td><a href="#BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Questionable cast to concrete collection</a></td><td>Dodgy code</td></tr>
406 <tr bgcolor="#eeeeee"><td><a href="#BC_UNCONFIRMED_CAST">BC: Unchecked/unconfirmed cast</a></td><td>Dodgy code</td></tr>
407 <tr bgcolor="#ffffff"><td><a href="#BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unchecked/unconfirmed cast of return value from method</a></td><td>Dodgy code</td></tr>
408 <tr bgcolor="#eeeeee"><td><a href="#BC_VACUOUS_INSTANCEOF">BC: instanceof will always return true</a></td><td>Dodgy code</td></tr>
409 <tr bgcolor="#ffffff"><td><a href="#ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSHIFT: Unsigned right shift cast to short/byte</a></td><td>Dodgy code</td></tr>
410 <tr bgcolor="#eeeeee"><td><a href="#CD_CIRCULAR_DEPENDENCY">CD: Test for circular dependencies among classes</a></td><td>Dodgy code</td></tr>
411 <tr bgcolor="#ffffff"><td><a href="#CI_CONFUSED_INHERITANCE">CI: Class is final but declares protected field</a></td><td>Dodgy code</td></tr>
412 <tr bgcolor="#eeeeee"><td><a href="#DB_DUPLICATE_BRANCHES">DB: Method uses the same code for two branches</a></td><td>Dodgy code</td></tr>
413 <tr bgcolor="#ffffff"><td><a href="#DB_DUPLICATE_SWITCH_CLAUSES">DB: Method uses the same code for two switch clauses</a></td><td>Dodgy code</td></tr>
414 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE">DLS: Dead store to local variable</a></td><td>Dodgy code</td></tr>
415 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless assignment in return statement</a></td><td>Dodgy code</td></tr>
416 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Dead store of null to local variable</a></td><td>Dodgy code</td></tr>
417 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dead store to local variable that shadows field</a></td><td>Dodgy code</td></tr>
418 <tr bgcolor="#eeeeee"><td><a href="#DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Code contains a hard coded reference to an absolute pathname</a></td><td>Dodgy code</td></tr>
419 <tr bgcolor="#ffffff"><td><a href="#DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Non serializable object written to ObjectOutput</a></td><td>Dodgy code</td></tr>
420 <tr bgcolor="#eeeeee"><td><a href="#DMI_USELESS_SUBSTRING">DMI: Invocation of substring(0), which returns the original value</a></td><td>Dodgy code</td></tr>
421 <tr bgcolor="#ffffff"><td><a href="#DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">Dm: Thread passed where Runnable expected</a></td><td>Dodgy code</td></tr>
422 <tr bgcolor="#eeeeee"><td><a href="#DMI_UNSUPPORTED_METHOD">Dm: Call to unsupported method</a></td><td>Dodgy code</td></tr>
423 <tr bgcolor="#ffffff"><td><a href="#EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't override equals in superclass</a></td><td>Dodgy code</td></tr>
424 <tr bgcolor="#eeeeee"><td><a href="#EQ_UNUSUAL">Eq: Unusual equals method </a></td><td>Dodgy code</td></tr>
425 <tr bgcolor="#ffffff"><td><a href="#FE_FLOATING_POINT_EQUALITY">FE: Test for floating point equality</a></td><td>Dodgy code</td></tr>
426 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">FS: Non-Boolean argument formatted using %b format specifier</a></td><td>Dodgy code</td></tr>
427 <tr bgcolor="#ffffff"><td><a href="#IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">IA: Potentially ambiguous invocation of either an inherited or outer method</a></td><td>Dodgy code</td></tr>
428 <tr bgcolor="#eeeeee"><td><a href="#IC_INIT_CIRCULARITY">IC: Initialization circularity</a></td><td>Dodgy code</td></tr>
429 <tr bgcolor="#ffffff"><td><a href="#ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Integral division result cast to double or float</a></td><td>Dodgy code</td></tr>
430 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST: Result of integer multiplication cast to long</a></td><td>Dodgy code</td></tr>
431 <tr bgcolor="#ffffff"><td><a href="#IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: Computation of average could overflow</a></td><td>Dodgy code</td></tr>
432 <tr bgcolor="#eeeeee"><td><a href="#IM_BAD_CHECK_FOR_ODD">IM: Check for oddness that won't work for negative numbers </a></td><td>Dodgy code</td></tr>
433 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_REM_BY_1">INT: Integer remainder modulo 1</a></td><td>Dodgy code</td></tr>
434 <tr bgcolor="#eeeeee"><td><a href="#INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit mask operation on integer value</a></td><td>Dodgy code</td></tr>
435 <tr bgcolor="#ffffff"><td><a href="#INT_VACUOUS_COMPARISON">INT: Vacuous comparison of integer value</a></td><td>Dodgy code</td></tr>
436 <tr bgcolor="#eeeeee"><td><a href="#MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: Class extends Servlet class and uses instance variables</a></td><td>Dodgy code</td></tr>
437 <tr bgcolor="#ffffff"><td><a href="#MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: Class extends Struts Action class and uses instance variables</a></td><td>Dodgy code</td></tr>
438 <tr bgcolor="#eeeeee"><td><a href="#NP_DEREFERENCE_OF_READLINE_VALUE">NP: Dereference of the result of readLine() without nullcheck</a></td><td>Dodgy code</td></tr>
439 <tr bgcolor="#ffffff"><td><a href="#NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Immediate dereference of the result of readLine()</a></td><td>Dodgy code</td></tr>
440 <tr bgcolor="#eeeeee"><td><a href="#NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Load of known null value</a></td><td>Dodgy code</td></tr>
441 <tr bgcolor="#ffffff"><td><a href="#NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP: Method tightens nullness annotation on parameter</a></td><td>Dodgy code</td></tr>
442 <tr bgcolor="#eeeeee"><td><a href="#NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Method relaxes nullness annotation on return value</a></td><td>Dodgy code</td></tr>
443 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP: Possible null pointer dereference due to return value of called method</a></td><td>Dodgy code</td></tr>
444 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP: Possible null pointer dereference on branch that might be infeasible</a></td><td>Dodgy code</td></tr>
445 <tr bgcolor="#ffffff"><td><a href="#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP: Parameter must be nonnull but is marked as nullable</a></td><td>Dodgy code</td></tr>
446 <tr bgcolor="#eeeeee"><td><a href="#NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP: Read of unwritten public or protected field</a></td><td>Dodgy code</td></tr>
447 <tr bgcolor="#ffffff"><td><a href="#NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentially dangerous use of non-short-circuit logic</a></td><td>Dodgy code</td></tr>
448 <tr bgcolor="#eeeeee"><td><a href="#NS_NON_SHORT_CIRCUIT">NS: Questionable use of non-short-circuit logic</a></td><td>Dodgy code</td></tr>
449 <tr bgcolor="#ffffff"><td><a href="#PS_PUBLIC_SEMAPHORES">PS: Class exposes synchronization and semaphores in its public interface</a></td><td>Dodgy code</td></tr>
450 <tr bgcolor="#eeeeee"><td><a href="#PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Consider returning a zero length array rather than null</a></td><td>Dodgy code</td></tr>
451 <tr bgcolor="#ffffff"><td><a href="#QF_QUESTIONABLE_FOR_LOOP">QF: Complicated, subtle or wrong increment in for-loop </a></td><td>Dodgy code</td></tr>
452 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">RCN: Redundant comparison of non-null value to null</a></td><td>Dodgy code</td></tr>
453 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RCN: Redundant comparison of two null values</a></td><td>Dodgy code</td></tr>
454 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RCN: Redundant nullcheck of value known to be non-null</a></td><td>Dodgy code</td></tr>
455 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN: Redundant nullcheck of value known to be null</a></td><td>Dodgy code</td></tr>
456 <tr bgcolor="#eeeeee"><td><a href="#REC_CATCH_EXCEPTION">REC: Exception is caught when Exception is not thrown</a></td><td>Dodgy code</td></tr>
457 <tr bgcolor="#ffffff"><td><a href="#RI_REDUNDANT_INTERFACES">RI: Class implements same interface as superclass</a></td><td>Dodgy code</td></tr>
458 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Method checks to see if result of String.indexOf is positive</a></td><td>Dodgy code</td></tr>
459 <tr bgcolor="#ffffff"><td><a href="#RV_DONT_JUST_NULL_CHECK_READLINE">RV: Method discards result of readLine after checking if it is nonnull</a></td><td>Dodgy code</td></tr>
460 <tr bgcolor="#eeeeee"><td><a href="#RV_REM_OF_HASHCODE">RV: Remainder of hashCode could be negative</a></td><td>Dodgy code</td></tr>
461 <tr bgcolor="#ffffff"><td><a href="#RV_REM_OF_RANDOM_INT">RV: Remainder of 32-bit signed random integer</a></td><td>Dodgy code</td></tr>
462 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method ignores return value, is this OK?</a></td><td>Dodgy code</td></tr>
463 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assignment of field</a></td><td>Dodgy code</td></tr>
464 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assignment of local variable </a></td><td>Dodgy code</td></tr>
465 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT">SA: Self assignment of local variable</a></td><td>Dodgy code</td></tr>
466 <tr bgcolor="#eeeeee"><td><a href="#SF_SWITCH_FALLTHROUGH">SF: Switch statement found where one case falls through to the next case</a></td><td>Dodgy code</td></tr>
467 <tr bgcolor="#ffffff"><td><a href="#SF_SWITCH_NO_DEFAULT">SF: Switch statement found where default case is missing</a></td><td>Dodgy code</td></tr>
468 <tr bgcolor="#eeeeee"><td><a href="#ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST: Write to static field from instance method</a></td><td>Dodgy code</td></tr>
469 <tr bgcolor="#ffffff"><td><a href="#SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: Private readResolve method not inherited by subclasses</a></td><td>Dodgy code</td></tr>
470 <tr bgcolor="#eeeeee"><td><a href="#SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">Se: Transient field of class that isn't Serializable. </a></td><td>Dodgy code</td></tr>
471 <tr bgcolor="#ffffff"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value required to have type qualifier, but marked as unknown</a></td><td>Dodgy code</td></tr>
472 <tr bgcolor="#eeeeee"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value required to not have type qualifier, but marked as unknown</a></td><td>Dodgy code</td></tr>
473 <tr bgcolor="#ffffff"><td><a href="#UCF_USELESS_CONTROL_FLOW">UCF: Useless control flow</a></td><td>Dodgy code</td></tr>
474 <tr bgcolor="#eeeeee"><td><a href="#UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Useless control flow to next line</a></td><td>Dodgy code</td></tr>
475 <tr bgcolor="#ffffff"><td><a href="#USM_USELESS_ABSTRACT_METHOD">USM: Abstract Method is already defined in implemented interface</a></td><td>Dodgy code</td></tr>
476 <tr bgcolor="#eeeeee"><td><a href="#USM_USELESS_SUBCLASS_METHOD">USM: Method superfluously delegates to parent class method</a></td><td>Dodgy code</td></tr>
477 <tr bgcolor="#ffffff"><td><a href="#URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: Unread public/protected field</a></td><td>Dodgy code</td></tr>
478 <tr bgcolor="#eeeeee"><td><a href="#UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: Unused public or protected field</a></td><td>Dodgy code</td></tr>
479 <tr bgcolor="#ffffff"><td><a href="#UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">UwF: Field not initialized in constructor but dereferenced without null check</a></td><td>Dodgy code</td></tr>
480 <tr bgcolor="#eeeeee"><td><a href="#UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF: Unwritten public or protected field</a></td><td>Dodgy code</td></tr>
481 <tr bgcolor="#ffffff"><td><a href="#XFB_XML_FACTORY_BYPASS">XFB: Method directly allocates a specific implementation of xml interfaces</a></td><td>Dodgy code</td></tr>
482 </table>
483 <h2>Descriptions</h2>
484 <h3><a name="AM_CREATES_EMPTY_JAR_FILE_ENTRY">AM: Creates an empty jar file entry (AM_CREATES_EMPTY_JAR_FILE_ENTRY)</a></h3>
485
486
487 <p>The code calls <code>putNextEntry()</code>, immediately
488 followed by a call to <code>closeEntry()</code>. This results
489 in an empty JarFile entry. The contents of the entry
490 should be written to the JarFile between the calls to
491 <code>putNextEntry()</code> and
492 <code>closeEntry()</code>.</p>
493
494
495 <h3><a name="AM_CREATES_EMPTY_ZIP_FILE_ENTRY">AM: Creates an empty zip file entry (AM_CREATES_EMPTY_ZIP_FILE_ENTRY)</a></h3>
496
497
498 <p>The code calls <code>putNextEntry()</code>, immediately
499 followed by a call to <code>closeEntry()</code>. This results
500 in an empty ZipFile entry. The contents of the entry
501 should be written to the ZipFile between the calls to
502 <code>putNextEntry()</code> and
503 <code>closeEntry()</code>.</p>
504
505
506 <h3><a name="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS">BC: Equals method should not assume anything about the type of its argument (BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)</a></h3>
507
508
509 <p>
510 The <code>equals(Object o)</code> method shouldn't make any assumptions
511 about the type of <code>o</code>. It should simply return
512 false if <code>o</code> is not the same type as <code>this</code>.
513 </p>
514
515
516 <h3><a name="BIT_SIGNED_CHECK">BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK)</a></h3>
517
518
519 <p> This method compares an expression such as</p>
520 <pre>((event.detail &amp; SWT.SELECTED) &gt; 0)</pre>.
521 <p>Using bit arithmetic and then comparing with the greater than operator can
522 lead to unexpected results (of course depending on the value of
523 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
524 for a bug. Even when SWT.SELECTED is not negative, it seems good practice
525 to use '!= 0' instead of '&gt; 0'.
526 </p>
527 <p>
528 <em>Boris Bokowski</em>
529 </p>
530
531
532 <h3><a name="CN_IDIOM">CN: Class implements Cloneable but does not define or use clone method (CN_IDIOM)</a></h3>
533
534
535 <p>
536 Class implements Cloneable but does not define or
537 use the clone method.</p>
538
539
540 <h3><a name="CN_IDIOM_NO_SUPER_CALL">CN: clone method does not call super.clone() (CN_IDIOM_NO_SUPER_CALL)</a></h3>
541
542
543 <p> This non-final class defines a clone() method that does not call super.clone().
544 If this class ("<i>A</i>") is extended by a subclass ("<i>B</i>"),
545 and the subclass <i>B</i> calls super.clone(), then it is likely that
546 <i>B</i>'s clone() method will return an object of type <i>A</i>,
547 which violates the standard contract for clone().</p>
548
549 <p> If all clone() methods call super.clone(), then they are guaranteed
550 to use Object.clone(), which always returns an object of the correct type.</p>
551
552
553 <h3><a name="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: Class defines clone() but doesn't implement Cloneable (CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE)</a></h3>
554
555
556 <p> This class defines a clone() method but the class doesn't implement Cloneable.
557 There are some situations in which this is OK (e.g., you want to control how subclasses
558 can clone themselves), but just make sure that this is what you intended.
559 </p>
560
561
562 <h3><a name="CO_ABSTRACT_SELF">Co: Abstract class defines covariant compareTo() method (CO_ABSTRACT_SELF)</a></h3>
563
564
565 <p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;
566 To correctly override the <code>compareTo()</code> method in the
567 <code>Comparable</code> interface, the parameter of <code>compareTo()</code>
568 must have type <code>java.lang.Object</code>.</p>
569
570
571 <h3><a name="CO_SELF_NO_OBJECT">Co: Covariant compareTo() method defined (CO_SELF_NO_OBJECT)</a></h3>
572
573
574 <p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;
575 To correctly override the <code>compareTo()</code> method in the
576 <code>Comparable</code> interface, the parameter of <code>compareTo()</code>
577 must have type <code>java.lang.Object</code>.</p>
578
579
580 <h3><a name="DE_MIGHT_DROP">DE: Method might drop exception (DE_MIGHT_DROP)</a></h3>
581
582
583 <p> This method might drop an exception.&nbsp; In general, exceptions
584 should be handled or reported in some way, or they should be thrown
585 out of the method.</p>
586
587
588 <h3><a name="DE_MIGHT_IGNORE">DE: Method might ignore exception (DE_MIGHT_IGNORE)</a></h3>
589
590
591 <p> This method might ignore an exception.&nbsp; In general, exceptions
592 should be handled or reported in some way, or they should be thrown
593 out of the method.</p>
594
595
596 <h3><a name="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI: Adding elements of an entry set may fail due to reuse of Entry objects (DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS)</a></h3>
597
598
599 <p> The entrySet() method is allowed to return a view of the
600 underlying Map in which a single Entry object is reused and returned
601 during the iteration. As of Java 1.6, both IdentityHashMap
602 and EnumMap did so. When iterating through such a Map,
603 the Entry value is only valid until you advance to the next iteration.
604 If, for example, you try to pass such an entrySet to an addAll method,
605 things will go badly wrong.
606 </p>
607
608
609 <h3><a name="DMI_RANDOM_USED_ONLY_ONCE">DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE)</a></h3>
610
611
612 <p> This code creates a java.util.Random object, uses it to generate one random number, and then discards
613 the Random object. This produces mediocre quality random numbers and is inefficient.
614 If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number
615 is required invoke a method on the existing Random object to obtain it.
616 </p>
617
618 <p>If it is important that the generated Random numbers not be guessable, you <em>must</em> not create a new Random for each random
619 number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead
620 (and avoid allocating a new SecureRandom for each random number needed).
621 </p>
622
623
624 <h3><a name="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI: Don't use removeAll to clear a collection (DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION)</a></h3>
625
626
627 <p> If you want to remove all elements from a collection <code>c</code>, use <code>c.clear</code>,
628 not <code>c.removeAll(c)</code>. Calling <code>c.removeAll(c)</code> to clear a collection
629 is less clear, susceptible to errors from typos, less efficient and
630 for some collections, might throw a <code>ConcurrentModificationException</code>.
631 </p>
632
633
634 <h3><a name="DM_EXIT">Dm: Method invokes System.exit(...) (DM_EXIT)</a></h3>
635
636
637 <p> Invoking System.exit shuts down the entire Java virtual machine. This
638 should only been done when it is appropriate. Such calls make it
639 hard or impossible for your code to be invoked by other code.
640 Consider throwing a RuntimeException instead.</p>
641
642
643 <h3><a name="DM_RUN_FINALIZERS_ON_EXIT">Dm: Method invokes dangerous method runFinalizersOnExit (DM_RUN_FINALIZERS_ON_EXIT)</a></h3>
644
645
646 <p> <em>Never call System.runFinalizersOnExit
647 or Runtime.runFinalizersOnExit for any reason: they are among the most
648 dangerous methods in the Java libraries.</em> -- Joshua Bloch</p>
649
650
651 <h3><a name="ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: Comparison of String parameter using == or != (ES_COMPARING_PARAMETER_STRING_WITH_EQ)</a></h3>
652
653
654 <p>This code compares a <code>java.lang.String</code> parameter for reference
655 equality using the == or != operators. Requiring callers to
656 pass only String constants or interned strings to a method is unnecessarily
657 fragile, and rarely leads to measurable performance gains. Consider
658 using the <code>equals(Object)</code> method instead.</p>
659
660
661 <h3><a name="ES_COMPARING_STRINGS_WITH_EQ">ES: Comparison of String objects using == or != (ES_COMPARING_STRINGS_WITH_EQ)</a></h3>
662
663
664 <p>This code compares <code>java.lang.String</code> objects for reference
665 equality using the == or != operators.
666 Unless both strings are either constants in a source file, or have been
667 interned using the <code>String.intern()</code> method, the same string
668 value may be represented by two different String objects. Consider
669 using the <code>equals(Object)</code> method instead.</p>
670
671
672 <h3><a name="EQ_ABSTRACT_SELF">Eq: Abstract class defines covariant equals() method (EQ_ABSTRACT_SELF)</a></h3>
673
674
675 <p> This class defines a covariant version of <code>equals()</code>.&nbsp;
676 To correctly override the <code>equals()</code> method in
677 <code>java.lang.Object</code>, the parameter of <code>equals()</code>
678 must have type <code>java.lang.Object</code>.</p>
679
680
681 <h3><a name="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">Eq: Equals checks for incompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS)</a></h3>
682
683
684 <p> This equals method is checking to see if the argument is some incompatible type
685 (i.e., a class that is neither a supertype nor subtype of the class that defines
686 the equals method). For example, the Foo class might have an equals method
687 that looks like:
688 </p>
689 <pre>
690 public boolean equals(Object o) {
691 if (o instanceof Foo)
692 return name.equals(((Foo)o).name);
693 else if (o instanceof String)
694 return name.equals(o);
695 else return false;
696 </pre>
697
698 <p>This is considered bad practice, as it makes it very hard to implement an equals method that
699 is symmetric and transitive. Without those properties, very unexpected behavoirs are possible.
700 </p>
701
702
703 <h3><a name="EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class defines compareTo(...) and uses Object.equals() (EQ_COMPARETO_USE_OBJECT_EQUALS)</a></h3>
704
705
706 <p> This class defines a <code>compareTo(...)</code> method but inherits its
707 <code>equals()</code> method from <code>java.lang.Object</code>.
708 Generally, the value of compareTo should return zero if and only if
709 equals returns true. If this is violated, weird and unpredictable
710 failures will occur in classes such as PriorityQueue.
711 In Java 5 the PriorityQueue.remove method uses the compareTo method,
712 while in Java 6 it uses the equals method.
713
714 <p>From the JavaDoc for the compareTo method in the Comparable interface:
715 <blockquote>
716 It is strongly recommended, but not strictly required that <code>(x.compareTo(y)==0) == (x.equals(y))</code>.
717 Generally speaking, any class that implements the Comparable interface and violates this condition
718 should clearly indicate this fact. The recommended language
719 is "Note: this class has a natural ordering that is inconsistent with equals."
720 </blockquote>
721
722
723 <h3><a name="EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals method fails for subtypes (EQ_GETCLASS_AND_CLASS_CONSTANT)</a></h3>
724
725
726 <p> This class has an equals method that will be broken if it is inherited by subclasses.
727 It compares a class literal with the class of the argument (e.g., in class <code>Foo</code>
728 it might check if <code>Foo.class == o.getClass()</code>).
729 It is better to check if <code>this.getClass() == o.getClass()</code>.
730 </p>
731
732
733 <h3><a name="EQ_SELF_NO_OBJECT">Eq: Covariant equals() method defined (EQ_SELF_NO_OBJECT)</a></h3>
734
735
736 <p> This class defines a covariant version of <code>equals()</code>.&nbsp;
737 To correctly override the <code>equals()</code> method in
738 <code>java.lang.Object</code>, the parameter of <code>equals()</code>
739 must have type <code>java.lang.Object</code>.</p>
740
741
742 <h3><a name="FI_EMPTY">FI: Empty finalizer should be deleted (FI_EMPTY)</a></h3>
743
744
745 <p> Empty <code>finalize()</code> methods are useless, so they should
746 be deleted.</p>
747
748
749 <h3><a name="FI_EXPLICIT_INVOCATION">FI: Explicit invocation of finalizer (FI_EXPLICIT_INVOCATION)</a></h3>
750
751
752 <p> This method contains an explicit invocation of the <code>finalize()</code>
753 method on an object.&nbsp; Because finalizer methods are supposed to be
754 executed once, and only by the VM, this is a bad idea.</p>
755 <p>If a connected set of objects beings finalizable, then the VM will invoke the
756 finalize method on all the finalizable object, possibly at the same time in different threads.
757 Thus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize
758 on objects referenced by X, because they may already be getting finalized in a separate thread.
759
760
761 <h3><a name="FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nulls fields (FI_FINALIZER_NULLS_FIELDS)</a></h3>
762
763
764 <p> This finalizer nulls out fields. This is usually an error, as it does not aid garbage collection,
765 and the object is going to be garbage collected anyway.
766
767
768 <h3><a name="FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalizer only nulls fields (FI_FINALIZER_ONLY_NULLS_FIELDS)</a></h3>
769
770
771 <p> This finalizer does nothing except null out fields. This is completely pointless, and requires that
772 the object be garbage collected, finalized, and then garbage collected again. You should just remove the finalize
773 method.
774
775
776 <h3><a name="FI_MISSING_SUPER_CALL">FI: Finalizer does not call superclass finalizer (FI_MISSING_SUPER_CALL)</a></h3>
777
778
779 <p> This <code>finalize()</code> method does not make a call to its
780 superclass's <code>finalize()</code> method.&nbsp; So, any finalizer
781 actions defined for the superclass will not be performed.&nbsp;
782 Add a call to <code>super.finalize()</code>.</p>
783
784
785 <h3><a name="FI_NULLIFY_SUPER">FI: Finalizer nullifies superclass finalizer (FI_NULLIFY_SUPER)</a></h3>
786
787
788 <p> This empty <code>finalize()</code> method explicitly negates the
789 effect of any finalizer defined by its superclass.&nbsp; Any finalizer
790 actions defined for the superclass will not be performed.&nbsp;
791 Unless this is intended, delete this method.</p>
792
793
794 <h3><a name="FI_USELESS">FI: Finalizer does nothing but call superclass finalizer (FI_USELESS)</a></h3>
795
796
797 <p> The only thing this <code>finalize()</code> method does is call
798 the superclass's <code>finalize()</code> method, making it
799 redundant.&nbsp; Delete it.</p>
800
801
802 <h3><a name="VA_FORMAT_STRING_USES_NEWLINE">FS: Format string should use %n rather than \n (VA_FORMAT_STRING_USES_NEWLINE)</a></h3>
803
804
805 <p>
806 This format string include a newline character (\n). In format strings, it is generally
807 preferable better to use %n, which will produce the platform-specific line separator.
808 </p>
809
810
811 <h3><a name="GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unchecked type in generic call (GC_UNCHECKED_TYPE_IN_GENERIC_CALL)</a></h3>
812
813
814 <p> This call to a generic collection method passes an argument
815 while compile type Object where a specific type from
816 the generic type parameters is expected.
817 Thus, neither the standard Java type system nor static analysis
818 can provide useful information on whether the
819 object being passed as a parameter is of an appropriate type.
820 </p>
821
822
823 <h3><a name="HE_EQUALS_NO_HASHCODE">HE: Class defines equals() but not hashCode() (HE_EQUALS_NO_HASHCODE)</a></h3>
824
825
826 <p> This class overrides <code>equals(Object)</code>, but does not
827 override <code>hashCode()</code>.&nbsp; Therefore, the class may violate the
828 invariant that equal objects must have equal hashcodes.</p>
829
830
831 <h3><a name="HE_EQUALS_USE_HASHCODE">HE: Class defines equals() and uses Object.hashCode() (HE_EQUALS_USE_HASHCODE)</a></h3>
832
833
834 <p> This class overrides <code>equals(Object)</code>, but does not
835 override <code>hashCode()</code>, and inherits the implementation of
836 <code>hashCode()</code> from <code>java.lang.Object</code> (which returns
837 the identity hash code, an arbitrary value assigned to the object
838 by the VM).&nbsp; Therefore, the class is very likely to violate the
839 invariant that equal objects must have equal hashcodes.</p>
840
841 <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
842 the recommended <code>hashCode</code> implementation to use is:</p>
843 <pre>public int hashCode() {
844 assert false : "hashCode not designed";
845 return 42; // any arbitrary constant will do
846 }</pre>
847
848
849 <h3><a name="HE_HASHCODE_NO_EQUALS">HE: Class defines hashCode() but not equals() (HE_HASHCODE_NO_EQUALS)</a></h3>
850
851
852 <p> This class defines a <code>hashCode()</code> method but not an
853 <code>equals()</code> method.&nbsp; Therefore, the class may
854 violate the invariant that equal objects must have equal hashcodes.</p>
855
856
857 <h3><a name="HE_HASHCODE_USE_OBJECT_EQUALS">HE: Class defines hashCode() and uses Object.equals() (HE_HASHCODE_USE_OBJECT_EQUALS)</a></h3>
858
859
860 <p> This class defines a <code>hashCode()</code> method but inherits its
861 <code>equals()</code> method from <code>java.lang.Object</code>
862 (which defines equality by comparing object references).&nbsp; Although
863 this will probably satisfy the contract that equal objects must have
864 equal hashcodes, it is probably not what was intended by overriding
865 the <code>hashCode()</code> method.&nbsp; (Overriding <code>hashCode()</code>
866 implies that the object's identity is based on criteria more complicated
867 than simple reference equality.)</p>
868 <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
869 the recommended <code>hashCode</code> implementation to use is:</p>
870 <pre>public int hashCode() {
871 assert false : "hashCode not designed";
872 return 42; // any arbitrary constant will do
873 }</pre>
874
875
876 <h3><a name="HE_INHERITS_EQUALS_USE_HASHCODE">HE: Class inherits equals() and uses Object.hashCode() (HE_INHERITS_EQUALS_USE_HASHCODE)</a></h3>
877
878
879 <p> This class inherits <code>equals(Object)</code> from an abstract
880 superclass, and <code>hashCode()</code> from
881 <code>java.lang.Object</code> (which returns
882 the identity hash code, an arbitrary value assigned to the object
883 by the VM).&nbsp; Therefore, the class is very likely to violate the
884 invariant that equal objects must have equal hashcodes.</p>
885
886 <p>If you don't want to define a hashCode method, and/or don't
887 believe the object will ever be put into a HashMap/Hashtable,
888 define the <code>hashCode()</code> method
889 to throw <code>UnsupportedOperationException</code>.</p>
890
891
892 <h3><a name="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION">IC: Superclass uses subclass during initialization (IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION)</a></h3>
893
894
895 <p> During the initialization of a class, the class makes an active use of a subclass.
896 That subclass will not yet be initialized at the time of this use.
897 For example, in the following code, <code>foo</code> will be null.</p>
898
899 <pre>
900 public class CircularClassInitialization {
901 static class InnerClassSingleton extends CircularClassInitialization {
902 static InnerClassSingleton singleton = new InnerClassSingleton();
903 }
904
905 static CircularClassInitialization foo = InnerClassSingleton.singleton;
906 }
907 </pre>
908
909
910
911 <h3><a name="IMSE_DONT_CATCH_IMSE">IMSE: Dubious catching of IllegalMonitorStateException (IMSE_DONT_CATCH_IMSE)</a></h3>
912
913
914 <p>IllegalMonitorStateException is generally only
915 thrown in case of a design flaw in your code (calling wait or
916 notify on an object you do not hold a lock on).</p>
917
918
919 <h3><a name="ISC_INSTANTIATE_STATIC_CLASS">ISC: Needless instantiation of class that only supplies static methods (ISC_INSTANTIATE_STATIC_CLASS)</a></h3>
920
921
922 <p> This class allocates an object that is based on a class that only supplies static methods. This object
923 does not need to be created, just access the static methods directly using the class name as a qualifier.</p>
924
925
926 <h3><a name="IT_NO_SUCH_ELEMENT">It: Iterator next() method can't throw NoSuchElementException (IT_NO_SUCH_ELEMENT)</a></h3>
927
928
929 <p> This class implements the <code>java.util.Iterator</code> interface.&nbsp;
930 However, its <code>next()</code> method is not capable of throwing
931 <code>java.util.NoSuchElementException</code>.&nbsp; The <code>next()</code>
932 method should be changed so it throws <code>NoSuchElementException</code>
933 if is called when there are no more elements to return.</p>
934
935
936 <h3><a name="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION">J2EE: Store of non serializable object into HttpSession (J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION)</a></h3>
937
938
939 <p>
940 This code seems to be storing a non-serializable object into an HttpSession.
941 If this session is passivated or migrated, an error will result.
942 </p>
943
944
945 <h3><a name="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP: Fields of immutable classes should be final (JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS)</a></h3>
946
947
948 <p> The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable,
949 and the rules for those annotations require that all fields are final.
950 .</p>
951
952
953 <h3><a name="NP_BOOLEAN_RETURN_NULL">NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)</a></h3>
954
955
956 <p>
957 A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen.
958 This method can be invoked as though it returned a value of type boolean, and
959 the compiler will insert automatic unboxing of the Boolean value. If a null value is returned,
960 this will result in a NullPointerException.
961 </p>
962
963
964 <h3><a name="NP_CLONE_COULD_RETURN_NULL">NP: Clone method may return null (NP_CLONE_COULD_RETURN_NULL)</a></h3>
965
966
967 <p>
968 This clone method seems to return null in some circumstances, but clone is never
969 allowed to return a null value. If you are convinced this path is unreachable, throw an AssertionError
970 instead.
971 </p>
972
973
974 <h3><a name="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: equals() method does not check for null argument (NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT)</a></h3>
975
976
977 <p>
978 This implementation of equals(Object) violates the contract defined
979 by java.lang.Object.equals() because it does not check for null
980 being passed as the argument. All equals() methods should return
981 false if passed a null value.
982 </p>
983
984
985 <h3><a name="NP_TOSTRING_COULD_RETURN_NULL">NP: toString method may return null (NP_TOSTRING_COULD_RETURN_NULL)</a></h3>
986
987
988 <p>
989 This toString method seems to return null in some circumstances. A liberal reading of the
990 spec could be interpreted as allowing this, but it is probably a bad idea and could cause
991 other code to break. Return the empty string or some other appropriate string rather than null.
992 </p>
993
994
995 <h3><a name="NM_CLASS_NAMING_CONVENTION">Nm: Class names should start with an upper case letter (NM_CLASS_NAMING_CONVENTION)</a></h3>
996
997
998 <p> Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
999 </p>
1000
1001
1002 <h3><a name="NM_CLASS_NOT_EXCEPTION">Nm: Class is not derived from an Exception, even though it is named as such (NM_CLASS_NOT_EXCEPTION)</a></h3>
1003
1004
1005 <p> This class is not derived from another exception, but ends with 'Exception'. This will
1006 be confusing to users of this class.</p>
1007
1008
1009 <h3><a name="NM_CONFUSING">Nm: Confusing method names (NM_CONFUSING)</a></h3>
1010
1011
1012 <p> The referenced methods have names that differ only by capitalization.</p>
1013
1014
1015 <h3><a name="NM_FIELD_NAMING_CONVENTION">Nm: Field names should start with a lower case letter (NM_FIELD_NAMING_CONVENTION)</a></h3>
1016
1017
1018 <p>
1019 Names of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized.
1020 </p>
1021
1022
1023 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER)</a></h3>
1024
1025
1026 <p>The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed
1027 in order to compile it in later versions of Java.</p>
1028
1029
1030
1031 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER)</a></h3>
1032
1033
1034 <p>This identifier is used as a keyword in later versions of Java. This code, and
1035 any code that references this API,
1036 will need to be changed in order to compile it in later versions of Java.</p>
1037
1038
1039
1040 <h3><a name="NM_METHOD_NAMING_CONVENTION">Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION)</a></h3>
1041
1042
1043 <p>
1044 Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.
1045 </p>
1046
1047
1048 <h3><a name="NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class names shouldn't shadow simple name of implemented interface (NM_SAME_SIMPLE_NAME_AS_INTERFACE)</a></h3>
1049
1050
1051 <p> This class/interface has a simple name that is identical to that of an implemented/extended interface, except
1052 that the interface is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
1053 This can be exceptionally confusing, create lots of situations in which you have to look at import statements
1054 to resolve references and creates many
1055 opportunities to accidently define methods that do not override methods in their superclasses.
1056 </p>
1057
1058
1059 <h3><a name="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class names shouldn't shadow simple name of superclass (NM_SAME_SIMPLE_NAME_AS_SUPERCLASS)</a></h3>
1060
1061
1062 <p> This class has a simple name that is identical to that of its superclass, except
1063 that its superclass is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
1064 This can be exceptionally confusing, create lots of situations in which you have to look at import statements
1065 to resolve references and creates many
1066 opportunities to accidently define methods that do not override methods in their superclasses.
1067 </p>
1068
1069
1070 <h3><a name="NM_VERY_CONFUSING_INTENTIONAL">Nm: Very confusing method names (but perhaps intentional) (NM_VERY_CONFUSING_INTENTIONAL)</a></h3>
1071
1072
1073 <p> The referenced methods have names that differ only by capitalization.
1074 This is very confusing because if the capitalization were
1075 identical then one of the methods would override the other. From the existence of other methods, it
1076 seems that the existence of both of these methods is intentional, but is sure is confusing.
1077 You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs.
1078 </p>
1079
1080
1081 <h3><a name="NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE_INTENTIONAL)</a></h3>
1082
1083
1084 <p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match
1085 the type of the corresponding parameter in the superclass. For example, if you have:</p>
1086
1087 <blockquote>
1088 <pre>
1089 import alpha.Foo;
1090 public class A {
1091 public int f(Foo x) { return 17; }
1092 }
1093 ----
1094 import beta.Foo;
1095 public class B extends A {
1096 public int f(Foo x) { return 42; }
1097 public int f(alpha.Foo x) { return 27; }
1098 }
1099 </pre>
1100 </blockquote>
1101
1102 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't
1103 override the
1104 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument
1105 types are <code>Foo</code>'s from different packages.
1106 </p>
1107
1108 <p>In this case, the subclass does define a method with a signature identical to the method in the superclass,
1109 so this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider
1110 removing or deprecating the method with the similar but not identical signature.
1111 </p>
1112
1113
1114 <h3><a name="ODR_OPEN_DATABASE_RESOURCE">ODR: Method may fail to close database resource (ODR_OPEN_DATABASE_RESOURCE)</a></h3>
1115
1116
1117 <p> The method creates a database resource (such as a database connection
1118 or row set), does not assign it to any
1119 fields, pass it to other methods, or return it, and does not appear to close
1120 the object on all paths out of the method.&nbsp; Failure to
1121 close database resources on all paths out of a method may
1122 result in poor performance, and could cause the application to
1123 have problems communicating with the database.
1124 </p>
1125
1126
1127 <h3><a name="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">ODR: Method may fail to close database resource on exception (ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH)</a></h3>
1128
1129
1130 <p> The method creates a database resource (such as a database connection
1131 or row set), does not assign it to any
1132 fields, pass it to other methods, or return it, and does not appear to close
1133 the object on all exception paths out of the method.&nbsp; Failure to
1134 close database resources on all paths out of a method may
1135 result in poor performance, and could cause the application to
1136 have problems communicating with the database.</p>
1137
1138
1139 <h3><a name="OS_OPEN_STREAM">OS: Method may fail to close stream (OS_OPEN_STREAM)</a></h3>
1140
1141
1142 <p> The method creates an IO stream object, does not assign it to any
1143 fields, pass it to other methods that might close it,
1144 or return it, and does not appear to close
1145 the stream on all paths out of the method.&nbsp; This may result in
1146 a file descriptor leak.&nbsp; It is generally a good
1147 idea to use a <code>finally</code> block to ensure that streams are
1148 closed.</p>
1149
1150
1151 <h3><a name="OS_OPEN_STREAM_EXCEPTION_PATH">OS: Method may fail to close stream on exception (OS_OPEN_STREAM_EXCEPTION_PATH)</a></h3>
1152
1153
1154 <p> The method creates an IO stream object, does not assign it to any
1155 fields, pass it to other methods, or return it, and does not appear to close
1156 it on all possible exception paths out of the method.&nbsp;
1157 This may result in a file descriptor leak.&nbsp; It is generally a good
1158 idea to use a <code>finally</code> block to ensure that streams are
1159 closed.</p>
1160
1161
1162 <h3><a name="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ: Don't reuse entry objects in iterators (PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS)</a></h3>
1163
1164
1165 <p> The entrySet() method is allowed to return a view of the
1166 underlying Map in which an Iterator and Map.Entry. This clever
1167 idea was used in several Map implementations, but introduces the possibility
1168 of nasty coding mistakes. If a map <code>m</code> returns
1169 such an iterator for an entrySet, then
1170 <code>c.addAll(m.entrySet())</code> will go badly wrong. All of
1171 the Map implementations in OpenJDK 1.7 have been rewritten to avoid this,
1172 you should to.
1173 </p>
1174
1175
1176 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicious reference comparison to constant (RC_REF_COMPARISON_BAD_PRACTICE)</a></h3>
1177
1178
1179 <p> This method compares a reference value to a constant using the == or != operator,
1180 where the correct way to compare instances of this type is generally
1181 with the equals() method.
1182 It is possible to create distinct instances that are equal but do not compare as == since
1183 they are different objects.
1184 Examples of classes which should generally
1185 not be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>
1186
1187
1188 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC: Suspicious reference comparison of Boolean values (RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN)</a></h3>
1189
1190
1191 <p> This method compares two Boolean values using the == or != operator.
1192 Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE),
1193 but it is possible to create other Boolean objects using the <code>new Boolean(b)</code>
1194 constructor. It is best to avoid such objects, but if they do exist,
1195 then checking Boolean objects for equality using == or != will give results
1196 than are different than you would get using <code>.equals(...)</code>
1197 </p>
1198
1199
1200 <h3><a name="RR_NOT_CHECKED">RR: Method ignores results of InputStream.read() (RR_NOT_CHECKED)</a></h3>
1201
1202
1203 <p> This method ignores the return value of one of the variants of
1204 <code>java.io.InputStream.read()</code> which can return multiple bytes.&nbsp;
1205 If the return value is not checked, the caller will not be able to correctly
1206 handle the case where fewer bytes were read than the caller requested.&nbsp;
1207 This is a particularly insidious kind of bug, because in many programs,
1208 reads from input streams usually do read the full amount of data requested,
1209 causing the program to fail only sporadically.</p>
1210
1211
1212 <h3><a name="SR_NOT_CHECKED">RR: Method ignores results of InputStream.skip() (SR_NOT_CHECKED)</a></h3>
1213
1214
1215 <p> This method ignores the return value of
1216 <code>java.io.InputStream.skip()</code> which can skip multiple bytes.&nbsp;
1217 If the return value is not checked, the caller will not be able to correctly
1218 handle the case where fewer bytes were skipped than the caller requested.&nbsp;
1219 This is a particularly insidious kind of bug, because in many programs,
1220 skips from input streams usually do skip the full amount of data requested,
1221 causing the program to fail only sporadically. With Buffered streams, however,
1222 skip() will only skip data in the buffer, and will routinely fail to skip the
1223 requested number of bytes.</p>
1224
1225
1226 <h3><a name="RV_NEGATING_RESULT_OF_COMPARETO">RV: Negating the result of compareTo()/compare() (RV_NEGATING_RESULT_OF_COMPARETO)</a></h3>
1227
1228
1229 <p> This code negatives the return value of a compareTo or compare method.
1230 This is a questionable or bad programming practice, since if the return
1231 value is Integer.MIN_VALUE, negating the return value won't
1232 negate the sign of the result. You can achieve the same intended result
1233 by reversing the order of the operands rather than by negating the results.
1234 </p>
1235
1236
1237 <h3><a name="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Method ignores exceptional return value (RV_RETURN_VALUE_IGNORED_BAD_PRACTICE)</a></h3>
1238
1239
1240 <p> This method returns a value that is not checked. The return value should be checked
1241 since it can indicate an unusual or unexpected function execution. For
1242 example, the <code>File.delete()</code> method returns false
1243 if the file could not be successfully deleted (rather than
1244 throwing an Exception).
1245 If you don't check the result, you won't notice if the method invocation
1246 signals unexpected behavior by returning an atypical return value.
1247 </p>
1248
1249
1250 <h3><a name="SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Static initializer creates instance before all static final fields assigned (SI_INSTANCE_BEFORE_FINALS_ASSIGNED)</a></h3>
1251
1252
1253 <p> The class's static initializer creates an instance of the class
1254 before all of the static final fields are assigned.</p>
1255
1256
1257 <h3><a name="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW: Certain swing methods needs to be invoked in Swing thread (SW_SWING_METHODS_INVOKED_IN_SWING_THREAD)</a></h3>
1258
1259
1260 <p>(<a href="http://web.archive.org/web/20090526170426/http://java.sun.com/developer/JDCTechTips/2003/tt1208.html">From JDC Tech Tip</a>): The Swing methods
1261 show(), setVisible(), and pack() will create the associated peer for the frame.
1262 With the creation of the peer, the system creates the event dispatch thread.
1263 This makes things problematic because the event dispatch thread could be notifying
1264 listeners while pack and validate are still processing. This situation could result in
1265 two threads going through the Swing component-based GUI -- it's a serious flaw that
1266 could result in deadlocks or other related threading issues. A pack call causes
1267 components to be realized. As they are being realized (that is, not necessarily
1268 visible), they could trigger listener notification on the event dispatch thread.</p>
1269
1270
1271
1272 <h3><a name="SE_BAD_FIELD">Se: Non-transient non-serializable instance field in serializable class (SE_BAD_FIELD)</a></h3>
1273
1274
1275 <p> This Serializable class defines a non-primitive instance field which is neither transient,
1276 Serializable, or <code>java.lang.Object</code>, and does not appear to implement
1277 the <code>Externalizable</code> interface or the
1278 <code>readObject()</code> and <code>writeObject()</code> methods.&nbsp;
1279 Objects of this class will not be deserialized correctly if a non-Serializable
1280 object is stored in this field.</p>
1281
1282
1283 <h3><a name="SE_BAD_FIELD_INNER_CLASS">Se: Non-serializable class has a serializable inner class (SE_BAD_FIELD_INNER_CLASS)</a></h3>
1284
1285
1286 <p> This Serializable class is an inner class of a non-serializable class.
1287 Thus, attempts to serialize it will also attempt to associate instance of the outer
1288 class with which it is associated, leading to a runtime error.
1289 </p>
1290 <p>If possible, making the inner class a static inner class should solve the
1291 problem. Making the outer class serializable might also work, but that would
1292 mean serializing an instance of the inner class would always also serialize the instance
1293 of the outer class, which it often not what you really want.
1294
1295
1296 <h3><a name="SE_BAD_FIELD_STORE">Se: Non-serializable value stored into instance field of a serializable class (SE_BAD_FIELD_STORE)</a></h3>
1297
1298
1299 <p> A non-serializable value is stored into a non-transient field
1300 of a serializable class.</p>
1301
1302
1303 <h3><a name="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Comparator doesn't implement Serializable (SE_COMPARATOR_SHOULD_BE_SERIALIZABLE)</a></h3>
1304
1305
1306 <p> This class implements the <code>Comparator</code> interface. You
1307 should consider whether or not it should also implement the <code>Serializable</code>
1308 interface. If a comparator is used to construct an ordered collection
1309 such as a <code>TreeMap</code>, then the <code>TreeMap</code>
1310 will be serializable only if the comparator is also serializable.
1311 As most comparators have little or no state, making them serializable
1312 is generally easy and good defensive programming.
1313 </p>
1314
1315
1316 <h3><a name="SE_INNER_CLASS">Se: Serializable inner class (SE_INNER_CLASS)</a></h3>
1317
1318
1319 <p> This Serializable class is an inner class. Any attempt to serialize
1320 it will also serialize the associated outer instance. The outer instance is serializable,
1321 so this won't fail, but it might serialize a lot more data than intended.
1322 If possible, making the inner class a static inner class (also known as a nested class) should solve the
1323 problem.
1324
1325
1326 <h3><a name="SE_NONFINAL_SERIALVERSIONID">Se: serialVersionUID isn't final (SE_NONFINAL_SERIALVERSIONID)</a></h3>
1327
1328
1329 <p> This class defines a <code>serialVersionUID</code> field that is not final.&nbsp;
1330 The field should be made final
1331 if it is intended to specify
1332 the version UID for purposes of serialization.</p>
1333
1334
1335 <h3><a name="SE_NONLONG_SERIALVERSIONID">Se: serialVersionUID isn't long (SE_NONLONG_SERIALVERSIONID)</a></h3>
1336
1337
1338 <p> This class defines a <code>serialVersionUID</code> field that is not long.&nbsp;
1339 The field should be made long
1340 if it is intended to specify
1341 the version UID for purposes of serialization.</p>
1342
1343
1344 <h3><a name="SE_NONSTATIC_SERIALVERSIONID">Se: serialVersionUID isn't static (SE_NONSTATIC_SERIALVERSIONID)</a></h3>
1345
1346
1347 <p> This class defines a <code>serialVersionUID</code> field that is not static.&nbsp;
1348 The field should be made static
1349 if it is intended to specify
1350 the version UID for purposes of serialization.</p>
1351
1352
1353 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR">Se: Class is Serializable but its superclass doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR)</a></h3>
1354
1355
1356 <p> This class implements the <code>Serializable</code> interface
1357 and its superclass does not. When such an object is deserialized,
1358 the fields of the superclass need to be initialized by
1359 invoking the void constructor of the superclass.
1360 Since the superclass does not have one,
1361 serialization and deserialization will fail at runtime.</p>
1362
1363
1364 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">Se: Class is Externalizable but doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION)</a></h3>
1365
1366
1367 <p> This class implements the <code>Externalizable</code> interface, but does
1368 not define a void constructor. When Externalizable objects are deserialized,
1369 they first need to be constructed by invoking the void
1370 constructor. Since this class does not have one,
1371 serialization and deserialization will fail at runtime.</p>
1372
1373
1374 <h3><a name="SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: The readResolve method must be declared with a return type of Object. (SE_READ_RESOLVE_MUST_RETURN_OBJECT)</a></h3>
1375
1376
1377 <p> In order for the readResolve method to be recognized by the serialization
1378 mechanism, it must be declared to have a return type of Object.
1379 </p>
1380
1381
1382 <h3><a name="SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Transient field that isn't set by deserialization. (SE_TRANSIENT_FIELD_NOT_RESTORED)</a></h3>
1383
1384
1385 <p> This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any
1386 deserialized instance of the class.
1387 </p>
1388
1389
1390 <h3><a name="SE_NO_SERIALVERSIONID">SnVI: Class is Serializable, but doesn't define serialVersionUID (SE_NO_SERIALVERSIONID)</a></h3>
1391
1392
1393 <p> This class implements the <code>Serializable</code> interface, but does
1394 not define a <code>serialVersionUID</code> field.&nbsp;
1395 A change as simple as adding a reference to a .class object
1396 will add synthetic fields to the class,
1397 which will unfortunately change the implicit
1398 serialVersionUID (e.g., adding a reference to <code>String.class</code>
1399 will generate a static field <code>class$java$lang$String</code>).
1400 Also, different source code to bytecode compilers may use different
1401 naming conventions for synthetic variables generated for
1402 references to class objects or inner classes.
1403 To ensure interoperability of Serializable across versions,
1404 consider adding an explicit serialVersionUID.</p>
1405
1406
1407 <h3><a name="UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: Usage of GetResource may be unsafe if class is extended (UI_INHERITANCE_UNSAFE_GETRESOURCE)</a></h3>
1408
1409
1410 <p>Calling <code>this.getClass().getResource(...)</code> could give
1411 results other than expected if this class is extended by a class in
1412 another package.</p>
1413
1414
1415 <h3><a name="BAC_BAD_APPLET_CONSTRUCTOR">BAC: Bad Applet Constructor relies on uninitialized AppletStub (BAC_BAD_APPLET_CONSTRUCTOR)</a></h3>
1416
1417
1418 <p>
1419 This constructor calls methods in the parent Applet that rely on the AppletStub. Since the AppletStub
1420 isn't initialized until the init() method of this applet is called, these methods will not perform
1421 correctly.
1422 </p>
1423
1424
1425 <h3><a name="BC_IMPOSSIBLE_CAST">BC: Impossible cast (BC_IMPOSSIBLE_CAST)</a></h3>
1426
1427
1428 <p>
1429 This cast will always throw a ClassCastException.
1430 FindBugs tracks type information from instanceof checks,
1431 and also uses more precise information about the types
1432 of values returned from methods and loaded from fields.
1433 Thus, it may have more precise information that just
1434 the declared type of a variable, and can use this to determine
1435 that a cast will always throw an exception at runtime.
1436
1437 </p>
1438
1439
1440 <h3><a name="BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downcast (BC_IMPOSSIBLE_DOWNCAST)</a></h3>
1441
1442
1443 <p>
1444 This cast will always throw a ClassCastException.
1445 The analysis believes it knows
1446 the precise type of the value being cast, and the attempt to
1447 downcast it to a subtype will always fail by throwing a ClassCastException.
1448 </p>
1449
1450
1451 <h3><a name="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impossible downcast of toArray() result (BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY)</a></h3>
1452
1453
1454 <p>
1455 This code is casting the result of calling <code>toArray()</code> on a collection
1456 to a type more specific than <code>Object[]</code>, as in:</p>
1457 <pre>
1458 String[] getAsArray(Collection&lt;String&gt; c) {
1459 return (String[]) c.toArray();
1460 }
1461 </pre>
1462 <p>This will usually fail by throwing a ClassCastException. The <code>toArray()</code>
1463 of almost all collections return an <code>Object[]</code>. They can't really do anything else,
1464 since the Collection object has no reference to the declared generic type of the collection.
1465 <p>The correct way to do get an array of a specific type from a collection is to use
1466 <code>c.toArray(new String[]);</code>
1467 or <code>c.toArray(new String[c.size()]);</code> (the latter is slightly more efficient).
1468 <p>There is one common/known exception exception to this. The <code>toArray()</code>
1469 method of lists returned by <code>Arrays.asList(...)</code> will return a covariantly
1470 typed array. For example, <code>Arrays.asArray(new String[] { "a" }).toArray()</code>
1471 will return a <code>String []</code>. FindBugs attempts to detect and suppress
1472 such cases, but may miss some.
1473 </p>
1474
1475
1476 <h3><a name="BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof will always return false (BC_IMPOSSIBLE_INSTANCEOF)</a></h3>
1477
1478
1479 <p>
1480 This instanceof test will always return false. Although this is safe, make sure it isn't
1481 an indication of some misunderstanding or some other logic error.
1482 </p>
1483
1484
1485 <h3><a name="BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of signed byte value (BIT_ADD_OF_SIGNED_BYTE)</a></h3>
1486
1487
1488 <p> Adds a byte value and a value which is known to have the 8 lower bits clear.
1489 Values loaded from a byte array are sign extended to 32 bits
1490 before any any bitwise operations are performed on the value.
1491 Thus, if <code>b[0]</code> contains the value <code>0xff</code>, and
1492 <code>x</code> is initially 0, then the code
1493 <code>((x &lt;&lt; 8) + b[0])</code> will sign extend <code>0xff</code>
1494 to get <code>0xffffffff</code>, and thus give the value
1495 <code>0xffffffff</code> as the result.
1496 </p>
1497
1498 <p>In particular, the following code for packing a byte array into an int is badly wrong: </p>
1499 <pre>
1500 int result = 0;
1501 for(int i = 0; i &lt; 4; i++)
1502 result = ((result &lt;&lt; 8) + b[i]);
1503 </pre>
1504
1505 <p>The following idiom will work instead: </p>
1506 <pre>
1507 int result = 0;
1508 for(int i = 0; i &lt; 4; i++)
1509 result = ((result &lt;&lt; 8) + (b[i] &amp; 0xff));
1510 </pre>
1511
1512
1513
1514 <h3><a name="BIT_AND">BIT: Incompatible bit masks (BIT_AND)</a></h3>
1515
1516
1517 <p> This method compares an expression of the form (e &amp; C) to D,
1518 which will always compare unequal
1519 due to the specific values of constants C and D.
1520 This may indicate a logic error or typo.</p>
1521
1522
1523 <h3><a name="BIT_AND_ZZ">BIT: Check to see if ((...) & 0) == 0 (BIT_AND_ZZ)</a></h3>
1524
1525
1526 <p> This method compares an expression of the form (e &amp; 0) to 0,
1527 which will always compare equal.
1528 This may indicate a logic error or typo.</p>
1529
1530
1531 <h3><a name="BIT_IOR">BIT: Incompatible bit masks (BIT_IOR)</a></h3>
1532
1533
1534 <p> This method compares an expression of the form (e | C) to D.
1535 which will always compare unequal
1536 due to the specific values of constants C and D.
1537 This may indicate a logic error or typo.</p>
1538
1539 <p> Typically, this bug occurs because the code wants to perform
1540 a membership test in a bit set, but uses the bitwise OR
1541 operator ("|") instead of bitwise AND ("&amp;").</p>
1542
1543
1544 <h3><a name="BIT_IOR_OF_SIGNED_BYTE">BIT: Bitwise OR of signed byte value (BIT_IOR_OF_SIGNED_BYTE)</a></h3>
1545
1546
1547 <p> Loads a byte value (e.g., a value loaded from a byte array or returned by a method
1548 with return type byte) and performs a bitwise OR with
1549 that value. Byte values are sign extended to 32 bits
1550 before any any bitwise operations are performed on the value.
1551 Thus, if <code>b[0]</code> contains the value <code>0xff</code>, and
1552 <code>x</code> is initially 0, then the code
1553 <code>((x &lt;&lt; 8) | b[0])</code> will sign extend <code>0xff</code>
1554 to get <code>0xffffffff</code>, and thus give the value
1555 <code>0xffffffff</code> as the result.
1556 </p>
1557
1558 <p>In particular, the following code for packing a byte array into an int is badly wrong: </p>
1559 <pre>
1560 int result = 0;
1561 for(int i = 0; i &lt; 4; i++)
1562 result = ((result &lt;&lt; 8) | b[i]);
1563 </pre>
1564
1565 <p>The following idiom will work instead: </p>
1566 <pre>
1567 int result = 0;
1568 for(int i = 0; i &lt; 4; i++)
1569 result = ((result &lt;&lt; 8) | (b[i] &amp; 0xff));
1570 </pre>
1571
1572
1573
1574 <h3><a name="BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK_HIGH_BIT)</a></h3>
1575
1576
1577 <p> This method compares an expression such as</p>
1578 <pre>((event.detail &amp; SWT.SELECTED) &gt; 0)</pre>.
1579 <p>Using bit arithmetic and then comparing with the greater than operator can
1580 lead to unexpected results (of course depending on the value of
1581 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
1582 for a bug. Even when SWT.SELECTED is not negative, it seems good practice
1583 to use '!= 0' instead of '&gt; 0'.
1584 </p>
1585 <p>
1586 <em>Boris Bokowski</em>
1587 </p>
1588
1589
1590 <h3><a name="BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: Class overrides a method implemented in super class Adapter wrongly (BOA_BADLY_OVERRIDDEN_ADAPTER)</a></h3>
1591
1592
1593 <p> This method overrides a method found in a parent class, where that class is an Adapter that implements
1594 a listener defined in the java.awt.event or javax.swing.event package. As a result, this method will not
1595 get called when the event occurs.</p>
1596
1597
1598 <h3><a name="ICAST_BAD_SHIFT_AMOUNT">BSHIFT: 32 bit int shifted by an amount not in the range -31..31 (ICAST_BAD_SHIFT_AMOUNT)</a></h3>
1599
1600
1601 <p>
1602 The code performs shift of a 32 bit int by a constant amount outside
1603 the range -31..31.
1604 The effect of this is to use the lower 5 bits of the integer
1605 value to decide how much to shift by (e.g., shifting by 40 bits is the same as shifting by 8 bits,
1606 and shifting by 32 bits is the same as shifting by zero bits). This probably isn't what was expected,
1607 and it is at least confusing.
1608 </p>
1609
1610
1611 <h3><a name="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR">Bx: Primitive value is unboxed and coerced for ternary operator (BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR)</a></h3>
1612
1613
1614 <p>A wrapped primitive value is unboxed and converted to another primitive type as part of the
1615 evaluation of a conditional ternary operator (the <code> b ? e1 : e2</code> operator). The
1616 semantics of Java mandate that if <code>e1</code> and <code>e2</code> are wrapped
1617 numeric values, the values are unboxed and converted/coerced to their common type (e.g,
1618 if <code>e1</code> is of type <code>Integer</code>
1619 and <code>e2</code> is of type <code>Float</code>, then <code>e1</code> is unboxed,
1620 converted to a floating point value, and boxed. See JLS Section 15.25.
1621 </p>
1622
1623
1624 <h3><a name="CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareTo()/compare() returns Integer.MIN_VALUE (CO_COMPARETO_RESULTS_MIN_VALUE)</a></h3>
1625
1626
1627 <p> In some situation, this compareTo or compare method returns
1628 the constant Integer.MIN_VALUE, which is an exceptionally bad practice.
1629 The only thing that matters about the return value of compareTo is the sign of the result.
1630 But people will sometimes negate the return value of compareTo, expecting that this will negate
1631 the sign of the result. And it will, except in the case where the value returned is Integer.MIN_VALUE.
1632 So just return -1 rather than Integer.MIN_VALUE.
1633
1634
1635 <h3><a name="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Useless increment in return statement (DLS_DEAD_LOCAL_INCREMENT_IN_RETURN)</a></h3>
1636
1637
1638 <p>This statement has a return such as <code>return x++;</code>.
1639 A postfix increment/decrement does not impact the value of the expression,
1640 so this increment/decrement has no effect.
1641 Please verify that this statement does the right thing.
1642 </p>
1643
1644
1645 <h3><a name="DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead store of class literal (DLS_DEAD_STORE_OF_CLASS_LITERAL)</a></h3>
1646
1647
1648 <p>
1649 This instruction assigns a class literal to a variable and then never uses it.
1650 <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The behavior of this differs in Java 1.4 and in Java 5.</a>
1651 In Java 1.4 and earlier, a reference to <code>Foo.class</code> would force the static initializer
1652 for <code>Foo</code> to be executed, if it has not been executed already.
1653 In Java 5 and later, it does not.
1654 </p>
1655 <p>See Sun's <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">article on Java SE compatibility</a>
1656 for more details and examples, and suggestions on how to force class initialization in Java 5.
1657 </p>
1658
1659
1660 <h3><a name="DLS_OVERWRITTEN_INCREMENT">DLS: Overwritten increment (DLS_OVERWRITTEN_INCREMENT)</a></h3>
1661
1662
1663 <p>
1664 The code performs an increment operation (e.g., <code>i++</code>) and then
1665 immediately overwrites it. For example, <code>i = i++</code> immediately
1666 overwrites the incremented value with the original value.
1667 </p>
1668
1669
1670 <h3><a name="DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed method arguments (DMI_ARGUMENTS_WRONG_ORDER)</a></h3>
1671
1672
1673 <p> The arguments to this method call seem to be in the wrong order.
1674 For example, a call <code>Preconditions.checkNotNull("message", message)</code>
1675 has reserved arguments: the value to be checked is the first argument.
1676 </p>
1677
1678
1679 <h3><a name="DMI_BAD_MONTH">DMI: Bad constant value for month (DMI_BAD_MONTH)</a></h3>
1680
1681
1682 <p>
1683 This code passes a constant month
1684 value outside the expected range of 0..11 to a method.
1685 </p>
1686
1687
1688 <h3><a name="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI: BigDecimal constructed from double that isn't represented precisely (DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE)</a></h3>
1689
1690
1691 <p>
1692 This code creates a BigDecimal from a double value that doesn't translate well to a
1693 decimal number.
1694 For example, one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.
1695 You probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation
1696 of the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1).
1697 </p>
1698
1699
1700
1701 <h3><a name="DMI_CALLING_NEXT_FROM_HASNEXT">DMI: hasNext method invokes next (DMI_CALLING_NEXT_FROM_HASNEXT)</a></h3>
1702
1703
1704 <p>
1705 The hasNext() method invokes the next() method. This is almost certainly wrong,
1706 since the hasNext() method is not supposed to change the state of the iterator,
1707 and the next method is supposed to change the state of the iterator.
1708 </p>
1709
1710
1711 <h3><a name="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES">DMI: Collections should not contain themselves (DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES)</a></h3>
1712
1713
1714 <p> This call to a generic collection's method would only make sense if a collection contained
1715 itself (e.g., if <code>s.contains(s)</code> were true). This is unlikely to be true and would cause
1716 problems if it were true (such as the computation of the hash code resulting in infinite recursion).
1717 It is likely that the wrong value is being passed as a parameter.
1718 </p>
1719
1720
1721 <h3><a name="DMI_DOH">DMI: D'oh! A nonsensical method invocation (DMI_DOH)</a></h3>
1722
1723
1724 <p>
1725 This partical method invocation doesn't make sense, for reasons that should be apparent from inspection.
1726 </p>
1727
1728
1729
1730 <h3><a name="DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocation of hashCode on an array (DMI_INVOKING_HASHCODE_ON_ARRAY)</a></h3>
1731
1732
1733 <p>
1734 The code invokes hashCode on an array. Calling hashCode on
1735 an array returns the same value as System.identityHashCode, and ingores
1736 the contents and length of the array. If you need a hashCode that
1737 depends on the contents of an array <code>a</code>,
1738 use <code>java.util.Arrays.hashCode(a)</code>.
1739
1740 </p>
1741
1742
1743 <h3><a name="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI: Double.longBitsToDouble invoked on an int (DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT)</a></h3>
1744
1745
1746 <p> The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed
1747 as an argument. This almostly certainly is not intended and is unlikely
1748 to give the intended result.
1749 </p>
1750
1751
1752 <h3><a name="DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuous call to collections (DMI_VACUOUS_SELF_COLLECTION_CALL)</a></h3>
1753
1754
1755 <p> This call doesn't make sense. For any collection <code>c</code>, calling <code>c.containsAll(c)</code> should
1756 always be true, and <code>c.retainAll(c)</code> should have no effect.
1757 </p>
1758
1759
1760 <h3><a name="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">Dm: Can't use reflection to check for presence of annotation without runtime retention (DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION)</a></h3>
1761
1762
1763 <p> Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection
1764 (e.g., by using the isAnnotationPresent method).
1765 .</p>
1766
1767
1768 <h3><a name="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR">Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor (DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR)</a></h3>
1769
1770
1771 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html">Javadoc</a>)
1772 While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect.
1773 </p>
1774
1775
1776
1777 <h3><a name="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS">Dm: Creation of ScheduledThreadPoolExecutor with zero core threads (DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS)</a></h3>
1778
1779
1780 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html#ScheduledThreadPoolExecutor(int)">Javadoc</a>)
1781 A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.
1782 </p>
1783
1784
1785
1786 <h3><a name="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Useless/vacuous call to EasyMock method (DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD)</a></h3>
1787
1788
1789 <p>This call doesn't pass any objects to the EasyMock method, so the call doesn't do anything.
1790 </p>
1791
1792
1793
1794 <h3><a name="EC_ARRAY_AND_NONARRAY">EC: equals() used to compare array and nonarray (EC_ARRAY_AND_NONARRAY)</a></h3>
1795
1796
1797 <p>
1798 This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem
1799 to be an array. If things being compared are of different types, they are guaranteed to be unequal
1800 and the comparison is almost certainly an error. Even if they are both arrays, the equals method
1801 on arrays only determines of the two arrays are the same object.
1802 To compare the
1803 contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
1804 </p>
1805
1806
1807 <h3><a name="EC_BAD_ARRAY_COMPARE">EC: Invocation of equals() on an array, which is equivalent to == (EC_BAD_ARRAY_COMPARE)</a></h3>
1808
1809
1810 <p>
1811 This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals
1812 method of Object, calling equals on an array is the same as comparing their addresses. To compare the
1813 contents of the arrays, use <code>java.util.Arrays.equals(Object[], Object[])</code>.
1814 To compare the addresses of the arrays, it would be
1815 less confusing to explicitly check pointer equality using <code>==</code>.
1816 </p>
1817
1818
1819 <h3><a name="EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(...) used to compare incompatible arrays (EC_INCOMPATIBLE_ARRAY_COMPARE)</a></h3>
1820
1821
1822 <p>
1823 This method invokes the .equals(Object o) to compare two arrays, but the arrays of
1824 of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]).
1825 They will never be equal. In addition, when equals(...) is used to compare arrays it
1826 only checks to see if they are the same array, and ignores the contents of the arrays.
1827 </p>
1828
1829
1830 <h3><a name="EC_NULL_ARG">EC: Call to equals(null) (EC_NULL_ARG)</a></h3>
1831
1832
1833 <p> This method calls equals(Object), passing a null value as
1834 the argument. According to the contract of the equals() method,
1835 this call should always return <code>false</code>.</p>
1836
1837
1838 <h3><a name="EC_UNRELATED_CLASS_AND_INTERFACE">EC: Call to equals() comparing unrelated class and interface (EC_UNRELATED_CLASS_AND_INTERFACE)</a></h3>
1839
1840
1841 <p>
1842 This method calls equals(Object) on two references, one of which is a class
1843 and the other an interface, where neither the class nor any of its
1844 non-abstract subclasses implement the interface.
1845 Therefore, the objects being compared
1846 are unlikely to be members of the same class at runtime
1847 (unless some application classes were not analyzed, or dynamic class
1848 loading can occur at runtime).
1849 According to the contract of equals(),
1850 objects of different
1851 classes should always compare as unequal; therefore, according to the
1852 contract defined by java.lang.Object.equals(Object),
1853 the result of this comparison will always be false at runtime.
1854 </p>
1855
1856
1857 <h3><a name="EC_UNRELATED_INTERFACES">EC: Call to equals() comparing different interface types (EC_UNRELATED_INTERFACES)</a></h3>
1858
1859
1860 <p> This method calls equals(Object) on two references of unrelated
1861 interface types, where neither is a subtype of the other,
1862 and there are no known non-abstract classes which implement both interfaces.
1863 Therefore, the objects being compared
1864 are unlikely to be members of the same class at runtime
1865 (unless some application classes were not analyzed, or dynamic class
1866 loading can occur at runtime).
1867 According to the contract of equals(),
1868 objects of different
1869 classes should always compare as unequal; therefore, according to the
1870 contract defined by java.lang.Object.equals(Object),
1871 the result of this comparison will always be false at runtime.
1872 </p>
1873
1874
1875 <h3><a name="EC_UNRELATED_TYPES">EC: Call to equals() comparing different types (EC_UNRELATED_TYPES)</a></h3>
1876
1877
1878 <p> This method calls equals(Object) on two references of different
1879 class types with no common subclasses.
1880 Therefore, the objects being compared
1881 are unlikely to be members of the same class at runtime
1882 (unless some application classes were not analyzed, or dynamic class
1883 loading can occur at runtime).
1884 According to the contract of equals(),
1885 objects of different
1886 classes should always compare as unequal; therefore, according to the
1887 contract defined by java.lang.Object.equals(Object),
1888 the result of this comparison will always be false at runtime.
1889 </p>
1890
1891
1892 <h3><a name="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">EC: Using pointer equality to compare different types (EC_UNRELATED_TYPES_USING_POINTER_EQUALITY)</a></h3>
1893
1894
1895 <p> This method uses using pointer equality to compare two references that seem to be of
1896 different types. The result of this comparison will always be false at runtime.
1897 </p>
1898
1899
1900 <h3><a name="EQ_ALWAYS_FALSE">Eq: equals method always returns false (EQ_ALWAYS_FALSE)</a></h3>
1901
1902
1903 <p> This class defines an equals method that always returns false. This means that an object is not equal to itself, and it is impossible to create useful Maps or Sets of this class. More fundamentally, it means
1904 that equals is not reflexive, one of the requirements of the equals method.</p>
1905 <p>The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class <code>Object</code>. If you need to override an equals inherited from a different
1906 superclass, you can use use:</p>
1907 <pre>
1908 public boolean equals(Object o) { return this == o; }
1909 </pre>
1910
1911
1912 <h3><a name="EQ_ALWAYS_TRUE">Eq: equals method always returns true (EQ_ALWAYS_TRUE)</a></h3>
1913
1914
1915 <p> This class defines an equals method that always returns true. This is imaginative, but not very smart.
1916 Plus, it means that the equals method is not symmetric.
1917 </p>
1918
1919
1920 <h3><a name="EQ_COMPARING_CLASS_NAMES">Eq: equals method compares class names rather than class objects (EQ_COMPARING_CLASS_NAMES)</a></h3>
1921
1922
1923 <p> This method checks to see if two objects are the same class by checking to see if the names
1924 of their classes are equal. You can have different classes with the same name if they are loaded by
1925 different class loaders. Just check to see if the class objects are the same.
1926 </p>
1927
1928
1929 <h3><a name="EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covariant equals() method defined for enum (EQ_DONT_DEFINE_EQUALS_FOR_ENUM)</a></h3>
1930
1931
1932 <p> This class defines an enumeration, and equality on enumerations are defined
1933 using object identity. Defining a covariant equals method for an enumeration
1934 value is exceptionally bad practice, since it would likely result
1935 in having two different enumeration values that compare as equals using
1936 the covariant enum method, and as not equal when compared normally.
1937 Don't do it.
1938 </p>
1939
1940
1941 <h3><a name="EQ_OTHER_NO_OBJECT">Eq: equals() method defined that doesn't override equals(Object) (EQ_OTHER_NO_OBJECT)</a></h3>
1942
1943
1944 <p> This class defines an <code>equals()</code>
1945 method, that doesn't override the normal <code>equals(Object)</code> method
1946 defined in the base <code>java.lang.Object</code> class.&nbsp; Instead, it
1947 inherits an <code>equals(Object)</code> method from a superclass.
1948 The class should probably define a <code>boolean equals(Object)</code> method.
1949 </p>
1950
1951
1952 <h3><a name="EQ_OTHER_USE_OBJECT">Eq: equals() method defined that doesn't override Object.equals(Object) (EQ_OTHER_USE_OBJECT)</a></h3>
1953
1954
1955 <p> This class defines an <code>equals()</code>
1956 method, that doesn't override the normal <code>equals(Object)</code> method
1957 defined in the base <code>java.lang.Object</code> class.&nbsp;
1958 The class should probably define a <code>boolean equals(Object)</code> method.
1959 </p>
1960
1961
1962 <h3><a name="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equals method overrides equals in superclass and may not be symmetric (EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC)</a></h3>
1963
1964
1965 <p> This class defines an equals method that overrides an equals method in a superclass. Both equals methods
1966 methods use <code>instanceof</code> in the determination of whether two objects are equal. This is fraught with peril,
1967 since it is important that the equals method is symmetrical (in other words, <code>a.equals(b) == b.equals(a)</code>).
1968 If B is a subtype of A, and A's equals method checks that the argument is an instanceof A, and B's equals method
1969 checks that the argument is an instanceof B, it is quite likely that the equivalence relation defined by these
1970 methods is not symmetric.
1971 </p>
1972
1973
1974 <h3><a name="EQ_SELF_USE_OBJECT">Eq: Covariant equals() method defined, Object.equals(Object) inherited (EQ_SELF_USE_OBJECT)</a></h3>
1975
1976
1977 <p> This class defines a covariant version of the <code>equals()</code>
1978 method, but inherits the normal <code>equals(Object)</code> method
1979 defined in the base <code>java.lang.Object</code> class.&nbsp;
1980 The class should probably define a <code>boolean equals(Object)</code> method.
1981 </p>
1982
1983
1984 <h3><a name="FB_MISSING_EXPECTED_WARNING">FB: Missing expected or desired warning from FindBugs (FB_MISSING_EXPECTED_WARNING)</a></h3>
1985
1986
1987 <p>FindBugs didn't generate generated a warning that, according to a @ExpectedWarning annotated,
1988 is expected or desired</p>
1989
1990
1991 <h3><a name="FB_UNEXPECTED_WARNING">FB: Unexpected/undesired warning from FindBugs (FB_UNEXPECTED_WARNING)</a></h3>
1992
1993
1994 <p>FindBugs generated a warning that, according to a @NoWarning annotated,
1995 is unexpected or undesired</p>
1996
1997
1998 <h3><a name="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Doomed test for equality to NaN (FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER)</a></h3>
1999
2000
2001 <p>
2002 This code checks to see if a floating point value is equal to the special
2003 Not A Number value (e.g., <code>if (x == Double.NaN)</code>). However,
2004 because of the special semantics of <code>NaN</code>, no value
2005 is equal to <code>Nan</code>, including <code>NaN</code>. Thus,
2006 <code>x == Double.NaN</code> always evaluates to false.
2007
2008 To check to see if a value contained in <code>x</code>
2009 is the special Not A Number value, use
2010 <code>Double.isNaN(x)</code> (or <code>Float.isNaN(x)</code> if
2011 <code>x</code> is floating point precision).
2012 </p>
2013
2014
2015 <h3><a name="FL_MATH_USING_FLOAT_PRECISION">FL: Method performs math using floating point precision (FL_MATH_USING_FLOAT_PRECISION)</a></h3>
2016
2017
2018 <p>
2019 The method performs math operations using floating point precision.
2020 Floating point precision is very imprecise. For example,
2021 16777216.0f + 1.0f = 16777216.0f. Consider using double math instead.</p>
2022
2023
2024 <h3><a name="VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format string placeholder incompatible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)</a></h3>
2025
2026
2027 <p>
2028 The format string placeholder is incompatible with the corresponding
2029 argument. For example,
2030 <code>
2031 System.out.println("%d\n", "hello");
2032 </code>
2033 <p>The %d placeholder requires a numeric argument, but a string value is
2034 passed instead.
2035 A runtime exception will occur when
2036 this statement is executed.
2037 </p>
2038
2039
2040 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION">FS: The type of a supplied argument doesn't match format specifier (VA_FORMAT_STRING_BAD_CONVERSION)</a></h3>
2041
2042
2043 <p>
2044 One of the arguments is uncompatible with the corresponding format string specifier.
2045 As a result, this will generate a runtime exception when executed.
2046 For example, <code>String.format("%d", "1")</code> will generate an exception, since
2047 the String "1" is incompatible with the format specifier %d.
2048 </p>
2049
2050
2051 <h3><a name="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED">FS: MessageFormat supplied where printf style format expected (VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED)</a></h3>
2052
2053
2054 <p>
2055 A method is called that expects a Java printf format string and a list of arguments.
2056 However, the format string doesn't contain any format specifiers (e.g., %s) but
2057 does contain message format elements (e.g., {0}). It is likely
2058 that the code is supplying a MessageFormat string when a printf-style format string
2059 is required. At runtime, all of the arguments will be ignored
2060 and the format string will be returned exactly as provided without any formatting.
2061 </p>
2062
2063
2064 <h3><a name="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS: More arguments are passed than are actually used in the format string (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED)</a></h3>
2065
2066
2067 <p>
2068 A format-string method with a variable number of arguments is called,
2069 but more arguments are passed than are actually used by the format string.
2070 This won't cause a runtime exception, but the code may be silently omitting
2071 information that was intended to be included in the formatted string.
2072 </p>
2073
2074
2075 <h3><a name="VA_FORMAT_STRING_ILLEGAL">FS: Illegal format string (VA_FORMAT_STRING_ILLEGAL)</a></h3>
2076
2077
2078 <p>
2079 The format string is syntactically invalid,
2080 and a runtime exception will occur when
2081 this statement is executed.
2082 </p>
2083
2084
2085 <h3><a name="VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Format string references missing argument (VA_FORMAT_STRING_MISSING_ARGUMENT)</a></h3>
2086
2087
2088 <p>
2089 Not enough arguments are passed to satisfy a placeholder in the format string.
2090 A runtime exception will occur when
2091 this statement is executed.
2092 </p>
2093
2094
2095 <h3><a name="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: No previous argument for format string (VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)</a></h3>
2096
2097
2098 <p>
2099 The format string specifies a relative index to request that the argument for the previous format specifier
2100 be reused. However, there is no previous argument.
2101 For example,
2102 </p>
2103 <p><code>formatter.format("%&lt;s %s", "a", "b")</code>
2104 </p>
2105 <p>would throw a MissingFormatArgumentException when executed.
2106 </p>
2107
2108
2109 <h3><a name="GC_UNRELATED_TYPES">GC: No relationship between generic parameter and method argument (GC_UNRELATED_TYPES)</a></h3>
2110
2111
2112 <p> This call to a generic collection method contains an argument
2113 with an incompatible class from that of the collection's parameter
2114 (i.e., the type of the argument is neither a supertype nor a subtype
2115 of the corresponding generic type argument).
2116 Therefore, it is unlikely that the collection contains any objects
2117 that are equal to the method argument used here.
2118 Most likely, the wrong value is being passed to the method.</p>
2119 <p>In general, instances of two unrelated classes are not equal.
2120 For example, if the <code>Foo</code> and <code>Bar</code> classes
2121 are not related by subtyping, then an instance of <code>Foo</code>
2122 should not be equal to an instance of <code>Bar</code>.
2123 Among other issues, doing so will likely result in an equals method
2124 that is not symmetrical. For example, if you define the <code>Foo</code> class
2125 so that a <code>Foo</code> can be equal to a <code>String</code>,
2126 your equals method isn't symmetrical since a <code>String</code> can only be equal
2127 to a <code>String</code>.
2128 </p>
2129 <p>In rare cases, people do define nonsymmetrical equals methods and still manage to make
2130 their code work. Although none of the APIs document or guarantee it, it is typically
2131 the case that if you check if a <code>Collection&lt;String&gt;</code> contains
2132 a <code>Foo</code>, the equals method of argument (e.g., the equals method of the
2133 <code>Foo</code> class) used to perform the equality checks.
2134 </p>
2135
2136
2137 <h3><a name="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS">HE: Signature declares use of unhashable class in hashed construct (HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS)</a></h3>
2138
2139
2140 <p> A method, field or class declares a generic signature where a non-hashable class
2141 is used in context where a hashable class is required.
2142 A class that declares an equals method but inherits a hashCode() method
2143 from Object is unhashable, since it doesn't fulfill the requirement that
2144 equal objects have equal hashCodes.
2145 </p>
2146
2147
2148 <h3><a name="HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class without a hashCode() method in a hashed data structure (HE_USE_OF_UNHASHABLE_CLASS)</a></h3>
2149
2150
2151 <p> A class defines an equals(Object) method but not a hashCode() method,
2152 and thus doesn't fulfill the requirement that equal objects have equal hashCodes.
2153 An instance of this class is used in a hash data structure, making the need to
2154 fix this problem of highest importance.
2155
2156
2157 <h3><a name="ICAST_INT_2_LONG_AS_INSTANT">ICAST: int value converted to long and used as absolute time (ICAST_INT_2_LONG_AS_INSTANT)</a></h3>
2158
2159
2160 <p>
2161 This code converts a 32-bit int value to a 64-bit long value, and then
2162 passes that value for a method parameter that requires an absolute time value.
2163 An absolute time value is the number
2164 of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
2165 For example, the following method, intended to convert seconds since the epoc into a Date, is badly
2166 broken:</p>
2167 <pre>
2168 Date getDate(int seconds) { return new Date(seconds * 1000); }
2169 </pre>
2170 <p>The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value.
2171 When a 32-bit value is converted to 64-bits and used to express an absolute time
2172 value, only dates in December 1969 and January 1970 can be represented.</p>
2173
2174 <p>Correct implementations for the above method are:</p>
2175
2176 <pre>
2177 // Fails for dates after 2037
2178 Date getDate(int seconds) { return new Date(seconds * 1000L); }
2179
2180 // better, works for all dates
2181 Date getDate(long seconds) { return new Date(seconds * 1000); }
2182 </pre>
2183
2184
2185 <h3><a name="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICAST: Integral value cast to double and then passed to Math.ceil (ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL)</a></h3>
2186
2187
2188 <p>
2189 This code converts an integral value (e.g., int or long)
2190 to a double precision
2191 floating point number and then
2192 passing the result to the Math.ceil() function, which rounds a double to
2193 the next higher integer value. This operation should always be a no-op,
2194 since the converting an integer to a double should give a number with no fractional part.
2195 It is likely that the operation that generated the value to be passed
2196 to Math.ceil was intended to be performed using double precision
2197 floating point arithmetic.
2198 </p>
2199
2200
2201
2202 <h3><a name="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICAST: int value cast to float and then passed to Math.round (ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND)</a></h3>
2203
2204
2205 <p>
2206 This code converts an int value to a float precision
2207 floating point number and then
2208 passing the result to the Math.round() function, which returns the int/long closest
2209 to the argument. This operation should always be a no-op,
2210 since the converting an integer to a float should give a number with no fractional part.
2211 It is likely that the operation that generated the value to be passed
2212 to Math.round was intended to be performed using
2213 floating point arithmetic.
2214 </p>
2215
2216
2217
2218 <h3><a name="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">IJU: JUnit assertion in run method will not be noticed by JUnit (IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD)</a></h3>
2219
2220
2221 <p> A JUnit assertion is performed in a run method. Failed JUnit assertions
2222 just result in exceptions being thrown.
2223 Thus, if this exception occurs in a thread other than the thread that invokes
2224 the test method, the exception will terminate the thread but not result
2225 in the test failing.
2226 </p>
2227
2228
2229 <h3><a name="IJU_BAD_SUITE_METHOD">IJU: TestCase declares a bad suite method (IJU_BAD_SUITE_METHOD)</a></h3>
2230
2231
2232 <p> Class is a JUnit TestCase and defines a suite() method.
2233 However, the suite method needs to be declared as either</p>
2234 <pre>public static junit.framework.Test suite()</pre>
2235 or
2236 <pre>public static junit.framework.TestSuite suite()</pre>
2237
2238
2239 <h3><a name="IJU_NO_TESTS">IJU: TestCase has no tests (IJU_NO_TESTS)</a></h3>
2240
2241
2242 <p> Class is a JUnit TestCase but has not implemented any test methods</p>
2243
2244
2245 <h3><a name="IJU_SETUP_NO_SUPER">IJU: TestCase defines setUp that doesn't call super.setUp() (IJU_SETUP_NO_SUPER)</a></h3>
2246
2247
2248 <p> Class is a JUnit TestCase and implements the setUp method. The setUp method should call
2249 super.setUp(), but doesn't.</p>
2250
2251
2252 <h3><a name="IJU_SUITE_NOT_STATIC">IJU: TestCase implements a non-static suite method (IJU_SUITE_NOT_STATIC)</a></h3>
2253
2254
2255 <p> Class is a JUnit TestCase and implements the suite() method.
2256 The suite method should be declared as being static, but isn't.</p>
2257
2258
2259 <h3><a name="IJU_TEARDOWN_NO_SUPER">IJU: TestCase defines tearDown that doesn't call super.tearDown() (IJU_TEARDOWN_NO_SUPER)</a></h3>
2260
2261
2262 <p> Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call
2263 super.tearDown(), but doesn't.</p>
2264
2265
2266 <h3><a name="IL_CONTAINER_ADDED_TO_ITSELF">IL: A collection is added to itself (IL_CONTAINER_ADDED_TO_ITSELF)</a></h3>
2267
2268
2269 <p>A collection is added to itself. As a result, computing the hashCode of this
2270 set will throw a StackOverflowException.
2271 </p>
2272
2273
2274 <h3><a name="IL_INFINITE_LOOP">IL: An apparent infinite loop (IL_INFINITE_LOOP)</a></h3>
2275
2276
2277 <p>This loop doesn't seem to have a way to terminate (other than by perhaps
2278 throwing an exception).</p>
2279
2280
2281 <h3><a name="IL_INFINITE_RECURSIVE_LOOP">IL: An apparent infinite recursive loop (IL_INFINITE_RECURSIVE_LOOP)</a></h3>
2282
2283
2284 <p>This method unconditionally invokes itself. This would seem to indicate
2285 an infinite recursive loop that will result in a stack overflow.</p>
2286
2287
2288 <h3><a name="IM_MULTIPLYING_RESULT_OF_IREM">IM: Integer multiply of result of integer remainder (IM_MULTIPLYING_RESULT_OF_IREM)</a></h3>
2289
2290
2291 <p>
2292 The code multiplies the result of an integer remaining by an integer constant.
2293 Be sure you don't have your operator precedence confused. For example
2294 i % 60 * 1000 is (i % 60) * 1000, not i % (60 * 1000).
2295 </p>
2296
2297
2298 <h3><a name="INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad comparison of int value with long constant (INT_BAD_COMPARISON_WITH_INT_VALUE)</a></h3>
2299
2300
2301 <p> This code compares an int value with a long constant that is outside
2302 the range of values that can be represented as an int value.
2303 This comparison is vacuous and possibily to be incorrect.
2304 </p>
2305
2306
2307 <h3><a name="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT: Bad comparison of nonnegative value with negative constant (INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE)</a></h3>
2308
2309
2310 <p> This code compares a value that is guaranteed to be non-negative with a negative constant.
2311 </p>
2312
2313
2314 <h3><a name="INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Bad comparison of signed byte (INT_BAD_COMPARISON_WITH_SIGNED_BYTE)</a></h3>
2315
2316
2317 <p> Signed bytes can only have a value in the range -128 to 127. Comparing
2318 a signed byte with a value outside that range is vacuous and likely to be incorrect.
2319 To convert a signed byte <code>b</code> to an unsigned value in the range 0..255,
2320 use <code>0xff &amp; b</code>
2321 </p>
2322
2323
2324 <h3><a name="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Doomed attempt to append to an object output stream (IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)</a></h3>
2325
2326
2327 <p>
2328 This code opens a file in append mode and then wraps the result in an object output stream.
2329 This won't allow you to append to an existing object output stream stored in a file. If you want to be
2330 able to append to an object output stream, you need to keep the object output stream open.
2331 </p>
2332 <p>The only situation in which opening a file in append mode and the writing an object output stream
2333 could work is if on reading the file you plan to open it in random access mode and seek to the byte offset
2334 where the append started.
2335 </p>
2336
2337 <p>
2338 TODO: example.
2339 </p>
2340
2341
2342 <h3><a name="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: A parameter is dead upon entry to a method but overwritten (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)</a></h3>
2343
2344
2345 <p>
2346 The initial value of this parameter is ignored, and the parameter
2347 is overwritten here. This often indicates a mistaken belief that
2348 the write to the parameter will be conveyed back to
2349 the caller.
2350 </p>
2351
2352
2353 <h3><a name="MF_CLASS_MASKS_FIELD">MF: Class defines field that masks a superclass field (MF_CLASS_MASKS_FIELD)</a></h3>
2354
2355
2356 <p> This class defines a field with the same name as a visible
2357 instance field in a superclass. This is confusing, and
2358 may indicate an error if methods update or access one of
2359 the fields when they wanted the other.</p>
2360
2361
2362 <h3><a name="MF_METHOD_MASKS_FIELD">MF: Method defines a variable that obscures a field (MF_METHOD_MASKS_FIELD)</a></h3>
2363
2364
2365 <p> This method defines a local variable with the same name as a field
2366 in this class or a superclass. This may cause the method to
2367 read an uninitialized value from the field, leave the field uninitialized,
2368 or both.</p>
2369
2370
2371 <h3><a name="NP_ALWAYS_NULL">NP: Null pointer dereference (NP_ALWAYS_NULL)</a></h3>
2372
2373
2374 <p> A null pointer is dereferenced here.&nbsp; This will lead to a
2375 <code>NullPointerException</code> when the code is executed.</p>
2376
2377
2378 <h3><a name="NP_ALWAYS_NULL_EXCEPTION">NP: Null pointer dereference in method on exception path (NP_ALWAYS_NULL_EXCEPTION)</a></h3>
2379
2380
2381 <p> A pointer which is null on an exception path is dereferenced here.&nbsp;
2382 This will lead to a <code>NullPointerException</code> when the code is executed.&nbsp;
2383 Note that because FindBugs currently does not prune infeasible exception paths,
2384 this may be a false warning.</p>
2385
2386 <p> Also note that FindBugs considers the default case of a switch statement to
2387 be an exception path, since the default case is often infeasible.</p>
2388
2389
2390 <h3><a name="NP_ARGUMENT_MIGHT_BE_NULL">NP: Method does not check for null argument (NP_ARGUMENT_MIGHT_BE_NULL)</a></h3>
2391
2392
2393 <p>
2394 A parameter to this method has been identified as a value that should
2395 always be checked to see whether or not it is null, but it is being dereferenced
2396 without a preceding null check.
2397 </p>
2398
2399
2400 <h3><a name="NP_CLOSING_NULL">NP: close() invoked on a value that is always null (NP_CLOSING_NULL)</a></h3>
2401
2402
2403 <p> close() is being invoked on a value that is always null. If this statement is executed,
2404 a null pointer exception will occur. But the big risk here you never close
2405 something that should be closed.
2406
2407
2408 <h3><a name="NP_GUARANTEED_DEREF">NP: Null value is guaranteed to be dereferenced (NP_GUARANTEED_DEREF)</a></h3>
2409
2410
2411 <p>
2412 There is a statement or branch that if executed guarantees that
2413 a value is null at this point, and that
2414 value that is guaranteed to be dereferenced
2415 (except on forward paths involving runtime exceptions).
2416 </p>
2417 <p>Note that a check such as
2418 <code>if (x == null) throw new NullPointerException();</code>
2419 is treated as a dereference of <code>x</code>.
2420
2421
2422 <h3><a name="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: Value is null and guaranteed to be dereferenced on exception path (NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH)</a></h3>
2423
2424
2425 <p>
2426 There is a statement or branch on an exception path
2427 that if executed guarantees that
2428 a value is null at this point, and that
2429 value that is guaranteed to be dereferenced
2430 (except on forward paths involving runtime exceptions).
2431 </p>
2432
2433
2434 <h3><a name="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP: Nonnull field is not initialized (NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3>
2435
2436
2437 <p> The field is marked as nonnull, but isn't written to by the constructor.
2438 The field might be initialized elsewhere during constructor, or might always
2439 be initialized before use.
2440 </p>
2441
2442
2443 <h3><a name="NP_NONNULL_PARAM_VIOLATION">NP: Method call passes null to a nonnull parameter (NP_NONNULL_PARAM_VIOLATION)</a></h3>
2444
2445
2446 <p>
2447 This method passes a null value as the parameter of a method which
2448 must be nonnull. Either this parameter has been explicitly marked
2449 as @Nonnull, or analysis has determined that this parameter is
2450 always dereferenced.
2451 </p>
2452
2453
2454 <h3><a name="NP_NONNULL_RETURN_VIOLATION">NP: Method may return null, but is declared @NonNull (NP_NONNULL_RETURN_VIOLATION)</a></h3>
2455
2456
2457 <p>
2458 This method may return a null value, but the method (or a superclass method
2459 which it overrides) is declared to return @NonNull.
2460 </p>
2461
2462
2463 <h3><a name="NP_NULL_INSTANCEOF">NP: A known null value is checked to see if it is an instance of a type (NP_NULL_INSTANCEOF)</a></h3>
2464
2465
2466 <p>
2467 This instanceof test will always return false, since the value being checked is guaranteed to be null.
2468 Although this is safe, make sure it isn't
2469 an indication of some misunderstanding or some other logic error.
2470 </p>
2471
2472
2473 <h3><a name="NP_NULL_ON_SOME_PATH">NP: Possible null pointer dereference (NP_NULL_ON_SOME_PATH)</a></h3>
2474
2475
2476 <p> There is a branch of statement that, <em>if executed,</em> guarantees that
2477 a null value will be dereferenced, which
2478 would generate a <code>NullPointerException</code> when the code is executed.
2479 Of course, the problem might be that the branch or statement is infeasible and that
2480 the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
2481 </p>
2482
2483
2484 <h3><a name="NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible null pointer dereference in method on exception path (NP_NULL_ON_SOME_PATH_EXCEPTION)</a></h3>
2485
2486
2487 <p> A reference value which is null on some exception control path is
2488 dereferenced here.&nbsp; This may lead to a <code>NullPointerException</code>
2489 when the code is executed.&nbsp;
2490 Note that because FindBugs currently does not prune infeasible exception paths,
2491 this may be a false warning.</p>
2492
2493 <p> Also note that FindBugs considers the default case of a switch statement to
2494 be an exception path, since the default case is often infeasible.</p>
2495
2496
2497 <h3><a name="NP_NULL_PARAM_DEREF">NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF)</a></h3>
2498
2499
2500 <p>
2501 This method call passes a null value for a nonnull method parameter.
2502 Either the parameter is annotated as a parameter that should
2503 always be nonnull, or analysis has shown that it will always be
2504 dereferenced.
2505 </p>
2506
2507
2508 <h3><a name="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS)</a></h3>
2509
2510
2511 <p>
2512 A possibly-null value is passed at a call site where all known
2513 target methods require the parameter to be nonnull.
2514 Either the parameter is annotated as a parameter that should
2515 always be nonnull, or analysis has shown that it will always be
2516 dereferenced.
2517 </p>
2518
2519
2520 <h3><a name="NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Non-virtual method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_NONVIRTUAL)</a></h3>
2521
2522
2523 <p>
2524 A possibly-null value is passed to a nonnull method parameter.
2525 Either the parameter is annotated as a parameter that should
2526 always be nonnull, or analysis has shown that it will always be
2527 dereferenced.
2528 </p>
2529
2530
2531 <h3><a name="NP_STORE_INTO_NONNULL_FIELD">NP: Store of null value into field annotated NonNull (NP_STORE_INTO_NONNULL_FIELD)</a></h3>
2532
2533
2534 <p> A value that could be null is stored into a field that has been annotated as NonNull. </p>
2535
2536
2537 <h3><a name="NP_UNWRITTEN_FIELD">NP: Read of unwritten field (NP_UNWRITTEN_FIELD)</a></h3>
2538
2539
2540 <p> The program is dereferencing a field that does not seem to ever have a non-null value written to it.
2541 Unless the field is initialized via some mechanism not seen by the analysis,
2542 dereferencing this value will generate a null pointer exception.
2543 </p>
2544
2545
2546 <h3><a name="NM_BAD_EQUAL">Nm: Class defines equal(Object); should it be equals(Object)? (NM_BAD_EQUAL)</a></h3>
2547
2548
2549 <p> This class defines a method <code>equal(Object)</code>.&nbsp; This method does
2550 not override the <code>equals(Object)</code> method in <code>java.lang.Object</code>,
2551 which is probably what was intended.</p>
2552
2553
2554 <h3><a name="NM_LCASE_HASHCODE">Nm: Class defines hashcode(); should it be hashCode()? (NM_LCASE_HASHCODE)</a></h3>
2555
2556
2557 <p> This class defines a method called <code>hashcode()</code>.&nbsp; This method
2558 does not override the <code>hashCode()</code> method in <code>java.lang.Object</code>,
2559 which is probably what was intended.</p>
2560
2561
2562 <h3><a name="NM_LCASE_TOSTRING">Nm: Class defines tostring(); should it be toString()? (NM_LCASE_TOSTRING)</a></h3>
2563
2564
2565 <p> This class defines a method called <code>tostring()</code>.&nbsp; This method
2566 does not override the <code>toString()</code> method in <code>java.lang.Object</code>,
2567 which is probably what was intended.</p>
2568
2569
2570 <h3><a name="NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Apparent method/constructor confusion (NM_METHOD_CONSTRUCTOR_CONFUSION)</a></h3>
2571
2572
2573 <p> This regular method has the same name as the class it is defined in. It is likely that this was intended to be a constructor.
2574 If it was intended to be a constructor, remove the declaration of a void return value.
2575 If you had accidently defined this method, realized the mistake, defined a proper constructor
2576 but can't get rid of this method due to backwards compatibility, deprecate the method.
2577 </p>
2578
2579
2580 <h3><a name="NM_VERY_CONFUSING">Nm: Very confusing method names (NM_VERY_CONFUSING)</a></h3>
2581
2582
2583 <p> The referenced methods have names that differ only by capitalization.
2584 This is very confusing because if the capitalization were
2585 identical then one of the methods would override the other.
2586 </p>
2587
2588
2589 <h3><a name="NM_WRONG_PACKAGE">Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE)</a></h3>
2590
2591
2592 <p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match
2593 the type of the corresponding parameter in the superclass. For example, if you have:</p>
2594
2595 <blockquote>
2596 <pre>
2597 import alpha.Foo;
2598 public class A {
2599 public int f(Foo x) { return 17; }
2600 }
2601 ----
2602 import beta.Foo;
2603 public class B extends A {
2604 public int f(Foo x) { return 42; }
2605 }
2606 </pre>
2607 </blockquote>
2608
2609 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't
2610 override the
2611 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument
2612 types are <code>Foo</code>'s from different packages.
2613 </p>
2614
2615
2616 <h3><a name="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Method assigns boolean literal in boolean expression (QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT)</a></h3>
2617
2618
2619 <p>
2620 This method assigns a literal boolean value (true or false) to a boolean variable inside
2621 an if or while expression. Most probably this was supposed to be a boolean comparison using
2622 ==, not an assignment using =.
2623 </p>
2624
2625
2626 <h3><a name="RC_REF_COMPARISON">RC: Suspicious reference comparison (RC_REF_COMPARISON)</a></h3>
2627
2628
2629 <p> This method compares two reference values using the == or != operator,
2630 where the correct way to compare instances of this type is generally
2631 with the equals() method.
2632 It is possible to create distinct instances that are equal but do not compare as == since
2633 they are different objects.
2634 Examples of classes which should generally
2635 not be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>
2636
2637
2638 <h3><a name="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE">RCN: Nullcheck of value previously dereferenced (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE)</a></h3>
2639
2640
2641 <p> A value is checked here to see whether it is null, but this value can't
2642 be null because it was previously dereferenced and if it were null a null pointer
2643 exception would have occurred at the earlier dereference.
2644 Essentially, this code and the previous dereference
2645 disagree as to whether this value is allowed to be null. Either the check is redundant
2646 or the previous dereference is erroneous.</p>
2647
2648
2649 <h3><a name="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Invalid syntax for regular expression (RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION)</a></h3>
2650
2651
2652 <p>
2653 The code here uses a regular expression that is invalid according to the syntax
2654 for regular expressions. This statement will throw a PatternSyntaxException when
2655 executed.
2656 </p>
2657
2658
2659 <h3><a name="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION">RE: File.separator used for regular expression (RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION)</a></h3>
2660
2661
2662 <p>
2663 The code here uses <code>File.separator</code>
2664 where a regular expression is required. This will fail on Windows
2665 platforms, where the <code>File.separator</code> is a backslash, which is interpreted in a
2666 regular expression as an escape character. Amoung other options, you can just use
2667 <code>File.separatorChar=='\\' ? "\\\\" : File.separator</code> instead of
2668 <code>File.separator</code>
2669
2670 </p>
2671
2672
2673 <h3><a name="RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." or "|" used for regular expression (RE_POSSIBLE_UNINTENDED_PATTERN)</a></h3>
2674
2675
2676 <p>
2677 A String function is being invoked and "." or "|" is being passed
2678 to a parameter that takes a regular expression as an argument. Is this what you intended?
2679 For example
2680 <li>s.replaceAll(".", "/") will return a String in which <em>every</em> character has been replaced by a '/' character
2681 <li>s.split(".") <em>always</em> returns a zero length array of String
2682 <li>"ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/"
2683 <li>"ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d]
2684 </p>
2685
2686
2687 <h3><a name="RV_01_TO_INT">RV: Random value from 0 to 1 is coerced to the integer 0 (RV_01_TO_INT)</a></h3>
2688
2689
2690 <p>A random value from 0 to 1 is being coerced to the integer value 0. You probably
2691 want to multiple the random value by something else before coercing it to an integer, or use the <code>Random.nextInt(n)</code> method.
2692 </p>
2693
2694
2695 <h3><a name="RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attempt to compute absolute value of signed 32-bit hashcode (RV_ABSOLUTE_VALUE_OF_HASHCODE)</a></h3>
2696
2697
2698 <p> This code generates a hashcode and then computes
2699 the absolute value of that hashcode. If the hashcode
2700 is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
2701 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>).
2702 </p>
2703 <p>One out of 2^32 strings have a hashCode of Integer.MIN_VALUE,
2704 including "polygenelubricants" "GydZG_" and ""DESIGNING WORKHOUSES".
2705 </p>
2706
2707
2708 <h3><a name="RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad attempt to compute absolute value of signed random integer (RV_ABSOLUTE_VALUE_OF_RANDOM_INT)</a></h3>
2709
2710
2711 <p> This code generates a random signed integer and then computes
2712 the absolute value of that random integer. If the number returned by the random number
2713 generator is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
2714 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>). (Same problem arised for long values as well).
2715 </p>
2716
2717
2718 <h3><a name="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV: Code checks for specific values returned by compareTo (RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE)</a></h3>
2719
2720
2721 <p> This code invoked a compareTo or compare method, and checks to see if the return value is a specific value,
2722 such as 1 or -1. When invoking these methods, you should only check the sign of the result, not for any specific
2723 non-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, some of them
2724 will return other values.
2725
2726
2727 <h3><a name="RV_EXCEPTION_NOT_THROWN">RV: Exception created and dropped rather than thrown (RV_EXCEPTION_NOT_THROWN)</a></h3>
2728
2729
2730 <p> This code creates an exception (or error) object, but doesn't do anything with it. For example,
2731 something like </p>
2732 <blockquote>
2733 <pre>
2734 if (x &lt; 0)
2735 new IllegalArgumentException("x must be nonnegative");
2736 </pre>
2737 </blockquote>
2738 <p>It was probably the intent of the programmer to throw the created exception:</p>
2739 <blockquote>
2740 <pre>
2741 if (x &lt; 0)
2742 throw new IllegalArgumentException("x must be nonnegative");
2743 </pre>
2744 </blockquote>
2745
2746
2747 <h3><a name="RV_RETURN_VALUE_IGNORED">RV: Method ignores return value (RV_RETURN_VALUE_IGNORED)</a></h3>
2748
2749
2750 <p> The return value of this method should be checked. One common
2751 cause of this warning is to invoke a method on an immutable object,
2752 thinking that it updates the object. For example, in the following code
2753 fragment,</p>
2754 <blockquote>
2755 <pre>
2756 String dateString = getHeaderField(name);
2757 dateString.trim();
2758 </pre>
2759 </blockquote>
2760 <p>the programmer seems to be thinking that the trim() method will update
2761 the String referenced by dateString. But since Strings are immutable, the trim()
2762 function returns a new String value, which is being ignored here. The code
2763 should be corrected to: </p>
2764 <blockquote>
2765 <pre>
2766 String dateString = getHeaderField(name);
2767 dateString = dateString.trim();
2768 </pre>
2769 </blockquote>
2770
2771
2772 <h3><a name="RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated conditional tests (RpC_REPEATED_CONDITIONAL_TEST)</a></h3>
2773
2774
2775 <p>The code contains a conditional test is performed twice, one right after the other
2776 (e.g., <code>x == 0 || x == 0</code>). Perhaps the second occurrence is intended to be something else
2777 (e.g., <code>x == 0 || y == 0</code>).
2778 </p>
2779
2780
2781 <h3><a name="SA_FIELD_SELF_ASSIGNMENT">SA: Self assignment of field (SA_FIELD_SELF_ASSIGNMENT)</a></h3>
2782
2783
2784 <p> This method contains a self assignment of a field; e.g.
2785 </p>
2786 <pre>
2787 int x;
2788 public void foo() {
2789 x = x;
2790 }
2791 </pre>
2792 <p>Such assignments are useless, and may indicate a logic error or typo.</p>
2793
2794
2795 <h3><a name="SA_FIELD_SELF_COMPARISON">SA: Self comparison of field with itself (SA_FIELD_SELF_COMPARISON)</a></h3>
2796
2797
2798 <p> This method compares a field with itself, and may indicate a typo or
2799 a logic error. Make sure that you are comparing the right things.
2800 </p>
2801
2802
2803 <h3><a name="SA_FIELD_SELF_COMPUTATION">SA: Nonsensical self computation involving a field (e.g., x & x) (SA_FIELD_SELF_COMPUTATION)</a></h3>
2804
2805
2806 <p> This method performs a nonsensical computation of a field with another
2807 reference to the same field (e.g., x&x or x-x). Because of the nature
2808 of the computation, this operation doesn't seem to make sense,
2809 and may indicate a typo or
2810 a logic error. Double check the computation.
2811 </p>
2812
2813
2814 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA: Self assignment of local rather than assignment to field (SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD)</a></h3>
2815
2816
2817 <p> This method contains a self assignment of a local variable, and there
2818 is a field with an identical name.
2819 assignment appears to have been ; e.g.</p>
2820 <pre>
2821 int foo;
2822 public void setFoo(int foo) {
2823 foo = foo;
2824 }
2825 </pre>
2826 <p>The assignment is useless. Did you mean to assign to the field instead?</p>
2827
2828
2829 <h3><a name="SA_LOCAL_SELF_COMPARISON">SA: Self comparison of value with itself (SA_LOCAL_SELF_COMPARISON)</a></h3>
2830
2831
2832 <p> This method compares a local variable with itself, and may indicate a typo or
2833 a logic error. Make sure that you are comparing the right things.
2834 </p>
2835
2836
2837 <h3><a name="SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical self computation involving a variable (e.g., x & x) (SA_LOCAL_SELF_COMPUTATION)</a></h3>
2838
2839
2840 <p> This method performs a nonsensical computation of a local variable with another
2841 reference to the same variable (e.g., x&x or x-x). Because of the nature
2842 of the computation, this operation doesn't seem to make sense,
2843 and may indicate a typo or
2844 a logic error. Double check the computation.
2845 </p>
2846
2847
2848 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF: Dead store due to switch statement fall through (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH)</a></h3>
2849
2850
2851 <p> A value stored in the previous switch case is overwritten here due to a switch fall through. It is likely that
2852 you forgot to put a break or return at the end of the previous case.
2853 </p>
2854
2855
2856 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW">SF: Dead store due to switch statement fall through to throw (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW)</a></h3>
2857
2858
2859 <p> A value stored in the previous switch case is ignored here due to a switch fall through to a place where
2860 an exception is thrown. It is likely that
2861 you forgot to put a break or return at the end of the previous case.
2862 </p>
2863
2864
2865 <h3><a name="SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly embrace of non-static inner class and thread local (SIC_THREADLOCAL_DEADLY_EMBRACE)</a></h3>
2866
2867
2868 <p> This class is an inner class, but should probably be a static inner class.
2869 As it is, there is a serious danger of a deadly embrace between the inner class
2870 and the thread local in the outer class. Because the inner class isn't static,
2871 it retains a reference to the outer class.
2872 If the thread local contains a reference to an instance of the inner
2873 class, the inner and outer instance will both be reachable
2874 and not eligible for garbage collection.
2875 </p>
2876
2877
2878 <h3><a name="SIO_SUPERFLUOUS_INSTANCEOF">SIO: Unnecessary type check done using instanceof operator (SIO_SUPERFLUOUS_INSTANCEOF)</a></h3>
2879
2880
2881 <p> Type check performed using the instanceof operator where it can be statically determined whether the object
2882 is of the type requested. </p>
2883
2884
2885 <h3><a name="SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Method attempts to access a prepared statement parameter with index 0 (SQL_BAD_PREPARED_STATEMENT_ACCESS)</a></h3>
2886
2887
2888 <p> A call to a setXXX method of a prepared statement was made where the
2889 parameter index is 0. As parameter indexes start at index 1, this is always a mistake.</p>
2890
2891
2892 <h3><a name="SQL_BAD_RESULTSET_ACCESS">SQL: Method attempts to access a result set field with index 0 (SQL_BAD_RESULTSET_ACCESS)</a></h3>
2893
2894
2895 <p> A call to getXXX or updateXXX methods of a result set was made where the
2896 field index is 0. As ResultSet fields start at index 1, this is always a mistake.</p>
2897
2898
2899 <h3><a name="STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Unneeded use of currentThread() call, to call interrupted() (STI_INTERRUPTED_ON_CURRENTTHREAD)</a></h3>
2900
2901
2902 <p>
2903 This method invokes the Thread.currentThread() call, just to call the interrupted() method. As interrupted() is a
2904 static method, is more simple and clear to use Thread.interrupted().
2905 </p>
2906
2907
2908 <h3><a name="STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Static Thread.interrupted() method invoked on thread instance (STI_INTERRUPTED_ON_UNKNOWNTHREAD)</a></h3>
2909
2910
2911 <p>
2912 This method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is
2913 not the current thread. As the interrupted() method is static, the interrupted method will be called on a different
2914 object than the one the author intended.
2915 </p>
2916
2917
2918 <h3><a name="SE_METHOD_MUST_BE_PRIVATE">Se: Method must be private in order for serialization to work (SE_METHOD_MUST_BE_PRIVATE)</a></h3>
2919
2920
2921 <p> This class implements the <code>Serializable</code> interface, and defines a method
2922 for custom serialization/deserialization. But since that method isn't declared private,
2923 it will be silently ignored by the serialization/deserialization API.</p>
2924
2925
2926 <h3><a name="SE_READ_RESOLVE_IS_STATIC">Se: The readResolve method must not be declared as a static method. (SE_READ_RESOLVE_IS_STATIC)</a></h3>
2927
2928
2929 <p> In order for the readResolve method to be recognized by the serialization
2930 mechanism, it must not be declared as a static method.
2931 </p>
2932
2933
2934 <h3><a name="TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required (TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED)</a></h3>
2935
2936
2937 <p>
2938 A value specified as carrying a type qualifier annotation is
2939 consumed in a location or locations requiring that the value not
2940 carry that annotation.
2941 </p>
2942
2943 <p>
2944 More precisely, a value annotated with a type qualifier specifying when=ALWAYS
2945 is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER.
2946 </p>
2947
2948 <p>
2949 For example, say that @NonNegative is a nickname for
2950 the type qualifier annotation @Negative(when=When.NEVER).
2951 The following code will generate this warning because
2952 the return statement requires a @NonNegative value,
2953 but receives one that is marked as @Negative.
2954 </p>
2955 <blockquote>
2956 <pre>
2957 public @NonNegative Integer example(@Negative Integer value) {
2958 return value;
2959 }
2960 </pre>
2961 </blockquote>
2962
2963
2964 <h3><a name="TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ: Comparing values with incompatible type qualifiers (TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS)</a></h3>
2965
2966
2967 <p>
2968 A value specified as carrying a type qualifier annotation is
2969 compared with a value that doesn't ever carry that qualifier.
2970 </p>
2971
2972 <p>
2973 More precisely, a value annotated with a type qualifier specifying when=ALWAYS
2974 is compared with a value that where the same type qualifier specifies when=NEVER.
2975 </p>
2976
2977 <p>
2978 For example, say that @NonNegative is a nickname for
2979 the type qualifier annotation @Negative(when=When.NEVER).
2980 The following code will generate this warning because
2981 the return statement requires a @NonNegative value,
2982 but receives one that is marked as @Negative.
2983 </p>
2984 <blockquote>
2985 <pre>
2986 public boolean example(@Negative Integer value1, @NonNegative Integer value2) {
2987 return value1.equals(value2);
2988 }
2989 </pre>
2990 </blockquote>
2991
2992
2993 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK)</a></h3>
2994
2995
2996 <p>
2997 A value that is annotated as possibility not being an instance of
2998 the values denoted by the type qualifier, and the value is guaranteed to be used
2999 in a way that requires values denoted by that type qualifier.
3000 </p>
3001
3002
3003 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK)</a></h3>
3004
3005
3006 <p>
3007 A value that is annotated as possibility being an instance of
3008 the values denoted by the type qualifier, and the value is guaranteed to be used
3009 in a way that prohibits values denoted by that type qualifier.
3010 </p>
3011
3012
3013 <h3><a name="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required (TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED)</a></h3>
3014
3015
3016 <p>
3017 A value specified as not carrying a type qualifier annotation is guaranteed
3018 to be consumed in a location or locations requiring that the value does
3019 carry that annotation.
3020 </p>
3021
3022 <p>
3023 More precisely, a value annotated with a type qualifier specifying when=NEVER
3024 is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS.
3025 </p>
3026
3027 <p>
3028 TODO: example
3029 </p>
3030
3031
3032 <h3><a name="TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ: Value without a type qualifier used where a value is required to have that qualifier (TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED)</a></h3>
3033
3034
3035 <p>
3036 A value is being used in a way that requires the value be annotation with a type qualifier.
3037 The type qualifier is strict, so the tool rejects any values that do not have
3038 the appropriate annotation.
3039 </p>
3040
3041 <p>
3042 To coerce a value to have a strict annotation, define an identity function where the return value is annotated
3043 with the strict annotation.
3044 This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.
3045 </p>
3046
3047
3048
3049 <h3><a name="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">UMAC: Uncallable method defined in anonymous class (UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS)</a></h3>
3050
3051
3052 <p> This anonymous class defined a method that is not directly invoked and does not override
3053 a method in a superclass. Since methods in other classes cannot directly invoke methods
3054 declared in an anonymous class, it seems that this method is uncallable. The method
3055 might simply be dead code, but it is also possible that the method is intended to
3056 override a method declared in a superclass, and due to an typo or other error the method does not,
3057 in fact, override the method it is intended to.
3058 </p>
3059
3060
3061 <h3><a name="UR_UNINIT_READ">UR: Uninitialized read of field in constructor (UR_UNINIT_READ)</a></h3>
3062
3063
3064 <p> This constructor reads a field which has not yet been assigned a value.&nbsp;
3065 This is often caused when the programmer mistakenly uses the field instead
3066 of one of the constructor's parameters.</p>
3067
3068
3069 <h3><a name="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR">UR: Uninitialized read of field method called from constructor of superclass (UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR)</a></h3>
3070
3071
3072 <p> This method is invoked in the constructor of of the superclass. At this point,
3073 the fields of the class have not yet initialized.</p>
3074 <p>To make this more concrete, consider the following classes:</p>
3075 <pre>abstract class A {
3076 int hashCode;
3077 abstract Object getValue();
3078 A() {
3079 hashCode = getValue().hashCode();
3080 }
3081 }
3082 class B extends A {
3083 Object value;
3084 B(Object v) {
3085 this.value = v;
3086 }
3087 Object getValue() {
3088 return value;
3089 }
3090 }</pre>
3091 <p>When a <code>B</code> is constructed,
3092 the constructor for the <code>A</code> class is invoked
3093 <em>before</em> the constructor for <code>B</code> sets <code>value</code>.
3094 Thus, when the constructor for <code>A</code> invokes <code>getValue</code>,
3095 an uninitialized value is read for <code>value</code>
3096 </p>
3097
3098
3099 <h3><a name="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">USELESS_STRING: Invocation of toString on an unnamed array (DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY)</a></h3>
3100
3101
3102 <p>
3103 The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result
3104 such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable
3105 String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
3106 </p>
3107
3108
3109 <h3><a name="DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRING: Invocation of toString on an array (DMI_INVOKING_TOSTRING_ON_ARRAY)</a></h3>
3110
3111
3112 <p>
3113 The code invokes toString on an array, which will generate a fairly useless result
3114 such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable
3115 String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
3116 </p>
3117
3118
3119 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">USELESS_STRING: Array formatted in useless way using format string (VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY)</a></h3>
3120
3121
3122 <p>
3123 One of the arguments being formatted with a format string is an array. This will be formatted
3124 using a fairly useless format, such as [I@304282, which doesn't actually show the contents
3125 of the array.
3126 Consider wrapping the array using <code>Arrays.asList(...)</code> before handling it off to a formatted.
3127 </p>
3128
3129
3130 <h3><a name="UWF_NULL_FIELD">UwF: Field only ever set to null (UWF_NULL_FIELD)</a></h3>
3131
3132
3133 <p> All writes to this field are of the constant value null, and thus
3134 all reads of the field will return null.
3135 Check for errors, or remove it if it is useless.</p>
3136
3137
3138 <h3><a name="UWF_UNWRITTEN_FIELD">UwF: Unwritten field (UWF_UNWRITTEN_FIELD)</a></h3>
3139
3140
3141 <p> This field is never written.&nbsp; All reads of it will return the default
3142 value. Check for errors (should it have been initialized?), or remove it if it is useless.</p>
3143
3144
3145 <h3><a name="VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">VA: Primitive array passed to function expecting a variable number of object arguments (VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG)</a></h3>
3146
3147
3148 <p>
3149 This code passes a primitive array to a function that takes a variable number of object arguments.
3150 This creates an array of length one to hold the primitive array and passes it to the function.
3151 </p>
3152
3153
3154 <h3><a name="VR_UNRESOLVABLE_REFERENCE">VR: Class makes reference to unresolvable class or method (VR_UNRESOLVABLE_REFERENCE)</a></h3>
3155
3156
3157 <p>
3158 This class makes a reference to a class or method that can not be
3159 resolved using against the libraries it is being analyzed with.
3160 </p>
3161
3162
3163 <h3><a name="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Potential lost logger changes due to weak reference in OpenJDK (LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE)</a></h3>
3164
3165
3166 <p>OpenJDK introduces a potential incompatibility.
3167 In particular, the java.util.logging.Logger behavior has
3168 changed. Instead of using strong references, it now uses weak references
3169 internally. That's a reasonable change, but unfortunately some code relies on
3170 the old behavior - when changing logger configuration, it simply drops the
3171 logger reference. That means that the garbage collector is free to reclaim
3172 that memory, which means that the logger configuration is lost. For example,
3173 consider:
3174 </p>
3175
3176 <pre>public static void initLogging() throws Exception {
3177 Logger logger = Logger.getLogger("edu.umd.cs");
3178 logger.addHandler(new FileHandler()); // call to change logger configuration
3179 logger.setUseParentHandlers(false); // another call to change logger configuration
3180 }</pre>
3181
3182 <p>The logger reference is lost at the end of the method (it doesn't
3183 escape the method), so if you have a garbage collection cycle just
3184 after the call to initLogging, the logger configuration is lost
3185 (because Logger only keeps weak references).</p>
3186
3187 <pre>public static void main(String[] args) throws Exception {
3188 initLogging(); // adds a file handler to the logger
3189 System.gc(); // logger configuration lost
3190 Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected
3191 }</pre>
3192 <p><em>Ulf Ochsenfahrt and Eric Fellheimer</em></p>
3193
3194
3195 <h3><a name="OBL_UNSATISFIED_OBLIGATION">OBL: Method may fail to clean up stream or resource (OBL_UNSATISFIED_OBLIGATION)</a></h3>
3196
3197
3198 <p>
3199 This method may fail to clean up (close, dispose of) a stream,
3200 database object, or other
3201 resource requiring an explicit cleanup operation.
3202 </p>
3203
3204 <p>
3205 In general, if a method opens a stream or other resource,
3206 the method should use a try/finally block to ensure that
3207 the stream or resource is cleaned up before the method
3208 returns.
3209 </p>
3210
3211 <p>
3212 This bug pattern is essentially the same as the
3213 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE
3214 bug patterns, but is based on a different
3215 (and hopefully better) static analysis technique.
3216 We are interested is getting feedback about the
3217 usefulness of this bug pattern.
3218 To send feedback, either:
3219 </p>
3220 <ul>
3221 <li>send email to findbugs@cs.umd.edu</li>
3222 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
3223 </ul>
3224
3225 <p>
3226 In particular,
3227 the false-positive suppression heuristics for this
3228 bug pattern have not been extensively tuned, so
3229 reports about false positives are helpful to us.
3230 </p>
3231
3232 <p>
3233 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for
3234 a description of the analysis technique.
3235 </p>
3236
3237
3238 <h3><a name="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL: Method may fail to clean up stream or resource on checked exception (OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE)</a></h3>
3239
3240
3241 <p>
3242 This method may fail to clean up (close, dispose of) a stream,
3243 database object, or other
3244 resource requiring an explicit cleanup operation.
3245 </p>
3246
3247 <p>
3248 In general, if a method opens a stream or other resource,
3249 the method should use a try/finally block to ensure that
3250 the stream or resource is cleaned up before the method
3251 returns.
3252 </p>
3253
3254 <p>
3255 This bug pattern is essentially the same as the
3256 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE
3257 bug patterns, but is based on a different
3258 (and hopefully better) static analysis technique.
3259 We are interested is getting feedback about the
3260 usefulness of this bug pattern.
3261 To send feedback, either:
3262 </p>
3263 <ul>
3264 <li>send email to findbugs@cs.umd.edu</li>
3265 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
3266 </ul>
3267
3268 <p>
3269 In particular,
3270 the false-positive suppression heuristics for this
3271 bug pattern have not been extensively tuned, so
3272 reports about false positives are helpful to us.
3273 </p>
3274
3275 <p>
3276 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for
3277 a description of the analysis technique.
3278 </p>
3279
3280
3281 <h3><a name="TESTING">TEST: Testing (TESTING)</a></h3>
3282
3283
3284 <p>This bug pattern is only generated by new, incompletely implemented
3285 bug detectors.</p>
3286
3287
3288 <h3><a name="DM_CONVERT_CASE">Dm: Consider using Locale parameterized version of invoked method (DM_CONVERT_CASE)</a></h3>
3289
3290
3291 <p> A String is being converted to upper or lowercase, using the platform's default encoding. This may
3292 result in improper conversions when used with international characters. Use the </p>
3293 <ul>
3294 <li>String.toUpperCase( Locale l )</li>
3295 <li>String.toLowerCase( Locale l )</li>
3296 </ul>
3297 <p>versions instead.</p>
3298
3299
3300 <h3><a name="DM_DEFAULT_ENCODING">Dm: Reliance on default encoding (DM_DEFAULT_ENCODING)</a></h3>
3301
3302
3303 <p> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. </p>
3304
3305
3306 <h3><a name="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">DP: Classloaders should only be created inside doPrivileged block (DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED)</a></h3>
3307
3308
3309 <p> This code creates a classloader, which needs permission if a security manage is installed.
3310 If this code might be invoked by code that does not
3311 have security permissions, then the classloader creation needs to occur inside a doPrivileged block.</p>
3312
3313
3314 <h3><a name="DP_DO_INSIDE_DO_PRIVILEGED">DP: Method invoked that should be only be invoked inside a doPrivileged block (DP_DO_INSIDE_DO_PRIVILEGED)</a></h3>
3315
3316
3317 <p> This code invokes a method that requires a security permission check.
3318 If this code will be granted security permissions, but might be invoked by code that does not
3319 have security permissions, then the invocation needs to occur inside a doPrivileged block.</p>
3320
3321
3322 <h3><a name="EI_EXPOSE_REP">EI: May expose internal representation by returning reference to mutable object (EI_EXPOSE_REP)</a></h3>
3323
3324
3325 <p> Returning a reference to a mutable object value stored in one of the object's fields
3326 exposes the internal representation of the object.&nbsp;
3327 If instances
3328 are accessed by untrusted code, and unchecked changes to
3329 the mutable object would compromise security or other
3330 important properties, you will need to do something different.
3331 Returning a new copy of the object is better approach in many situations.</p>
3332
3333
3334 <h3><a name="EI_EXPOSE_REP2">EI2: May expose internal representation by incorporating reference to mutable object (EI_EXPOSE_REP2)</a></h3>
3335
3336
3337 <p> This code stores a reference to an externally mutable object into the
3338 internal representation of the object.&nbsp;
3339 If instances
3340 are accessed by untrusted code, and unchecked changes to
3341 the mutable object would compromise security or other
3342 important properties, you will need to do something different.
3343 Storing a copy of the object is better approach in many situations.</p>
3344
3345
3346 <h3><a name="FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Finalizer should be protected, not public (FI_PUBLIC_SHOULD_BE_PROTECTED)</a></h3>
3347
3348
3349 <p> A class's <code>finalize()</code> method should have protected access,
3350 not public.</p>
3351
3352
3353 <h3><a name="EI_EXPOSE_STATIC_REP2">MS: May expose internal static state by storing a mutable object into a static field (EI_EXPOSE_STATIC_REP2)</a></h3>
3354
3355
3356 <p> This code stores a reference to an externally mutable object into a static
3357 field.
3358 If unchecked changes to
3359 the mutable object would compromise security or other
3360 important properties, you will need to do something different.
3361 Storing a copy of the object is better approach in many situations.</p>
3362
3363
3364 <h3><a name="MS_CANNOT_BE_FINAL">MS: Field isn't final and can't be protected from malicious code (MS_CANNOT_BE_FINAL)</a></h3>
3365
3366
3367 <p>
3368 A mutable static field could be changed by malicious code or
3369 by accident from another package.
3370 Unfortunately, the way the field is used doesn't allow
3371 any easy fix to this problem.</p>
3372
3373
3374 <h3><a name="MS_EXPOSE_REP">MS: Public static method may expose internal representation by returning array (MS_EXPOSE_REP)</a></h3>
3375
3376
3377 <p> A public static method returns a reference to
3378 an array that is part of the static state of the class.
3379 Any code that calls this method can freely modify
3380 the underlying array.
3381 One fix is to return a copy of the array.</p>
3382
3383
3384 <h3><a name="MS_FINAL_PKGPROTECT">MS: Field should be both final and package protected (MS_FINAL_PKGPROTECT)</a></h3>
3385
3386
3387 <p>
3388 A mutable static field could be changed by malicious code or
3389 by accident from another package.
3390 The field could be made package protected and/or made final
3391 to avoid
3392 this vulnerability.</p>
3393
3394
3395 <h3><a name="MS_MUTABLE_ARRAY">MS: Field is a mutable array (MS_MUTABLE_ARRAY)</a></h3>
3396
3397
3398 <p> A final static field references an array
3399 and can be accessed by malicious code or
3400 by accident from another package.
3401 This code can freely modify the contents of the array.</p>
3402
3403
3404 <h3><a name="MS_MUTABLE_HASHTABLE">MS: Field is a mutable Hashtable (MS_MUTABLE_HASHTABLE)</a></h3>
3405
3406
3407 <p>A final static field references a Hashtable
3408 and can be accessed by malicious code or
3409 by accident from another package.
3410 This code can freely modify the contents of the Hashtable.</p>
3411
3412
3413 <h3><a name="MS_OOI_PKGPROTECT">MS: Field should be moved out of an interface and made package protected (MS_OOI_PKGPROTECT)</a></h3>
3414
3415
3416 <p>
3417 A final static field that is
3418 defined in an interface references a mutable
3419 object such as an array or hashtable.
3420 This mutable object could
3421 be changed by malicious code or
3422 by accident from another package.
3423 To solve this, the field needs to be moved to a class
3424 and made package protected
3425 to avoid
3426 this vulnerability.</p>
3427
3428
3429 <h3><a name="MS_PKGPROTECT">MS: Field should be package protected (MS_PKGPROTECT)</a></h3>
3430
3431
3432 <p> A mutable static field could be changed by malicious code or
3433 by accident.
3434 The field could be made package protected to avoid
3435 this vulnerability.</p>
3436
3437
3438 <h3><a name="MS_SHOULD_BE_FINAL">MS: Field isn't final but should be (MS_SHOULD_BE_FINAL)</a></h3>
3439
3440
3441 <p>
3442 This static field public but not final, and
3443 could be changed by malicious code or
3444 by accident from another package.
3445 The field could be made final to avoid
3446 this vulnerability.</p>
3447
3448
3449 <h3><a name="MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Field isn't final but should be refactored to be so (MS_SHOULD_BE_REFACTORED_TO_BE_FINAL)</a></h3>
3450
3451
3452 <p>
3453 This static field public but not final, and
3454 could be changed by malicious code or
3455 by accident from another package.
3456 The field could be made final to avoid
3457 this vulnerability. However, the static initializer contains more than one write
3458 to the field, so doing so will require some refactoring.
3459 </p>
3460
3461
3462 <h3><a name="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT: Sequence of calls to concurrent abstraction may not be atomic (AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION)</a></h3>
3463
3464
3465 <p>This code contains a sequence of calls to a concurrent abstraction
3466 (such as a concurrent hash map).
3467 These calls will not be executed atomically.
3468
3469
3470 <h3><a name="DC_DOUBLECHECK">DC: Possible double check of field (DC_DOUBLECHECK)</a></h3>
3471
3472
3473 <p> This method may contain an instance of double-checked locking.&nbsp;
3474 This idiom is not correct according to the semantics of the Java memory
3475 model.&nbsp; For more information, see the web page
3476 <a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html"
3477 >http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a>.</p>
3478
3479
3480 <h3><a name="DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchronization on Boolean (DL_SYNCHRONIZATION_ON_BOOLEAN)</a></h3>
3481
3482
3483 <p> The code synchronizes on a boxed primitive constant, such as an Boolean.</p>
3484 <pre>
3485 private static Boolean inited = Boolean.FALSE;
3486 ...
3487 synchronized(inited) {
3488 if (!inited) {
3489 init();
3490 inited = Boolean.TRUE;
3491 }
3492 }
3493 ...
3494 </pre>
3495 <p>Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness
3496 and possible deadlock</p>
3497 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3498
3499
3500 <h3><a name="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive (DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE)</a></h3>
3501
3502
3503 <p> The code synchronizes on a boxed primitive constant, such as an Integer.</p>
3504 <pre>
3505 private static Integer count = 0;
3506 ...
3507 synchronized(count) {
3508 count++;
3509 }
3510 ...
3511 </pre>
3512 <p>Since Integer objects can be cached and shared,
3513 this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness
3514 and possible deadlock</p>
3515 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3516
3517
3518 <h3><a name="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: Synchronization on interned String (DL_SYNCHRONIZATION_ON_SHARED_CONSTANT)</a></h3>
3519
3520
3521 <p> The code synchronizes on interned String.</p>
3522 <pre>
3523 private static String LOCK = "LOCK";
3524 ...
3525 synchronized(LOCK) { ...}
3526 ...
3527 </pre>
3528 <p>Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could
3529 is locking on something that other code might also be locking. This could result in very strange and hard to diagnose
3530 blocking and deadlock behavior. See <a href="http://www.javalobby.org/java/forums/t96352.html">http://www.javalobby.org/java/forums/t96352.html</a> and <a href="http://jira.codehaus.org/browse/JETTY-352">http://jira.codehaus.org/browse/JETTY-352</a>.
3531 </p>
3532 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3533
3534
3535 <h3><a name="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive values (DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE)</a></h3>
3536
3537
3538 <p> The code synchronizes on an apparently unshared boxed primitive,
3539 such as an Integer.</p>
3540 <pre>
3541 private static final Integer fileLock = new Integer(1);
3542 ...
3543 synchronized(fileLock) {
3544 .. do something ..
3545 }
3546 ...
3547 </pre>
3548 <p>It would be much better, in this code, to redeclare fileLock as</p>
3549 <pre>
3550 private static final Object fileLock = new Object();
3551 </pre>
3552 <p>
3553 The existing code might be OK, but it is confusing and a
3554 future refactoring, such as the "Remove Boxing" refactoring in IntelliJ,
3555 might replace this with the use of an interned Integer object shared
3556 throughout the JVM, leading to very confusing behavior and potential deadlock.
3557 </p>
3558
3559
3560 <h3><a name="DM_MONITOR_WAIT_ON_CONDITION">Dm: Monitor wait() called on Condition (DM_MONITOR_WAIT_ON_CONDITION)</a></h3>
3561
3562
3563 <p>
3564 This method calls <code>wait()</code> on a
3565 <code>java.util.concurrent.locks.Condition</code> object.&nbsp;
3566 Waiting for a <code>Condition</code> should be done using one of the <code>await()</code>
3567 methods defined by the <code>Condition</code> interface.
3568 </p>
3569
3570
3571 <h3><a name="DM_USELESS_THREAD">Dm: A thread was created using the default empty run method (DM_USELESS_THREAD)</a></h3>
3572
3573
3574 <p>This method creates a thread without specifying a run method either by deriving from the Thread class, or
3575 by passing a Runnable object. This thread, then, does nothing but waste time.
3576 </p>
3577
3578
3579 <h3><a name="ESync_EMPTY_SYNC">ESync: Empty synchronized block (ESync_EMPTY_SYNC)</a></h3>
3580
3581
3582 <p> The code contains an empty synchronized block:</p>
3583 <pre>
3584 synchronized() {}
3585 </pre>
3586 <p>Empty synchronized blocks are far more subtle and hard to use correctly
3587 than most people recognize, and empty synchronized blocks
3588 are almost never a better solution
3589 than less contrived solutions.
3590 </p>
3591
3592
3593 <h3><a name="IS2_INCONSISTENT_SYNC">IS: Inconsistent synchronization (IS2_INCONSISTENT_SYNC)</a></h3>
3594
3595
3596 <p> The fields of this class appear to be accessed inconsistently with respect
3597 to synchronization.&nbsp; This bug report indicates that the bug pattern detector
3598 judged that
3599 </p>
3600 <ul>
3601 <li> The class contains a mix of locked and unlocked accesses,</li>
3602 <li> The class is <b>not</b> annotated as javax.annotation.concurrent.NotThreadSafe,</li>
3603 <li> At least one locked access was performed by one of the class's own methods, and</li>
3604 <li> The number of unsynchronized field accesses (reads and writes) was no more than
3605 one third of all accesses, with writes being weighed twice as high as reads</li>
3606 </ul>
3607
3608 <p> A typical bug matching this bug pattern is forgetting to synchronize
3609 one of the methods in a class that is intended to be thread-safe.</p>
3610
3611 <p> You can select the nodes labeled "Unsynchronized access" to show the
3612 code locations where the detector believed that a field was accessed
3613 without synchronization.</p>
3614
3615 <p> Note that there are various sources of inaccuracy in this detector;
3616 for example, the detector cannot statically detect all situations in which
3617 a lock is held.&nbsp; Also, even when the detector is accurate in
3618 distinguishing locked vs. unlocked accesses, the code in question may still
3619 be correct.</p>
3620
3621
3622
3623 <h3><a name="IS_FIELD_NOT_GUARDED">IS: Field not guarded against concurrent access (IS_FIELD_NOT_GUARDED)</a></h3>
3624
3625
3626 <p> This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy,
3627 but can be accessed in a way that seems to violate those annotations.</p>
3628
3629
3630 <h3><a name="JLM_JSR166_LOCK_MONITORENTER">JLM: Synchronization performed on Lock (JLM_JSR166_LOCK_MONITORENTER)</a></h3>
3631
3632
3633 <p> This method performs synchronization an object that implements
3634 java.util.concurrent.locks.Lock. Such an object is locked/unlocked
3635 using
3636 <code>acquire()</code>/<code>release()</code> rather
3637 than using the <code>synchronized (...)</code> construct.
3638 </p>
3639
3640
3641 <h3><a name="JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM: Synchronization performed on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)</a></h3>
3642
3643
3644 <p> This method performs synchronization an object that is an instance of
3645 a class from the java.util.concurrent package (or its subclasses). Instances
3646 of these classes have their own concurrency control mechanisms that are orthogonal to
3647 the synchronization provided by the Java keyword <code>synchronized</code>. For example,
3648 synchronizing on an <code>AtomicBoolean</code> will not prevent other threads
3649 from modifying the <code>AtomicBoolean</code>.</p>
3650 <p>Such code may be correct, but should be carefully reviewed and documented,
3651 and may confuse people who have to maintain the code at a later date.
3652 </p>
3653
3654
3655 <h3><a name="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JLM: Using monitor style wait methods on util.concurrent abstraction (JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT)</a></h3>
3656
3657
3658 <p> This method calls
3659 <code>wait()</code>,
3660 <code>notify()</code> or
3661 <code>notifyAll()()</code>
3662 on an object that also provides an
3663 <code>await()</code>,
3664 <code>signal()</code>,
3665 <code>signalAll()</code> method (such as util.concurrent Condition objects).
3666 This probably isn't what you want, and even if you do want it, you should consider changing
3667 your design, as other developers will find it exceptionally confusing.
3668 </p>
3669
3670
3671 <h3><a name="LI_LAZY_INIT_STATIC">LI: Incorrect lazy initialization of static field (LI_LAZY_INIT_STATIC)</a></h3>
3672
3673
3674 <p> This method contains an unsynchronized lazy initialization of a non-volatile static field.
3675 Because the compiler or processor may reorder instructions,
3676 threads are not guaranteed to see a completely initialized object,
3677 <em>if the method can be called by multiple threads</em>.
3678 You can make the field volatile to correct the problem.
3679 For more information, see the
3680 <a href="http://www.cs.umd.edu/~pugh/java/memoryModel/">Java Memory Model web site</a>.
3681 </p>
3682
3683
3684 <h3><a name="LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect lazy initialization and update of static field (LI_LAZY_INIT_UPDATE_STATIC)</a></h3>
3685
3686
3687 <p> This method contains an unsynchronized lazy initialization of a static field.
3688 After the field is set, the object stored into that location is further updated or accessed.
3689 The setting of the field is visible to other threads as soon as it is set. If the
3690 futher accesses in the method that set the field serve to initialize the object, then
3691 you have a <em>very serious</em> multithreading bug, unless something else prevents
3692 any other thread from accessing the stored object until it is fully initialized.
3693 </p>
3694 <p>Even if you feel confident that the method is never called by multiple
3695 threads, it might be better to not set the static field until the value
3696 you are setting it to is fully populated/initialized.
3697
3698
3699 <h3><a name="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD">ML: Synchronization on field in futile attempt to guard that field (ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD)</a></h3>
3700
3701
3702 <p> This method synchronizes on a field in what appears to be an attempt
3703 to guard against simultaneous updates to that field. But guarding a field
3704 gets a lock on the referenced object, not on the field. This may not
3705 provide the mutual exclusion you need, and other threads might
3706 be obtaining locks on the referenced objects (for other purposes). An example
3707 of this pattern would be:</p>
3708 <pre>
3709 private Long myNtfSeqNbrCounter = new Long(0);
3710 private Long getNotificationSequenceNumber() {
3711 Long result = null;
3712 synchronized(myNtfSeqNbrCounter) {
3713 result = new Long(myNtfSeqNbrCounter.longValue() + 1);
3714 myNtfSeqNbrCounter = new Long(result.longValue());
3715 }
3716 return result;
3717 }
3718 </pre>
3719
3720
3721 <h3><a name="ML_SYNC_ON_UPDATED_FIELD">ML: Method synchronizes on an updated field (ML_SYNC_ON_UPDATED_FIELD)</a></h3>
3722
3723
3724 <p> This method synchronizes on an object
3725 referenced from a mutable field.
3726 This is unlikely to have useful semantics, since different
3727 threads may be synchronizing on different objects.</p>
3728
3729
3730 <h3><a name="MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable servlet field (MSF_MUTABLE_SERVLET_FIELD)</a></h3>
3731
3732
3733 <p>A web server generally only creates one instance of servlet or jsp class (i.e., treats
3734 the class as a Singleton),
3735 and will
3736 have multiple threads invoke methods on that instance to service multiple
3737 simultaneous requests.
3738 Thus, having a mutable instance field generally creates race conditions.
3739
3740
3741 <h3><a name="MWN_MISMATCHED_NOTIFY">MWN: Mismatched notify() (MWN_MISMATCHED_NOTIFY)</a></h3>
3742
3743
3744 <p> This method calls Object.notify() or Object.notifyAll() without obviously holding a lock
3745 on the object.&nbsp; Calling notify() or notifyAll() without a lock held will result in
3746 an <code>IllegalMonitorStateException</code> being thrown.</p>
3747
3748
3749 <h3><a name="MWN_MISMATCHED_WAIT">MWN: Mismatched wait() (MWN_MISMATCHED_WAIT)</a></h3>
3750
3751
3752 <p> This method calls Object.wait() without obviously holding a lock
3753 on the object.&nbsp; Calling wait() without a lock held will result in
3754 an <code>IllegalMonitorStateException</code> being thrown.</p>
3755
3756
3757 <h3><a name="NN_NAKED_NOTIFY">NN: Naked notify (NN_NAKED_NOTIFY)</a></h3>
3758
3759
3760 <p> A call to <code>notify()</code> or <code>notifyAll()</code>
3761 was made without any (apparent) accompanying
3762 modification to mutable object state.&nbsp; In general, calling a notify
3763 method on a monitor is done because some condition another thread is
3764 waiting for has become true.&nbsp; However, for the condition to be meaningful,
3765 it must involve a heap object that is visible to both threads.</p>
3766
3767 <p> This bug does not necessarily indicate an error, since the change to
3768 mutable object state may have taken place in a method which then called
3769 the method containing the notification.</p>
3770
3771
3772 <h3><a name="NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchronize and null check on the same field. (NP_SYNC_AND_NULL_CHECK_FIELD)</a></h3>
3773
3774
3775 <p>Since the field is synchronized on, it seems not likely to be null.
3776 If it is null and then synchronized on a NullPointerException will be
3777 thrown and the check would be pointless. Better to synchronize on
3778 another field.</p>
3779
3780
3781
3782 <h3><a name="NO_NOTIFY_NOT_NOTIFYALL">No: Using notify() rather than notifyAll() (NO_NOTIFY_NOT_NOTIFYALL)</a></h3>
3783
3784
3785 <p> This method calls <code>notify()</code> rather than <code>notifyAll()</code>.&nbsp;
3786 Java monitors are often used for multiple conditions.&nbsp; Calling <code>notify()</code>
3787 only wakes up one thread, meaning that the thread woken up might not be the
3788 one waiting for the condition that the caller just satisfied.</p>
3789
3790
3791 <h3><a name="RS_READOBJECT_SYNC">RS: Class's readObject() method is synchronized (RS_READOBJECT_SYNC)</a></h3>
3792
3793
3794 <p> This serializable class defines a <code>readObject()</code> which is
3795 synchronized.&nbsp; By definition, an object created by deserialization
3796 is only reachable by one thread, and thus there is no need for
3797 <code>readObject()</code> to be synchronized.&nbsp; If the <code>readObject()</code>
3798 method itself is causing the object to become visible to another thread,
3799 that is an example of very dubious coding style.</p>
3800
3801
3802 <h3><a name="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused (RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED)</a></h3>
3803
3804
3805 The <code>putIfAbsent</code> method is typically used to ensure that a
3806 single value is associated with a given key (the first value for which put
3807 if absent succeeds).
3808 If you ignore the return value and retain a reference to the value passed in,
3809 you run the risk of retaining a value that is not the one that is associated with the key in the map.
3810 If it matters which one you use and you use the one that isn't stored in the map,
3811 your program will behave incorrectly.
3812
3813
3814 <h3><a name="RU_INVOKE_RUN">Ru: Invokes run on a thread (did you mean to start it instead?) (RU_INVOKE_RUN)</a></h3>
3815
3816
3817 <p> This method explicitly invokes <code>run()</code> on an object.&nbsp;
3818 In general, classes implement the <code>Runnable</code> interface because
3819 they are going to have their <code>run()</code> method invoked in a new thread,
3820 in which case <code>Thread.start()</code> is the right method to call.</p>
3821
3822
3823 <h3><a name="SC_START_IN_CTOR">SC: Constructor invokes Thread.start() (SC_START_IN_CTOR)</a></h3>
3824
3825
3826 <p> The constructor starts a thread. This is likely to be wrong if
3827 the class is ever extended/subclassed, since the thread will be started
3828 before the subclass constructor is started.</p>
3829
3830
3831 <h3><a name="SP_SPIN_ON_FIELD">SP: Method spins on field (SP_SPIN_ON_FIELD)</a></h3>
3832
3833
3834 <p> This method spins in a loop which reads a field.&nbsp; The compiler
3835 may legally hoist the read out of the loop, turning the code into an
3836 infinite loop.&nbsp; The class should be changed so it uses proper
3837 synchronization (including wait and notify calls).</p>
3838
3839
3840 <h3><a name="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">STCAL: Call to static Calendar (STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE)</a></h3>
3841
3842
3843 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use.
3844 The detector has found a call to an instance of Calendar that has been obtained via a static
3845 field. This looks suspicous.</p>
3846 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3847 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3848
3849
3850 <h3><a name="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE">STCAL: Call to static DateFormat (STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE)</a></h3>
3851
3852
3853 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.
3854 The detector has found a call to an instance of DateFormat that has been obtained via a static
3855 field. This looks suspicous.</p>
3856 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3857 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3858
3859
3860 <h3><a name="STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Static Calendar field (STCAL_STATIC_CALENDAR_INSTANCE)</a></h3>
3861
3862
3863 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use.
3864 Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the
3865 application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see
3866 random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate().</p>
3867 <p>You may also experience serialization problems.</p>
3868 <p>Using an instance field is recommended.</p>
3869 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3870 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3871
3872
3873 <h3><a name="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">STCAL: Static DateFormat (STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE)</a></h3>
3874
3875
3876 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.
3877 Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the
3878 application.</p>
3879 <p>You may also experience serialization problems.</p>
3880 <p>Using an instance field is recommended.</p>
3881 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3882 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3883
3884
3885 <h3><a name="SWL_SLEEP_WITH_LOCK_HELD">SWL: Method calls Thread.sleep() with a lock held (SWL_SLEEP_WITH_LOCK_HELD)</a></h3>
3886
3887
3888 <p>
3889 This method calls Thread.sleep() with a lock held. This may result
3890 in very poor performance and scalability, or a deadlock, since other threads may
3891 be waiting to acquire the lock. It is a much better idea to call
3892 wait() on the lock, which releases the lock and allows other threads
3893 to run.
3894 </p>
3895
3896
3897 <h3><a name="TLW_TWO_LOCK_WAIT">TLW: Wait with two locks held (TLW_TWO_LOCK_WAIT)</a></h3>
3898
3899
3900 <p> Waiting on a monitor while two locks are held may cause
3901 deadlock.
3902 &nbsp;
3903 Performing a wait only releases the lock on the object
3904 being waited on, not any other locks.
3905 &nbsp;
3906 This not necessarily a bug, but is worth examining
3907 closely.</p>
3908
3909
3910 <h3><a name="UG_SYNC_SET_UNSYNC_GET">UG: Unsynchronized get method, synchronized set method (UG_SYNC_SET_UNSYNC_GET)</a></h3>
3911
3912
3913 <p> This class contains similarly-named get and set
3914 methods where the set method is synchronized and the get method is not.&nbsp;
3915 This may result in incorrect behavior at runtime, as callers of the get
3916 method will not necessarily see a consistent state for the object.&nbsp;
3917 The get method should be made synchronized.</p>
3918
3919
3920 <h3><a name="UL_UNRELEASED_LOCK">UL: Method does not release lock on all paths (UL_UNRELEASED_LOCK)</a></h3>
3921
3922
3923 <p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,
3924 but does not release it on all paths out of the method. In general, the correct idiom
3925 for using a JSR-166 lock is:
3926 </p>
3927 <pre>
3928 Lock l = ...;
3929 l.lock();
3930 try {
3931 // do something
3932 } finally {
3933 l.unlock();
3934 }
3935 </pre>
3936
3937
3938 <h3><a name="UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: Method does not release lock on all exception paths (UL_UNRELEASED_LOCK_EXCEPTION_PATH)</a></h3>
3939
3940
3941 <p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,
3942 but does not release it on all exception paths out of the method. In general, the correct idiom
3943 for using a JSR-166 lock is:
3944 </p>
3945 <pre>
3946 Lock l = ...;
3947 l.lock();
3948 try {
3949 // do something
3950 } finally {
3951 l.unlock();
3952 }
3953 </pre>
3954
3955
3956 <h3><a name="UW_UNCOND_WAIT">UW: Unconditional wait (UW_UNCOND_WAIT)</a></h3>
3957
3958
3959 <p> This method contains a call to <code>java.lang.Object.wait()</code> which
3960 is not guarded by conditional control flow.&nbsp; The code should
3961 verify that condition it intends to wait for is not already satisfied
3962 before calling wait; any previous notifications will be ignored.
3963 </p>
3964
3965
3966 <h3><a name="VO_VOLATILE_INCREMENT">VO: An increment to a volatile field isn't atomic (VO_VOLATILE_INCREMENT)</a></h3>
3967
3968
3969 <p>This code increments a volatile field. Increments of volatile fields aren't
3970 atomic. If more than one thread is incrementing the field at the same time,
3971 increments could be lost.
3972 </p>
3973
3974
3975 <h3><a name="VO_VOLATILE_REFERENCE_TO_ARRAY">VO: A volatile reference to an array doesn't treat the array elements as volatile (VO_VOLATILE_REFERENCE_TO_ARRAY)</a></h3>
3976
3977
3978 <p>This declares a volatile reference to an array, which might not be what
3979 you want. With a volatile reference to an array, reads and writes of
3980 the reference to the array are treated as volatile, but the array elements
3981 are non-volatile. To get volatile array elements, you will need to use
3982 one of the atomic array classes in java.util.concurrent (provided
3983 in Java 5.0).</p>
3984
3985
3986 <h3><a name="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL">WL: Synchronization on getClass rather than class literal (WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL)</a></h3>
3987
3988
3989 <p>
3990 This instance method synchronizes on <code>this.getClass()</code>. If this class is subclassed,
3991 subclasses will synchronize on the class object for the subclass, which isn't likely what was intended.
3992 For example, consider this code from java.awt.Label:</p>
3993 <pre>
3994 private static final String base = "label";
3995 private static int nameCounter = 0;
3996 String constructComponentName() {
3997 synchronized (getClass()) {
3998 return base + nameCounter++;
3999 }
4000 }
4001 </pre>
4002 <p>Subclasses of <code>Label</code> won't synchronize on the same subclass, giving rise to a datarace.
4003 Instead, this code should be synchronizing on <code>Label.class</code></p>
4004 <pre>
4005 private static final String base = "label";
4006 private static int nameCounter = 0;
4007 String constructComponentName() {
4008 synchronized (Label.class) {
4009 return base + nameCounter++;
4010 }
4011 }
4012 </pre>
4013 <p>Bug pattern contributed by Jason Mehrens</p>
4014
4015
4016 <h3><a name="WS_WRITEOBJECT_SYNC">WS: Class's writeObject() method is synchronized but nothing else is (WS_WRITEOBJECT_SYNC)</a></h3>
4017
4018
4019 <p> This class has a <code>writeObject()</code> method which is synchronized;
4020 however, no other method of the class is synchronized.</p>
4021
4022
4023 <h3><a name="WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await() not in loop (WA_AWAIT_NOT_IN_LOOP)</a></h3>
4024
4025
4026 <p> This method contains a call to <code>java.util.concurrent.await()</code>
4027 (or variants)
4028 which is not in a loop.&nbsp; If the object is used for multiple conditions,
4029 the condition the caller intended to wait for might not be the one
4030 that actually occurred.</p>
4031
4032
4033 <h3><a name="WA_NOT_IN_LOOP">Wa: Wait not in loop (WA_NOT_IN_LOOP)</a></h3>
4034
4035
4036 <p> This method contains a call to <code>java.lang.Object.wait()</code>
4037 which is not in a loop.&nbsp; If the monitor is used for multiple conditions,
4038 the condition the caller intended to wait for might not be the one
4039 that actually occurred.</p>
4040
4041
4042 <h3><a name="NOISE_FIELD_REFERENCE">NOISE: Bogus warning about a field reference (NOISE_FIELD_REFERENCE)</a></h3>
4043
4044
4045 <p>Bogus warning.</p>
4046
4047
4048 <h3><a name="NOISE_METHOD_CALL">NOISE: Bogus warning about a method call (NOISE_METHOD_CALL)</a></h3>
4049
4050
4051 <p>Bogus warning.</p>
4052
4053
4054 <h3><a name="NOISE_NULL_DEREFERENCE">NOISE: Bogus warning about a null pointer dereference (NOISE_NULL_DEREFERENCE)</a></h3>
4055
4056
4057 <p>Bogus warning.</p>
4058
4059
4060 <h3><a name="NOISE_OPERATION">NOISE: Bogus warning about an operation (NOISE_OPERATION)</a></h3>
4061
4062
4063 <p>Bogus warning.</p>
4064
4065
4066 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive value is boxed and then immediately unboxed (BX_BOXING_IMMEDIATELY_UNBOXED)</a></h3>
4067
4068
4069 <p>A primitive is boxed, and then immediately unboxed. This probably is due to a manual
4070 boxing in a place where an unboxed value is required, thus forcing the compiler
4071 to immediately undo the work of the boxing.
4072 </p>
4073
4074
4075 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION">Bx: Primitive value is boxed then unboxed to perform primitive coercion (BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION)</a></h3>
4076
4077
4078 <p>A primitive boxed value constructed and then immediately converted into a different primitive type
4079 (e.g., <code>new Double(d).intValue()</code>). Just perform direct primitive coercion (e.g., <code>(int) d</code>).</p>
4080
4081
4082 <h3><a name="BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed value is unboxed and then immediately reboxed (BX_UNBOXING_IMMEDIATELY_REBOXED)</a></h3>
4083
4084
4085 <p>A boxed value is unboxed and then immediately reboxed.
4086 </p>
4087
4088
4089 <h3><a name="DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/unboxing to parse a primitive (DM_BOXED_PRIMITIVE_FOR_PARSING)</a></h3>
4090
4091
4092 <p>A boxed primitive is created from a String, just to extract the unboxed primitive value.
4093 It is more efficient to just call the static parseXXX method.</p>
4094
4095
4096 <h3><a name="DM_BOXED_PRIMITIVE_TOSTRING">Bx: Method allocates a boxed primitive just to call toString (DM_BOXED_PRIMITIVE_TOSTRING)</a></h3>
4097
4098
4099 <p>A boxed primitive is allocated just to call toString(). It is more effective to just use the static
4100 form of toString which takes the primitive value. So,</p>
4101 <table>
4102 <tr><th>Replace...</th><th>With this...</th></tr>
4103 <tr><td>new Integer(1).toString()</td><td>Integer.toString(1)</td></tr>
4104 <tr><td>new Long(1).toString()</td><td>Long.toString(1)</td></tr>
4105 <tr><td>new Float(1.0).toString()</td><td>Float.toString(1.0)</td></tr>
4106 <tr><td>new Double(1.0).toString()</td><td>Double.toString(1.0)</td></tr>
4107 <tr><td>new Byte(1).toString()</td><td>Byte.toString(1)</td></tr>
4108 <tr><td>new Short(1).toString()</td><td>Short.toString(1)</td></tr>
4109 <tr><td>new Boolean(true).toString()</td><td>Boolean.toString(true)</td></tr>
4110 </table>
4111
4112
4113 <h3><a name="DM_FP_NUMBER_CTOR">Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead (DM_FP_NUMBER_CTOR)</a></h3>
4114
4115
4116 <p>
4117 Using <code>new Double(double)</code> is guaranteed to always result in a new object whereas
4118 <code>Double.valueOf(double)</code> allows caching of values to be done by the compiler, class library, or JVM.
4119 Using of cached values avoids object allocation and the code will be faster.
4120 </p>
4121 <p>
4122 Unless the class must be compatible with JVMs predating Java 1.5,
4123 use either autoboxing or the <code>valueOf()</code> method when creating instances of <code>Double</code> and <code>Float</code>.
4124 </p>
4125
4126
4127 <h3><a name="DM_NUMBER_CTOR">Bx: Method invokes inefficient Number constructor; use static valueOf instead (DM_NUMBER_CTOR)</a></h3>
4128
4129
4130 <p>
4131 Using <code>new Integer(int)</code> is guaranteed to always result in a new object whereas
4132 <code>Integer.valueOf(int)</code> allows caching of values to be done by the compiler, class library, or JVM.
4133 Using of cached values avoids object allocation and the code will be faster.
4134 </p>
4135 <p>
4136 Values between -128 and 127 are guaranteed to have corresponding cached instances
4137 and using <code>valueOf</code> is approximately 3.5 times faster than using constructor.
4138 For values outside the constant range the performance of both styles is the same.
4139 </p>
4140 <p>
4141 Unless the class must be compatible with JVMs predating Java 1.5,
4142 use either autoboxing or the <code>valueOf()</code> method when creating instances of
4143 <code>Long</code>, <code>Integer</code>, <code>Short</code>, <code>Character</code>, and <code>Byte</code>.
4144 </p>
4145
4146
4147 <h3><a name="DMI_BLOCKING_METHODS_ON_URL">Dm: The equals and hashCode methods of URL are blocking (DMI_BLOCKING_METHODS_ON_URL)</a></h3>
4148
4149
4150 <p> The equals and hashCode
4151 method of URL perform domain name resolution, this can result in a big performance hit.
4152 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
4153 Consider using <code>java.net.URI</code> instead.
4154 </p>
4155
4156
4157 <h3><a name="DMI_COLLECTION_OF_URLS">Dm: Maps and sets of URLs can be performance hogs (DMI_COLLECTION_OF_URLS)</a></h3>
4158
4159
4160 <p> This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode
4161 method of URL perform domain name resolution, this can result in a big performance hit.
4162 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
4163 Consider using <code>java.net.URI</code> instead.
4164 </p>
4165
4166
4167 <h3><a name="DM_BOOLEAN_CTOR">Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead (DM_BOOLEAN_CTOR)</a></h3>
4168
4169
4170 <p> Creating new instances of <code>java.lang.Boolean</code> wastes
4171 memory, since <code>Boolean</code> objects are immutable and there are
4172 only two useful values of this type.&nbsp; Use the <code>Boolean.valueOf()</code>
4173 method (or Java 1.5 autoboxing) to create <code>Boolean</code> objects instead.</p>
4174
4175
4176 <h3><a name="DM_GC">Dm: Explicit garbage collection; extremely dubious except in benchmarking code (DM_GC)</a></h3>
4177
4178
4179 <p> Code explicitly invokes garbage collection.
4180 Except for specific use in benchmarking, this is very dubious.</p>
4181 <p>In the past, situations where people have explicitly invoked
4182 the garbage collector in routines such as close or finalize methods
4183 has led to huge performance black holes. Garbage collection
4184 can be expensive. Any situation that forces hundreds or thousands
4185 of garbage collections will bring the machine to a crawl.</p>
4186
4187
4188 <h3><a name="DM_NEW_FOR_GETCLASS">Dm: Method allocates an object, only to get the class object (DM_NEW_FOR_GETCLASS)</a></h3>
4189
4190
4191 <p>This method allocates an object just to call getClass() on it, in order to
4192 retrieve the Class object for it. It is simpler to just access the .class property of the class.</p>
4193
4194
4195 <h3><a name="DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer (DM_NEXTINT_VIA_NEXTDOUBLE)</a></h3>
4196
4197
4198 <p>If <code>r</code> is a <code>java.util.Random</code>, you can generate a random number from <code>0</code> to <code>n-1</code>
4199 using <code>r.nextInt(n)</code>, rather than using <code>(int)(r.nextDouble() * n)</code>.
4200 </p>
4201 <p>The argument to nextInt must be positive. If, for example, you want to generate a random
4202 value from -99 to 0, use <code>-r.nextInt(100)</code>.
4203 </p>
4204
4205
4206 <h3><a name="DM_STRING_CTOR">Dm: Method invokes inefficient new String(String) constructor (DM_STRING_CTOR)</a></h3>
4207
4208
4209 <p> Using the <code>java.lang.String(String)</code> constructor wastes memory
4210 because the object so constructed will be functionally indistinguishable
4211 from the <code>String</code> passed as a parameter.&nbsp; Just use the
4212 argument <code>String</code> directly.</p>
4213
4214
4215 <h3><a name="DM_STRING_TOSTRING">Dm: Method invokes toString() method on a String (DM_STRING_TOSTRING)</a></h3>
4216
4217
4218 <p> Calling <code>String.toString()</code> is just a redundant operation.
4219 Just use the String.</p>
4220
4221
4222 <h3><a name="DM_STRING_VOID_CTOR">Dm: Method invokes inefficient new String() constructor (DM_STRING_VOID_CTOR)</a></h3>
4223
4224
4225 <p> Creating a new <code>java.lang.String</code> object using the
4226 no-argument constructor wastes memory because the object so created will
4227 be functionally indistinguishable from the empty string constant
4228 <code>""</code>.&nbsp; Java guarantees that identical string constants
4229 will be represented by the same <code>String</code> object.&nbsp; Therefore,
4230 you should just use the empty string constant directly.</p>
4231
4232
4233 <h3><a name="HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge string constants is duplicated across multiple class files (HSC_HUGE_SHARED_STRING_CONSTANT)</a></h3>
4234
4235
4236 <p>
4237 A large String constant is duplicated across multiple class files.
4238 This is likely because a final field is initialized to a String constant, and the Java language
4239 mandates that all references to a final field from other classes be inlined into
4240 that classfile. See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6447475">JDK bug 6447475</a>
4241 for a description of an occurrence of this bug in the JDK and how resolving it reduced
4242 the size of the JDK by 1 megabyte.
4243 </p>
4244
4245
4246 <h3><a name="IMA_INEFFICIENT_MEMBER_ACCESS">IMA: Method accesses a private member variable of owning class (IMA_INEFFICIENT_MEMBER_ACCESS)</a></h3>
4247
4248
4249 <p>
4250 This method of an inner class reads from or writes to a private member variable of the owning class,
4251 or calls a private method of the owning class. The compiler must generate a special method to access this
4252 private member, causing this to be less efficient. Relaxing the protection of the member variable or method
4253 will allow the compiler to treat this as a normal access.
4254 </p>
4255
4256
4257 <h3><a name="ITA_INEFFICIENT_TO_ARRAY">ITA: Method uses toArray() with zero-length array argument (ITA_INEFFICIENT_TO_ARRAY)</a></h3>
4258
4259
4260 <p> This method uses the toArray() method of a collection derived class, and passes
4261 in a zero-length prototype array argument. It is more efficient to use
4262 <code>myCollection.toArray(new Foo[myCollection.size()])</code>
4263 If the array passed in is big enough to store all of the
4264 elements of the collection, then it is populated and returned
4265 directly. This avoids the need to create a second array
4266 (by reflection) to return as the result.</p>
4267
4268
4269 <h3><a name="SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: Method concatenates strings using + in a loop (SBSC_USE_STRINGBUFFER_CONCATENATION)</a></h3>
4270
4271
4272 <p> The method seems to be building a String using concatenation in a loop.
4273 In each iteration, the String is converted to a StringBuffer/StringBuilder,
4274 appended to, and converted back to a String.
4275 This can lead to a cost quadratic in the number of iterations,
4276 as the growing string is recopied in each iteration. </p>
4277
4278 <p>Better performance can be obtained by using
4279 a StringBuffer (or StringBuilder in Java 1.5) explicitly.</p>
4280
4281 <p> For example:</p>
4282 <pre>
4283 // This is bad
4284 String s = "";
4285 for (int i = 0; i &lt; field.length; ++i) {
4286 s = s + field[i];
4287 }
4288
4289 // This is better
4290 StringBuffer buf = new StringBuffer();
4291 for (int i = 0; i &lt; field.length; ++i) {
4292 buf.append(field[i]);
4293 }
4294 String s = buf.toString();
4295 </pre>
4296
4297
4298 <h3><a name="SIC_INNER_SHOULD_BE_STATIC">SIC: Should be a static inner class (SIC_INNER_SHOULD_BE_STATIC)</a></h3>
4299
4300
4301 <p> This class is an inner class, but does not use its embedded reference
4302 to the object which created it.&nbsp; This reference makes the instances
4303 of the class larger, and may keep the reference to the creator object
4304 alive longer than necessary.&nbsp; If possible, the class should be
4305 made static.
4306 </p>
4307
4308
4309 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Could be refactored into a named static inner class (SIC_INNER_SHOULD_BE_STATIC_ANON)</a></h3>
4310
4311
4312 <p> This class is an inner class, but does not use its embedded reference
4313 to the object which created it.&nbsp; This reference makes the instances
4314 of the class larger, and may keep the reference to the creator object
4315 alive longer than necessary.&nbsp; If possible, the class should be
4316 made into a <em>static</em> inner class. Since anonymous inner
4317 classes cannot be marked as static, doing this will require refactoring
4318 the inner class so that it is a named inner class.</p>
4319
4320
4321 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC: Could be refactored into a static inner class (SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS)</a></h3>
4322
4323
4324 <p> This class is an inner class, but does not use its embedded reference
4325 to the object which created it except during construction of the
4326 inner object.&nbsp; This reference makes the instances
4327 of the class larger, and may keep the reference to the creator object
4328 alive longer than necessary.&nbsp; If possible, the class should be
4329 made into a <em>static</em> inner class. Since the reference to the
4330 outer object is required during construction of the inner instance,
4331 the inner class will need to be refactored so as to
4332 pass a reference to the outer instance to the constructor
4333 for the inner class.</p>
4334
4335
4336 <h3><a name="SS_SHOULD_BE_STATIC">SS: Unread field: should this field be static? (SS_SHOULD_BE_STATIC)</a></h3>
4337
4338
4339 <p> This class contains an instance final field that
4340 is initialized to a compile-time static value.
4341 Consider making the field static.</p>
4342
4343
4344 <h3><a name="UM_UNNECESSARY_MATH">UM: Method calls static Math class method on a constant value (UM_UNNECESSARY_MATH)</a></h3>
4345
4346
4347 <p> This method uses a static method from java.lang.Math on a constant value. This method's
4348 result in this case, can be determined statically, and is faster and sometimes more accurate to
4349 just use the constant. Methods detected are:
4350 </p>
4351 <table>
4352 <tr>
4353 <th>Method</th> <th>Parameter</th>
4354 </tr>
4355 <tr>
4356 <td>abs</td> <td>-any-</td>
4357 </tr>
4358 <tr>
4359 <td>acos</td> <td>0.0 or 1.0</td>
4360 </tr>
4361 <tr>
4362 <td>asin</td> <td>0.0 or 1.0</td>
4363 </tr>
4364 <tr>
4365 <td>atan</td> <td>0.0 or 1.0</td>
4366 </tr>
4367 <tr>
4368 <td>atan2</td> <td>0.0</td>
4369 </tr>
4370 <tr>
4371 <td>cbrt</td> <td>0.0 or 1.0</td>
4372 </tr>
4373 <tr>
4374 <td>ceil</td> <td>-any-</td>
4375 </tr>
4376 <tr>
4377 <td>cos</td> <td>0.0</td>
4378 </tr>
4379 <tr>
4380 <td>cosh</td> <td>0.0</td>
4381 </tr>
4382 <tr>
4383 <td>exp</td> <td>0.0 or 1.0</td>
4384 </tr>
4385 <tr>
4386 <td>expm1</td> <td>0.0</td>
4387 </tr>
4388 <tr>
4389 <td>floor</td> <td>-any-</td>
4390 </tr>
4391 <tr>
4392 <td>log</td> <td>0.0 or 1.0</td>
4393 </tr>
4394 <tr>
4395 <td>log10</td> <td>0.0 or 1.0</td>
4396 </tr>
4397 <tr>
4398 <td>rint</td> <td>-any-</td>
4399 </tr>
4400 <tr>
4401 <td>round</td> <td>-any-</td>
4402 </tr>
4403 <tr>
4404 <td>sin</td> <td>0.0</td>
4405 </tr>
4406 <tr>
4407 <td>sinh</td> <td>0.0</td>
4408 </tr>
4409 <tr>
4410 <td>sqrt</td> <td>0.0 or 1.0</td>
4411 </tr>
4412 <tr>
4413 <td>tan</td> <td>0.0</td>
4414 </tr>
4415 <tr>
4416 <td>tanh</td> <td>0.0</td>
4417 </tr>
4418 <tr>
4419 <td>toDegrees</td> <td>0.0 or 1.0</td>
4420 </tr>
4421 <tr>
4422 <td>toRadians</td> <td>0.0</td>
4423 </tr>
4424 </table>
4425
4426
4427 <h3><a name="UPM_UNCALLED_PRIVATE_METHOD">UPM: Private method is never called (UPM_UNCALLED_PRIVATE_METHOD)</a></h3>
4428
4429
4430 <p> This private method is never called. Although it is
4431 possible that the method will be invoked through reflection,
4432 it is more likely that the method is never used, and should be
4433 removed.
4434 </p>
4435
4436
4437 <h3><a name="URF_UNREAD_FIELD">UrF: Unread field (URF_UNREAD_FIELD)</a></h3>
4438
4439
4440 <p> This field is never read.&nbsp; Consider removing it from the class.</p>
4441
4442
4443 <h3><a name="UUF_UNUSED_FIELD">UuF: Unused field (UUF_UNUSED_FIELD)</a></h3>
4444
4445
4446 <p> This field is never used.&nbsp; Consider removing it from the class.</p>
4447
4448
4449 <h3><a name="WMI_WRONG_MAP_ITERATOR">WMI: Inefficient use of keySet iterator instead of entrySet iterator (WMI_WRONG_MAP_ITERATOR)</a></h3>
4450
4451
4452 <p> This method accesses the value of a Map entry, using a key that was retrieved from
4453 a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the
4454 Map.get(key) lookup.</p>
4455
4456
4457 <h3><a name="DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded constant database password (DMI_CONSTANT_DB_PASSWORD)</a></h3>
4458
4459
4460 <p>This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can
4461 easily learn the password.
4462 </p>
4463
4464
4465
4466 <h3><a name="DMI_EMPTY_DB_PASSWORD">Dm: Empty database password (DMI_EMPTY_DB_PASSWORD)</a></h3>
4467
4468
4469 <p>This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password.
4470 </p>
4471
4472
4473
4474 <h3><a name="HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP cookie formed from untrusted input (HRS_REQUEST_PARAMETER_TO_COOKIE)</a></h3>
4475
4476
4477 <p>This code constructs an HTTP Cookie using an untrusted HTTP parameter. If this cookie is added to an HTTP response, it will allow a HTTP response splitting
4478 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
4479 for more information.</p>
4480 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response splitting.
4481 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4482 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously
4483 consider using a commercial static analysis or pen-testing tool.
4484 </p>
4485
4486
4487
4488 <h3><a name="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: HTTP Response splitting vulnerability (HRS_REQUEST_PARAMETER_TO_HTTP_HEADER)</a></h3>
4489
4490
4491 <p>This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting
4492 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
4493 for more information.</p>
4494 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response splitting.
4495 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4496 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously
4497 consider using a commercial static analysis or pen-testing tool.
4498 </p>
4499
4500
4501
4502 <h3><a name="PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute path traversal in servlet (PT_ABSOLUTE_PATH_TRAVERSAL)</a></h3>
4503
4504
4505 <p>The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory,
4506 but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
4507
4508 See <a href="http://cwe.mitre.org/data/definitions/36.html">http://cwe.mitre.org/data/definitions/36.html</a>
4509 for more information.</p>
4510 <p>FindBugs looks only for the most blatant, obvious cases of absolute path traversal.
4511 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4512 vulnerabilities that FindBugs doesn't report. If you are concerned about absolute path traversal, you should seriously
4513 consider using a commercial static analysis or pen-testing tool.
4514 </p>
4515
4516
4517
4518 <h3><a name="PT_RELATIVE_PATH_TRAVERSAL">PT: Relative path traversal in servlet (PT_RELATIVE_PATH_TRAVERSAL)</a></h3>
4519
4520
4521 <p>The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.
4522
4523 See <a href="http://cwe.mitre.org/data/definitions/23.html">http://cwe.mitre.org/data/definitions/23.html</a>
4524 for more information.</p>
4525 <p>FindBugs looks only for the most blatant, obvious cases of relative path traversal.
4526 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4527 vulnerabilities that FindBugs doesn't report. If you are concerned about relative path traversal, you should seriously
4528 consider using a commercial static analysis or pen-testing tool.
4529 </p>
4530
4531
4532
4533 <h3><a name="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQL: Nonconstant string passed to execute method on an SQL statement (SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE)</a></h3>
4534
4535
4536 <p>The method invokes the execute method on an SQL statement with a String that seems
4537 to be dynamically generated. Consider using
4538 a prepared statement instead. It is more efficient and less vulnerable to
4539 SQL injection attacks.
4540 </p>
4541
4542
4543 <h3><a name="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING">SQL: A prepared statement is generated from a nonconstant String (SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING)</a></h3>
4544
4545
4546 <p>The code creates an SQL prepared statement from a nonconstant String.
4547 If unchecked, tainted data from a user is used in building this String, SQL injection could
4548 be used to make the prepared statement do something unexpected and undesirable.
4549 </p>
4550
4551
4552 <h3><a name="XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JSP reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_JSP_WRITER)</a></h3>
4553
4554
4555 <p>This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting
4556 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4557 for more information.</p>
4558 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4559 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4560 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4561 consider using a commercial static analysis or pen-testing tool.
4562 </p>
4563
4564
4565 <h3><a name="XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Servlet reflected cross site scripting vulnerability in error page (XSS_REQUEST_PARAMETER_TO_SEND_ERROR)</a></h3>
4566
4567
4568 <p>This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows
4569 for a reflected cross site scripting
4570 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4571 for more information.</p>
4572 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4573 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4574 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4575 consider using a commercial static analysis or pen-testing tool.
4576 </p>
4577
4578
4579
4580 <h3><a name="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS: Servlet reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER)</a></h3>
4581
4582
4583 <p>This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting
4584 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4585 for more information.</p>
4586 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4587 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4588 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4589 consider using a commercial static analysis or pen-testing tool.
4590 </p>
4591
4592
4593
4594 <h3><a name="BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Questionable cast to abstract collection (BC_BAD_CAST_TO_ABSTRACT_COLLECTION)</a></h3>
4595
4596
4597 <p>
4598 This code casts a Collection to an abstract collection
4599 (such as <code>List</code>, <code>Set</code>, or <code>Map</code>).
4600 Ensure that you are guaranteed that the object is of the type
4601 you are casting to. If all you need is to be able
4602 to iterate through a collection, you don't need to cast it to a Set or List.
4603 </p>
4604
4605
4606 <h3><a name="BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Questionable cast to concrete collection (BC_BAD_CAST_TO_CONCRETE_COLLECTION)</a></h3>
4607
4608
4609 <p>
4610 This code casts an abstract collection (such as a Collection, List, or Set)
4611 to a specific concrete implementation (such as an ArrayList or HashSet).
4612 This might not be correct, and it may make your code fragile, since
4613 it makes it harder to switch to other concrete implementations at a future
4614 point. Unless you have a particular reason to do so, just use the abstract
4615 collection class.
4616 </p>
4617
4618
4619 <h3><a name="BC_UNCONFIRMED_CAST">BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST)</a></h3>
4620
4621
4622 <p>
4623 This cast is unchecked, and not all instances of the type casted from can be cast to
4624 the type it is being cast to. Check that your program logic ensures that this
4625 cast will not fail.
4626 </p>
4627
4628
4629 <h3><a name="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unchecked/unconfirmed cast of return value from method (BC_UNCONFIRMED_CAST_OF_RETURN_VALUE)</a></h3>
4630
4631
4632 <p>
4633 This code performs an unchecked cast of the return value of a method.
4634 The code might be calling the method in such a way that the cast is guaranteed to be
4635 safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this
4636 cast will not fail.
4637 </p>
4638
4639
4640 <h3><a name="BC_VACUOUS_INSTANCEOF">BC: instanceof will always return true (BC_VACUOUS_INSTANCEOF)</a></h3>
4641
4642
4643 <p>
4644 This instanceof test will always return true (unless the value being tested is null).
4645 Although this is safe, make sure it isn't
4646 an indication of some misunderstanding or some other logic error.
4647 If you really want to test the value for being null, perhaps it would be clearer to do
4648 better to do a null test rather than an instanceof test.
4649 </p>
4650
4651
4652 <h3><a name="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSHIFT: Unsigned right shift cast to short/byte (ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT)</a></h3>
4653
4654
4655 <p>
4656 The code performs an unsigned right shift, whose result is then
4657 cast to a short or byte, which discards the upper bits of the result.
4658 Since the upper bits are discarded, there may be no difference between
4659 a signed and unsigned right shift (depending upon the size of the shift).
4660 </p>
4661
4662
4663 <h3><a name="CD_CIRCULAR_DEPENDENCY">CD: Test for circular dependencies among classes (CD_CIRCULAR_DEPENDENCY)</a></h3>
4664
4665
4666 <p>
4667 This class has a circular dependency with other classes. This makes building these classes
4668 difficult, as each is dependent on the other to build correctly. Consider using interfaces
4669 to break the hard dependency.
4670 </p>
4671
4672
4673 <h3><a name="CI_CONFUSED_INHERITANCE">CI: Class is final but declares protected field (CI_CONFUSED_INHERITANCE)</a></h3>
4674
4675
4676 <p>
4677 This class is declared to be final, but declares fields to be protected. Since the class
4678 is final, it can not be derived from, and the use of protected is confusing. The access
4679 modifier for the field should be changed to private or public to represent the true
4680 use for the field.
4681 </p>
4682
4683
4684 <h3><a name="DB_DUPLICATE_BRANCHES">DB: Method uses the same code for two branches (DB_DUPLICATE_BRANCHES)</a></h3>
4685
4686
4687 <p>
4688 This method uses the same code to implement two branches of a conditional branch.
4689 Check to ensure that this isn't a coding mistake.
4690 </p>
4691
4692
4693 <h3><a name="DB_DUPLICATE_SWITCH_CLAUSES">DB: Method uses the same code for two switch clauses (DB_DUPLICATE_SWITCH_CLAUSES)</a></h3>
4694
4695
4696 <p>
4697 This method uses the same code to implement two clauses of a switch statement.
4698 This could be a case of duplicate code, but it might also indicate
4699 a coding mistake.
4700 </p>
4701
4702
4703 <h3><a name="DLS_DEAD_LOCAL_STORE">DLS: Dead store to local variable (DLS_DEAD_LOCAL_STORE)</a></h3>
4704
4705
4706 <p>
4707 This instruction assigns a value to a local variable,
4708 but the value is not read or used in any subsequent instruction.
4709 Often, this indicates an error, because the value computed is never
4710 used.
4711 </p>
4712 <p>
4713 Note that Sun's javac compiler often generates dead stores for
4714 final local variables. Because FindBugs is a bytecode-based tool,
4715 there is no easy way to eliminate these false positives.
4716 </p>
4717
4718
4719 <h3><a name="DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless assignment in return statement (DLS_DEAD_LOCAL_STORE_IN_RETURN)</a></h3>
4720
4721
4722 <p>
4723 This statement assigns to a local variable in a return statement. This assignment
4724 has effect. Please verify that this statement does the right thing.
4725 </p>
4726
4727
4728 <h3><a name="DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Dead store of null to local variable (DLS_DEAD_LOCAL_STORE_OF_NULL)</a></h3>
4729
4730
4731 <p>The code stores null into a local variable, and the stored value is not
4732 read. This store may have been introduced to assist the garbage collector, but
4733 as of Java SE 6.0, this is no longer needed or useful.
4734 </p>
4735
4736
4737 <h3><a name="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dead store to local variable that shadows field (DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD)</a></h3>
4738
4739
4740 <p>
4741 This instruction assigns a value to a local variable,
4742 but the value is not read or used in any subsequent instruction.
4743 Often, this indicates an error, because the value computed is never
4744 used. There is a field with the same name as the local variable. Did you
4745 mean to assign to that variable instead?
4746 </p>
4747
4748
4749 <h3><a name="DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Code contains a hard coded reference to an absolute pathname (DMI_HARDCODED_ABSOLUTE_FILENAME)</a></h3>
4750
4751
4752 <p>This code constructs a File object using a hard coded to an absolute pathname
4753 (e.g., <code>new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");</code>
4754 </p>
4755
4756
4757 <h3><a name="DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Non serializable object written to ObjectOutput (DMI_NONSERIALIZABLE_OBJECT_WRITTEN)</a></h3>
4758
4759
4760 <p>
4761 This code seems to be passing a non-serializable object to the ObjectOutput.writeObject method.
4762 If the object is, indeed, non-serializable, an error will result.
4763 </p>
4764
4765
4766 <h3><a name="DMI_USELESS_SUBSTRING">DMI: Invocation of substring(0), which returns the original value (DMI_USELESS_SUBSTRING)</a></h3>
4767
4768
4769 <p>
4770 This code invokes substring(0) on a String, which returns the original value.
4771 </p>
4772
4773
4774 <h3><a name="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">Dm: Thread passed where Runnable expected (DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED)</a></h3>
4775
4776
4777 <p> A Thread object is passed as a parameter to a method where
4778 a Runnable is expected. This is rather unusual, and may indicate a logic error
4779 or cause unexpected behavior.
4780 </p>
4781
4782
4783 <h3><a name="DMI_UNSUPPORTED_METHOD">Dm: Call to unsupported method (DMI_UNSUPPORTED_METHOD)</a></h3>
4784
4785
4786 <p>All targets of this method invocation throw an UnsupportedOperationException.
4787 </p>
4788
4789
4790
4791 <h3><a name="EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't override equals in superclass (EQ_DOESNT_OVERRIDE_EQUALS)</a></h3>
4792
4793
4794 <p> This class extends a class that defines an equals method and adds fields, but doesn't
4795 define an equals method itself. Thus, equality on instances of this class will
4796 ignore the identity of the subclass and the added fields. Be sure this is what is intended,
4797 and that you don't need to override the equals method. Even if you don't need to override
4798 the equals method, consider overriding it anyway to document the fact
4799 that the equals method for the subclass just return the result of
4800 invoking super.equals(o).
4801 </p>
4802
4803
4804 <h3><a name="EQ_UNUSUAL">Eq: Unusual equals method (EQ_UNUSUAL)</a></h3>
4805
4806
4807 <p> This class doesn't do any of the patterns we recognize for checking that the type of the argument
4808 is compatible with the type of the <code>this</code> object. There might not be anything wrong with
4809 this code, but it is worth reviewing.
4810 </p>
4811
4812
4813 <h3><a name="FE_FLOATING_POINT_EQUALITY">FE: Test for floating point equality (FE_FLOATING_POINT_EQUALITY)</a></h3>
4814
4815
4816 <p>
4817 This operation compares two floating point values for equality.
4818 Because floating point calculations may involve rounding,
4819 calculated float and double values may not be accurate.
4820 For values that must be precise, such as monetary values,
4821 consider using a fixed-precision type such as BigDecimal.
4822 For values that need not be precise, consider comparing for equality
4823 within some range, for example:
4824 <code>if ( Math.abs(x - y) &lt; .0000001 )</code>.
4825 See the Java Language Specification, section 4.2.4.
4826 </p>
4827
4828
4829 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">FS: Non-Boolean argument formatted using %b format specifier (VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN)</a></h3>
4830
4831
4832 <p>
4833 An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an
4834 exception; instead, it will print true for any nonnull value, and false for null.
4835 This feature of format strings is strange, and may not be what you intended.
4836 </p>
4837
4838
4839 <h3><a name="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">IA: Potentially ambiguous invocation of either an inherited or outer method (IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD)</a></h3>
4840
4841
4842 <p>
4843 An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class.
4844 For example, you invoke <code>foo(17)</code>, which is defined in both a superclass and in an outer method.
4845 By the Java semantics,
4846 it will be resolved to invoke the inherited method, but this may not be want
4847 you intend.
4848 </p>
4849 <p>If you really intend to invoke the inherited method,
4850 invoke it by invoking the method on super (e.g., invoke super.foo(17)), and
4851 thus it will be clear to other readers of your code and to FindBugs
4852 that you want to invoke the inherited method, not the method in the outer class.
4853 </p>
4854 <p>If you call <code>this.foo(17)</code>, then the inherited method will be invoked. However, since FindBugs only looks at
4855 classfiles, it
4856 can't tell the difference between an invocation of <code>this.foo(17)</code> and <code>foo(17)</code>, it will still
4857 complain about a potential ambiguous invocation.
4858 </p>
4859
4860
4861 <h3><a name="IC_INIT_CIRCULARITY">IC: Initialization circularity (IC_INIT_CIRCULARITY)</a></h3>
4862
4863
4864 <p> A circularity was detected in the static initializers of the two
4865 classes referenced by the bug instance.&nbsp; Many kinds of unexpected
4866 behavior may arise from such circularity.</p>
4867
4868
4869 <h3><a name="ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Integral division result cast to double or float (ICAST_IDIV_CAST_TO_DOUBLE)</a></h3>
4870
4871
4872 <p>
4873 This code casts the result of an integral division (e.g., int or long division)
4874 operation to double or
4875 float.
4876 Doing division on integers truncates the result
4877 to the integer value closest to zero. The fact that the result
4878 was cast to double suggests that this precision should have been retained.
4879 What was probably meant was to cast one or both of the operands to
4880 double <em>before</em> performing the division. Here is an example:
4881 </p>
4882 <blockquote>
4883 <pre>
4884 int x = 2;
4885 int y = 5;
4886 // Wrong: yields result 0.0
4887 double value1 = x / y;
4888
4889 // Right: yields result 0.4
4890 double value2 = x / (double) y;
4891 </pre>
4892 </blockquote>
4893
4894
4895 <h3><a name="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST: Result of integer multiplication cast to long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)</a></h3>
4896
4897
4898 <p>
4899 This code performs integer multiply and then converts the result to a long,
4900 as in:</p>
4901 <pre>
4902 long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }
4903 </pre>
4904 <p>
4905 If the multiplication is done using long arithmetic, you can avoid
4906 the possibility that the result will overflow. For example, you
4907 could fix the above code to:</p>
4908 <pre>
4909 long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
4910 </pre>
4911 or
4912 <pre>
4913 static final long MILLISECONDS_PER_DAY = 24L*3600*1000;
4914 long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }
4915 </pre>
4916
4917
4918 <h3><a name="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: Computation of average could overflow (IM_AVERAGE_COMPUTATION_COULD_OVERFLOW)</a></h3>
4919
4920
4921 <p>The code computes the average of two integers using either division or signed right shift,
4922 and then uses the result as the index of an array.
4923 If the values being averaged are very large, this can overflow (resulting in the computation
4924 of a negative average). Assuming that the result is intended to be nonnegative, you
4925 can use an unsigned right shift instead. In other words, rather that using <code>(low+high)/2</code>,
4926 use <code>(low+high) &gt;&gt;&gt; 1</code>
4927 </p>
4928 <p>This bug exists in many earlier implementations of binary search and merge sort.
4929 Martin Buchholz <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6412541">found and fixed it</a>
4930 in the JDK libraries, and Joshua Bloch
4931 <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">widely
4932 publicized the bug pattern</a>.
4933 </p>
4934
4935
4936 <h3><a name="IM_BAD_CHECK_FOR_ODD">IM: Check for oddness that won't work for negative numbers (IM_BAD_CHECK_FOR_ODD)</a></h3>
4937
4938
4939 <p>
4940 The code uses x % 2 == 1 to check to see if a value is odd, but this won't work
4941 for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check
4942 for oddness, consider using x &amp; 1 == 1, or x % 2 != 0.
4943 </p>
4944
4945
4946 <h3><a name="INT_BAD_REM_BY_1">INT: Integer remainder modulo 1 (INT_BAD_REM_BY_1)</a></h3>
4947
4948
4949 <p> Any expression (exp % 1) is guaranteed to always return zero.
4950 Did you mean (exp &amp; 1) or (exp % 2) instead?
4951 </p>
4952
4953
4954 <h3><a name="INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit mask operation on integer value (INT_VACUOUS_BIT_OPERATION)</a></h3>
4955
4956
4957 <p> This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work
4958 (e.g., <code>v & 0xffffffff</code>).
4959
4960 </p>
4961
4962
4963 <h3><a name="INT_VACUOUS_COMPARISON">INT: Vacuous comparison of integer value (INT_VACUOUS_COMPARISON)</a></h3>
4964
4965
4966 <p> There is an integer comparison that always returns
4967 the same value (e.g., x &lt;= Integer.MAX_VALUE).
4968 </p>
4969
4970
4971 <h3><a name="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: Class extends Servlet class and uses instance variables (MTIA_SUSPECT_SERVLET_INSTANCE_FIELD)</a></h3>
4972
4973
4974 <p>
4975 This class extends from a Servlet class, and uses an instance member variable. Since only
4976 one instance of a Servlet class is created by the J2EE framework, and used in a
4977 multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider
4978 only using method local variables.
4979 </p>
4980
4981
4982 <h3><a name="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: Class extends Struts Action class and uses instance variables (MTIA_SUSPECT_STRUTS_INSTANCE_FIELD)</a></h3>
4983
4984
4985 <p>
4986 This class extends from a Struts Action class, and uses an instance member variable. Since only
4987 one instance of a struts Action class is created by the Struts framework, and used in a
4988 multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider
4989 only using method local variables. Only instance fields that are written outside of a monitor
4990 are reported.
4991 </p>
4992
4993
4994 <h3><a name="NP_DEREFERENCE_OF_READLINE_VALUE">NP: Dereference of the result of readLine() without nullcheck (NP_DEREFERENCE_OF_READLINE_VALUE)</a></h3>
4995
4996
4997 <p> The result of invoking readLine() is dereferenced without checking to see if the result is null. If there are no more lines of text
4998 to read, readLine() will return null and dereferencing that will generate a null pointer exception.
4999 </p>
5000
5001
5002 <h3><a name="NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Immediate dereference of the result of readLine() (NP_IMMEDIATE_DEREFERENCE_OF_READLINE)</a></h3>
5003
5004
5005 <p> The result of invoking readLine() is immediately dereferenced. If there are no more lines of text
5006 to read, readLine() will return null and dereferencing that will generate a null pointer exception.
5007 </p>
5008
5009
5010 <h3><a name="NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Load of known null value (NP_LOAD_OF_KNOWN_NULL_VALUE)</a></h3>
5011
5012
5013 <p> The variable referenced at this point is known to be null due to an earlier
5014 check against null. Although this is valid, it might be a mistake (perhaps you
5015 intended to refer to a different variable, or perhaps the earlier check to see if the
5016 variable is null should have been a check to see if it was nonnull).
5017 </p>
5018
5019
5020 <h3><a name="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP: Method tightens nullness annotation on parameter (NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION)</a></h3>
5021
5022 <p>
5023 A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter
5024 that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.
5025 Doing so violates the contract that the method should handle a null parameter.
5026 </p>
5027
5028 <h3><a name="NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Method relaxes nullness annotation on return value (NP_METHOD_RETURN_RELAXING_ANNOTATION)</a></h3>
5029
5030 <p>
5031 A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated
5032 as returning a @Nonnull value,
5033 you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value.
5034 Doing so violates the contract that the method shouldn't return null.
5035 </p>
5036
5037 <h3><a name="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP: Possible null pointer dereference due to return value of called method (NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE)</a></h3>
5038
5039
5040 <p> The return value from a method is dereferenced without a null check,
5041 and the return value of that method is one that should generally be checked
5042 for null. This may lead to a <code>NullPointerException</code> when the code is executed.
5043 </p>
5044
5045
5046 <h3><a name="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP: Possible null pointer dereference on branch that might be infeasible (NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE)</a></h3>
5047
5048
5049 <p> There is a branch of statement that, <em>if executed,</em> guarantees that
5050 a null value will be dereferenced, which
5051 would generate a <code>NullPointerException</code> when the code is executed.
5052 Of course, the problem might be that the branch or statement is infeasible and that
5053 the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
5054 Due to the fact that this value had been previously tested for nullness,
5055 this is a definite possibility.
5056 </p>
5057
5058
5059 <h3><a name="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP: Parameter must be nonnull but is marked as nullable (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE)</a></h3>
5060
5061
5062 <p> This parameter is always used in a way that requires it to be nonnull,
5063 but the parameter is explicitly annotated as being Nullable. Either the use
5064 of the parameter or the annotation is wrong.
5065 </p>
5066
5067
5068 <h3><a name="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP: Read of unwritten public or protected field (NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5069
5070
5071 <p> The program is dereferencing a public or protected
5072 field that does not seem to ever have a non-null value written to it.
5073 Unless the field is initialized via some mechanism not seen by the analysis,
5074 dereferencing this value will generate a null pointer exception.
5075 </p>
5076
5077
5078 <h3><a name="NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentially dangerous use of non-short-circuit logic (NS_DANGEROUS_NON_SHORT_CIRCUIT)</a></h3>
5079
5080
5081 <p> This code seems to be using non-short-circuit logic (e.g., &amp;
5082 or |)
5083 rather than short-circuit logic (&amp;&amp; or ||). In addition,
5084 it seem possible that, depending on the value of the left hand side, you might not
5085 want to evaluate the right hand side (because it would have side effects, could cause an exception
5086 or could be expensive.</p>
5087 <p>
5088 Non-short-circuit logic causes both sides of the expression
5089 to be evaluated even when the result can be inferred from
5090 knowing the left-hand side. This can be less efficient and
5091 can result in errors if the left-hand side guards cases
5092 when evaluating the right-hand side can generate an error.
5093 </p>
5094
5095 <p>See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java
5096 Language Specification</a> for details
5097
5098 </p>
5099
5100
5101 <h3><a name="NS_NON_SHORT_CIRCUIT">NS: Questionable use of non-short-circuit logic (NS_NON_SHORT_CIRCUIT)</a></h3>
5102
5103
5104 <p> This code seems to be using non-short-circuit logic (e.g., &amp;
5105 or |)
5106 rather than short-circuit logic (&amp;&amp; or ||).
5107 Non-short-circuit logic causes both sides of the expression
5108 to be evaluated even when the result can be inferred from
5109 knowing the left-hand side. This can be less efficient and
5110 can result in errors if the left-hand side guards cases
5111 when evaluating the right-hand side can generate an error.
5112
5113 <p>See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java
5114 Language Specification</a> for details
5115
5116 </p>
5117
5118
5119 <h3><a name="PS_PUBLIC_SEMAPHORES">PS: Class exposes synchronization and semaphores in its public interface (PS_PUBLIC_SEMAPHORES)</a></h3>
5120
5121
5122 <p>
5123 This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this
5124 reference). Client classes that use this class, may, in addition, use an instance of this class
5125 as a synchronizing object. Because two classes are using the same object for synchronization,
5126 Multithread correctness is suspect. You should not synchronize nor call semaphore methods on
5127 a public reference. Consider using a internal private member variable to control synchronization.
5128 </p>
5129
5130
5131 <h3><a name="PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Consider returning a zero length array rather than null (PZLA_PREFER_ZERO_LENGTH_ARRAYS)</a></h3>
5132
5133
5134 <p> It is often a better design to
5135 return a length zero array rather than a null reference to indicate that there
5136 are no results (i.e., an empty list of results).
5137 This way, no explicit check for null is needed by clients of the method.</p>
5138
5139 <p>On the other hand, using null to indicate
5140 "there is no answer to this question" is probably appropriate.
5141 For example, <code>File.listFiles()</code> returns an empty list
5142 if given a directory containing no files, and returns null if the file
5143 is not a directory.</p>
5144
5145
5146 <h3><a name="QF_QUESTIONABLE_FOR_LOOP">QF: Complicated, subtle or wrong increment in for-loop (QF_QUESTIONABLE_FOR_LOOP)</a></h3>
5147
5148
5149 <p>Are you sure this for loop is incrementing the correct variable?
5150 It appears that another variable is being initialized and checked
5151 by the for loop.
5152 </p>
5153
5154
5155 <h3><a name="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">RCN: Redundant comparison of non-null value to null (RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE)</a></h3>
5156
5157
5158 <p> This method contains a reference known to be non-null with another reference
5159 known to be null.</p>
5160
5161
5162 <h3><a name="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RCN: Redundant comparison of two null values (RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES)</a></h3>
5163
5164
5165 <p> This method contains a redundant comparison of two references known to
5166 both be definitely null.</p>
5167
5168
5169 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RCN: Redundant nullcheck of value known to be non-null (RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE)</a></h3>
5170
5171
5172 <p> This method contains a redundant check of a known non-null value against
5173 the constant null.</p>
5174
5175
5176 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN: Redundant nullcheck of value known to be null (RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE)</a></h3>
5177
5178
5179 <p> This method contains a redundant check of a known null value against
5180 the constant null.</p>
5181
5182
5183 <h3><a name="REC_CATCH_EXCEPTION">REC: Exception is caught when Exception is not thrown (REC_CATCH_EXCEPTION)</a></h3>
5184
5185
5186 <p>
5187 This method uses a try-catch block that catches Exception objects, but Exception is not
5188 thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to
5189 say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception
5190 each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well,
5191 masking potential bugs.
5192 </p>
5193 <p>A better approach is to either explicitly catch the specific exceptions that are thrown,
5194 or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p>
5195 <pre>
5196 try {
5197 ...
5198 } catch (RuntimeException e) {
5199 throw e;
5200 } catch (Exception e) {
5201 ... deal with all non-runtime exceptions ...
5202 }</pre>
5203
5204
5205 <h3><a name="RI_REDUNDANT_INTERFACES">RI: Class implements same interface as superclass (RI_REDUNDANT_INTERFACES)</a></h3>
5206
5207
5208 <p>
5209 This class declares that it implements an interface that is also implemented by a superclass.
5210 This is redundant because once a superclass implements an interface, all subclasses by default also
5211 implement this interface. It may point out that the inheritance hierarchy has changed since
5212 this class was created, and consideration should be given to the ownership of
5213 the interface's implementation.
5214 </p>
5215
5216
5217 <h3><a name="RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Method checks to see if result of String.indexOf is positive (RV_CHECK_FOR_POSITIVE_INDEXOF)</a></h3>
5218
5219
5220 <p> The method invokes String.indexOf and checks to see if the result is positive or non-positive.
5221 It is much more typical to check to see if the result is negative or non-negative. It is
5222 positive only if the substring checked for occurs at some place other than at the beginning of
5223 the String.</p>
5224
5225
5226 <h3><a name="RV_DONT_JUST_NULL_CHECK_READLINE">RV: Method discards result of readLine after checking if it is nonnull (RV_DONT_JUST_NULL_CHECK_READLINE)</a></h3>
5227
5228
5229 <p> The value returned by readLine is discarded after checking to see if the return
5230 value is non-null. In almost all situations, if the result is non-null, you will want
5231 to use that non-null value. Calling readLine again will give you a different line.</p>
5232
5233
5234 <h3><a name="RV_REM_OF_HASHCODE">RV: Remainder of hashCode could be negative (RV_REM_OF_HASHCODE)</a></h3>
5235
5236
5237 <p> This code computes a hashCode, and then computes
5238 the remainder of that value modulo another value. Since the hashCode
5239 can be negative, the result of the remainder operation
5240 can also be negative. </p>
5241 <p> Assuming you want to ensure that the result of your computation is nonnegative,
5242 you may need to change your code.
5243 If you know the divisor is a power of 2,
5244 you can use a bitwise and operator instead (i.e., instead of
5245 using <code>x.hashCode()%n</code>, use <code>x.hashCode()&amp;(n-1)</code>.
5246 This is probably faster than computing the remainder as well.
5247 If you don't know that the divisor is a power of 2, take the absolute
5248 value of the result of the remainder operation (i.e., use
5249 <code>Math.abs(x.hashCode()%n)</code>
5250 </p>
5251
5252
5253 <h3><a name="RV_REM_OF_RANDOM_INT">RV: Remainder of 32-bit signed random integer (RV_REM_OF_RANDOM_INT)</a></h3>
5254
5255
5256 <p> This code generates a random signed integer and then computes
5257 the remainder of that value modulo another value. Since the random
5258 number can be negative, the result of the remainder operation
5259 can also be negative. Be sure this is intended, and strongly
5260 consider using the Random.nextInt(int) method instead.
5261 </p>
5262
5263
5264 <h3><a name="RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method ignores return value, is this OK? (RV_RETURN_VALUE_IGNORED_INFERRED)</a></h3>
5265
5266
5267 <p>This code calls a method and ignores the return value. The return value
5268 is the same type as the type the method is invoked on, and from our analysis it looks
5269 like the return value might be important (e.g., like ignoring the
5270 return value of <code>String.toLowerCase()</code>).
5271 </p>
5272 <p>We are guessing that ignoring the return value might be a bad idea just from
5273 a simple analysis of the body of the method. You can use a @CheckReturnValue annotation
5274 to instruct FindBugs as to whether ignoring the return value of this method
5275 is important or acceptable.
5276 </p>
5277 <p>Please investigate this closely to decide whether it is OK to ignore the return value.
5278 </p>
5279
5280
5281 <h3><a name="SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assignment of field (SA_FIELD_DOUBLE_ASSIGNMENT)</a></h3>
5282
5283
5284 <p> This method contains a double assignment of a field; e.g.
5285 </p>
5286 <pre>
5287 int x,y;
5288 public void foo() {
5289 x = x = 17;
5290 }
5291 </pre>
5292 <p>Assigning to a field twice is useless, and may indicate a logic error or typo.</p>
5293
5294
5295 <h3><a name="SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assignment of local variable (SA_LOCAL_DOUBLE_ASSIGNMENT)</a></h3>
5296
5297
5298 <p> This method contains a double assignment of a local variable; e.g.
5299 </p>
5300 <pre>
5301 public void foo() {
5302 int x,y;
5303 x = x = 17;
5304 }
5305 </pre>
5306 <p>Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.</p>
5307
5308
5309 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT">SA: Self assignment of local variable (SA_LOCAL_SELF_ASSIGNMENT)</a></h3>
5310
5311
5312 <p> This method contains a self assignment of a local variable; e.g.</p>
5313 <pre>
5314 public void foo() {
5315 int x = 3;
5316 x = x;
5317 }
5318 </pre>
5319 <p>
5320 Such assignments are useless, and may indicate a logic error or typo.
5321 </p>
5322
5323
5324 <h3><a name="SF_SWITCH_FALLTHROUGH">SF: Switch statement found where one case falls through to the next case (SF_SWITCH_FALLTHROUGH)</a></h3>
5325
5326
5327 <p> This method contains a switch statement where one case branch will fall through to the next case.
5328 Usually you need to end this case with a break or return.</p>
5329
5330
5331 <h3><a name="SF_SWITCH_NO_DEFAULT">SF: Switch statement found where default case is missing (SF_SWITCH_NO_DEFAULT)</a></h3>
5332
5333
5334 <p> This method contains a switch statement where default case is missing.
5335 Usually you need to provide a default case.</p>
5336 <p>Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if
5337 the default case is at the end of the switch statement and doesn't end with a break statement.
5338
5339
5340 <h3><a name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST: Write to static field from instance method (ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD)</a></h3>
5341
5342
5343 <p> This instance method writes to a static field. This is tricky to get
5344 correct if multiple instances are being manipulated,
5345 and generally bad practice.
5346 </p>
5347
5348
5349 <h3><a name="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: Private readResolve method not inherited by subclasses (SE_PRIVATE_READ_RESOLVE_NOT_INHERITED)</a></h3>
5350
5351
5352 <p> This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses.
5353 This might be intentional and OK, but should be reviewed to ensure it is what is intended.
5354 </p>
5355
5356
5357 <h3><a name="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">Se: Transient field of class that isn't Serializable. (SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS)</a></h3>
5358
5359
5360 <p> The field is marked as transient, but the class isn't Serializable, so marking it as transient
5361 has absolutely no effect.
5362 This may be leftover marking from a previous version of the code in which the class was transient, or
5363 it may indicate a misunderstanding of how serialization works.
5364 </p>
5365
5366
5367 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value required to have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK)</a></h3>
5368
5369
5370 <p>
5371 A value is used in a way that requires it to be always be a value denoted by a type qualifier, but
5372 there is an explicit annotation stating that it is not known where the value is required to have that type qualifier.
5373 Either the usage or the annotation is incorrect.
5374 </p>
5375
5376
5377 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value required to not have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK)</a></h3>
5378
5379
5380 <p>
5381 A value is used in a way that requires it to be never be a value denoted by a type qualifier, but
5382 there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier.
5383 Either the usage or the annotation is incorrect.
5384 </p>
5385
5386
5387 <h3><a name="UCF_USELESS_CONTROL_FLOW">UCF: Useless control flow (UCF_USELESS_CONTROL_FLOW)</a></h3>
5388
5389
5390 <p> This method contains a useless control flow statement, where
5391 control flow continues onto the same place regardless of whether or not
5392 the branch is taken. For example,
5393 this is caused by having an empty statement
5394 block for an <code>if</code> statement:</p>
5395 <pre>
5396 if (argv.length == 0) {
5397 // TODO: handle this case
5398 }
5399 </pre>
5400
5401
5402 <h3><a name="UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Useless control flow to next line (UCF_USELESS_CONTROL_FLOW_NEXT_LINE)</a></h3>
5403
5404
5405 <p> This method contains a useless control flow statement in which control
5406 flow follows to the same or following line regardless of whether or not
5407 the branch is taken.
5408 Often, this is caused by inadvertently using an empty statement as the
5409 body of an <code>if</code> statement, e.g.:</p>
5410 <pre>
5411 if (argv.length == 1);
5412 System.out.println("Hello, " + argv[0]);
5413 </pre>
5414
5415
5416 <h3><a name="USM_USELESS_ABSTRACT_METHOD">USM: Abstract Method is already defined in implemented interface (USM_USELESS_ABSTRACT_METHOD)</a></h3>
5417
5418
5419 <p>
5420 This abstract method is already defined in an interface that is implemented by this abstract
5421 class. This method can be removed, as it provides no additional value.
5422 </p>
5423
5424
5425 <h3><a name="USM_USELESS_SUBCLASS_METHOD">USM: Method superfluously delegates to parent class method (USM_USELESS_SUBCLASS_METHOD)</a></h3>
5426
5427
5428 <p>
5429 This derived method merely calls the same superclass method passing in the exact parameters
5430 received. This method can be removed, as it provides no additional value.
5431 </p>
5432
5433
5434 <h3><a name="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: Unread public/protected field (URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5435
5436
5437 <p> This field is never read.&nbsp;
5438 The field is public or protected, so perhaps
5439 it is intended to be used with classes not seen as part of the analysis. If not,
5440 consider removing it from the class.</p>
5441
5442
5443 <h3><a name="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: Unused public or protected field (UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5444
5445
5446 <p> This field is never used.&nbsp;
5447 The field is public or protected, so perhaps
5448 it is intended to be used with classes not seen as part of the analysis. If not,
5449 consider removing it from the class.</p>
5450
5451
5452 <h3><a name="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">UwF: Field not initialized in constructor but dereferenced without null check (UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3>
5453
5454
5455 <p> This field is never initialized within any constructor, and is therefore could be null after
5456 the object is constructed. Elsewhere, it is loaded and dereferenced without a null check.
5457 This could be a either an error or a questionable design, since
5458 it means a null pointer exception will be generated if that field is dereferenced
5459 before being initialized.
5460 </p>
5461
5462
5463 <h3><a name="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF: Unwritten public or protected field (UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5464
5465
5466 <p> No writes were seen to this public/protected field.&nbsp; All reads of it will return the default
5467 value. Check for errors (should it have been initialized?), or remove it if it is useless.</p>
5468
5469
5470 <h3><a name="XFB_XML_FACTORY_BYPASS">XFB: Method directly allocates a specific implementation of xml interfaces (XFB_XML_FACTORY_BYPASS)</a></h3>
5471
5472
5473 <p>
5474 This method allocates a specific implementation of an xml interface. It is preferable to use
5475 the supplied factory classes to create these objects so that the implementation can be
5476 changed at runtime. See
5477 </p>
5478 <ul>
5479 <li>javax.xml.parsers.DocumentBuilderFactory</li>
5480 <li>javax.xml.parsers.SAXParserFactory</li>
5481 <li>javax.xml.transform.TransformerFactory</li>
5482 <li>org.w3c.dom.Document.create<i>XXXX</i></li>
5483 </ul>
5484 <p>for details.</p>
5485
5486
5487
5488
5489 <hr> <p>
5490 <script language="JavaScript" type="text/javascript">
5491 <!---//hide script from old browsers
5492 document.write( "Last updated "+ document.lastModified + "." );
5493 //end hiding contents --->
5494 </script>
5495 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
5496 <p>
5497 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
5498 </td></tr></table>
5499 </body></html>
Binary diff not shown
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1 <html><head><title>FindBugs Bug Descriptions</title>
2 <link rel="stylesheet" type="text/css" href="findbugs.css"/>
3 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
4 </head><body>
5
6 <table width="100%"><tr>
7
8 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
9 <table width="100%" cellspacing="0" border="0">
10 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
11
12 <tr><td>&nbsp;</td></tr>
13
14 <tr><td><b>Docs and Info</b></td></tr>
15 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
16 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
17 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
27
28 <tr><td>&nbsp;</td></tr>
29
30 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
31
32 <tr><td>&nbsp;</td></tr>
33
34 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
35
36 <tr><td>&nbsp;</td></tr>
37
38 <tr><td><b>Development</b></td></tr>
39 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
40 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
41 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
48 </table>
49 </td>
50 <td align="left" valign="top">
51 <h1>FindBugs Bug Descriptions</h1>
52 <p>This document lists the standard bug patterns reported by
53 <a href="http://findbugs.sourceforge.net">FindBugs</a> version 2.0.3.</p>
54 <h2>Summary</h2>
55 <table width="100%">
56 <tr bgcolor="#b9b9fe"><th>Description</th><th>Category</th></tr>
57 <tr bgcolor="#eeeeee"><td><a href="#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS">BC: Equals method should not assume anything about the type of its argument</a></td><td>Bad practice</td></tr>
58 <tr bgcolor="#ffffff"><td><a href="#BIT_SIGNED_CHECK">BIT: Check for sign of bitwise operation</a></td><td>Bad practice</td></tr>
59 <tr bgcolor="#eeeeee"><td><a href="#CN_IDIOM">CN: Class implements Cloneable but does not define or use clone method</a></td><td>Bad practice</td></tr>
60 <tr bgcolor="#ffffff"><td><a href="#CN_IDIOM_NO_SUPER_CALL">CN: clone method does not call super.clone()</a></td><td>Bad practice</td></tr>
61 <tr bgcolor="#eeeeee"><td><a href="#CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: Class defines clone() but doesn't implement Cloneable</a></td><td>Bad practice</td></tr>
62 <tr bgcolor="#ffffff"><td><a href="#CO_ABSTRACT_SELF">Co: Abstract class defines covariant compareTo() method</a></td><td>Bad practice</td></tr>
63 <tr bgcolor="#eeeeee"><td><a href="#CO_SELF_NO_OBJECT">Co: Covariant compareTo() method defined</a></td><td>Bad practice</td></tr>
64 <tr bgcolor="#ffffff"><td><a href="#DE_MIGHT_DROP">DE: Method might drop exception</a></td><td>Bad practice</td></tr>
65 <tr bgcolor="#eeeeee"><td><a href="#DE_MIGHT_IGNORE">DE: Method might ignore exception</a></td><td>Bad practice</td></tr>
66 <tr bgcolor="#ffffff"><td><a href="#DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI: Adding elements of an entry set may fail due to reuse of Entry objects</a></td><td>Bad practice</td></tr>
67 <tr bgcolor="#eeeeee"><td><a href="#DMI_RANDOM_USED_ONLY_ONCE">DMI: Random object created and used only once</a></td><td>Bad practice</td></tr>
68 <tr bgcolor="#ffffff"><td><a href="#DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI: Don't use removeAll to clear a collection</a></td><td>Bad practice</td></tr>
69 <tr bgcolor="#eeeeee"><td><a href="#DM_EXIT">Dm: Method invokes System.exit(...)</a></td><td>Bad practice</td></tr>
70 <tr bgcolor="#ffffff"><td><a href="#DM_RUN_FINALIZERS_ON_EXIT">Dm: Method invokes dangerous method runFinalizersOnExit</a></td><td>Bad practice</td></tr>
71 <tr bgcolor="#eeeeee"><td><a href="#ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: Comparison of String parameter using == or !=</a></td><td>Bad practice</td></tr>
72 <tr bgcolor="#ffffff"><td><a href="#ES_COMPARING_STRINGS_WITH_EQ">ES: Comparison of String objects using == or !=</a></td><td>Bad practice</td></tr>
73 <tr bgcolor="#eeeeee"><td><a href="#EQ_ABSTRACT_SELF">Eq: Abstract class defines covariant equals() method</a></td><td>Bad practice</td></tr>
74 <tr bgcolor="#ffffff"><td><a href="#EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">Eq: Equals checks for incompatible operand</a></td><td>Bad practice</td></tr>
75 <tr bgcolor="#eeeeee"><td><a href="#EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class defines compareTo(...) and uses Object.equals()</a></td><td>Bad practice</td></tr>
76 <tr bgcolor="#ffffff"><td><a href="#EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals method fails for subtypes</a></td><td>Bad practice</td></tr>
77 <tr bgcolor="#eeeeee"><td><a href="#EQ_SELF_NO_OBJECT">Eq: Covariant equals() method defined</a></td><td>Bad practice</td></tr>
78 <tr bgcolor="#ffffff"><td><a href="#FI_EMPTY">FI: Empty finalizer should be deleted</a></td><td>Bad practice</td></tr>
79 <tr bgcolor="#eeeeee"><td><a href="#FI_EXPLICIT_INVOCATION">FI: Explicit invocation of finalizer</a></td><td>Bad practice</td></tr>
80 <tr bgcolor="#ffffff"><td><a href="#FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nulls fields</a></td><td>Bad practice</td></tr>
81 <tr bgcolor="#eeeeee"><td><a href="#FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalizer only nulls fields</a></td><td>Bad practice</td></tr>
82 <tr bgcolor="#ffffff"><td><a href="#FI_MISSING_SUPER_CALL">FI: Finalizer does not call superclass finalizer</a></td><td>Bad practice</td></tr>
83 <tr bgcolor="#eeeeee"><td><a href="#FI_NULLIFY_SUPER">FI: Finalizer nullifies superclass finalizer</a></td><td>Bad practice</td></tr>
84 <tr bgcolor="#ffffff"><td><a href="#FI_USELESS">FI: Finalizer does nothing but call superclass finalizer</a></td><td>Bad practice</td></tr>
85 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_USES_NEWLINE">FS: Format string should use %n rather than \n</a></td><td>Bad practice</td></tr>
86 <tr bgcolor="#ffffff"><td><a href="#GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unchecked type in generic call</a></td><td>Bad practice</td></tr>
87 <tr bgcolor="#eeeeee"><td><a href="#HE_EQUALS_NO_HASHCODE">HE: Class defines equals() but not hashCode()</a></td><td>Bad practice</td></tr>
88 <tr bgcolor="#ffffff"><td><a href="#HE_EQUALS_USE_HASHCODE">HE: Class defines equals() and uses Object.hashCode()</a></td><td>Bad practice</td></tr>
89 <tr bgcolor="#eeeeee"><td><a href="#HE_HASHCODE_NO_EQUALS">HE: Class defines hashCode() but not equals()</a></td><td>Bad practice</td></tr>
90 <tr bgcolor="#ffffff"><td><a href="#HE_HASHCODE_USE_OBJECT_EQUALS">HE: Class defines hashCode() and uses Object.equals()</a></td><td>Bad practice</td></tr>
91 <tr bgcolor="#eeeeee"><td><a href="#HE_INHERITS_EQUALS_USE_HASHCODE">HE: Class inherits equals() and uses Object.hashCode()</a></td><td>Bad practice</td></tr>
92 <tr bgcolor="#ffffff"><td><a href="#IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION">IC: Superclass uses subclass during initialization</a></td><td>Bad practice</td></tr>
93 <tr bgcolor="#eeeeee"><td><a href="#IMSE_DONT_CATCH_IMSE">IMSE: Dubious catching of IllegalMonitorStateException</a></td><td>Bad practice</td></tr>
94 <tr bgcolor="#ffffff"><td><a href="#ISC_INSTANTIATE_STATIC_CLASS">ISC: Needless instantiation of class that only supplies static methods</a></td><td>Bad practice</td></tr>
95 <tr bgcolor="#eeeeee"><td><a href="#IT_NO_SUCH_ELEMENT">It: Iterator next() method can't throw NoSuchElementException</a></td><td>Bad practice</td></tr>
96 <tr bgcolor="#ffffff"><td><a href="#J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION">J2EE: Store of non serializable object into HttpSession</a></td><td>Bad practice</td></tr>
97 <tr bgcolor="#eeeeee"><td><a href="#JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP: Fields of immutable classes should be final</a></td><td>Bad practice</td></tr>
98 <tr bgcolor="#ffffff"><td><a href="#NP_BOOLEAN_RETURN_NULL">NP: Method with Boolean return type returns explicit null</a></td><td>Bad practice</td></tr>
99 <tr bgcolor="#eeeeee"><td><a href="#NP_CLONE_COULD_RETURN_NULL">NP: Clone method may return null</a></td><td>Bad practice</td></tr>
100 <tr bgcolor="#ffffff"><td><a href="#NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: equals() method does not check for null argument</a></td><td>Bad practice</td></tr>
101 <tr bgcolor="#eeeeee"><td><a href="#NP_TOSTRING_COULD_RETURN_NULL">NP: toString method may return null</a></td><td>Bad practice</td></tr>
102 <tr bgcolor="#ffffff"><td><a href="#NM_CLASS_NAMING_CONVENTION">Nm: Class names should start with an upper case letter</a></td><td>Bad practice</td></tr>
103 <tr bgcolor="#eeeeee"><td><a href="#NM_CLASS_NOT_EXCEPTION">Nm: Class is not derived from an Exception, even though it is named as such</a></td><td>Bad practice</td></tr>
104 <tr bgcolor="#ffffff"><td><a href="#NM_CONFUSING">Nm: Confusing method names</a></td><td>Bad practice</td></tr>
105 <tr bgcolor="#eeeeee"><td><a href="#NM_FIELD_NAMING_CONVENTION">Nm: Field names should start with a lower case letter</a></td><td>Bad practice</td></tr>
106 <tr bgcolor="#ffffff"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java</a></td><td>Bad practice</td></tr>
107 <tr bgcolor="#eeeeee"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java</a></td><td>Bad practice</td></tr>
108 <tr bgcolor="#ffffff"><td><a href="#NM_METHOD_NAMING_CONVENTION">Nm: Method names should start with a lower case letter</a></td><td>Bad practice</td></tr>
109 <tr bgcolor="#eeeeee"><td><a href="#NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class names shouldn't shadow simple name of implemented interface</a></td><td>Bad practice</td></tr>
110 <tr bgcolor="#ffffff"><td><a href="#NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class names shouldn't shadow simple name of superclass</a></td><td>Bad practice</td></tr>
111 <tr bgcolor="#eeeeee"><td><a href="#NM_VERY_CONFUSING_INTENTIONAL">Nm: Very confusing method names (but perhaps intentional)</a></td><td>Bad practice</td></tr>
112 <tr bgcolor="#ffffff"><td><a href="#NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doesn't override method in superclass due to wrong package for parameter</a></td><td>Bad practice</td></tr>
113 <tr bgcolor="#eeeeee"><td><a href="#ODR_OPEN_DATABASE_RESOURCE">ODR: Method may fail to close database resource</a></td><td>Bad practice</td></tr>
114 <tr bgcolor="#ffffff"><td><a href="#ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">ODR: Method may fail to close database resource on exception</a></td><td>Bad practice</td></tr>
115 <tr bgcolor="#eeeeee"><td><a href="#OS_OPEN_STREAM">OS: Method may fail to close stream</a></td><td>Bad practice</td></tr>
116 <tr bgcolor="#ffffff"><td><a href="#OS_OPEN_STREAM_EXCEPTION_PATH">OS: Method may fail to close stream on exception</a></td><td>Bad practice</td></tr>
117 <tr bgcolor="#eeeeee"><td><a href="#PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ: Don't reuse entry objects in iterators</a></td><td>Bad practice</td></tr>
118 <tr bgcolor="#ffffff"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicious reference comparison to constant</a></td><td>Bad practice</td></tr>
119 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC: Suspicious reference comparison of Boolean values</a></td><td>Bad practice</td></tr>
120 <tr bgcolor="#ffffff"><td><a href="#RR_NOT_CHECKED">RR: Method ignores results of InputStream.read()</a></td><td>Bad practice</td></tr>
121 <tr bgcolor="#eeeeee"><td><a href="#SR_NOT_CHECKED">RR: Method ignores results of InputStream.skip()</a></td><td>Bad practice</td></tr>
122 <tr bgcolor="#ffffff"><td><a href="#RV_NEGATING_RESULT_OF_COMPARETO">RV: Negating the result of compareTo()/compare()</a></td><td>Bad practice</td></tr>
123 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Method ignores exceptional return value</a></td><td>Bad practice</td></tr>
124 <tr bgcolor="#ffffff"><td><a href="#SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Static initializer creates instance before all static final fields assigned</a></td><td>Bad practice</td></tr>
125 <tr bgcolor="#eeeeee"><td><a href="#SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW: Certain swing methods needs to be invoked in Swing thread</a></td><td>Bad practice</td></tr>
126 <tr bgcolor="#ffffff"><td><a href="#SE_BAD_FIELD">Se: Non-transient non-serializable instance field in serializable class</a></td><td>Bad practice</td></tr>
127 <tr bgcolor="#eeeeee"><td><a href="#SE_BAD_FIELD_INNER_CLASS">Se: Non-serializable class has a serializable inner class</a></td><td>Bad practice</td></tr>
128 <tr bgcolor="#ffffff"><td><a href="#SE_BAD_FIELD_STORE">Se: Non-serializable value stored into instance field of a serializable class</a></td><td>Bad practice</td></tr>
129 <tr bgcolor="#eeeeee"><td><a href="#SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Comparator doesn't implement Serializable</a></td><td>Bad practice</td></tr>
130 <tr bgcolor="#ffffff"><td><a href="#SE_INNER_CLASS">Se: Serializable inner class</a></td><td>Bad practice</td></tr>
131 <tr bgcolor="#eeeeee"><td><a href="#SE_NONFINAL_SERIALVERSIONID">Se: serialVersionUID isn't final</a></td><td>Bad practice</td></tr>
132 <tr bgcolor="#ffffff"><td><a href="#SE_NONLONG_SERIALVERSIONID">Se: serialVersionUID isn't long</a></td><td>Bad practice</td></tr>
133 <tr bgcolor="#eeeeee"><td><a href="#SE_NONSTATIC_SERIALVERSIONID">Se: serialVersionUID isn't static</a></td><td>Bad practice</td></tr>
134 <tr bgcolor="#ffffff"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR">Se: Class is Serializable but its superclass doesn't define a void constructor</a></td><td>Bad practice</td></tr>
135 <tr bgcolor="#eeeeee"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">Se: Class is Externalizable but doesn't define a void constructor</a></td><td>Bad practice</td></tr>
136 <tr bgcolor="#ffffff"><td><a href="#SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: The readResolve method must be declared with a return type of Object. </a></td><td>Bad practice</td></tr>
137 <tr bgcolor="#eeeeee"><td><a href="#SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Transient field that isn't set by deserialization. </a></td><td>Bad practice</td></tr>
138 <tr bgcolor="#ffffff"><td><a href="#SE_NO_SERIALVERSIONID">SnVI: Class is Serializable, but doesn't define serialVersionUID</a></td><td>Bad practice</td></tr>
139 <tr bgcolor="#eeeeee"><td><a href="#UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: Usage of GetResource may be unsafe if class is extended</a></td><td>Bad practice</td></tr>
140 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_CAST">BC: Impossible cast</a></td><td>Correctness</td></tr>
141 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downcast</a></td><td>Correctness</td></tr>
142 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impossible downcast of toArray() result</a></td><td>Correctness</td></tr>
143 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof will always return false</a></td><td>Correctness</td></tr>
144 <tr bgcolor="#ffffff"><td><a href="#BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of signed byte value</a></td><td>Correctness</td></tr>
145 <tr bgcolor="#eeeeee"><td><a href="#BIT_AND">BIT: Incompatible bit masks</a></td><td>Correctness</td></tr>
146 <tr bgcolor="#ffffff"><td><a href="#BIT_AND_ZZ">BIT: Check to see if ((...) & 0) == 0</a></td><td>Correctness</td></tr>
147 <tr bgcolor="#eeeeee"><td><a href="#BIT_IOR">BIT: Incompatible bit masks</a></td><td>Correctness</td></tr>
148 <tr bgcolor="#ffffff"><td><a href="#BIT_IOR_OF_SIGNED_BYTE">BIT: Bitwise OR of signed byte value</a></td><td>Correctness</td></tr>
149 <tr bgcolor="#eeeeee"><td><a href="#BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for sign of bitwise operation</a></td><td>Correctness</td></tr>
150 <tr bgcolor="#ffffff"><td><a href="#BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: Class overrides a method implemented in super class Adapter wrongly</a></td><td>Correctness</td></tr>
151 <tr bgcolor="#eeeeee"><td><a href="#ICAST_BAD_SHIFT_AMOUNT">BSHIFT: 32 bit int shifted by an amount not in the range -31..31</a></td><td>Correctness</td></tr>
152 <tr bgcolor="#ffffff"><td><a href="#BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR">Bx: Primitive value is unboxed and coerced for ternary operator</a></td><td>Correctness</td></tr>
153 <tr bgcolor="#eeeeee"><td><a href="#CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareTo()/compare() returns Integer.MIN_VALUE</a></td><td>Correctness</td></tr>
154 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Useless increment in return statement</a></td><td>Correctness</td></tr>
155 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead store of class literal</a></td><td>Correctness</td></tr>
156 <tr bgcolor="#ffffff"><td><a href="#DLS_OVERWRITTEN_INCREMENT">DLS: Overwritten increment</a></td><td>Correctness</td></tr>
157 <tr bgcolor="#eeeeee"><td><a href="#DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed method arguments</a></td><td>Correctness</td></tr>
158 <tr bgcolor="#ffffff"><td><a href="#DMI_BAD_MONTH">DMI: Bad constant value for month</a></td><td>Correctness</td></tr>
159 <tr bgcolor="#eeeeee"><td><a href="#DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI: BigDecimal constructed from double that isn't represented precisely</a></td><td>Correctness</td></tr>
160 <tr bgcolor="#ffffff"><td><a href="#DMI_CALLING_NEXT_FROM_HASNEXT">DMI: hasNext method invokes next</a></td><td>Correctness</td></tr>
161 <tr bgcolor="#eeeeee"><td><a href="#DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES">DMI: Collections should not contain themselves</a></td><td>Correctness</td></tr>
162 <tr bgcolor="#ffffff"><td><a href="#DMI_DOH">DMI: D'oh! A nonsensical method invocation</a></td><td>Correctness</td></tr>
163 <tr bgcolor="#eeeeee"><td><a href="#DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocation of hashCode on an array</a></td><td>Correctness</td></tr>
164 <tr bgcolor="#ffffff"><td><a href="#DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI: Double.longBitsToDouble invoked on an int</a></td><td>Correctness</td></tr>
165 <tr bgcolor="#eeeeee"><td><a href="#DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuous call to collections</a></td><td>Correctness</td></tr>
166 <tr bgcolor="#ffffff"><td><a href="#DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">Dm: Can't use reflection to check for presence of annotation without runtime retention</a></td><td>Correctness</td></tr>
167 <tr bgcolor="#eeeeee"><td><a href="#DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR">Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor</a></td><td>Correctness</td></tr>
168 <tr bgcolor="#ffffff"><td><a href="#DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS">Dm: Creation of ScheduledThreadPoolExecutor with zero core threads</a></td><td>Correctness</td></tr>
169 <tr bgcolor="#eeeeee"><td><a href="#DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Useless/vacuous call to EasyMock method</a></td><td>Correctness</td></tr>
170 <tr bgcolor="#ffffff"><td><a href="#EC_ARRAY_AND_NONARRAY">EC: equals() used to compare array and nonarray</a></td><td>Correctness</td></tr>
171 <tr bgcolor="#eeeeee"><td><a href="#EC_BAD_ARRAY_COMPARE">EC: Invocation of equals() on an array, which is equivalent to ==</a></td><td>Correctness</td></tr>
172 <tr bgcolor="#ffffff"><td><a href="#EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(...) used to compare incompatible arrays</a></td><td>Correctness</td></tr>
173 <tr bgcolor="#eeeeee"><td><a href="#EC_NULL_ARG">EC: Call to equals(null)</a></td><td>Correctness</td></tr>
174 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_CLASS_AND_INTERFACE">EC: Call to equals() comparing unrelated class and interface</a></td><td>Correctness</td></tr>
175 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_INTERFACES">EC: Call to equals() comparing different interface types</a></td><td>Correctness</td></tr>
176 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_TYPES">EC: Call to equals() comparing different types</a></td><td>Correctness</td></tr>
177 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">EC: Using pointer equality to compare different types</a></td><td>Correctness</td></tr>
178 <tr bgcolor="#ffffff"><td><a href="#EQ_ALWAYS_FALSE">Eq: equals method always returns false</a></td><td>Correctness</td></tr>
179 <tr bgcolor="#eeeeee"><td><a href="#EQ_ALWAYS_TRUE">Eq: equals method always returns true</a></td><td>Correctness</td></tr>
180 <tr bgcolor="#ffffff"><td><a href="#EQ_COMPARING_CLASS_NAMES">Eq: equals method compares class names rather than class objects</a></td><td>Correctness</td></tr>
181 <tr bgcolor="#eeeeee"><td><a href="#EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covariant equals() method defined for enum</a></td><td>Correctness</td></tr>
182 <tr bgcolor="#ffffff"><td><a href="#EQ_OTHER_NO_OBJECT">Eq: equals() method defined that doesn't override equals(Object)</a></td><td>Correctness</td></tr>
183 <tr bgcolor="#eeeeee"><td><a href="#EQ_OTHER_USE_OBJECT">Eq: equals() method defined that doesn't override Object.equals(Object)</a></td><td>Correctness</td></tr>
184 <tr bgcolor="#ffffff"><td><a href="#EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equals method overrides equals in superclass and may not be symmetric</a></td><td>Correctness</td></tr>
185 <tr bgcolor="#eeeeee"><td><a href="#EQ_SELF_USE_OBJECT">Eq: Covariant equals() method defined, Object.equals(Object) inherited</a></td><td>Correctness</td></tr>
186 <tr bgcolor="#ffffff"><td><a href="#FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Doomed test for equality to NaN</a></td><td>Correctness</td></tr>
187 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format string placeholder incompatible with passed argument</a></td><td>Correctness</td></tr>
188 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION">FS: The type of a supplied argument doesn't match format specifier</a></td><td>Correctness</td></tr>
189 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED">FS: MessageFormat supplied where printf style format expected</a></td><td>Correctness</td></tr>
190 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS: More arguments are passed than are actually used in the format string</a></td><td>Correctness</td></tr>
191 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_ILLEGAL">FS: Illegal format string</a></td><td>Correctness</td></tr>
192 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Format string references missing argument</a></td><td>Correctness</td></tr>
193 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: No previous argument for format string</a></td><td>Correctness</td></tr>
194 <tr bgcolor="#ffffff"><td><a href="#GC_UNRELATED_TYPES">GC: No relationship between generic parameter and method argument</a></td><td>Correctness</td></tr>
195 <tr bgcolor="#eeeeee"><td><a href="#HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS">HE: Signature declares use of unhashable class in hashed construct</a></td><td>Correctness</td></tr>
196 <tr bgcolor="#ffffff"><td><a href="#HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class without a hashCode() method in a hashed data structure</a></td><td>Correctness</td></tr>
197 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INT_2_LONG_AS_INSTANT">ICAST: int value converted to long and used as absolute time</a></td><td>Correctness</td></tr>
198 <tr bgcolor="#ffffff"><td><a href="#ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICAST: Integral value cast to double and then passed to Math.ceil</a></td><td>Correctness</td></tr>
199 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICAST: int value cast to float and then passed to Math.round</a></td><td>Correctness</td></tr>
200 <tr bgcolor="#ffffff"><td><a href="#IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">IJU: JUnit assertion in run method will not be noticed by JUnit</a></td><td>Correctness</td></tr>
201 <tr bgcolor="#eeeeee"><td><a href="#IJU_BAD_SUITE_METHOD">IJU: TestCase declares a bad suite method </a></td><td>Correctness</td></tr>
202 <tr bgcolor="#ffffff"><td><a href="#IJU_NO_TESTS">IJU: TestCase has no tests</a></td><td>Correctness</td></tr>
203 <tr bgcolor="#eeeeee"><td><a href="#IJU_SETUP_NO_SUPER">IJU: TestCase defines setUp that doesn't call super.setUp()</a></td><td>Correctness</td></tr>
204 <tr bgcolor="#ffffff"><td><a href="#IJU_SUITE_NOT_STATIC">IJU: TestCase implements a non-static suite method </a></td><td>Correctness</td></tr>
205 <tr bgcolor="#eeeeee"><td><a href="#IJU_TEARDOWN_NO_SUPER">IJU: TestCase defines tearDown that doesn't call super.tearDown()</a></td><td>Correctness</td></tr>
206 <tr bgcolor="#ffffff"><td><a href="#IL_CONTAINER_ADDED_TO_ITSELF">IL: A collection is added to itself</a></td><td>Correctness</td></tr>
207 <tr bgcolor="#eeeeee"><td><a href="#IL_INFINITE_LOOP">IL: An apparent infinite loop</a></td><td>Correctness</td></tr>
208 <tr bgcolor="#ffffff"><td><a href="#IL_INFINITE_RECURSIVE_LOOP">IL: An apparent infinite recursive loop</a></td><td>Correctness</td></tr>
209 <tr bgcolor="#eeeeee"><td><a href="#IM_MULTIPLYING_RESULT_OF_IREM">IM: Integer multiply of result of integer remainder</a></td><td>Correctness</td></tr>
210 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad comparison of int value with long constant</a></td><td>Correctness</td></tr>
211 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT: Bad comparison of nonnegative value with negative constant</a></td><td>Correctness</td></tr>
212 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Bad comparison of signed byte</a></td><td>Correctness</td></tr>
213 <tr bgcolor="#eeeeee"><td><a href="#IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Doomed attempt to append to an object output stream</a></td><td>Correctness</td></tr>
214 <tr bgcolor="#ffffff"><td><a href="#IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: A parameter is dead upon entry to a method but overwritten</a></td><td>Correctness</td></tr>
215 <tr bgcolor="#eeeeee"><td><a href="#MF_CLASS_MASKS_FIELD">MF: Class defines field that masks a superclass field</a></td><td>Correctness</td></tr>
216 <tr bgcolor="#ffffff"><td><a href="#MF_METHOD_MASKS_FIELD">MF: Method defines a variable that obscures a field</a></td><td>Correctness</td></tr>
217 <tr bgcolor="#eeeeee"><td><a href="#NP_ALWAYS_NULL">NP: Null pointer dereference</a></td><td>Correctness</td></tr>
218 <tr bgcolor="#ffffff"><td><a href="#NP_ALWAYS_NULL_EXCEPTION">NP: Null pointer dereference in method on exception path</a></td><td>Correctness</td></tr>
219 <tr bgcolor="#eeeeee"><td><a href="#NP_ARGUMENT_MIGHT_BE_NULL">NP: Method does not check for null argument</a></td><td>Correctness</td></tr>
220 <tr bgcolor="#ffffff"><td><a href="#NP_CLOSING_NULL">NP: close() invoked on a value that is always null</a></td><td>Correctness</td></tr>
221 <tr bgcolor="#eeeeee"><td><a href="#NP_GUARANTEED_DEREF">NP: Null value is guaranteed to be dereferenced</a></td><td>Correctness</td></tr>
222 <tr bgcolor="#ffffff"><td><a href="#NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: Value is null and guaranteed to be dereferenced on exception path</a></td><td>Correctness</td></tr>
223 <tr bgcolor="#eeeeee"><td><a href="#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP: Nonnull field is not initialized</a></td><td>Correctness</td></tr>
224 <tr bgcolor="#ffffff"><td><a href="#NP_NONNULL_PARAM_VIOLATION">NP: Method call passes null to a nonnull parameter </a></td><td>Correctness</td></tr>
225 <tr bgcolor="#eeeeee"><td><a href="#NP_NONNULL_RETURN_VIOLATION">NP: Method may return null, but is declared @NonNull</a></td><td>Correctness</td></tr>
226 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_INSTANCEOF">NP: A known null value is checked to see if it is an instance of a type</a></td><td>Correctness</td></tr>
227 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH">NP: Possible null pointer dereference</a></td><td>Correctness</td></tr>
228 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible null pointer dereference in method on exception path</a></td><td>Correctness</td></tr>
229 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_PARAM_DEREF">NP: Method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
230 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP: Method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
231 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Non-virtual method call passes null for nonnull parameter</a></td><td>Correctness</td></tr>
232 <tr bgcolor="#ffffff"><td><a href="#NP_STORE_INTO_NONNULL_FIELD">NP: Store of null value into field annotated NonNull</a></td><td>Correctness</td></tr>
233 <tr bgcolor="#eeeeee"><td><a href="#NP_UNWRITTEN_FIELD">NP: Read of unwritten field</a></td><td>Correctness</td></tr>
234 <tr bgcolor="#ffffff"><td><a href="#NM_BAD_EQUAL">Nm: Class defines equal(Object); should it be equals(Object)?</a></td><td>Correctness</td></tr>
235 <tr bgcolor="#eeeeee"><td><a href="#NM_LCASE_HASHCODE">Nm: Class defines hashcode(); should it be hashCode()?</a></td><td>Correctness</td></tr>
236 <tr bgcolor="#ffffff"><td><a href="#NM_LCASE_TOSTRING">Nm: Class defines tostring(); should it be toString()?</a></td><td>Correctness</td></tr>
237 <tr bgcolor="#eeeeee"><td><a href="#NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Apparent method/constructor confusion</a></td><td>Correctness</td></tr>
238 <tr bgcolor="#ffffff"><td><a href="#NM_VERY_CONFUSING">Nm: Very confusing method names</a></td><td>Correctness</td></tr>
239 <tr bgcolor="#eeeeee"><td><a href="#NM_WRONG_PACKAGE">Nm: Method doesn't override method in superclass due to wrong package for parameter</a></td><td>Correctness</td></tr>
240 <tr bgcolor="#ffffff"><td><a href="#QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Method assigns boolean literal in boolean expression</a></td><td>Correctness</td></tr>
241 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON">RC: Suspicious reference comparison</a></td><td>Correctness</td></tr>
242 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE">RCN: Nullcheck of value previously dereferenced</a></td><td>Correctness</td></tr>
243 <tr bgcolor="#eeeeee"><td><a href="#RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Invalid syntax for regular expression</a></td><td>Correctness</td></tr>
244 <tr bgcolor="#ffffff"><td><a href="#RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION">RE: File.separator used for regular expression</a></td><td>Correctness</td></tr>
245 <tr bgcolor="#eeeeee"><td><a href="#RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." or "|" used for regular expression</a></td><td>Correctness</td></tr>
246 <tr bgcolor="#ffffff"><td><a href="#RV_01_TO_INT">RV: Random value from 0 to 1 is coerced to the integer 0</a></td><td>Correctness</td></tr>
247 <tr bgcolor="#eeeeee"><td><a href="#RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attempt to compute absolute value of signed 32-bit hashcode </a></td><td>Correctness</td></tr>
248 <tr bgcolor="#ffffff"><td><a href="#RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad attempt to compute absolute value of signed random integer</a></td><td>Correctness</td></tr>
249 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV: Code checks for specific values returned by compareTo</a></td><td>Correctness</td></tr>
250 <tr bgcolor="#ffffff"><td><a href="#RV_EXCEPTION_NOT_THROWN">RV: Exception created and dropped rather than thrown</a></td><td>Correctness</td></tr>
251 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED">RV: Method ignores return value</a></td><td>Correctness</td></tr>
252 <tr bgcolor="#ffffff"><td><a href="#RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated conditional tests</a></td><td>Correctness</td></tr>
253 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_ASSIGNMENT">SA: Self assignment of field</a></td><td>Correctness</td></tr>
254 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_SELF_COMPARISON">SA: Self comparison of field with itself</a></td><td>Correctness</td></tr>
255 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_COMPUTATION">SA: Nonsensical self computation involving a field (e.g., x & x)</a></td><td>Correctness</td></tr>
256 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA: Self assignment of local rather than assignment to field</a></td><td>Correctness</td></tr>
257 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_SELF_COMPARISON">SA: Self comparison of value with itself</a></td><td>Correctness</td></tr>
258 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical self computation involving a variable (e.g., x & x)</a></td><td>Correctness</td></tr>
259 <tr bgcolor="#eeeeee"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF: Dead store due to switch statement fall through</a></td><td>Correctness</td></tr>
260 <tr bgcolor="#ffffff"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW">SF: Dead store due to switch statement fall through to throw</a></td><td>Correctness</td></tr>
261 <tr bgcolor="#eeeeee"><td><a href="#SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly embrace of non-static inner class and thread local</a></td><td>Correctness</td></tr>
262 <tr bgcolor="#ffffff"><td><a href="#SIO_SUPERFLUOUS_INSTANCEOF">SIO: Unnecessary type check done using instanceof operator</a></td><td>Correctness</td></tr>
263 <tr bgcolor="#eeeeee"><td><a href="#SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Method attempts to access a prepared statement parameter with index 0</a></td><td>Correctness</td></tr>
264 <tr bgcolor="#ffffff"><td><a href="#SQL_BAD_RESULTSET_ACCESS">SQL: Method attempts to access a result set field with index 0</a></td><td>Correctness</td></tr>
265 <tr bgcolor="#eeeeee"><td><a href="#STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Unneeded use of currentThread() call, to call interrupted() </a></td><td>Correctness</td></tr>
266 <tr bgcolor="#ffffff"><td><a href="#STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Static Thread.interrupted() method invoked on thread instance</a></td><td>Correctness</td></tr>
267 <tr bgcolor="#eeeeee"><td><a href="#SE_METHOD_MUST_BE_PRIVATE">Se: Method must be private in order for serialization to work</a></td><td>Correctness</td></tr>
268 <tr bgcolor="#ffffff"><td><a href="#SE_READ_RESOLVE_IS_STATIC">Se: The readResolve method must not be declared as a static method. </a></td><td>Correctness</td></tr>
269 <tr bgcolor="#eeeeee"><td><a href="#TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required</a></td><td>Correctness</td></tr>
270 <tr bgcolor="#ffffff"><td><a href="#TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ: Comparing values with incompatible type qualifiers</a></td><td>Correctness</td></tr>
271 <tr bgcolor="#eeeeee"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier</a></td><td>Correctness</td></tr>
272 <tr bgcolor="#ffffff"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier</a></td><td>Correctness</td></tr>
273 <tr bgcolor="#eeeeee"><td><a href="#TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required</a></td><td>Correctness</td></tr>
274 <tr bgcolor="#ffffff"><td><a href="#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ: Value without a type qualifier used where a value is required to have that qualifier</a></td><td>Correctness</td></tr>
275 <tr bgcolor="#eeeeee"><td><a href="#UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">UMAC: Uncallable method defined in anonymous class</a></td><td>Correctness</td></tr>
276 <tr bgcolor="#ffffff"><td><a href="#UR_UNINIT_READ">UR: Uninitialized read of field in constructor</a></td><td>Correctness</td></tr>
277 <tr bgcolor="#eeeeee"><td><a href="#UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR">UR: Uninitialized read of field method called from constructor of superclass</a></td><td>Correctness</td></tr>
278 <tr bgcolor="#ffffff"><td><a href="#DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">USELESS_STRING: Invocation of toString on an unnamed array</a></td><td>Correctness</td></tr>
279 <tr bgcolor="#eeeeee"><td><a href="#DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRING: Invocation of toString on an array</a></td><td>Correctness</td></tr>
280 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">USELESS_STRING: Array formatted in useless way using format string</a></td><td>Correctness</td></tr>
281 <tr bgcolor="#eeeeee"><td><a href="#UWF_NULL_FIELD">UwF: Field only ever set to null</a></td><td>Correctness</td></tr>
282 <tr bgcolor="#ffffff"><td><a href="#UWF_UNWRITTEN_FIELD">UwF: Unwritten field</a></td><td>Correctness</td></tr>
283 <tr bgcolor="#eeeeee"><td><a href="#VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">VA: Primitive array passed to function expecting a variable number of object arguments</a></td><td>Correctness</td></tr>
284 <tr bgcolor="#ffffff"><td><a href="#LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Potential lost logger changes due to weak reference in OpenJDK</a></td><td>Experimental</td></tr>
285 <tr bgcolor="#eeeeee"><td><a href="#OBL_UNSATISFIED_OBLIGATION">OBL: Method may fail to clean up stream or resource</a></td><td>Experimental</td></tr>
286 <tr bgcolor="#ffffff"><td><a href="#OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL: Method may fail to clean up stream or resource on checked exception</a></td><td>Experimental</td></tr>
287 <tr bgcolor="#eeeeee"><td><a href="#DM_CONVERT_CASE">Dm: Consider using Locale parameterized version of invoked method</a></td><td>Internationalization</td></tr>
288 <tr bgcolor="#ffffff"><td><a href="#DM_DEFAULT_ENCODING">Dm: Reliance on default encoding</a></td><td>Internationalization</td></tr>
289 <tr bgcolor="#eeeeee"><td><a href="#DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">DP: Classloaders should only be created inside doPrivileged block</a></td><td>Malicious code vulnerability</td></tr>
290 <tr bgcolor="#ffffff"><td><a href="#DP_DO_INSIDE_DO_PRIVILEGED">DP: Method invoked that should be only be invoked inside a doPrivileged block</a></td><td>Malicious code vulnerability</td></tr>
291 <tr bgcolor="#eeeeee"><td><a href="#EI_EXPOSE_REP">EI: May expose internal representation by returning reference to mutable object</a></td><td>Malicious code vulnerability</td></tr>
292 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_REP2">EI2: May expose internal representation by incorporating reference to mutable object</a></td><td>Malicious code vulnerability</td></tr>
293 <tr bgcolor="#eeeeee"><td><a href="#FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Finalizer should be protected, not public</a></td><td>Malicious code vulnerability</td></tr>
294 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_STATIC_REP2">MS: May expose internal static state by storing a mutable object into a static field</a></td><td>Malicious code vulnerability</td></tr>
295 <tr bgcolor="#eeeeee"><td><a href="#MS_CANNOT_BE_FINAL">MS: Field isn't final and can't be protected from malicious code</a></td><td>Malicious code vulnerability</td></tr>
296 <tr bgcolor="#ffffff"><td><a href="#MS_EXPOSE_REP">MS: Public static method may expose internal representation by returning array</a></td><td>Malicious code vulnerability</td></tr>
297 <tr bgcolor="#eeeeee"><td><a href="#MS_FINAL_PKGPROTECT">MS: Field should be both final and package protected</a></td><td>Malicious code vulnerability</td></tr>
298 <tr bgcolor="#ffffff"><td><a href="#MS_MUTABLE_ARRAY">MS: Field is a mutable array</a></td><td>Malicious code vulnerability</td></tr>
299 <tr bgcolor="#eeeeee"><td><a href="#MS_MUTABLE_HASHTABLE">MS: Field is a mutable Hashtable</a></td><td>Malicious code vulnerability</td></tr>
300 <tr bgcolor="#ffffff"><td><a href="#MS_OOI_PKGPROTECT">MS: Field should be moved out of an interface and made package protected</a></td><td>Malicious code vulnerability</td></tr>
301 <tr bgcolor="#eeeeee"><td><a href="#MS_PKGPROTECT">MS: Field should be package protected</a></td><td>Malicious code vulnerability</td></tr>
302 <tr bgcolor="#ffffff"><td><a href="#MS_SHOULD_BE_FINAL">MS: Field isn't final but should be</a></td><td>Malicious code vulnerability</td></tr>
303 <tr bgcolor="#eeeeee"><td><a href="#MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Field isn't final but should be refactored to be so</a></td><td>Malicious code vulnerability</td></tr>
304 <tr bgcolor="#ffffff"><td><a href="#AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT: Sequence of calls to concurrent abstraction may not be atomic</a></td><td>Multithreaded correctness</td></tr>
305 <tr bgcolor="#eeeeee"><td><a href="#DC_DOUBLECHECK">DC: Possible double check of field</a></td><td>Multithreaded correctness</td></tr>
306 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchronization on Boolean</a></td><td>Multithreaded correctness</td></tr>
307 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive</a></td><td>Multithreaded correctness</td></tr>
308 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: Synchronization on interned String </a></td><td>Multithreaded correctness</td></tr>
309 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive values</a></td><td>Multithreaded correctness</td></tr>
310 <tr bgcolor="#ffffff"><td><a href="#DM_MONITOR_WAIT_ON_CONDITION">Dm: Monitor wait() called on Condition</a></td><td>Multithreaded correctness</td></tr>
311 <tr bgcolor="#eeeeee"><td><a href="#DM_USELESS_THREAD">Dm: A thread was created using the default empty run method</a></td><td>Multithreaded correctness</td></tr>
312 <tr bgcolor="#ffffff"><td><a href="#ESync_EMPTY_SYNC">ESync: Empty synchronized block</a></td><td>Multithreaded correctness</td></tr>
313 <tr bgcolor="#eeeeee"><td><a href="#IS2_INCONSISTENT_SYNC">IS: Inconsistent synchronization</a></td><td>Multithreaded correctness</td></tr>
314 <tr bgcolor="#ffffff"><td><a href="#IS_FIELD_NOT_GUARDED">IS: Field not guarded against concurrent access</a></td><td>Multithreaded correctness</td></tr>
315 <tr bgcolor="#eeeeee"><td><a href="#JLM_JSR166_LOCK_MONITORENTER">JLM: Synchronization performed on Lock</a></td><td>Multithreaded correctness</td></tr>
316 <tr bgcolor="#ffffff"><td><a href="#JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM: Synchronization performed on util.concurrent instance</a></td><td>Multithreaded correctness</td></tr>
317 <tr bgcolor="#eeeeee"><td><a href="#JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JLM: Using monitor style wait methods on util.concurrent abstraction</a></td><td>Multithreaded correctness</td></tr>
318 <tr bgcolor="#ffffff"><td><a href="#LI_LAZY_INIT_STATIC">LI: Incorrect lazy initialization of static field</a></td><td>Multithreaded correctness</td></tr>
319 <tr bgcolor="#eeeeee"><td><a href="#LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect lazy initialization and update of static field</a></td><td>Multithreaded correctness</td></tr>
320 <tr bgcolor="#ffffff"><td><a href="#ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD">ML: Synchronization on field in futile attempt to guard that field</a></td><td>Multithreaded correctness</td></tr>
321 <tr bgcolor="#eeeeee"><td><a href="#ML_SYNC_ON_UPDATED_FIELD">ML: Method synchronizes on an updated field</a></td><td>Multithreaded correctness</td></tr>
322 <tr bgcolor="#ffffff"><td><a href="#MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable servlet field</a></td><td>Multithreaded correctness</td></tr>
323 <tr bgcolor="#eeeeee"><td><a href="#MWN_MISMATCHED_NOTIFY">MWN: Mismatched notify()</a></td><td>Multithreaded correctness</td></tr>
324 <tr bgcolor="#ffffff"><td><a href="#MWN_MISMATCHED_WAIT">MWN: Mismatched wait()</a></td><td>Multithreaded correctness</td></tr>
325 <tr bgcolor="#eeeeee"><td><a href="#NN_NAKED_NOTIFY">NN: Naked notify</a></td><td>Multithreaded correctness</td></tr>
326 <tr bgcolor="#ffffff"><td><a href="#NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchronize and null check on the same field.</a></td><td>Multithreaded correctness</td></tr>
327 <tr bgcolor="#eeeeee"><td><a href="#NO_NOTIFY_NOT_NOTIFYALL">No: Using notify() rather than notifyAll()</a></td><td>Multithreaded correctness</td></tr>
328 <tr bgcolor="#ffffff"><td><a href="#RS_READOBJECT_SYNC">RS: Class's readObject() method is synchronized</a></td><td>Multithreaded correctness</td></tr>
329 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused</a></td><td>Multithreaded correctness</td></tr>
330 <tr bgcolor="#ffffff"><td><a href="#RU_INVOKE_RUN">Ru: Invokes run on a thread (did you mean to start it instead?)</a></td><td>Multithreaded correctness</td></tr>
331 <tr bgcolor="#eeeeee"><td><a href="#SC_START_IN_CTOR">SC: Constructor invokes Thread.start()</a></td><td>Multithreaded correctness</td></tr>
332 <tr bgcolor="#ffffff"><td><a href="#SP_SPIN_ON_FIELD">SP: Method spins on field</a></td><td>Multithreaded correctness</td></tr>
333 <tr bgcolor="#eeeeee"><td><a href="#STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">STCAL: Call to static Calendar</a></td><td>Multithreaded correctness</td></tr>
334 <tr bgcolor="#ffffff"><td><a href="#STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE">STCAL: Call to static DateFormat</a></td><td>Multithreaded correctness</td></tr>
335 <tr bgcolor="#eeeeee"><td><a href="#STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Static Calendar field</a></td><td>Multithreaded correctness</td></tr>
336 <tr bgcolor="#ffffff"><td><a href="#STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">STCAL: Static DateFormat</a></td><td>Multithreaded correctness</td></tr>
337 <tr bgcolor="#eeeeee"><td><a href="#SWL_SLEEP_WITH_LOCK_HELD">SWL: Method calls Thread.sleep() with a lock held</a></td><td>Multithreaded correctness</td></tr>
338 <tr bgcolor="#ffffff"><td><a href="#TLW_TWO_LOCK_WAIT">TLW: Wait with two locks held</a></td><td>Multithreaded correctness</td></tr>
339 <tr bgcolor="#eeeeee"><td><a href="#UG_SYNC_SET_UNSYNC_GET">UG: Unsynchronized get method, synchronized set method</a></td><td>Multithreaded correctness</td></tr>
340 <tr bgcolor="#ffffff"><td><a href="#UL_UNRELEASED_LOCK">UL: Method does not release lock on all paths</a></td><td>Multithreaded correctness</td></tr>
341 <tr bgcolor="#eeeeee"><td><a href="#UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: Method does not release lock on all exception paths</a></td><td>Multithreaded correctness</td></tr>
342 <tr bgcolor="#ffffff"><td><a href="#UW_UNCOND_WAIT">UW: Unconditional wait</a></td><td>Multithreaded correctness</td></tr>
343 <tr bgcolor="#eeeeee"><td><a href="#VO_VOLATILE_INCREMENT">VO: An increment to a volatile field isn't atomic</a></td><td>Multithreaded correctness</td></tr>
344 <tr bgcolor="#ffffff"><td><a href="#VO_VOLATILE_REFERENCE_TO_ARRAY">VO: A volatile reference to an array doesn't treat the array elements as volatile</a></td><td>Multithreaded correctness</td></tr>
345 <tr bgcolor="#eeeeee"><td><a href="#WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL">WL: Synchronization on getClass rather than class literal</a></td><td>Multithreaded correctness</td></tr>
346 <tr bgcolor="#ffffff"><td><a href="#WS_WRITEOBJECT_SYNC">WS: Class's writeObject() method is synchronized but nothing else is</a></td><td>Multithreaded correctness</td></tr>
347 <tr bgcolor="#eeeeee"><td><a href="#WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await() not in loop </a></td><td>Multithreaded correctness</td></tr>
348 <tr bgcolor="#ffffff"><td><a href="#WA_NOT_IN_LOOP">Wa: Wait not in loop </a></td><td>Multithreaded correctness</td></tr>
349 <tr bgcolor="#eeeeee"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive value is boxed and then immediately unboxed</a></td><td>Performance</td></tr>
350 <tr bgcolor="#ffffff"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION">Bx: Primitive value is boxed then unboxed to perform primitive coercion</a></td><td>Performance</td></tr>
351 <tr bgcolor="#eeeeee"><td><a href="#BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed value is unboxed and then immediately reboxed</a></td><td>Performance</td></tr>
352 <tr bgcolor="#ffffff"><td><a href="#DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/unboxing to parse a primitive</a></td><td>Performance</td></tr>
353 <tr bgcolor="#eeeeee"><td><a href="#DM_BOXED_PRIMITIVE_TOSTRING">Bx: Method allocates a boxed primitive just to call toString</a></td><td>Performance</td></tr>
354 <tr bgcolor="#ffffff"><td><a href="#DM_FP_NUMBER_CTOR">Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead</a></td><td>Performance</td></tr>
355 <tr bgcolor="#eeeeee"><td><a href="#DM_NUMBER_CTOR">Bx: Method invokes inefficient Number constructor; use static valueOf instead</a></td><td>Performance</td></tr>
356 <tr bgcolor="#ffffff"><td><a href="#DMI_BLOCKING_METHODS_ON_URL">Dm: The equals and hashCode methods of URL are blocking</a></td><td>Performance</td></tr>
357 <tr bgcolor="#eeeeee"><td><a href="#DMI_COLLECTION_OF_URLS">Dm: Maps and sets of URLs can be performance hogs</a></td><td>Performance</td></tr>
358 <tr bgcolor="#ffffff"><td><a href="#DM_BOOLEAN_CTOR">Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead</a></td><td>Performance</td></tr>
359 <tr bgcolor="#eeeeee"><td><a href="#DM_GC">Dm: Explicit garbage collection; extremely dubious except in benchmarking code</a></td><td>Performance</td></tr>
360 <tr bgcolor="#ffffff"><td><a href="#DM_NEW_FOR_GETCLASS">Dm: Method allocates an object, only to get the class object</a></td><td>Performance</td></tr>
361 <tr bgcolor="#eeeeee"><td><a href="#DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer</a></td><td>Performance</td></tr>
362 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_CTOR">Dm: Method invokes inefficient new String(String) constructor</a></td><td>Performance</td></tr>
363 <tr bgcolor="#eeeeee"><td><a href="#DM_STRING_TOSTRING">Dm: Method invokes toString() method on a String</a></td><td>Performance</td></tr>
364 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_VOID_CTOR">Dm: Method invokes inefficient new String() constructor</a></td><td>Performance</td></tr>
365 <tr bgcolor="#eeeeee"><td><a href="#HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge string constants is duplicated across multiple class files</a></td><td>Performance</td></tr>
366 <tr bgcolor="#ffffff"><td><a href="#ITA_INEFFICIENT_TO_ARRAY">ITA: Method uses toArray() with zero-length array argument</a></td><td>Performance</td></tr>
367 <tr bgcolor="#eeeeee"><td><a href="#SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: Method concatenates strings using + in a loop</a></td><td>Performance</td></tr>
368 <tr bgcolor="#ffffff"><td><a href="#SIC_INNER_SHOULD_BE_STATIC">SIC: Should be a static inner class</a></td><td>Performance</td></tr>
369 <tr bgcolor="#eeeeee"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Could be refactored into a named static inner class</a></td><td>Performance</td></tr>
370 <tr bgcolor="#ffffff"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC: Could be refactored into a static inner class</a></td><td>Performance</td></tr>
371 <tr bgcolor="#eeeeee"><td><a href="#SS_SHOULD_BE_STATIC">SS: Unread field: should this field be static?</a></td><td>Performance</td></tr>
372 <tr bgcolor="#ffffff"><td><a href="#UM_UNNECESSARY_MATH">UM: Method calls static Math class method on a constant value</a></td><td>Performance</td></tr>
373 <tr bgcolor="#eeeeee"><td><a href="#UPM_UNCALLED_PRIVATE_METHOD">UPM: Private method is never called</a></td><td>Performance</td></tr>
374 <tr bgcolor="#ffffff"><td><a href="#URF_UNREAD_FIELD">UrF: Unread field</a></td><td>Performance</td></tr>
375 <tr bgcolor="#eeeeee"><td><a href="#UUF_UNUSED_FIELD">UuF: Unused field</a></td><td>Performance</td></tr>
376 <tr bgcolor="#ffffff"><td><a href="#WMI_WRONG_MAP_ITERATOR">WMI: Inefficient use of keySet iterator instead of entrySet iterator</a></td><td>Performance</td></tr>
377 <tr bgcolor="#eeeeee"><td><a href="#DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded constant database password</a></td><td>Security</td></tr>
378 <tr bgcolor="#ffffff"><td><a href="#DMI_EMPTY_DB_PASSWORD">Dm: Empty database password</a></td><td>Security</td></tr>
379 <tr bgcolor="#eeeeee"><td><a href="#HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP cookie formed from untrusted input</a></td><td>Security</td></tr>
380 <tr bgcolor="#ffffff"><td><a href="#HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: HTTP Response splitting vulnerability</a></td><td>Security</td></tr>
381 <tr bgcolor="#eeeeee"><td><a href="#PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute path traversal in servlet</a></td><td>Security</td></tr>
382 <tr bgcolor="#ffffff"><td><a href="#PT_RELATIVE_PATH_TRAVERSAL">PT: Relative path traversal in servlet</a></td><td>Security</td></tr>
383 <tr bgcolor="#eeeeee"><td><a href="#SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQL: Nonconstant string passed to execute method on an SQL statement</a></td><td>Security</td></tr>
384 <tr bgcolor="#ffffff"><td><a href="#SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING">SQL: A prepared statement is generated from a nonconstant String</a></td><td>Security</td></tr>
385 <tr bgcolor="#eeeeee"><td><a href="#XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JSP reflected cross site scripting vulnerability</a></td><td>Security</td></tr>
386 <tr bgcolor="#ffffff"><td><a href="#XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Servlet reflected cross site scripting vulnerability in error page</a></td><td>Security</td></tr>
387 <tr bgcolor="#eeeeee"><td><a href="#XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS: Servlet reflected cross site scripting vulnerability</a></td><td>Security</td></tr>
388 <tr bgcolor="#ffffff"><td><a href="#BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Questionable cast to abstract collection </a></td><td>Dodgy code</td></tr>
389 <tr bgcolor="#eeeeee"><td><a href="#BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Questionable cast to concrete collection</a></td><td>Dodgy code</td></tr>
390 <tr bgcolor="#ffffff"><td><a href="#BC_UNCONFIRMED_CAST">BC: Unchecked/unconfirmed cast</a></td><td>Dodgy code</td></tr>
391 <tr bgcolor="#eeeeee"><td><a href="#BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unchecked/unconfirmed cast of return value from method</a></td><td>Dodgy code</td></tr>
392 <tr bgcolor="#ffffff"><td><a href="#BC_VACUOUS_INSTANCEOF">BC: instanceof will always return true</a></td><td>Dodgy code</td></tr>
393 <tr bgcolor="#eeeeee"><td><a href="#ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSHIFT: Unsigned right shift cast to short/byte</a></td><td>Dodgy code</td></tr>
394 <tr bgcolor="#ffffff"><td><a href="#CI_CONFUSED_INHERITANCE">CI: Class is final but declares protected field</a></td><td>Dodgy code</td></tr>
395 <tr bgcolor="#eeeeee"><td><a href="#DB_DUPLICATE_BRANCHES">DB: Method uses the same code for two branches</a></td><td>Dodgy code</td></tr>
396 <tr bgcolor="#ffffff"><td><a href="#DB_DUPLICATE_SWITCH_CLAUSES">DB: Method uses the same code for two switch clauses</a></td><td>Dodgy code</td></tr>
397 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE">DLS: Dead store to local variable</a></td><td>Dodgy code</td></tr>
398 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless assignment in return statement</a></td><td>Dodgy code</td></tr>
399 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Dead store of null to local variable</a></td><td>Dodgy code</td></tr>
400 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dead store to local variable that shadows field</a></td><td>Dodgy code</td></tr>
401 <tr bgcolor="#eeeeee"><td><a href="#DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Code contains a hard coded reference to an absolute pathname</a></td><td>Dodgy code</td></tr>
402 <tr bgcolor="#ffffff"><td><a href="#DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Non serializable object written to ObjectOutput</a></td><td>Dodgy code</td></tr>
403 <tr bgcolor="#eeeeee"><td><a href="#DMI_USELESS_SUBSTRING">DMI: Invocation of substring(0), which returns the original value</a></td><td>Dodgy code</td></tr>
404 <tr bgcolor="#ffffff"><td><a href="#DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">Dm: Thread passed where Runnable expected</a></td><td>Dodgy code</td></tr>
405 <tr bgcolor="#eeeeee"><td><a href="#EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't override equals in superclass</a></td><td>Dodgy code</td></tr>
406 <tr bgcolor="#ffffff"><td><a href="#EQ_UNUSUAL">Eq: Unusual equals method </a></td><td>Dodgy code</td></tr>
407 <tr bgcolor="#eeeeee"><td><a href="#FE_FLOATING_POINT_EQUALITY">FE: Test for floating point equality</a></td><td>Dodgy code</td></tr>
408 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">FS: Non-Boolean argument formatted using %b format specifier</a></td><td>Dodgy code</td></tr>
409 <tr bgcolor="#eeeeee"><td><a href="#IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">IA: Potentially ambiguous invocation of either an inherited or outer method</a></td><td>Dodgy code</td></tr>
410 <tr bgcolor="#ffffff"><td><a href="#IC_INIT_CIRCULARITY">IC: Initialization circularity</a></td><td>Dodgy code</td></tr>
411 <tr bgcolor="#eeeeee"><td><a href="#ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Integral division result cast to double or float</a></td><td>Dodgy code</td></tr>
412 <tr bgcolor="#ffffff"><td><a href="#ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST: Result of integer multiplication cast to long</a></td><td>Dodgy code</td></tr>
413 <tr bgcolor="#eeeeee"><td><a href="#IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: Computation of average could overflow</a></td><td>Dodgy code</td></tr>
414 <tr bgcolor="#ffffff"><td><a href="#IM_BAD_CHECK_FOR_ODD">IM: Check for oddness that won't work for negative numbers </a></td><td>Dodgy code</td></tr>
415 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_REM_BY_1">INT: Integer remainder modulo 1</a></td><td>Dodgy code</td></tr>
416 <tr bgcolor="#ffffff"><td><a href="#INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit mask operation on integer value</a></td><td>Dodgy code</td></tr>
417 <tr bgcolor="#eeeeee"><td><a href="#INT_VACUOUS_COMPARISON">INT: Vacuous comparison of integer value</a></td><td>Dodgy code</td></tr>
418 <tr bgcolor="#ffffff"><td><a href="#MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: Class extends Servlet class and uses instance variables</a></td><td>Dodgy code</td></tr>
419 <tr bgcolor="#eeeeee"><td><a href="#MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: Class extends Struts Action class and uses instance variables</a></td><td>Dodgy code</td></tr>
420 <tr bgcolor="#ffffff"><td><a href="#NP_DEREFERENCE_OF_READLINE_VALUE">NP: Dereference of the result of readLine() without nullcheck</a></td><td>Dodgy code</td></tr>
421 <tr bgcolor="#eeeeee"><td><a href="#NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Immediate dereference of the result of readLine()</a></td><td>Dodgy code</td></tr>
422 <tr bgcolor="#ffffff"><td><a href="#NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Load of known null value</a></td><td>Dodgy code</td></tr>
423 <tr bgcolor="#eeeeee"><td><a href="#NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP: Method tightens nullness annotation on parameter</a></td><td>Dodgy code</td></tr>
424 <tr bgcolor="#ffffff"><td><a href="#NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Method relaxes nullness annotation on return value</a></td><td>Dodgy code</td></tr>
425 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP: Possible null pointer dereference due to return value of called method</a></td><td>Dodgy code</td></tr>
426 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP: Possible null pointer dereference on branch that might be infeasible</a></td><td>Dodgy code</td></tr>
427 <tr bgcolor="#eeeeee"><td><a href="#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP: Parameter must be nonnull but is marked as nullable</a></td><td>Dodgy code</td></tr>
428 <tr bgcolor="#ffffff"><td><a href="#NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP: Read of unwritten public or protected field</a></td><td>Dodgy code</td></tr>
429 <tr bgcolor="#eeeeee"><td><a href="#NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentially dangerous use of non-short-circuit logic</a></td><td>Dodgy code</td></tr>
430 <tr bgcolor="#ffffff"><td><a href="#NS_NON_SHORT_CIRCUIT">NS: Questionable use of non-short-circuit logic</a></td><td>Dodgy code</td></tr>
431 <tr bgcolor="#eeeeee"><td><a href="#PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Consider returning a zero length array rather than null</a></td><td>Dodgy code</td></tr>
432 <tr bgcolor="#ffffff"><td><a href="#QF_QUESTIONABLE_FOR_LOOP">QF: Complicated, subtle or wrong increment in for-loop </a></td><td>Dodgy code</td></tr>
433 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">RCN: Redundant comparison of non-null value to null</a></td><td>Dodgy code</td></tr>
434 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RCN: Redundant comparison of two null values</a></td><td>Dodgy code</td></tr>
435 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RCN: Redundant nullcheck of value known to be non-null</a></td><td>Dodgy code</td></tr>
436 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN: Redundant nullcheck of value known to be null</a></td><td>Dodgy code</td></tr>
437 <tr bgcolor="#eeeeee"><td><a href="#REC_CATCH_EXCEPTION">REC: Exception is caught when Exception is not thrown</a></td><td>Dodgy code</td></tr>
438 <tr bgcolor="#ffffff"><td><a href="#RI_REDUNDANT_INTERFACES">RI: Class implements same interface as superclass</a></td><td>Dodgy code</td></tr>
439 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Method checks to see if result of String.indexOf is positive</a></td><td>Dodgy code</td></tr>
440 <tr bgcolor="#ffffff"><td><a href="#RV_DONT_JUST_NULL_CHECK_READLINE">RV: Method discards result of readLine after checking if it is nonnull</a></td><td>Dodgy code</td></tr>
441 <tr bgcolor="#eeeeee"><td><a href="#RV_REM_OF_HASHCODE">RV: Remainder of hashCode could be negative</a></td><td>Dodgy code</td></tr>
442 <tr bgcolor="#ffffff"><td><a href="#RV_REM_OF_RANDOM_INT">RV: Remainder of 32-bit signed random integer</a></td><td>Dodgy code</td></tr>
443 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method ignores return value, is this OK?</a></td><td>Dodgy code</td></tr>
444 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assignment of field</a></td><td>Dodgy code</td></tr>
445 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assignment of local variable </a></td><td>Dodgy code</td></tr>
446 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT">SA: Self assignment of local variable</a></td><td>Dodgy code</td></tr>
447 <tr bgcolor="#eeeeee"><td><a href="#SF_SWITCH_FALLTHROUGH">SF: Switch statement found where one case falls through to the next case</a></td><td>Dodgy code</td></tr>
448 <tr bgcolor="#ffffff"><td><a href="#SF_SWITCH_NO_DEFAULT">SF: Switch statement found where default case is missing</a></td><td>Dodgy code</td></tr>
449 <tr bgcolor="#eeeeee"><td><a href="#ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST: Write to static field from instance method</a></td><td>Dodgy code</td></tr>
450 <tr bgcolor="#ffffff"><td><a href="#SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: Private readResolve method not inherited by subclasses</a></td><td>Dodgy code</td></tr>
451 <tr bgcolor="#eeeeee"><td><a href="#SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">Se: Transient field of class that isn't Serializable. </a></td><td>Dodgy code</td></tr>
452 <tr bgcolor="#ffffff"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value required to have type qualifier, but marked as unknown</a></td><td>Dodgy code</td></tr>
453 <tr bgcolor="#eeeeee"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value required to not have type qualifier, but marked as unknown</a></td><td>Dodgy code</td></tr>
454 <tr bgcolor="#ffffff"><td><a href="#UCF_USELESS_CONTROL_FLOW">UCF: Useless control flow</a></td><td>Dodgy code</td></tr>
455 <tr bgcolor="#eeeeee"><td><a href="#UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Useless control flow to next line</a></td><td>Dodgy code</td></tr>
456 <tr bgcolor="#ffffff"><td><a href="#URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: Unread public/protected field</a></td><td>Dodgy code</td></tr>
457 <tr bgcolor="#eeeeee"><td><a href="#UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: Unused public or protected field</a></td><td>Dodgy code</td></tr>
458 <tr bgcolor="#ffffff"><td><a href="#UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">UwF: Field not initialized in constructor but dereferenced without null check</a></td><td>Dodgy code</td></tr>
459 <tr bgcolor="#eeeeee"><td><a href="#UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF: Unwritten public or protected field</a></td><td>Dodgy code</td></tr>
460 <tr bgcolor="#ffffff"><td><a href="#XFB_XML_FACTORY_BYPASS">XFB: Method directly allocates a specific implementation of xml interfaces</a></td><td>Dodgy code</td></tr>
461 </table>
462 <h2>Descriptions</h2>
463 <h3><a name="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS">BC: Equals method should not assume anything about the type of its argument (BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)</a></h3>
464
465
466 <p>
467 The <code>equals(Object o)</code> method shouldn't make any assumptions
468 about the type of <code>o</code>. It should simply return
469 false if <code>o</code> is not the same type as <code>this</code>.
470 </p>
471
472
473 <h3><a name="BIT_SIGNED_CHECK">BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK)</a></h3>
474
475
476 <p> This method compares an expression such as</p>
477 <pre>((event.detail &amp; SWT.SELECTED) &gt; 0)</pre>.
478 <p>Using bit arithmetic and then comparing with the greater than operator can
479 lead to unexpected results (of course depending on the value of
480 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
481 for a bug. Even when SWT.SELECTED is not negative, it seems good practice
482 to use '!= 0' instead of '&gt; 0'.
483 </p>
484 <p>
485 <em>Boris Bokowski</em>
486 </p>
487
488
489 <h3><a name="CN_IDIOM">CN: Class implements Cloneable but does not define or use clone method (CN_IDIOM)</a></h3>
490
491
492 <p>
493 Class implements Cloneable but does not define or
494 use the clone method.</p>
495
496
497 <h3><a name="CN_IDIOM_NO_SUPER_CALL">CN: clone method does not call super.clone() (CN_IDIOM_NO_SUPER_CALL)</a></h3>
498
499
500 <p> This non-final class defines a clone() method that does not call super.clone().
501 If this class ("<i>A</i>") is extended by a subclass ("<i>B</i>"),
502 and the subclass <i>B</i> calls super.clone(), then it is likely that
503 <i>B</i>'s clone() method will return an object of type <i>A</i>,
504 which violates the standard contract for clone().</p>
505
506 <p> If all clone() methods call super.clone(), then they are guaranteed
507 to use Object.clone(), which always returns an object of the correct type.</p>
508
509
510 <h3><a name="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: Class defines clone() but doesn't implement Cloneable (CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE)</a></h3>
511
512
513 <p> This class defines a clone() method but the class doesn't implement Cloneable.
514 There are some situations in which this is OK (e.g., you want to control how subclasses
515 can clone themselves), but just make sure that this is what you intended.
516 </p>
517
518
519 <h3><a name="CO_ABSTRACT_SELF">Co: Abstract class defines covariant compareTo() method (CO_ABSTRACT_SELF)</a></h3>
520
521
522 <p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;
523 To correctly override the <code>compareTo()</code> method in the
524 <code>Comparable</code> interface, the parameter of <code>compareTo()</code>
525 must have type <code>java.lang.Object</code>.</p>
526
527
528 <h3><a name="CO_SELF_NO_OBJECT">Co: Covariant compareTo() method defined (CO_SELF_NO_OBJECT)</a></h3>
529
530
531 <p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;
532 To correctly override the <code>compareTo()</code> method in the
533 <code>Comparable</code> interface, the parameter of <code>compareTo()</code>
534 must have type <code>java.lang.Object</code>.</p>
535
536
537 <h3><a name="DE_MIGHT_DROP">DE: Method might drop exception (DE_MIGHT_DROP)</a></h3>
538
539
540 <p> This method might drop an exception.&nbsp; In general, exceptions
541 should be handled or reported in some way, or they should be thrown
542 out of the method.</p>
543
544
545 <h3><a name="DE_MIGHT_IGNORE">DE: Method might ignore exception (DE_MIGHT_IGNORE)</a></h3>
546
547
548 <p> This method might ignore an exception.&nbsp; In general, exceptions
549 should be handled or reported in some way, or they should be thrown
550 out of the method.</p>
551
552
553 <h3><a name="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI: Adding elements of an entry set may fail due to reuse of Entry objects (DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS)</a></h3>
554
555
556 <p> The entrySet() method is allowed to return a view of the
557 underlying Map in which a single Entry object is reused and returned
558 during the iteration. As of Java 1.6, both IdentityHashMap
559 and EnumMap did so. When iterating through such a Map,
560 the Entry value is only valid until you advance to the next iteration.
561 If, for example, you try to pass such an entrySet to an addAll method,
562 things will go badly wrong.
563 </p>
564
565
566 <h3><a name="DMI_RANDOM_USED_ONLY_ONCE">DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE)</a></h3>
567
568
569 <p> This code creates a java.util.Random object, uses it to generate one random number, and then discards
570 the Random object. This produces mediocre quality random numbers and is inefficient.
571 If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number
572 is required invoke a method on the existing Random object to obtain it.
573 </p>
574
575 <p>If it is important that the generated Random numbers not be guessable, you <em>must</em> not create a new Random for each random
576 number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead
577 (and avoid allocating a new SecureRandom for each random number needed).
578 </p>
579
580
581 <h3><a name="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI: Don't use removeAll to clear a collection (DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION)</a></h3>
582
583
584 <p> If you want to remove all elements from a collection <code>c</code>, use <code>c.clear</code>,
585 not <code>c.removeAll(c)</code>. Calling <code>c.removeAll(c)</code> to clear a collection
586 is less clear, susceptible to errors from typos, less efficient and
587 for some collections, might throw a <code>ConcurrentModificationException</code>.
588 </p>
589
590
591 <h3><a name="DM_EXIT">Dm: Method invokes System.exit(...) (DM_EXIT)</a></h3>
592
593
594 <p> Invoking System.exit shuts down the entire Java virtual machine. This
595 should only been done when it is appropriate. Such calls make it
596 hard or impossible for your code to be invoked by other code.
597 Consider throwing a RuntimeException instead.</p>
598
599
600 <h3><a name="DM_RUN_FINALIZERS_ON_EXIT">Dm: Method invokes dangerous method runFinalizersOnExit (DM_RUN_FINALIZERS_ON_EXIT)</a></h3>
601
602
603 <p> <em>Never call System.runFinalizersOnExit
604 or Runtime.runFinalizersOnExit for any reason: they are among the most
605 dangerous methods in the Java libraries.</em> -- Joshua Bloch</p>
606
607
608 <h3><a name="ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: Comparison of String parameter using == or != (ES_COMPARING_PARAMETER_STRING_WITH_EQ)</a></h3>
609
610
611 <p>This code compares a <code>java.lang.String</code> parameter for reference
612 equality using the == or != operators. Requiring callers to
613 pass only String constants or interned strings to a method is unnecessarily
614 fragile, and rarely leads to measurable performance gains. Consider
615 using the <code>equals(Object)</code> method instead.</p>
616
617
618 <h3><a name="ES_COMPARING_STRINGS_WITH_EQ">ES: Comparison of String objects using == or != (ES_COMPARING_STRINGS_WITH_EQ)</a></h3>
619
620
621 <p>This code compares <code>java.lang.String</code> objects for reference
622 equality using the == or != operators.
623 Unless both strings are either constants in a source file, or have been
624 interned using the <code>String.intern()</code> method, the same string
625 value may be represented by two different String objects. Consider
626 using the <code>equals(Object)</code> method instead.</p>
627
628
629 <h3><a name="EQ_ABSTRACT_SELF">Eq: Abstract class defines covariant equals() method (EQ_ABSTRACT_SELF)</a></h3>
630
631
632 <p> This class defines a covariant version of <code>equals()</code>.&nbsp;
633 To correctly override the <code>equals()</code> method in
634 <code>java.lang.Object</code>, the parameter of <code>equals()</code>
635 must have type <code>java.lang.Object</code>.</p>
636
637
638 <h3><a name="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">Eq: Equals checks for incompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS)</a></h3>
639
640
641 <p> This equals method is checking to see if the argument is some incompatible type
642 (i.e., a class that is neither a supertype nor subtype of the class that defines
643 the equals method). For example, the Foo class might have an equals method
644 that looks like:
645 </p>
646 <pre>
647 public boolean equals(Object o) {
648 if (o instanceof Foo)
649 return name.equals(((Foo)o).name);
650 else if (o instanceof String)
651 return name.equals(o);
652 else return false;
653 </pre>
654
655 <p>This is considered bad practice, as it makes it very hard to implement an equals method that
656 is symmetric and transitive. Without those properties, very unexpected behavoirs are possible.
657 </p>
658
659
660 <h3><a name="EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class defines compareTo(...) and uses Object.equals() (EQ_COMPARETO_USE_OBJECT_EQUALS)</a></h3>
661
662
663 <p> This class defines a <code>compareTo(...)</code> method but inherits its
664 <code>equals()</code> method from <code>java.lang.Object</code>.
665 Generally, the value of compareTo should return zero if and only if
666 equals returns true. If this is violated, weird and unpredictable
667 failures will occur in classes such as PriorityQueue.
668 In Java 5 the PriorityQueue.remove method uses the compareTo method,
669 while in Java 6 it uses the equals method.
670
671 <p>From the JavaDoc for the compareTo method in the Comparable interface:
672 <blockquote>
673 It is strongly recommended, but not strictly required that <code>(x.compareTo(y)==0) == (x.equals(y))</code>.
674 Generally speaking, any class that implements the Comparable interface and violates this condition
675 should clearly indicate this fact. The recommended language
676 is "Note: this class has a natural ordering that is inconsistent with equals."
677 </blockquote>
678
679
680 <h3><a name="EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals method fails for subtypes (EQ_GETCLASS_AND_CLASS_CONSTANT)</a></h3>
681
682
683 <p> This class has an equals method that will be broken if it is inherited by subclasses.
684 It compares a class literal with the class of the argument (e.g., in class <code>Foo</code>
685 it might check if <code>Foo.class == o.getClass()</code>).
686 It is better to check if <code>this.getClass() == o.getClass()</code>.
687 </p>
688
689
690 <h3><a name="EQ_SELF_NO_OBJECT">Eq: Covariant equals() method defined (EQ_SELF_NO_OBJECT)</a></h3>
691
692
693 <p> This class defines a covariant version of <code>equals()</code>.&nbsp;
694 To correctly override the <code>equals()</code> method in
695 <code>java.lang.Object</code>, the parameter of <code>equals()</code>
696 must have type <code>java.lang.Object</code>.</p>
697
698
699 <h3><a name="FI_EMPTY">FI: Empty finalizer should be deleted (FI_EMPTY)</a></h3>
700
701
702 <p> Empty <code>finalize()</code> methods are useless, so they should
703 be deleted.</p>
704
705
706 <h3><a name="FI_EXPLICIT_INVOCATION">FI: Explicit invocation of finalizer (FI_EXPLICIT_INVOCATION)</a></h3>
707
708
709 <p> This method contains an explicit invocation of the <code>finalize()</code>
710 method on an object.&nbsp; Because finalizer methods are supposed to be
711 executed once, and only by the VM, this is a bad idea.</p>
712 <p>If a connected set of objects beings finalizable, then the VM will invoke the
713 finalize method on all the finalizable object, possibly at the same time in different threads.
714 Thus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize
715 on objects referenced by X, because they may already be getting finalized in a separate thread.
716
717
718 <h3><a name="FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nulls fields (FI_FINALIZER_NULLS_FIELDS)</a></h3>
719
720
721 <p> This finalizer nulls out fields. This is usually an error, as it does not aid garbage collection,
722 and the object is going to be garbage collected anyway.
723
724
725 <h3><a name="FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalizer only nulls fields (FI_FINALIZER_ONLY_NULLS_FIELDS)</a></h3>
726
727
728 <p> This finalizer does nothing except null out fields. This is completely pointless, and requires that
729 the object be garbage collected, finalized, and then garbage collected again. You should just remove the finalize
730 method.
731
732
733 <h3><a name="FI_MISSING_SUPER_CALL">FI: Finalizer does not call superclass finalizer (FI_MISSING_SUPER_CALL)</a></h3>
734
735
736 <p> This <code>finalize()</code> method does not make a call to its
737 superclass's <code>finalize()</code> method.&nbsp; So, any finalizer
738 actions defined for the superclass will not be performed.&nbsp;
739 Add a call to <code>super.finalize()</code>.</p>
740
741
742 <h3><a name="FI_NULLIFY_SUPER">FI: Finalizer nullifies superclass finalizer (FI_NULLIFY_SUPER)</a></h3>
743
744
745 <p> This empty <code>finalize()</code> method explicitly negates the
746 effect of any finalizer defined by its superclass.&nbsp; Any finalizer
747 actions defined for the superclass will not be performed.&nbsp;
748 Unless this is intended, delete this method.</p>
749
750
751 <h3><a name="FI_USELESS">FI: Finalizer does nothing but call superclass finalizer (FI_USELESS)</a></h3>
752
753
754 <p> The only thing this <code>finalize()</code> method does is call
755 the superclass's <code>finalize()</code> method, making it
756 redundant.&nbsp; Delete it.</p>
757
758
759 <h3><a name="VA_FORMAT_STRING_USES_NEWLINE">FS: Format string should use %n rather than \n (VA_FORMAT_STRING_USES_NEWLINE)</a></h3>
760
761
762 <p>
763 This format string include a newline character (\n). In format strings, it is generally
764 preferable better to use %n, which will produce the platform-specific line separator.
765 </p>
766
767
768 <h3><a name="GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unchecked type in generic call (GC_UNCHECKED_TYPE_IN_GENERIC_CALL)</a></h3>
769
770
771 <p> This call to a generic collection method passes an argument
772 while compile type Object where a specific type from
773 the generic type parameters is expected.
774 Thus, neither the standard Java type system nor static analysis
775 can provide useful information on whether the
776 object being passed as a parameter is of an appropriate type.
777 </p>
778
779
780 <h3><a name="HE_EQUALS_NO_HASHCODE">HE: Class defines equals() but not hashCode() (HE_EQUALS_NO_HASHCODE)</a></h3>
781
782
783 <p> This class overrides <code>equals(Object)</code>, but does not
784 override <code>hashCode()</code>.&nbsp; Therefore, the class may violate the
785 invariant that equal objects must have equal hashcodes.</p>
786
787
788 <h3><a name="HE_EQUALS_USE_HASHCODE">HE: Class defines equals() and uses Object.hashCode() (HE_EQUALS_USE_HASHCODE)</a></h3>
789
790
791 <p> This class overrides <code>equals(Object)</code>, but does not
792 override <code>hashCode()</code>, and inherits the implementation of
793 <code>hashCode()</code> from <code>java.lang.Object</code> (which returns
794 the identity hash code, an arbitrary value assigned to the object
795 by the VM).&nbsp; Therefore, the class is very likely to violate the
796 invariant that equal objects must have equal hashcodes.</p>
797
798 <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
799 the recommended <code>hashCode</code> implementation to use is:</p>
800 <pre>public int hashCode() {
801 assert false : "hashCode not designed";
802 return 42; // any arbitrary constant will do
803 }</pre>
804
805
806 <h3><a name="HE_HASHCODE_NO_EQUALS">HE: Class defines hashCode() but not equals() (HE_HASHCODE_NO_EQUALS)</a></h3>
807
808
809 <p> This class defines a <code>hashCode()</code> method but not an
810 <code>equals()</code> method.&nbsp; Therefore, the class may
811 violate the invariant that equal objects must have equal hashcodes.</p>
812
813
814 <h3><a name="HE_HASHCODE_USE_OBJECT_EQUALS">HE: Class defines hashCode() and uses Object.equals() (HE_HASHCODE_USE_OBJECT_EQUALS)</a></h3>
815
816
817 <p> This class defines a <code>hashCode()</code> method but inherits its
818 <code>equals()</code> method from <code>java.lang.Object</code>
819 (which defines equality by comparing object references).&nbsp; Although
820 this will probably satisfy the contract that equal objects must have
821 equal hashcodes, it is probably not what was intended by overriding
822 the <code>hashCode()</code> method.&nbsp; (Overriding <code>hashCode()</code>
823 implies that the object's identity is based on criteria more complicated
824 than simple reference equality.)</p>
825 <p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
826 the recommended <code>hashCode</code> implementation to use is:</p>
827 <pre>public int hashCode() {
828 assert false : "hashCode not designed";
829 return 42; // any arbitrary constant will do
830 }</pre>
831
832
833 <h3><a name="HE_INHERITS_EQUALS_USE_HASHCODE">HE: Class inherits equals() and uses Object.hashCode() (HE_INHERITS_EQUALS_USE_HASHCODE)</a></h3>
834
835
836 <p> This class inherits <code>equals(Object)</code> from an abstract
837 superclass, and <code>hashCode()</code> from
838 <code>java.lang.Object</code> (which returns
839 the identity hash code, an arbitrary value assigned to the object
840 by the VM).&nbsp; Therefore, the class is very likely to violate the
841 invariant that equal objects must have equal hashcodes.</p>
842
843 <p>If you don't want to define a hashCode method, and/or don't
844 believe the object will ever be put into a HashMap/Hashtable,
845 define the <code>hashCode()</code> method
846 to throw <code>UnsupportedOperationException</code>.</p>
847
848
849 <h3><a name="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION">IC: Superclass uses subclass during initialization (IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION)</a></h3>
850
851
852 <p> During the initialization of a class, the class makes an active use of a subclass.
853 That subclass will not yet be initialized at the time of this use.
854 For example, in the following code, <code>foo</code> will be null.</p>
855
856 <pre>
857 public class CircularClassInitialization {
858 static class InnerClassSingleton extends CircularClassInitialization {
859 static InnerClassSingleton singleton = new InnerClassSingleton();
860 }
861
862 static CircularClassInitialization foo = InnerClassSingleton.singleton;
863 }
864 </pre>
865
866
867
868 <h3><a name="IMSE_DONT_CATCH_IMSE">IMSE: Dubious catching of IllegalMonitorStateException (IMSE_DONT_CATCH_IMSE)</a></h3>
869
870
871 <p>IllegalMonitorStateException is generally only
872 thrown in case of a design flaw in your code (calling wait or
873 notify on an object you do not hold a lock on).</p>
874
875
876 <h3><a name="ISC_INSTANTIATE_STATIC_CLASS">ISC: Needless instantiation of class that only supplies static methods (ISC_INSTANTIATE_STATIC_CLASS)</a></h3>
877
878
879 <p> This class allocates an object that is based on a class that only supplies static methods. This object
880 does not need to be created, just access the static methods directly using the class name as a qualifier.</p>
881
882
883 <h3><a name="IT_NO_SUCH_ELEMENT">It: Iterator next() method can't throw NoSuchElementException (IT_NO_SUCH_ELEMENT)</a></h3>
884
885
886 <p> This class implements the <code>java.util.Iterator</code> interface.&nbsp;
887 However, its <code>next()</code> method is not capable of throwing
888 <code>java.util.NoSuchElementException</code>.&nbsp; The <code>next()</code>
889 method should be changed so it throws <code>NoSuchElementException</code>
890 if is called when there are no more elements to return.</p>
891
892
893 <h3><a name="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION">J2EE: Store of non serializable object into HttpSession (J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION)</a></h3>
894
895
896 <p>
897 This code seems to be storing a non-serializable object into an HttpSession.
898 If this session is passivated or migrated, an error will result.
899 </p>
900
901
902 <h3><a name="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP: Fields of immutable classes should be final (JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS)</a></h3>
903
904
905 <p> The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable,
906 and the rules for those annotations require that all fields are final.
907 .</p>
908
909
910 <h3><a name="NP_BOOLEAN_RETURN_NULL">NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)</a></h3>
911
912
913 <p>
914 A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen.
915 This method can be invoked as though it returned a value of type boolean, and
916 the compiler will insert automatic unboxing of the Boolean value. If a null value is returned,
917 this will result in a NullPointerException.
918 </p>
919
920
921 <h3><a name="NP_CLONE_COULD_RETURN_NULL">NP: Clone method may return null (NP_CLONE_COULD_RETURN_NULL)</a></h3>
922
923
924 <p>
925 This clone method seems to return null in some circumstances, but clone is never
926 allowed to return a null value. If you are convinced this path is unreachable, throw an AssertionError
927 instead.
928 </p>
929
930
931 <h3><a name="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: equals() method does not check for null argument (NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT)</a></h3>
932
933
934 <p>
935 This implementation of equals(Object) violates the contract defined
936 by java.lang.Object.equals() because it does not check for null
937 being passed as the argument. All equals() methods should return
938 false if passed a null value.
939 </p>
940
941
942 <h3><a name="NP_TOSTRING_COULD_RETURN_NULL">NP: toString method may return null (NP_TOSTRING_COULD_RETURN_NULL)</a></h3>
943
944
945 <p>
946 This toString method seems to return null in some circumstances. A liberal reading of the
947 spec could be interpreted as allowing this, but it is probably a bad idea and could cause
948 other code to break. Return the empty string or some other appropriate string rather than null.
949 </p>
950
951
952 <h3><a name="NM_CLASS_NAMING_CONVENTION">Nm: Class names should start with an upper case letter (NM_CLASS_NAMING_CONVENTION)</a></h3>
953
954
955 <p> Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
956 </p>
957
958
959 <h3><a name="NM_CLASS_NOT_EXCEPTION">Nm: Class is not derived from an Exception, even though it is named as such (NM_CLASS_NOT_EXCEPTION)</a></h3>
960
961
962 <p> This class is not derived from another exception, but ends with 'Exception'. This will
963 be confusing to users of this class.</p>
964
965
966 <h3><a name="NM_CONFUSING">Nm: Confusing method names (NM_CONFUSING)</a></h3>
967
968
969 <p> The referenced methods have names that differ only by capitalization.</p>
970
971
972 <h3><a name="NM_FIELD_NAMING_CONVENTION">Nm: Field names should start with a lower case letter (NM_FIELD_NAMING_CONVENTION)</a></h3>
973
974
975 <p>
976 Names of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized.
977 </p>
978
979
980 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER)</a></h3>
981
982
983 <p>The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed
984 in order to compile it in later versions of Java.</p>
985
986
987
988 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER">Nm: Use of identifier that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER)</a></h3>
989
990
991 <p>This identifier is used as a keyword in later versions of Java. This code, and
992 any code that references this API,
993 will need to be changed in order to compile it in later versions of Java.</p>
994
995
996
997 <h3><a name="NM_METHOD_NAMING_CONVENTION">Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION)</a></h3>
998
999
1000 <p>
1001 Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.
1002 </p>
1003
1004
1005 <h3><a name="NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class names shouldn't shadow simple name of implemented interface (NM_SAME_SIMPLE_NAME_AS_INTERFACE)</a></h3>
1006
1007
1008 <p> This class/interface has a simple name that is identical to that of an implemented/extended interface, except
1009 that the interface is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
1010 This can be exceptionally confusing, create lots of situations in which you have to look at import statements
1011 to resolve references and creates many
1012 opportunities to accidently define methods that do not override methods in their superclasses.
1013 </p>
1014
1015
1016 <h3><a name="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class names shouldn't shadow simple name of superclass (NM_SAME_SIMPLE_NAME_AS_SUPERCLASS)</a></h3>
1017
1018
1019 <p> This class has a simple name that is identical to that of its superclass, except
1020 that its superclass is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).
1021 This can be exceptionally confusing, create lots of situations in which you have to look at import statements
1022 to resolve references and creates many
1023 opportunities to accidently define methods that do not override methods in their superclasses.
1024 </p>
1025
1026
1027 <h3><a name="NM_VERY_CONFUSING_INTENTIONAL">Nm: Very confusing method names (but perhaps intentional) (NM_VERY_CONFUSING_INTENTIONAL)</a></h3>
1028
1029
1030 <p> The referenced methods have names that differ only by capitalization.
1031 This is very confusing because if the capitalization were
1032 identical then one of the methods would override the other. From the existence of other methods, it
1033 seems that the existence of both of these methods is intentional, but is sure is confusing.
1034 You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs.
1035 </p>
1036
1037
1038 <h3><a name="NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE_INTENTIONAL)</a></h3>
1039
1040
1041 <p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match
1042 the type of the corresponding parameter in the superclass. For example, if you have:</p>
1043
1044 <blockquote>
1045 <pre>
1046 import alpha.Foo;
1047 public class A {
1048 public int f(Foo x) { return 17; }
1049 }
1050 ----
1051 import beta.Foo;
1052 public class B extends A {
1053 public int f(Foo x) { return 42; }
1054 public int f(alpha.Foo x) { return 27; }
1055 }
1056 </pre>
1057 </blockquote>
1058
1059 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't
1060 override the
1061 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument
1062 types are <code>Foo</code>'s from different packages.
1063 </p>
1064
1065 <p>In this case, the subclass does define a method with a signature identical to the method in the superclass,
1066 so this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider
1067 removing or deprecating the method with the similar but not identical signature.
1068 </p>
1069
1070
1071 <h3><a name="ODR_OPEN_DATABASE_RESOURCE">ODR: Method may fail to close database resource (ODR_OPEN_DATABASE_RESOURCE)</a></h3>
1072
1073
1074 <p> The method creates a database resource (such as a database connection
1075 or row set), does not assign it to any
1076 fields, pass it to other methods, or return it, and does not appear to close
1077 the object on all paths out of the method.&nbsp; Failure to
1078 close database resources on all paths out of a method may
1079 result in poor performance, and could cause the application to
1080 have problems communicating with the database.
1081 </p>
1082
1083
1084 <h3><a name="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">ODR: Method may fail to close database resource on exception (ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH)</a></h3>
1085
1086
1087 <p> The method creates a database resource (such as a database connection
1088 or row set), does not assign it to any
1089 fields, pass it to other methods, or return it, and does not appear to close
1090 the object on all exception paths out of the method.&nbsp; Failure to
1091 close database resources on all paths out of a method may
1092 result in poor performance, and could cause the application to
1093 have problems communicating with the database.</p>
1094
1095
1096 <h3><a name="OS_OPEN_STREAM">OS: Method may fail to close stream (OS_OPEN_STREAM)</a></h3>
1097
1098
1099 <p> The method creates an IO stream object, does not assign it to any
1100 fields, pass it to other methods that might close it,
1101 or return it, and does not appear to close
1102 the stream on all paths out of the method.&nbsp; This may result in
1103 a file descriptor leak.&nbsp; It is generally a good
1104 idea to use a <code>finally</code> block to ensure that streams are
1105 closed.</p>
1106
1107
1108 <h3><a name="OS_OPEN_STREAM_EXCEPTION_PATH">OS: Method may fail to close stream on exception (OS_OPEN_STREAM_EXCEPTION_PATH)</a></h3>
1109
1110
1111 <p> The method creates an IO stream object, does not assign it to any
1112 fields, pass it to other methods, or return it, and does not appear to close
1113 it on all possible exception paths out of the method.&nbsp;
1114 This may result in a file descriptor leak.&nbsp; It is generally a good
1115 idea to use a <code>finally</code> block to ensure that streams are
1116 closed.</p>
1117
1118
1119 <h3><a name="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ: Don't reuse entry objects in iterators (PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS)</a></h3>
1120
1121
1122 <p> The entrySet() method is allowed to return a view of the
1123 underlying Map in which an Iterator and Map.Entry. This clever
1124 idea was used in several Map implementations, but introduces the possibility
1125 of nasty coding mistakes. If a map <code>m</code> returns
1126 such an iterator for an entrySet, then
1127 <code>c.addAll(m.entrySet())</code> will go badly wrong. All of
1128 the Map implementations in OpenJDK 1.7 have been rewritten to avoid this,
1129 you should to.
1130 </p>
1131
1132
1133 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicious reference comparison to constant (RC_REF_COMPARISON_BAD_PRACTICE)</a></h3>
1134
1135
1136 <p> This method compares a reference value to a constant using the == or != operator,
1137 where the correct way to compare instances of this type is generally
1138 with the equals() method.
1139 It is possible to create distinct instances that are equal but do not compare as == since
1140 they are different objects.
1141 Examples of classes which should generally
1142 not be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>
1143
1144
1145 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC: Suspicious reference comparison of Boolean values (RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN)</a></h3>
1146
1147
1148 <p> This method compares two Boolean values using the == or != operator.
1149 Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE),
1150 but it is possible to create other Boolean objects using the <code>new Boolean(b)</code>
1151 constructor. It is best to avoid such objects, but if they do exist,
1152 then checking Boolean objects for equality using == or != will give results
1153 than are different than you would get using <code>.equals(...)</code>
1154 </p>
1155
1156
1157 <h3><a name="RR_NOT_CHECKED">RR: Method ignores results of InputStream.read() (RR_NOT_CHECKED)</a></h3>
1158
1159
1160 <p> This method ignores the return value of one of the variants of
1161 <code>java.io.InputStream.read()</code> which can return multiple bytes.&nbsp;
1162 If the return value is not checked, the caller will not be able to correctly
1163 handle the case where fewer bytes were read than the caller requested.&nbsp;
1164 This is a particularly insidious kind of bug, because in many programs,
1165 reads from input streams usually do read the full amount of data requested,
1166 causing the program to fail only sporadically.</p>
1167
1168
1169 <h3><a name="SR_NOT_CHECKED">RR: Method ignores results of InputStream.skip() (SR_NOT_CHECKED)</a></h3>
1170
1171
1172 <p> This method ignores the return value of
1173 <code>java.io.InputStream.skip()</code> which can skip multiple bytes.&nbsp;
1174 If the return value is not checked, the caller will not be able to correctly
1175 handle the case where fewer bytes were skipped than the caller requested.&nbsp;
1176 This is a particularly insidious kind of bug, because in many programs,
1177 skips from input streams usually do skip the full amount of data requested,
1178 causing the program to fail only sporadically. With Buffered streams, however,
1179 skip() will only skip data in the buffer, and will routinely fail to skip the
1180 requested number of bytes.</p>
1181
1182
1183 <h3><a name="RV_NEGATING_RESULT_OF_COMPARETO">RV: Negating the result of compareTo()/compare() (RV_NEGATING_RESULT_OF_COMPARETO)</a></h3>
1184
1185
1186 <p> This code negatives the return value of a compareTo or compare method.
1187 This is a questionable or bad programming practice, since if the return
1188 value is Integer.MIN_VALUE, negating the return value won't
1189 negate the sign of the result. You can achieve the same intended result
1190 by reversing the order of the operands rather than by negating the results.
1191 </p>
1192
1193
1194 <h3><a name="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Method ignores exceptional return value (RV_RETURN_VALUE_IGNORED_BAD_PRACTICE)</a></h3>
1195
1196
1197 <p> This method returns a value that is not checked. The return value should be checked
1198 since it can indicate an unusual or unexpected function execution. For
1199 example, the <code>File.delete()</code> method returns false
1200 if the file could not be successfully deleted (rather than
1201 throwing an Exception).
1202 If you don't check the result, you won't notice if the method invocation
1203 signals unexpected behavior by returning an atypical return value.
1204 </p>
1205
1206
1207 <h3><a name="SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Static initializer creates instance before all static final fields assigned (SI_INSTANCE_BEFORE_FINALS_ASSIGNED)</a></h3>
1208
1209
1210 <p> The class's static initializer creates an instance of the class
1211 before all of the static final fields are assigned.</p>
1212
1213
1214 <h3><a name="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW: Certain swing methods needs to be invoked in Swing thread (SW_SWING_METHODS_INVOKED_IN_SWING_THREAD)</a></h3>
1215
1216
1217 <p>(<a href="http://web.archive.org/web/20090526170426/http://java.sun.com/developer/JDCTechTips/2003/tt1208.html">From JDC Tech Tip</a>): The Swing methods
1218 show(), setVisible(), and pack() will create the associated peer for the frame.
1219 With the creation of the peer, the system creates the event dispatch thread.
1220 This makes things problematic because the event dispatch thread could be notifying
1221 listeners while pack and validate are still processing. This situation could result in
1222 two threads going through the Swing component-based GUI -- it's a serious flaw that
1223 could result in deadlocks or other related threading issues. A pack call causes
1224 components to be realized. As they are being realized (that is, not necessarily
1225 visible), they could trigger listener notification on the event dispatch thread.</p>
1226
1227
1228
1229 <h3><a name="SE_BAD_FIELD">Se: Non-transient non-serializable instance field in serializable class (SE_BAD_FIELD)</a></h3>
1230
1231
1232 <p> This Serializable class defines a non-primitive instance field which is neither transient,
1233 Serializable, or <code>java.lang.Object</code>, and does not appear to implement
1234 the <code>Externalizable</code> interface or the
1235 <code>readObject()</code> and <code>writeObject()</code> methods.&nbsp;
1236 Objects of this class will not be deserialized correctly if a non-Serializable
1237 object is stored in this field.</p>
1238
1239
1240 <h3><a name="SE_BAD_FIELD_INNER_CLASS">Se: Non-serializable class has a serializable inner class (SE_BAD_FIELD_INNER_CLASS)</a></h3>
1241
1242
1243 <p> This Serializable class is an inner class of a non-serializable class.
1244 Thus, attempts to serialize it will also attempt to associate instance of the outer
1245 class with which it is associated, leading to a runtime error.
1246 </p>
1247 <p>If possible, making the inner class a static inner class should solve the
1248 problem. Making the outer class serializable might also work, but that would
1249 mean serializing an instance of the inner class would always also serialize the instance
1250 of the outer class, which it often not what you really want.
1251
1252
1253 <h3><a name="SE_BAD_FIELD_STORE">Se: Non-serializable value stored into instance field of a serializable class (SE_BAD_FIELD_STORE)</a></h3>
1254
1255
1256 <p> A non-serializable value is stored into a non-transient field
1257 of a serializable class.</p>
1258
1259
1260 <h3><a name="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Comparator doesn't implement Serializable (SE_COMPARATOR_SHOULD_BE_SERIALIZABLE)</a></h3>
1261
1262
1263 <p> This class implements the <code>Comparator</code> interface. You
1264 should consider whether or not it should also implement the <code>Serializable</code>
1265 interface. If a comparator is used to construct an ordered collection
1266 such as a <code>TreeMap</code>, then the <code>TreeMap</code>
1267 will be serializable only if the comparator is also serializable.
1268 As most comparators have little or no state, making them serializable
1269 is generally easy and good defensive programming.
1270 </p>
1271
1272
1273 <h3><a name="SE_INNER_CLASS">Se: Serializable inner class (SE_INNER_CLASS)</a></h3>
1274
1275
1276 <p> This Serializable class is an inner class. Any attempt to serialize
1277 it will also serialize the associated outer instance. The outer instance is serializable,
1278 so this won't fail, but it might serialize a lot more data than intended.
1279 If possible, making the inner class a static inner class (also known as a nested class) should solve the
1280 problem.
1281
1282
1283 <h3><a name="SE_NONFINAL_SERIALVERSIONID">Se: serialVersionUID isn't final (SE_NONFINAL_SERIALVERSIONID)</a></h3>
1284
1285
1286 <p> This class defines a <code>serialVersionUID</code> field that is not final.&nbsp;
1287 The field should be made final
1288 if it is intended to specify
1289 the version UID for purposes of serialization.</p>
1290
1291
1292 <h3><a name="SE_NONLONG_SERIALVERSIONID">Se: serialVersionUID isn't long (SE_NONLONG_SERIALVERSIONID)</a></h3>
1293
1294
1295 <p> This class defines a <code>serialVersionUID</code> field that is not long.&nbsp;
1296 The field should be made long
1297 if it is intended to specify
1298 the version UID for purposes of serialization.</p>
1299
1300
1301 <h3><a name="SE_NONSTATIC_SERIALVERSIONID">Se: serialVersionUID isn't static (SE_NONSTATIC_SERIALVERSIONID)</a></h3>
1302
1303
1304 <p> This class defines a <code>serialVersionUID</code> field that is not static.&nbsp;
1305 The field should be made static
1306 if it is intended to specify
1307 the version UID for purposes of serialization.</p>
1308
1309
1310 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR">Se: Class is Serializable but its superclass doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR)</a></h3>
1311
1312
1313 <p> This class implements the <code>Serializable</code> interface
1314 and its superclass does not. When such an object is deserialized,
1315 the fields of the superclass need to be initialized by
1316 invoking the void constructor of the superclass.
1317 Since the superclass does not have one,
1318 serialization and deserialization will fail at runtime.</p>
1319
1320
1321 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">Se: Class is Externalizable but doesn't define a void constructor (SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION)</a></h3>
1322
1323
1324 <p> This class implements the <code>Externalizable</code> interface, but does
1325 not define a void constructor. When Externalizable objects are deserialized,
1326 they first need to be constructed by invoking the void
1327 constructor. Since this class does not have one,
1328 serialization and deserialization will fail at runtime.</p>
1329
1330
1331 <h3><a name="SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: The readResolve method must be declared with a return type of Object. (SE_READ_RESOLVE_MUST_RETURN_OBJECT)</a></h3>
1332
1333
1334 <p> In order for the readResolve method to be recognized by the serialization
1335 mechanism, it must be declared to have a return type of Object.
1336 </p>
1337
1338
1339 <h3><a name="SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Transient field that isn't set by deserialization. (SE_TRANSIENT_FIELD_NOT_RESTORED)</a></h3>
1340
1341
1342 <p> This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any
1343 deserialized instance of the class.
1344 </p>
1345
1346
1347 <h3><a name="SE_NO_SERIALVERSIONID">SnVI: Class is Serializable, but doesn't define serialVersionUID (SE_NO_SERIALVERSIONID)</a></h3>
1348
1349
1350 <p> This class implements the <code>Serializable</code> interface, but does
1351 not define a <code>serialVersionUID</code> field.&nbsp;
1352 A change as simple as adding a reference to a .class object
1353 will add synthetic fields to the class,
1354 which will unfortunately change the implicit
1355 serialVersionUID (e.g., adding a reference to <code>String.class</code>
1356 will generate a static field <code>class$java$lang$String</code>).
1357 Also, different source code to bytecode compilers may use different
1358 naming conventions for synthetic variables generated for
1359 references to class objects or inner classes.
1360 To ensure interoperability of Serializable across versions,
1361 consider adding an explicit serialVersionUID.</p>
1362
1363
1364 <h3><a name="UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: Usage of GetResource may be unsafe if class is extended (UI_INHERITANCE_UNSAFE_GETRESOURCE)</a></h3>
1365
1366
1367 <p>Calling <code>this.getClass().getResource(...)</code> could give
1368 results other than expected if this class is extended by a class in
1369 another package.</p>
1370
1371
1372 <h3><a name="BC_IMPOSSIBLE_CAST">BC: Impossible cast (BC_IMPOSSIBLE_CAST)</a></h3>
1373
1374
1375 <p>
1376 This cast will always throw a ClassCastException.
1377 FindBugs tracks type information from instanceof checks,
1378 and also uses more precise information about the types
1379 of values returned from methods and loaded from fields.
1380 Thus, it may have more precise information that just
1381 the declared type of a variable, and can use this to determine
1382 that a cast will always throw an exception at runtime.
1383
1384 </p>
1385
1386
1387 <h3><a name="BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downcast (BC_IMPOSSIBLE_DOWNCAST)</a></h3>
1388
1389
1390 <p>
1391 This cast will always throw a ClassCastException.
1392 The analysis believes it knows
1393 the precise type of the value being cast, and the attempt to
1394 downcast it to a subtype will always fail by throwing a ClassCastException.
1395 </p>
1396
1397
1398 <h3><a name="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impossible downcast of toArray() result (BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY)</a></h3>
1399
1400
1401 <p>
1402 This code is casting the result of calling <code>toArray()</code> on a collection
1403 to a type more specific than <code>Object[]</code>, as in:</p>
1404 <pre>
1405 String[] getAsArray(Collection&lt;String&gt; c) {
1406 return (String[]) c.toArray();
1407 }
1408 </pre>
1409 <p>This will usually fail by throwing a ClassCastException. The <code>toArray()</code>
1410 of almost all collections return an <code>Object[]</code>. They can't really do anything else,
1411 since the Collection object has no reference to the declared generic type of the collection.
1412 <p>The correct way to do get an array of a specific type from a collection is to use
1413 <code>c.toArray(new String[]);</code>
1414 or <code>c.toArray(new String[c.size()]);</code> (the latter is slightly more efficient).
1415 <p>There is one common/known exception exception to this. The <code>toArray()</code>
1416 method of lists returned by <code>Arrays.asList(...)</code> will return a covariantly
1417 typed array. For example, <code>Arrays.asArray(new String[] { "a" }).toArray()</code>
1418 will return a <code>String []</code>. FindBugs attempts to detect and suppress
1419 such cases, but may miss some.
1420 </p>
1421
1422
1423 <h3><a name="BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof will always return false (BC_IMPOSSIBLE_INSTANCEOF)</a></h3>
1424
1425
1426 <p>
1427 This instanceof test will always return false. Although this is safe, make sure it isn't
1428 an indication of some misunderstanding or some other logic error.
1429 </p>
1430
1431
1432 <h3><a name="BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of signed byte value (BIT_ADD_OF_SIGNED_BYTE)</a></h3>
1433
1434
1435 <p> Adds a byte value and a value which is known to have the 8 lower bits clear.
1436 Values loaded from a byte array are sign extended to 32 bits
1437 before any any bitwise operations are performed on the value.
1438 Thus, if <code>b[0]</code> contains the value <code>0xff</code>, and
1439 <code>x</code> is initially 0, then the code
1440 <code>((x &lt;&lt; 8) + b[0])</code> will sign extend <code>0xff</code>
1441 to get <code>0xffffffff</code>, and thus give the value
1442 <code>0xffffffff</code> as the result.
1443 </p>
1444
1445 <p>In particular, the following code for packing a byte array into an int is badly wrong: </p>
1446 <pre>
1447 int result = 0;
1448 for(int i = 0; i &lt; 4; i++)
1449 result = ((result &lt;&lt; 8) + b[i]);
1450 </pre>
1451
1452 <p>The following idiom will work instead: </p>
1453 <pre>
1454 int result = 0;
1455 for(int i = 0; i &lt; 4; i++)
1456 result = ((result &lt;&lt; 8) + (b[i] &amp; 0xff));
1457 </pre>
1458
1459
1460
1461 <h3><a name="BIT_AND">BIT: Incompatible bit masks (BIT_AND)</a></h3>
1462
1463
1464 <p> This method compares an expression of the form (e &amp; C) to D,
1465 which will always compare unequal
1466 due to the specific values of constants C and D.
1467 This may indicate a logic error or typo.</p>
1468
1469
1470 <h3><a name="BIT_AND_ZZ">BIT: Check to see if ((...) & 0) == 0 (BIT_AND_ZZ)</a></h3>
1471
1472
1473 <p> This method compares an expression of the form (e &amp; 0) to 0,
1474 which will always compare equal.
1475 This may indicate a logic error or typo.</p>
1476
1477
1478 <h3><a name="BIT_IOR">BIT: Incompatible bit masks (BIT_IOR)</a></h3>
1479
1480
1481 <p> This method compares an expression of the form (e | C) to D.
1482 which will always compare unequal
1483 due to the specific values of constants C and D.
1484 This may indicate a logic error or typo.</p>
1485
1486 <p> Typically, this bug occurs because the code wants to perform
1487 a membership test in a bit set, but uses the bitwise OR
1488 operator ("|") instead of bitwise AND ("&amp;").</p>
1489
1490
1491 <h3><a name="BIT_IOR_OF_SIGNED_BYTE">BIT: Bitwise OR of signed byte value (BIT_IOR_OF_SIGNED_BYTE)</a></h3>
1492
1493
1494 <p> Loads a byte value (e.g., a value loaded from a byte array or returned by a method
1495 with return type byte) and performs a bitwise OR with
1496 that value. Byte values are sign extended to 32 bits
1497 before any any bitwise operations are performed on the value.
1498 Thus, if <code>b[0]</code> contains the value <code>0xff</code>, and
1499 <code>x</code> is initially 0, then the code
1500 <code>((x &lt;&lt; 8) | b[0])</code> will sign extend <code>0xff</code>
1501 to get <code>0xffffffff</code>, and thus give the value
1502 <code>0xffffffff</code> as the result.
1503 </p>
1504
1505 <p>In particular, the following code for packing a byte array into an int is badly wrong: </p>
1506 <pre>
1507 int result = 0;
1508 for(int i = 0; i &lt; 4; i++)
1509 result = ((result &lt;&lt; 8) | b[i]);
1510 </pre>
1511
1512 <p>The following idiom will work instead: </p>
1513 <pre>
1514 int result = 0;
1515 for(int i = 0; i &lt; 4; i++)
1516 result = ((result &lt;&lt; 8) | (b[i] &amp; 0xff));
1517 </pre>
1518
1519
1520
1521 <h3><a name="BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK_HIGH_BIT)</a></h3>
1522
1523
1524 <p> This method compares an expression such as</p>
1525 <pre>((event.detail &amp; SWT.SELECTED) &gt; 0)</pre>.
1526 <p>Using bit arithmetic and then comparing with the greater than operator can
1527 lead to unexpected results (of course depending on the value of
1528 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
1529 for a bug. Even when SWT.SELECTED is not negative, it seems good practice
1530 to use '!= 0' instead of '&gt; 0'.
1531 </p>
1532 <p>
1533 <em>Boris Bokowski</em>
1534 </p>
1535
1536
1537 <h3><a name="BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: Class overrides a method implemented in super class Adapter wrongly (BOA_BADLY_OVERRIDDEN_ADAPTER)</a></h3>
1538
1539
1540 <p> This method overrides a method found in a parent class, where that class is an Adapter that implements
1541 a listener defined in the java.awt.event or javax.swing.event package. As a result, this method will not
1542 get called when the event occurs.</p>
1543
1544
1545 <h3><a name="ICAST_BAD_SHIFT_AMOUNT">BSHIFT: 32 bit int shifted by an amount not in the range -31..31 (ICAST_BAD_SHIFT_AMOUNT)</a></h3>
1546
1547
1548 <p>
1549 The code performs shift of a 32 bit int by a constant amount outside
1550 the range -31..31.
1551 The effect of this is to use the lower 5 bits of the integer
1552 value to decide how much to shift by (e.g., shifting by 40 bits is the same as shifting by 8 bits,
1553 and shifting by 32 bits is the same as shifting by zero bits). This probably isn't what was expected,
1554 and it is at least confusing.
1555 </p>
1556
1557
1558 <h3><a name="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR">Bx: Primitive value is unboxed and coerced for ternary operator (BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR)</a></h3>
1559
1560
1561 <p>A wrapped primitive value is unboxed and converted to another primitive type as part of the
1562 evaluation of a conditional ternary operator (the <code> b ? e1 : e2</code> operator). The
1563 semantics of Java mandate that if <code>e1</code> and <code>e2</code> are wrapped
1564 numeric values, the values are unboxed and converted/coerced to their common type (e.g,
1565 if <code>e1</code> is of type <code>Integer</code>
1566 and <code>e2</code> is of type <code>Float</code>, then <code>e1</code> is unboxed,
1567 converted to a floating point value, and boxed. See JLS Section 15.25.
1568 </p>
1569
1570
1571 <h3><a name="CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareTo()/compare() returns Integer.MIN_VALUE (CO_COMPARETO_RESULTS_MIN_VALUE)</a></h3>
1572
1573
1574 <p> In some situation, this compareTo or compare method returns
1575 the constant Integer.MIN_VALUE, which is an exceptionally bad practice.
1576 The only thing that matters about the return value of compareTo is the sign of the result.
1577 But people will sometimes negate the return value of compareTo, expecting that this will negate
1578 the sign of the result. And it will, except in the case where the value returned is Integer.MIN_VALUE.
1579 So just return -1 rather than Integer.MIN_VALUE.
1580
1581
1582 <h3><a name="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Useless increment in return statement (DLS_DEAD_LOCAL_INCREMENT_IN_RETURN)</a></h3>
1583
1584
1585 <p>This statement has a return such as <code>return x++;</code>.
1586 A postfix increment/decrement does not impact the value of the expression,
1587 so this increment/decrement has no effect.
1588 Please verify that this statement does the right thing.
1589 </p>
1590
1591
1592 <h3><a name="DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead store of class literal (DLS_DEAD_STORE_OF_CLASS_LITERAL)</a></h3>
1593
1594
1595 <p>
1596 This instruction assigns a class literal to a variable and then never uses it.
1597 <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The behavior of this differs in Java 1.4 and in Java 5.</a>
1598 In Java 1.4 and earlier, a reference to <code>Foo.class</code> would force the static initializer
1599 for <code>Foo</code> to be executed, if it has not been executed already.
1600 In Java 5 and later, it does not.
1601 </p>
1602 <p>See Sun's <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">article on Java SE compatibility</a>
1603 for more details and examples, and suggestions on how to force class initialization in Java 5.
1604 </p>
1605
1606
1607 <h3><a name="DLS_OVERWRITTEN_INCREMENT">DLS: Overwritten increment (DLS_OVERWRITTEN_INCREMENT)</a></h3>
1608
1609
1610 <p>
1611 The code performs an increment operation (e.g., <code>i++</code>) and then
1612 immediately overwrites it. For example, <code>i = i++</code> immediately
1613 overwrites the incremented value with the original value.
1614 </p>
1615
1616
1617 <h3><a name="DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed method arguments (DMI_ARGUMENTS_WRONG_ORDER)</a></h3>
1618
1619
1620 <p> The arguments to this method call seem to be in the wrong order.
1621 For example, a call <code>Preconditions.checkNotNull("message", message)</code>
1622 has reserved arguments: the value to be checked is the first argument.
1623 </p>
1624
1625
1626 <h3><a name="DMI_BAD_MONTH">DMI: Bad constant value for month (DMI_BAD_MONTH)</a></h3>
1627
1628
1629 <p>
1630 This code passes a constant month
1631 value outside the expected range of 0..11 to a method.
1632 </p>
1633
1634
1635 <h3><a name="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI: BigDecimal constructed from double that isn't represented precisely (DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE)</a></h3>
1636
1637
1638 <p>
1639 This code creates a BigDecimal from a double value that doesn't translate well to a
1640 decimal number.
1641 For example, one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.
1642 You probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation
1643 of the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1).
1644 </p>
1645
1646
1647
1648 <h3><a name="DMI_CALLING_NEXT_FROM_HASNEXT">DMI: hasNext method invokes next (DMI_CALLING_NEXT_FROM_HASNEXT)</a></h3>
1649
1650
1651 <p>
1652 The hasNext() method invokes the next() method. This is almost certainly wrong,
1653 since the hasNext() method is not supposed to change the state of the iterator,
1654 and the next method is supposed to change the state of the iterator.
1655 </p>
1656
1657
1658 <h3><a name="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES">DMI: Collections should not contain themselves (DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES)</a></h3>
1659
1660
1661 <p> This call to a generic collection's method would only make sense if a collection contained
1662 itself (e.g., if <code>s.contains(s)</code> were true). This is unlikely to be true and would cause
1663 problems if it were true (such as the computation of the hash code resulting in infinite recursion).
1664 It is likely that the wrong value is being passed as a parameter.
1665 </p>
1666
1667
1668 <h3><a name="DMI_DOH">DMI: D'oh! A nonsensical method invocation (DMI_DOH)</a></h3>
1669
1670
1671 <p>
1672 This partical method invocation doesn't make sense, for reasons that should be apparent from inspection.
1673 </p>
1674
1675
1676
1677 <h3><a name="DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocation of hashCode on an array (DMI_INVOKING_HASHCODE_ON_ARRAY)</a></h3>
1678
1679
1680 <p>
1681 The code invokes hashCode on an array. Calling hashCode on
1682 an array returns the same value as System.identityHashCode, and ingores
1683 the contents and length of the array. If you need a hashCode that
1684 depends on the contents of an array <code>a</code>,
1685 use <code>java.util.Arrays.hashCode(a)</code>.
1686
1687 </p>
1688
1689
1690 <h3><a name="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI: Double.longBitsToDouble invoked on an int (DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT)</a></h3>
1691
1692
1693 <p> The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed
1694 as an argument. This almostly certainly is not intended and is unlikely
1695 to give the intended result.
1696 </p>
1697
1698
1699 <h3><a name="DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuous call to collections (DMI_VACUOUS_SELF_COLLECTION_CALL)</a></h3>
1700
1701
1702 <p> This call doesn't make sense. For any collection <code>c</code>, calling <code>c.containsAll(c)</code> should
1703 always be true, and <code>c.retainAll(c)</code> should have no effect.
1704 </p>
1705
1706
1707 <h3><a name="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">Dm: Can't use reflection to check for presence of annotation without runtime retention (DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION)</a></h3>
1708
1709
1710 <p> Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection
1711 (e.g., by using the isAnnotationPresent method).
1712 .</p>
1713
1714
1715 <h3><a name="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR">Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecutor (DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR)</a></h3>
1716
1717
1718 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html">Javadoc</a>)
1719 While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect.
1720 </p>
1721
1722
1723
1724 <h3><a name="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS">Dm: Creation of ScheduledThreadPoolExecutor with zero core threads (DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS)</a></h3>
1725
1726
1727 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html#ScheduledThreadPoolExecutor(int)">Javadoc</a>)
1728 A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.
1729 </p>
1730
1731
1732
1733 <h3><a name="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Useless/vacuous call to EasyMock method (DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD)</a></h3>
1734
1735
1736 <p>This call doesn't pass any objects to the EasyMock method, so the call doesn't do anything.
1737 </p>
1738
1739
1740
1741 <h3><a name="EC_ARRAY_AND_NONARRAY">EC: equals() used to compare array and nonarray (EC_ARRAY_AND_NONARRAY)</a></h3>
1742
1743
1744 <p>
1745 This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem
1746 to be an array. If things being compared are of different types, they are guaranteed to be unequal
1747 and the comparison is almost certainly an error. Even if they are both arrays, the equals method
1748 on arrays only determines of the two arrays are the same object.
1749 To compare the
1750 contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
1751 </p>
1752
1753
1754 <h3><a name="EC_BAD_ARRAY_COMPARE">EC: Invocation of equals() on an array, which is equivalent to == (EC_BAD_ARRAY_COMPARE)</a></h3>
1755
1756
1757 <p>
1758 This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals
1759 method of Object, calling equals on an array is the same as comparing their addresses. To compare the
1760 contents of the arrays, use <code>java.util.Arrays.equals(Object[], Object[])</code>.
1761 To compare the addresses of the arrays, it would be
1762 less confusing to explicitly check pointer equality using <code>==</code>.
1763 </p>
1764
1765
1766 <h3><a name="EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(...) used to compare incompatible arrays (EC_INCOMPATIBLE_ARRAY_COMPARE)</a></h3>
1767
1768
1769 <p>
1770 This method invokes the .equals(Object o) to compare two arrays, but the arrays of
1771 of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]).
1772 They will never be equal. In addition, when equals(...) is used to compare arrays it
1773 only checks to see if they are the same array, and ignores the contents of the arrays.
1774 </p>
1775
1776
1777 <h3><a name="EC_NULL_ARG">EC: Call to equals(null) (EC_NULL_ARG)</a></h3>
1778
1779
1780 <p> This method calls equals(Object), passing a null value as
1781 the argument. According to the contract of the equals() method,
1782 this call should always return <code>false</code>.</p>
1783
1784
1785 <h3><a name="EC_UNRELATED_CLASS_AND_INTERFACE">EC: Call to equals() comparing unrelated class and interface (EC_UNRELATED_CLASS_AND_INTERFACE)</a></h3>
1786
1787
1788 <p>
1789 This method calls equals(Object) on two references, one of which is a class
1790 and the other an interface, where neither the class nor any of its
1791 non-abstract subclasses implement the interface.
1792 Therefore, the objects being compared
1793 are unlikely to be members of the same class at runtime
1794 (unless some application classes were not analyzed, or dynamic class
1795 loading can occur at runtime).
1796 According to the contract of equals(),
1797 objects of different
1798 classes should always compare as unequal; therefore, according to the
1799 contract defined by java.lang.Object.equals(Object),
1800 the result of this comparison will always be false at runtime.
1801 </p>
1802
1803
1804 <h3><a name="EC_UNRELATED_INTERFACES">EC: Call to equals() comparing different interface types (EC_UNRELATED_INTERFACES)</a></h3>
1805
1806
1807 <p> This method calls equals(Object) on two references of unrelated
1808 interface types, where neither is a subtype of the other,
1809 and there are no known non-abstract classes which implement both interfaces.
1810 Therefore, the objects being compared
1811 are unlikely to be members of the same class at runtime
1812 (unless some application classes were not analyzed, or dynamic class
1813 loading can occur at runtime).
1814 According to the contract of equals(),
1815 objects of different
1816 classes should always compare as unequal; therefore, according to the
1817 contract defined by java.lang.Object.equals(Object),
1818 the result of this comparison will always be false at runtime.
1819 </p>
1820
1821
1822 <h3><a name="EC_UNRELATED_TYPES">EC: Call to equals() comparing different types (EC_UNRELATED_TYPES)</a></h3>
1823
1824
1825 <p> This method calls equals(Object) on two references of different
1826 class types with no common subclasses.
1827 Therefore, the objects being compared
1828 are unlikely to be members of the same class at runtime
1829 (unless some application classes were not analyzed, or dynamic class
1830 loading can occur at runtime).
1831 According to the contract of equals(),
1832 objects of different
1833 classes should always compare as unequal; therefore, according to the
1834 contract defined by java.lang.Object.equals(Object),
1835 the result of this comparison will always be false at runtime.
1836 </p>
1837
1838
1839 <h3><a name="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">EC: Using pointer equality to compare different types (EC_UNRELATED_TYPES_USING_POINTER_EQUALITY)</a></h3>
1840
1841
1842 <p> This method uses using pointer equality to compare two references that seem to be of
1843 different types. The result of this comparison will always be false at runtime.
1844 </p>
1845
1846
1847 <h3><a name="EQ_ALWAYS_FALSE">Eq: equals method always returns false (EQ_ALWAYS_FALSE)</a></h3>
1848
1849
1850 <p> This class defines an equals method that always returns false. This means that an object is not equal to itself, and it is impossible to create useful Maps or Sets of this class. More fundamentally, it means
1851 that equals is not reflexive, one of the requirements of the equals method.</p>
1852 <p>The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class <code>Object</code>. If you need to override an equals inherited from a different
1853 superclass, you can use use:</p>
1854 <pre>
1855 public boolean equals(Object o) { return this == o; }
1856 </pre>
1857
1858
1859 <h3><a name="EQ_ALWAYS_TRUE">Eq: equals method always returns true (EQ_ALWAYS_TRUE)</a></h3>
1860
1861
1862 <p> This class defines an equals method that always returns true. This is imaginative, but not very smart.
1863 Plus, it means that the equals method is not symmetric.
1864 </p>
1865
1866
1867 <h3><a name="EQ_COMPARING_CLASS_NAMES">Eq: equals method compares class names rather than class objects (EQ_COMPARING_CLASS_NAMES)</a></h3>
1868
1869
1870 <p> This method checks to see if two objects are the same class by checking to see if the names
1871 of their classes are equal. You can have different classes with the same name if they are loaded by
1872 different class loaders. Just check to see if the class objects are the same.
1873 </p>
1874
1875
1876 <h3><a name="EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covariant equals() method defined for enum (EQ_DONT_DEFINE_EQUALS_FOR_ENUM)</a></h3>
1877
1878
1879 <p> This class defines an enumeration, and equality on enumerations are defined
1880 using object identity. Defining a covariant equals method for an enumeration
1881 value is exceptionally bad practice, since it would likely result
1882 in having two different enumeration values that compare as equals using
1883 the covariant enum method, and as not equal when compared normally.
1884 Don't do it.
1885 </p>
1886
1887
1888 <h3><a name="EQ_OTHER_NO_OBJECT">Eq: equals() method defined that doesn't override equals(Object) (EQ_OTHER_NO_OBJECT)</a></h3>
1889
1890
1891 <p> This class defines an <code>equals()</code>
1892 method, that doesn't override the normal <code>equals(Object)</code> method
1893 defined in the base <code>java.lang.Object</code> class.&nbsp; Instead, it
1894 inherits an <code>equals(Object)</code> method from a superclass.
1895 The class should probably define a <code>boolean equals(Object)</code> method.
1896 </p>
1897
1898
1899 <h3><a name="EQ_OTHER_USE_OBJECT">Eq: equals() method defined that doesn't override Object.equals(Object) (EQ_OTHER_USE_OBJECT)</a></h3>
1900
1901
1902 <p> This class defines an <code>equals()</code>
1903 method, that doesn't override the normal <code>equals(Object)</code> method
1904 defined in the base <code>java.lang.Object</code> class.&nbsp;
1905 The class should probably define a <code>boolean equals(Object)</code> method.
1906 </p>
1907
1908
1909 <h3><a name="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equals method overrides equals in superclass and may not be symmetric (EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC)</a></h3>
1910
1911
1912 <p> This class defines an equals method that overrides an equals method in a superclass. Both equals methods
1913 methods use <code>instanceof</code> in the determination of whether two objects are equal. This is fraught with peril,
1914 since it is important that the equals method is symmetrical (in other words, <code>a.equals(b) == b.equals(a)</code>).
1915 If B is a subtype of A, and A's equals method checks that the argument is an instanceof A, and B's equals method
1916 checks that the argument is an instanceof B, it is quite likely that the equivalence relation defined by these
1917 methods is not symmetric.
1918 </p>
1919
1920
1921 <h3><a name="EQ_SELF_USE_OBJECT">Eq: Covariant equals() method defined, Object.equals(Object) inherited (EQ_SELF_USE_OBJECT)</a></h3>
1922
1923
1924 <p> This class defines a covariant version of the <code>equals()</code>
1925 method, but inherits the normal <code>equals(Object)</code> method
1926 defined in the base <code>java.lang.Object</code> class.&nbsp;
1927 The class should probably define a <code>boolean equals(Object)</code> method.
1928 </p>
1929
1930
1931 <h3><a name="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Doomed test for equality to NaN (FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER)</a></h3>
1932
1933
1934 <p>
1935 This code checks to see if a floating point value is equal to the special
1936 Not A Number value (e.g., <code>if (x == Double.NaN)</code>). However,
1937 because of the special semantics of <code>NaN</code>, no value
1938 is equal to <code>Nan</code>, including <code>NaN</code>. Thus,
1939 <code>x == Double.NaN</code> always evaluates to false.
1940
1941 To check to see if a value contained in <code>x</code>
1942 is the special Not A Number value, use
1943 <code>Double.isNaN(x)</code> (or <code>Float.isNaN(x)</code> if
1944 <code>x</code> is floating point precision).
1945 </p>
1946
1947
1948 <h3><a name="VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format string placeholder incompatible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)</a></h3>
1949
1950
1951 <p>
1952 The format string placeholder is incompatible with the corresponding
1953 argument. For example,
1954 <code>
1955 System.out.println("%d\n", "hello");
1956 </code>
1957 <p>The %d placeholder requires a numeric argument, but a string value is
1958 passed instead.
1959 A runtime exception will occur when
1960 this statement is executed.
1961 </p>
1962
1963
1964 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION">FS: The type of a supplied argument doesn't match format specifier (VA_FORMAT_STRING_BAD_CONVERSION)</a></h3>
1965
1966
1967 <p>
1968 One of the arguments is uncompatible with the corresponding format string specifier.
1969 As a result, this will generate a runtime exception when executed.
1970 For example, <code>String.format("%d", "1")</code> will generate an exception, since
1971 the String "1" is incompatible with the format specifier %d.
1972 </p>
1973
1974
1975 <h3><a name="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED">FS: MessageFormat supplied where printf style format expected (VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED)</a></h3>
1976
1977
1978 <p>
1979 A method is called that expects a Java printf format string and a list of arguments.
1980 However, the format string doesn't contain any format specifiers (e.g., %s) but
1981 does contain message format elements (e.g., {0}). It is likely
1982 that the code is supplying a MessageFormat string when a printf-style format string
1983 is required. At runtime, all of the arguments will be ignored
1984 and the format string will be returned exactly as provided without any formatting.
1985 </p>
1986
1987
1988 <h3><a name="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS: More arguments are passed than are actually used in the format string (VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED)</a></h3>
1989
1990
1991 <p>
1992 A format-string method with a variable number of arguments is called,
1993 but more arguments are passed than are actually used by the format string.
1994 This won't cause a runtime exception, but the code may be silently omitting
1995 information that was intended to be included in the formatted string.
1996 </p>
1997
1998
1999 <h3><a name="VA_FORMAT_STRING_ILLEGAL">FS: Illegal format string (VA_FORMAT_STRING_ILLEGAL)</a></h3>
2000
2001
2002 <p>
2003 The format string is syntactically invalid,
2004 and a runtime exception will occur when
2005 this statement is executed.
2006 </p>
2007
2008
2009 <h3><a name="VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Format string references missing argument (VA_FORMAT_STRING_MISSING_ARGUMENT)</a></h3>
2010
2011
2012 <p>
2013 Not enough arguments are passed to satisfy a placeholder in the format string.
2014 A runtime exception will occur when
2015 this statement is executed.
2016 </p>
2017
2018
2019 <h3><a name="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: No previous argument for format string (VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)</a></h3>
2020
2021
2022 <p>
2023 The format string specifies a relative index to request that the argument for the previous format specifier
2024 be reused. However, there is no previous argument.
2025 For example,
2026 </p>
2027 <p><code>formatter.format("%&lt;s %s", "a", "b")</code>
2028 </p>
2029 <p>would throw a MissingFormatArgumentException when executed.
2030 </p>
2031
2032
2033 <h3><a name="GC_UNRELATED_TYPES">GC: No relationship between generic parameter and method argument (GC_UNRELATED_TYPES)</a></h3>
2034
2035
2036 <p> This call to a generic collection method contains an argument
2037 with an incompatible class from that of the collection's parameter
2038 (i.e., the type of the argument is neither a supertype nor a subtype
2039 of the corresponding generic type argument).
2040 Therefore, it is unlikely that the collection contains any objects
2041 that are equal to the method argument used here.
2042 Most likely, the wrong value is being passed to the method.</p>
2043 <p>In general, instances of two unrelated classes are not equal.
2044 For example, if the <code>Foo</code> and <code>Bar</code> classes
2045 are not related by subtyping, then an instance of <code>Foo</code>
2046 should not be equal to an instance of <code>Bar</code>.
2047 Among other issues, doing so will likely result in an equals method
2048 that is not symmetrical. For example, if you define the <code>Foo</code> class
2049 so that a <code>Foo</code> can be equal to a <code>String</code>,
2050 your equals method isn't symmetrical since a <code>String</code> can only be equal
2051 to a <code>String</code>.
2052 </p>
2053 <p>In rare cases, people do define nonsymmetrical equals methods and still manage to make
2054 their code work. Although none of the APIs document or guarantee it, it is typically
2055 the case that if you check if a <code>Collection&lt;String&gt;</code> contains
2056 a <code>Foo</code>, the equals method of argument (e.g., the equals method of the
2057 <code>Foo</code> class) used to perform the equality checks.
2058 </p>
2059
2060
2061 <h3><a name="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS">HE: Signature declares use of unhashable class in hashed construct (HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS)</a></h3>
2062
2063
2064 <p> A method, field or class declares a generic signature where a non-hashable class
2065 is used in context where a hashable class is required.
2066 A class that declares an equals method but inherits a hashCode() method
2067 from Object is unhashable, since it doesn't fulfill the requirement that
2068 equal objects have equal hashCodes.
2069 </p>
2070
2071
2072 <h3><a name="HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class without a hashCode() method in a hashed data structure (HE_USE_OF_UNHASHABLE_CLASS)</a></h3>
2073
2074
2075 <p> A class defines an equals(Object) method but not a hashCode() method,
2076 and thus doesn't fulfill the requirement that equal objects have equal hashCodes.
2077 An instance of this class is used in a hash data structure, making the need to
2078 fix this problem of highest importance.
2079
2080
2081 <h3><a name="ICAST_INT_2_LONG_AS_INSTANT">ICAST: int value converted to long and used as absolute time (ICAST_INT_2_LONG_AS_INSTANT)</a></h3>
2082
2083
2084 <p>
2085 This code converts a 32-bit int value to a 64-bit long value, and then
2086 passes that value for a method parameter that requires an absolute time value.
2087 An absolute time value is the number
2088 of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
2089 For example, the following method, intended to convert seconds since the epoc into a Date, is badly
2090 broken:</p>
2091 <pre>
2092 Date getDate(int seconds) { return new Date(seconds * 1000); }
2093 </pre>
2094 <p>The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value.
2095 When a 32-bit value is converted to 64-bits and used to express an absolute time
2096 value, only dates in December 1969 and January 1970 can be represented.</p>
2097
2098 <p>Correct implementations for the above method are:</p>
2099
2100 <pre>
2101 // Fails for dates after 2037
2102 Date getDate(int seconds) { return new Date(seconds * 1000L); }
2103
2104 // better, works for all dates
2105 Date getDate(long seconds) { return new Date(seconds * 1000); }
2106 </pre>
2107
2108
2109 <h3><a name="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICAST: Integral value cast to double and then passed to Math.ceil (ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL)</a></h3>
2110
2111
2112 <p>
2113 This code converts an integral value (e.g., int or long)
2114 to a double precision
2115 floating point number and then
2116 passing the result to the Math.ceil() function, which rounds a double to
2117 the next higher integer value. This operation should always be a no-op,
2118 since the converting an integer to a double should give a number with no fractional part.
2119 It is likely that the operation that generated the value to be passed
2120 to Math.ceil was intended to be performed using double precision
2121 floating point arithmetic.
2122 </p>
2123
2124
2125
2126 <h3><a name="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICAST: int value cast to float and then passed to Math.round (ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND)</a></h3>
2127
2128
2129 <p>
2130 This code converts an int value to a float precision
2131 floating point number and then
2132 passing the result to the Math.round() function, which returns the int/long closest
2133 to the argument. This operation should always be a no-op,
2134 since the converting an integer to a float should give a number with no fractional part.
2135 It is likely that the operation that generated the value to be passed
2136 to Math.round was intended to be performed using
2137 floating point arithmetic.
2138 </p>
2139
2140
2141
2142 <h3><a name="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">IJU: JUnit assertion in run method will not be noticed by JUnit (IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD)</a></h3>
2143
2144
2145 <p> A JUnit assertion is performed in a run method. Failed JUnit assertions
2146 just result in exceptions being thrown.
2147 Thus, if this exception occurs in a thread other than the thread that invokes
2148 the test method, the exception will terminate the thread but not result
2149 in the test failing.
2150 </p>
2151
2152
2153 <h3><a name="IJU_BAD_SUITE_METHOD">IJU: TestCase declares a bad suite method (IJU_BAD_SUITE_METHOD)</a></h3>
2154
2155
2156 <p> Class is a JUnit TestCase and defines a suite() method.
2157 However, the suite method needs to be declared as either</p>
2158 <pre>public static junit.framework.Test suite()</pre>
2159 or
2160 <pre>public static junit.framework.TestSuite suite()</pre>
2161
2162
2163 <h3><a name="IJU_NO_TESTS">IJU: TestCase has no tests (IJU_NO_TESTS)</a></h3>
2164
2165
2166 <p> Class is a JUnit TestCase but has not implemented any test methods</p>
2167
2168
2169 <h3><a name="IJU_SETUP_NO_SUPER">IJU: TestCase defines setUp that doesn't call super.setUp() (IJU_SETUP_NO_SUPER)</a></h3>
2170
2171
2172 <p> Class is a JUnit TestCase and implements the setUp method. The setUp method should call
2173 super.setUp(), but doesn't.</p>
2174
2175
2176 <h3><a name="IJU_SUITE_NOT_STATIC">IJU: TestCase implements a non-static suite method (IJU_SUITE_NOT_STATIC)</a></h3>
2177
2178
2179 <p> Class is a JUnit TestCase and implements the suite() method.
2180 The suite method should be declared as being static, but isn't.</p>
2181
2182
2183 <h3><a name="IJU_TEARDOWN_NO_SUPER">IJU: TestCase defines tearDown that doesn't call super.tearDown() (IJU_TEARDOWN_NO_SUPER)</a></h3>
2184
2185
2186 <p> Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call
2187 super.tearDown(), but doesn't.</p>
2188
2189
2190 <h3><a name="IL_CONTAINER_ADDED_TO_ITSELF">IL: A collection is added to itself (IL_CONTAINER_ADDED_TO_ITSELF)</a></h3>
2191
2192
2193 <p>A collection is added to itself. As a result, computing the hashCode of this
2194 set will throw a StackOverflowException.
2195 </p>
2196
2197
2198 <h3><a name="IL_INFINITE_LOOP">IL: An apparent infinite loop (IL_INFINITE_LOOP)</a></h3>
2199
2200
2201 <p>This loop doesn't seem to have a way to terminate (other than by perhaps
2202 throwing an exception).</p>
2203
2204
2205 <h3><a name="IL_INFINITE_RECURSIVE_LOOP">IL: An apparent infinite recursive loop (IL_INFINITE_RECURSIVE_LOOP)</a></h3>
2206
2207
2208 <p>This method unconditionally invokes itself. This would seem to indicate
2209 an infinite recursive loop that will result in a stack overflow.</p>
2210
2211
2212 <h3><a name="IM_MULTIPLYING_RESULT_OF_IREM">IM: Integer multiply of result of integer remainder (IM_MULTIPLYING_RESULT_OF_IREM)</a></h3>
2213
2214
2215 <p>
2216 The code multiplies the result of an integer remaining by an integer constant.
2217 Be sure you don't have your operator precedence confused. For example
2218 i % 60 * 1000 is (i % 60) * 1000, not i % (60 * 1000).
2219 </p>
2220
2221
2222 <h3><a name="INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad comparison of int value with long constant (INT_BAD_COMPARISON_WITH_INT_VALUE)</a></h3>
2223
2224
2225 <p> This code compares an int value with a long constant that is outside
2226 the range of values that can be represented as an int value.
2227 This comparison is vacuous and possibily to be incorrect.
2228 </p>
2229
2230
2231 <h3><a name="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT: Bad comparison of nonnegative value with negative constant (INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE)</a></h3>
2232
2233
2234 <p> This code compares a value that is guaranteed to be non-negative with a negative constant.
2235 </p>
2236
2237
2238 <h3><a name="INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Bad comparison of signed byte (INT_BAD_COMPARISON_WITH_SIGNED_BYTE)</a></h3>
2239
2240
2241 <p> Signed bytes can only have a value in the range -128 to 127. Comparing
2242 a signed byte with a value outside that range is vacuous and likely to be incorrect.
2243 To convert a signed byte <code>b</code> to an unsigned value in the range 0..255,
2244 use <code>0xff &amp; b</code>
2245 </p>
2246
2247
2248 <h3><a name="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Doomed attempt to append to an object output stream (IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)</a></h3>
2249
2250
2251 <p>
2252 This code opens a file in append mode and then wraps the result in an object output stream.
2253 This won't allow you to append to an existing object output stream stored in a file. If you want to be
2254 able to append to an object output stream, you need to keep the object output stream open.
2255 </p>
2256 <p>The only situation in which opening a file in append mode and the writing an object output stream
2257 could work is if on reading the file you plan to open it in random access mode and seek to the byte offset
2258 where the append started.
2259 </p>
2260
2261 <p>
2262 TODO: example.
2263 </p>
2264
2265
2266 <h3><a name="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: A parameter is dead upon entry to a method but overwritten (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)</a></h3>
2267
2268
2269 <p>
2270 The initial value of this parameter is ignored, and the parameter
2271 is overwritten here. This often indicates a mistaken belief that
2272 the write to the parameter will be conveyed back to
2273 the caller.
2274 </p>
2275
2276
2277 <h3><a name="MF_CLASS_MASKS_FIELD">MF: Class defines field that masks a superclass field (MF_CLASS_MASKS_FIELD)</a></h3>
2278
2279
2280 <p> This class defines a field with the same name as a visible
2281 instance field in a superclass. This is confusing, and
2282 may indicate an error if methods update or access one of
2283 the fields when they wanted the other.</p>
2284
2285
2286 <h3><a name="MF_METHOD_MASKS_FIELD">MF: Method defines a variable that obscures a field (MF_METHOD_MASKS_FIELD)</a></h3>
2287
2288
2289 <p> This method defines a local variable with the same name as a field
2290 in this class or a superclass. This may cause the method to
2291 read an uninitialized value from the field, leave the field uninitialized,
2292 or both.</p>
2293
2294
2295 <h3><a name="NP_ALWAYS_NULL">NP: Null pointer dereference (NP_ALWAYS_NULL)</a></h3>
2296
2297
2298 <p> A null pointer is dereferenced here.&nbsp; This will lead to a
2299 <code>NullPointerException</code> when the code is executed.</p>
2300
2301
2302 <h3><a name="NP_ALWAYS_NULL_EXCEPTION">NP: Null pointer dereference in method on exception path (NP_ALWAYS_NULL_EXCEPTION)</a></h3>
2303
2304
2305 <p> A pointer which is null on an exception path is dereferenced here.&nbsp;
2306 This will lead to a <code>NullPointerException</code> when the code is executed.&nbsp;
2307 Note that because FindBugs currently does not prune infeasible exception paths,
2308 this may be a false warning.</p>
2309
2310 <p> Also note that FindBugs considers the default case of a switch statement to
2311 be an exception path, since the default case is often infeasible.</p>
2312
2313
2314 <h3><a name="NP_ARGUMENT_MIGHT_BE_NULL">NP: Method does not check for null argument (NP_ARGUMENT_MIGHT_BE_NULL)</a></h3>
2315
2316
2317 <p>
2318 A parameter to this method has been identified as a value that should
2319 always be checked to see whether or not it is null, but it is being dereferenced
2320 without a preceding null check.
2321 </p>
2322
2323
2324 <h3><a name="NP_CLOSING_NULL">NP: close() invoked on a value that is always null (NP_CLOSING_NULL)</a></h3>
2325
2326
2327 <p> close() is being invoked on a value that is always null. If this statement is executed,
2328 a null pointer exception will occur. But the big risk here you never close
2329 something that should be closed.
2330
2331
2332 <h3><a name="NP_GUARANTEED_DEREF">NP: Null value is guaranteed to be dereferenced (NP_GUARANTEED_DEREF)</a></h3>
2333
2334
2335 <p>
2336 There is a statement or branch that if executed guarantees that
2337 a value is null at this point, and that
2338 value that is guaranteed to be dereferenced
2339 (except on forward paths involving runtime exceptions).
2340 </p>
2341 <p>Note that a check such as
2342 <code>if (x == null) throw new NullPointerException();</code>
2343 is treated as a dereference of <code>x</code>.
2344
2345
2346 <h3><a name="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: Value is null and guaranteed to be dereferenced on exception path (NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH)</a></h3>
2347
2348
2349 <p>
2350 There is a statement or branch on an exception path
2351 that if executed guarantees that
2352 a value is null at this point, and that
2353 value that is guaranteed to be dereferenced
2354 (except on forward paths involving runtime exceptions).
2355 </p>
2356
2357
2358 <h3><a name="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP: Nonnull field is not initialized (NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3>
2359
2360
2361 <p> The field is marked as nonnull, but isn't written to by the constructor.
2362 The field might be initialized elsewhere during constructor, or might always
2363 be initialized before use.
2364 </p>
2365
2366
2367 <h3><a name="NP_NONNULL_PARAM_VIOLATION">NP: Method call passes null to a nonnull parameter (NP_NONNULL_PARAM_VIOLATION)</a></h3>
2368
2369
2370 <p>
2371 This method passes a null value as the parameter of a method which
2372 must be nonnull. Either this parameter has been explicitly marked
2373 as @Nonnull, or analysis has determined that this parameter is
2374 always dereferenced.
2375 </p>
2376
2377
2378 <h3><a name="NP_NONNULL_RETURN_VIOLATION">NP: Method may return null, but is declared @NonNull (NP_NONNULL_RETURN_VIOLATION)</a></h3>
2379
2380
2381 <p>
2382 This method may return a null value, but the method (or a superclass method
2383 which it overrides) is declared to return @NonNull.
2384 </p>
2385
2386
2387 <h3><a name="NP_NULL_INSTANCEOF">NP: A known null value is checked to see if it is an instance of a type (NP_NULL_INSTANCEOF)</a></h3>
2388
2389
2390 <p>
2391 This instanceof test will always return false, since the value being checked is guaranteed to be null.
2392 Although this is safe, make sure it isn't
2393 an indication of some misunderstanding or some other logic error.
2394 </p>
2395
2396
2397 <h3><a name="NP_NULL_ON_SOME_PATH">NP: Possible null pointer dereference (NP_NULL_ON_SOME_PATH)</a></h3>
2398
2399
2400 <p> There is a branch of statement that, <em>if executed,</em> guarantees that
2401 a null value will be dereferenced, which
2402 would generate a <code>NullPointerException</code> when the code is executed.
2403 Of course, the problem might be that the branch or statement is infeasible and that
2404 the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
2405 </p>
2406
2407
2408 <h3><a name="NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible null pointer dereference in method on exception path (NP_NULL_ON_SOME_PATH_EXCEPTION)</a></h3>
2409
2410
2411 <p> A reference value which is null on some exception control path is
2412 dereferenced here.&nbsp; This may lead to a <code>NullPointerException</code>
2413 when the code is executed.&nbsp;
2414 Note that because FindBugs currently does not prune infeasible exception paths,
2415 this may be a false warning.</p>
2416
2417 <p> Also note that FindBugs considers the default case of a switch statement to
2418 be an exception path, since the default case is often infeasible.</p>
2419
2420
2421 <h3><a name="NP_NULL_PARAM_DEREF">NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF)</a></h3>
2422
2423
2424 <p>
2425 This method call passes a null value for a nonnull method parameter.
2426 Either the parameter is annotated as a parameter that should
2427 always be nonnull, or analysis has shown that it will always be
2428 dereferenced.
2429 </p>
2430
2431
2432 <h3><a name="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP: Method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS)</a></h3>
2433
2434
2435 <p>
2436 A possibly-null value is passed at a call site where all known
2437 target methods require the parameter to be nonnull.
2438 Either the parameter is annotated as a parameter that should
2439 always be nonnull, or analysis has shown that it will always be
2440 dereferenced.
2441 </p>
2442
2443
2444 <h3><a name="NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Non-virtual method call passes null for nonnull parameter (NP_NULL_PARAM_DEREF_NONVIRTUAL)</a></h3>
2445
2446
2447 <p>
2448 A possibly-null value is passed to a nonnull method parameter.
2449 Either the parameter is annotated as a parameter that should
2450 always be nonnull, or analysis has shown that it will always be
2451 dereferenced.
2452 </p>
2453
2454
2455 <h3><a name="NP_STORE_INTO_NONNULL_FIELD">NP: Store of null value into field annotated NonNull (NP_STORE_INTO_NONNULL_FIELD)</a></h3>
2456
2457
2458 <p> A value that could be null is stored into a field that has been annotated as NonNull. </p>
2459
2460
2461 <h3><a name="NP_UNWRITTEN_FIELD">NP: Read of unwritten field (NP_UNWRITTEN_FIELD)</a></h3>
2462
2463
2464 <p> The program is dereferencing a field that does not seem to ever have a non-null value written to it.
2465 Unless the field is initialized via some mechanism not seen by the analysis,
2466 dereferencing this value will generate a null pointer exception.
2467 </p>
2468
2469
2470 <h3><a name="NM_BAD_EQUAL">Nm: Class defines equal(Object); should it be equals(Object)? (NM_BAD_EQUAL)</a></h3>
2471
2472
2473 <p> This class defines a method <code>equal(Object)</code>.&nbsp; This method does
2474 not override the <code>equals(Object)</code> method in <code>java.lang.Object</code>,
2475 which is probably what was intended.</p>
2476
2477
2478 <h3><a name="NM_LCASE_HASHCODE">Nm: Class defines hashcode(); should it be hashCode()? (NM_LCASE_HASHCODE)</a></h3>
2479
2480
2481 <p> This class defines a method called <code>hashcode()</code>.&nbsp; This method
2482 does not override the <code>hashCode()</code> method in <code>java.lang.Object</code>,
2483 which is probably what was intended.</p>
2484
2485
2486 <h3><a name="NM_LCASE_TOSTRING">Nm: Class defines tostring(); should it be toString()? (NM_LCASE_TOSTRING)</a></h3>
2487
2488
2489 <p> This class defines a method called <code>tostring()</code>.&nbsp; This method
2490 does not override the <code>toString()</code> method in <code>java.lang.Object</code>,
2491 which is probably what was intended.</p>
2492
2493
2494 <h3><a name="NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Apparent method/constructor confusion (NM_METHOD_CONSTRUCTOR_CONFUSION)</a></h3>
2495
2496
2497 <p> This regular method has the same name as the class it is defined in. It is likely that this was intended to be a constructor.
2498 If it was intended to be a constructor, remove the declaration of a void return value.
2499 If you had accidently defined this method, realized the mistake, defined a proper constructor
2500 but can't get rid of this method due to backwards compatibility, deprecate the method.
2501 </p>
2502
2503
2504 <h3><a name="NM_VERY_CONFUSING">Nm: Very confusing method names (NM_VERY_CONFUSING)</a></h3>
2505
2506
2507 <p> The referenced methods have names that differ only by capitalization.
2508 This is very confusing because if the capitalization were
2509 identical then one of the methods would override the other.
2510 </p>
2511
2512
2513 <h3><a name="NM_WRONG_PACKAGE">Nm: Method doesn't override method in superclass due to wrong package for parameter (NM_WRONG_PACKAGE)</a></h3>
2514
2515
2516 <p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match
2517 the type of the corresponding parameter in the superclass. For example, if you have:</p>
2518
2519 <blockquote>
2520 <pre>
2521 import alpha.Foo;
2522 public class A {
2523 public int f(Foo x) { return 17; }
2524 }
2525 ----
2526 import beta.Foo;
2527 public class B extends A {
2528 public int f(Foo x) { return 42; }
2529 }
2530 </pre>
2531 </blockquote>
2532
2533 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't
2534 override the
2535 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument
2536 types are <code>Foo</code>'s from different packages.
2537 </p>
2538
2539
2540 <h3><a name="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Method assigns boolean literal in boolean expression (QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT)</a></h3>
2541
2542
2543 <p>
2544 This method assigns a literal boolean value (true or false) to a boolean variable inside
2545 an if or while expression. Most probably this was supposed to be a boolean comparison using
2546 ==, not an assignment using =.
2547 </p>
2548
2549
2550 <h3><a name="RC_REF_COMPARISON">RC: Suspicious reference comparison (RC_REF_COMPARISON)</a></h3>
2551
2552
2553 <p> This method compares two reference values using the == or != operator,
2554 where the correct way to compare instances of this type is generally
2555 with the equals() method.
2556 It is possible to create distinct instances that are equal but do not compare as == since
2557 they are different objects.
2558 Examples of classes which should generally
2559 not be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>
2560
2561
2562 <h3><a name="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE">RCN: Nullcheck of value previously dereferenced (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE)</a></h3>
2563
2564
2565 <p> A value is checked here to see whether it is null, but this value can't
2566 be null because it was previously dereferenced and if it were null a null pointer
2567 exception would have occurred at the earlier dereference.
2568 Essentially, this code and the previous dereference
2569 disagree as to whether this value is allowed to be null. Either the check is redundant
2570 or the previous dereference is erroneous.</p>
2571
2572
2573 <h3><a name="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Invalid syntax for regular expression (RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION)</a></h3>
2574
2575
2576 <p>
2577 The code here uses a regular expression that is invalid according to the syntax
2578 for regular expressions. This statement will throw a PatternSyntaxException when
2579 executed.
2580 </p>
2581
2582
2583 <h3><a name="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION">RE: File.separator used for regular expression (RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION)</a></h3>
2584
2585
2586 <p>
2587 The code here uses <code>File.separator</code>
2588 where a regular expression is required. This will fail on Windows
2589 platforms, where the <code>File.separator</code> is a backslash, which is interpreted in a
2590 regular expression as an escape character. Amoung other options, you can just use
2591 <code>File.separatorChar=='\\' ? "\\\\" : File.separator</code> instead of
2592 <code>File.separator</code>
2593
2594 </p>
2595
2596
2597 <h3><a name="RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." or "|" used for regular expression (RE_POSSIBLE_UNINTENDED_PATTERN)</a></h3>
2598
2599
2600 <p>
2601 A String function is being invoked and "." or "|" is being passed
2602 to a parameter that takes a regular expression as an argument. Is this what you intended?
2603 For example
2604 <li>s.replaceAll(".", "/") will return a String in which <em>every</em> character has been replaced by a '/' character
2605 <li>s.split(".") <em>always</em> returns a zero length array of String
2606 <li>"ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/"
2607 <li>"ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d]
2608 </p>
2609
2610
2611 <h3><a name="RV_01_TO_INT">RV: Random value from 0 to 1 is coerced to the integer 0 (RV_01_TO_INT)</a></h3>
2612
2613
2614 <p>A random value from 0 to 1 is being coerced to the integer value 0. You probably
2615 want to multiple the random value by something else before coercing it to an integer, or use the <code>Random.nextInt(n)</code> method.
2616 </p>
2617
2618
2619 <h3><a name="RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attempt to compute absolute value of signed 32-bit hashcode (RV_ABSOLUTE_VALUE_OF_HASHCODE)</a></h3>
2620
2621
2622 <p> This code generates a hashcode and then computes
2623 the absolute value of that hashcode. If the hashcode
2624 is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
2625 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>).
2626 </p>
2627 <p>One out of 2^32 strings have a hashCode of Integer.MIN_VALUE,
2628 including "polygenelubricants" "GydZG_" and ""DESIGNING WORKHOUSES".
2629 </p>
2630
2631
2632 <h3><a name="RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad attempt to compute absolute value of signed random integer (RV_ABSOLUTE_VALUE_OF_RANDOM_INT)</a></h3>
2633
2634
2635 <p> This code generates a random signed integer and then computes
2636 the absolute value of that random integer. If the number returned by the random number
2637 generator is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since
2638 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>). (Same problem arised for long values as well).
2639 </p>
2640
2641
2642 <h3><a name="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV: Code checks for specific values returned by compareTo (RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE)</a></h3>
2643
2644
2645 <p> This code invoked a compareTo or compare method, and checks to see if the return value is a specific value,
2646 such as 1 or -1. When invoking these methods, you should only check the sign of the result, not for any specific
2647 non-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, some of them
2648 will return other values.
2649
2650
2651 <h3><a name="RV_EXCEPTION_NOT_THROWN">RV: Exception created and dropped rather than thrown (RV_EXCEPTION_NOT_THROWN)</a></h3>
2652
2653
2654 <p> This code creates an exception (or error) object, but doesn't do anything with it. For example,
2655 something like </p>
2656 <blockquote>
2657 <pre>
2658 if (x &lt; 0)
2659 new IllegalArgumentException("x must be nonnegative");
2660 </pre>
2661 </blockquote>
2662 <p>It was probably the intent of the programmer to throw the created exception:</p>
2663 <blockquote>
2664 <pre>
2665 if (x &lt; 0)
2666 throw new IllegalArgumentException("x must be nonnegative");
2667 </pre>
2668 </blockquote>
2669
2670
2671 <h3><a name="RV_RETURN_VALUE_IGNORED">RV: Method ignores return value (RV_RETURN_VALUE_IGNORED)</a></h3>
2672
2673
2674 <p> The return value of this method should be checked. One common
2675 cause of this warning is to invoke a method on an immutable object,
2676 thinking that it updates the object. For example, in the following code
2677 fragment,</p>
2678 <blockquote>
2679 <pre>
2680 String dateString = getHeaderField(name);
2681 dateString.trim();
2682 </pre>
2683 </blockquote>
2684 <p>the programmer seems to be thinking that the trim() method will update
2685 the String referenced by dateString. But since Strings are immutable, the trim()
2686 function returns a new String value, which is being ignored here. The code
2687 should be corrected to: </p>
2688 <blockquote>
2689 <pre>
2690 String dateString = getHeaderField(name);
2691 dateString = dateString.trim();
2692 </pre>
2693 </blockquote>
2694
2695
2696 <h3><a name="RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated conditional tests (RpC_REPEATED_CONDITIONAL_TEST)</a></h3>
2697
2698
2699 <p>The code contains a conditional test is performed twice, one right after the other
2700 (e.g., <code>x == 0 || x == 0</code>). Perhaps the second occurrence is intended to be something else
2701 (e.g., <code>x == 0 || y == 0</code>).
2702 </p>
2703
2704
2705 <h3><a name="SA_FIELD_SELF_ASSIGNMENT">SA: Self assignment of field (SA_FIELD_SELF_ASSIGNMENT)</a></h3>
2706
2707
2708 <p> This method contains a self assignment of a field; e.g.
2709 </p>
2710 <pre>
2711 int x;
2712 public void foo() {
2713 x = x;
2714 }
2715 </pre>
2716 <p>Such assignments are useless, and may indicate a logic error or typo.</p>
2717
2718
2719 <h3><a name="SA_FIELD_SELF_COMPARISON">SA: Self comparison of field with itself (SA_FIELD_SELF_COMPARISON)</a></h3>
2720
2721
2722 <p> This method compares a field with itself, and may indicate a typo or
2723 a logic error. Make sure that you are comparing the right things.
2724 </p>
2725
2726
2727 <h3><a name="SA_FIELD_SELF_COMPUTATION">SA: Nonsensical self computation involving a field (e.g., x & x) (SA_FIELD_SELF_COMPUTATION)</a></h3>
2728
2729
2730 <p> This method performs a nonsensical computation of a field with another
2731 reference to the same field (e.g., x&x or x-x). Because of the nature
2732 of the computation, this operation doesn't seem to make sense,
2733 and may indicate a typo or
2734 a logic error. Double check the computation.
2735 </p>
2736
2737
2738 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA: Self assignment of local rather than assignment to field (SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD)</a></h3>
2739
2740
2741 <p> This method contains a self assignment of a local variable, and there
2742 is a field with an identical name.
2743 assignment appears to have been ; e.g.</p>
2744 <pre>
2745 int foo;
2746 public void setFoo(int foo) {
2747 foo = foo;
2748 }
2749 </pre>
2750 <p>The assignment is useless. Did you mean to assign to the field instead?</p>
2751
2752
2753 <h3><a name="SA_LOCAL_SELF_COMPARISON">SA: Self comparison of value with itself (SA_LOCAL_SELF_COMPARISON)</a></h3>
2754
2755
2756 <p> This method compares a local variable with itself, and may indicate a typo or
2757 a logic error. Make sure that you are comparing the right things.
2758 </p>
2759
2760
2761 <h3><a name="SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical self computation involving a variable (e.g., x & x) (SA_LOCAL_SELF_COMPUTATION)</a></h3>
2762
2763
2764 <p> This method performs a nonsensical computation of a local variable with another
2765 reference to the same variable (e.g., x&x or x-x). Because of the nature
2766 of the computation, this operation doesn't seem to make sense,
2767 and may indicate a typo or
2768 a logic error. Double check the computation.
2769 </p>
2770
2771
2772 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF: Dead store due to switch statement fall through (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH)</a></h3>
2773
2774
2775 <p> A value stored in the previous switch case is overwritten here due to a switch fall through. It is likely that
2776 you forgot to put a break or return at the end of the previous case.
2777 </p>
2778
2779
2780 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW">SF: Dead store due to switch statement fall through to throw (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW)</a></h3>
2781
2782
2783 <p> A value stored in the previous switch case is ignored here due to a switch fall through to a place where
2784 an exception is thrown. It is likely that
2785 you forgot to put a break or return at the end of the previous case.
2786 </p>
2787
2788
2789 <h3><a name="SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly embrace of non-static inner class and thread local (SIC_THREADLOCAL_DEADLY_EMBRACE)</a></h3>
2790
2791
2792 <p> This class is an inner class, but should probably be a static inner class.
2793 As it is, there is a serious danger of a deadly embrace between the inner class
2794 and the thread local in the outer class. Because the inner class isn't static,
2795 it retains a reference to the outer class.
2796 If the thread local contains a reference to an instance of the inner
2797 class, the inner and outer instance will both be reachable
2798 and not eligible for garbage collection.
2799 </p>
2800
2801
2802 <h3><a name="SIO_SUPERFLUOUS_INSTANCEOF">SIO: Unnecessary type check done using instanceof operator (SIO_SUPERFLUOUS_INSTANCEOF)</a></h3>
2803
2804
2805 <p> Type check performed using the instanceof operator where it can be statically determined whether the object
2806 is of the type requested. </p>
2807
2808
2809 <h3><a name="SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Method attempts to access a prepared statement parameter with index 0 (SQL_BAD_PREPARED_STATEMENT_ACCESS)</a></h3>
2810
2811
2812 <p> A call to a setXXX method of a prepared statement was made where the
2813 parameter index is 0. As parameter indexes start at index 1, this is always a mistake.</p>
2814
2815
2816 <h3><a name="SQL_BAD_RESULTSET_ACCESS">SQL: Method attempts to access a result set field with index 0 (SQL_BAD_RESULTSET_ACCESS)</a></h3>
2817
2818
2819 <p> A call to getXXX or updateXXX methods of a result set was made where the
2820 field index is 0. As ResultSet fields start at index 1, this is always a mistake.</p>
2821
2822
2823 <h3><a name="STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Unneeded use of currentThread() call, to call interrupted() (STI_INTERRUPTED_ON_CURRENTTHREAD)</a></h3>
2824
2825
2826 <p>
2827 This method invokes the Thread.currentThread() call, just to call the interrupted() method. As interrupted() is a
2828 static method, is more simple and clear to use Thread.interrupted().
2829 </p>
2830
2831
2832 <h3><a name="STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Static Thread.interrupted() method invoked on thread instance (STI_INTERRUPTED_ON_UNKNOWNTHREAD)</a></h3>
2833
2834
2835 <p>
2836 This method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is
2837 not the current thread. As the interrupted() method is static, the interrupted method will be called on a different
2838 object than the one the author intended.
2839 </p>
2840
2841
2842 <h3><a name="SE_METHOD_MUST_BE_PRIVATE">Se: Method must be private in order for serialization to work (SE_METHOD_MUST_BE_PRIVATE)</a></h3>
2843
2844
2845 <p> This class implements the <code>Serializable</code> interface, and defines a method
2846 for custom serialization/deserialization. But since that method isn't declared private,
2847 it will be silently ignored by the serialization/deserialization API.</p>
2848
2849
2850 <h3><a name="SE_READ_RESOLVE_IS_STATIC">Se: The readResolve method must not be declared as a static method. (SE_READ_RESOLVE_IS_STATIC)</a></h3>
2851
2852
2853 <p> In order for the readResolve method to be recognized by the serialization
2854 mechanism, it must not be declared as a static method.
2855 </p>
2856
2857
2858 <h3><a name="TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">TQ: Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required (TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED)</a></h3>
2859
2860
2861 <p>
2862 A value specified as carrying a type qualifier annotation is
2863 consumed in a location or locations requiring that the value not
2864 carry that annotation.
2865 </p>
2866
2867 <p>
2868 More precisely, a value annotated with a type qualifier specifying when=ALWAYS
2869 is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER.
2870 </p>
2871
2872 <p>
2873 For example, say that @NonNegative is a nickname for
2874 the type qualifier annotation @Negative(when=When.NEVER).
2875 The following code will generate this warning because
2876 the return statement requires a @NonNegative value,
2877 but receives one that is marked as @Negative.
2878 </p>
2879 <blockquote>
2880 <pre>
2881 public @NonNegative Integer example(@Negative Integer value) {
2882 return value;
2883 }
2884 </pre>
2885 </blockquote>
2886
2887
2888 <h3><a name="TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ: Comparing values with incompatible type qualifiers (TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS)</a></h3>
2889
2890
2891 <p>
2892 A value specified as carrying a type qualifier annotation is
2893 compared with a value that doesn't ever carry that qualifier.
2894 </p>
2895
2896 <p>
2897 More precisely, a value annotated with a type qualifier specifying when=ALWAYS
2898 is compared with a value that where the same type qualifier specifies when=NEVER.
2899 </p>
2900
2901 <p>
2902 For example, say that @NonNegative is a nickname for
2903 the type qualifier annotation @Negative(when=When.NEVER).
2904 The following code will generate this warning because
2905 the return statement requires a @NonNegative value,
2906 but receives one that is marked as @Negative.
2907 </p>
2908 <blockquote>
2909 <pre>
2910 public boolean example(@Negative Integer value1, @NonNegative Integer value2) {
2911 return value1.equals(value2);
2912 }
2913 </pre>
2914 </blockquote>
2915
2916
2917 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value that might not carry a type qualifier is always used in a way requires that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK)</a></h3>
2918
2919
2920 <p>
2921 A value that is annotated as possibility not being an instance of
2922 the values denoted by the type qualifier, and the value is guaranteed to be used
2923 in a way that requires values denoted by that type qualifier.
2924 </p>
2925
2926
2927 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK)</a></h3>
2928
2929
2930 <p>
2931 A value that is annotated as possibility being an instance of
2932 the values denoted by the type qualifier, and the value is guaranteed to be used
2933 in a way that prohibits values denoted by that type qualifier.
2934 </p>
2935
2936
2937 <h3><a name="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">TQ: Value annotated as never carrying a type qualifier used where value carrying that qualifier is required (TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED)</a></h3>
2938
2939
2940 <p>
2941 A value specified as not carrying a type qualifier annotation is guaranteed
2942 to be consumed in a location or locations requiring that the value does
2943 carry that annotation.
2944 </p>
2945
2946 <p>
2947 More precisely, a value annotated with a type qualifier specifying when=NEVER
2948 is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS.
2949 </p>
2950
2951 <p>
2952 TODO: example
2953 </p>
2954
2955
2956 <h3><a name="TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ: Value without a type qualifier used where a value is required to have that qualifier (TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED)</a></h3>
2957
2958
2959 <p>
2960 A value is being used in a way that requires the value be annotation with a type qualifier.
2961 The type qualifier is strict, so the tool rejects any values that do not have
2962 the appropriate annotation.
2963 </p>
2964
2965 <p>
2966 To coerce a value to have a strict annotation, define an identity function where the return value is annotated
2967 with the strict annotation.
2968 This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.
2969 </p>
2970
2971
2972
2973 <h3><a name="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">UMAC: Uncallable method defined in anonymous class (UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS)</a></h3>
2974
2975
2976 <p> This anonymous class defined a method that is not directly invoked and does not override
2977 a method in a superclass. Since methods in other classes cannot directly invoke methods
2978 declared in an anonymous class, it seems that this method is uncallable. The method
2979 might simply be dead code, but it is also possible that the method is intended to
2980 override a method declared in a superclass, and due to an typo or other error the method does not,
2981 in fact, override the method it is intended to.
2982 </p>
2983
2984
2985 <h3><a name="UR_UNINIT_READ">UR: Uninitialized read of field in constructor (UR_UNINIT_READ)</a></h3>
2986
2987
2988 <p> This constructor reads a field which has not yet been assigned a value.&nbsp;
2989 This is often caused when the programmer mistakenly uses the field instead
2990 of one of the constructor's parameters.</p>
2991
2992
2993 <h3><a name="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR">UR: Uninitialized read of field method called from constructor of superclass (UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR)</a></h3>
2994
2995
2996 <p> This method is invoked in the constructor of of the superclass. At this point,
2997 the fields of the class have not yet initialized.</p>
2998 <p>To make this more concrete, consider the following classes:</p>
2999 <pre>abstract class A {
3000 int hashCode;
3001 abstract Object getValue();
3002 A() {
3003 hashCode = getValue().hashCode();
3004 }
3005 }
3006 class B extends A {
3007 Object value;
3008 B(Object v) {
3009 this.value = v;
3010 }
3011 Object getValue() {
3012 return value;
3013 }
3014 }</pre>
3015 <p>When a <code>B</code> is constructed,
3016 the constructor for the <code>A</code> class is invoked
3017 <em>before</em> the constructor for <code>B</code> sets <code>value</code>.
3018 Thus, when the constructor for <code>A</code> invokes <code>getValue</code>,
3019 an uninitialized value is read for <code>value</code>
3020 </p>
3021
3022
3023 <h3><a name="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">USELESS_STRING: Invocation of toString on an unnamed array (DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY)</a></h3>
3024
3025
3026 <p>
3027 The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result
3028 such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable
3029 String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
3030 </p>
3031
3032
3033 <h3><a name="DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRING: Invocation of toString on an array (DMI_INVOKING_TOSTRING_ON_ARRAY)</a></h3>
3034
3035
3036 <p>
3037 The code invokes toString on an array, which will generate a fairly useless result
3038 such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable
3039 String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
3040 </p>
3041
3042
3043 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">USELESS_STRING: Array formatted in useless way using format string (VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY)</a></h3>
3044
3045
3046 <p>
3047 One of the arguments being formatted with a format string is an array. This will be formatted
3048 using a fairly useless format, such as [I@304282, which doesn't actually show the contents
3049 of the array.
3050 Consider wrapping the array using <code>Arrays.asList(...)</code> before handling it off to a formatted.
3051 </p>
3052
3053
3054 <h3><a name="UWF_NULL_FIELD">UwF: Field only ever set to null (UWF_NULL_FIELD)</a></h3>
3055
3056
3057 <p> All writes to this field are of the constant value null, and thus
3058 all reads of the field will return null.
3059 Check for errors, or remove it if it is useless.</p>
3060
3061
3062 <h3><a name="UWF_UNWRITTEN_FIELD">UwF: Unwritten field (UWF_UNWRITTEN_FIELD)</a></h3>
3063
3064
3065 <p> This field is never written.&nbsp; All reads of it will return the default
3066 value. Check for errors (should it have been initialized?), or remove it if it is useless.</p>
3067
3068
3069 <h3><a name="VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">VA: Primitive array passed to function expecting a variable number of object arguments (VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG)</a></h3>
3070
3071
3072 <p>
3073 This code passes a primitive array to a function that takes a variable number of object arguments.
3074 This creates an array of length one to hold the primitive array and passes it to the function.
3075 </p>
3076
3077
3078 <h3><a name="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Potential lost logger changes due to weak reference in OpenJDK (LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE)</a></h3>
3079
3080
3081 <p>OpenJDK introduces a potential incompatibility.
3082 In particular, the java.util.logging.Logger behavior has
3083 changed. Instead of using strong references, it now uses weak references
3084 internally. That's a reasonable change, but unfortunately some code relies on
3085 the old behavior - when changing logger configuration, it simply drops the
3086 logger reference. That means that the garbage collector is free to reclaim
3087 that memory, which means that the logger configuration is lost. For example,
3088 consider:
3089 </p>
3090
3091 <pre>public static void initLogging() throws Exception {
3092 Logger logger = Logger.getLogger("edu.umd.cs");
3093 logger.addHandler(new FileHandler()); // call to change logger configuration
3094 logger.setUseParentHandlers(false); // another call to change logger configuration
3095 }</pre>
3096
3097 <p>The logger reference is lost at the end of the method (it doesn't
3098 escape the method), so if you have a garbage collection cycle just
3099 after the call to initLogging, the logger configuration is lost
3100 (because Logger only keeps weak references).</p>
3101
3102 <pre>public static void main(String[] args) throws Exception {
3103 initLogging(); // adds a file handler to the logger
3104 System.gc(); // logger configuration lost
3105 Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected
3106 }</pre>
3107 <p><em>Ulf Ochsenfahrt and Eric Fellheimer</em></p>
3108
3109
3110 <h3><a name="OBL_UNSATISFIED_OBLIGATION">OBL: Method may fail to clean up stream or resource (OBL_UNSATISFIED_OBLIGATION)</a></h3>
3111
3112
3113 <p>
3114 This method may fail to clean up (close, dispose of) a stream,
3115 database object, or other
3116 resource requiring an explicit cleanup operation.
3117 </p>
3118
3119 <p>
3120 In general, if a method opens a stream or other resource,
3121 the method should use a try/finally block to ensure that
3122 the stream or resource is cleaned up before the method
3123 returns.
3124 </p>
3125
3126 <p>
3127 This bug pattern is essentially the same as the
3128 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE
3129 bug patterns, but is based on a different
3130 (and hopefully better) static analysis technique.
3131 We are interested is getting feedback about the
3132 usefulness of this bug pattern.
3133 To send feedback, either:
3134 </p>
3135 <ul>
3136 <li>send email to findbugs@cs.umd.edu</li>
3137 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
3138 </ul>
3139
3140 <p>
3141 In particular,
3142 the false-positive suppression heuristics for this
3143 bug pattern have not been extensively tuned, so
3144 reports about false positives are helpful to us.
3145 </p>
3146
3147 <p>
3148 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for
3149 a description of the analysis technique.
3150 </p>
3151
3152
3153 <h3><a name="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL: Method may fail to clean up stream or resource on checked exception (OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE)</a></h3>
3154
3155
3156 <p>
3157 This method may fail to clean up (close, dispose of) a stream,
3158 database object, or other
3159 resource requiring an explicit cleanup operation.
3160 </p>
3161
3162 <p>
3163 In general, if a method opens a stream or other resource,
3164 the method should use a try/finally block to ensure that
3165 the stream or resource is cleaned up before the method
3166 returns.
3167 </p>
3168
3169 <p>
3170 This bug pattern is essentially the same as the
3171 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE
3172 bug patterns, but is based on a different
3173 (and hopefully better) static analysis technique.
3174 We are interested is getting feedback about the
3175 usefulness of this bug pattern.
3176 To send feedback, either:
3177 </p>
3178 <ul>
3179 <li>send email to findbugs@cs.umd.edu</li>
3180 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
3181 </ul>
3182
3183 <p>
3184 In particular,
3185 the false-positive suppression heuristics for this
3186 bug pattern have not been extensively tuned, so
3187 reports about false positives are helpful to us.
3188 </p>
3189
3190 <p>
3191 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for
3192 a description of the analysis technique.
3193 </p>
3194
3195
3196 <h3><a name="DM_CONVERT_CASE">Dm: Consider using Locale parameterized version of invoked method (DM_CONVERT_CASE)</a></h3>
3197
3198
3199 <p> A String is being converted to upper or lowercase, using the platform's default encoding. This may
3200 result in improper conversions when used with international characters. Use the </p>
3201 <ul>
3202 <li>String.toUpperCase( Locale l )</li>
3203 <li>String.toLowerCase( Locale l )</li>
3204 </ul>
3205 <p>versions instead.</p>
3206
3207
3208 <h3><a name="DM_DEFAULT_ENCODING">Dm: Reliance on default encoding (DM_DEFAULT_ENCODING)</a></h3>
3209
3210
3211 <p> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. </p>
3212
3213
3214 <h3><a name="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">DP: Classloaders should only be created inside doPrivileged block (DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED)</a></h3>
3215
3216
3217 <p> This code creates a classloader, which needs permission if a security manage is installed.
3218 If this code might be invoked by code that does not
3219 have security permissions, then the classloader creation needs to occur inside a doPrivileged block.</p>
3220
3221
3222 <h3><a name="DP_DO_INSIDE_DO_PRIVILEGED">DP: Method invoked that should be only be invoked inside a doPrivileged block (DP_DO_INSIDE_DO_PRIVILEGED)</a></h3>
3223
3224
3225 <p> This code invokes a method that requires a security permission check.
3226 If this code will be granted security permissions, but might be invoked by code that does not
3227 have security permissions, then the invocation needs to occur inside a doPrivileged block.</p>
3228
3229
3230 <h3><a name="EI_EXPOSE_REP">EI: May expose internal representation by returning reference to mutable object (EI_EXPOSE_REP)</a></h3>
3231
3232
3233 <p> Returning a reference to a mutable object value stored in one of the object's fields
3234 exposes the internal representation of the object.&nbsp;
3235 If instances
3236 are accessed by untrusted code, and unchecked changes to
3237 the mutable object would compromise security or other
3238 important properties, you will need to do something different.
3239 Returning a new copy of the object is better approach in many situations.</p>
3240
3241
3242 <h3><a name="EI_EXPOSE_REP2">EI2: May expose internal representation by incorporating reference to mutable object (EI_EXPOSE_REP2)</a></h3>
3243
3244
3245 <p> This code stores a reference to an externally mutable object into the
3246 internal representation of the object.&nbsp;
3247 If instances
3248 are accessed by untrusted code, and unchecked changes to
3249 the mutable object would compromise security or other
3250 important properties, you will need to do something different.
3251 Storing a copy of the object is better approach in many situations.</p>
3252
3253
3254 <h3><a name="FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Finalizer should be protected, not public (FI_PUBLIC_SHOULD_BE_PROTECTED)</a></h3>
3255
3256
3257 <p> A class's <code>finalize()</code> method should have protected access,
3258 not public.</p>
3259
3260
3261 <h3><a name="EI_EXPOSE_STATIC_REP2">MS: May expose internal static state by storing a mutable object into a static field (EI_EXPOSE_STATIC_REP2)</a></h3>
3262
3263
3264 <p> This code stores a reference to an externally mutable object into a static
3265 field.
3266 If unchecked changes to
3267 the mutable object would compromise security or other
3268 important properties, you will need to do something different.
3269 Storing a copy of the object is better approach in many situations.</p>
3270
3271
3272 <h3><a name="MS_CANNOT_BE_FINAL">MS: Field isn't final and can't be protected from malicious code (MS_CANNOT_BE_FINAL)</a></h3>
3273
3274
3275 <p>
3276 A mutable static field could be changed by malicious code or
3277 by accident from another package.
3278 Unfortunately, the way the field is used doesn't allow
3279 any easy fix to this problem.</p>
3280
3281
3282 <h3><a name="MS_EXPOSE_REP">MS: Public static method may expose internal representation by returning array (MS_EXPOSE_REP)</a></h3>
3283
3284
3285 <p> A public static method returns a reference to
3286 an array that is part of the static state of the class.
3287 Any code that calls this method can freely modify
3288 the underlying array.
3289 One fix is to return a copy of the array.</p>
3290
3291
3292 <h3><a name="MS_FINAL_PKGPROTECT">MS: Field should be both final and package protected (MS_FINAL_PKGPROTECT)</a></h3>
3293
3294
3295 <p>
3296 A mutable static field could be changed by malicious code or
3297 by accident from another package.
3298 The field could be made package protected and/or made final
3299 to avoid
3300 this vulnerability.</p>
3301
3302
3303 <h3><a name="MS_MUTABLE_ARRAY">MS: Field is a mutable array (MS_MUTABLE_ARRAY)</a></h3>
3304
3305
3306 <p> A final static field references an array
3307 and can be accessed by malicious code or
3308 by accident from another package.
3309 This code can freely modify the contents of the array.</p>
3310
3311
3312 <h3><a name="MS_MUTABLE_HASHTABLE">MS: Field is a mutable Hashtable (MS_MUTABLE_HASHTABLE)</a></h3>
3313
3314
3315 <p>A final static field references a Hashtable
3316 and can be accessed by malicious code or
3317 by accident from another package.
3318 This code can freely modify the contents of the Hashtable.</p>
3319
3320
3321 <h3><a name="MS_OOI_PKGPROTECT">MS: Field should be moved out of an interface and made package protected (MS_OOI_PKGPROTECT)</a></h3>
3322
3323
3324 <p>
3325 A final static field that is
3326 defined in an interface references a mutable
3327 object such as an array or hashtable.
3328 This mutable object could
3329 be changed by malicious code or
3330 by accident from another package.
3331 To solve this, the field needs to be moved to a class
3332 and made package protected
3333 to avoid
3334 this vulnerability.</p>
3335
3336
3337 <h3><a name="MS_PKGPROTECT">MS: Field should be package protected (MS_PKGPROTECT)</a></h3>
3338
3339
3340 <p> A mutable static field could be changed by malicious code or
3341 by accident.
3342 The field could be made package protected to avoid
3343 this vulnerability.</p>
3344
3345
3346 <h3><a name="MS_SHOULD_BE_FINAL">MS: Field isn't final but should be (MS_SHOULD_BE_FINAL)</a></h3>
3347
3348
3349 <p>
3350 This static field public but not final, and
3351 could be changed by malicious code or
3352 by accident from another package.
3353 The field could be made final to avoid
3354 this vulnerability.</p>
3355
3356
3357 <h3><a name="MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Field isn't final but should be refactored to be so (MS_SHOULD_BE_REFACTORED_TO_BE_FINAL)</a></h3>
3358
3359
3360 <p>
3361 This static field public but not final, and
3362 could be changed by malicious code or
3363 by accident from another package.
3364 The field could be made final to avoid
3365 this vulnerability. However, the static initializer contains more than one write
3366 to the field, so doing so will require some refactoring.
3367 </p>
3368
3369
3370 <h3><a name="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT: Sequence of calls to concurrent abstraction may not be atomic (AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION)</a></h3>
3371
3372
3373 <p>This code contains a sequence of calls to a concurrent abstraction
3374 (such as a concurrent hash map).
3375 These calls will not be executed atomically.
3376
3377
3378 <h3><a name="DC_DOUBLECHECK">DC: Possible double check of field (DC_DOUBLECHECK)</a></h3>
3379
3380
3381 <p> This method may contain an instance of double-checked locking.&nbsp;
3382 This idiom is not correct according to the semantics of the Java memory
3383 model.&nbsp; For more information, see the web page
3384 <a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html"
3385 >http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a>.</p>
3386
3387
3388 <h3><a name="DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchronization on Boolean (DL_SYNCHRONIZATION_ON_BOOLEAN)</a></h3>
3389
3390
3391 <p> The code synchronizes on a boxed primitive constant, such as an Boolean.</p>
3392 <pre>
3393 private static Boolean inited = Boolean.FALSE;
3394 ...
3395 synchronized(inited) {
3396 if (!inited) {
3397 init();
3398 inited = Boolean.TRUE;
3399 }
3400 }
3401 ...
3402 </pre>
3403 <p>Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness
3404 and possible deadlock</p>
3405 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3406
3407
3408 <h3><a name="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive (DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE)</a></h3>
3409
3410
3411 <p> The code synchronizes on a boxed primitive constant, such as an Integer.</p>
3412 <pre>
3413 private static Integer count = 0;
3414 ...
3415 synchronized(count) {
3416 count++;
3417 }
3418 ...
3419 </pre>
3420 <p>Since Integer objects can be cached and shared,
3421 this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness
3422 and possible deadlock</p>
3423 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3424
3425
3426 <h3><a name="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: Synchronization on interned String (DL_SYNCHRONIZATION_ON_SHARED_CONSTANT)</a></h3>
3427
3428
3429 <p> The code synchronizes on interned String.</p>
3430 <pre>
3431 private static String LOCK = "LOCK";
3432 ...
3433 synchronized(LOCK) { ...}
3434 ...
3435 </pre>
3436 <p>Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could
3437 is locking on something that other code might also be locking. This could result in very strange and hard to diagnose
3438 blocking and deadlock behavior. See <a href="http://www.javalobby.org/java/forums/t96352.html">http://www.javalobby.org/java/forums/t96352.html</a> and <a href="http://jira.codehaus.org/browse/JETTY-352">http://jira.codehaus.org/browse/JETTY-352</a>.
3439 </p>
3440 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>
3441
3442
3443 <h3><a name="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE">DL: Synchronization on boxed primitive values (DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE)</a></h3>
3444
3445
3446 <p> The code synchronizes on an apparently unshared boxed primitive,
3447 such as an Integer.</p>
3448 <pre>
3449 private static final Integer fileLock = new Integer(1);
3450 ...
3451 synchronized(fileLock) {
3452 .. do something ..
3453 }
3454 ...
3455 </pre>
3456 <p>It would be much better, in this code, to redeclare fileLock as</p>
3457 <pre>
3458 private static final Object fileLock = new Object();
3459 </pre>
3460 <p>
3461 The existing code might be OK, but it is confusing and a
3462 future refactoring, such as the "Remove Boxing" refactoring in IntelliJ,
3463 might replace this with the use of an interned Integer object shared
3464 throughout the JVM, leading to very confusing behavior and potential deadlock.
3465 </p>
3466
3467
3468 <h3><a name="DM_MONITOR_WAIT_ON_CONDITION">Dm: Monitor wait() called on Condition (DM_MONITOR_WAIT_ON_CONDITION)</a></h3>
3469
3470
3471 <p>
3472 This method calls <code>wait()</code> on a
3473 <code>java.util.concurrent.locks.Condition</code> object.&nbsp;
3474 Waiting for a <code>Condition</code> should be done using one of the <code>await()</code>
3475 methods defined by the <code>Condition</code> interface.
3476 </p>
3477
3478
3479 <h3><a name="DM_USELESS_THREAD">Dm: A thread was created using the default empty run method (DM_USELESS_THREAD)</a></h3>
3480
3481
3482 <p>This method creates a thread without specifying a run method either by deriving from the Thread class, or
3483 by passing a Runnable object. This thread, then, does nothing but waste time.
3484 </p>
3485
3486
3487 <h3><a name="ESync_EMPTY_SYNC">ESync: Empty synchronized block (ESync_EMPTY_SYNC)</a></h3>
3488
3489
3490 <p> The code contains an empty synchronized block:</p>
3491 <pre>
3492 synchronized() {}
3493 </pre>
3494 <p>Empty synchronized blocks are far more subtle and hard to use correctly
3495 than most people recognize, and empty synchronized blocks
3496 are almost never a better solution
3497 than less contrived solutions.
3498 </p>
3499
3500
3501 <h3><a name="IS2_INCONSISTENT_SYNC">IS: Inconsistent synchronization (IS2_INCONSISTENT_SYNC)</a></h3>
3502
3503
3504 <p> The fields of this class appear to be accessed inconsistently with respect
3505 to synchronization.&nbsp; This bug report indicates that the bug pattern detector
3506 judged that
3507 </p>
3508 <ul>
3509 <li> The class contains a mix of locked and unlocked accesses,</li>
3510 <li> The class is <b>not</b> annotated as javax.annotation.concurrent.NotThreadSafe,</li>
3511 <li> At least one locked access was performed by one of the class's own methods, and</li>
3512 <li> The number of unsynchronized field accesses (reads and writes) was no more than
3513 one third of all accesses, with writes being weighed twice as high as reads</li>
3514 </ul>
3515
3516 <p> A typical bug matching this bug pattern is forgetting to synchronize
3517 one of the methods in a class that is intended to be thread-safe.</p>
3518
3519 <p> You can select the nodes labeled "Unsynchronized access" to show the
3520 code locations where the detector believed that a field was accessed
3521 without synchronization.</p>
3522
3523 <p> Note that there are various sources of inaccuracy in this detector;
3524 for example, the detector cannot statically detect all situations in which
3525 a lock is held.&nbsp; Also, even when the detector is accurate in
3526 distinguishing locked vs. unlocked accesses, the code in question may still
3527 be correct.</p>
3528
3529
3530
3531 <h3><a name="IS_FIELD_NOT_GUARDED">IS: Field not guarded against concurrent access (IS_FIELD_NOT_GUARDED)</a></h3>
3532
3533
3534 <p> This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy,
3535 but can be accessed in a way that seems to violate those annotations.</p>
3536
3537
3538 <h3><a name="JLM_JSR166_LOCK_MONITORENTER">JLM: Synchronization performed on Lock (JLM_JSR166_LOCK_MONITORENTER)</a></h3>
3539
3540
3541 <p> This method performs synchronization an object that implements
3542 java.util.concurrent.locks.Lock. Such an object is locked/unlocked
3543 using
3544 <code>acquire()</code>/<code>release()</code> rather
3545 than using the <code>synchronized (...)</code> construct.
3546 </p>
3547
3548
3549 <h3><a name="JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM: Synchronization performed on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)</a></h3>
3550
3551
3552 <p> This method performs synchronization an object that is an instance of
3553 a class from the java.util.concurrent package (or its subclasses). Instances
3554 of these classes have their own concurrency control mechanisms that are orthogonal to
3555 the synchronization provided by the Java keyword <code>synchronized</code>. For example,
3556 synchronizing on an <code>AtomicBoolean</code> will not prevent other threads
3557 from modifying the <code>AtomicBoolean</code>.</p>
3558 <p>Such code may be correct, but should be carefully reviewed and documented,
3559 and may confuse people who have to maintain the code at a later date.
3560 </p>
3561
3562
3563 <h3><a name="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JLM: Using monitor style wait methods on util.concurrent abstraction (JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT)</a></h3>
3564
3565
3566 <p> This method calls
3567 <code>wait()</code>,
3568 <code>notify()</code> or
3569 <code>notifyAll()()</code>
3570 on an object that also provides an
3571 <code>await()</code>,
3572 <code>signal()</code>,
3573 <code>signalAll()</code> method (such as util.concurrent Condition objects).
3574 This probably isn't what you want, and even if you do want it, you should consider changing
3575 your design, as other developers will find it exceptionally confusing.
3576 </p>
3577
3578
3579 <h3><a name="LI_LAZY_INIT_STATIC">LI: Incorrect lazy initialization of static field (LI_LAZY_INIT_STATIC)</a></h3>
3580
3581
3582 <p> This method contains an unsynchronized lazy initialization of a non-volatile static field.
3583 Because the compiler or processor may reorder instructions,
3584 threads are not guaranteed to see a completely initialized object,
3585 <em>if the method can be called by multiple threads</em>.
3586 You can make the field volatile to correct the problem.
3587 For more information, see the
3588 <a href="http://www.cs.umd.edu/~pugh/java/memoryModel/">Java Memory Model web site</a>.
3589 </p>
3590
3591
3592 <h3><a name="LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect lazy initialization and update of static field (LI_LAZY_INIT_UPDATE_STATIC)</a></h3>
3593
3594
3595 <p> This method contains an unsynchronized lazy initialization of a static field.
3596 After the field is set, the object stored into that location is further updated or accessed.
3597 The setting of the field is visible to other threads as soon as it is set. If the
3598 futher accesses in the method that set the field serve to initialize the object, then
3599 you have a <em>very serious</em> multithreading bug, unless something else prevents
3600 any other thread from accessing the stored object until it is fully initialized.
3601 </p>
3602 <p>Even if you feel confident that the method is never called by multiple
3603 threads, it might be better to not set the static field until the value
3604 you are setting it to is fully populated/initialized.
3605
3606
3607 <h3><a name="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD">ML: Synchronization on field in futile attempt to guard that field (ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD)</a></h3>
3608
3609
3610 <p> This method synchronizes on a field in what appears to be an attempt
3611 to guard against simultaneous updates to that field. But guarding a field
3612 gets a lock on the referenced object, not on the field. This may not
3613 provide the mutual exclusion you need, and other threads might
3614 be obtaining locks on the referenced objects (for other purposes). An example
3615 of this pattern would be:</p>
3616 <pre>
3617 private Long myNtfSeqNbrCounter = new Long(0);
3618 private Long getNotificationSequenceNumber() {
3619 Long result = null;
3620 synchronized(myNtfSeqNbrCounter) {
3621 result = new Long(myNtfSeqNbrCounter.longValue() + 1);
3622 myNtfSeqNbrCounter = new Long(result.longValue());
3623 }
3624 return result;
3625 }
3626 </pre>
3627
3628
3629 <h3><a name="ML_SYNC_ON_UPDATED_FIELD">ML: Method synchronizes on an updated field (ML_SYNC_ON_UPDATED_FIELD)</a></h3>
3630
3631
3632 <p> This method synchronizes on an object
3633 referenced from a mutable field.
3634 This is unlikely to have useful semantics, since different
3635 threads may be synchronizing on different objects.</p>
3636
3637
3638 <h3><a name="MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable servlet field (MSF_MUTABLE_SERVLET_FIELD)</a></h3>
3639
3640
3641 <p>A web server generally only creates one instance of servlet or jsp class (i.e., treats
3642 the class as a Singleton),
3643 and will
3644 have multiple threads invoke methods on that instance to service multiple
3645 simultaneous requests.
3646 Thus, having a mutable instance field generally creates race conditions.
3647
3648
3649 <h3><a name="MWN_MISMATCHED_NOTIFY">MWN: Mismatched notify() (MWN_MISMATCHED_NOTIFY)</a></h3>
3650
3651
3652 <p> This method calls Object.notify() or Object.notifyAll() without obviously holding a lock
3653 on the object.&nbsp; Calling notify() or notifyAll() without a lock held will result in
3654 an <code>IllegalMonitorStateException</code> being thrown.</p>
3655
3656
3657 <h3><a name="MWN_MISMATCHED_WAIT">MWN: Mismatched wait() (MWN_MISMATCHED_WAIT)</a></h3>
3658
3659
3660 <p> This method calls Object.wait() without obviously holding a lock
3661 on the object.&nbsp; Calling wait() without a lock held will result in
3662 an <code>IllegalMonitorStateException</code> being thrown.</p>
3663
3664
3665 <h3><a name="NN_NAKED_NOTIFY">NN: Naked notify (NN_NAKED_NOTIFY)</a></h3>
3666
3667
3668 <p> A call to <code>notify()</code> or <code>notifyAll()</code>
3669 was made without any (apparent) accompanying
3670 modification to mutable object state.&nbsp; In general, calling a notify
3671 method on a monitor is done because some condition another thread is
3672 waiting for has become true.&nbsp; However, for the condition to be meaningful,
3673 it must involve a heap object that is visible to both threads.</p>
3674
3675 <p> This bug does not necessarily indicate an error, since the change to
3676 mutable object state may have taken place in a method which then called
3677 the method containing the notification.</p>
3678
3679
3680 <h3><a name="NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchronize and null check on the same field. (NP_SYNC_AND_NULL_CHECK_FIELD)</a></h3>
3681
3682
3683 <p>Since the field is synchronized on, it seems not likely to be null.
3684 If it is null and then synchronized on a NullPointerException will be
3685 thrown and the check would be pointless. Better to synchronize on
3686 another field.</p>
3687
3688
3689
3690 <h3><a name="NO_NOTIFY_NOT_NOTIFYALL">No: Using notify() rather than notifyAll() (NO_NOTIFY_NOT_NOTIFYALL)</a></h3>
3691
3692
3693 <p> This method calls <code>notify()</code> rather than <code>notifyAll()</code>.&nbsp;
3694 Java monitors are often used for multiple conditions.&nbsp; Calling <code>notify()</code>
3695 only wakes up one thread, meaning that the thread woken up might not be the
3696 one waiting for the condition that the caller just satisfied.</p>
3697
3698
3699 <h3><a name="RS_READOBJECT_SYNC">RS: Class's readObject() method is synchronized (RS_READOBJECT_SYNC)</a></h3>
3700
3701
3702 <p> This serializable class defines a <code>readObject()</code> which is
3703 synchronized.&nbsp; By definition, an object created by deserialization
3704 is only reachable by one thread, and thus there is no need for
3705 <code>readObject()</code> to be synchronized.&nbsp; If the <code>readObject()</code>
3706 method itself is causing the object to become visible to another thread,
3707 that is an example of very dubious coding style.</p>
3708
3709
3710 <h3><a name="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV: Return value of putIfAbsent ignored, value passed to putIfAbsent reused (RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED)</a></h3>
3711
3712
3713 The <code>putIfAbsent</code> method is typically used to ensure that a
3714 single value is associated with a given key (the first value for which put
3715 if absent succeeds).
3716 If you ignore the return value and retain a reference to the value passed in,
3717 you run the risk of retaining a value that is not the one that is associated with the key in the map.
3718 If it matters which one you use and you use the one that isn't stored in the map,
3719 your program will behave incorrectly.
3720
3721
3722 <h3><a name="RU_INVOKE_RUN">Ru: Invokes run on a thread (did you mean to start it instead?) (RU_INVOKE_RUN)</a></h3>
3723
3724
3725 <p> This method explicitly invokes <code>run()</code> on an object.&nbsp;
3726 In general, classes implement the <code>Runnable</code> interface because
3727 they are going to have their <code>run()</code> method invoked in a new thread,
3728 in which case <code>Thread.start()</code> is the right method to call.</p>
3729
3730
3731 <h3><a name="SC_START_IN_CTOR">SC: Constructor invokes Thread.start() (SC_START_IN_CTOR)</a></h3>
3732
3733
3734 <p> The constructor starts a thread. This is likely to be wrong if
3735 the class is ever extended/subclassed, since the thread will be started
3736 before the subclass constructor is started.</p>
3737
3738
3739 <h3><a name="SP_SPIN_ON_FIELD">SP: Method spins on field (SP_SPIN_ON_FIELD)</a></h3>
3740
3741
3742 <p> This method spins in a loop which reads a field.&nbsp; The compiler
3743 may legally hoist the read out of the loop, turning the code into an
3744 infinite loop.&nbsp; The class should be changed so it uses proper
3745 synchronization (including wait and notify calls).</p>
3746
3747
3748 <h3><a name="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">STCAL: Call to static Calendar (STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE)</a></h3>
3749
3750
3751 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use.
3752 The detector has found a call to an instance of Calendar that has been obtained via a static
3753 field. This looks suspicous.</p>
3754 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3755 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3756
3757
3758 <h3><a name="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE">STCAL: Call to static DateFormat (STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE)</a></h3>
3759
3760
3761 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.
3762 The detector has found a call to an instance of DateFormat that has been obtained via a static
3763 field. This looks suspicous.</p>
3764 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3765 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3766
3767
3768 <h3><a name="STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Static Calendar field (STCAL_STATIC_CALENDAR_INSTANCE)</a></h3>
3769
3770
3771 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use.
3772 Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the
3773 application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see
3774 random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate().</p>
3775 <p>You may also experience serialization problems.</p>
3776 <p>Using an instance field is recommended.</p>
3777 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3778 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3779
3780
3781 <h3><a name="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">STCAL: Static DateFormat (STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE)</a></h3>
3782
3783
3784 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.
3785 Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the
3786 application.</p>
3787 <p>You may also experience serialization problems.</p>
3788 <p>Using an instance field is recommended.</p>
3789 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a>
3790 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a>.</p>
3791
3792
3793 <h3><a name="SWL_SLEEP_WITH_LOCK_HELD">SWL: Method calls Thread.sleep() with a lock held (SWL_SLEEP_WITH_LOCK_HELD)</a></h3>
3794
3795
3796 <p>
3797 This method calls Thread.sleep() with a lock held. This may result
3798 in very poor performance and scalability, or a deadlock, since other threads may
3799 be waiting to acquire the lock. It is a much better idea to call
3800 wait() on the lock, which releases the lock and allows other threads
3801 to run.
3802 </p>
3803
3804
3805 <h3><a name="TLW_TWO_LOCK_WAIT">TLW: Wait with two locks held (TLW_TWO_LOCK_WAIT)</a></h3>
3806
3807
3808 <p> Waiting on a monitor while two locks are held may cause
3809 deadlock.
3810 &nbsp;
3811 Performing a wait only releases the lock on the object
3812 being waited on, not any other locks.
3813 &nbsp;
3814 This not necessarily a bug, but is worth examining
3815 closely.</p>
3816
3817
3818 <h3><a name="UG_SYNC_SET_UNSYNC_GET">UG: Unsynchronized get method, synchronized set method (UG_SYNC_SET_UNSYNC_GET)</a></h3>
3819
3820
3821 <p> This class contains similarly-named get and set
3822 methods where the set method is synchronized and the get method is not.&nbsp;
3823 This may result in incorrect behavior at runtime, as callers of the get
3824 method will not necessarily see a consistent state for the object.&nbsp;
3825 The get method should be made synchronized.</p>
3826
3827
3828 <h3><a name="UL_UNRELEASED_LOCK">UL: Method does not release lock on all paths (UL_UNRELEASED_LOCK)</a></h3>
3829
3830
3831 <p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,
3832 but does not release it on all paths out of the method. In general, the correct idiom
3833 for using a JSR-166 lock is:
3834 </p>
3835 <pre>
3836 Lock l = ...;
3837 l.lock();
3838 try {
3839 // do something
3840 } finally {
3841 l.unlock();
3842 }
3843 </pre>
3844
3845
3846 <h3><a name="UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: Method does not release lock on all exception paths (UL_UNRELEASED_LOCK_EXCEPTION_PATH)</a></h3>
3847
3848
3849 <p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,
3850 but does not release it on all exception paths out of the method. In general, the correct idiom
3851 for using a JSR-166 lock is:
3852 </p>
3853 <pre>
3854 Lock l = ...;
3855 l.lock();
3856 try {
3857 // do something
3858 } finally {
3859 l.unlock();
3860 }
3861 </pre>
3862
3863
3864 <h3><a name="UW_UNCOND_WAIT">UW: Unconditional wait (UW_UNCOND_WAIT)</a></h3>
3865
3866
3867 <p> This method contains a call to <code>java.lang.Object.wait()</code> which
3868 is not guarded by conditional control flow.&nbsp; The code should
3869 verify that condition it intends to wait for is not already satisfied
3870 before calling wait; any previous notifications will be ignored.
3871 </p>
3872
3873
3874 <h3><a name="VO_VOLATILE_INCREMENT">VO: An increment to a volatile field isn't atomic (VO_VOLATILE_INCREMENT)</a></h3>
3875
3876
3877 <p>This code increments a volatile field. Increments of volatile fields aren't
3878 atomic. If more than one thread is incrementing the field at the same time,
3879 increments could be lost.
3880 </p>
3881
3882
3883 <h3><a name="VO_VOLATILE_REFERENCE_TO_ARRAY">VO: A volatile reference to an array doesn't treat the array elements as volatile (VO_VOLATILE_REFERENCE_TO_ARRAY)</a></h3>
3884
3885
3886 <p>This declares a volatile reference to an array, which might not be what
3887 you want. With a volatile reference to an array, reads and writes of
3888 the reference to the array are treated as volatile, but the array elements
3889 are non-volatile. To get volatile array elements, you will need to use
3890 one of the atomic array classes in java.util.concurrent (provided
3891 in Java 5.0).</p>
3892
3893
3894 <h3><a name="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL">WL: Synchronization on getClass rather than class literal (WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL)</a></h3>
3895
3896
3897 <p>
3898 This instance method synchronizes on <code>this.getClass()</code>. If this class is subclassed,
3899 subclasses will synchronize on the class object for the subclass, which isn't likely what was intended.
3900 For example, consider this code from java.awt.Label:</p>
3901 <pre>
3902 private static final String base = "label";
3903 private static int nameCounter = 0;
3904 String constructComponentName() {
3905 synchronized (getClass()) {
3906 return base + nameCounter++;
3907 }
3908 }
3909 </pre>
3910 <p>Subclasses of <code>Label</code> won't synchronize on the same subclass, giving rise to a datarace.
3911 Instead, this code should be synchronizing on <code>Label.class</code></p>
3912 <pre>
3913 private static final String base = "label";
3914 private static int nameCounter = 0;
3915 String constructComponentName() {
3916 synchronized (Label.class) {
3917 return base + nameCounter++;
3918 }
3919 }
3920 </pre>
3921 <p>Bug pattern contributed by Jason Mehrens</p>
3922
3923
3924 <h3><a name="WS_WRITEOBJECT_SYNC">WS: Class's writeObject() method is synchronized but nothing else is (WS_WRITEOBJECT_SYNC)</a></h3>
3925
3926
3927 <p> This class has a <code>writeObject()</code> method which is synchronized;
3928 however, no other method of the class is synchronized.</p>
3929
3930
3931 <h3><a name="WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await() not in loop (WA_AWAIT_NOT_IN_LOOP)</a></h3>
3932
3933
3934 <p> This method contains a call to <code>java.util.concurrent.await()</code>
3935 (or variants)
3936 which is not in a loop.&nbsp; If the object is used for multiple conditions,
3937 the condition the caller intended to wait for might not be the one
3938 that actually occurred.</p>
3939
3940
3941 <h3><a name="WA_NOT_IN_LOOP">Wa: Wait not in loop (WA_NOT_IN_LOOP)</a></h3>
3942
3943
3944 <p> This method contains a call to <code>java.lang.Object.wait()</code>
3945 which is not in a loop.&nbsp; If the monitor is used for multiple conditions,
3946 the condition the caller intended to wait for might not be the one
3947 that actually occurred.</p>
3948
3949
3950 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive value is boxed and then immediately unboxed (BX_BOXING_IMMEDIATELY_UNBOXED)</a></h3>
3951
3952
3953 <p>A primitive is boxed, and then immediately unboxed. This probably is due to a manual
3954 boxing in a place where an unboxed value is required, thus forcing the compiler
3955 to immediately undo the work of the boxing.
3956 </p>
3957
3958
3959 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION">Bx: Primitive value is boxed then unboxed to perform primitive coercion (BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION)</a></h3>
3960
3961
3962 <p>A primitive boxed value constructed and then immediately converted into a different primitive type
3963 (e.g., <code>new Double(d).intValue()</code>). Just perform direct primitive coercion (e.g., <code>(int) d</code>).</p>
3964
3965
3966 <h3><a name="BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed value is unboxed and then immediately reboxed (BX_UNBOXING_IMMEDIATELY_REBOXED)</a></h3>
3967
3968
3969 <p>A boxed value is unboxed and then immediately reboxed.
3970 </p>
3971
3972
3973 <h3><a name="DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/unboxing to parse a primitive (DM_BOXED_PRIMITIVE_FOR_PARSING)</a></h3>
3974
3975
3976 <p>A boxed primitive is created from a String, just to extract the unboxed primitive value.
3977 It is more efficient to just call the static parseXXX method.</p>
3978
3979
3980 <h3><a name="DM_BOXED_PRIMITIVE_TOSTRING">Bx: Method allocates a boxed primitive just to call toString (DM_BOXED_PRIMITIVE_TOSTRING)</a></h3>
3981
3982
3983 <p>A boxed primitive is allocated just to call toString(). It is more effective to just use the static
3984 form of toString which takes the primitive value. So,</p>
3985 <table>
3986 <tr><th>Replace...</th><th>With this...</th></tr>
3987 <tr><td>new Integer(1).toString()</td><td>Integer.toString(1)</td></tr>
3988 <tr><td>new Long(1).toString()</td><td>Long.toString(1)</td></tr>
3989 <tr><td>new Float(1.0).toString()</td><td>Float.toString(1.0)</td></tr>
3990 <tr><td>new Double(1.0).toString()</td><td>Double.toString(1.0)</td></tr>
3991 <tr><td>new Byte(1).toString()</td><td>Byte.toString(1)</td></tr>
3992 <tr><td>new Short(1).toString()</td><td>Short.toString(1)</td></tr>
3993 <tr><td>new Boolean(true).toString()</td><td>Boolean.toString(true)</td></tr>
3994 </table>
3995
3996
3997 <h3><a name="DM_FP_NUMBER_CTOR">Bx: Method invokes inefficient floating-point Number constructor; use static valueOf instead (DM_FP_NUMBER_CTOR)</a></h3>
3998
3999
4000 <p>
4001 Using <code>new Double(double)</code> is guaranteed to always result in a new object whereas
4002 <code>Double.valueOf(double)</code> allows caching of values to be done by the compiler, class library, or JVM.
4003 Using of cached values avoids object allocation and the code will be faster.
4004 </p>
4005 <p>
4006 Unless the class must be compatible with JVMs predating Java 1.5,
4007 use either autoboxing or the <code>valueOf()</code> method when creating instances of <code>Double</code> and <code>Float</code>.
4008 </p>
4009
4010
4011 <h3><a name="DM_NUMBER_CTOR">Bx: Method invokes inefficient Number constructor; use static valueOf instead (DM_NUMBER_CTOR)</a></h3>
4012
4013
4014 <p>
4015 Using <code>new Integer(int)</code> is guaranteed to always result in a new object whereas
4016 <code>Integer.valueOf(int)</code> allows caching of values to be done by the compiler, class library, or JVM.
4017 Using of cached values avoids object allocation and the code will be faster.
4018 </p>
4019 <p>
4020 Values between -128 and 127 are guaranteed to have corresponding cached instances
4021 and using <code>valueOf</code> is approximately 3.5 times faster than using constructor.
4022 For values outside the constant range the performance of both styles is the same.
4023 </p>
4024 <p>
4025 Unless the class must be compatible with JVMs predating Java 1.5,
4026 use either autoboxing or the <code>valueOf()</code> method when creating instances of
4027 <code>Long</code>, <code>Integer</code>, <code>Short</code>, <code>Character</code>, and <code>Byte</code>.
4028 </p>
4029
4030
4031 <h3><a name="DMI_BLOCKING_METHODS_ON_URL">Dm: The equals and hashCode methods of URL are blocking (DMI_BLOCKING_METHODS_ON_URL)</a></h3>
4032
4033
4034 <p> The equals and hashCode
4035 method of URL perform domain name resolution, this can result in a big performance hit.
4036 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
4037 Consider using <code>java.net.URI</code> instead.
4038 </p>
4039
4040
4041 <h3><a name="DMI_COLLECTION_OF_URLS">Dm: Maps and sets of URLs can be performance hogs (DMI_COLLECTION_OF_URLS)</a></h3>
4042
4043
4044 <p> This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode
4045 method of URL perform domain name resolution, this can result in a big performance hit.
4046 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.
4047 Consider using <code>java.net.URI</code> instead.
4048 </p>
4049
4050
4051 <h3><a name="DM_BOOLEAN_CTOR">Dm: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead (DM_BOOLEAN_CTOR)</a></h3>
4052
4053
4054 <p> Creating new instances of <code>java.lang.Boolean</code> wastes
4055 memory, since <code>Boolean</code> objects are immutable and there are
4056 only two useful values of this type.&nbsp; Use the <code>Boolean.valueOf()</code>
4057 method (or Java 1.5 autoboxing) to create <code>Boolean</code> objects instead.</p>
4058
4059
4060 <h3><a name="DM_GC">Dm: Explicit garbage collection; extremely dubious except in benchmarking code (DM_GC)</a></h3>
4061
4062
4063 <p> Code explicitly invokes garbage collection.
4064 Except for specific use in benchmarking, this is very dubious.</p>
4065 <p>In the past, situations where people have explicitly invoked
4066 the garbage collector in routines such as close or finalize methods
4067 has led to huge performance black holes. Garbage collection
4068 can be expensive. Any situation that forces hundreds or thousands
4069 of garbage collections will bring the machine to a crawl.</p>
4070
4071
4072 <h3><a name="DM_NEW_FOR_GETCLASS">Dm: Method allocates an object, only to get the class object (DM_NEW_FOR_GETCLASS)</a></h3>
4073
4074
4075 <p>This method allocates an object just to call getClass() on it, in order to
4076 retrieve the Class object for it. It is simpler to just access the .class property of the class.</p>
4077
4078
4079 <h3><a name="DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Use the nextInt method of Random rather than nextDouble to generate a random integer (DM_NEXTINT_VIA_NEXTDOUBLE)</a></h3>
4080
4081
4082 <p>If <code>r</code> is a <code>java.util.Random</code>, you can generate a random number from <code>0</code> to <code>n-1</code>
4083 using <code>r.nextInt(n)</code>, rather than using <code>(int)(r.nextDouble() * n)</code>.
4084 </p>
4085 <p>The argument to nextInt must be positive. If, for example, you want to generate a random
4086 value from -99 to 0, use <code>-r.nextInt(100)</code>.
4087 </p>
4088
4089
4090 <h3><a name="DM_STRING_CTOR">Dm: Method invokes inefficient new String(String) constructor (DM_STRING_CTOR)</a></h3>
4091
4092
4093 <p> Using the <code>java.lang.String(String)</code> constructor wastes memory
4094 because the object so constructed will be functionally indistinguishable
4095 from the <code>String</code> passed as a parameter.&nbsp; Just use the
4096 argument <code>String</code> directly.</p>
4097
4098
4099 <h3><a name="DM_STRING_TOSTRING">Dm: Method invokes toString() method on a String (DM_STRING_TOSTRING)</a></h3>
4100
4101
4102 <p> Calling <code>String.toString()</code> is just a redundant operation.
4103 Just use the String.</p>
4104
4105
4106 <h3><a name="DM_STRING_VOID_CTOR">Dm: Method invokes inefficient new String() constructor (DM_STRING_VOID_CTOR)</a></h3>
4107
4108
4109 <p> Creating a new <code>java.lang.String</code> object using the
4110 no-argument constructor wastes memory because the object so created will
4111 be functionally indistinguishable from the empty string constant
4112 <code>""</code>.&nbsp; Java guarantees that identical string constants
4113 will be represented by the same <code>String</code> object.&nbsp; Therefore,
4114 you should just use the empty string constant directly.</p>
4115
4116
4117 <h3><a name="HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge string constants is duplicated across multiple class files (HSC_HUGE_SHARED_STRING_CONSTANT)</a></h3>
4118
4119
4120 <p>
4121 A large String constant is duplicated across multiple class files.
4122 This is likely because a final field is initialized to a String constant, and the Java language
4123 mandates that all references to a final field from other classes be inlined into
4124 that classfile. See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6447475">JDK bug 6447475</a>
4125 for a description of an occurrence of this bug in the JDK and how resolving it reduced
4126 the size of the JDK by 1 megabyte.
4127 </p>
4128
4129
4130 <h3><a name="ITA_INEFFICIENT_TO_ARRAY">ITA: Method uses toArray() with zero-length array argument (ITA_INEFFICIENT_TO_ARRAY)</a></h3>
4131
4132
4133 <p> This method uses the toArray() method of a collection derived class, and passes
4134 in a zero-length prototype array argument. It is more efficient to use
4135 <code>myCollection.toArray(new Foo[myCollection.size()])</code>
4136 If the array passed in is big enough to store all of the
4137 elements of the collection, then it is populated and returned
4138 directly. This avoids the need to create a second array
4139 (by reflection) to return as the result.</p>
4140
4141
4142 <h3><a name="SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: Method concatenates strings using + in a loop (SBSC_USE_STRINGBUFFER_CONCATENATION)</a></h3>
4143
4144
4145 <p> The method seems to be building a String using concatenation in a loop.
4146 In each iteration, the String is converted to a StringBuffer/StringBuilder,
4147 appended to, and converted back to a String.
4148 This can lead to a cost quadratic in the number of iterations,
4149 as the growing string is recopied in each iteration. </p>
4150
4151 <p>Better performance can be obtained by using
4152 a StringBuffer (or StringBuilder in Java 1.5) explicitly.</p>
4153
4154 <p> For example:</p>
4155 <pre>
4156 // This is bad
4157 String s = "";
4158 for (int i = 0; i &lt; field.length; ++i) {
4159 s = s + field[i];
4160 }
4161
4162 // This is better
4163 StringBuffer buf = new StringBuffer();
4164 for (int i = 0; i &lt; field.length; ++i) {
4165 buf.append(field[i]);
4166 }
4167 String s = buf.toString();
4168 </pre>
4169
4170
4171 <h3><a name="SIC_INNER_SHOULD_BE_STATIC">SIC: Should be a static inner class (SIC_INNER_SHOULD_BE_STATIC)</a></h3>
4172
4173
4174 <p> This class is an inner class, but does not use its embedded reference
4175 to the object which created it.&nbsp; This reference makes the instances
4176 of the class larger, and may keep the reference to the creator object
4177 alive longer than necessary.&nbsp; If possible, the class should be
4178 made static.
4179 </p>
4180
4181
4182 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Could be refactored into a named static inner class (SIC_INNER_SHOULD_BE_STATIC_ANON)</a></h3>
4183
4184
4185 <p> This class is an inner class, but does not use its embedded reference
4186 to the object which created it.&nbsp; This reference makes the instances
4187 of the class larger, and may keep the reference to the creator object
4188 alive longer than necessary.&nbsp; If possible, the class should be
4189 made into a <em>static</em> inner class. Since anonymous inner
4190 classes cannot be marked as static, doing this will require refactoring
4191 the inner class so that it is a named inner class.</p>
4192
4193
4194 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC: Could be refactored into a static inner class (SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS)</a></h3>
4195
4196
4197 <p> This class is an inner class, but does not use its embedded reference
4198 to the object which created it except during construction of the
4199 inner object.&nbsp; This reference makes the instances
4200 of the class larger, and may keep the reference to the creator object
4201 alive longer than necessary.&nbsp; If possible, the class should be
4202 made into a <em>static</em> inner class. Since the reference to the
4203 outer object is required during construction of the inner instance,
4204 the inner class will need to be refactored so as to
4205 pass a reference to the outer instance to the constructor
4206 for the inner class.</p>
4207
4208
4209 <h3><a name="SS_SHOULD_BE_STATIC">SS: Unread field: should this field be static? (SS_SHOULD_BE_STATIC)</a></h3>
4210
4211
4212 <p> This class contains an instance final field that
4213 is initialized to a compile-time static value.
4214 Consider making the field static.</p>
4215
4216
4217 <h3><a name="UM_UNNECESSARY_MATH">UM: Method calls static Math class method on a constant value (UM_UNNECESSARY_MATH)</a></h3>
4218
4219
4220 <p> This method uses a static method from java.lang.Math on a constant value. This method's
4221 result in this case, can be determined statically, and is faster and sometimes more accurate to
4222 just use the constant. Methods detected are:
4223 </p>
4224 <table>
4225 <tr>
4226 <th>Method</th> <th>Parameter</th>
4227 </tr>
4228 <tr>
4229 <td>abs</td> <td>-any-</td>
4230 </tr>
4231 <tr>
4232 <td>acos</td> <td>0.0 or 1.0</td>
4233 </tr>
4234 <tr>
4235 <td>asin</td> <td>0.0 or 1.0</td>
4236 </tr>
4237 <tr>
4238 <td>atan</td> <td>0.0 or 1.0</td>
4239 </tr>
4240 <tr>
4241 <td>atan2</td> <td>0.0</td>
4242 </tr>
4243 <tr>
4244 <td>cbrt</td> <td>0.0 or 1.0</td>
4245 </tr>
4246 <tr>
4247 <td>ceil</td> <td>-any-</td>
4248 </tr>
4249 <tr>
4250 <td>cos</td> <td>0.0</td>
4251 </tr>
4252 <tr>
4253 <td>cosh</td> <td>0.0</td>
4254 </tr>
4255 <tr>
4256 <td>exp</td> <td>0.0 or 1.0</td>
4257 </tr>
4258 <tr>
4259 <td>expm1</td> <td>0.0</td>
4260 </tr>
4261 <tr>
4262 <td>floor</td> <td>-any-</td>
4263 </tr>
4264 <tr>
4265 <td>log</td> <td>0.0 or 1.0</td>
4266 </tr>
4267 <tr>
4268 <td>log10</td> <td>0.0 or 1.0</td>
4269 </tr>
4270 <tr>
4271 <td>rint</td> <td>-any-</td>
4272 </tr>
4273 <tr>
4274 <td>round</td> <td>-any-</td>
4275 </tr>
4276 <tr>
4277 <td>sin</td> <td>0.0</td>
4278 </tr>
4279 <tr>
4280 <td>sinh</td> <td>0.0</td>
4281 </tr>
4282 <tr>
4283 <td>sqrt</td> <td>0.0 or 1.0</td>
4284 </tr>
4285 <tr>
4286 <td>tan</td> <td>0.0</td>
4287 </tr>
4288 <tr>
4289 <td>tanh</td> <td>0.0</td>
4290 </tr>
4291 <tr>
4292 <td>toDegrees</td> <td>0.0 or 1.0</td>
4293 </tr>
4294 <tr>
4295 <td>toRadians</td> <td>0.0</td>
4296 </tr>
4297 </table>
4298
4299
4300 <h3><a name="UPM_UNCALLED_PRIVATE_METHOD">UPM: Private method is never called (UPM_UNCALLED_PRIVATE_METHOD)</a></h3>
4301
4302
4303 <p> This private method is never called. Although it is
4304 possible that the method will be invoked through reflection,
4305 it is more likely that the method is never used, and should be
4306 removed.
4307 </p>
4308
4309
4310 <h3><a name="URF_UNREAD_FIELD">UrF: Unread field (URF_UNREAD_FIELD)</a></h3>
4311
4312
4313 <p> This field is never read.&nbsp; Consider removing it from the class.</p>
4314
4315
4316 <h3><a name="UUF_UNUSED_FIELD">UuF: Unused field (UUF_UNUSED_FIELD)</a></h3>
4317
4318
4319 <p> This field is never used.&nbsp; Consider removing it from the class.</p>
4320
4321
4322 <h3><a name="WMI_WRONG_MAP_ITERATOR">WMI: Inefficient use of keySet iterator instead of entrySet iterator (WMI_WRONG_MAP_ITERATOR)</a></h3>
4323
4324
4325 <p> This method accesses the value of a Map entry, using a key that was retrieved from
4326 a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the
4327 Map.get(key) lookup.</p>
4328
4329
4330 <h3><a name="DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded constant database password (DMI_CONSTANT_DB_PASSWORD)</a></h3>
4331
4332
4333 <p>This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can
4334 easily learn the password.
4335 </p>
4336
4337
4338
4339 <h3><a name="DMI_EMPTY_DB_PASSWORD">Dm: Empty database password (DMI_EMPTY_DB_PASSWORD)</a></h3>
4340
4341
4342 <p>This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password.
4343 </p>
4344
4345
4346
4347 <h3><a name="HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP cookie formed from untrusted input (HRS_REQUEST_PARAMETER_TO_COOKIE)</a></h3>
4348
4349
4350 <p>This code constructs an HTTP Cookie using an untrusted HTTP parameter. If this cookie is added to an HTTP response, it will allow a HTTP response splitting
4351 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
4352 for more information.</p>
4353 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response splitting.
4354 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4355 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously
4356 consider using a commercial static analysis or pen-testing tool.
4357 </p>
4358
4359
4360
4361 <h3><a name="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: HTTP Response splitting vulnerability (HRS_REQUEST_PARAMETER_TO_HTTP_HEADER)</a></h3>
4362
4363
4364 <p>This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting
4365 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>
4366 for more information.</p>
4367 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response splitting.
4368 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4369 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously
4370 consider using a commercial static analysis or pen-testing tool.
4371 </p>
4372
4373
4374
4375 <h3><a name="PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute path traversal in servlet (PT_ABSOLUTE_PATH_TRAVERSAL)</a></h3>
4376
4377
4378 <p>The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory,
4379 but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
4380
4381 See <a href="http://cwe.mitre.org/data/definitions/36.html">http://cwe.mitre.org/data/definitions/36.html</a>
4382 for more information.</p>
4383 <p>FindBugs looks only for the most blatant, obvious cases of absolute path traversal.
4384 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4385 vulnerabilities that FindBugs doesn't report. If you are concerned about absolute path traversal, you should seriously
4386 consider using a commercial static analysis or pen-testing tool.
4387 </p>
4388
4389
4390
4391 <h3><a name="PT_RELATIVE_PATH_TRAVERSAL">PT: Relative path traversal in servlet (PT_RELATIVE_PATH_TRAVERSAL)</a></h3>
4392
4393
4394 <p>The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.
4395
4396 See <a href="http://cwe.mitre.org/data/definitions/23.html">http://cwe.mitre.org/data/definitions/23.html</a>
4397 for more information.</p>
4398 <p>FindBugs looks only for the most blatant, obvious cases of relative path traversal.
4399 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more
4400 vulnerabilities that FindBugs doesn't report. If you are concerned about relative path traversal, you should seriously
4401 consider using a commercial static analysis or pen-testing tool.
4402 </p>
4403
4404
4405
4406 <h3><a name="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQL: Nonconstant string passed to execute method on an SQL statement (SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE)</a></h3>
4407
4408
4409 <p>The method invokes the execute method on an SQL statement with a String that seems
4410 to be dynamically generated. Consider using
4411 a prepared statement instead. It is more efficient and less vulnerable to
4412 SQL injection attacks.
4413 </p>
4414
4415
4416 <h3><a name="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING">SQL: A prepared statement is generated from a nonconstant String (SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING)</a></h3>
4417
4418
4419 <p>The code creates an SQL prepared statement from a nonconstant String.
4420 If unchecked, tainted data from a user is used in building this String, SQL injection could
4421 be used to make the prepared statement do something unexpected and undesirable.
4422 </p>
4423
4424
4425 <h3><a name="XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JSP reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_JSP_WRITER)</a></h3>
4426
4427
4428 <p>This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting
4429 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4430 for more information.</p>
4431 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4432 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4433 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4434 consider using a commercial static analysis or pen-testing tool.
4435 </p>
4436
4437
4438 <h3><a name="XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Servlet reflected cross site scripting vulnerability in error page (XSS_REQUEST_PARAMETER_TO_SEND_ERROR)</a></h3>
4439
4440
4441 <p>This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows
4442 for a reflected cross site scripting
4443 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4444 for more information.</p>
4445 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4446 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4447 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4448 consider using a commercial static analysis or pen-testing tool.
4449 </p>
4450
4451
4452
4453 <h3><a name="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS: Servlet reflected cross site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER)</a></h3>
4454
4455
4456 <p>This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting
4457 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a>
4458 for more information.</p>
4459 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripting.
4460 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting
4461 vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously
4462 consider using a commercial static analysis or pen-testing tool.
4463 </p>
4464
4465
4466
4467 <h3><a name="BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Questionable cast to abstract collection (BC_BAD_CAST_TO_ABSTRACT_COLLECTION)</a></h3>
4468
4469
4470 <p>
4471 This code casts a Collection to an abstract collection
4472 (such as <code>List</code>, <code>Set</code>, or <code>Map</code>).
4473 Ensure that you are guaranteed that the object is of the type
4474 you are casting to. If all you need is to be able
4475 to iterate through a collection, you don't need to cast it to a Set or List.
4476 </p>
4477
4478
4479 <h3><a name="BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Questionable cast to concrete collection (BC_BAD_CAST_TO_CONCRETE_COLLECTION)</a></h3>
4480
4481
4482 <p>
4483 This code casts an abstract collection (such as a Collection, List, or Set)
4484 to a specific concrete implementation (such as an ArrayList or HashSet).
4485 This might not be correct, and it may make your code fragile, since
4486 it makes it harder to switch to other concrete implementations at a future
4487 point. Unless you have a particular reason to do so, just use the abstract
4488 collection class.
4489 </p>
4490
4491
4492 <h3><a name="BC_UNCONFIRMED_CAST">BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST)</a></h3>
4493
4494
4495 <p>
4496 This cast is unchecked, and not all instances of the type casted from can be cast to
4497 the type it is being cast to. Check that your program logic ensures that this
4498 cast will not fail.
4499 </p>
4500
4501
4502 <h3><a name="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unchecked/unconfirmed cast of return value from method (BC_UNCONFIRMED_CAST_OF_RETURN_VALUE)</a></h3>
4503
4504
4505 <p>
4506 This code performs an unchecked cast of the return value of a method.
4507 The code might be calling the method in such a way that the cast is guaranteed to be
4508 safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this
4509 cast will not fail.
4510 </p>
4511
4512
4513 <h3><a name="BC_VACUOUS_INSTANCEOF">BC: instanceof will always return true (BC_VACUOUS_INSTANCEOF)</a></h3>
4514
4515
4516 <p>
4517 This instanceof test will always return true (unless the value being tested is null).
4518 Although this is safe, make sure it isn't
4519 an indication of some misunderstanding or some other logic error.
4520 If you really want to test the value for being null, perhaps it would be clearer to do
4521 better to do a null test rather than an instanceof test.
4522 </p>
4523
4524
4525 <h3><a name="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSHIFT: Unsigned right shift cast to short/byte (ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT)</a></h3>
4526
4527
4528 <p>
4529 The code performs an unsigned right shift, whose result is then
4530 cast to a short or byte, which discards the upper bits of the result.
4531 Since the upper bits are discarded, there may be no difference between
4532 a signed and unsigned right shift (depending upon the size of the shift).
4533 </p>
4534
4535
4536 <h3><a name="CI_CONFUSED_INHERITANCE">CI: Class is final but declares protected field (CI_CONFUSED_INHERITANCE)</a></h3>
4537
4538
4539 <p>
4540 This class is declared to be final, but declares fields to be protected. Since the class
4541 is final, it can not be derived from, and the use of protected is confusing. The access
4542 modifier for the field should be changed to private or public to represent the true
4543 use for the field.
4544 </p>
4545
4546
4547 <h3><a name="DB_DUPLICATE_BRANCHES">DB: Method uses the same code for two branches (DB_DUPLICATE_BRANCHES)</a></h3>
4548
4549
4550 <p>
4551 This method uses the same code to implement two branches of a conditional branch.
4552 Check to ensure that this isn't a coding mistake.
4553 </p>
4554
4555
4556 <h3><a name="DB_DUPLICATE_SWITCH_CLAUSES">DB: Method uses the same code for two switch clauses (DB_DUPLICATE_SWITCH_CLAUSES)</a></h3>
4557
4558
4559 <p>
4560 This method uses the same code to implement two clauses of a switch statement.
4561 This could be a case of duplicate code, but it might also indicate
4562 a coding mistake.
4563 </p>
4564
4565
4566 <h3><a name="DLS_DEAD_LOCAL_STORE">DLS: Dead store to local variable (DLS_DEAD_LOCAL_STORE)</a></h3>
4567
4568
4569 <p>
4570 This instruction assigns a value to a local variable,
4571 but the value is not read or used in any subsequent instruction.
4572 Often, this indicates an error, because the value computed is never
4573 used.
4574 </p>
4575 <p>
4576 Note that Sun's javac compiler often generates dead stores for
4577 final local variables. Because FindBugs is a bytecode-based tool,
4578 there is no easy way to eliminate these false positives.
4579 </p>
4580
4581
4582 <h3><a name="DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless assignment in return statement (DLS_DEAD_LOCAL_STORE_IN_RETURN)</a></h3>
4583
4584
4585 <p>
4586 This statement assigns to a local variable in a return statement. This assignment
4587 has effect. Please verify that this statement does the right thing.
4588 </p>
4589
4590
4591 <h3><a name="DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Dead store of null to local variable (DLS_DEAD_LOCAL_STORE_OF_NULL)</a></h3>
4592
4593
4594 <p>The code stores null into a local variable, and the stored value is not
4595 read. This store may have been introduced to assist the garbage collector, but
4596 as of Java SE 6.0, this is no longer needed or useful.
4597 </p>
4598
4599
4600 <h3><a name="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dead store to local variable that shadows field (DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD)</a></h3>
4601
4602
4603 <p>
4604 This instruction assigns a value to a local variable,
4605 but the value is not read or used in any subsequent instruction.
4606 Often, this indicates an error, because the value computed is never
4607 used. There is a field with the same name as the local variable. Did you
4608 mean to assign to that variable instead?
4609 </p>
4610
4611
4612 <h3><a name="DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Code contains a hard coded reference to an absolute pathname (DMI_HARDCODED_ABSOLUTE_FILENAME)</a></h3>
4613
4614
4615 <p>This code constructs a File object using a hard coded to an absolute pathname
4616 (e.g., <code>new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");</code>
4617 </p>
4618
4619
4620 <h3><a name="DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Non serializable object written to ObjectOutput (DMI_NONSERIALIZABLE_OBJECT_WRITTEN)</a></h3>
4621
4622
4623 <p>
4624 This code seems to be passing a non-serializable object to the ObjectOutput.writeObject method.
4625 If the object is, indeed, non-serializable, an error will result.
4626 </p>
4627
4628
4629 <h3><a name="DMI_USELESS_SUBSTRING">DMI: Invocation of substring(0), which returns the original value (DMI_USELESS_SUBSTRING)</a></h3>
4630
4631
4632 <p>
4633 This code invokes substring(0) on a String, which returns the original value.
4634 </p>
4635
4636
4637 <h3><a name="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">Dm: Thread passed where Runnable expected (DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED)</a></h3>
4638
4639
4640 <p> A Thread object is passed as a parameter to a method where
4641 a Runnable is expected. This is rather unusual, and may indicate a logic error
4642 or cause unexpected behavior.
4643 </p>
4644
4645
4646 <h3><a name="EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't override equals in superclass (EQ_DOESNT_OVERRIDE_EQUALS)</a></h3>
4647
4648
4649 <p> This class extends a class that defines an equals method and adds fields, but doesn't
4650 define an equals method itself. Thus, equality on instances of this class will
4651 ignore the identity of the subclass and the added fields. Be sure this is what is intended,
4652 and that you don't need to override the equals method. Even if you don't need to override
4653 the equals method, consider overriding it anyway to document the fact
4654 that the equals method for the subclass just return the result of
4655 invoking super.equals(o).
4656 </p>
4657
4658
4659 <h3><a name="EQ_UNUSUAL">Eq: Unusual equals method (EQ_UNUSUAL)</a></h3>
4660
4661
4662 <p> This class doesn't do any of the patterns we recognize for checking that the type of the argument
4663 is compatible with the type of the <code>this</code> object. There might not be anything wrong with
4664 this code, but it is worth reviewing.
4665 </p>
4666
4667
4668 <h3><a name="FE_FLOATING_POINT_EQUALITY">FE: Test for floating point equality (FE_FLOATING_POINT_EQUALITY)</a></h3>
4669
4670
4671 <p>
4672 This operation compares two floating point values for equality.
4673 Because floating point calculations may involve rounding,
4674 calculated float and double values may not be accurate.
4675 For values that must be precise, such as monetary values,
4676 consider using a fixed-precision type such as BigDecimal.
4677 For values that need not be precise, consider comparing for equality
4678 within some range, for example:
4679 <code>if ( Math.abs(x - y) &lt; .0000001 )</code>.
4680 See the Java Language Specification, section 4.2.4.
4681 </p>
4682
4683
4684 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">FS: Non-Boolean argument formatted using %b format specifier (VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN)</a></h3>
4685
4686
4687 <p>
4688 An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an
4689 exception; instead, it will print true for any nonnull value, and false for null.
4690 This feature of format strings is strange, and may not be what you intended.
4691 </p>
4692
4693
4694 <h3><a name="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">IA: Potentially ambiguous invocation of either an inherited or outer method (IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD)</a></h3>
4695
4696
4697 <p>
4698 An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class.
4699 For example, you invoke <code>foo(17)</code>, which is defined in both a superclass and in an outer method.
4700 By the Java semantics,
4701 it will be resolved to invoke the inherited method, but this may not be want
4702 you intend.
4703 </p>
4704 <p>If you really intend to invoke the inherited method,
4705 invoke it by invoking the method on super (e.g., invoke super.foo(17)), and
4706 thus it will be clear to other readers of your code and to FindBugs
4707 that you want to invoke the inherited method, not the method in the outer class.
4708 </p>
4709 <p>If you call <code>this.foo(17)</code>, then the inherited method will be invoked. However, since FindBugs only looks at
4710 classfiles, it
4711 can't tell the difference between an invocation of <code>this.foo(17)</code> and <code>foo(17)</code>, it will still
4712 complain about a potential ambiguous invocation.
4713 </p>
4714
4715
4716 <h3><a name="IC_INIT_CIRCULARITY">IC: Initialization circularity (IC_INIT_CIRCULARITY)</a></h3>
4717
4718
4719 <p> A circularity was detected in the static initializers of the two
4720 classes referenced by the bug instance.&nbsp; Many kinds of unexpected
4721 behavior may arise from such circularity.</p>
4722
4723
4724 <h3><a name="ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Integral division result cast to double or float (ICAST_IDIV_CAST_TO_DOUBLE)</a></h3>
4725
4726
4727 <p>
4728 This code casts the result of an integral division (e.g., int or long division)
4729 operation to double or
4730 float.
4731 Doing division on integers truncates the result
4732 to the integer value closest to zero. The fact that the result
4733 was cast to double suggests that this precision should have been retained.
4734 What was probably meant was to cast one or both of the operands to
4735 double <em>before</em> performing the division. Here is an example:
4736 </p>
4737 <blockquote>
4738 <pre>
4739 int x = 2;
4740 int y = 5;
4741 // Wrong: yields result 0.0
4742 double value1 = x / y;
4743
4744 // Right: yields result 0.4
4745 double value2 = x / (double) y;
4746 </pre>
4747 </blockquote>
4748
4749
4750 <h3><a name="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST: Result of integer multiplication cast to long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)</a></h3>
4751
4752
4753 <p>
4754 This code performs integer multiply and then converts the result to a long,
4755 as in:</p>
4756 <pre>
4757 long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }
4758 </pre>
4759 <p>
4760 If the multiplication is done using long arithmetic, you can avoid
4761 the possibility that the result will overflow. For example, you
4762 could fix the above code to:</p>
4763 <pre>
4764 long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
4765 </pre>
4766 or
4767 <pre>
4768 static final long MILLISECONDS_PER_DAY = 24L*3600*1000;
4769 long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }
4770 </pre>
4771
4772
4773 <h3><a name="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: Computation of average could overflow (IM_AVERAGE_COMPUTATION_COULD_OVERFLOW)</a></h3>
4774
4775
4776 <p>The code computes the average of two integers using either division or signed right shift,
4777 and then uses the result as the index of an array.
4778 If the values being averaged are very large, this can overflow (resulting in the computation
4779 of a negative average). Assuming that the result is intended to be nonnegative, you
4780 can use an unsigned right shift instead. In other words, rather that using <code>(low+high)/2</code>,
4781 use <code>(low+high) &gt;&gt;&gt; 1</code>
4782 </p>
4783 <p>This bug exists in many earlier implementations of binary search and merge sort.
4784 Martin Buchholz <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6412541">found and fixed it</a>
4785 in the JDK libraries, and Joshua Bloch
4786 <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">widely
4787 publicized the bug pattern</a>.
4788 </p>
4789
4790
4791 <h3><a name="IM_BAD_CHECK_FOR_ODD">IM: Check for oddness that won't work for negative numbers (IM_BAD_CHECK_FOR_ODD)</a></h3>
4792
4793
4794 <p>
4795 The code uses x % 2 == 1 to check to see if a value is odd, but this won't work
4796 for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check
4797 for oddness, consider using x &amp; 1 == 1, or x % 2 != 0.
4798 </p>
4799
4800
4801 <h3><a name="INT_BAD_REM_BY_1">INT: Integer remainder modulo 1 (INT_BAD_REM_BY_1)</a></h3>
4802
4803
4804 <p> Any expression (exp % 1) is guaranteed to always return zero.
4805 Did you mean (exp &amp; 1) or (exp % 2) instead?
4806 </p>
4807
4808
4809 <h3><a name="INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit mask operation on integer value (INT_VACUOUS_BIT_OPERATION)</a></h3>
4810
4811
4812 <p> This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work
4813 (e.g., <code>v & 0xffffffff</code>).
4814
4815 </p>
4816
4817
4818 <h3><a name="INT_VACUOUS_COMPARISON">INT: Vacuous comparison of integer value (INT_VACUOUS_COMPARISON)</a></h3>
4819
4820
4821 <p> There is an integer comparison that always returns
4822 the same value (e.g., x &lt;= Integer.MAX_VALUE).
4823 </p>
4824
4825
4826 <h3><a name="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: Class extends Servlet class and uses instance variables (MTIA_SUSPECT_SERVLET_INSTANCE_FIELD)</a></h3>
4827
4828
4829 <p>
4830 This class extends from a Servlet class, and uses an instance member variable. Since only
4831 one instance of a Servlet class is created by the J2EE framework, and used in a
4832 multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider
4833 only using method local variables.
4834 </p>
4835
4836
4837 <h3><a name="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: Class extends Struts Action class and uses instance variables (MTIA_SUSPECT_STRUTS_INSTANCE_FIELD)</a></h3>
4838
4839
4840 <p>
4841 This class extends from a Struts Action class, and uses an instance member variable. Since only
4842 one instance of a struts Action class is created by the Struts framework, and used in a
4843 multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider
4844 only using method local variables. Only instance fields that are written outside of a monitor
4845 are reported.
4846 </p>
4847
4848
4849 <h3><a name="NP_DEREFERENCE_OF_READLINE_VALUE">NP: Dereference of the result of readLine() without nullcheck (NP_DEREFERENCE_OF_READLINE_VALUE)</a></h3>
4850
4851
4852 <p> The result of invoking readLine() is dereferenced without checking to see if the result is null. If there are no more lines of text
4853 to read, readLine() will return null and dereferencing that will generate a null pointer exception.
4854 </p>
4855
4856
4857 <h3><a name="NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Immediate dereference of the result of readLine() (NP_IMMEDIATE_DEREFERENCE_OF_READLINE)</a></h3>
4858
4859
4860 <p> The result of invoking readLine() is immediately dereferenced. If there are no more lines of text
4861 to read, readLine() will return null and dereferencing that will generate a null pointer exception.
4862 </p>
4863
4864
4865 <h3><a name="NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Load of known null value (NP_LOAD_OF_KNOWN_NULL_VALUE)</a></h3>
4866
4867
4868 <p> The variable referenced at this point is known to be null due to an earlier
4869 check against null. Although this is valid, it might be a mistake (perhaps you
4870 intended to refer to a different variable, or perhaps the earlier check to see if the
4871 variable is null should have been a check to see if it was nonnull).
4872 </p>
4873
4874
4875 <h3><a name="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP: Method tightens nullness annotation on parameter (NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION)</a></h3>
4876
4877 <p>
4878 A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter
4879 that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.
4880 Doing so violates the contract that the method should handle a null parameter.
4881 </p>
4882
4883 <h3><a name="NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Method relaxes nullness annotation on return value (NP_METHOD_RETURN_RELAXING_ANNOTATION)</a></h3>
4884
4885 <p>
4886 A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated
4887 as returning a @Nonnull value,
4888 you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value.
4889 Doing so violates the contract that the method shouldn't return null.
4890 </p>
4891
4892 <h3><a name="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP: Possible null pointer dereference due to return value of called method (NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE)</a></h3>
4893
4894
4895 <p> The return value from a method is dereferenced without a null check,
4896 and the return value of that method is one that should generally be checked
4897 for null. This may lead to a <code>NullPointerException</code> when the code is executed.
4898 </p>
4899
4900
4901 <h3><a name="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP: Possible null pointer dereference on branch that might be infeasible (NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE)</a></h3>
4902
4903
4904 <p> There is a branch of statement that, <em>if executed,</em> guarantees that
4905 a null value will be dereferenced, which
4906 would generate a <code>NullPointerException</code> when the code is executed.
4907 Of course, the problem might be that the branch or statement is infeasible and that
4908 the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
4909 Due to the fact that this value had been previously tested for nullness,
4910 this is a definite possibility.
4911 </p>
4912
4913
4914 <h3><a name="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP: Parameter must be nonnull but is marked as nullable (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE)</a></h3>
4915
4916
4917 <p> This parameter is always used in a way that requires it to be nonnull,
4918 but the parameter is explicitly annotated as being Nullable. Either the use
4919 of the parameter or the annotation is wrong.
4920 </p>
4921
4922
4923 <h3><a name="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP: Read of unwritten public or protected field (NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
4924
4925
4926 <p> The program is dereferencing a public or protected
4927 field that does not seem to ever have a non-null value written to it.
4928 Unless the field is initialized via some mechanism not seen by the analysis,
4929 dereferencing this value will generate a null pointer exception.
4930 </p>
4931
4932
4933 <h3><a name="NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentially dangerous use of non-short-circuit logic (NS_DANGEROUS_NON_SHORT_CIRCUIT)</a></h3>
4934
4935
4936 <p> This code seems to be using non-short-circuit logic (e.g., &amp;
4937 or |)
4938 rather than short-circuit logic (&amp;&amp; or ||). In addition,
4939 it seem possible that, depending on the value of the left hand side, you might not
4940 want to evaluate the right hand side (because it would have side effects, could cause an exception
4941 or could be expensive.</p>
4942 <p>
4943 Non-short-circuit logic causes both sides of the expression
4944 to be evaluated even when the result can be inferred from
4945 knowing the left-hand side. This can be less efficient and
4946 can result in errors if the left-hand side guards cases
4947 when evaluating the right-hand side can generate an error.
4948 </p>
4949
4950 <p>See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java
4951 Language Specification</a> for details
4952
4953 </p>
4954
4955
4956 <h3><a name="NS_NON_SHORT_CIRCUIT">NS: Questionable use of non-short-circuit logic (NS_NON_SHORT_CIRCUIT)</a></h3>
4957
4958
4959 <p> This code seems to be using non-short-circuit logic (e.g., &amp;
4960 or |)
4961 rather than short-circuit logic (&amp;&amp; or ||).
4962 Non-short-circuit logic causes both sides of the expression
4963 to be evaluated even when the result can be inferred from
4964 knowing the left-hand side. This can be less efficient and
4965 can result in errors if the left-hand side guards cases
4966 when evaluating the right-hand side can generate an error.
4967
4968 <p>See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java
4969 Language Specification</a> for details
4970
4971 </p>
4972
4973
4974 <h3><a name="PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Consider returning a zero length array rather than null (PZLA_PREFER_ZERO_LENGTH_ARRAYS)</a></h3>
4975
4976
4977 <p> It is often a better design to
4978 return a length zero array rather than a null reference to indicate that there
4979 are no results (i.e., an empty list of results).
4980 This way, no explicit check for null is needed by clients of the method.</p>
4981
4982 <p>On the other hand, using null to indicate
4983 "there is no answer to this question" is probably appropriate.
4984 For example, <code>File.listFiles()</code> returns an empty list
4985 if given a directory containing no files, and returns null if the file
4986 is not a directory.</p>
4987
4988
4989 <h3><a name="QF_QUESTIONABLE_FOR_LOOP">QF: Complicated, subtle or wrong increment in for-loop (QF_QUESTIONABLE_FOR_LOOP)</a></h3>
4990
4991
4992 <p>Are you sure this for loop is incrementing the correct variable?
4993 It appears that another variable is being initialized and checked
4994 by the for loop.
4995 </p>
4996
4997
4998 <h3><a name="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">RCN: Redundant comparison of non-null value to null (RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE)</a></h3>
4999
5000
5001 <p> This method contains a reference known to be non-null with another reference
5002 known to be null.</p>
5003
5004
5005 <h3><a name="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RCN: Redundant comparison of two null values (RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES)</a></h3>
5006
5007
5008 <p> This method contains a redundant comparison of two references known to
5009 both be definitely null.</p>
5010
5011
5012 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RCN: Redundant nullcheck of value known to be non-null (RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE)</a></h3>
5013
5014
5015 <p> This method contains a redundant check of a known non-null value against
5016 the constant null.</p>
5017
5018
5019 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN: Redundant nullcheck of value known to be null (RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE)</a></h3>
5020
5021
5022 <p> This method contains a redundant check of a known null value against
5023 the constant null.</p>
5024
5025
5026 <h3><a name="REC_CATCH_EXCEPTION">REC: Exception is caught when Exception is not thrown (REC_CATCH_EXCEPTION)</a></h3>
5027
5028
5029 <p>
5030 This method uses a try-catch block that catches Exception objects, but Exception is not
5031 thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to
5032 say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception
5033 each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well,
5034 masking potential bugs.
5035 </p>
5036 <p>A better approach is to either explicitly catch the specific exceptions that are thrown,
5037 or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p>
5038 <pre>
5039 try {
5040 ...
5041 } catch (RuntimeException e) {
5042 throw e;
5043 } catch (Exception e) {
5044 ... deal with all non-runtime exceptions ...
5045 }</pre>
5046
5047
5048 <h3><a name="RI_REDUNDANT_INTERFACES">RI: Class implements same interface as superclass (RI_REDUNDANT_INTERFACES)</a></h3>
5049
5050
5051 <p>
5052 This class declares that it implements an interface that is also implemented by a superclass.
5053 This is redundant because once a superclass implements an interface, all subclasses by default also
5054 implement this interface. It may point out that the inheritance hierarchy has changed since
5055 this class was created, and consideration should be given to the ownership of
5056 the interface's implementation.
5057 </p>
5058
5059
5060 <h3><a name="RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Method checks to see if result of String.indexOf is positive (RV_CHECK_FOR_POSITIVE_INDEXOF)</a></h3>
5061
5062
5063 <p> The method invokes String.indexOf and checks to see if the result is positive or non-positive.
5064 It is much more typical to check to see if the result is negative or non-negative. It is
5065 positive only if the substring checked for occurs at some place other than at the beginning of
5066 the String.</p>
5067
5068
5069 <h3><a name="RV_DONT_JUST_NULL_CHECK_READLINE">RV: Method discards result of readLine after checking if it is nonnull (RV_DONT_JUST_NULL_CHECK_READLINE)</a></h3>
5070
5071
5072 <p> The value returned by readLine is discarded after checking to see if the return
5073 value is non-null. In almost all situations, if the result is non-null, you will want
5074 to use that non-null value. Calling readLine again will give you a different line.</p>
5075
5076
5077 <h3><a name="RV_REM_OF_HASHCODE">RV: Remainder of hashCode could be negative (RV_REM_OF_HASHCODE)</a></h3>
5078
5079
5080 <p> This code computes a hashCode, and then computes
5081 the remainder of that value modulo another value. Since the hashCode
5082 can be negative, the result of the remainder operation
5083 can also be negative. </p>
5084 <p> Assuming you want to ensure that the result of your computation is nonnegative,
5085 you may need to change your code.
5086 If you know the divisor is a power of 2,
5087 you can use a bitwise and operator instead (i.e., instead of
5088 using <code>x.hashCode()%n</code>, use <code>x.hashCode()&amp;(n-1)</code>.
5089 This is probably faster than computing the remainder as well.
5090 If you don't know that the divisor is a power of 2, take the absolute
5091 value of the result of the remainder operation (i.e., use
5092 <code>Math.abs(x.hashCode()%n)</code>
5093 </p>
5094
5095
5096 <h3><a name="RV_REM_OF_RANDOM_INT">RV: Remainder of 32-bit signed random integer (RV_REM_OF_RANDOM_INT)</a></h3>
5097
5098
5099 <p> This code generates a random signed integer and then computes
5100 the remainder of that value modulo another value. Since the random
5101 number can be negative, the result of the remainder operation
5102 can also be negative. Be sure this is intended, and strongly
5103 consider using the Random.nextInt(int) method instead.
5104 </p>
5105
5106
5107 <h3><a name="RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method ignores return value, is this OK? (RV_RETURN_VALUE_IGNORED_INFERRED)</a></h3>
5108
5109
5110 <p>This code calls a method and ignores the return value. The return value
5111 is the same type as the type the method is invoked on, and from our analysis it looks
5112 like the return value might be important (e.g., like ignoring the
5113 return value of <code>String.toLowerCase()</code>).
5114 </p>
5115 <p>We are guessing that ignoring the return value might be a bad idea just from
5116 a simple analysis of the body of the method. You can use a @CheckReturnValue annotation
5117 to instruct FindBugs as to whether ignoring the return value of this method
5118 is important or acceptable.
5119 </p>
5120 <p>Please investigate this closely to decide whether it is OK to ignore the return value.
5121 </p>
5122
5123
5124 <h3><a name="SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assignment of field (SA_FIELD_DOUBLE_ASSIGNMENT)</a></h3>
5125
5126
5127 <p> This method contains a double assignment of a field; e.g.
5128 </p>
5129 <pre>
5130 int x,y;
5131 public void foo() {
5132 x = x = 17;
5133 }
5134 </pre>
5135 <p>Assigning to a field twice is useless, and may indicate a logic error or typo.</p>
5136
5137
5138 <h3><a name="SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assignment of local variable (SA_LOCAL_DOUBLE_ASSIGNMENT)</a></h3>
5139
5140
5141 <p> This method contains a double assignment of a local variable; e.g.
5142 </p>
5143 <pre>
5144 public void foo() {
5145 int x,y;
5146 x = x = 17;
5147 }
5148 </pre>
5149 <p>Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.</p>
5150
5151
5152 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT">SA: Self assignment of local variable (SA_LOCAL_SELF_ASSIGNMENT)</a></h3>
5153
5154
5155 <p> This method contains a self assignment of a local variable; e.g.</p>
5156 <pre>
5157 public void foo() {
5158 int x = 3;
5159 x = x;
5160 }
5161 </pre>
5162 <p>
5163 Such assignments are useless, and may indicate a logic error or typo.
5164 </p>
5165
5166
5167 <h3><a name="SF_SWITCH_FALLTHROUGH">SF: Switch statement found where one case falls through to the next case (SF_SWITCH_FALLTHROUGH)</a></h3>
5168
5169
5170 <p> This method contains a switch statement where one case branch will fall through to the next case.
5171 Usually you need to end this case with a break or return.</p>
5172
5173
5174 <h3><a name="SF_SWITCH_NO_DEFAULT">SF: Switch statement found where default case is missing (SF_SWITCH_NO_DEFAULT)</a></h3>
5175
5176
5177 <p> This method contains a switch statement where default case is missing.
5178 Usually you need to provide a default case.</p>
5179 <p>Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if
5180 the default case is at the end of the switch statement and doesn't end with a break statement.
5181
5182
5183 <h3><a name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST: Write to static field from instance method (ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD)</a></h3>
5184
5185
5186 <p> This instance method writes to a static field. This is tricky to get
5187 correct if multiple instances are being manipulated,
5188 and generally bad practice.
5189 </p>
5190
5191
5192 <h3><a name="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: Private readResolve method not inherited by subclasses (SE_PRIVATE_READ_RESOLVE_NOT_INHERITED)</a></h3>
5193
5194
5195 <p> This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses.
5196 This might be intentional and OK, but should be reviewed to ensure it is what is intended.
5197 </p>
5198
5199
5200 <h3><a name="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">Se: Transient field of class that isn't Serializable. (SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS)</a></h3>
5201
5202
5203 <p> The field is marked as transient, but the class isn't Serializable, so marking it as transient
5204 has absolutely no effect.
5205 This may be leftover marking from a previous version of the code in which the class was transient, or
5206 it may indicate a misunderstanding of how serialization works.
5207 </p>
5208
5209
5210 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value required to have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK)</a></h3>
5211
5212
5213 <p>
5214 A value is used in a way that requires it to be always be a value denoted by a type qualifier, but
5215 there is an explicit annotation stating that it is not known where the value is required to have that type qualifier.
5216 Either the usage or the annotation is incorrect.
5217 </p>
5218
5219
5220 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value required to not have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK)</a></h3>
5221
5222
5223 <p>
5224 A value is used in a way that requires it to be never be a value denoted by a type qualifier, but
5225 there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier.
5226 Either the usage or the annotation is incorrect.
5227 </p>
5228
5229
5230 <h3><a name="UCF_USELESS_CONTROL_FLOW">UCF: Useless control flow (UCF_USELESS_CONTROL_FLOW)</a></h3>
5231
5232
5233 <p> This method contains a useless control flow statement, where
5234 control flow continues onto the same place regardless of whether or not
5235 the branch is taken. For example,
5236 this is caused by having an empty statement
5237 block for an <code>if</code> statement:</p>
5238 <pre>
5239 if (argv.length == 0) {
5240 // TODO: handle this case
5241 }
5242 </pre>
5243
5244
5245 <h3><a name="UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Useless control flow to next line (UCF_USELESS_CONTROL_FLOW_NEXT_LINE)</a></h3>
5246
5247
5248 <p> This method contains a useless control flow statement in which control
5249 flow follows to the same or following line regardless of whether or not
5250 the branch is taken.
5251 Often, this is caused by inadvertently using an empty statement as the
5252 body of an <code>if</code> statement, e.g.:</p>
5253 <pre>
5254 if (argv.length == 1);
5255 System.out.println("Hello, " + argv[0]);
5256 </pre>
5257
5258
5259 <h3><a name="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: Unread public/protected field (URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5260
5261
5262 <p> This field is never read.&nbsp;
5263 The field is public or protected, so perhaps
5264 it is intended to be used with classes not seen as part of the analysis. If not,
5265 consider removing it from the class.</p>
5266
5267
5268 <h3><a name="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: Unused public or protected field (UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5269
5270
5271 <p> This field is never used.&nbsp;
5272 The field is public or protected, so perhaps
5273 it is intended to be used with classes not seen as part of the analysis. If not,
5274 consider removing it from the class.</p>
5275
5276
5277 <h3><a name="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">UwF: Field not initialized in constructor but dereferenced without null check (UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3>
5278
5279
5280 <p> This field is never initialized within any constructor, and is therefore could be null after
5281 the object is constructed. Elsewhere, it is loaded and dereferenced without a null check.
5282 This could be a either an error or a questionable design, since
5283 it means a null pointer exception will be generated if that field is dereferenced
5284 before being initialized.
5285 </p>
5286
5287
5288 <h3><a name="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF: Unwritten public or protected field (UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3>
5289
5290
5291 <p> No writes were seen to this public/protected field.&nbsp; All reads of it will return the default
5292 value. Check for errors (should it have been initialized?), or remove it if it is useless.</p>
5293
5294
5295 <h3><a name="XFB_XML_FACTORY_BYPASS">XFB: Method directly allocates a specific implementation of xml interfaces (XFB_XML_FACTORY_BYPASS)</a></h3>
5296
5297
5298 <p>
5299 This method allocates a specific implementation of an xml interface. It is preferable to use
5300 the supplied factory classes to create these objects so that the implementation can be
5301 changed at runtime. See
5302 </p>
5303 <ul>
5304 <li>javax.xml.parsers.DocumentBuilderFactory</li>
5305 <li>javax.xml.parsers.SAXParserFactory</li>
5306 <li>javax.xml.transform.TransformerFactory</li>
5307 <li>org.w3c.dom.Document.create<i>XXXX</i></li>
5308 </ul>
5309 <p>for details.</p>
5310
5311
5312
5313
5314 <hr> <p>
5315 <script language="JavaScript" type="text/javascript">
5316 <!---//hide script from old browsers
5317 document.write( "Last updated "+ document.lastModified + "." );
5318 //end hiding contents --->
5319 </script>
5320 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
5321 <p>
5322 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
5323 </td></tr></table>
5324 </body></html>
Binary diff not shown
0 <html>
1 <head>
2 <title>Contributing to FindBugs</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>Contributing to FindBugs</h1>
57
58 <p> If you have a bug fix or feature enhancement you would like to contribute,
59 we would be happy to consider it for inclusion.</p>
60
61 <h2>Import FindBugs code as Eclipse projects</h2>
62
63 <p>The preferred way to get the FindBugs source code and create the patch is to use Eclipse + SVN.
64 You can easily import FindBugs code into Eclipse by following the steps described
65 here: <a href="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/doc/building_findbugsplugin.txt">Import Eclipse projects</a>
66 .
67 </p>
68
69 <h2>Preparing a patch</h2>
70
71 <p> The best way to
72 send an enhancement is to create a patch against the latest code
73 in the FindBugs Subversion repository
74 at <a href="http://findbugs.googlecode.com/svn/trunk/">http://findbugs.googlecode.com/svn/trunk/</a>
75 (those people who have been given commit priviledges should use
76 <a href="https://findbugs.googlecode.com/svn/trunk/">http<b>s</b>://findbugs.googlecode.com/svn/trunk/</a>).
77 </p>
78
79 <p>To create a patch from Eclipse, please right click the [findbugs] or [findBugsEclipsePlugin] project
80 and choose [Team | Create Patch...] context menu.
81 </p>
82
83 <p> Please follow these guidelines when preparing your patch:</p>
84 <ul>
85 <li> <b>Use the same indentation style as the source file(s) you
86 are modifying</b>.&nbsp; In particular, please use tabs (not spaces)
87 to indent your code; one tab per indent level.
88 <li> If at all possible, avoid making whitespace modifications.
89 <li> Small patches are appreciated.
90 <li> If you are submitting a new bug detector, please submit a small
91 standalone source file that contains an instance of the
92 kind of bug the detector looks for.
93 </ul>
94
95 <p> Following these guidelines makes it much easier for us
96 to incorporate new code.
97
98 <h2>How to submit a patch</h2>
99
100 <p> Patches may be submitted through the
101 <a href="http://sourceforge.net/tracker/?atid=614695&group_id=96405&func=browse">Patches</a> tracker on the
102 <a href="http://sourceforge.net/projects/findbugs/">sourceforge project page</a>.
103
104
105 <hr> <p>
106 <script language="JavaScript" type="text/javascript">
107 <!---//hide script from old browsers
108 document.write( "Last updated "+ document.lastModified + "." );
109 //end hiding contents --->
110 </script>
111 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
112 <p>
113 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
114
115 </td>
116
117 </tr></table>
118
119 </body>
120 </html>
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 <html>
1 <head>
2 <title>FindBugs&trade; 1.2 Demo and Results</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css" />
4
5 </head>
6
7 <body>
8
9 <table width="100%"><tr>
10
11
12 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
13 <table width="100%" cellspacing="0" border="0">
14 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
15
16 <tr><td>&nbsp;</td></tr>
17
18 <tr><td><b>Docs and Info</b></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
31
32 <tr><td>&nbsp;</td></tr>
33
34 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
35
36 <tr><td>&nbsp;</td></tr>
37
38 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
39
40 <tr><td>&nbsp;</td></tr>
41
42 <tr><td><b>Development</b></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
52 </table>
53 </td>
54
55 <td align="left" valign="top">
56 <h1>
57 FindBugs 1.2 demo and results
58 </h1>
59
60 <p>If you just want to try running FindBugs against your
61 own code, you can
62 <a href="http://findbugs.cs.umd.edu/demo/jnlp/findbugs.jnlp">run FindBugs</a> using Java Webstart.
63 This will use our new gui under Java 1.5+ and our old gui under Java 1.4.
64 The new gui provides a number of new features, but requires Java 1.5+.
65 Both use exactly the same analysis engine.
66
67 </p><p>This web page provides results of running FindBugs 1.2.0
68 against several open source applications. We provide a summary
69 of the number of bugs we found, as well as a generated HTML listing
70 of the bugs and
71 a <a href="http://java.sun.com/products/javawebstart/">Java
72 WebStart</a> demo of the new GUI we've introduced in FindBugs version 1.1,
73 displaying the warnings and the relevant source.
74
75
76 </p><p>The applications and versions of them we report on
77 are somewhat arbitrary. In some cases, they are release versions,
78 in other cases nightly builds. We find lots of bugs in every large code
79 base we examine; these applications are certainly not the worst we have seen.
80 I have been allowed to confidentially examine the results of running FindBugs
81 against several closed commercial code bases by well respected companies;
82 the results I've seen there are not significantly different from
83 what I've observed in open source code bases.
84
85
86 </p><p><em>Experimental details</em>: These results are from running
87 FindBugs 1.2.0 at standard effort level. Our results do not include
88 any low priority warnings or any warnings about vulnerabilities to
89 malicious code. Although we have (repeatedly) manually audited the results,
90 we haven't manually filtered out false positives from these warnings,
91 so that you can get a feeling for the quality of the warnings generated
92 by FindBugs.
93 </p><p>Some of the bugs contain audit comments: they are marked as to whether
94 we thought the warning indicated a bug that should or must be fixed, or whether it was not, in fact, a bug.
95 </p><p>In the webstart versions, we've only included the bugs for which
96 we were able to identify source files. The number of lines of non-commenting source
97 statements in the table below (KNCSS) is derived from the same files
98 that we analyzed and in which we report bugs; we actually compute
99 KNCSS from the classfiles, not the source files.
100
101 </p><p><em>Vulnerability disclosure</em>: Thankfully, Java isn't C or C++. Dereferencing
102 a null pointer or accessing outside the bounds of an array generates a runtime
103 exception rather than a shell exploit. We do not believe that any of the
104 warnings here represents a security vulnerability, although we have not audited
105 them to verify that. These projects are all aware of the existence of
106 FindBugs, and FindBugs is already open source and available
107 for use both by developers and attackers, we don't believe that making
108 these results available constitutes a reckless disclosure.
109
110
111 </p><p><em>Recommendations</em>: First, review the correctness warnings.
112 We feel confident that developers
113 would want to fix most of the high and medium priority correctness warnings we report.
114 Once you've reviewed those,
115 you might want to look at some of the other categories.
116 </p><p>
117 In other categories,
118 such as Bad practice and Dodgy code, we accept more false positives. You
119 might decide that a pattern bug pattern isn't relevant for your code
120 base (e.g., you never use Serialization for persistent storage,
121 so you never care about the fact that you didn't define a serializationUID),
122 and even for the bug patterns relevant to your code base,
123 perhaps only a minority will reflect problems serious enough to
124 convince you to change your code.
125
126 </p><p><em>Please be patient</em> The Web start versions not only have to download the applications,
127 they need to download about 10 megabytes of data and source files. Please
128 be patient. Sorry we don't have a progress bar for the data and source download;
129 the ability to remotely download a data and source archive is a little bit of
130 a hack. We've provided small versions of some of the data sets that include
131 only the correctness bugs and the source files containing those warnings. The small
132 datasets are about a quarter of the sizes of the full datasets.
133 </p>
134 <p>
135 </p><table border="2">
136 <tr><th rowspan="2">Application</th><th colspan="2">Details</th><th colspan="2">Correctness bugs</th><th rowspan="2">Bad Practice</th><th rowspan="2">Dodgy</th><th rowspan="2">KNCSS
137 </th></tr><tr><th>HTML</th><th>WebStart</th><th>NP bugs</th><th>Other
138 </th></tr><tr><td align="right">Sun JDK 1.7.0-b12</td><td align="right">
139 <a href="http://findbugs.cs.umd.edu/demo/jdk7/index.html">All</a>
140 </td><td align="right">
141 <a href="http://findbugs.cs.umd.edu/demo/jdk7/index.jnlp">All</a>
142 <a href="http://findbugs.cs.umd.edu/demo/jdk7/small.jnlp">Small</a>
143 </td><td align="right">68</td><td align="right">180</td><td align="right">954</td><td align="right">654</td><td align="right">597
144
145 </td></tr><tr><td align="right">eclipse-SDK-3.3M7-solaris-gtk</td><td align="right">
146 <a href="http://findbugs.cs.umd.edu/demo/eclipse/index.html">All</a>
147 </td><td align="right">
148 <a href="http://findbugs.cs.umd.edu/demo/eclipse/index.jnlp">All</a>
149 <a href="http://findbugs.cs.umd.edu/demo/eclipse/small.jnlp">Small</a>
150 </td><td align="right">146</td><td align="right">259</td><td align="right">1,079</td><td align="right">643</td><td align="right">1,447
151
152 </td></tr><tr><td align="right">netbeans-6_0-m8</td><td align="right">
153 <a href="http://findbugs.cs.umd.edu/demo/netbeans/index.html">All</a>
154 </td><td align="right">
155 <a href="http://findbugs.cs.umd.edu/demo/netbeans/index.jnlp">All</a>
156 <a href="http://findbugs.cs.umd.edu/demo/netbeans/small.jnlp">Small</a>
157 </td><td align="right">189</td><td align="right">305</td><td align="right">3,010</td><td align="right">1,112</td><td align="right">1,022
158
159 </td></tr><tr><td align="right">glassfish-v2-b43</td><td align="right">
160 <a href="http://findbugs.cs.umd.edu/demo/glassfish/index.html">All</a>
161 </td><td align="right">
162 <a href="http://findbugs.cs.umd.edu/demo/glassfish/index.jnlp">All</a>
163 <a href="http://findbugs.cs.umd.edu/demo/glassfish/small.jnlp">Small</a>
164 </td><td align="right">146</td><td align="right">154</td><td align="right">964</td><td align="right">1,222</td><td align="right">2,176
165
166 </td></tr><tr><td align="right">jboss-4.0.5</td><td align="right">
167 <a href="http://findbugs.cs.umd.edu/demo/jboss/index.html">All</a>
168 </td><td align="right">
169 <a href="http://findbugs.cs.umd.edu/demo/jboss/index.jnlp">All</a>
170 <a href="http://findbugs.cs.umd.edu/demo/jboss/small.jnlp">Small</a>
171 </td><td align="right">30</td><td align="right">57</td><td align="right">263</td><td align="right">214</td><td align="right">178
172
173 </td></tr></table>
174 <p><em>KNCSS</em> - Thousands of lines of non-commenting source statements
175
176 </p><h2>Bug categories</h2>
177 <dl>
178 <dt>Correctness bug
179 </dt><dd>Probable bug - an apparent coding mistake
180 resulting in code that was probably not what the
181 developer intended. We strive for a low false positive rate.
182 </dd><dt>Bad Practice
183 </dt><dd>
184 Violations of recommended and essential
185 coding practice. Examples include hash code and equals
186 problems, cloneable idiom, dropped exceptions,
187 serializable problems, and misuse of finalize.
188 We strive to make this analysis accurate,
189 although some groups may
190 not care about some of the bad practices.
191 </dd><dt>Dodgy
192 </dt><dd>
193 Code that is confusing, anomalous, or
194 written in a way that leads itself to errors.
195 Examples include dead local stores, switch fall through,
196 unconfirmed casts, and redundant null check of value
197 known to be null.
198 More false positives accepted.
199 In previous versions of FindBugs, this category was known as Style.
200 </dl>
201
202
203 <hr> <p>
204 <script language="JavaScript" type="text/javascript">
205 <!---//hide script from old browsers
206 document.write( "Last updated "+ document.lastModified + "." );
207 //end hiding contents --->
208 </script>
209 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
210 <p>
211 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A></td></tr></table>
212
213 </body>
214 </html>
215
216
217
218
0 <html>
1 <head>
2 <title>FindBugs Downloads</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs downloads</h1>
57
58 <p> This page contains links to downloads
59 of FindBugs version 2.0.3,
60 released on 17:16:15 EST, 22 November, 2013. Download links
61 for all FindBugs versions and files
62 are <a href="http://sourceforge.net/project/showfiles.php?group_id=96405">available
63 on the sourceforge download page</a>.
64
65 <ul>
66 <li>
67 FindBugs tool (standard version with command line, ant, and Swing interfaces)
68 <ul>
69 <li><a href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.tar.gz?download">findbugs-2.0.3.tar.gz</a></li>
70 <li><a href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.zip?download">findbugs-2.0.3.zip</a></li>
71 <li><a href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download">findbugs-2.0.3-source.zip</a></li>
72 </ul>
73 </li>
74 <li>
75 The following versions of FindBugs are pre-configured to disable <a href="updateChecking.html">checks for updated versions</a>
76 of FindBugs, and
77 the plugin that allows communication with the FindBugs community cloud is disabled by default.
78 Such configurations are appropriate in situations where it is important that no information about the use of FindBugs
79 be disclosed outside of the organization where it is used.
80 <ul>
81 <li><a href="http://prdownloads.sourceforge.net/findbugs/findbugs-noUpdateChecks-2.0.3.tar.gz?download">findbugs-2.0.3.tar.gz</a></li>
82 <li><a href="http://prdownloads.sourceforge.net/findbugs/findbugs-noUpdateChecks-2.0.3.zip?download">findbugs-2.0.3.zip</a></li>
83 </ul>
84 </li>
85 <li>Eclipse plugin for FindBugs version 2.0.3.20131122 (requires Eclipse 3.6 or later)
86 <ul>
87 <li><a href="http://sourceforge.net/projects/findbugs/files/findbugs%20eclipse%20plugin/2.0.3/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122-15020.zip/download">edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122-15020.zip</a>
88 <li><a href="http://sourceforge.net/projects/findbugs/files/findbugs%20eclipse%20plugin/2.0.3/eclipsePlugin-2.0.3.20131122-15020-source.zip/download">
89 eclipsePlugin-2.0.3.20131122-15020-source.zip/download</a>
90 </ul>
91 </li>
92 </ul>
93
94 The Eclipse plugin may also be obtained from one of the FindBugs Eclipse plugin update sites:
95 <ul>
96 <li><a href="http://findbugs.cs.umd.edu/eclipse">http://findbugs.cs.umd.edu/eclipse</a> update site for <b>official</b> releases</li>
97 <li><a href="http://findbugs.cs.umd.edu/eclipse-candidate">http://findbugs.cs.umd.edu/eclipse-candidate</a> update site for <b>candidate</b> releases and official releases</li>
98 <li><a href="http://findbugs.cs.umd.edu/eclipse-daily">http://findbugs.cs.umd.edu/eclipse-daily</a> update site for <b>all</b> releases, including developmental ones</li>
99 </ul>
100
101
102 <hr> <p>
103 <script language="JavaScript" type="text/javascript">
104 <!---//hide script from old browsers
105 document.write( "Last updated "+ document.lastModified + "." );
106 //end hiding contents --->
107 </script>
108 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
109 <p>
110 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
111
112 </td>
113
114 </tr></table>
115
116 </body>
117 </html>
0 <html>
1 <head>
2 <title>FindBugs&trade; Fact Sheet</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs&trade; Fact Sheet</h1>
57
58 <p> FindBugs looks for bugs in Java programs.&nbsp; It is based
59 on the concept of <i>bug patterns</i>.&nbsp; A bug pattern is a code
60 idiom that is often an error.&nbsp; Bug patterns arise for a variety
61 of reasons:
62 </p>
63
64 <ul>
65 <li> Difficult language features
66 <li> Misunderstood API methods
67 <li> Misunderstood invariants when code is modified during maintenance
68 <li> Garden variety mistakes: typos, use of the wrong boolean operator
69 </ul>
70
71 <p> FindBugs uses <i>static analysis</i> to inspect Java bytecode
72 for occurrences of bug patterns.&nbsp;
73 Static analysis means that FindBugs can find bugs by simply inspecting
74 a program's code: executing the program is not necessary.&nbsp;
75 This makes FindBugs very easy to use: in general, you should be
76 able to use it to look for bugs in your code within a few minutes of downloading it.&nbsp;
77 FindBugs works by analyzing Java bytecode (compiled class files),
78 so you don't even need the program's source code to use it.&nbsp;
79 Because its analysis is
80 sometimes imprecise, FindBugs can report <i>false warnings</i>,
81 which are warnings that do not indicate real errors.&nbsp;
82 In practice, the rate of false warnings reported by FindBugs
83 is less than 50%.
84 </p>
85
86 <p>
87 FindBugs supports a plugin architecture allowing anyone to add new
88 bug detectors.&nbsp; The <a href="publications.html">publications page</a>
89 contains links to articles describing how to write a new detector
90 for FindBugs.&nbsp; If you are familiar with Java bytecode
91 you can write a new FindBugs detector in as little as a few minutes.
92 </p>
93
94 <p> FindBugs is free software, available under the terms of the
95 <a href="http://www.gnu.org/copyleft/lesser.html">Lesser GNU Public License</a>.&nbsp;
96 It is written in Java, and can be run with any virtual machine compatible
97 with Sun's JDK 1.5.&nbsp; It can analyze programs written for any version
98 of Java.&nbsp; FindBugs was originally developed by Bill Pugh and David Hovemeyer.&nbsp;
99 It is maintained by Bill Pugh, and
100 a <a href="team.html">team of volunteers</a>.
101 </p>
102
103 <p> FindBugs uses <a href="http://jakarta.apache.org/bcel/">BCEL</a> to
104 analyze Java bytecode.&nbsp;
105 As of version 1.1, FindBugs also supports bug detectors written using
106 the <a href="http://asm.objectweb.org/">ASM</a> bytecode framework.&nbsp;
107 FindBugs uses <a href="http://dom4j.org/">dom4j</a>
108 for XML manipulation.
109 </p>
110
111
112 <hr> <p>
113 <script language="JavaScript" type="text/javascript">
114 <!---//hide script from old browsers
115 document.write( "Last updated "+ document.lastModified + "." );
116 //end hiding contents --->
117 </script>
118 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
119 <p>
120 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
121
122 </td>
123
124 </tr></table>
125
126 </body>
127 </html>
0 BODY {
1 background: white;
2 }
3
4 A.plain {
5 text-decoration: none;
6 }
7
8 A.sidebar {
9 text-decoration: none;
10 }
11
12 A.sidebar:hover, A.sidebar:active {
13 text-decoration: underline;
14 }
0 <html>
1 <head>
2 <title>FindBugs 2&trade; - Find Bugs in Java Programs</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css" />
4
5 </head>
6
7 <body>
8
9 <table width="100%">
10 <tr>
11
12
13 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
14 <table width="100%" cellspacing="0" border="0">
15 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
16
17 <tr><td>&nbsp;</td></tr>
18
19 <tr><td><b>Docs and Info</b></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
31 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
32
33 <tr><td>&nbsp;</td></tr>
34
35 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
36
37 <tr><td>&nbsp;</td></tr>
38
39 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
40
41 <tr><td>&nbsp;</td></tr>
42
43 <tr><td><b>Development</b></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
52 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
53 </table>
54 </td>
55
56 <td align="left" valign="top">
57
58 <p></p>
59 <table>
60 <tr>
61 <td valign="center"><a href="http://findbugs.sourceforge.net/"><img src="buggy-sm.png" alt="FindBugs logo"
62 border="0" /> </a></td>
63 <td valign="center"><a href="http://www.umd.edu/"><img src="informal.png"
64 alt="UMD logo" border="0" /> </a></td>
65 </tr>
66 </table>
67
68 <h1>FindBugs 2</h1>
69
70 <p>This page describes the major changes in FindBugs 2. We are well aware that the documentation on
71 the new features in FindBugs 2.0 have not kept up with the implementation. We will be working to
72 improve the documentation, but don't want to hold up the release any longer to improve the
73 documentation.</p>
74 <p>Anyone currently using FindBugs 1.3.9 should find FindBugs 2.0 to largely be a drop-in
75 replacement that offers better accuracy and performance.</p>
76
77
78 <p>
79 Also check out <a href="http://code.google.com/p/findbugs/w/list">http://code.google.com/p/findbugs/w/list</a>
80 for more information about some recent features/changes in FindBugs.
81 </p>
82
83 <p>The major new features in FindBugs 2 are as follows:</p>
84 <ul>
85 <li>Bug Rank - bugs are given a rank 1-20, and grouped into the categories scariest (rank 1-4),
86 scary (rank 5-9), troubling (rank 10-14), and of concern (rank 15-20).
87 <ul>
88 <li>priority renamed confidence - many people were confused by the priority reported by
89 FindBugs, and considered all HIGH priority issues to be important. To reflect the
90 actually meaning of this attribute of issues, it has been renamed confidence. Issues of
91 different bug patterns should be compared by there rank, not their confidence.</li>
92 </ul>
93
94 </li>
95 <li><a href="#cloud">Cloud storage</a> - having a convent way for developers to share
96 information about when an issue was first seen, and whether it is believed to be a serious
97 problem, is important to successful and cost-effective deployment of static analysis in a large
98 software project.</li>
99 <li><a href="#updateChecks">update checks</a> - FindBugs will check for releases of new
100 versions of FindBugs. Note: we leverage this capability to count the number of FindBugs users.
101 These update checks can easily be disabled.</li>
102 <li><a href="#plugins">Plugins</a> - FindBugs 2.0 makes it much easier to define plugins that
103 provide various capabilities, and install these plugins either on a per user or per installation
104 basis.</li>
105 <li><code>fb</code> command - rather than using the rather haphazard collection of command line
106 scripts developed over the years for running various FindBugs commands, you can now use just
107 one: <code>fb</code>.
108 <ul>
109 <li><code>fb analyze</code> - invokes the FindBugs analysis</li>
110 <li><code>fb gui</code> - launches the FindBugs GUI
111 <li><code>fb list</code> - lists the issues from a FindBugs analysis file</li>
112 <li><code>fb help</code> - lists the command available.</li>
113 </ul>
114 <p>
115 Plugins can be used to extend the commands that can be invoked via
116 <code>fb</code>.
117 </p>
118 </li>
119 <li><a href="#newBugPatterns">New bug patterns and detectors</a>,
120 and improved accuracy
121 </li>
122 <li><a href="#performance">Improved performance</a>: overall, we've seen an average 10%
123 performance improvement over a large range of benchmarks, although a few users have experienced
124 performance regressions we are still trying to understand.</li>
125 <li id="guava">Guava support - working with Kevin Bourrillion, we have provided additional support for the
126 <a href="http://code.google.com/p/guava-libraries/">Guava library</a>, recognizing many common
127 misuse patterns.
128 </li>
129 <li id="jsr305">JSR-305 support - improved detection of problems identified by JSR-305 annotations. In
130 particular, we've significantly improved both the accuracy and performance of the analysis of
131 type qualifiers.</li>
132 </ul>
133
134 <h2 id="cloud">Cloud storage of issue evaluations</h2>
135 <p>For many years, you could store evaluations of FindBugs issues within the XML containing the
136 analysis results. However, this approach did not work well for a team of distributed developers.
137 Instead, we now provide a cloud based mechanism for storing this information. We are providing a
138 free communal cloud (hostied by Google appengine) for storing evaluations of FindBugs issues. You
139 can set up your own private cloud for storing issues, but at the moment this checking out a copy of
140 FindBugs, making some modifications and building the cloud storage plugin from source. We hope to
141 make it easier to have your own private cloud in FindBugs 2.0.1.</p>
142 <p>We have analyzed several large open source projects, and provide Java web start links to allow
143 you to view the results. We'd be happy to work with projects to make the results available from a
144 continuous build:</p>
145 <ul>
146 <li><a href="http://findbugs.cs.umd.edu/cloud/jdk.jnlp">Sun's JDK 8</a></li>
147 <li><a href="http://findbugs.cs.umd.edu/cloud/eclipse.jnlp">Eclipse 3.8</a></li>
148 <li><a href="http://findbugs.cs.umd.edu/cloud/tomcat.jnlp">Apache Tomcat 7.0</a></li>
149 <li><a href="http://findbugs.cs.umd.edu/cloud/intellij.jnlp">IntelliJ IDEA</a></li>
150 <li><a href="http://findbugs.cs.umd.edu/cloud/jboss.jnlp">JBoss</a></li>
151 </ul>
152
153 <h2 id="updateChecks">FindBugs update checks</h2>
154 <p>
155 FindBugs now checks to see if a new version of FindBugs or a plugin has been released. We make use
156 of this check to collect statistics on the operating system, java version, locale and FindBugs entry
157 point (e.g., ant, command line, GUI). <a href="updateChecking.html">More information is
158 available</a>, including information about how to disable update checks if your organization has a
159 policy against allowing the collection of such information. No information about the code being
160 analyzed is reported.
161
162 </p>
163
164 <h2 id="plugins">Plugins</h2>
165 <p>FindBugs 2.0 makes it much easier to customize FindBugs with plugins.</p>
166 <p>FindBugs looks for plugins in two places: your personal home directory, and in FindBugs home
167 (plugins installed in your home directory take precedence). In both places, it looks in two places:
168 the plugin directory, which contains plugins that are enabled by default, and the optionalPlugin
169 directory, which contains plugins that are disabled by default but can be enabled for a particular
170 project.</p>
171 <p>The FindBugs project includes several plugins:</p>
172 <ul>
173 <li><i>Cloud plugins</i>: These plugins provide ways to persist and share information about
174 issues seen in an analysis (e.g., when was this issue first seen, and any evaluations as to
175 whether this is harmless or a must fix issue, as well as comments about the issue from
176 developers)
177 <ul>
178 <li><code>bugCollectionCloud</code> - stores issue evaluations in the XML. The way
179 issue evaluations were always stored before FindBugs 2.0. Distributed in the
180 optionalPlugin directory.</li>
181 <li><code>findbugsCommunalCloud</code> Stores issue evaluations in the communal cloud
182 hosted at findbugs.appspot.com. Distributed in the plugin directory.</li>
183 <li><code>jdbcCloudClient</code> an older, deprecated cloud that stored information in
184 an SQL database. Not distributed, most be built from source.</li>
185 </ul></li>
186 <li><code>noUpdateChecks</code> - Disables checks for updated versions and usage counting.
187 Distributed in the optionalPlugin directory.</li>
188 <li><code>poweruser</code> - provides a number of additional commands for the <code>fb</code>
189 command. It is believed most of these commands are used by few people outside of the FindBugs
190 development team. Distributed in the optionalPlugin directory.</li>
191 <li><i>Bug filing plugins</i>: these plugins assist in the filing of FindBugs issues in built
192 trackers. The bug filing framework is designed to be extensible to other bug filing systems. At
193 the moment, these plugins are not supported, and must be built from source.
194 <ul>
195 <li><code>jira</code></li>
196 <li><code>google code</code></li>
197 </ul></li>
198 </ul>
199 <h2 id="performance">Performance Improvements/regressions</h2>
200 <p>
201 In our own testing, <a href="performance.html">we've seen an overall improvement of 9% in
202 FindBugs performance from 1.3.9 to 2.0.0, with the majority of benchmarks seeing improvements</a>. A
203 few users have reported significant performance regressions and we are <a href="performance.html">asking
204 for more information from anyone seeing significant performance regressions</a>.
205
206 </p>
207 <h2 id="newBugPatterns">New Bug patterns</h2>
208 <ul>
209 <li><a
210 href="http://findbugs.sourceforge.net/bugDescriptions.html#AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION</a>
211 </li>
212 <li><a
213 href="http://findbugs.sourceforge.net/bugDescriptions.html#BX_UNBOXING_IMMEDIATELY_REBOXED">BX_UNBOXING_IMMEDIATELY_REBOXED</a>
214 </li>
215 <li><a
216 href="http://findbugs.sourceforge.net/bugDescriptions.html#CO_COMPARETO_RESULTS_MIN_VALUE">CO_COMPARETO_RESULTS_MIN_VALUE</a>
217 </li>
218 <li><a
219 href="http://findbugs.sourceforge.net/bugDescriptions.html#DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD</a>
220 </li>
221 <li><a href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_ARGUMENTS_WRONG_ORDER">DMI_ARGUMENTS_WRONG_ORDER</a>
222 </li>
223 <li><a
224 href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE</a>
225 </li>
226 <li><a href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_DOH">DMI_DOH</a></li>
227 <li><a
228 href="http://findbugs.sourceforge.net/bugDescriptions.html#DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS</a>
229 </li>
230 <li><a href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_DEFAULT_ENCODING">DM_DEFAULT_ENCODING</a>
231 </li>
232 <li><a href="http://findbugs.sourceforge.net/bugDescriptions.html#ICAST_INT_2_LONG_AS_INSTANT">ICAST_INT_2_LONG_AS_INSTANT</a>
233 </li>
234 <li><a
235 href="http://findbugs.sourceforge.net/bugDescriptions.html#INT_BAD_COMPARISON_WITH_INT_VALUE">INT_BAD_COMPARISON_WITH_INT_VALUE</a>
236 </li>
237 <li><a
238 href="http://findbugs.sourceforge.net/bugDescriptions.html#JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT</a>
239 </li>
240 <li><a
241 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD</a>
242 </li>
243 <li><a
244 href="http://findbugs.sourceforge.net/bugDescriptions.html#OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE</a>
245 </li>
246 <li><a
247 href="http://findbugs.sourceforge.net/bugDescriptions.html#PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS</a>
248 </li>
249 <li><a
250 href="http://findbugs.sourceforge.net/bugDescriptions.html#RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE</a>
251 </li>
252 <li><a
253 href="http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO">RV_NEGATING_RESULT_OF_COMPARETO</a>
254 </li>
255 <li><a
256 href="http://findbugs.sourceforge.net/bugDescriptions.html#RV_RETURN_VALUE_IGNORED_INFERRED">RV_RETURN_VALUE_IGNORED_INFERRED</a>
257 </li>
258 <li><a
259 href="http://findbugs.sourceforge.net/bugDescriptions.html#SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD</a>
260 </li>
261 <li><a
262 href="http://findbugs.sourceforge.net/bugDescriptions.html#URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD</a>
263 </li>
264 <li><a
265 href="http://findbugs.sourceforge.net/bugDescriptions.html#UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD</a>
266 </li>
267 <li><a
268 href="http://findbugs.sourceforge.net/bugDescriptions.html#UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD</a>
269 </li>
270 <li><a
271 href="http://findbugs.sourceforge.net/bugDescriptions.html#VA_FORMAT_STRING_USES_NEWLINE">VA_FORMAT_STRING_USES_NEWLINE</a>
272 </li>
273 <li><a href="http://findbugs.sourceforge.net/bugDescriptions.html#VO_VOLATILE_INCREMENT">VO_VOLATILE_INCREMENT</a>
274 </li>
275 </ul>
276
277 </td>
278 </tr>
279 </table>
280
281 </body>
282 </html>
0 <html>
1 <head>
2 <title>FindBugs&trade; - Find Bugs in Java Programs</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css" />
4
5 </head>
6
7 <body>
8
9 <table width="100%">
10 <tr>
11
12
13 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
14 <table width="100%" cellspacing="0" border="0">
15 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
16
17 <tr><td>&nbsp;</td></tr>
18
19 <tr><td><b>Docs and Info</b></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
31 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
32
33 <tr><td>&nbsp;</td></tr>
34
35 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
36
37 <tr><td>&nbsp;</td></tr>
38
39 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
40
41 <tr><td>&nbsp;</td></tr>
42
43 <tr><td><b>Development</b></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
52 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
53 </table>
54 </td>
55
56 <td align="left" valign="top">
57
58 <p></p>
59 <table>
60 <tr>
61 <td valign="center"><a href="http://findbugs.sourceforge.net/"><img src="buggy-sm.png" alt="FindBugs logo"
62 border="0" /> </a></td>
63 <td valign="center"><a href="http://www.umd.edu/"><img src="informal.png"
64 alt="UMD logo" border="0" /> </a></td>
65 </tr>
66 </table>
67
68 <h1>FindBugs&trade; - Find Bugs in Java Programs</h1>
69
70 <p>
71 This is the web page for FindBugs, a program which uses static analysis to look for bugs in Java
72 code.&nbsp; It is free software, distributed under the terms of the <a
73 href="http://www.gnu.org/licenses/lgpl.html">Lesser GNU Public License</a>. The name
74 FindBugs&trade; and the <a href="buggy-sm.png">FindBugs logo</a> are trademarked by <a
75 href="http://www.umd.edu">The University of Maryland</a>. FindBugs has been downloaded more than
76 a million times.
77 </p>
78
79 <p>The current version of FindBugs is 2.0.3.</p>
80
81 <p>
82 FindBugs requires JRE (or JDK) 1.5.0 or later to run.&nbsp; However, it can analyze programs
83 compiled for any version of Java, from 1.0 to 1.7. Some classfiles compiled for Java 1.8 give
84 FindBugs problems, the next major release of FindBugs will handle Java 1.8 classfiles.
85
86 <p> The current version of FindBugs is 2.0.3,
87
88 released on 17:16:15 EST, 22 November, 2013. <a href="reportingBugs.html">We are very interested in getting
89 feedback on how to improve FindBugs</a>. File bug reports on <a
90 href="http://sourceforge.net/tracker/?func=browse&amp;group_id=96405&amp;atid=614693"> our
91 sourceforge bug tracker</a>
92 </p>
93 <p>The current version of FindBugs may encounter errors when analyzing
94 Java 1.8 bytecode, due to changes in the classfile format. After FindBugs 2.0.3
95 is released, work will start on the next major release of FindBugs, which will
96 be able to analyze Java 1.8 (and will require Java 1.7 to compile and run).
97
98
99 <p>
100 <a href="#changes">Changes</a> | <a href="#talks">Talks</a> | <a href="#papers">Papers </a> | <a
101 href="#sponsors">Sponsors</a> | <a href="#support">Support</a>
102 </p>
103
104 <h1>FindBugs 2.0.3 Release</h1>
105 <p>FindBugs 2.0.3 is intended to be a minor bug fix release over
106 FindBugs 2.0.2. Although than some improvements to existing bug detectors
107 and analysis engines, and a few new bug patterns, and some
108 important bug fixes to the Eclipse plugin, no significant changes
109 should be observed. Consult the <a href="Changes.html">Change log</a>
110 for more details.</p>
111
112 <p>
113 Also check out <a href="http://code.google.com/p/findbugs/w/list">http://code.google.com/p/findbugs/w/list</a>
114 for more information about some recent features/changes in FindBugs.
115 </p>
116
117
118 <h3>
119 <a href="findbugs2.html">Major changes in FindBugs 2.0 (from FindBugs 1.3.x)</a>
120 </h3>
121 <ul>
122 <li><a href="findbugs2.html#cloud">FindBugs Communal cloud</a></li>
123 <li><a href="findbugs2.html#updateChecks">checks for updated versions of FindBugs</a></li>
124 <li><a href="findbugs2.html#plugins">Powerful plugin capabilities</a></li>
125 <li><a href="findbugs2.html#newBugPatterns">new bug patterns</a>,
126 including new/improved support for <a href="findbugs2.html#guava">Guava</a>
127 and <a href="findbugs2.html#jsr305">JSR-305</a>
128 </li>
129 <li><a href="findbugs2.html#performance">improved performance</a></li>
130 </ul>
131
132
133 <h2>Ways to run FindBugs</h2>
134 <p>Here are various ways to run FindBugs. For plugins not supported by the FindBugs team, check to
135 see what version of FindBugs they provide; it might take a little while for the plugins to update to
136 FindBugs 2.0.</p>
137 <dl>
138 <dt>Command line, ant, GUI</dt>
139 <dd>Provided in FindBugs download</dd>
140 <dt>
141 <a href="http://www.eclipse.org/">Eclipse</a>
142 </dt>
143 <dd>
144 Update site for Eclipse plugin: <a href="http://findbugs.cs.umd.edu/eclipse">http://findbugs.cs.umd.edu/eclipse</a>.
145 Supported by the FindBugs project.
146 </dd>
147 <dt>
148 <a href="http://maven.apache.org/">Maven</a>
149 </dt>
150 <dd>
151 <a href="http://mojo.codehaus.org/findbugs-maven-plugin/">http://mojo.codehaus.org/findbugs-maven-plugin/</a>
152 </dd>
153 <dt>
154 <a href="http://netbeans.org/">Netbeans</a>
155 </dt>
156 <dd>
157 <a href="http://kenai.com/projects/sqe/pages/Home">SQE: Software Quality Environment</a>
158 </dd>
159 <dt><a href="https://wiki.jenkins-ci.org/display/JENKINS">Jenkins</a></dt>
160 <dd> <a href="https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin">Jenkins FindBugs Plugin</a>
161
162 <dt>
163 <a href="http://wiki.hudson-ci.org/display/HUDSON/Home">Hudson</a>
164 </dt>
165 <dd>
166 <a href="http://wiki.hudson-ci.org/display/HUDSON/FindBugs+Plugin"> HUDSON FindBugs Plugin</a>
167 </dd>
168 <dt>
169 <a href="http://www.jetbrains.com/idea/">IntelliJ</a>
170 </dt>
171 <dd>
172 Several plugins, see <a href="http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins">http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins</a>
173 for a description.
174
175 </dd>
176 </dl>
177
178
179 <h1>New</h1>
180 <ul>
181
182 <li>jFormatString library republished at
183 <a href="http://code.google.com/p/j-format-string">http://code.google.com/p/j-format-string</a>.
184 This is the library we use for compile time checking of format strings. It is separately published to
185
186 <li>We're releasing FindBugs 2.0.3.
187
188 Mostly small changes to address false positives, with one important fix to the Eclipse plugin
189 to fix a problem that had prevented the plugin from running in some versions of Eclipse.
190 Check the <a href="Changes.html">change log</a> for more details.
191
192 <li>We've released <a href="findbugs2.html">FindBugs 2.0</a>
193 </li>
194 <li>FindBugs communal cloud and Java web start links:. We have analyzed several large open
195 source projects, and provide Java web start links to allow you to view the results. We'd be
196 happy to work with projects to make the results available from a continuous build:
197 <p></p>
198 <ul>
199 <li><a href="http://findbugs.cs.umd.edu/cloud/jdk.jnlp">Sun's JDK 8</a></li>
200 <li><a href="http://findbugs.cs.umd.edu/cloud/eclipse.jnlp">Eclipse 3.8</a></li>
201 <li><a href="http://findbugs.cs.umd.edu/cloud/tomcat.jnlp">Apache Tomcat 7.0</a></li>
202 <li><a href="http://findbugs.cs.umd.edu/cloud/intellij.jnlp">IntelliJ IDEA</a></li>
203 <li><a href="http://findbugs.cs.umd.edu/cloud/jboss.jnlp">JBoss</a></li>
204 </ul>
205 </li>
206 </ul>
207
208
209
210 <h1>Experience with FindBugs</h1>
211 <ul>
212 <li><b>Google FindBugs Fixit</b>: Google has a tradition of <a
213 href="http://www.nytimes.com/2007/10/21/jobs/21pre.html">engineering fixits</a>, special days where
214 they try to get all of their engineers focused on some specific problem or technique for improving
215 the systems at Google. A fixit might work to improve web accessibility, internal testing, removing
216 TODO's from internal software, etc.
217
218 <p>In 2009, Google held a global fixit for UMD's FindBugs tool a static analysis tool for
219 finding coding mistakes in Java software. The focus of the fixit was to get feedback on the
220 4,000 highest confidence issues found by FindBugs at Google, and let Google engineers decide
221 which issues, if any, needed fixing.</p>
222 <p>More than 700 engineers ran FindBugs from dozens of offices. More than 250 of them entered
223 more than 8,000 reviews of the issues. A review is a classification of an issue as must-fix,
224 should-fix, mostly-harmless, not-a-bug, and several other categories. More than 75% of the
225 reviews classified issues as must fix, should fix or I will fix. Many of the scariest issues
226 received more than 10 reviews each.</p>
227 <p>Engineers have already submitted changes that made more than 1,100 of the 3,800 issues go
228 away. Engineers filed more than 1,700 bug reports, of which 600 have already been marked as
229 fixed Work continues on addressing the issues raised by the fixit, and on supporting the
230 integration of FindBugs into the software development process at Google.</p>
231 <p>The fixit at Google showcased new capabilities of FindBugs that provide a cloud computing /
232 social networking backdrop. Reviews of issues are immediately persisted into a central store,
233 where they can be seen by other developers, and FindBugs is integrated into the internal Google
234 tools for filing and viewing bug reports and for viewing the version control history of source
235 files. For the Fixit, FindBugs was configured in a mode where engineers could not see reviews
236 from other engineers until they had entered their own; after the fixit, the configuration will
237 be changed to a more open configuration where engineers can see reviews from others without
238 having to provide their own review first. These capabilities have all been contributed to UMD's
239 open source FindBugs tool, although a fair bit of engineering remains to prepare the
240 capabilities for general release and make sure they can integrate into systems outside of
241 Google. The new capabilities are expected to be ready for general release in Fall 2009.</p>
242 </li>
243 </ul>
244
245 <h2>
246 <a name="talks">Talks about FindBugs</a>
247 </h2>
248 <ul>
249 <li>
250 <a href="http://www.cs.umd.edu/~pugh/MistakesThatMatter.pdf">Mistakes That Matter</a>, JavaOne,
251 2009
252 </li>
253 <li><a href="http://youtu.be/jflQSFhYTEo?hd=1">Youtube video</a> showing of demo
254 of our 2.0 Eclipse plugin (5 minutes)</li>
255 <li><a href="http://findbugs.cs.umd.edu/talks/findbugs.mov">Quicktime movie</a> showing of demo
256 of our new GUI to view some of the null pointer bugs in Eclipse (Big file warning: 23 Megabytes)</li>
257 <li><a href="http://findbugs.cs.umd.edu/talks/JavaOne2007-TS2007.pdf">JavaOne 2007 talk on
258 Improving Software Quality Using Static Analysis</a></li>
259 <li><a href="http://findbugs.cs.umd.edu/talks/fb-sdbp-2006.pdf">Talk</a> Bill Pugh gave at <a
260 href="http://www.sdexpo.com/2006/sdbp/">SD Best Practices</a>, Sept 14th (more of a handle on
261 tutorial about using FindBugs)</li>
262 <li><a href="http://findbugs.cs.umd.edu/talks/fb-Sept1213-2006.pdf">Talk</a> Bill Pugh gave at
263 <a href="http://itasoftware.com/">ITA Software</a> and <a href="http://www.csail.mit.edu/">MIT</a>,
264 Sept 12th and 13th (more of a research focus)</li>
265 <li><a href="http://video.google.com/videoplay?docid=-8150751070230264609">Video of talk</a>
266 Bill Pugh gave at <a href="http://www.google.com">Google</a>, July 6th, 2006</li>
267 <li><a href="http://javaposse.com/index.php?post_id=95780">Java Posse podcast interview
268 with Bill Pugh and Brian Goetz</a></li>
269 </ul>
270 <h2>
271 <a name="papers">Papers about FindBugs</a>
272 </h2>
273 <ul>
274 <li><a href="http://findbugs.cs.umd.edu/papers/MoreNullPointerBugs07.pdf">Finding More Null
275 Pointer Bugs, But Not Too Many</a>, by <a href="http://faculty.ycp.edu/~dhovemey/">David
276 Hovemeyer</a>, York College of Pennsylvania and <a href="http://www.cs.umd.edu/~pugh/">William
277 Pugh</a>, Univ. of Maryland, <a href="http://paste07.cs.washington.edu/">7th ACM
278 SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering</a>, June, 2007</li>
279 <li><a href="http://findbugs.cs.umd.edu/papers/FindBugsExperiences07.pdf">Evaluating Static
280 Analysis Defect Warnings On Production Software,</a> <a href="http://www.cs.umd.edu/~nat/">Nathaniel
281 Ayewah</a> and <a href="http://www.cs.umd.edu/~pugh/">William Pugh</a>, Univ. of Maryland, and
282 J. David Morgenthaler, John Penix and YuQian Zhou, Google, Inc., <a
283 href="http://paste07.cs.washington.edu/">7th ACM SIGPLAN-SIGSOFT Workshop on Program
284 Analysis for Software Tools and Engineering</a>, June, 2007
285 </li>
286 </ul>
287
288 <h1>
289 <a name="sponsors">Contributors and Sponsors</a>
290 </h1>
291 <p>
292 The <a href="team.html">current development team</a> consists of <a
293 href="http://www.cs.umd.edu/~pugh">Bill Pugh</a> and <a
294 href="http://andrei.gmxhome.de/privat.html">Andrey Loskutov</a>.
295 </p>
296 <p>The most recent funding for FindBugs comes from a Google Faculty Research Awards.</p>
297 <h2>
298 <a name="support">Additional Support</a>
299 </h2>
300 <p>
301 Numerous <a =href="team.html">people</a> have made significant contributions to the FindBugs
302 project, including founding work by <a href="http://goose.ycp.edu/~dhovemey/">David Hovemeyer</a>
303 and the web cloud infrastructure by Keith Lea.
304 </p>
305 <p>
306 YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC
307 is creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look
308 at YourKit's leading software products: <a href="http://www.yourkit.com/java/profiler/index.jsp">YourKit
309 Java Profiler</a> and <a href="http://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET
310 Profiler</a>.
311 </p>
312 <p>
313 The FindBugs project also uses <a href="http://www.atlassian.com/software/fisheye/">FishEye</a> and
314 <a href="http://www.atlassian.com/software/clover/">Clover</a>, which are generously provided by <a
315 href="http://www.cenqua.com/">Cenqua/Atlassian</a>.
316 </p>
317 <p>
318 Additional financial support for the FindBugs project was provided by <a href="http://www.nsf.gov">National
319 Science Foundation</a> grants ASC9720199 and CCR-0098162,
320 </p>
321 <p>Any opinions, findings and conclusions or recommendations expressed in this material are those of
322 the author(s) and do not necessarily reflect the views of the National Science Foundation (NSF).
323 </p>
324
325 <hr> <p>
326 <script language="JavaScript" type="text/javascript">
327 <!---//hide script from old browsers
328 document.write( "Last updated "+ document.lastModified + "." );
329 //end hiding contents --->
330 </script>
331 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
332 <p>
333 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
334 </td>
335 </tr>
336 </table>
337
338 </body>
339 </html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;14&#31456; &#35613;&#36766;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="license.html" title="&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;14&#31456; &#35613;&#36766;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="license.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;</td></tr></table><hr></div><div class="chapter" title="&#31532;14&#31456; &#35613;&#36766;"><div class="titlepage"><div><div><h2 class="title"><a name="acknowledgments"></a>&#31532;14&#31456; &#35613;&#36766;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="acknowledgments.html#d0e3438">1. &#36002;&#29486;&#32773;</a></span></dt><dt><span class="sect1"><a href="acknowledgments.html#d0e3561">2. &#20351;&#29992;&#12375;&#12390;&#12356;&#12427;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;</a></span></dt></dl></div><div class="sect1" title="1. &#36002;&#29486;&#32773;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e3438"></a>1. &#36002;&#29486;&#32773;</h2></div></div></div><p><span class="application">FindBugs</span> was originally written by Bill Pugh (<code class="email">&lt;<a class="email" href="mailto:pugh@cs.umd.edu">pugh@cs.umd.edu</a>&gt;</code>).
3 David Hovemeyer (<code class="email">&lt;<a class="email" href="mailto:daveho@cs.umd.edu">daveho@cs.umd.edu</a>&gt;</code>) implemented some of the
4 detectors, added the Swing GUI, and is a co-maintainer.</p><p>Mike Fagan (<code class="email">&lt;<a class="email" href="mailto:mfagan@tde.com">mfagan@tde.com</a>&gt;</code>) contributed the <span class="application">Ant</span> build script,
5 the <span class="application">Ant</span> task, and several enhancements and bug fixes to the GUI.</p><p>Germano Leichsenring contributed Japanese translations of the bug
6 summaries.</p><p>David Li contributed the Emacs bug report format.</p><p>Peter D. Stout contributed recursive detection of Class-Path
7 attributes in analyzed Jar files, German translations of
8 text used in the Swing GUI, and other fixes.</p><p>Peter Friese wrote the <span class="application">FindBugs</span> Eclipse plugin.</p><p>Rohan Lloyd contributed several Mac OS X enhancements,
9 bug detector improvements,
10 and maintains the Fink package for <span class="application">FindBugs</span>.</p><p>Hiroshi Okugawa translated the <span class="application">FindBugs</span> manual and
11 more of the bug summaries into Japanese.</p><p>Phil Crosby enhanced the Eclipse plugin to add a view
12 to display the bug details.</p><p>Dave Brosius fixed a number of bugs, added user preferences
13 to the Swing GUI, improved several bug detectors, and
14 contributed the string concatenation detector.</p><p>Thomas Klaeger contributed a number of bug fixes and
15 bug detector improvements.</p><p>Andrei Loskutov made a number of improvements to the
16 Eclipse plugin.</p><p>Brian Goetz contributed a major refactoring of the
17 visitor classes to improve readability and understandability.</p><p> Pete Angstadt fixed several problems in the Swing GUI.</p><p>Francis Lalonde provided a task resource file for the
18 FindBugs Ant task.</p><p>Garvin LeClaire contributed support for output in
19 Xdocs format, for use by Maven.</p><p>Holger Stenzhorn contributed improved German translations of items
20 in the Swing GUI.</p><p>Juha Knuutila contributed Finnish translations of items
21 in the Swing GUI.</p><p>Tanel Lebedev contributed Estonian translations of items
22 in the Swing GUI.</p><p>Hanai Shisei (ruimo) contributed full Japanese translations of
23 bug messages, and text used in the Swing GUI.</p><p>David Cotton contributed Fresh translations for bug
24 messages and for the Swing GUI.</p><p>Michael Tamm contributed support for the "errorProperty" attribute
25 in the Ant task.</p><p>Thomas Kuehne improved the German translation of the Swing GUI.</p><p>Len Trigg improved source file support for the Emacs output mode.</p><p>Greg Bentz provided a fix for the hashcode/equals detector.</p><p>K. Hashimoto contributed internationalization fixes and several other
26 bug fixes.</p><p>
27 Glenn Boysko contributed support for ignoring specified local
28 variables in the dead local store detector.
29 </p><p>
30 Jay Dunning contributed a detector to find equality comparisons
31 of floating-point values, and overhauled the analysis summary
32 report and its representation in the saved XML format.
33 </p><p>
34 Olivier Parent contributed updated French translations for bug descriptions and
35 Swing GUI.
36 </p><p>
37 Chris Nappin contributed the <code class="filename">plain.xsl</code>
38 stylesheet.
39 </p><p>
40 Etienne Giraudy contributed the <code class="filename">fancy.xsl</code> and <code class="filename">fancy-hist.xsl</code>
41 stylesheets, and made improvements to the <span class="command"><strong>-xml:withMessages</strong></span>
42 option.
43 </p><p>
44 Takashi Okamoto fixed bugs in the project preferences dialog
45 in the Eclipse plugin, and contributed to its internationalization and localization.
46 </p><p>Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.</p><p>Jeff Knox contributed support for the warningsProperty attribute
47 in the Ant task.</p><p>Peter Hendriks extended the Eclipse plugin preferences,
48 and fixed a bug related to renaming the Eclipse plugin ID.</p><p>Mark McKay contributed an Ant task to launch the findbugs frame.</p><p>Dieter von Holten (dvholten) contributed
49 some German improvements to findbugs_de.properties.</p><p>If you have contributed to <span class="application">FindBugs</span>, but aren't mentioned above,
50 please send email to <code class="email">&lt;<a class="email" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>&gt;</code> (and also accept
51 our humble apologies).</p></div><div class="sect1" title="2. &#20351;&#29992;&#12375;&#12390;&#12356;&#12427;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e3561"></a>2. &#20351;&#29992;&#12375;&#12390;&#12356;&#12427;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;</h2></div></div></div><p><span class="application">FindBugs</span> &#12399;&#12289;&#12356;&#12367;&#12388;&#12363;&#12398;&#12458;&#12540;&#12503;&#12531;&#12477;&#12540;&#12473;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;&#12497;&#12483;&#12465;&#12540;&#12472;&#12434;&#20351;&#29992;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12364;&#12394;&#12369;&#12428;&#12400;&#12289; <span class="application">FindBugs</span> &#12398;&#38283;&#30330;&#12399;&#12289;&#12424;&#12426;&#19968;&#23652;&#22256;&#38627;&#12394;&#12418;&#12398;&#12395;&#12394;&#12387;&#12383;&#12371;&#12392;&#12391;&#12375;&#12423;&#12358;&#12290;</p><div class="sect2" title="2.1. BCEL"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3571"></a>2.1. BCEL</h3></div></div></div><p><span class="application">FindBugs</span> includes software developed by the Apache Software Foundation
52 (<a class="ulink" href="http://www.apache.org/" target="_top">http://www.apache.org/</a>).
53 Specifically, it uses the <a class="ulink" href="http://jakarta.apache.org/bcel/" target="_top">Byte Code
54 Engineering Library</a>.</p></div><div class="sect2" title="2.2. ASM"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3584"></a>2.2. ASM</h3></div></div></div><p><span class="application">FindBugs</span> uses the <a class="ulink" href="http://asm.objectweb.org/" target="_top">ASM</a>
55 bytecode framework, which is distributed under the following license:</p><div class="blockquote"><blockquote class="blockquote"><p>
56 Copyright (c) 2000-2005 INRIA, France Telecom
57 All rights reserved.
58 </p><p>
59 Redistribution and use in source and binary forms, with or without
60 modification, are permitted provided that the following conditions
61 are met:
62 </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
63 Redistributions of source code must retain the above copyright
64 notice, this list of conditions and the following disclaimer.
65 </p></li><li class="listitem"><p>
66 Redistributions in binary form must reproduce the above copyright
67 notice, this list of conditions and the following disclaimer in the
68 documentation and/or other materials provided with the distribution.
69 </p></li><li class="listitem"><p>
70 Neither the name of the copyright holders nor the names of its
71 contributors may be used to endorse or promote products derived from
72 this software without specific prior written permission.
73 </p></li></ol></div><p>
74 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
75 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
78 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
79 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
80 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
81 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
82 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
83 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
84 THE POSSIBILITY OF SUCH DAMAGE.
85 </p></blockquote></div></div><div class="sect2" title="2.3. DOM4J"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3611"></a>2.3. DOM4J</h3></div></div></div><p><span class="application">FindBugs</span> uses <a class="ulink" href="http://dom4j.org" target="_top">DOM4J</a>, which is
86 distributed under the following license:</p><div class="blockquote"><blockquote class="blockquote"><p>
87 Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
88 </p><p>
89 Redistribution and use of this software and associated documentation
90 ("Software"), with or without modification, are permitted provided that
91 the following conditions are met:
92 </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
93 Redistributions of source code must retain copyright statements and
94 notices. Redistributions must also contain a copy of this document.
95 </p></li><li class="listitem"><p>
96 Redistributions in binary form must reproduce the above copyright
97 notice, this list of conditions and the following disclaimer in the
98 documentation and/or other materials provided with the distribution.
99 </p></li><li class="listitem"><p>
100 The name "DOM4J" must not be used to endorse or promote products
101 derived from this Software without prior written permission
102 of MetaStuff, Ltd. For written permission, please contact
103 <code class="email">&lt;<a class="email" href="mailto:dom4j-info@metastuff.com">dom4j-info@metastuff.com</a>&gt;</code>.
104 </p></li><li class="listitem"><p>
105 Products derived from this Software may not be called "DOM4J" nor may
106 "DOM4J" appear in their names without prior written permission of
107 MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
108 </p></li><li class="listitem"><p>
109 Due credit should be given to the DOM4J Project (<a class="ulink" href="http://dom4j.org/" target="_top">http://dom4j.org/</a>).
110 </p></li></ol></div><p>
111 THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS''
112 AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
113 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
114 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS
115 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
116 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
117 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
118 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
119 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
120 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
121 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
122 </p></blockquote></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="license.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;</td></tr><tr><td width="40%" align="left" valign="top">&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;"><link rel="next" href="annotations.html" title="&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="filter.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="annotations.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;"><div class="titlepage"><div><div><h2 class="title"><a name="analysisprops"></a>&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</h2></div></div></div><p><span class="application">FindBugs</span> &#12399;&#20998;&#26512;&#12377;&#12427;&#22580;&#21512;&#12395;&#12356;&#12367;&#12388;&#12363;&#12398;&#35251;&#28857;&#12434;&#25345;&#12387;&#12390;&#12356;&#12414;&#12377;&#12290;&#12381;&#12375;&#12390;&#12289;&#35251;&#28857;&#12434;&#12459;&#12473;&#12479;&#12510;&#12452;&#12474;&#12375;&#12390;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#20351;&#12387;&#12390;&#12289;&#12381;&#12428;&#12425;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;&#12371;&#12398;&#31456;&#12391;&#12399;&#12289;&#20998;&#26512;&#12458;&#12503;&#12471;&#12519;&#12531;&#12398;&#35373;&#23450;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><p>&#20998;&#26512;&#12458;&#12503;&#12471;&#12519;&#12531;&#12398;&#20027;&#12394;&#30446;&#30340;&#12399;&#12289; 2 &#12388;&#12354;&#12426;&#12414;&#12377;&#12290;1 &#30058;&#30446;&#12399;&#12289; <span class="application">FindBugs</span> &#12395;&#23550;&#12375;&#12390;&#20998;&#26512;&#12373;&#12428;&#12427;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12398;&#12513;&#12477;&#12483;&#12489;&#12398;&#24847;&#21619;&#12434;&#20253;&#12360;&#12427;&#12371;&#12392;&#12391;&#12377;&#12290;&#12381;&#12358;&#12377;&#12427;&#12371;&#12392;&#12391; <span class="application">FindBugs</span> &#12364;&#12424;&#12426;&#27491;&#30906;&#12394;&#32080;&#26524;&#12434;&#20986;&#12377;&#12371;&#12392;&#12364;&#12391;&#12365;&#12289;&#35492;&#26908;&#20986;&#12434;&#28187;&#12425;&#12377;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;2 &#30058;&#30446;&#12395;&#12289;&#20998;&#26512;&#12434;&#34892;&#12358;&#12395;&#24403;&#12383;&#12426;&#12381;&#12398;&#31934;&#24230;&#12434;&#35373;&#23450;&#12391;&#12365;&#12427;&#12424;&#12358;&#12395;&#12377;&#12427;&#12371;&#12392;&#12391;&#12377;&#12290;&#20998;&#26512;&#12398;&#31934;&#24230;&#12434;&#33853;&#12392;&#12377;&#12371;&#12392;&#12391;&#12289;&#12513;&#12514;&#12522;&#20351;&#29992;&#37327;&#12392;&#20998;&#26512;&#26178;&#38291;&#12434;&#28187;&#12425;&#12377;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12383;&#12384;&#12375;&#12289;&#26412;&#24403;&#12398;&#12496;&#12464;&#12434;&#35211;&#36867;&#12375;&#12383;&#12426;&#12289;&#35492;&#26908;&#20986;&#12398;&#25968;&#12364;&#22679;&#12360;&#12427;&#12392;&#12356;&#12358;&#20195;&#20767;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p><p>&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531; <span class="command"><strong>-property</strong></span> &#12434;&#20351;&#12387;&#12390;&#12289;&#20998;&#26512;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="screen">
3 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -property "cfg.noprune=true" <em class="replaceable"><code>myApp.jar</code></em></strong></span>
4 </pre><p>
5 </p><p>&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#20998;&#26512;&#12458;&#12503;&#12471;&#12519;&#12531;&#12398;&#19968;&#35239;&#12434; <a class="xref" href="analysisprops.html#analysisproptable" title="&#34920;9.1 &#35373;&#23450;&#21487;&#33021;&#12394;&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;">&#34920;9.1&#12300;&#35373;&#23450;&#21487;&#33021;&#12394;&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12301;</a> &#12395;&#31034;&#12375;&#12414;&#12377;&#12290;</p><div class="table"><a name="analysisproptable"></a><p class="title"><b>&#34920;9.1 &#35373;&#23450;&#21487;&#33021;&#12394;&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</b></p><div class="table-contents"><table summary="&#35373;&#23450;&#21487;&#33021;&#12394;&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#21517;</th><th align="left">&#35373;&#23450;&#20516;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">findbugs.assertionmethods</td><td align="left">&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12398;&#23436;&#20840;&#20462;&#39166;&#12513;&#12477;&#12483;&#12489;&#21517;&#12522;&#12473;&#12488; : &#20363;&#12289; "com.foo.MyClass.checkAssertion"</td><td align="left">&#12371;&#12398;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12395;&#12399;&#12289;&#12503;&#12525;&#12464;&#12521;&#12512;&#12364;&#27491;&#12375;&#12356;&#12371;&#12392;&#12434;&#12481;&#12455;&#12483;&#12463;&#12377;&#12427;&#12383;&#12417;&#12395;&#20351;&#12431;&#12428;&#12427;&#12513;&#12477;&#12483;&#12489;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12398;&#12513;&#12477;&#12483;&#12489;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; &#12481;&#12455;&#12483;&#12463;&#12513;&#12477;&#12483;&#12489;&#12391;&#30906;&#35469;&#12375;&#12383;&#20516;&#12395;&#23550;&#12377;&#12427; null &#21442;&#29031;&#12450;&#12463;&#12475;&#12473;&#12487;&#12451;&#12486;&#12463;&#12479;&#12398;&#35492;&#26908;&#20986;&#12434;&#22238;&#36991;&#12391;&#12365;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">findbugs.de.comment</td><td align="left">true &#12414;&#12383;&#12399; false</td><td align="left">true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289; DroppedException (&#28961;&#35222;&#12373;&#12428;&#12383;&#20363;&#22806;) &#12487;&#12451;&#12486;&#12463;&#12479;&#12399;&#31354;&#12398; catch &#12502;&#12525;&#12483;&#12463; &#12395;&#12467;&#12513;&#12531;&#12488;&#12364;&#28961;&#12356;&#12363;&#25506;&#12375;&#12414;&#12377;&#12290;&#12381;&#12375;&#12390;&#12289;&#12467;&#12513;&#12531;&#12488;&#12364;&#12415;&#12388;&#12363;&#12387;&#12383;&#22580;&#21512;&#12395;&#12399;&#35686;&#21578;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;</td></tr><tr><td align="left">findbugs.maskedfields.locals</td><td align="left">true &#12414;&#12383;&#12399; false</td><td align="left">true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#12501;&#12451;&#12540;&#12523;&#12489;&#12434;&#38560;&#34109;&#12375;&#12390;&#12356;&#12427;&#12525;&#12540;&#12459;&#12523;&#22793;&#25968;&#12395;&#23550;&#12375;&#12390;&#20778;&#20808;&#24230;(&#20302;)&#12398;&#35686;&#21578;&#12364;&#30330;&#34892;&#12373;&#12428;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; false &#12391;&#12377;&#12290;</td></tr><tr><td align="left">findbugs.nullderef.assumensp</td><td align="left">true &#12414;&#12383;&#12399; false</td><td align="left">&#20351;&#29992;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290; (&#24847;&#22259; : true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;null &#21442;&#29031;&#12450;&#12463;&#12475;&#12473;&#12487;&#12451;&#12486;&#12463;&#12479;&#12399;&#12513;&#12477;&#12483;&#12489;&#12363;&#12425;&#12398;&#25147;&#12426;&#20516;&#12289;&#12414;&#12383;&#12399;&#12289;&#12513;&#12477;&#12483;&#12489;&#12395;&#21463;&#12369;&#28193;&#12373;&#12428;&#12427;&#24341;&#25968;&#12434; null &#12391;&#12354;&#12427;&#12392;&#20206;&#23450;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; false &#12391;&#12377;&#12290;&#12371;&#12398;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#26377;&#21177;&#12395;&#12377;&#12427;&#12392;&#12289;&#22823;&#37327;&#12398;&#35492;&#26908;&#20986;&#12364;&#29983;&#25104;&#12373;&#12428;&#12427;&#12391;&#12354;&#12429;&#12358;&#12371;&#12392;&#12395;&#27880;&#24847;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;)</td></tr><tr><td align="left">findbugs.refcomp.reportAll</td><td align="left">true &#12414;&#12383;&#12399; false</td><td align="left">true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289; == &#12362;&#12424;&#12403; != &#28436;&#31639;&#23376;&#12434;&#20351;&#12387;&#12390;&#12356;&#12427;&#30097;&#12431;&#12375;&#12356;&#21442;&#29031;&#27604;&#36611;&#12364;&#12377;&#12409;&#12390;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290; false &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#21516;&#27096;&#12398;&#35686;&#21578;&#12399; 1 &#12513;&#12477;&#12483;&#12489;&#12395;&#12388;&#12365; 1 &#12388;&#12375;&#12363;&#30330;&#34892;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; false &#12391;&#12377;&#12290;</td></tr><tr><td align="left">findbugs.sf.comment</td><td align="left">true &#12414;&#12383;&#12399; false</td><td align="left">true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289; SwitchFallthrough &#12487;&#12451;&#12486;&#12463;&#12479;&#12399;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12395;&#12300;fall&#12301;&#12414;&#12383;&#12399;&#12300;nobreak&#12301;&#12392;&#12356;&#12358;&#21336;&#35486;&#12434;&#21547;&#12435;&#12384;&#12467;&#12513;&#12531;&#12488;&#12434;&#35352;&#36617;&#12375;&#12390;&#12356;&#12394;&#12356; case&#12521;&#12505;&#12523; &#12395;&#38480;&#12426;&#35686;&#21578;&#12434;&#22577;&#21578;&#12375;&#12414;&#12377;&#12290;(&#12371;&#12398;&#27231;&#33021;&#12364;&#27491;&#12375;&#12367;&#21205;&#20316;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289;&#27491;&#30906;&#12394;&#12477;&#12540;&#12473;&#12497;&#12473;&#12364;&#24517;&#35201;&#12391;&#12377;&#12290;) &#12371;&#12428;&#12395;&#12424;&#12426;&#12289;&#24847;&#22259;&#30340;&#12391;&#12399;&#12394;&#12356; switch &#25991;&#12398; fallthrough &#12434;&#30330;&#35211;&#12375;&#26131;&#12367;&#12394;&#12426;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="filter.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="annotations.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="analysisprops.html" title="&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;"><link rel="next" href="rejarForAnalysis.html" title="&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="analysisprops.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="rejarForAnalysis.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h2 class="title"><a name="annotations"></a>&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;</h2></div></div></div><p><span class="application">FindBugs</span> &#12399;&#12356;&#12367;&#12388;&#12363;&#12398;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12469;&#12509;&#12540;&#12488;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#38283;&#30330;&#32773;&#12398;&#24847;&#22259;&#12434;&#26126;&#30906;&#12395;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; FindBugs &#12399;&#12424;&#12426;&#30340;&#30906;&#12395;&#35686;&#21578;&#12434;&#30330;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#20351;&#29992;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399; Java 5 &#12364;&#24517;&#35201;&#12391;&#12354;&#12426;&#12289; annotations.jar &#12362;&#12424;&#12403; jsr305.jar &#12501;&#12449;&#12452;&#12523;&#12434;&#12467;&#12531;&#12497;&#12452;&#12523;&#26178;&#12398;&#12463;&#12521;&#12473;&#12497;&#12473;&#12395;&#21547;&#12417;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.CheckForNull</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
3 <p>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12388;&#12369;&#12383;&#35201;&#32032;&#12399;&#12289; null &#12391;&#12354;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#24403;&#35442;&#35201;&#32032;&#12434;&#20351;&#29992;&#12377;&#12427;&#38555;&#12399; null &#12481;&#12455;&#12483;&#12463;&#12434;&#12377;&#12427;&#12409;&#12365;&#12391;&#12377;&#12290;&#12371;&#12398;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12513;&#12477;&#12483;&#12489;&#12395;&#36969;&#29992;&#12377;&#12427;&#12392;&#12289;&#12513;&#12477;&#12483;&#12489;&#12398;&#25147;&#12426;&#20516;&#12395;&#36969;&#29992;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.CheckReturnValue</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Method, Constructor
4 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
5 <span class="command"><strong>priority:</strong></span> &#35686;&#21578;&#12398;&#20778;&#20808;&#24230;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (HIGH, MEDIUM, LOW, IGNORE) &#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :MEDIUM&#12290;</p><p>
6 <span class="command"><strong>explanation:</strong></span>&#25147;&#12426;&#20516;&#12434;&#12481;&#12455;&#12483;&#12463;&#12375;&#12394;&#12369;&#12400;&#12394;&#12425;&#12394;&#12356;&#29702;&#30001;&#12434;&#12486;&#12461;&#12473;&#12488;&#12391;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :""&#12290;</p></dd></dl></div><p>&#12371;&#12398;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#21628;&#20986;&#12375;&#24460;&#12395;&#25147;&#12426;&#20516;&#12434;&#12481;&#12455;&#12483;&#12463;&#12377;&#12409;&#12365;&#12513;&#12477;&#12483;&#12489;&#12434;&#34920;&#12377;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotation</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
7 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
8 <span class="command"><strong>value:</strong></span>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12463;&#12521;&#12473;&#12398;class&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12290;&#35079;&#25968;&#12398;&#12463;&#12521;&#12473;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>
9 <span class="command"><strong>priority:</strong></span>&#30465;&#30053;&#26178;&#12398;&#20778;&#20808;&#24230;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (HIGH, MEDIUM, LOW, IGNORE) &#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :MEDIUM&#12290;</p></dd></dl></div><p>
10 Indicates that all members of the class or package should be annotated with the default
11 value of the supplied annotation classes. This would be used for behavior annotations
12 such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use
13 @DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only
14 on those parameters, methods or fields that you want to allow to be null.
15 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
16 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
17 <span class="command"><strong>value:</strong></span>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12463;&#12521;&#12473;&#12398;class&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12290;&#35079;&#25968;&#12398;&#12463;&#12521;&#12473;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>
18 <span class="command"><strong>priority:</strong></span>&#30465;&#30053;&#26178;&#12398;&#20778;&#20808;&#24230;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (HIGH, MEDIUM, LOW, IGNORE) &#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :MEDIUM&#12290;</p></dd></dl></div><p>
19 This is same as the DefaultAnnotation except it only applys to fields.
20 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
21 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
22 <span class="command"><strong>value:</strong></span>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12463;&#12521;&#12473;&#12398;class&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12290;&#35079;&#25968;&#12398;&#12463;&#12521;&#12473;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>
23 <span class="command"><strong>priority:</strong></span>&#30465;&#30053;&#26178;&#12398;&#20778;&#20808;&#24230;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (HIGH, MEDIUM, LOW, IGNORE) &#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :MEDIUM&#12290;</p></dd></dl></div><p>
24 This is same as the DefaultAnnotation except it only applys to methods.
25 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
26 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
27 <span class="command"><strong>value:</strong></span>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12463;&#12521;&#12473;&#12398;class&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12290;&#35079;&#25968;&#12398;&#12463;&#12521;&#12473;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>
28 <span class="command"><strong>priority:</strong></span>&#30465;&#30053;&#26178;&#12398;&#20778;&#20808;&#24230;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (HIGH, MEDIUM, LOW, IGNORE) &#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :MEDIUM&#12290;</p></dd></dl></div><p>
29 This is same as the DefaultAnnotation except it only applys to method parameters.
30 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.NonNull</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
31 <p>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12388;&#12369;&#12383;&#35201;&#32032;&#12399;&#12289; null &#12391;&#12354;&#12387;&#12390;&#12399;&#12356;&#12369;&#12414;&#12379;&#12435;&#12290;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12388;&#12369;&#12383;&#12501;&#12451;&#12540;&#12523;&#12489;&#12399;&#12289;&#27083;&#31689;&#23436;&#20102;&#24460; null &#12391;&#12354;&#12387;&#12390;&#12399;&#12356;&#12369;&#12414;&#12379;&#12435;&#12290;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12388;&#12369;&#12383;&#12513;&#12477;&#12483;&#12489;&#12399;&#12289; null &#12391;&#12399;&#12394;&#12356;&#20516;&#12434;&#25147;&#12426;&#20516;&#12392;&#12375;&#12394;&#12369;&#12428;&#12400;&#12394;&#12426;&#12414;&#12379;&#12435;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.Nullable</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
32 <p>&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12434;&#12388;&#12369;&#12383;&#35201;&#32032;&#12399;&#12289; null &#12391;&#12354;&#12387;&#12390;&#12399;&#12356;&#12369;&#12414;&#12379;&#12435;&#12290;In general, this means developers will have to read the documentation to determine when a null value is acceptable and whether it is neccessary to check for a null value. FindBugs will treat the annotated items as though they had no annotation.</p><p>
33 In pratice this annotation is useful only for overriding an overarching NonNull
34 annotation.
35 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.OverrideMustInvoke</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Method
36 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
37 <span class="command"><strong>value:</strong></span>Specify when the super invocation should be
38 performed (FIRST, ANYTIME, LAST). Default value:ANYTIME.
39 </p></dd></dl></div><p>
40 Used to annotate a method that, if overridden, must (or should) be invoke super
41 in the overriding method. Examples of such methods include finalize() and clone().
42 The argument to the method indicates when the super invocation should occur:
43 at any time, at the beginning of the overriding method, or at the end of the overriding method.
44 (This anotation is not implmemented in FindBugs as of September 8, 2006).
45 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.PossiblyNull</strong></span></span></dt><dd><p>
46 This annotation is deprecated. Use CheckForNull instead.
47 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.SuppressWarnings</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Field, Method, Parameter, Constructor, Package
48 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
49 <span class="command"><strong>value:</strong></span>The name of the warning. More than one name can be specified.
50 </p><p>
51 <span class="command"><strong>justification:</strong></span>Reason why the warning should be ignored. &#12487;&#12501;&#12457;&#12523;&#12488;&#20516; :""&#12290;</p></dd></dl></div><p>
52 The set of warnings that are to be suppressed by the compiler in the annotated element.
53 Duplicate names are permitted. The second and successive occurrences of a name are ignored.
54 The presence of unrecognized warning names is <span class="emphasis"><em>not</em></span> an error: Compilers
55 must ignore any warning names they do not recognize. They are, however, free to emit a
56 warning if an annotation contains an unrecognized warning name. Compiler vendors should
57 document the warning names they support in conjunction with this annotation type. They
58 are encouraged to cooperate to ensure that the same names work across multiple compilers.
59 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.UnknownNullness</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
60 <p>
61 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
62 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.UnknownNullness</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
63 <p>
64 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
65 </p></dd></dl></div><p>&#12414;&#12383;&#12289; <span class="application">FindBugs</span> &#27425;&#12395;&#31034;&#12377;&#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&#12418;&#12469;&#12509;&#12540;&#12488;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290; :</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">net.jcip.annotations.GuardedBy</li><li class="listitem">net.jcip.annotations.Immutable</li><li class="listitem">net.jcip.annotations.NotThreadSafe</li><li class="listitem">net.jcip.annotations.ThreadSafe</li></ul></div><p>
66 </p><p><a class="ulink" href="http://jcip.net/" target="_top">Java Concurrency in Practice</a> &#12398; <a class="ulink" href="http://jcip.net/annotations/doc/index.html" target="_top"> API &#12489;&#12461;&#12517;&#12513;&#12531;&#12488;</a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="analysisprops.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="rejarForAnalysis.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;6&#31456; FindBugs&#8482; Ant &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="gui.html" title="&#31532;5&#31456; FindBugs GUI &#12398;&#20351;&#29992;&#26041;&#27861;"><link rel="next" href="eclipse.html" title="&#31532;7&#31456; FindBugs&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;6&#31456; <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gui.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="eclipse.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;6&#31456; FindBugs&#8482; Ant &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;"><div class="titlepage"><div><div><h2 class="title"><a name="anttask"></a>&#31532;6&#31456; <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="anttask.html#d0e1173">1. <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1209">2. build.xml &#12398;&#26360;&#12365;&#26041;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1278">3. &#12479;&#12473;&#12463;&#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1303">4. &#12497;&#12521;&#12513;&#12540;&#12479;&#12540;</a></span></dt></dl></div><p>&#12371;&#12398;&#31456;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12434; <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a> &#12398;&#12499;&#12523;&#12489;&#12473;&#12463;&#12522;&#12503;&#12488;&#12395;&#32068;&#12415;&#20837;&#12428;&#12427;&#26041;&#27861;&#12395;&#12388;&#12356;&#12390;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290; <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a> &#12399;&#12289;&#12499;&#12523;&#12489;&#12420;&#37197;&#20633;&#12434;&#34892;&#12358;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427; Java &#12391;&#12424;&#12367;&#20351;&#29992;&#12373;&#12428;&#12427;&#12484;&#12540;&#12523;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12434;&#20351;&#29992;&#12377;&#12427;&#12392;&#12289; &#12499;&#12523;&#12489;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20316;&#25104;&#12375;&#12390;&#27231;&#26800;&#30340;&#12395; <span class="application">FindBugs</span> &#12395;&#12424;&#12427; Java &#12467;&#12540;&#12489;&#12398;&#20998;&#26512;&#12434;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12399;&#12289; Mike Fagan &#27663;&#12398;&#22810;&#22823;&#12394;&#36002;&#29486;&#12395;&#12424;&#12427;&#12418;&#12398;&#12391;&#12377;&#12290;</p><div class="sect1" title="1. Ant &#12479;&#12473;&#12463;&#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1173"></a>1. <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</h2></div></div></div><p><span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12399;&#12289; <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs-ant.jar</code> &#12434; <span class="application">Ant</span> &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;<code class="filename">lib</code> &#12469;&#12502;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#12467;&#12500;&#12540;&#12377;&#12427;&#12384;&#12369;&#12391;&#12377;&#12290;</p><div class="note" title="&#27880;&#35352;" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[&#27880;&#35352;]" src="note.png"></td><th align="left">&#27880;&#35352;</th></tr><tr><td align="left" valign="top"><p>&#20351;&#29992;&#12377;&#12427; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12392; <span class="application">FindBugs</span> &#26412;&#20307;&#12399;&#12289;&#21516;&#26801;&#12373;&#12428;&#12390;&#12356;&#12383;&#21516;&#12376;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#12418;&#12398;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12434;&#24375;&#12367;&#25512;&#22888;&#12375;&#12414;&#12377;&#12290;&#21029;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398; <span class="application">FindBugs</span> &#12395;&#21547;&#12414;&#12428;&#12390;&#12356;&#12383; <span class="application">Ant</span> &#12479;&#12473;&#12463; Jar &#12501;&#12449;&#12452;&#12523;&#12391;&#12398;&#21205;&#20316;&#12399;&#20445;&#35388;&#12375;&#12414;&#12379;&#12435;&#12290;</p></td></tr></table></div><p>
3 </p></div><div class="sect1" title="2. build.xml &#12398;&#26360;&#12365;&#26041;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1209"></a>2. build.xml &#12398;&#26360;&#12365;&#26041;</h2></div></div></div><p><span class="application">FindBugs</span> &#12434; <code class="filename">build.xml</code> (<span class="application">Ant</span> &#12499;&#12523;&#12489;&#12473;&#12463;&#12522;&#12503;&#12488;) &#12395;&#32068;&#12415;&#20837;&#12428;&#12427;&#12383;&#12417;&#12395;&#12399;&#12414;&#12378;&#12289;&#12479;&#12473;&#12463;&#23450;&#32681;&#12434;&#35352;&#36848;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12479;&#12473;&#12463;&#23450;&#32681;&#12399;&#27425;&#12398;&#12424;&#12358;&#12395;&#35352;&#36848;&#12375;&#12414;&#12377;&#12290;:</p><pre class="screen">
4 &lt;taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/&gt;
5 </pre><p>&#12479;&#12473;&#12463;&#23450;&#32681;&#12399;&#12289; <code class="literal">findbugs</code> &#35201;&#32032;&#12434; <code class="filename">build.xml</code> &#19978;&#12395;&#35352;&#36848;&#12375;&#12383;&#12392;&#12365;&#12289;&#12381;&#12398;&#12479;&#12473;&#12463;&#12398;&#23455;&#34892;&#12395;&#20351;&#29992;&#12373;&#12428;&#12427;&#12463;&#12521;&#12473;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p><p>&#12479;&#12473;&#12463;&#23450;&#32681;&#12398;&#35352;&#36848;&#12434;&#12377;&#12428;&#12400;&#12289;<code class="literal">findbugs</code> &#12479;&#12473;&#12463;&#12434;&#20351;&#12387;&#12390;&#12479;&#12540;&#12466;&#12483;&#12488;&#12434;&#23450;&#32681;&#12391;&#12365;&#12414;&#12377;&#12290;&#27425;&#12395;&#31034;&#12377;&#12398;&#12399;&#12289; Apache <a class="ulink" href="http://jakarta.apache.org/bcel/" target="_top">BCEL</a> &#12521;&#12452;&#12502;&#12521;&#12522;&#12540;&#12434;&#20998;&#26512;&#12377;&#12427;&#22580;&#21512;&#12434;&#24819;&#23450;&#12375;&#12383; <code class="filename">build.xml</code> &#12398;&#35352;&#36848;&#20363;&#12391;&#12377;&#12290;</p><pre class="screen">
6 &lt;property name="findbugs.home" value="/export/home/daveho/work/findbugs" /&gt;
7
8 &lt;target name="findbugs" depends="jar"&gt;
9 &lt;findbugs home="${findbugs.home}"
10 output="xml"
11 outputFile="bcel-fb.xml" &gt;
12 &lt;auxClasspath path="${basedir}/lib/Regex.jar" /&gt;
13 &lt;sourcePath path="${basedir}/src/java" /&gt;
14 &lt;class location="${basedir}/bin/bcel.jar" /&gt;
15 &lt;/findbugs&gt;
16 &lt;/target&gt;
17 </pre><p><code class="literal">findbugs</code> &#35201;&#32032;&#12395;&#12399;&#12289; <code class="literal">home</code> &#23646;&#24615;&#12364;&#24517;&#38920;&#12391;&#12377;&#12290; <span class="application">FindBugs</span> &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12377;&#12394;&#12431;&#12385; <em class="replaceable"><code>$FINDBUGS_HOME</code></em> &#12398;&#20516;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;<a class="xref" href="installing.html" title="&#31532;2&#31456; FindBugs&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;">2&#31456;<i><span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p>&#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399; <code class="filename">bcel.jar</code> &#12395;&#23550;&#12375;&#12390; <span class="application">FindBugs</span> &#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;&#12371;&#12398; Jar &#12501;&#12449;&#12452;&#12523;&#12399;&#12289; BCEL &#12499;&#12523;&#12489;&#12473;&#12463;&#12522;&#12503;&#12488;&#12395;&#12424;&#12387;&#12390;&#20316;&#25104;&#12373;&#12428;&#12427;&#12418;&#12398;&#12391;&#12377;&#12290;(&#19978;&#35352;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12364;&#12300;jar&#12301;&#12479;&#12540;&#12466;&#12483;&#12488;&#12395;&#20381;&#23384;&#12375;&#12390;&#12356;&#12427; (depends) &#12392;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12395;&#12424;&#12426;&#12289; <span class="application">FindBugs</span> &#12364;&#23455;&#34892;&#12373;&#12428;&#12427;&#21069;&#12395;&#24403;&#35442;&#12521;&#12452;&#12502;&#12521;&#12522;&#12540;&#12364;&#23436;&#20840;&#12395;&#12467;&#12531;&#12497;&#12452;&#12523;&#12373;&#12428;&#12390;&#12356;&#12427;&#12371;&#12392;&#12434;&#20445;&#35388;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;) <span class="application">FindBugs</span> &#12398;&#20986;&#21147;&#12399;&#12289; XML &#24418;&#24335;&#12391; <code class="filename">bcel-fb.xml</code> &#12501;&#12449;&#12452;&#12523;&#12395;&#20445;&#23384;&#12373;&#12428;&#12414;&#12377;&#12290;&#35036;&#21161; Jar &#12501;&#12449;&#12452;&#12523; <code class="filename">Regex.jar</code> &#12434; aux classpath &#12395;&#35352;&#36848;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12394;&#12380;&#12394;&#12425;&#12289;&#24403;&#35442; Jar &#12501;&#12449;&#12452;&#12523;&#12364; BCEL &#12513;&#12452;&#12531;&#65381;&#12521;&#12452;&#12502;&#12521;&#12522;&#12540;&#12363;&#12425;&#21442;&#29031;&#12373;&#12428;&#12427;&#12363;&#12425;&#12391;&#12377;&#12290;source path &#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#20445;&#23384;&#12373;&#12428;&#12427;&#12496;&#12464;&#12487;&#12540;&#12479;&#12395; BCEL &#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12408;&#12398;&#27491;&#30906;&#12394;&#21442;&#29031;&#12364;&#35352;&#36848;&#12373;&#12428;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="3. &#12479;&#12473;&#12463;&#12398;&#23455;&#34892;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1278"></a>3. &#12479;&#12473;&#12463;&#12398;&#23455;&#34892;</h2></div></div></div><p>&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12363;&#12425; <span class="application">Ant</span> &#12434;&#36215;&#21205;&#12377;&#12427;&#20363;&#12434;&#27425;&#12395;&#31034;&#12375;&#12414;&#12377;&#12290;&#21069;&#36848;&#12398; <code class="literal">findbugs</code> &#12479;&#12540;&#12466;&#12483;&#12488;&#12434;&#20351;&#29992;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;</p><pre class="screen">
18 <code class="prompt">[daveho@noir]$</code> <span class="command"><strong>ant findbugs</strong></span>
19 Buildfile: build.xml
20
21 init:
22
23 compile:
24
25 examples:
26
27 jar:
28
29 findbugs:
30 [findbugs] Running FindBugs...
31 [findbugs] Bugs were found
32 [findbugs] Output saved to bcel-fb.xml
33
34 BUILD SUCCESSFUL
35 Total time: 35 seconds
36 </pre><p>&#12371;&#12398;&#20107;&#20363;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289;XML &#12501;&#12449;&#12452;&#12523;&#12391;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#20445;&#23384;&#12375;&#12390;&#12356;&#12427;&#12398;&#12391;&#12289; <span class="application">FindBugs</span> GUI &#12434;&#20351;&#12387;&#12390;&#32080;&#26524;&#12434;&#21442;&#29031;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290; <a class="xref" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;">4&#31456;<i><span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="sect1" title="4. &#12497;&#12521;&#12513;&#12540;&#12479;&#12540;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1303"></a>4. &#12497;&#12521;&#12513;&#12540;&#12479;&#12540;</h2></div></div></div><p>&#12371;&#12398;&#12475;&#12463;&#12471;&#12519;&#12531;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12479;&#12473;&#12463;&#12434;&#20351;&#29992;&#12377;&#12427;&#38555;&#12395;&#12289;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#12497;&#12521;&#12513;&#12540;&#12479;&#12540;&#12395;&#12388;&#12356;&#12390;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><code class="literal">class</code></span></dt><dd><p>&#20998;&#26512;&#12398;&#23550;&#35937;&#12392;&#12394;&#12427;&#12463;&#12521;&#12473;&#32676;&#12434;&#25351;&#23450;&#12377;&#12427;&#12383;&#12417;&#12398;&#12493;&#12473;&#12488;&#12373;&#12428;&#12427;&#35201;&#32032;&#12391;&#12377;&#12290;<code class="literal">class</code> &#35201;&#32032;&#12395;&#12399; <code class="literal">location</code> &#23646;&#24615;&#12398;&#25351;&#23450;&#12364;&#24517;&#38920;&#12391;&#12377;&#12290;&#20998;&#26512;&#23550;&#35937;&#12392;&#12394;&#12427;&#12450;&#12540;&#12459;&#12452;&#12502;&#12501;&#12449;&#12452;&#12523; (jar, zip, &#20182;)&#12289;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12414;&#12383;&#12399;&#12463;&#12521;&#12473;&#12501;&#12449;&#12452;&#12523;&#12398;&#21517;&#21069;&#12434;&#35352;&#36848;&#12375;&#12414;&#12377;&#12290;1 &#12388;&#12398; <code class="literal">findbugs</code> &#35201;&#32032;&#12395;&#23550;&#12375;&#12390;&#12289;&#35079;&#25968;&#12398; <code class="literal">class</code> &#23376;&#35201;&#32032;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">auxClasspath</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12493;&#12473;&#12488;&#12373;&#12428;&#12427;&#35201;&#32032;&#12391;&#12377;&#12290;&#20998;&#26512;&#23550;&#35937;&#12398;&#12521;&#12452;&#12502;&#12521;&#12522;&#12540;&#12414;&#12383;&#12399;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12395;&#12424;&#12387;&#12390;&#20351;&#29992;&#12373;&#12428;&#12390;&#12356;&#12427;&#12364;&#20998;&#26512;&#12398;&#23550;&#35937;&#12395;&#12399;&#12375;&#12383;&#12367;&#12394;&#12356;&#12463;&#12521;&#12473;&#12434;&#21547;&#12435;&#12391;&#12356;&#12427;&#12463;&#12521;&#12473;&#12497;&#12473; (Jar &#12501;&#12449;&#12452;&#12523;&#12414;&#12383;&#12399;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;) &#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290; <span class="application">Ant</span> &#12398; Java &#12479;&#12473;&#12463;&#12395;&#12354;&#12427; <code class="literal">classpath</code> &#35201;&#32032; &#12392;&#21516;&#12376;&#26041;&#27861;&#12391;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">sourcePath</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12493;&#12473;&#12488;&#12373;&#12428;&#12427;&#35201;&#32032;&#12391;&#12377;&#12290;&#20998;&#26512;&#23550;&#35937; Java &#12467;&#12540;&#12489;&#12398;&#12467;&#12531;&#12497;&#12452;&#12523;&#26178;&#12395;&#20351;&#29992;&#12375;&#12383;&#12477;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12434;&#21547;&#12435;&#12391;&#12356;&#12427;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12408;&#12398;&#12497;&#12473;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12477;&#12540;&#12473;&#12497;&#12473;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12395;&#12424;&#12426;&#12289;&#29983;&#25104;&#12373;&#12428;&#12427; XML &#12398;&#12496;&#12464;&#20986;&#21147;&#32080;&#26524;&#12395;&#23436;&#20840;&#12394;&#12477;&#12540;&#12473;&#24773;&#22577;&#12434;&#12418;&#12383;&#12379;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12289;&#24460;&#12395;&#12394;&#12387;&#12390; GUI &#12391;&#21442;&#29031;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">home</code></span></dt><dd><p>&#24517;&#38920;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12364;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12373;&#12428;&#12390;&#12356;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#21517;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">quietErrors</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12502;&#12540;&#12523;&#20516;&#23646;&#24615;&#12391;&#12377;&#12290;true &#12434;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#28145;&#21051;&#12394;&#20998;&#26512;&#12456;&#12521;&#12540;&#30330;&#29983;&#12420;&#12463;&#12521;&#12473;&#12364;&#12415;&#12388;&#12363;&#12425;&#12394;&#12356;&#12392;&#12356;&#12387;&#12383;&#24773;&#22577;&#12364; <span class="application">FindBugs</span> &#20986;&#21147;&#12395;&#35352;&#37682;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; false &#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">reportLevel</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#22577;&#21578;&#12373;&#12428;&#12427;&#12496;&#12464;&#12398;&#20778;&#20808;&#24230;&#12398;&#12375;&#12365;&#12356;&#20516;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12300;low&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#12377;&#12409;&#12390;&#12398;&#12496;&#12464;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;&#12300;medium&#12301; (&#12487;&#12501;&#12457;&#12523;&#12488;) &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20778;&#20808;&#24230; (&#20013;)&#12362;&#12424;&#12403;&#20778;&#20808;&#24230; (&#39640;)&#12398;&#12496;&#12464;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;&#12300;high&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20778;&#20808;&#24230; (&#39640;) &#12398;&#12496;&#12464;&#12398;&#12415;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">output</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#20986;&#21147;&#24418;&#24335;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12300;xml&#12301; (&#12487;&#12501;&#12457;&#12523;&#12488;) &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399; XML &#24418;&#24335;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12300;xml:withMessages&#12301; &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399;&#20154;&#38291;&#12364;&#35501;&#12417;&#12427;&#12513;&#12483;&#12475;&#12540;&#12472; &#12364;&#36861;&#21152;&#12373;&#12428;&#12383; XML &#24418;&#24335;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;(XSL &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#20351;&#12387;&#12390;&#12524;&#12509;&#12540;&#12488;&#12434;&#20316;&#25104;&#12377;&#12427;&#12371;&#12392;&#12434;&#35336;&#30011;&#12375;&#12390;&#12356;&#12427;&#22580;&#21512;&#12399;&#12371;&#12398;&#24418;&#24335;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;) &#12300;html&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399; HTML &#24418;&#24335;(&#12487;&#12501;&#12457;&#12523;&#12488;&#12398;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12399; default.xsl) &#12395;&#12394;&#12426;&#12414;&#12377;&#12290; &#12300;text&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399;&#29305;&#21029;&#12394;&#12486;&#12461;&#12473;&#12488;&#24418;&#24335;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12300;emacs&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399; <a class="ulink" href="http://www.gnu.org/software/emacs/" target="_top">Emacs</a> &#12456;&#12521;&#12540;&#12513;&#12483;&#12475;&#12540;&#12472;&#24418;&#24335;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12300;xdocs&#12301;&#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289;&#20986;&#21147;&#12399; Apache Maven &#12391;&#20351;&#29992;&#12391;&#12365;&#12427; xdoc XML &#12395;&#12394;&#12426;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">stylesheet</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;output &#23646;&#24615; &#12395; html &#12434;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12395;&#12289; HTML &#20986;&#21147;&#20316;&#25104;&#12395;&#20351;&#29992;&#12373;&#12428;&#12427;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;FindBugs &#37197;&#24067;&#29289;&#12395;&#21547;&#12414;&#12428;&#12390;&#12356;&#12427;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12399;&#12289; default.xsl&#12289; fancy.xsl &#12289; fancy-hist.xsl &#12289; plain.xsl &#12362;&#12424;&#12403; summary.xsl &#12391;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#20516;&#12399; default.xsl &#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">sort</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<code class="literal">output</code> &#23646;&#24615;&#12395;&#12300;text&#12301;&#12434;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12395;&#12289;&#12496;&#12464;&#12398;&#22577;&#21578;&#12434;&#12463;&#12521;&#12473;&#38918;&#12395;&#12477;&#12540;&#12488;&#12377;&#12427;&#12363;&#12393;&#12358;&#12363;&#12434; <code class="literal">sort</code> &#23646;&#24615;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; true &#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">outputFile</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12289;<span class="application">FindBugs</span> &#12398;&#20986;&#21147;&#12399;&#12381;&#12398;&#21517;&#21069;&#12398;&#12501;&#12449;&#12452;&#12523;&#12408;&#12392;&#20445;&#23384;&#12373;&#12428;&#12414;&#12377;&#12290;&#30465;&#30053;&#26178;&#12289;&#20986;&#21147;&#12399; <span class="application">Ant</span> &#12395;&#12424;&#12387;&#12390;&#30452;&#25509;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">debug</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12502;&#12540;&#12523;&#20516;&#23646;&#24615;&#12391;&#12377;&#12290;true &#12395;&#35373;&#23450;&#12377;&#12427;&#12392;&#12289; <span class="application">FindBugs</span> &#12399; &#35386;&#26029;&#24773;&#22577;&#12434;&#20986;&#21147;&#12375;&#12414;&#12377;&#12290;&#12393;&#12398;&#12463;&#12521;&#12473;&#12434;&#20998;&#26512;&#12375;&#12390;&#12356;&#12427;&#12363;&#12289;&#12393;&#12398;&#12497;&#12464;&#12497;&#12479;&#12540;&#12531;&#12487;&#12451;&#12486;&#12463;&#12479;&#12364;&#23455;&#34892;&#12373;&#12428;&#12390;&#12356;&#12427;&#12363;&#12289;&#12392;&#12356;&#12358;&#24773;&#22577;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; false &#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">effort</code></span></dt><dd><p>&#20998;&#26512;&#12398;&#27963;&#21205;&#12524;&#12505;&#12523;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">min</code> &#12289;<code class="literal">default</code> &#12414;&#12383;&#12399; <code class="literal">max</code> &#12398;&#12356;&#12378;&#12428;&#12363;&#12398;&#20516;&#12434;&#35373;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#20998;&#26512;&#12524;&#12505;&#12523;&#12398;&#35373;&#23450;&#12395;&#38306;&#12377;&#12427;&#35443;&#32048;&#24773;&#22577;&#12399;&#12289; <a class="xref" href="running.html#commandLineOptions" title="3. &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;">&#12300;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12301;</a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">conserveSpace</code></span></dt><dd><p>effort="min" &#12392;&#21516;&#32681;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">workHard</code></span></dt><dd><p>effort="max" &#12392;&#21516;&#32681;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">visitors</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#12393;&#12398;&#12496;&#12464;&#12487;&#12451;&#12486;&#12463;&#12479;&#12434;&#23455;&#34892;&#12377;&#12427;&#12363;&#12434;&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12398;&#12522;&#12473;&#12488;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12496;&#12464;&#12487;&#12451;&#12486;&#12463;&#12479;&#12399;&#12497;&#12483;&#12465;&#12540;&#12472;&#25351;&#23450;&#12394;&#12375;&#12398;&#12463;&#12521;&#12473;&#21517;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#30465;&#30053;&#26178;&#12289;&#12487;&#12501;&#12457;&#12523;&#12488;&#12391;&#28961;&#21177;&#21270;&#12373;&#12428;&#12390;&#12356;&#12427;&#12418;&#12398;&#12434;&#38500;&#12367;&#12377;&#12409;&#12390;&#12398;&#12487;&#12451;&#12486;&#12463;&#12479;&#12364;&#23455;&#34892;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">omitVisitors</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<code class="literal">visitors</code> &#23646;&#24615;&#12392;&#20284;&#12390;&#12356;&#12414;&#12377;&#12364;&#12289;&#12371;&#12385;&#12425;&#12399; <span class="emphasis"><em>&#23455;&#34892;&#12373;&#12428;&#12394;&#12356;</em></span> &#12487;&#12451;&#12486;&#12463;&#12479;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">excludeFilter</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#22577;&#21578;&#12363;&#12425;&#38500;&#22806;&#12373;&#12428;&#12427;&#12496;&#12464;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<a class="xref" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;">8&#31456;<i>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">includeFilter</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#22577;&#21578;&#12373;&#12428;&#12427;&#12496;&#12464;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<a class="xref" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;">8&#31456;<i>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">projectFile</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289; <span class="application">FindBugs</span> GUI &#12391;&#20316;&#25104;&#12375;&#12414;&#12377;&#12290;&#20998;&#26512;&#12373;&#12428;&#12427;&#12463;&#12521;&#12473;&#12289;&#12362;&#12424;&#12403;&#12289;&#35036;&#21161;&#12463;&#12521;&#12473;&#12497;&#12473;&#12289;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12364;&#35352;&#20837;&#12373;&#12428;&#12390;&#12414;&#12377;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289; <code class="literal">class</code> &#35201;&#32032;&#12539; <code class="literal">auxClasspath</code> &#23646;&#24615;&#12362;&#12424;&#12403; <code class="literal">sourcePath</code> &#23646;&#24615;&#12434;&#35373;&#23450;&#12377;&#12427;&#24517;&#35201;&#12399;&#12354;&#12426;&#12414;&#12379;&#12435;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#20316;&#25104;&#26041;&#27861;&#12399;&#12289; <a class="xref" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;">4&#31456;<i><span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">jvmargs</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12434;&#23455;&#34892;&#12375;&#12390;&#12356;&#12427; Java &#20206;&#24819;&#12510;&#12471;&#12531;&#12395;&#23550;&#12375;&#12390;&#21463;&#12369;&#28193;&#12373;&#12428;&#12427;&#24341;&#25968;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#24040;&#22823;&#12394;&#12503;&#12525;&#12464;&#12521;&#12512;&#12434;&#20998;&#26512;&#12377;&#12427;&#22580;&#21512;&#12395;&#12289; JVM &#12364;&#20351;&#29992;&#12377;&#12427;&#12513;&#12514;&#12522;&#23481;&#37327;&#12434;&#22679;&#12420;&#12377;&#25351;&#23450;&#12434;&#12377;&#12427;&#12383;&#12417;&#12395;&#12371;&#12398;&#24341;&#25968;&#12434;&#21033;&#29992;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12427;&#12363;&#12418;&#12375;&#12428;&#12414;&#12379;&#12435;&#12290;</p></dd><dt><span class="term"><code class="literal">systemProperty</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12493;&#12473;&#12488;&#12373;&#12428;&#12427;&#35201;&#32032;&#12391;&#12377;&#12290;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12289;Java &#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#23450;&#32681;&#12375;&#12414;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12395;&#12399;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12381;&#12375;&#12390;&#12289; <code class="literal">value</code> &#23646;&#24615;&#12395;&#12399;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12398;&#20516;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">timeout</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12434;&#23455;&#34892;&#12375;&#12390;&#12356;&#12427; Java &#12503;&#12525;&#12475;&#12473; &#12398;&#23455;&#34892;&#35377;&#23481;&#26178;&#38291;&#12434;&#12511;&#12522;&#31186;&#21336;&#20301;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#26178;&#38291;&#12434;&#36229;&#36942;&#12377;&#12427;&#12392;&#12495;&#12531;&#12464;&#12450;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12392;&#21028;&#26029;&#12375;&#12390;&#12503;&#12525;&#12475;&#12473;&#12364;&#32066;&#20102;&#12373;&#12428;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; 600,000 &#12511;&#12522;&#31186; (10 &#20998;) &#12391;&#12377;&#12290;&#24040;&#22823;&#12394;&#12503;&#12525;&#12464;&#12521;&#12512;&#12398;&#22580;&#21512;&#12399;&#12289; <span class="application">FindBugs</span> &#12364;&#20998;&#26512;&#12434;&#23436;&#20102;&#12377;&#12427;&#12414;&#12391;&#12395; 10 &#20998; &#20197;&#19978;&#25499;&#12363;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12427;&#12371;&#12392;&#12395;&#27880;&#24847;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">failOnError</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#12502;&#12540;&#12523;&#20516;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12398;&#23455;&#34892;&#20013;&#12395;&#12456;&#12521;&#12540;&#12364;&#12354;&#12387;&#12383;&#22580;&#21512;&#12395;&#12289;&#12499;&#12523;&#12489;&#12503;&#12525;&#12475;&#12473;&#33258;&#20307;&#12434;&#25171;&#12385;&#20999;&#12387;&#12390;&#30064;&#24120;&#32066;&#20102;&#12373;&#12379;&#12427;&#12363;&#12393;&#12358;&#12363;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289;&#12300;false&#12301;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">errorProperty</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12398;&#23455;&#34892;&#20013;&#12395;&#12456;&#12521;&#12540;&#12364;&#30330;&#29983;&#12375;&#12383;&#22580;&#21512;&#12395;&#12289;&#12300;true&#12301;&#12364;&#35373;&#23450;&#12373;&#12428;&#12427;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">warningsProperty</code></span></dt><dd><p>&#20219;&#24847;&#25351;&#23450;&#12398;&#23646;&#24615;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12364;&#20998;&#26512;&#12375;&#12383;&#12503;&#12525;&#12464;&#12521;&#12512;&#12395;&#12496;&#12464;&#22577;&#21578;&#12364; 1 &#20214;&#12391;&#12418;&#12354;&#12427;&#22580;&#21512;&#12395;&#12289;&#12300;true&#12301;&#12364;&#35373;&#23450;&#12373;&#12428;&#12427;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd></dl></div><p>
37
38
39 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gui.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="eclipse.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;5&#31456; <span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;7&#31456; <span class="application">FindBugs</span>&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;3&#31456; FindBugs&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="installing.html" title="&#31532;2&#31456; FindBugs&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;"><link rel="next" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;3&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="installing.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="running.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;3&#31456; FindBugs&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;"><div class="titlepage"><div><div><h2 class="title"><a name="building"></a>&#31532;3&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="building.html#d0e175">1. &#21069;&#25552;&#26465;&#20214;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e258">2. &#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e271">3. <code class="filename">local.properties</code> &#12398;&#20462;&#27491;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e326">4. <span class="application">Ant</span> &#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e420">5. &#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12363;&#12425;&#12398; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</a></span></dt></dl></div><p>&#12371;&#12398;&#31456;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12434;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12363;&#12425;&#12499;&#12523;&#12489;&#12377;&#12427;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12434;&#20462;&#27491;&#12377;&#12427;&#12371;&#12392;&#12395;&#33288;&#21619;&#12364;&#12394;&#12356;&#12398;&#12391;&#12354;&#12428;&#12400;&#12289; <a class="link" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;">&#27425;&#12398;&#31456;</a> &#12395;&#36914;&#12435;&#12391;&#12367;&#12384;&#12373;&#12356;&#12290;</p><div class="sect1" title="1. &#21069;&#25552;&#26465;&#20214;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e175"></a>1. &#21069;&#25552;&#26465;&#20214;</h2></div></div></div><p>&#12477;&#12540;&#12473;&#12363;&#12425; <span class="application">FindBugs</span> &#12434;&#12467;&#12531;&#12497;&#12452;&#12523;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289;&#20197;&#19979;&#12398;&#12418;&#12398;&#12364;&#24517;&#35201;&#12391;&#12377;&#12290;</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download" target="_top"><span class="application">FindBugs</span> &#12398;&#12477;&#12540;&#12473;&#37197;&#24067;&#29289;</a>
3 </p></li><li class="listitem"><p>
4 <a class="ulink" href="http://java.sun.com/j2se/" target="_top">JDK 1.5.0 &#12505;&#12540;&#12479; &#12414;&#12383;&#12399;&#12381;&#12428;&#20197;&#38477;</a>
5 </p></li><li class="listitem"><p>
6 <a class="ulink" href="http://ant.apache.org/" target="_top">Apache <span class="application">Ant</span></a>, &#12496;&#12540;&#12472;&#12519;&#12531; 1.6.3 &#12414;&#12383;&#12399;&#12381;&#12428;&#20197;&#38477;</p></li></ul></div><p>
7 </p><div class="warning" title="&#35686;&#21578;" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[&#35686;&#21578;]" src="warning.png"></td><th align="left">&#35686;&#21578;</th></tr><tr><td align="left" valign="top"><p>Redhat Linux &#12471;&#12473;&#12486;&#12512;&#12398; <code class="filename">/usr/bin/ant</code> &#12395;&#21516;&#26801;&#12373;&#12428;&#12390;&#12356;&#12427; <span class="application">Ant</span> &#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12398;&#12467;&#12531;&#12497;&#12452;&#12523;&#12399;<span class="emphasis"><em>&#12358;&#12414;&#12367;&#12391;&#12365;&#12414;&#12379;&#12435;</em></span>&#12290;<a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span> web &#12469;&#12452;&#12488;</a>&#12363;&#12425;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12375;&#12390;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12377;&#12427;&#12371;&#12392;&#12434;&#25512;&#22888;&#12375;&#12414;&#12377;&#12290;<span class="application">Ant</span> &#12434;&#23455;&#34892;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289; &#29872;&#22659;&#22793;&#25968; <em class="replaceable"><code>JAVA_HOME</code></em> &#12364; JDK 1.5 (&#12414;&#12383;&#12399;&#12381;&#12428;&#20197;&#38477;)&#12434;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12375;&#12383;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#25351;&#12375;&#12390;&#12356;&#12427;&#12371;&#12392;&#12434;&#30906;&#35469;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></td></tr></table></div><p>&#20307;&#35009;&#12398;&#25972;&#12387;&#12383; <span class="application">FindBugs</span> &#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#29983;&#25104;&#12375;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289;&#20197;&#19979;&#12398;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;&#12418;&#24517;&#35201;&#12392;&#12394;&#12426;&#12414;&#12377;:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/index.html" target="_top">DocBook XSL &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;</a>&#12290;<span class="application">FindBugs</span> &#12398;&#12510;&#12491;&#12517;&#12450;&#12523;&#12434; HTML &#12395;&#22793;&#25563;&#12377;&#12427;&#12398;&#12395;&#24517;&#35201;&#12391;&#12377;&#12290;</p></li><li class="listitem"><p><a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT &#12503;&#12525;&#12475;&#12483;&#12469;&#12540;</a>&#12290;(&#21516;&#27096;&#12395;&#12289; <span class="application">FindBugs</span> &#12398;&#12510;&#12491;&#12517;&#12450;&#12523;&#12434; HTML &#12395;&#22793;&#25563;&#12377;&#12427;&#12398;&#12395;&#24517;&#35201;&#12391;&#12377;&#12290;)</p></li></ul></div><p>
8 </p></div><div class="sect1" title="2. &#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e258"></a>2. &#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</h2></div></div></div><p>&#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12375;&#12383;&#24460;&#12395;&#12289;&#12381;&#12428;&#12434;&#20316;&#26989;&#29992;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#23637;&#38283;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#36890;&#24120;&#12399;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#12467;&#12510;&#12531;&#12489;&#12391;&#23637;&#38283;&#12434;&#34892;&#12356;&#12414;&#12377;:</p><pre class="screen">
9 <code class="prompt">$ </code><span class="command"><strong>unzip findbugs-2.0.3-source.zip</strong></span>
10 </pre><p>
11
12 </p></div><div class="sect1" title="3. local.properties &#12398;&#20462;&#27491;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e271"></a>3. <code class="filename">local.properties</code> &#12398;&#20462;&#27491;</h2></div></div></div><p>FindBugs &#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#12499;&#12523;&#12489;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289; <code class="filename">local.properties</code> &#12501;&#12449;&#12452;&#12523;&#12434;&#20462;&#27491;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289; <span class="application">FindBugs</span> &#12434;&#12499;&#12523;&#12489;&#12377;&#12427;&#38555;&#12395; <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a> <code class="filename">build.xml</code> &#12501;&#12449;&#12452;&#12523;&#12364;&#21442;&#29031;&#12375;&#12414;&#12377;&#12290;FindBugs &#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#12499;&#12523;&#12489;&#12375;&#12394;&#12356;&#22580;&#21512;&#12399;&#12289;&#12371;&#12398;&#12501;&#12449;&#12452;&#12523;&#12399;&#28961;&#35222;&#12375;&#12390;&#12418;&#12363;&#12414;&#12356;&#12414;&#12379;&#12435;&#12290;</p><p><code class="filename">local.properties</code> &#12391;&#12398;&#23450;&#32681;&#12399;&#12289; <code class="filename">build.properties</code> &#12501;&#12449;&#12452;&#12523;&#12391;&#12398;&#23450;&#32681;&#12395;&#20778;&#20808;&#12375;&#12414;&#12377;&#12290;<code class="filename">build.properties</code> &#12399;&#27425;&#12398;&#12424;&#12358;&#12394;&#20869;&#23481;&#12391;&#12377;:</p><pre class="programlisting">
13
14 # User Configuration:
15 # This section must be modified to reflect your system.
16
17 local.software.home =/export/home/daveho/linux
18
19 # Set this to the directory containing the DocBook Modular XSL Stylesheets
20 # from http://docbook.sourceforge.net/projects/xsl/
21
22 xsl.stylesheet.home =${local.software.home}/docbook/docbook-xsl-1.71.1
23
24 # Set this to the directory where Saxon (http://saxon.sourceforge.net/)
25 # is installed.
26
27 saxon.home =${local.software.home}/java/saxon-6.5.5
28
29 </pre><p>
30 </p><p><code class="varname">xsl.stylesheet.home</code> &#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12395;&#12399;&#12289;<a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/" target="_top">DocBook Modular XSL &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;</a>&#12364;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12375;&#12390;&#12354;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;&#32118;&#23550;&#12497;&#12473;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#29983;&#25104;&#12375;&#12424;&#12358;&#12392;&#32771;&#12360;&#12390;&#12356;&#12427;&#22580;&#21512;&#12395;&#12398;&#12415;&#12289;&#12371;&#12398;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#25351;&#23450;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p><p><code class="varname">saxon.home</code> &#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12395;&#12399;&#12289;<a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT &#12503;&#12525;&#12475;&#12483;&#12469;&#12540;</a>&#12364;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12375;&#12390;&#12354;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;&#32118;&#23550;&#12497;&#12473;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#29983;&#25104;&#12375;&#12424;&#12358;&#12392;&#32771;&#12360;&#12390;&#12356;&#12427;&#22580;&#21512;&#12395;&#12398;&#12415;&#12289;&#12371;&#12398;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#25351;&#23450;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="4. Ant &#12398;&#23455;&#34892;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e326"></a>4. <span class="application">Ant</span> &#12398;&#23455;&#34892;</h2></div></div></div><p>&#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;&#12289; <span class="application">Ant</span> &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12289;<code class="filename">build.properties</code>(<code class="filename">local.properties</code>) &#12398;&#20462;&#27491; (&#12371;&#12428;&#12399;&#20219;&#24847;) &#12362;&#12424;&#12403;&#12484;&#12540;&#12523; (<span class="application">Saxon</span> &#12394;&#12393;)&#12398;&#29872;&#22659;&#27083;&#31689;&#12364;&#12391;&#12365;&#12428;&#12400;&#12289; <span class="application">FindBugs</span> &#12434;&#12499;&#12523;&#12489;&#12377;&#12427;&#12383;&#12417;&#12398;&#28310;&#20633;&#12399;&#23436;&#20102;&#12391;&#12377;&#12290;<span class="application">Ant</span> &#12398;&#36215;&#21205;&#12377;&#12427;&#26041;&#27861;&#12399;&#12289;&#21336;&#12395;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12377;&#12427;&#12384;&#12369;&#12391;&#12377;&#12290;</p><pre class="screen">
31 <code class="prompt">$ </code><span class="command"><strong>ant <em class="replaceable"><code>target</code></em></strong></span>
32 </pre><p><em class="replaceable"><code>target</code></em> &#12395;&#12399;&#20197;&#19979;&#12398;&#12356;&#12378;&#12428;&#12363;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;: </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>build</strong></span></span></dt><dd><p>&#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399;&#12289; <span class="application">FindBugs</span> &#12398;&#12467;&#12540;&#12489;&#12434;&#12467;&#12531;&#12497;&#12452;&#12523;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12399;&#12289;&#12487;&#12501;&#12457;&#12523;&#12488;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>docs</strong></span></span></dt><dd><p>&#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399;&#12289;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12398;&#25972;&#24418;&#12434;&#34892;&#12356;&#12414;&#12377;(&#12414;&#12383;&#12289;&#21103;&#20316;&#29992;&#12392;&#12375;&#12390;&#12356;&#12367;&#12388;&#12363;&#12398;&#12477;&#12540;&#12473;&#12398;&#12467;&#12531;&#12497;&#12452;&#12523;&#12418;&#34892;&#12356;&#12414;&#12377;&#12290;)</p></dd><dt><span class="term"><span class="command"><strong>runjunit</strong></span></span></dt><dd><p>&#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399;&#12289;&#12467;&#12531;&#12497;&#12452;&#12523;&#12434;&#34892;&#12356; <span class="application">FindBugs</span> &#12364;&#25345;&#12387;&#12390;&#12356;&#12427; JUnit &#12486;&#12473;&#12488;&#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;&#12518;&#12491;&#12483;&#12488;&#12486;&#12473;&#12488;&#12364;&#22833;&#25943;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289;&#12456;&#12521;&#12540;&#12513;&#12483;&#12475;&#12540;&#12472;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>bindist</strong></span></span></dt><dd><p><span class="application">FindBugs</span> &#12398;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12434;&#27083;&#31689;&#12375;&#12414;&#12377;&#12290;&#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399;&#12289; <code class="filename">.zip</code> &#12362;&#12424;&#12403; <code class="filename">.tar.gz</code> &#12398;&#12450;&#12540;&#12459;&#12452;&#12502;&#12434;&#12381;&#12428;&#12382;&#12428;&#20316;&#25104;&#12375;&#12414;&#12377;&#12290;</p></dd></dl></div><p>
33 </p><p><span class="application">Ant</span> &#12467;&#12510;&#12531;&#12489;&#12398;&#23455;&#34892;&#24460;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#20986;&#21147;&#12364;&#34920;&#31034;&#12373;&#12428;&#12427;&#12399;&#12378;&#12391;&#12377;&#12290; (&#12371;&#12398;&#21069;&#12395; <span class="application">Ant</span> &#12364;&#23455;&#34892;&#12375;&#12383;&#12479;&#12473;&#12463;&#12395;&#38306;&#12377;&#12427;&#12513;&#12483;&#12475;&#12540;&#12472;&#12418;&#12356;&#12367;&#12425;&#12363;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;):</p><pre class="screen">
34 <code class="computeroutput">
35 BUILD SUCCESSFUL
36 Total time: 17 seconds
37 </code>
38 </pre><p>
39 </p></div><div class="sect1" title="5. &#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12363;&#12425;&#12398; FindBugs&#8482; &#12398;&#23455;&#34892;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e420"></a>5. &#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12363;&#12425;&#12398; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</h2></div></div></div><p><span class="command"><strong>build</strong></span> &#12479;&#12540;&#12466;&#12483;&#12488;&#12398;&#23455;&#34892;&#12364;&#32066;&#20102;&#12377;&#12427;&#12392;&#12289;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12392;&#21516;&#27096;&#12398;&#29366;&#24907;&#12364;&#20316;&#26989;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#27083;&#31689;&#12373;&#12428;&#12427;&#12424;&#12358;&#12395; <span class="application">FindBugs</span> &#12398;<span class="application">Ant</span> &#12499;&#12523;&#12489;&#12473;&#12463;&#12522;&#12503;&#12488;&#12399;&#35352;&#36848;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;<a class="xref" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;">4&#31456;<i><span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</i></a> &#12398; <span class="application">FindBugs</span> &#12398;&#23455;&#34892;&#12395;&#38306;&#12377;&#12427;&#24773;&#22577;&#12399;&#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#22580;&#21512;&#12395;&#12418;&#24540;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="installing.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="running.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;2&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;4&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;12&#31456; FindBugs&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="rejarForAnalysis.html" title="&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;"><link rel="next" href="license.html" title="&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;12&#31456; <span class="application">FindBugs</span>&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rejarForAnalysis.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="license.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;12&#31456; FindBugs&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;"><div class="titlepage"><div><div><h2 class="title"><a name="datamining"></a>&#31532;12&#31456; <span class="application">FindBugs</span>&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="datamining.html#commands">1. &#12467;&#12510;&#12531;&#12489;</a></span></dt><dt><span class="sect1"><a href="datamining.html#examples">2. &#20363;</a></span></dt><dt><span class="sect1"><a href="datamining.html#antexample">3. Ant &#12398;&#20363;</a></span></dt></dl></div><p>&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12408;&#12398;&#39640;&#27231;&#33021;&#12398;&#21839;&#12356;&#21512;&#12431;&#12379;&#27231;&#33021;&#12289;&#12362;&#12424;&#12403;&#12289;&#35519;&#26619;&#23550;&#35937;&#12398;&#12467;&#12540;&#12489;&#12398;&#35079;&#25968;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12431;&#12383;&#12427;&#35686;&#21578;&#12398;&#36861;&#36321;&#35352;&#37682;&#27231;&#33021;&#12434;&#12289; FindBugs &#12399;&#20869;&#34101;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12434;&#20351;&#12387;&#12390;&#27425;&#12398;&#12424;&#12358;&#12394;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12377;&#12394;&#12431;&#12385;&#12289;&#12356;&#12388;&#12496;&#12464;&#12364;&#26368;&#21021;&#25345;&#12385;&#36796;&#12414;&#12428;&#12383;&#12363;&#12434;&#25436;&#12375;&#20986;&#12377;&#12371;&#12392;&#12289;&#26368;&#32066;&#12522;&#12522;&#12540;&#12473;&#20197;&#24460;&#25345;&#12385;&#36796;&#12414;&#12428;&#12383;&#35686;&#21578;&#12398;&#20998;&#26512;&#12434;&#34892;&#12358;&#12371;&#12392;&#12289;&#12414;&#12383;&#12399;&#12289;&#28961;&#38480;&#20877;&#36215;&#12523;&#12540;&#12503;&#12398;&#25968;&#12434;&#26178;&#38291;&#36600;&#12391;&#12464;&#12521;&#12501;&#12395;&#12377;&#12427;&#12371;&#12392;&#12391;&#12377;&#12290;</p><p>&#12371;&#12428;&#12425;&#12398;&#25216;&#34899;&#12399;&#12289; FindBugs &#12364;&#35686;&#21578;&#12398;&#20445;&#23384;&#12395;&#20351;&#12358; XML &#26360;&#24335;&#12434;&#20351;&#29992;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12398; XML &#12501;&#12449;&#12452;&#12523;&#12399;&#12289;&#36890;&#24120;&#12289;&#29305;&#23450;&#12398; 1 &#20998;&#26512;&#12395;&#23550;&#12377;&#12427;&#35686;&#21578;&#12364;&#20837;&#12428;&#12425;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#12375;&#12363;&#12375;&#12381;&#12428;&#12425;&#12395;&#12399;&#12289;&#19968;&#36899;&#12398;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;&#12398;&#12499;&#12523;&#12489;&#12420;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23550;&#12377;&#12427;&#20998;&#26512;&#32080;&#26524;&#12434;&#26684;&#32013;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12377;&#12409;&#12390;&#12398; FindBugs XML &#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12399;&#12289;&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;&#12392;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503; &#12364;&#20837;&#12428;&#12425;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;FindBugs &#12399;&#20998;&#26512;&#12364;&#34892;&#12431;&#12428;&#12427;&#12501;&#12449;&#12452;&#12523;&#12398;&#26356;&#26032;&#26178;&#21051;&#12363;&#12425;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12434;&#35336;&#31639;&#12375;&#12414;&#12377; (&#20363;&#12360;&#12400;&#12289;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12399;&#12463;&#12521;&#12473;&#12501;&#12449;&#12452;&#12523;&#12398;&#29983;&#25104;&#26178;&#21051;&#12395;&#12394;&#12427;&#12424;&#12358;&#12395;&#12394;&#12387;&#12390;&#12356;&#12414;&#12377;&#12290;&#20998;&#26512;&#12364;&#34892;&#12431;&#12428;&#12383;&#26178;&#21051;&#12391;&#12399;&#12354;&#12426;&#12414;&#12379;&#12435;) &#12290;&#21508;&#12293;&#12398;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12399;&#12289;&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;&#12418;&#20837;&#12428;&#12425;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;&#12392;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12399;&#12289; <span class="command"><strong>setBugDatabaseInfo</strong></span> (<a class="xref" href="datamining.html#setBugDatabaseInfo" title="1.7. setBugDatabaseInfo">&#12300;setBugDatabaseInfo&#12301;</a>) &#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12375;&#12390;&#25163;&#21205;&#12391;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#26684;&#32013;&#12377;&#12427;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289;&#20998;&#26512;&#12373;&#12428;&#12427;&#12467;&#12540;&#12489;&#12398;&#21508;&#12496;&#12540;&#12472;&#12519;&#12531;&#12372;&#12392;&#12395;&#12471;&#12540;&#12465;&#12531;&#12473;&#30058;&#21495;&#12364;&#21106;&#12426;&#24403;&#12390;&#12425;&#12428;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12398;&#12471;&#12540;&#12465;&#12531;&#12473;&#30058;&#21495;&#12399;&#21336;&#12395; 0 &#12363;&#12425;&#22987;&#12414;&#12427;&#36899;&#32154;&#12377;&#12427;&#25972;&#25968;&#20516;&#12391;&#12377; (&#20363;&#12360;&#12400;&#12289; 4 &#12388;&#12398;&#12467;&#12540;&#12489;&#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#26684;&#32013;&#12377;&#12427;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12399;&#12289;&#12496;&#12540;&#12472;&#12519;&#12531; 0~3 &#12364;&#20837;&#12428;&#12425;&#12428;&#12414;&#12377;) &#12290;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12399;&#12414;&#12383;&#12289;&#21508;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#21517;&#21069;&#12392;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12364;&#12381;&#12428;&#12382;&#12428;&#35352;&#37682;&#12373;&#12428;&#12414;&#12377;&#12290;<span class="command"><strong>filterBugs</strong></span> &#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12392;&#12289;&#12471;&#12540;&#12465;&#12531;&#12473;&#30058;&#21495;&#12289;&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;&#12414;&#12383;&#12399;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12363;&#12425;&#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#21442;&#29031;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>1 &#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#26684;&#32013;&#12377;&#12427;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#38598;&#21512;&#12363;&#12425;&#12289; 1 &#20491;&#12398;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12434;&#20316;&#25104;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#23550;&#12375;&#12390;&#12289;&#12381;&#12428;&#20197;&#24460;&#12395;&#20316;&#25104;&#12373;&#12428;&#12383; 1 &#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12434;&#32080;&#21512;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12371;&#12428;&#12425;&#12398;&#12467;&#12510;&#12531;&#12489;&#12398;&#12356;&#12367;&#12388;&#12363;&#12399;&#12289; ant &#12479;&#12473;&#12463;&#12392;&#12375;&#12390;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12467;&#12510;&#12531;&#12489;&#12398;&#23455;&#34892;&#26041;&#27861;&#12362;&#12424;&#12403;&#23646;&#24615;&#12539;&#24341;&#25968;&#12398;&#35443;&#32048;&#12399;&#12289;&#20197;&#19979;&#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#20197;&#19979;&#12398;&#12377;&#12409;&#12390;&#12398;&#20363;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289; <code class="literal">findbugs.lib</code> <code class="literal">refid</code> &#12364;&#27491;&#12375;&#12367;&#35373;&#23450;&#12373;&#12428;&#12390;&#12356;&#12427;&#12371;&#12392;&#12434;&#21069;&#25552;&#12392;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#35373;&#23450;&#26041;&#27861;&#12398;&#19968;&#20363;&#12434;&#27425;&#12395;&#31034;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
3
4 &lt;!-- findbugs &#12479;&#12473;&#12463;&#23450;&#32681; --&gt;
5 &lt;property name="findbugs.home" value="/your/path/to/findbugs" /&gt;
6 &lt;path id="findbugs.lib"&gt;
7 &lt;fileset dir="${findbugs.home}/lib"&gt;
8 &lt;include name="findbugs-ant.jar"/&gt;
9 &lt;/fileset&gt;
10 &lt;/path&gt;
11
12 </pre><div class="sect1" title="1. &#12467;&#12510;&#12531;&#12489;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="commands"></a>1. &#12467;&#12510;&#12531;&#12489;</h2></div></div></div><p>FindBugs &#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464; &#12484;&#12540;&#12523;&#12399;&#12377;&#12409;&#12390;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12363;&#12425;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12356;&#12367;&#12388;&#12363;&#12398;&#12424;&#12426;&#26377;&#29992;&#12394;&#12467;&#12510;&#12531;&#12489;&#12399;&#12289; ant &#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12363;&#12425;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12484;&#12540;&#12523;&#12395;&#12388;&#12356;&#12390;&#31777;&#21336;&#12395;&#35500;&#26126;&#12375;&#12414;&#12377; :</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#unionBugs" title="1.1. unionBugs">unionBugs</a></strong></span></span></dt><dd><p>&#21029;&#12398;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#21029;&#20491;&#12398;&#20998;&#26512;&#32080;&#26524;&#12434;&#32080;&#21512;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#computeBugHistory" title="1.2. computeBugHistory">computeBugHistory</a></strong></span></span></dt><dd><p>&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12363;&#12425;&#24471;&#12425;&#12428;&#12383;&#35079;&#25968;&#12398;&#12496;&#12464;&#35686;&#21578;&#12434;&#12289;&#12510;&#12540;&#12472;&#12375;&#12390; 1 &#20491;&#12398;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12434;&#20351;&#12387;&#12390;&#12289;&#26082;&#23384;&#12398;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#26356;&#12395;&#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#36861;&#21152;&#12375;&#12383;&#12426;&#12289; 1 &#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#26684;&#32013;&#12377;&#12427;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#38598;&#21512;&#12363;&#12425; 1 &#20491;&#12398;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12434;&#20316;&#25104;&#12375;&#12383;&#12426;&#12289;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#setBugDatabaseInfo" title="1.7. setBugDatabaseInfo">setBugDatabaseInfo</a></strong></span></span></dt><dd><p>&#12522;&#12499;&#12472;&#12519;&#12531;&#21517;&#12420;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12394;&#12393;&#12398;&#24773;&#22577;&#12434; XML &#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#listBugDatabaseInfo" title="1.8. listBugDatabaseInfo">listBugDatabaseInfo</a></strong></span></span></dt><dd><p>XML &#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12395;&#12354;&#12427;&#12522;&#12499;&#12472;&#12519;&#12531;&#21517;&#12420;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12394;&#12393;&#12398;&#24773;&#22577;&#12434;&#19968;&#35239;&#34920;&#31034;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#filterBugs" title="1.3. filterBugs">filterBugs</a></strong></span></span></dt><dd><p>&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#37096;&#20998;&#38598;&#21512;&#12434;&#36984;&#25246;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#mineBugHistory" title="1.4. mineBugHistory">mineBugHistory</a></strong></span></span></dt><dd><p>&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#21508;&#12496;&#12540;&#12472;&#12519;&#12531;&#27598;&#12398;&#35686;&#21578;&#25968;&#12434;&#19968;&#35239;&#12395;&#12375;&#12383;&#34920;&#12434;&#20316;&#25104;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#defectDensity" title="1.5. defectDensity">defectDensity</a></strong></span></span></dt><dd><p>&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20840;&#20307;&#12362;&#12424;&#12403;&#12463;&#12521;&#12473;&#27598;&#12539;&#12497;&#12483;&#12465;&#12540;&#12472;&#27598;&#12398;&#19981;&#33391;&#23494;&#24230; (1000 NCSS &#27598;&#12398;&#35686;&#21578;&#25968;) &#12395;&#38306;&#12377;&#12427;&#24773;&#22577;&#12434;&#19968;&#35239;&#34920;&#31034;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#convertXmlToText" title="1.6. convertXmlToText">convertXmlToText</a></strong></span></span></dt><dd><p>XML &#24418;&#24335;&#12398;&#12496;&#12464;&#35686;&#21578;&#12434;&#12289; 1 &#34892; 1 &#12496;&#12464;&#12398;&#12486;&#12461;&#12473;&#12488;&#24418;&#24335;&#12289;&#12414;&#12383;&#12399;&#12289;HTML&#24418;&#24335;&#12395;&#22793;&#25563;&#12375;&#12414;&#12377;&#12290;</p></dd></dl></div><div class="sect2" title="1.1. unionBugs"><div class="titlepage"><div><div><h3 class="title"><a name="unionBugs"></a>1.1. unionBugs</h3></div></div></div><p>&#20998;&#26512;&#12377;&#12427;&#12398;&#12395;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12398; jar &#12501;&#12449;&#12452;&#12523;&#12434;&#20998;&#21106;&#12375;&#12390;&#12356;&#12427;&#22580;&#21512;&#12289;&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#21029;&#20491;&#12395;&#29983;&#25104;&#12373;&#12428;&#12383; XML &#12496;&#12464;&#35686;&#21578;&#12501;&#12449;&#12452;&#12523;&#12434;&#12377;&#12409;&#12390;&#12398;&#35686;&#21578;&#12434;&#21547;&#12435;&#12391;&#12356;&#12427; 1 &#12388;&#12398; &#12501;&#12449;&#12452;&#12523;&#12395;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#21516;&#12376;&#12501;&#12449;&#12452;&#12523;&#12398;&#30064;&#12394;&#12427;&#12496;&#12540;&#12472;&#12519;&#12531;&#12434;&#20998;&#26512;&#12375;&#12383;&#32080;&#26524;&#12434;&#32080;&#21512;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289;&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;<span class="emphasis"><em>&#20351;&#29992;&#12375;&#12394;&#12356;&#12391;&#12367;&#12384;&#12373;&#12356;</em></span>&#12290;&#20195;&#12431;&#12426;&#12395; <span class="command"><strong>computeBugHistory</strong></span> &#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p>XML &#12501;&#12449;&#12452;&#12523;&#12399;&#12289;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12391;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#32080;&#26524;&#12399;&#12289;&#27161;&#28310;&#20986;&#21147;&#12395;&#36865;&#12425;&#12428;&#12414;&#12377;&#12290;</p></div><div class="sect2" title="1.2. computeBugHistory"><div class="titlepage"><div><div><h3 class="title"><a name="computeBugHistory"></a>1.2. computeBugHistory</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#20998;&#26512;&#12377;&#12427;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;&#12398;&#30064;&#12394;&#12427;&#12499;&#12523;&#12489;&#12414;&#12383;&#12399;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#24773;&#22577;&#12434;&#21547;&#12416;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12434;&#29983;&#25104;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#20837;&#21147;&#12392;&#12375;&#12390;&#25552;&#20379;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12398; 1 &#30058;&#30446;&#12398;&#12501;&#12449;&#12452;&#12523;&#12363;&#12425;&#23653;&#27508;&#12364;&#21462;&#24471;&#12373;&#12428;&#12414;&#12377;&#12290;&#24460;&#12395;&#32154;&#12367;&#12501;&#12449;&#12452;&#12523;&#12399; 1 &#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12391;&#12354;&#12427;&#12424;&#12358;&#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356; (&#12418;&#12375;&#12289;&#23653;&#27508;&#12434;&#25345;&#12387;&#12390;&#12356;&#12383;&#12392;&#12375;&#12390;&#12418;&#28961;&#35222;&#12373;&#12428;&#12414;&#12377;) &#12290;</p><p>&#12487;&#12501;&#12457;&#12523;&#12488;&#12391;&#12399;&#12289;&#32080;&#26524;&#12399;&#27161;&#28310;&#20986;&#21147;&#12395;&#36865;&#12425;&#12428;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398;&#27231;&#33021;&#12399;&#12289; ant &#12363;&#12425;&#12418;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12378;&#27425;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395;&#12289;&#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12395; <span class="command"><strong>computeBugHistory</strong></span> &#12434; taskdef &#12391;&#23450;&#32681;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
13
14 &lt;taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"&gt;
15 &lt;classpath refid="findbugs.lib" /&gt;
16 &lt;/taskdef&gt;
17
18 </pre><p>&#12371;&#12398; ant &#12479;&#12473;&#12463;&#12395;&#25351;&#23450;&#12391;&#12365;&#12427;&#23646;&#24615;&#12434;&#12289;&#19979;&#34920;&#12395;&#19968;&#35239;&#12391;&#31034;&#12375;&#12414;&#12377;&#12290;&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12377;&#12427;&#12395;&#12399;&#12289; <code class="literal">&lt;datafile&gt;</code> &#35201;&#32032;&#12434;&#20837;&#12428;&#23376;&#12395;&#12375;&#12390;&#20837;&#12428;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="programlisting">
19
20 &lt;computeBugHistory home="${findbugs.home}" ...&gt;
21 &lt;datafile name="analyze1.xml"/&gt;
22 &lt;datafile name="analyze2.xml"/&gt;
23 &lt;/computeBugHistory&gt;
24
25 </pre><div class="table"><a name="computeBugHistoryTable"></a><p class="title"><b>&#34920;12.1 computeBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</b></p><div class="table-contents"><table summary="computeBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</th><th align="left">Ant &#23646;&#24615;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">-output &lt;file&gt;</td><td align="left">output="&lt;file&gt;"</td><td align="left">&#20986;&#21147;&#32080;&#26524;&#12434;&#20445;&#23384;&#12377;&#12427;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290; (&#21516;&#26178;&#12395;&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12395;&#12418;&#12394;&#12426;&#12360;&#12414;&#12377;)</td></tr><tr><td align="left">-overrideRevisionNames[:truth]</td><td align="left">overrideRevisionNames="[true|false]"</td><td align="left">&#12501;&#12449;&#12452;&#12523;&#21517;&#12363;&#12425;&#31639;&#20986;&#12373;&#12428;&#12427;&#12381;&#12428;&#12382;&#12428;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;&#12434;&#25351;&#23450;&#22793;&#26356;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-noPackageMoves[:truth]</td><td align="left">noPackageMoves="[true|false]"</td><td align="left">&#12497;&#12483;&#12465;&#12540;&#12472;&#12434;&#31227;&#21205;&#12375;&#12383;&#12463;&#12521;&#12473;&#12364;&#12354;&#12427;&#22580;&#21512;&#12289;&#24403;&#35442;&#12463;&#12521;&#12473;&#12398;&#35686;&#21578;&#12399;&#21029;&#12398;&#23384;&#22312;&#12392;&#12375;&#12390;&#25201;&#12431;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-preciseMatch[:truth]</td><td align="left">preciseMatch="[true|false]"</td><td align="left">&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12364;&#27491;&#30906;&#12395;&#19968;&#33268;&#12377;&#12427;&#12371;&#12392;&#12434;&#35201;&#27714;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-precisePriorityMatch[:truth]</td><td align="left">precisePriorityMatch="[true|false]"</td><td align="left">&#20778;&#20808;&#24230;&#12364;&#27491;&#30906;&#12395;&#19968;&#33268;&#12375;&#12383;&#22580;&#21512;&#12398;&#12415;&#35686;&#21578;&#12364;&#21516;&#19968;&#12391;&#12354;&#12427;&#12392;&#21028;&#26029;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-quiet[:truth]</td><td align="left">quiet="[true|false]"</td><td align="left">&#12456;&#12521;&#12540;&#12364;&#30330;&#29983;&#12375;&#12394;&#12356;&#38480;&#12426;&#12289;&#27161;&#28310;&#20986;&#21147;&#12395;&#12399;&#20309;&#12418;&#34920;&#31034;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;</td></tr><tr><td align="left">-withMessages[:truth]</td><td align="left">withMessages="[true|false]"</td><td align="left">&#20986;&#21147; XML &#12395;&#20154;&#38291;&#12364;&#35501;&#12416;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#12496;&#12464;&#12513;&#12483;&#12475;&#12540;&#12472;&#12364;&#21547;&#12414;&#12428;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.3. filterBugs"><div class="titlepage"><div><div><h3 class="title"><a name="filterBugs"></a>1.3. filterBugs</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; FindBugs XML &#35686;&#21578;&#12501;&#12449;&#12452;&#12523;&#12363;&#12425;&#19968;&#37096;&#20998;&#12434;&#36984;&#12403;&#20986;&#12375;&#12390;&#26032;&#35215; FindBugs &#35686;&#21578;&#12501;&#12449;&#12452;&#12523;&#12395;&#36984;&#25246;&#12373;&#12428;&#12383;&#37096;&#20998;&#12434;&#26360;&#12365;&#36796;&#12416;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12395;&#12399;&#12289;&#12458;&#12503;&#12471;&#12519;&#12531;&#32676;&#12395;&#32154;&#12356;&#12390; 0 &#20491;&#12363;&#12425; 2 &#20491;&#12398; findbugs xml &#12496;&#12464;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#12402;&#12392;&#12388;&#12418;&#25351;&#23450;&#12375;&#12394;&#12356;&#22580;&#21512;&#12399;&#12289;&#27161;&#28310;&#20837;&#21147;&#12363;&#12425;&#35501;&#12435;&#12391;&#27161;&#28310;&#20986;&#21147;&#12395;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434; 1 &#20491; &#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289;&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12363;&#12425;&#35501;&#12435;&#12391;&#27161;&#28310;&#20986;&#21147;&#12395;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434; 2 &#20491; &#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289; 1 &#30058;&#30446;&#12395;&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12363;&#12425;&#35501;&#12435;&#12391; 2 &#30058;&#30446;&#12395;&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12395;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398;&#27231;&#33021;&#12399;&#12289; ant &#12363;&#12425;&#12418;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12378;&#27425;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395;&#12289;&#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12395; <span class="command"><strong>filterBugs</strong></span> &#12434; taskdef &#12391;&#23450;&#32681;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
26
27 &lt;taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask"&gt;
28 &lt;classpath refid="findbugs.lib" /&gt;
29 &lt;/taskdef&gt;
30
31 </pre><p>&#12371;&#12398; ant &#12479;&#12473;&#12463;&#12395;&#25351;&#23450;&#12391;&#12365;&#12427;&#23646;&#24615;&#12434;&#12289;&#19979;&#34920;&#12395;&#19968;&#35239;&#12391;&#31034;&#12375;&#12414;&#12377;&#12290;&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12377;&#12427;&#12395;&#12399;&#12289; <code class="literal">input</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12377;&#12427;&#12363;&#12289; <code class="literal">&lt;datafile&gt;</code> &#35201;&#32032;&#12434;&#20837;&#12428;&#23376;&#12395;&#12375;&#12390;&#20837;&#12428;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="programlisting">
32
33 &lt;filterBugs home="${findbugs.home}" ...&gt;
34 &lt;datafile name="analyze.xml"/&gt;
35 &lt;/filterBugs&gt;
36
37 </pre><div class="table"><a name="filterOptionsTable"></a><p class="title"><b>&#34920;12.2 filterBugs &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</b></p><div class="table-contents"><table summary="filterBugs &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</th><th align="left">Ant &#23646;&#24615;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">&#20986;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-not</td><td align="left">not="[true|false]"</td><td align="left">&#12501;&#12451;&#12523;&#12479;&#12540;&#12398;&#12473;&#12452;&#12483;&#12481;&#12434;&#21453;&#36578;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-withSource[:truth]</td><td align="left">withSource="[true|false]"</td><td align="left">&#12477;&#12540;&#12473;&#12364;&#20837;&#25163;&#21487;&#33021;&#12394;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-exclude &lt;filter file&gt;</td><td align="left">exclude="&lt;filter file&gt;"</td><td align="left">&#12501;&#12451;&#12523;&#12479;&#12540;&#12395;&#19968;&#33268;&#12377;&#12427;&#12496;&#12464;&#12364;&#38500;&#22806;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-include &lt;filter file&gt;</td><td align="left">include="&lt;filter file&gt;"</td><td align="left">&#12501;&#12451;&#12523;&#12479;&#12540;&#12395;&#19968;&#33268;&#12377;&#12427;&#12496;&#12464;&#12398;&#12415;&#12434;&#21547;&#12414;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-annotation &lt;text&gt;</td><td align="left">annotation="&lt;text&gt;"</td><td align="left">&#25163;&#12391;&#20837;&#21147;&#12375;&#12383;&#27880;&#37320;&#12395;&#25351;&#23450;&#12375;&#12383;&#25991;&#35328;&#12434;&#21547;&#12416;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-after &lt;when&gt;</td><td align="left">after="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12424;&#12426;&#24460;&#12395;&#21021;&#12417;&#12390;&#20986;&#29694;&#12375;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-before &lt;when&gt;</td><td align="left">before="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12424;&#12426;&#21069;&#12395;&#21021;&#12417;&#12390;&#20986;&#29694;&#12375;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-first &lt;when&gt;</td><td align="left">first="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#21021;&#12417;&#12390;&#20986;&#29694;&#12375;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-last &lt;when&gt;</td><td align="left">last="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12364;&#20986;&#29694;&#12375;&#12383;&#26368;&#24460;&#12391;&#12354;&#12427;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-fixed &lt;when&gt;</td><td align="left">fixed="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#21069;&#22238;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12364;&#20986;&#29694;&#12375;&#12383;&#26368;&#24460;&#12391;&#12354;&#12427;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290; (<code class="option">-last</code> &#12395;&#20778;&#20808;&#12375;&#12414;&#12377;)&#12290;</td></tr><tr><td align="left">-present &lt;when&gt;</td><td align="left">present="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12377;&#12427;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-absent &lt;when&gt;</td><td align="left">absent="&lt;when&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12375;&#12394;&#12356;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-active[:truth]</td><td align="left">active="[true|false]"</td><td align="left">&#26368;&#32066;&#36890;&#30058;&#12395;&#23384;&#22312;&#12377;&#12427;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-introducedByChange[:truth]</td><td align="left">introducedByChange="[true|false]"</td><td align="left">&#23384;&#22312;&#12377;&#12427;&#12463;&#12521;&#12473;&#12398;&#22793;&#26356;&#12395;&#12424;&#12387;&#12390;&#12418;&#12383;&#12425;&#12373;&#12428;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-removedByChange[:truth]</td><td align="left">removedByChange="[true|false]"</td><td align="left">&#23384;&#22312;&#12377;&#12427;&#12463;&#12521;&#12473;&#12398;&#22793;&#26356;&#12395;&#12424;&#12387;&#12390;&#38500;&#21435;&#12373;&#12428;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-newCode[:truth]</td><td align="left">newCode="[true|false]"</td><td align="left">&#26032;&#12463;&#12521;&#12473;&#12398;&#36861;&#21152;&#12395;&#12424;&#12387;&#12390;&#12418;&#12383;&#12425;&#12373;&#12428;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-removedCode[:truth]</td><td align="left">removedCode="[true|false]"</td><td align="left">&#12463;&#12521;&#12473;&#12398;&#21066;&#38500;&#12395;&#12424;&#12387;&#12390;&#38500;&#21435;&#12373;&#12428;&#12383;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-priority &lt;level&gt;</td><td align="left">priority="&lt;level&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#20778;&#20808;&#24230;&#20197;&#19978;&#12398;&#20778;&#20808;&#24230;&#12434;&#12418;&#12388;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-class &lt;pattern&gt;</td><td align="left">class="&lt;class&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12497;&#12479;&#12540;&#12531;&#12395;&#19968;&#33268;&#12377;&#12427;&#20027;&#12463;&#12521;&#12473;&#12434;&#12418;&#12388;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-bugPattern &lt;pattern&gt;</td><td align="left">bugPattern="&lt;pattern&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12497;&#12479;&#12540;&#12531;&#12395;&#19968;&#33268;&#12377;&#12427;&#12496;&#12464;&#31278;&#21029;&#12434;&#12418;&#12388;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-category &lt;category&gt;</td><td align="left">category="&lt;category&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#25991;&#23383;&#21015;&#12391;&#22987;&#12414;&#12427;&#12459;&#12486;&#12468;&#12522;&#12540;&#12398;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-designation &lt;designation&gt;</td><td align="left">designation="&lt;designation&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12496;&#12464;&#20998;&#39006;&#25351;&#23450;&#12434;&#12418;&#12388;&#35686;&#21578;&#12398;&#12415;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290; (&#20363;&#12289; -designation SHOULD_FIX)</td></tr><tr><td align="left">-withMessages[:truth] </td><td align="left">withMessages="[true|false]"</td><td align="left">&#12486;&#12461;&#12473;&#12488;&#12513;&#12483;&#12475;&#12540;&#12472;&#12434;&#21547;&#12435;&#12384; XML &#12364;&#29983;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.4. mineBugHistory"><div class="titlepage"><div><div><h3 class="title"><a name="mineBugHistory"></a>1.4. mineBugHistory</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#35079;&#25968;&#12496;&#12540;&#12472;&#12519;&#12531;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#21508;&#12496;&#12540;&#12472;&#12519;&#12531;&#27598;&#12398;&#35686;&#21578;&#25968;&#12434;&#19968;&#35239;&#12395;&#12375;&#12383;&#34920;&#12434;&#20316;&#25104;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398;&#27231;&#33021;&#12399;&#12289; ant &#12363;&#12425;&#12418;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12378;&#27425;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395;&#12289;&#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12395; <span class="command"><strong>mineBugHistory</strong></span> &#12434; taskdef &#12391;&#23450;&#32681;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
38
39 &lt;taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"&gt;
40 &lt;classpath refid="findbugs.lib" /&gt;
41 &lt;/taskdef&gt;
42
43 </pre><p>&#12371;&#12398; ant &#12479;&#12473;&#12463;&#12395;&#25351;&#23450;&#12391;&#12365;&#12427;&#23646;&#24615;&#12434;&#12289;&#19979;&#34920;&#12395;&#19968;&#35239;&#12391;&#31034;&#12375;&#12414;&#12377;&#12290;&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12377;&#12427;&#12395;&#12399;&#12289; <code class="literal">input</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12377;&#12427;&#12363;&#12289; <code class="literal">&lt;datafile&gt;</code> &#35201;&#32032;&#12434;&#20837;&#12428;&#23376;&#12395;&#12375;&#12390;&#20837;&#12428;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="programlisting">
44
45 &lt;mineBugHistory home="${findbugs.home}" ...&gt;
46 &lt;datafile name="analyze.xml"/&gt;
47 &lt;/mineBugHistory&gt;
48
49 </pre><div class="table"><a name="mineBugHistoryOptionsTable"></a><p class="title"><b>&#34920;12.3 mineBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</b></p><div class="table-contents"><table summary="mineBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</th><th align="left">Ant &#23646;&#24615;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">&#20986;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-formatDates</td><td align="left">formatDates="[true|false]"</td><td align="left">&#12487;&#12540;&#12479;&#12364;&#12486;&#12461;&#12473;&#12488;&#24418;&#24335;&#12391;&#25551;&#30011;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-noTabs</td><td align="left">noTabs="[true|false]"</td><td align="left">&#12479;&#12502;&#12398;&#20195;&#12431;&#12426;&#12395;&#35079;&#25968;&#12473;&#12506;&#12540;&#12473;&#12391;&#12459;&#12521;&#12512;&#12364;&#21306;&#20999;&#12425;&#12428;&#12414;&#12377; (&#19979;&#35352;&#21442;&#29031;)&#12290;</td></tr><tr><td align="left">-summary</td><td align="left">summary="[true|false]"</td><td align="left">&#26368;&#26032; 10 &#20214;&#12398;&#22793;&#26356;&#12398;&#35201;&#32004;&#12364;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"><p><code class="option">-noTabs</code> &#20986;&#21147;&#12434;&#20351;&#12358;&#12371;&#12392;&#12391;&#12289;&#22266;&#23450;&#24133;&#12501;&#12457;&#12531;&#12488;&#12398;&#12471;&#12455;&#12523;&#12391;&#35501;&#12415;&#26131;&#12367;&#12394;&#12426;&#12414;&#12377;&#12290;&#25968;&#20516;&#12459;&#12521;&#12512;&#12399;&#21491;&#23492;&#12379;&#12373;&#12428;&#12427;&#12398;&#12391;&#12289;&#12473;&#12506;&#12540;&#12473;&#12364;&#12459;&#12521;&#12512;&#20516;&#12398;&#21069;&#12395;&#25407;&#20837;&#12373;&#12428;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#20351;&#29992;&#12375;&#12383;&#22580;&#21512;&#12289; <code class="option">-formatDates</code> &#12434;&#25351;&#23450;&#12375;&#12383;&#12392;&#12365;&#12395;&#35201;&#32004;&#12398;&#26085;&#20184;&#12434;&#25551;&#30011;&#12377;&#12427;&#12398;&#12395;&#31354;&#30333;&#12364;&#22475;&#12417;&#36796;&#12414;&#12428;&#12394;&#12367;&#12394;&#12426;&#12414;&#12377;&#12290;</p><p>&#20986;&#21147;&#12373;&#12428;&#12427;&#34920;&#12399;&#12289; (<code class="option">-noTabs</code> &#12364;&#28961;&#12369;&#12428;&#12400;) &#12479;&#12502;&#21306;&#20999;&#12426;&#12391;&#27425;&#12395;&#31034;&#12377;&#12459;&#12521;&#12512;&#12363;&#12425;&#25104;&#12426;&#12414;&#12377; :</p><div class="table"><a name="mineBugHistoryColumns"></a><p class="title"><b>&#34920;12.4 mineBugHistory &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;</b></p><div class="table-contents"><table summary="mineBugHistory &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">&#34920;&#38988;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">seq</td><td align="left">&#12471;&#12540;&#12465;&#12531;&#12473;&#30058;&#21495; (0 &#22987;&#12414;&#12426;&#12398;&#36899;&#32154;&#12375;&#12383;&#25972;&#25968;&#20516;)</td></tr><tr><td align="left">version</td><td align="left">&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;</td></tr><tr><td align="left">time</td><td align="left">&#12522;&#12522;&#12540;&#12473;&#12373;&#12428;&#12383;&#26085;&#26178;</td></tr><tr><td align="left">classes</td><td align="left">&#20998;&#26512;&#12373;&#12428;&#12383;&#12463;&#12521;&#12473;&#25968;</td></tr><tr><td align="left">NCSS</td><td align="left">&#12467;&#12513;&#12531;&#12488;&#25991;&#12434;&#38500;&#12356;&#12383;&#21629;&#20196;&#25968; (Non Commenting Source Statements)</td></tr><tr><td align="left">added</td><td align="left">&#21069;&#22238;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12375;&#12383;&#12463;&#12521;&#12473;&#12395;&#12362;&#12369;&#12427;&#26032;&#35215;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">newCode</td><td align="left">&#21069;&#22238;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12375;&#12394;&#12363;&#12387;&#12383;&#12463;&#12521;&#12473;&#12395;&#12362;&#12369;&#12427;&#26032;&#35215;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">fixed</td><td align="left">&#29694;&#22312;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12377;&#12427;&#12463;&#12521;&#12473;&#12395;&#12362;&#12369;&#12427;&#38500;&#21435;&#12373;&#12428;&#12383;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">removed</td><td align="left">&#29694;&#22312;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12375;&#12394;&#12356;&#12463;&#12521;&#12473;&#12398;&#21069;&#22238;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12362;&#12369;&#12427;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">retained</td><td align="left">&#29694;&#22312;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12392;&#21069;&#22238;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398;&#20001;&#26041;&#12395;&#23384;&#22312;&#12377;&#12427;&#35686;&#21578;&#12398;&#25968;</td></tr><tr><td align="left">dead</td><td align="left">&#20197;&#21069;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12375;&#12383;&#12364;&#29694;&#22312;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12418;&#30452;&#21069;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12418;&#23384;&#22312;&#12375;&#12394;&#12356;&#35686;&#21578;&#12398;&#25968;</td></tr><tr><td align="left">active</td><td align="left">&#29694;&#22312;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#23384;&#22312;&#12377;&#12427;&#35686;&#21578;&#32207;&#25968;</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.5. defectDensity"><div class="titlepage"><div><div><h3 class="title"><a name="defectDensity"></a>1.5. defectDensity</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20840;&#20307;&#12362;&#12424;&#12403;&#12463;&#12521;&#12473;&#27598;&#12539;&#12497;&#12483;&#12465;&#12540;&#12472;&#27598;&#12398;&#19981;&#33391;&#23494;&#24230; (1000 NCSS &#27598;&#12398;&#35686;&#21578;&#25968;) &#12395;&#38306;&#12377;&#12427;&#24773;&#22577;&#12434;&#19968;&#35239;&#34920;&#31034;&#12391;&#12365;&#12414;&#12377;&#12290;&#27161;&#28310;&#20837;&#21147;&#12363;&#12425;&#35501;&#12415;&#36796;&#12416;&#22580;&#21512;&#12399;&#12501;&#12449;&#12452;&#12523;&#25351;&#23450;&#12394;&#12375;&#12391;&#12289;&#12381;&#12358;&#12391;&#12394;&#12369;&#12428;&#12400;&#12289;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12391;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12390;&#12289;&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;</p><p>&#20986;&#21147;&#12373;&#12428;&#12427;&#34920;&#12399;&#12289;&#27425;&#12395;&#31034;&#12377;&#12459;&#12521;&#12512;&#12363;&#12425;&#25104;&#12426;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20840;&#20307;&#24773;&#22577;&#12398;&#34892;&#12289;&#12362;&#12424;&#12403;&#12289;4 &#20491;&#20197;&#19978;&#12398;&#35686;&#21578;&#12434;&#21547;&#12435;&#12391;&#12356;&#12427;&#21508;&#12497;&#12483;&#12465;&#12540;&#12472;&#24773;&#22577;&#12414;&#12383;&#12399;&#21508;&#12463;&#12521;&#12473;&#24773;&#22577;&#12398;&#34892;&#12418;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;</p><div class="table"><a name="defectDensityColumns"></a><p class="title"><b>&#34920;12.5 defectDensity &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;</b></p><div class="table-contents"><table summary="defectDensity &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">&#34920;&#38988;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">kind</td><td align="left">&#12503;&#12525;&#12472;&#12455;&#12463;&#12488; (project)&#12289;&#12497;&#12483;&#12465;&#12540;&#12472; (package) &#12414;&#12383;&#12399;&#12463;&#12521;&#12473; (class)</td></tr><tr><td align="left">name</td><td align="left">&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12289;&#12497;&#12483;&#12465;&#12540;&#12472;&#12414;&#12383;&#12399;&#12463;&#12521;&#12473;&#12398;&#21517;&#21069;</td></tr><tr><td align="left">density</td><td align="left"> 1000 NCSS &#27598;&#12398;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">bugs</td><td align="left">&#35686;&#21578;&#25968;</td></tr><tr><td align="left">NCSS</td><td align="left">&#12467;&#12513;&#12531;&#12488;&#25991;&#12434;&#38500;&#12356;&#12383;&#21629;&#20196;&#25968; (Non Commenting Source Statements) </td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.6. convertXmlToText"><div class="titlepage"><div><div><h3 class="title"><a name="convertXmlToText"></a>1.6. convertXmlToText</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;XML &#24418;&#24335;&#12398;&#12496;&#12464;&#35686;&#21578;&#12434;&#12289; 1 &#34892; 1 &#12496;&#12464;&#12398;&#12486;&#12461;&#12473;&#12488;&#24418;&#24335;&#12289;&#12414;&#12383;&#12399;&#12289;HTML&#24418;&#24335;&#12395;&#22793;&#25563;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12371;&#12398;&#27231;&#33021;&#12399;&#12289; ant &#12363;&#12425;&#12418;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12378;&#27425;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395;&#12289;&#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12395; <span class="command"><strong>convertXmlToText</strong></span> &#12434; taskdef &#12391;&#23450;&#32681;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
50
51 &lt;taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask"&gt;
52 &lt;classpath refid="findbugs.lib" /&gt;
53 &lt;/taskdef&gt;
54
55 </pre><p>&#12371;&#12398; ant &#12479;&#12473;&#12463;&#12395;&#25351;&#23450;&#12391;&#12365;&#12427;&#23646;&#24615;&#12434;&#12289;&#19979;&#34920;&#12395;&#19968;&#35239;&#12391;&#31034;&#12375;&#12414;&#12377;&#12290;</p><div class="table"><a name="convertXmlToTextTable"></a><p class="title"><b>&#34920;12.6 convertXmlToText &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</b></p><div class="table-contents"><table summary="convertXmlToText &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</th><th align="left">Ant &#23646;&#24615;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;filename&gt;"</td><td align="left">&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;filename&gt;"</td><td align="left">&#20986;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-longBugCodes</td><td align="left">longBugCodes="[true|false]"</td><td align="left">2 &#25991;&#23383;&#12398;&#12496;&#12464;&#30053;&#31216;&#12398;&#20195;&#12431;&#12426;&#12395;&#12289;&#30465;&#30053;&#12394;&#12375;&#12398;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12467;&#12540;&#12489;&#12434;&#20351;&#29992;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">&nbsp;</td><td align="left">format="text"</td><td align="left">&#12503;&#12524;&#12540;&#12531;&#12486;&#12461;&#12473;&#12488;&#12398;&#20986;&#21147;&#12364;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;1 &#34892;&#12395;&#12388;&#12365; 1 &#12388;&#12398;&#12496;&#12464;&#12364;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#26178;&#12398;&#12487;&#12501;&#12457;&#12523;&#12488;&#12391;&#12377;&#12290;</td></tr><tr><td align="left">-html[:stylesheet]</td><td align="left">format="html:&lt;stylesheet&gt;"</td><td align="left">&#25351;&#23450;&#12373;&#12428;&#12383;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#20351;&#29992;&#12375;&#12390;&#20986;&#21147;&#12364;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377; (&#19979;&#35352;&#21442;&#29031;) &#12290;&#30465;&#30053;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289; default.xsl &#12364;&#20351;&#29992;&#12373;&#12428;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"><p>-html/format &#12458;&#12503;&#12471;&#12519;&#12531;&#12395;&#12399;&#12289;plain.xsl &#12289; default.xsl &#12289; fancy.xsl &#12289; fancy-hist.xsl &#12414;&#12383;&#12399; &#12518;&#12540;&#12470;&#33258;&#36523;&#12364;&#20316;&#25104;&#12375;&#12383; XSL &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12398;&#12356;&#12378;&#12428;&#12363;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12458;&#12503;&#12471;&#12519;&#12531;&#21517;&#12434;&#12424;&#12381;&#12395;&#12289; html &#20197;&#22806;&#12398;&#24418;&#24335;&#12434;&#20986;&#21147;&#12377;&#12427;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;FindBugs &#12395;&#21547;&#12414;&#12428;&#12390;&#12356;&#12427;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;(&#19978;&#36848;)&#20197;&#22806;&#12398;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289;&#12458;&#12503;&#12471;&#12519;&#12531; -html/format &#12391;&#24403;&#35442;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12408;&#12398;&#12497;&#12473;&#12414;&#12383;&#12399; URL &#12434;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="sect2" title="1.7. setBugDatabaseInfo"><div class="titlepage"><div><div><h3 class="title"><a name="setBugDatabaseInfo"></a>1.7. setBugDatabaseInfo</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#25351;&#23450;&#12375;&#12383;&#12496;&#12464;&#35686;&#21578;&#12395;&#12513;&#12479;&#24773;&#22577;&#12434;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12395;&#12399;&#27425;&#12395;&#31034;&#12377;&#12458;&#12503;&#12471;&#12519;&#12531;&#12364;&#12354;&#12426;&#12414;&#12377;:</p><p>&#12371;&#12398;&#27231;&#33021;&#12399;&#12289; ant &#12363;&#12425;&#12418;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12378;&#27425;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395;&#12289;&#12499;&#12523;&#12489;&#12501;&#12449;&#12452;&#12523;&#12395; <span class="command"><strong>setBugDatabaseInfo</strong></span> &#12434; taskdef &#12391;&#23450;&#32681;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
56
57 &lt;taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"&gt;
58 &lt;classpath refid="findbugs.lib" /&gt;
59 &lt;/taskdef&gt;
60
61 </pre><p>&#12371;&#12398; ant &#12479;&#12473;&#12463;&#12395;&#25351;&#23450;&#12391;&#12365;&#12427;&#23646;&#24615;&#12434;&#12289;&#19979;&#34920;&#12395;&#19968;&#35239;&#12391;&#31034;&#12375;&#12414;&#12377;&#12290;&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12377;&#12427;&#12395;&#12399;&#12289; <code class="literal">input</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12377;&#12427;&#12363;&#12289; <code class="literal">&lt;datafile&gt;</code> &#35201;&#32032;&#12434;&#20837;&#12428;&#23376;&#12395;&#12375;&#12390;&#20837;&#12428;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="programlisting">
62
63 &lt;setBugDatabaseInfo home="${findbugs.home}" ...&gt;
64 &lt;datafile name="analyze.xml"/&gt;
65 &lt;/setBugDatabaseInfo&gt;
66
67 </pre><div class="table"><a name="setBugDatabaseInfoOptions"></a><p class="title"><b>&#34920;12.7 setBugDatabaseInfo &#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</b></p><div class="table-contents"><table summary="setBugDatabaseInfo &#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</th><th align="left">Ant &#23646;&#24615;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">&#20837;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">&#20986;&#21147;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-name &lt;name&gt;</td><td align="left">name="&lt;name&gt;"</td><td align="left">&#26368;&#26032;&#12522;&#12499;&#12472;&#12519;&#12531;&#12398;&#21517;&#21069;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-timestamp &lt;when&gt;</td><td align="left">timestamp="&lt;when&gt;"</td><td align="left">&#26368;&#26032;&#12522;&#12499;&#12472;&#12519;&#12531;&#12398;&#12479;&#12452;&#12512;&#12539;&#12473;&#12479;&#12531;&#12503;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-source &lt;directory&gt;</td><td align="left">source="&lt;directory&gt;"</td><td align="left">&#12477;&#12540;&#12473;&#12434;&#26908;&#32034;&#12377;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#36861;&#21152;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-findSource &lt;directory&gt;</td><td align="left">findSource="&lt;directory&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#20869;&#12434;&#26908;&#32034;&#12375;&#12390;&#38306;&#36899;&#12377;&#12427;&#12477;&#12540;&#12473;&#12398;&#22580;&#25152;&#12434;&#36861;&#21152;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-suppress &lt;filter file&gt;</td><td align="left">suppress="&lt;filter file&gt;"</td><td align="left">&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12395;&#19968;&#33268;&#12377;&#12427;&#35686;&#21578;&#12434;&#25233;&#27490;&#12375;&#12414;&#12377; (&#20197;&#21069;&#12395;&#25351;&#23450;&#12375;&#12383;&#25233;&#27490;&#35373;&#23450;&#12399;&#32622;&#12365;&#25563;&#12360;&#12425;&#12428;&#12414;&#12377;)&#12290;</td></tr><tr><td align="left">-withMessages</td><td align="left">withMessages="[true|false]"</td><td align="left">XML&#12395;&#12486;&#12461;&#12473;&#12488;&#12513;&#12483;&#12475;&#12540;&#12472;&#12434;&#36861;&#21152;&#12375;&#12414;&#12377;&#12290;</td></tr><tr><td align="left">-resetSource</td><td align="left">resetSource="[true|false]"</td><td align="left">&#12477;&#12540;&#12473;&#26908;&#32034;&#12497;&#12473;&#12434;&#12377;&#12409;&#12390;&#21066;&#38500;&#12375;&#12414;&#12377;&#12290;</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.8. listBugDatabaseInfo"><div class="titlepage"><div><div><h3 class="title"><a name="listBugDatabaseInfo"></a>1.8. listBugDatabaseInfo</h3></div></div></div><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12398;&#23455;&#34892;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12391; 0 &#20491;&#20197;&#19978;&#12398; xml &#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12434;1&#12388;&#12418;&#25351;&#23450;&#12375;&#12394;&#12369;&#12428;&#12400;&#12289;&#27161;&#28310;&#20986;&#21147;&#12363;&#12425;&#35501;&#12415;&#36796;&#12415;&#12434;&#34892;&#12356;&#12486;&#12540;&#12502;&#12523;&#12398;&#12504;&#12483;&#12480;&#12540;&#12399;&#29983;&#25104;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;</p><p>&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12395;&#12399; 1 &#12388;&#12384;&#12369;&#12458;&#12503;&#12471;&#12519;&#12531;&#12364;&#12354;&#12426;&#12414;&#12377; : <code class="option">-formatDates</code> &#12434;&#25351;&#23450;&#12377;&#12427;&#12392;&#12486;&#12461;&#12473;&#12488;&#24418;&#24335;&#12391;&#12487;&#12540;&#12479;&#12364;&#25551;&#30011;&#12373;&#12428;&#12414;&#12377;&#12290;</p><p>&#20986;&#21147;&#12373;&#12428;&#12427;&#34920;&#12399;&#12289;&#21508;&#12496;&#12464;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12372;&#12392;&#12395;&#34892;&#12434;&#25345;&#12385;&#12289;&#27425;&#12395;&#31034;&#12377;&#12459;&#12521;&#12512;&#12363;&#12425;&#25104;&#12426;&#12414;&#12377; :</p><div class="table"><a name="listBugDatabaseInfoColumns"></a><p class="title"><b>&#34920;12.8 listBugDatabaseInfo &#12459;&#12521;&#12512;&#19968;&#35239;</b></p><div class="table-contents"><table summary="listBugDatabaseInfo &#12459;&#12521;&#12512;&#19968;&#35239;" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">&#12459;&#12521;&#12512;</th><th align="left">&#30446;&#30340;</th></tr></thead><tbody><tr><td align="left">version</td><td align="left">&#12496;&#12540;&#12472;&#12519;&#12531;&#21517;</td></tr><tr><td align="left">time</td><td align="left">&#12522;&#12522;&#12540;&#12473;&#12373;&#12428;&#12383;&#26085;&#26178;</td></tr><tr><td align="left">classes</td><td align="left">&#20998;&#26512;&#12373;&#12428;&#12383;&#12463;&#12521;&#12473;&#25968;</td></tr><tr><td align="left">NCSS</td><td align="left">&#12467;&#12513;&#12531;&#12488;&#25991;&#12434;&#38500;&#12356;&#12383;&#21629;&#20196;&#25968; (Non Commenting Source Statements)</td></tr><tr><td align="left">total</td><td align="left">&#20840;&#35686;&#21578;&#25968;</td></tr><tr><td align="left">high</td><td align="left">&#20778;&#20808;&#24230;(&#39640;)&#12398;&#35686;&#21578;&#12398;&#32207;&#25968;</td></tr><tr><td align="left">medium</td><td align="left">&#20778;&#20808;&#24230;(&#20013;)&#12398;&#35686;&#21578;&#12398;&#32207;&#25968;</td></tr><tr><td align="left">low</td><td align="left">&#20778;&#20808;&#24230;(&#20302;)&#12398;&#35686;&#21578;&#12398;&#32207;&#25968;</td></tr><tr><td align="left">filename</td><td align="left">&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#21517;</td></tr></tbody></table></div></div><br class="table-break"></div></div><div class="sect1" title="2. &#20363;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="examples"></a>2. &#20363;</h2></div></div></div><div class="sect2" title="2.1. &#25552;&#20379;&#12373;&#12428;&#12383;&#12471;&#12455;&#12523;&#12539;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12375;&#12390;&#12398;&#23653;&#27508;&#12510;&#12452;&#12491;&#12531;&#12464;"><div class="titlepage"><div><div><h3 class="title"><a name="unixscriptsexamples"></a>2.1. &#25552;&#20379;&#12373;&#12428;&#12383;&#12471;&#12455;&#12523;&#12539;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12375;&#12390;&#12398;&#23653;&#27508;&#12510;&#12452;&#12491;&#12531;&#12464;</h3></div></div></div><p>&#20197;&#19979;&#12399;&#12377;&#12409;&#12390;&#12289; jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60 &#12398;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12395;&#23550;&#12375;&#12390;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;</p><p>&#20197;&#19979;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12375;&#12390;&#12415;&#12414;&#12377; :</p><pre class="screen">
68 computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
69 </pre><p>&#12377;&#12427;&#12392;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#20986;&#21147;&#12364;&#34892;&#12431;&#12428;&#12414;&#12377; :</p><pre class="screen">
70 seq version time classes NCSS added newCode fixed removed retained dead active
71 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4
72 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4
73 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2
74 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1
75 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1
76 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1
77 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1
78 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1
79 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1
80 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1
81 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1
82 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1
83 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1
84 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1
85 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1
86 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1
87 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1
88 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2
89 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2
90 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2
91 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2
92 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2
93 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3
94 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5
95 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5
96 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5
97 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5
98 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5
99 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4
100 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4
101 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3
102 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3
103 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3
104 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4
105 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4
106 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4
107 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3
108 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3
109 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3
110 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3
111 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3
112 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3
113 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3
114 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3
115 </pre><p>&#27425;&#12395;&#31034;&#12377;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12377;&#12427;&#12392;&#12289;db.xml &#20013;&#38291;&#12501;&#12449;&#12452;&#12523;&#12434;&#29983;&#25104;&#12377;&#12427;&#12371;&#12392;&#12394;&#12367;&#30452;&#25509;&#21516;&#12376;&#24773;&#22577;&#12434;&#20316;&#25104;&#12391;&#12365;&#12414;&#12377;&#12290;</p><pre class="screen">
116 computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
117 </pre><p>&#12371;&#12398;&#24773;&#22577;&#12434;&#20351;&#12387;&#12390;&#12289; Sun JDK1.6.0 &#12398;&#21508;&#12499;&#12523;&#12489;&#12395;&#12362;&#12356;&#12390; FindBugs &#12395;&#12424;&#12387;&#12390;&#30330;&#35211;&#12373;&#12428;&#12383;&#28961;&#38480;&#20877;&#36215;&#12523;&#12540;&#12503;&#12398;&#25968;&#12434;&#34920;&#12377;&#12464;&#12521;&#12501;&#12434;&#34920;&#31034;&#12375;&#12414;&#12377;&#12290;&#38738;&#33394;&#12398;&#38936;&#22495;&#12399;&#12289;&#24403;&#35442;&#12499;&#12523;&#12489;&#12395;&#12362;&#12369;&#12427;&#28961;&#38480;&#20877;&#36215;&#12523;&#12540;&#12503;&#12398;&#25968;&#12434;&#34920;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12381;&#12398;&#19978;&#12395;&#25551;&#12363;&#12428;&#12390;&#12356;&#12427;&#36196;&#33394;&#12398;&#38936;&#22495;&#12399;&#12289;&#20197;&#21069;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12399;&#23384;&#22312;&#12375;&#12383;&#12364;&#24403;&#35442;&#12496;&#12540;&#12472;&#12519;&#12531;&#12391;&#12399;&#38500;&#21435;&#12373;&#12428;&#12383;&#28961;&#38480;&#20877;&#36215;&#12523;&#12540;&#12503;&#12398;&#25968;&#12434;&#34920;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290; (&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#36196;&#33394;&#12398;&#38936;&#22495;&#12392;&#38738;&#33394;&#12398;&#38936;&#22495;&#12434;&#36275;&#12375;&#21512;&#12431;&#12379;&#12383;&#39640;&#12373;&#12399;&#27770;&#12375;&#12390;&#28187;&#23569;&#12375;&#12394;&#12356;&#12371;&#12392;&#12364;&#20445;&#35388;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#12381;&#12375;&#12390;&#12289;&#26032;&#12383;&#12395;&#28961;&#38480;&#20877;&#36215;&#12523;&#12540;&#12503;&#12398;&#12496;&#12464;&#12364;&#25345;&#12385;&#36796;&#12414;&#12428;&#12383;&#26178;&#28857;&#12391;&#22679;&#21152;&#12375;&#12414;&#12377;) &#12290;&#36196;&#33394;&#12398;&#38936;&#22495;&#12398;&#39640;&#12373;&#12399;&#12289;&#24403;&#35442;&#12496;&#12540;&#12472;&#12519;&#12531;&#12395;&#12362;&#12356;&#12390;&#20462;&#27491;&#12414;&#12383;&#12399;&#21066;&#38500;&#12373;&#12428;&#12383;&#12496;&#12464;&#25968;&#12398;&#21512;&#35336;&#12391;&#31639;&#20986;&#12373;&#12428;&#12414;&#12377;&#12290;&#12496;&#12540;&#12472;&#12519;&#12531; 13 &#12362;&#12424;&#12403; 14 &#12395;&#12362;&#12356;&#12390;&#35211;&#12425;&#12428;&#12427;&#28187;&#23569;&#12399;&#12289; FindBugs &#12434;&#20351;&#29992;&#12375;&#12390;&#35211;&#12388;&#12363;&#12387;&#12383; JDK &#12398;&#12496;&#12464;&#12398;&#22577;&#21578;&#12434; Sun &#12364;&#21463;&#12369;&#21462;&#12387;&#12383;&#12371;&#12392;&#12395;&#12424;&#12427;&#12418;&#12398;&#12391;&#12377;&#12290;</p><div class="mediaobject"><img src="infiniteRecursiveLoops.png"></div><p>db.xml &#12501;&#12449;&#12452;&#12523;&#12399;&#12289; jdk1.6.0 &#12398;&#12377;&#12409;&#12390;&#12398;&#12499;&#12523;&#12489;&#12395;&#23550;&#12377;&#12427;&#26908;&#32034;&#32080;&#26524;&#12434;&#20445;&#25345;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#27425;&#12395;&#31034;&#12377;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#20778;&#20808;&#24230;(&#39640;)&#12414;&#12383;&#12399;&#20778;&#20808;&#24230;(&#20302;)&#12398;&#27491;&#30906;&#24615;&#12395;&#38306;&#12377;&#12427;&#35686;&#21578;&#12398;&#23653;&#27508;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377; :</p><pre class="screen">
118 filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
119 </pre><p>&#20316;&#25104;&#12373;&#12428;&#12427;&#34920;&#12398;&#20363; :</p><pre class="screen">
120 seq version time classes NCSS added newCode fixed removed retained dead active
121 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075
122 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075
123 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072
124 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072
125 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071
126 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070
127 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070
128 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069
129 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069
130 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066
131 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065
132 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065
133 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034
134 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034
135 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034
136 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035
137 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035
138 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036
139 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070
140 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070
141 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070
142 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070
143 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110
144 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253
145 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253
146 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253
147 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246
148 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246
149 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263
150 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244
151 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388
152 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388
153 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399
154 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422
155 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435
156 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433
157 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422
158 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422
159 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420
160 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397
161 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397
162 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397
163 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398
164 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398
165 44 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396
166 </pre></div><div class="sect2" title="2.2. &#22679;&#20998;&#23653;&#27508;&#12513;&#12531;&#12486;&#12490;&#12531;&#12473;"><div class="titlepage"><div><div><h3 class="title"><a name="incrementalhistory"></a>2.2. &#22679;&#20998;&#23653;&#27508;&#12513;&#12531;&#12486;&#12490;&#12531;&#12473;</h3></div></div></div><p>&#20206;&#12395;&#12289; db.xml &#12364;&#12499;&#12523;&#12489; b12 - b60 &#12395;&#23550;&#12377;&#12427; findbugs &#23455;&#34892;&#32080;&#26524;&#12434;&#20445;&#25345;&#12375;&#12390;&#12356;&#12427;&#22580;&#21512;&#12289;&#27425;&#12395;&#31034;&#12377;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; db.xml &#12395; b61 &#12395;&#23550;&#12377;&#12427;&#23455;&#34892;&#32080;&#26524;&#12434;&#36861;&#21152;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377; :</p><pre class="screen">
167 computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
168 </pre></div></div><div class="sect1" title="3. Ant &#12398;&#20363;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="antexample"></a>3. Ant &#12398;&#20363;</h2></div></div></div><p>findbugs &#12398;&#23455;&#34892;&#12392;&#12381;&#12398;&#24460;&#12398;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;&#12484;&#12540;&#12523;&#12398;&#27963;&#29992;&#12398;&#20001;&#26041;&#12434;&#23455;&#34892;&#12375;&#12390;&#12356;&#12427; ant &#12473;&#12463;&#12522;&#12503;&#12488;&#12398;&#23436;&#20840;&#12394;&#20363;&#12434;&#20197;&#19979;&#12395;&#31034;&#12375;&#12414;&#12377; :</p><pre class="screen">
169
170 &lt;project name="analyze_asm_util" default="findbugs"&gt;
171 &lt;!-- findbugs &#12479;&#12473;&#12463;&#23450;&#32681; --&gt;
172 &lt;property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" /&gt;
173 &lt;property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" /&gt;
174
175 &lt;path id="findbugs.lib"&gt;
176 &lt;fileset dir="${findbugs.home}/lib"&gt;
177 &lt;include name="findbugs-ant.jar"/&gt;
178 &lt;/fileset&gt;
179 &lt;/path&gt;
180
181 &lt;taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"&gt;
182 &lt;classpath refid="findbugs.lib" /&gt;
183 &lt;/taskdef&gt;
184
185 &lt;taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"&gt;
186 &lt;classpath refid="findbugs.lib" /&gt;
187 &lt;/taskdef&gt;
188
189 &lt;taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"&gt;
190 &lt;classpath refid="findbugs.lib" /&gt;
191 &lt;/taskdef&gt;
192
193 &lt;taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"&gt;
194 &lt;classpath refid="findbugs.lib" /&gt;
195 &lt;/taskdef&gt;
196
197 &lt;!-- findbugs &#12479;&#12473;&#12463;&#23450;&#32681; --&gt;
198 &lt;target name="findbugs"&gt;
199 &lt;antcall target="analyze" /&gt;
200 &lt;antcall target="mine" /&gt;
201 &lt;/target&gt;
202
203 &lt;!-- &#20998;&#26512;&#12434;&#34892;&#12358;&#12479;&#12473;&#12463;--&gt;
204 &lt;target name="analyze"&gt;
205 &lt;!-- asm-util &#12395;&#23550;&#12375;&#12390; findbugs &#12434;&#23455;&#34892;&#12377;&#12427; --&gt;
206 &lt;findbugs home="${findbugs.home}"
207 output="xml:withMessages"
208 timeout="90000000"
209 reportLevel="experimental"
210 workHard="true"
211 effort="max"
212 adjustExperimental="true"
213 jvmargs="${jvmargs}"
214 failOnError="true"
215 outputFile="out.xml"
216 projectName="Findbugs"
217 debug="false"&gt;
218 &lt;class location="asm-util-3.0.jar" /&gt;
219 &lt;/findbugs&gt;
220 &lt;/target&gt;
221
222 &lt;target name="mine"&gt;
223
224 &lt;!-- &#26368;&#26032;&#12398;&#20998;&#26512;&#32080;&#26524;&#12395;&#24773;&#22577;&#12434;&#35373;&#23450;&#12377;&#12427; --&gt;
225 &lt;setBugDatabaseInfo home="${findbugs.home}"
226 withMessages="true"
227 name="asm-util-3.0.jar"
228 input="out.xml"
229 output="out-rel.xml"/&gt;
230
231 &lt;!-- &#23653;&#27508;&#12501;&#12449;&#12452;&#12523; (out-hist.xml) &#12364;&#26082;&#12395;&#23384;&#22312;&#12377;&#12427;&#12363;&#12393;&#12358;&#12363;&#12434;&#30906;&#35469;&#12377;&#12427; --&gt;
232 &lt;condition property="mining.historyfile.available"&gt;
233 &lt;available file="out-hist.xml"/&gt;
234 &lt;/condition&gt;
235 &lt;condition property="mining.historyfile.notavailable"&gt;
236 &lt;not&gt;
237 &lt;available file="out-hist.xml"/&gt;
238 &lt;/not&gt;
239 &lt;/condition&gt;
240
241 &lt;!-- &#12371;&#12398;&#12479;&#12540;&#12466;&#12483;&#12488;&#12399;&#12289;&#23653;&#27508;&#12501;&#12449;&#12452;&#12523;&#12364;&#23384;&#22312;&#12375;&#12394;&#12356;&#12392;&#12365; (&#21021;&#22238;) &#12384;&#12369;&#23455;&#34892;&#12373;&#12428;&#12414;&#12377; --&gt;
242 &lt;antcall target="history-init"&gt;
243 &lt;param name="data.file" value="out-rel.xml" /&gt;
244 &lt;param name="hist.file" value="out-hist.xml" /&gt;
245 &lt;/antcall&gt;
246 &lt;!-- &#19978;&#35352;&#20197;&#22806;&#12398;&#22580;&#21512;&#12395;&#23455;&#34892;&#12373;&#12428;&#12414;&#12377; --&gt;
247 &lt;antcall target="history"&gt;
248 &lt;param name="data.file" value="out-rel.xml" /&gt;
249 &lt;param name="hist.file" value="out-hist.xml" /&gt;
250 &lt;param name="hist.summary.file" value="out-hist.txt" /&gt;
251 &lt;/antcall&gt;
252 &lt;/target&gt;
253
254 &lt;!-- &#23653;&#27508;&#12501;&#12449;&#12452;&#12523;&#12434;&#21021;&#26399;&#21270;&#12375;&#12414;&#12377; --&gt;
255 &lt;target name="history-init" if="mining.historyfile.notavailable"&gt;
256 &lt;copy file="${data.file}" tofile="${hist.file}" /&gt;
257 &lt;/target&gt;
258
259 &lt;!-- &#12496;&#12464;&#23653;&#27508;&#12434;&#31639;&#20986;&#12375;&#12414;&#12377; --&gt;
260 &lt;target name="history" if="mining.historyfile.available"&gt;
261 &lt;!-- ${data.file} &#12434; ${hist.file} &#12395;&#12510;&#12540;&#12472;&#12375;&#12414;&#12377; --&gt;
262 &lt;computeBugHistory home="${findbugs.home}"
263 withMessages="true"
264 output="${hist.file}"&gt;
265 &lt;dataFile name="${hist.file}"/&gt;
266 &lt;dataFile name="${data.file}"/&gt;
267 &lt;/computeBugHistory&gt;
268
269 &lt;!-- &#23653;&#27508;&#12434;&#31639;&#20986;&#12375;&#12390; ${hist.summary.file} &#12395;&#20986;&#21147;&#12375;&#12414;&#12377; --&gt;
270 &lt;mineBugHistory home="${findbugs.home}"
271 formatDates="true"
272 noTabs="true"
273 input="${hist.file}"
274 output="${hist.summary.file}"/&gt;
275 &lt;/target&gt;
276
277 &lt;/project&gt;
278
279 </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="rejarForAnalysis.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="license.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;7&#31456; FindBugs&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="anttask.html" title="&#31532;6&#31456; FindBugs&#8482; Ant &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;"><link rel="next" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;7&#31456; <span class="application">FindBugs</span>&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="filter.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;7&#31456; FindBugs&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>&#31532;7&#31456; <span class="application">FindBugs</span>&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="eclipse.html#d0e1604">1. &#24517;&#35201;&#26465;&#20214;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1611">2. &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1658">3. &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1681">4. &#12488;&#12521;&#12502;&#12523;&#12471;&#12517;&#12540;&#12486;&#12451;&#12531;&#12464;</a></span></dt></dl></div><p>FindBugs Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12395;&#12424;&#12387;&#12390;&#12289; <span class="application">FindBugs</span> &#12434; <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE &#12391;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#12424;&#12358;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;FindBugs Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12399;&#12289; Peter Friese &#27663;&#12398;&#22810;&#22823;&#12394;&#36002;&#29486;&#12395;&#12424;&#12427;&#12418;&#12398;&#12391;&#12377;&#12290;Phil Crosby &#27663; &#12392; Andrei Loskutov &#27663;&#12399;&#12289;&#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#37325;&#35201;&#12394;&#25913;&#33391;&#12395;&#36002;&#29486;&#12375;&#12414;&#12375;&#12383;&#12290;</p><div class="sect1" title="1. &#24517;&#35201;&#26465;&#20214;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1604"></a>1. &#24517;&#35201;&#26465;&#20214;</h2></div></div></div><p><span class="application">FindBugs</span> Eclipse Plugin &#12434;&#20351;&#29992;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289; Eclipse 3.3 &#12354;&#12427;&#12356;&#12399;&#12381;&#12428;&#20197;&#38477;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12289;&#12414;&#12383;&#12289; JRE/JDK 1.5 &#12354;&#12427;&#12356;&#12399;&#12381;&#12428;&#20197;&#38477;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12364;&#24517;&#35201;&#12391;&#12377;&#12290;</p></div><div class="sect1" title="2. &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1611"></a>2. &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</h2></div></div></div><p>&#26356;&#26032;&#12469;&#12452;&#12488;&#12364;&#25552;&#20379;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#26356;&#26032;&#12469;&#12452;&#12488;&#12434;&#21033;&#29992;&#12375;&#12390;&#12289;&#27231;&#26800;&#30340;&#12395; FindBugs &#12434; Eclipse &#12395;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12383;&#33258;&#21205;&#30340;&#12395;&#12289;&#26368;&#26032;&#29256;&#12398;&#12450;&#12483;&#12503;&#12487;&#12540;&#12488;&#12434;&#29031;&#20250;&#12375;&#12390;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;&#20869;&#23481;&#12398;&#30064;&#12394;&#12427; 3 &#12388;&#12398;&#26356;&#26032;&#12469;&#12452;&#12488;&#12364;&#23384;&#22312;&#12375;&#12414;&#12377;&#12290;</p><div class="variablelist" title="FindBugs Eclipse &#26356;&#26032;&#12469;&#12452;&#12488;&#19968;&#35239;"><p class="title"><b>FindBugs Eclipse &#26356;&#26032;&#12469;&#12452;&#12488;&#19968;&#35239;</b></p><dl><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p>FindBugs &#12398;&#20844;&#24335;&#12522;&#12522;&#12540;&#12473;&#29289;&#12434;&#25552;&#20379;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-candidate/" target="_top">http://findbugs.cs.umd.edu/eclips-candidate/</a></span></dt><dd><p>FindBugs&#12398;&#20844;&#24335;&#12522;&#12522;&#12540;&#12473;&#29289;&#12395;&#21152;&#12360;&#12390;&#12289;&#20844;&#24335;&#12522;&#12522;&#12540;&#12473;&#20505;&#35036;&#29256;&#12434;&#25552;&#20379;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily/</a></span></dt><dd><p>FindBugs&#12398;&#26085;&#27425;&#12499;&#12523;&#12489;&#29289;&#12434;&#25552;&#20379;&#12375;&#12414;&#12377;&#12290;&#12467;&#12531;&#12497;&#12452;&#12523;&#12364;&#12391;&#12365;&#12427;&#12371;&#12392;&#20197;&#19978;&#12398;&#12486;&#12473;&#12488;&#12399;&#34892;&#12431;&#12428;&#12390;&#12356;&#12414;&#12379;&#12435;&#12290;</p></dd></dl></div><p>&#12414;&#12383;&#12289;&#27425;&#12395;&#31034;&#12377;&#12522;&#12531;&#12463;&#12363;&#12425;&#25163;&#21205;&#12391;&#12503;&#12521;&#12464;&#12452;&#12531;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377; : <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download" target="_top">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</a>. &#23637;&#38283;&#12375;&#12390; Eclipse &#12398;&#12300;plugins&#12301;&#12469;&#12502;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#20837;&#12428;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;(&#12381;&#12358;&#12377;&#12427;&#12392;&#12289; &lt;eclipse &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540; &gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png &#12364; <span class="application">FindBugs</span> &#12398;&#12525;&#12468;&#12501;&#12449;&#12452;&#12523;&#12408;&#12398;&#12497;&#12473;&#12395;&#12394;&#12427;&#12399;&#12378;&#12391;&#12377;&#12290;)</p><p>&#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#23637;&#38283;&#12364;&#12391;&#12365;&#12383;&#12425;&#12289; Eclipse &#12434;&#36215;&#21205;&#12375;&#12390; <span class="guimenu">Help</span> &#8594; <span class="guimenuitem">About Eclipse Platform</span> &#8594; <span class="guimenuitem">Plug-in Details</span> &#12434;&#36984;&#25246;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12300;FindBugs Project&#12301;&#12363;&#12425;&#25552;&#20379;&#12373;&#12428;&#12383;&#12300;FindBugs Plug-in&#12301;&#12392;&#12356;&#12358;&#12503;&#12521;&#12464;&#12452;&#12531;&#12364;&#12354;&#12427;&#12371;&#12392;&#12434;&#30906;&#35469;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="sect1" title="3. &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1658"></a>3. &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</h2></div></div></div><p>&#23455;&#34892;&#12377;&#12427;&#12395;&#12399;&#12289; Java &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#19978;&#12391;&#21491;&#12463;&#12522;&#12483;&#12463;&#12375;&#12390;&#12300;Find Bugs&#12301;&#12434;&#36984;&#25246;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12364;&#23455;&#34892;&#12373;&#12428;&#12390;&#12289;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12398;&#23455;&#20363;&#12398;&#21487;&#33021;&#24615;&#12364;&#12354;&#12427;&#12392;&#35672;&#21029;&#12373;&#12428;&#12383;&#12467;&#12540;&#12489;&#31623;&#25152;&#12395;&#21839;&#38988;&#12510;&#12540;&#12459;&#12540;&#12364;&#12388;&#12365;&#12414;&#12377;&#12290; (&#12477;&#12540;&#12473;&#30011;&#38754;&#12362;&#12424;&#12403; Eclipse &#21839;&#38988;&#12499;&#12517;&#12540;&#12395;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;)</p><p>Java &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12480;&#12452;&#12450;&#12525;&#12464;&#12434;&#38283;&#12356;&#12390;&#12300;Findbugs&#12301;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12506;&#12540;&#12472;&#12434;&#36984;&#25246;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; <span class="application">FindBugs</span> &#12398;&#21205;&#20316;&#12434;&#12459;&#12473;&#12479;&#12510;&#12452;&#12474;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#36984;&#25246;&#12391;&#12365;&#12427;&#38917;&#30446;&#12395;&#12399;&#27425;&#12398;&#12424;&#12358;&#12394;&#12418;&#12398;&#12364;&#12354;&#12426;&#12414;&#12377; :</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>&#12300;Run FindBugs Automatically&#12301;&#12481;&#12455;&#12483;&#12463;&#12508;&#12483;&#12463;&#12473;&#12398;&#35373;&#23450;&#12290;&#12481;&#12455;&#12483;&#12463;&#12377;&#12427;&#12392;&#12289;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20869;&#12398; Java &#12463;&#12521;&#12473;&#12364;&#20462;&#27491;&#12373;&#12428;&#12427;&#12383;&#12403;&#12395; FindBugs &#12364;&#23455;&#34892;&#12373;&#12428;&#12414;&#12377;&#12290;</p></li><li class="listitem"><p>&#20778;&#20808;&#24230;&#12392;&#12496;&#12464;&#12459;&#12486;&#12468;&#12522;&#12540;&#12398;&#36984;&#25246;&#12290;&#12371;&#12428;&#12425;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289;&#12393;&#12398;&#35686;&#21578;&#12434;&#34920;&#31034;&#12377;&#12427;&#12363;&#12434;&#36984;&#25246;&#12375;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#20778;&#20808;&#24230;&#12391; &#12300;Medium&#12301; &#12434;&#36984;&#25246;&#12377;&#12427;&#12392;&#12289;&#20778;&#20808;&#24230; (&#20013;) &#12362;&#12424;&#12403;&#20778;&#20808;&#24230; (&#39640;) &#12398;&#35686;&#21578;&#12398;&#12415;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#21516;&#27096;&#12395;&#12289;&#12300;Style&#12301;&#12481;&#12455;&#12483;&#12463;&#12508;&#12483;&#12463;&#12473;&#12398;&#12481;&#12455;&#12483;&#12463;&#12510;&#12540;&#12463;&#12434;&#22806;&#12377;&#12392;&#12289;Style &#12459;&#12486;&#12468;&#12522;&#12540;&#12395;&#23646;&#12377;&#12427;&#35686;&#21578;&#12399;&#34920;&#31034;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;</p></li><li class="listitem"><p>&#12487;&#12451;&#12486;&#12463;&#12479;&#12398;&#36984;&#25246;&#12290;&#34920;&#12363;&#12425;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12391;&#26377;&#21177;&#12395;&#12375;&#12383;&#12356;&#12487;&#12451;&#12486;&#12463;&#12479;&#12434;&#36984;&#25246;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></li></ul></div></div><div class="sect1" title="4. &#12488;&#12521;&#12502;&#12523;&#12471;&#12517;&#12540;&#12486;&#12451;&#12531;&#12464;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1681"></a>4. &#12488;&#12521;&#12502;&#12523;&#12471;&#12517;&#12540;&#12486;&#12451;&#12531;&#12464;</h2></div></div></div><p><span class="application">FindBugs</span> Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12399;&#12289;&#12414;&#12384;&#23455;&#39443;&#27573;&#38542;&#12391;&#12377;&#12290;&#12371;&#12398;&#12475;&#12463;&#12471;&#12519;&#12531;&#12391;&#12399;&#12289;&#12503;&#12521;&#12464;&#12452;&#12531;&#12395;&#38306;&#12377;&#12427;&#19968;&#33324;&#30340;&#12394;&#21839;&#38988;&#12392; (&#21028;&#26126;&#12375;&#12390;&#12356;&#12428;&#12400;) &#12381;&#12428;&#12425;&#12398;&#21839;&#38988;&#12398;&#35299;&#27770;&#26041;&#27861;&#12434;&#35352;&#36848;&#12375;&#12414;&#12377;&#12290;</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><span class="application">FindBugs</span> &#21839;&#38988;&#12510;&#12540;&#12459;&#12540;&#12364; (&#12477;&#12540;&#12473;&#30011;&#38754;&#12362;&#12424;&#12403;&#21839;&#38988;&#12499;&#12517;&#12540;&#12395;) &#34920;&#31034;&#12373;&#12428;&#12394;&#12356;&#22580;&#21512;&#12399;&#12289;&#21839;&#38988;&#12499;&#12517;&#12540;&#12398;&#12501;&#12451;&#12523;&#12479;&#12540;&#35373;&#23450;&#12434;&#22793;&#26356;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#35443;&#32048;&#24773;&#22577;&#12399; <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="anttask.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="filter.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;6&#31456; <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</td></tr></table></div></body></html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="eclipse.html" title="&#31532;7&#31456; FindBugs&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;"><link rel="next" href="analysisprops.html" title="&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="eclipse.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="analysisprops.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;"><div class="titlepage"><div><div><h2 class="title"><a name="filter"></a>&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="filter.html#d0e1709">1. &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12398;&#27010;&#35201;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1759">2. &#12510;&#12483;&#12481;&#12531;&#12464;&#26465;&#20214;&#12398;&#31278;&#39006;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1958">3. Java &#35201;&#32032;&#21517;&#12510;&#12483;&#12481;&#12531;&#12464;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1982">4. &#30041;&#24847;&#20107;&#38917;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2012">5. &#20363;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2065">6. &#23436;&#20840;&#12394;&#20363;</a></span></dt></dl></div><p>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#29305;&#23450;&#12398;&#12463;&#12521;&#12473;&#12420;&#12513;&#12477;&#12483;&#12489;&#12434;&#12496;&#12464;&#22577;&#21578;&#12395;&#21547;&#12417;&#12383;&#12426;&#12496;&#12464;&#22577;&#21578;&#12363;&#12425;&#38500;&#22806;&#12375;&#12383;&#12426;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12371;&#12398;&#31456;&#12391;&#12399;&#12289;&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12398;&#20351;&#29992;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><div class="note" title="&#35336;&#30011;&#12373;&#12428;&#12390;&#12356;&#12427;&#27231;&#33021;" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: &#35336;&#30011;&#12373;&#12428;&#12390;&#12356;&#12427;&#27231;&#33021;"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[&#27880;&#35352;]" src="note.png"></td><th align="left">&#35336;&#30011;&#12373;&#12428;&#12390;&#12356;&#12427;&#27231;&#33021;</th></tr><tr><td align="left" valign="top"><p>&#12501;&#12451;&#12523;&#12479;&#12540;&#12399;&#29694;&#22312;&#12289;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12391;&#12398;&#12415;&#12469;&#12509;&#12540;&#12488;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#26368;&#32066;&#30340;&#12395;&#12399;&#12289;&#12501;&#12451;&#12523;&#12479;&#12540;&#12398;&#12469;&#12509;&#12540;&#12488;&#12399; GUI &#12395;&#12418;&#36861;&#21152;&#12373;&#12428;&#12427;&#20104;&#23450;&#12391;&#12377;&#12290;</p></td></tr></table></div><p>
3 </p><div class="sect1" title="1. &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12398;&#27010;&#35201;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1709"></a>1. &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12398;&#27010;&#35201;</h2></div></div></div><p>&#27010;&#24565;&#30340;&#12395;&#35328;&#12360;&#12400;&#12289;&#12501;&#12451;&#12523;&#12479;&#12540;&#12399;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#12354;&#12427;&#22522;&#28310;&#12392;&#29031;&#21512;&#12375;&#12414;&#12377;&#12290;&#12501;&#12451;&#12523;&#12479;&#12540;&#12434;&#23450;&#32681;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289; &#29305;&#21029;&#12394;&#21462;&#12426;&#25201;&#12356;&#12434;&#12377;&#12427;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#36984;&#25246;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#12354;&#12427;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#12496;&#12464;&#22577;&#21578;&#12395;&#21547;&#12417;&#12383;&#12426;&#12289;&#12496;&#12464;&#22577;&#21578;&#12363;&#12425;&#38500;&#22806;&#12375;&#12383;&#12426;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><p>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289; <a class="ulink" href="http://www.w3.org/XML/" target="_top">XML</a> &#25991;&#26360;&#12391;&#12377;&#12290;&#26368;&#19978;&#20301;&#35201;&#32032;&#12364;&#12288;<code class="literal">FindBugsFilter</code> &#35201;&#32032; &#12391;&#12354;&#12426;&#12289;&#12381;&#12398;&#23376;&#35201;&#32032;&#12392;&#12375;&#12390; <code class="literal">Match</code> &#35201;&#32032;&#12434;&#35079;&#25968;&#20491;&#23450;&#32681;&#12375;&#12414;&#12377;&#12290;&#12381;&#12428;&#12382;&#12428;&#12398; <code class="literal">Match</code> &#35201;&#32032;&#12399;&#12289;&#29983;&#25104;&#12373;&#12428;&#12383;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12395;&#36969;&#29992;&#12373;&#12428;&#12427;&#36848;&#37096;&#12395;&#12354;&#12383;&#12426;&#12414;&#12377;&#12290;&#36890;&#24120;&#12289;&#12501;&#12451;&#12523;&#12479;&#12540;&#12399;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#38500;&#22806;&#12377;&#12427;&#12383;&#12417;&#12395;&#20351;&#29992;&#12375;&#12414;&#12377;&#12290;&#27425;&#12395;&#12289;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;:</p><pre class="screen">
4 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -exclude <em class="replaceable"><code>myExcludeFilter.xml</code></em> <em class="replaceable"><code>myApp.jar</code></em></strong></span>
5 </pre><p>&#12414;&#12383;&#19968;&#26041;&#12391;&#12289;&#30340;&#12434;&#12375;&#12412;&#12387;&#12383;&#22577;&#21578;&#12434;&#24471;&#12427;&#12383;&#12417;&#12395;&#12496;&#12464;&#22577;&#21578;&#32080;&#26524;&#12434;&#36984;&#25246;&#12377;&#12427;&#12383;&#12417;&#12395;&#12501;&#12451;&#12523;&#12479;&#12540;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12418;&#32771;&#12360;&#12425;&#12428;&#12414;&#12377; :</p><pre class="screen">
6 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -include <em class="replaceable"><code>myIncludeFilter.xml</code></em> <em class="replaceable"><code>myApp.jar</code></em></strong></span>
7 </pre><p>
8 </p><p>
9 <code class="literal">Match</code> &#35201;&#32032;&#12399;&#23376;&#35201;&#32032;&#12434;&#25345;&#12385;&#12414;&#12377;&#12290;&#12381;&#12428;&#12425;&#12398;&#23376;&#35201;&#32032;&#12399;&#35542;&#29702;&#31309;&#12391;&#36848;&#37096;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12388;&#12414;&#12426;&#12289;&#36848;&#37096;&#12364;&#30495;&#12391;&#12354;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289;&#12377;&#12409;&#12390;&#12398;&#23376;&#35201;&#32032;&#12364;&#30495;&#12391;&#12354;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="2. &#12510;&#12483;&#12481;&#12531;&#12464;&#26465;&#20214;&#12398;&#31278;&#39006;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1759"></a>2. &#12510;&#12483;&#12481;&#12531;&#12464;&#26465;&#20214;&#12398;&#31278;&#39006;</h2></div></div></div><div class="variablelist"><dl><dt><span class="term"><code class="literal">&lt;Bug&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12434;&#25351;&#23450;&#12375;&#12390;&#29031;&#21512;&#12375;&#12414;&#12377;&#12290;<code class="literal">pattern</code> &#23646;&#24615;&#12395;&#12399;&#12289;&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12391;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#39006;&#22411;&#12398;&#12522;&#12473;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12393;&#12398;&#35686;&#21578;&#12364;&#12393;&#12398;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#39006;&#22411;&#12395;&#12354;&#12383;&#12427;&#12363;&#12399;&#12289; <span class="command"><strong>-xml</strong></span> &#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#12388;&#12363;&#12387;&#12390;&#20986;&#21147;&#12373;&#12428;&#12383;&#12418;&#12398; (<code class="literal">BugInstance</code> &#35201;&#32032;&#12398; <code class="literal">type</code> &#23646;&#24615;) &#12434;&#35211;&#12427;&#12363;&#12289;&#12414;&#12383;&#12399;&#12289; <a class="ulink" href="../../bugDescriptions.html" target="_top">&#12496;&#12464;&#35299;&#35500;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;</a>&#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p>&#12418;&#12387;&#12392;&#31890;&#24230;&#12398;&#31895;&#12356;&#29031;&#21512;&#12434;&#34892;&#12356;&#12383;&#12356;&#12392;&#12365;&#12399;&#12289; <code class="literal">code</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12496;&#12464;&#30053;&#31216;&#12398;&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12398;&#12522;&#12473;&#12488;&#12391;&#25351;&#23450;&#12391;&#12365;&#12414;&#12377;&#12290;&#12373;&#12425;&#12395;&#31890;&#24230;&#12398;&#31895;&#12356;&#29031;&#21512;&#12434;&#34892;&#12356;&#12383;&#12356;&#12392;&#12365;&#12399;&#12289; <code class="literal">category</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#27425;&#12395;&#31034;&#12377;&#12289;&#12496;&#12464;&#12459;&#12486;&#12468;&#12522;&#12540;&#21517;&#12398;&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12398;&#12522;&#12473;&#12488;&#12391;&#25351;&#23450;&#12391;&#12365;&#12414;&#12377; : <code class="literal">CORRECTNESS</code>, <code class="literal">MT_CORRECTNESS</code>, <code class="literal">BAD_PRACTICICE</code>, <code class="literal">PERFORMANCE</code>, <code class="literal">STYLE</code>.</p><p>&#21516;&#12376; <code class="literal">&lt;Bug&gt;</code> &#35201;&#32032;&#12395;&#19978;&#35352;&#12398;&#23646;&#24615;&#12434;&#35079;&#25968;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#21517;&#12289;&#12496;&#12464;&#30053;&#31216;&#12289;&#12496;&#12464;&#12459;&#12486;&#12468;&#12522;&#12540;&#12398;&#12356;&#12378;&#12428;&#12363;1&#12388;&#12391;&#12418;&#35442;&#24403;&#12377;&#12428;&#12400;&#12289;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12399;&#21512;&#33268;&#12377;&#12427;&#12392;&#21028;&#23450;&#12373;&#12428;&#12414;&#12377;&#12290;</p><p>&#19979;&#20301;&#20114;&#25563;&#24615;&#12434;&#25345;&#12383;&#12379;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289; <code class="literal">&lt;Bug&gt;</code> &#35201;&#32032;&#12398;&#20195;&#12431;&#12426;&#12395; <code class="literal">&lt;BugPattern&gt;</code> &#35201;&#32032;&#12362;&#12424;&#12403; <code class="literal">&lt;BugCode&gt;</code> &#35201;&#32032;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12371;&#12428;&#12425;&#12398;&#35201;&#32032;&#12399;&#12381;&#12428;&#12382;&#12428;&#12289; <code class="literal">name</code> &#23646;&#24615;&#12391;&#20516;&#12398;&#12522;&#12473;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12398;&#35201;&#32032;&#12399;&#12289;&#23558;&#26469;&#12469;&#12509;&#12540;&#12488;&#12373;&#12428;&#12394;&#12367;&#12394;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Priority&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#29305;&#23450;&#12398;&#20778;&#20808;&#24230;&#12434;&#12418;&#12388;&#35686;&#21578;&#12434;&#29031;&#21512;&#12375;&#12414;&#12377;&#12290;<code class="literal">value</code> &#23646;&#24615;&#12395;&#12399;&#12289;&#25972;&#25968;&#20516;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; : 1 &#12399;&#20778;&#20808;&#24230;(&#39640;)&#12289;&#12414;&#12383;&#12289; 2 &#12399;&#20778;&#20808;&#24230;(&#20013;) &#12289; 3 &#12399;&#20778;&#20808;&#24230;(&#20302;) &#12434;&#31034;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Package&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289; <code class="literal">name</code> &#23646;&#24615;&#12391;&#25351;&#23450;&#12375;&#12383;&#29305;&#23450;&#12398;&#12497;&#12483;&#12465;&#12540;&#12472;&#20869;&#12395;&#12354;&#12427;&#12463;&#12521;&#12473;&#12395;&#38306;&#36899;&#12375;&#12383;&#35686;&#21578;&#12434;&#29031;&#21512;&#12375;&#12414;&#12377;&#12290;&#20837;&#12428;&#23376;&#12398;&#12497;&#12483;&#12465;&#12540;&#12472;&#12399;&#21547;&#12414;&#12428;&#12414;&#12379;&#12435; (Java import &#25991;&#12395;&#24467;&#12387;&#12390;&#12356;&#12414;&#12377;) &#12290;&#12375;&#12363;&#12375;&#12394;&#12364;&#12425;&#12289;&#27491;&#35215;&#34920;&#29694;&#12434;&#20351;&#12358;&#12392;&#35079;&#25968;&#12497;&#12483;&#12465;&#12540;&#12472;&#12395;&#12510;&#12483;&#12481;&#12373;&#12379;&#12427;&#12371;&#12392;&#12399;&#31777;&#21336;&#12395;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Class&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#29305;&#23450;&#12398;&#12463;&#12521;&#12473;&#12395;&#38306;&#36899;&#12375;&#12383;&#35686;&#21578;&#12434;&#29031;&#21512;&#12375;&#12414;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#29031;&#21512;&#12377;&#12427;&#12463;&#12521;&#12473;&#21517;&#12434;&#12463;&#12521;&#12473;&#21517;&#12381;&#12398;&#12418;&#12398;&#12363;&#12289;&#12414;&#12383;&#12399;&#12289;&#27491;&#35215;&#34920;&#29694;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p><p>&#19979;&#20301;&#20114;&#25563;&#24615;&#12434;&#25345;&#12383;&#12379;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289;&#12371;&#12398;&#35201;&#32032;&#12398;&#20195;&#12431;&#12426;&#12395; <code class="literal">Match</code> &#35201;&#32032;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12463;&#12521;&#12473;&#21517;&#12381;&#12398;&#12418;&#12398;&#12398;&#25351;&#23450;&#12399; <code class="literal">class</code> &#23646;&#24615;&#12434;&#12289;&#12463;&#12521;&#12473;&#21517;&#12434;&#27491;&#35215;&#34920;&#29694;&#12391;&#25351;&#23450;&#12377;&#12427;&#22580;&#21512;&#12399; <code class="literal">classregex</code> &#23646;&#24615;&#12434;&#12381;&#12428;&#12382;&#12428;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;</p><p>&#12418;&#12375; <code class="literal">Match</code> &#35201;&#32032;&#12395; <code class="literal">Class</code> &#35201;&#32032;&#12364;&#28961;&#12363;&#12387;&#12383;&#12426;&#12289; <code class="literal">class</code> / <code class="literal">classregex</code> &#23646;&#24615;&#12364;&#28961;&#12363;&#12387;&#12383;&#12426;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289;&#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12395;&#36969;&#29992;&#12373;&#12428;&#12414;&#12377;&#12290;&#12381;&#12398;&#22580;&#21512;&#12289;&#24819;&#23450;&#22806;&#12395;&#22810;&#12367;&#12398;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12364;&#19968;&#33268;&#12375;&#12390;&#12375;&#12414;&#12358;&#12371;&#12392;&#12364;&#12354;&#12426;&#24471;&#12414;&#12377;&#12290;&#12381;&#12398;&#22580;&#21512;&#12399;&#12289;&#36969;&#24403;&#12394;&#12513;&#12477;&#12483;&#12489;&#12420;&#12501;&#12451;&#12540;&#12523;&#12489;&#12391;&#32094;&#12426;&#36796;&#12435;&#12391;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Method&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#12513;&#12477;&#12483;&#12489;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#29031;&#21512;&#12377;&#12427;&#12513;&#12477;&#12483;&#12489;&#21517;&#12434;&#12513;&#12477;&#12483;&#12489;&#21517;&#12381;&#12398;&#12418;&#12398;&#12363;&#12289;&#12414;&#12383;&#12399;&#12289;&#27491;&#35215;&#34920;&#29694;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">params</code> &#23646;&#24615;&#12395;&#12399;&#12289;&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12391;&#12513;&#12477;&#12483;&#12489;&#24341;&#25968;&#12398;&#22411;&#12398;&#12522;&#12473;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">returns</code> &#23646;&#24615;&#12395;&#12399;&#12513;&#12477;&#12483;&#12489;&#12398;&#25147;&#12426;&#20516;&#12398;&#22411;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">params</code> &#12362;&#12424;&#12403; <code class="literal">returns</code> &#12395;&#12362;&#12356;&#12390;&#12399;&#12289;&#12463;&#12521;&#12473;&#21517;&#12399;&#23436;&#20840;&#20462;&#39166;&#21517;&#12391;&#12354;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;(&#20363;&#12360;&#12400;&#12289;&#21336;&#12395; "String" &#12391;&#12399;&#12394;&#12367; "java.lang.String" &#12392;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;) <code class="literal">params</code> <code class="literal">returns</code> &#12398;&#12393;&#12385;&#12425;&#12363;&#19968;&#26041;&#12434;&#25351;&#23450;&#12375;&#12383;&#22580;&#21512;&#12399;&#12289;&#12418;&#12358;&#19968;&#26041;&#12398;&#23646;&#24615;&#12398;&#25351;&#23450;&#12418;&#24517;&#38920;&#12391;&#12377;&#12290;&#12394;&#12380;&#12394;&#12425;&#12400;&#12289;&#12513;&#12477;&#12483;&#12489;&#12471;&#12464;&#12491;&#12481;&#12515;&#12540;&#12434;&#27083;&#31689;&#12398;&#12383;&#12417;&#12395;&#24517;&#35201;&#12384;&#12363;&#12425;&#12391;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12289;<code class="literal">params</code> &#23646;&#24615; &#12362;&#12424;&#12403; <code class="literal">returns</code> &#23646;&#24615;&#12414;&#12383;&#12399; 3 &#12388;&#12398; &#23646;&#24615;&#12377;&#12409;&#12390;&#12289;&#12398;&#12393;&#12428;&#12363;&#12434;&#26465;&#20214;&#12392;&#12377;&#12427;&#12371;&#12392;&#12391;&#12365;&#12427;&#12371;&#12392;&#12434;&#24847;&#21619;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12371;&#12398;&#12424;&#12358;&#12395;&#12289;&#21517;&#21069;&#12392;&#12471;&#12464;&#12491;&#12481;&#12515;&#12540;&#12395;&#22522;&#12389;&#12367;&#27096;&#12293;&#12394;&#31278;&#39006;&#12398;&#26465;&#20214;&#12434;&#35215;&#23450;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Field&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#12501;&#12451;&#12540;&#12523;&#12489;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#29031;&#21512;&#12377;&#12427;&#12501;&#12451;&#12540;&#12523;&#12489;&#21517;&#12434;&#12501;&#12451;&#12540;&#12523;&#12489;&#21517;&#12381;&#12398;&#12418;&#12398;&#12363;&#12289;&#12414;&#12383;&#12399;&#12289;&#27491;&#35215;&#34920;&#29694;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12501;&#12451;&#12540;&#12523;&#12489;&#12398;&#12471;&#12464;&#12491;&#12481;&#12515;&#12540;&#12395;&#29031;&#12425;&#12375;&#12383;&#12501;&#12451;&#12523;&#12479;&#12522;&#12531;&#12464;&#12434;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290; <code class="literal">type</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#12501;&#12451;&#12540;&#12523;&#12489;&#12398;&#22411;&#12434;&#23436;&#20840;&#20462;&#39166;&#21517;&#12391;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#21517;&#21069;&#12392;&#12471;&#12464;&#12491;&#12481;&#12515;&#12540;&#12395;&#22522;&#12389;&#12367;&#26465;&#20214;&#12434;&#35215;&#23450;&#12377;&#12427;&#12383;&#12417;&#12395;&#12289;&#12381;&#12398;2&#12388;&#12398;&#23646;&#24615;&#12434;&#20001;&#26041;&#12392;&#12418;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Local&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#12525;&#12540;&#12459;&#12523;&#22793;&#25968;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;<code class="literal">name</code> &#23646;&#24615;&#12434;&#20351;&#29992;&#12375;&#12390;&#12289;&#29031;&#21512;&#12377;&#12427;&#12525;&#12540;&#12459;&#12523;&#22793;&#25968;&#21517;&#12434;&#12525;&#12540;&#12459;&#12523;&#22793;&#25968;&#21517;&#12381;&#12398;&#12418;&#12398;&#12363;&#12289;&#12414;&#12383;&#12399;&#12289;&#27491;&#35215;&#34920;&#29694;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12525;&#12540;&#12459;&#12523;&#22793;&#25968;&#12392;&#12399;&#12289;&#12513;&#12477;&#12483;&#12489;&#20869;&#12391;&#23450;&#32681;&#12375;&#12383;&#22793;&#25968;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><code class="literal">&lt;Or&gt;</code></span></dt><dd><p>&#12371;&#12398;&#35201;&#32032;&#12399;&#12289;&#35542;&#29702;&#21644;&#12392;&#12375;&#12390; <code class="literal">Match</code> &#26465;&#38917;&#12434;&#32080;&#21512;&#12375;&#12414;&#12377;&#12290;&#12377;&#12394;&#12431;&#12385;&#12289;2&#12388;&#12398; <code class="literal">Method</code> &#35201;&#32032;&#12434; <code class="literal">Or</code> &#26465;&#38917;&#12395;&#20837;&#12428;&#12427;&#12371;&#12392;&#12391;&#12289;&#12393;&#12385;&#12425;&#12363;&#19968;&#26041;&#12398;&#12513;&#12477;&#12483;&#12489;&#12391;&#12510;&#12483;&#12481;&#12373;&#12379;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd></dl></div></div><div class="sect1" title="3. Java &#35201;&#32032;&#21517;&#12510;&#12483;&#12481;&#12531;&#12464;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1958"></a>3. Java &#35201;&#32032;&#21517;&#12510;&#12483;&#12481;&#12531;&#12464;</h2></div></div></div><p><code class="literal">Class</code> &#12289; <code class="literal">Method</code> &#12414;&#12383;&#12399; <code class="literal">Field</code> &#12398; <code class="literal">name</code> &#23646;&#24615;&#12364;&#25991;&#23383; ~ &#12391;&#22987;&#12414;&#12387;&#12390;&#12356;&#12427;&#22580;&#21512;&#12399;&#12289;&#23646;&#24615;&#20516;&#12398;&#27531;&#12426;&#12398;&#37096;&#20998;&#12434; Java &#12398;&#27491;&#35215;&#34920;&#29694;&#12392;&#12375;&#12390;&#35299;&#37320;&#12375;&#12414;&#12377;&#12290;&#12381;&#12358;&#12375;&#12390;&#12289;&#24403;&#35442; Java &#35201;&#32032;&#12398;&#21517;&#21069;&#12395;&#23550;&#12375;&#12390;&#12398;&#29031;&#21512;&#12364;&#34892;&#12431;&#12428;&#12414;&#12377;&#12290;</p><p>&#12497;&#12479;&#12540;&#12531;&#12398;&#29031;&#21512;&#12399;&#35201;&#32032;&#12398;&#21517;&#21069;&#20840;&#20307;&#12395;&#23550;&#12375;&#12390;&#34892;&#12431;&#12428;&#12427;&#12371;&#12392;&#12395;&#27880;&#24847;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12381;&#12398;&#12383;&#12417;&#12289;&#37096;&#20998;&#19968;&#33268;&#29031;&#21512;&#12434;&#34892;&#12356;&#12383;&#12356;&#22580;&#21512;&#12399;&#12497;&#12479;&#12540;&#12531;&#25991;&#23383;&#21015;&#12398;&#21069;&#24460;&#12395; .* &#12434;&#20184;&#21152;&#12375;&#12390;&#20351;&#29992;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p><p>&#12497;&#12479;&#12540;&#12531;&#12398;&#27083;&#25991;&#35215;&#21063;&#12395;&#38306;&#12375;&#12390;&#12399;&#12289; <a class="ulink" href="http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/util/regex/Pattern.html" target="_top"><code class="literal">java.util.regex.Pattern</code></a> &#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="sect1" title="4. &#30041;&#24847;&#20107;&#38917;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1982"></a>4. &#30041;&#24847;&#20107;&#38917;</h2></div></div></div><p>
10 <code class="literal">Match</code> &#26465;&#38917;&#12399;&#12289;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12395;&#23455;&#38555;&#12395;&#21547;&#12414;&#12428;&#12390;&#12356;&#12427;&#24773;&#22577;&#12395;&#12398;&#12415;&#19968;&#33268;&#12375;&#12414;&#12377;&#12290;&#12377;&#12409;&#12390;&#12398;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12399;&#12463;&#12521;&#12473;&#12434;&#25345;&#12387;&#12390;&#12356;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#19968;&#33324;&#30340;&#12395;&#35328;&#12387;&#12390;&#12289;&#12496;&#12464;&#12434;&#38500;&#22806;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12463;&#12521;&#12473;&#12434;&#29992;&#12356;&#12390;&#34892;&#12358;&#12392;&#12358;&#12414;&#12367;&#12356;&#12367;&#12371;&#12392;&#12364;&#22810;&#12356;&#12391;&#12377;&#12290;</p><p>&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12398;&#20013;&#12395;&#12399;&#12289;2&#20491;&#20197;&#19978;&#12398;&#12463;&#12521;&#12473;&#12434;&#20445;&#25345;&#12375;&#12390;&#12356;&#12427;&#12418;&#12398;&#12418;&#12354;&#12426;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289; DE (dropped exception : &#20363;&#22806;&#12398;&#28961;&#35222;) &#12496;&#12464;&#12399;&#12289; &#20363;&#22806;&#12398;&#28961;&#35222;&#12364;&#30330;&#29983;&#12375;&#12383;&#12513;&#12477;&#12483;&#12489;&#12434;&#25345;&#12387;&#12390;&#12356;&#12427;&#12463;&#12521;&#12473;&#12392;&#12289; &#28961;&#35222;&#12373;&#12428;&#12383;&#20363;&#22806;&#12398;&#22411;&#12434;&#34920;&#12377;&#12463;&#12521;&#12473;&#12398;&#20001;&#26041;&#12434;&#21547;&#12435;&#12384;&#24418;&#12391;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;<code class="literal">Match</code> &#26465;&#38917;&#12392;&#12399;&#12289; <span class="emphasis"><em>1&#30058;&#30446;</em></span> (&#20027;) &#12398;&#12463;&#12521;&#12473;&#12398;&#12415;&#12364;&#29031;&#21512;&#12373;&#12428;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#20363;&#12360;&#12400;&#12289;&#12463;&#12521;&#12473; "com.foobar.A" &#12289; "com.foobar.B" &#38291;&#12391;&#12398; IC (initialization circularity : &#21021;&#26399;&#21270;&#26178;&#12398;&#20966;&#29702;&#24490;&#29872;) &#12496;&#12464;&#22577;&#21578;&#12434;&#25233;&#27490;&#12375;&#12383;&#12356;&#22580;&#21512;&#12289;&#20197;&#19979;&#12395;&#31034;&#12377;&#12424;&#12358;&#12395; 2&#12388;&#12398; <code class="literal">Match</code> &#26465;&#38917;&#12434;&#20351;&#29992;&#12375;&#12414;&#12377; :</p><pre class="programlisting">
11 &lt;Match&gt;
12 &lt;Class name="com.foobar.A" /&gt;
13 &lt;Bug code="IC" /&gt;
14 &lt;/Match&gt;
15
16 &lt;Match&gt;
17 &lt;Class name="com.foobar.B" /&gt;
18 &lt;Bug code="IC" /&gt;
19 &lt;/Match&gt;
20 </pre><p>&#26126;&#31034;&#30340;&#12395;&#20001;&#26041;&#12398;&#12463;&#12521;&#12473;&#12391;&#29031;&#21512;&#12377;&#12427;&#12371;&#12392;&#12395;&#12424;&#12387;&#12390;&#12289;&#24490;&#29872;&#12375;&#12390;&#12356;&#12427;&#12393;&#12385;&#12425;&#12398;&#12463;&#12521;&#12473;&#12364;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12398; 1 &#30058;&#30446;&#12395;&#12394;&#12387;&#12390;&#12356;&#12427;&#12363;&#12395;&#38306;&#20418;&#12394;&#12367;&#19968;&#33268;&#12373;&#12379;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;(&#12418;&#12385;&#12429;&#12435;&#12371;&#12398;&#26041;&#27861;&#12399;&#12289;&#20966;&#29702;&#24490;&#29872;&#12364; "com.foobar.A" &#12289; "com.foobar.B" &#12395;&#21152;&#12360;&#12390;3&#30058;&#30446;&#12398;&#12463;&#12521;&#12473;&#12418;&#21547;&#12435;&#12391;&#12356;&#12427;&#22580;&#21512;&#12399;&#22259;&#12425;&#12378;&#12418;&#22833;&#25943;&#12375;&#12390;&#12375;&#12414;&#12358;&#24656;&#12428;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;)</p><p>&#22810;&#12367;&#12398;&#31278;&#39006;&#12398;&#12496;&#12464;&#22577;&#21578;&#12399;&#12289;&#33258;&#36523;&#12364;&#20986;&#29694;&#12375;&#12383;&#12513;&#12477;&#12483;&#12489;&#12434;&#22577;&#21578;&#12375;&#12414;&#12377;&#12290;&#12381;&#12428;&#12425;&#12398;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12395;&#23550;&#12375;&#12390;&#12399;&#12289; <code class="literal">Method</code> &#26465;&#38917;&#12434; <code class="literal">Match</code> &#35201;&#32032;&#12395;&#21152;&#12360;&#12427;&#12392;&#26399;&#24453;&#36890;&#12426;&#12398;&#21205;&#20316;&#12434;&#12377;&#12427;&#12391;&#12375;&#12423;&#12358;&#12290;</p></div><div class="sect1" title="5. &#20363;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2012"></a>5. &#20363;</h2></div></div></div><p>1. &#29305;&#23450;&#12398;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#12377;&#12409;&#12390;&#12398;&#12496;&#12464;&#22577;&#21578;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
21
22 &lt;Match&gt;
23 &lt;Class name="com.foobar.MyClass" /&gt;
24 &lt;/Match&gt;
25
26 </pre><p>
27
28 </p><p>2. &#12496;&#12464;&#30053;&#31216;&#12434;&#25351;&#23450;&#12375;&#12390;&#12289;&#29305;&#23450;&#12398;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#26908;&#26619;&#38917;&#30446;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
29
30 &lt;Match&gt;
31 &lt;Class name="com.foobar.MyClass"/ &gt;
32 &lt;Bug code="DE,UrF,SIC" /&gt;
33 &lt;/Match&gt;
34
35 </pre><p>
36 </p><p>3. &#12496;&#12464;&#30053;&#31216;&#12434;&#25351;&#23450;&#12375;&#12390;&#12289;&#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#26908;&#26619;&#38917;&#30446;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
37
38 &lt;Match&gt;
39 &lt;Bug code="DE,UrF,SIC" /&gt;
40 &lt;/Match&gt;
41
42 </pre><p>
43 </p><p>4. &#12496;&#12464;&#12459;&#12486;&#12468;&#12522;&#12540;&#12434;&#25351;&#23450;&#12375;&#12390;&#12289;&#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#26908;&#26619;&#38917;&#30446;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
44
45 &lt;Match&gt;
46 &lt;Bug category="PERFORMANCE" /&gt;
47 &lt;/Match&gt;
48
49 </pre><p>
50 </p><p>5. &#12496;&#12464;&#30053;&#31216;&#12434;&#25351;&#23450;&#12375;&#12390;&#12289;&#29305;&#23450;&#12398;&#12463;&#12521;&#12473;&#12398;&#25351;&#23450;&#12373;&#12428;&#12383;&#12513;&#12477;&#12483;&#12489;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#12496;&#12464;&#31278;&#21029;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
51
52 &lt;Match&gt;
53 &lt;Class name="com.foobar.MyClass" /&gt;
54 &lt;Or&gt;
55 &lt;Method name="frob" params="int,java.lang.String" returns="void" /&gt;
56 &lt;Method name="blat" params="" returns="boolean" /&gt;
57 &lt;/Or&gt;
58 &lt;Bug code="DC" /&gt;
59 &lt;/Match&gt;
60
61 </pre><p>
62 </p><p>6. &#29305;&#23450;&#12398;&#12513;&#12477;&#12483;&#12489;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
63
64 &lt;!-- open stream &#12395;&#38306;&#12377;&#12427;&#35492;&#26908;&#20986;&#12364;&#12354;&#12427;&#12513;&#12477;&#12483;&#12489;&#12290;--&gt;
65 &lt;Match&gt;
66 &lt;Class name="com.foobar.MyClass" /&gt;
67 &lt;Method name="writeDataToFile" /&gt;
68 &lt;Bug pattern="OS_OPEN_STREAM" /&gt;
69 &lt;/Match&gt;
70
71 </pre><p>
72 </p><p>7. &#29305;&#23450;&#12398;&#12513;&#12477;&#12483;&#12489;&#12395;&#23550;&#12377;&#12427;&#29305;&#23450;&#12398;&#20778;&#20808;&#24230;&#12434;&#20184;&#19982;&#12373;&#12428;&#12383;&#29305;&#23450;&#12398;&#12496;&#12464;&#12497;&#12479;&#12540;&#12531;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
73
74 &lt;!-- dead local store (&#20778;&#20808;&#24230; (&#20013;)) &#12395;&#38306;&#12377;&#12427;&#35492;&#26908;&#20986;&#12364;&#12354;&#12427;&#12513;&#12477;&#12483;&#12489;&#12290;--&gt;
75 &lt;Match&gt;
76 &lt;Class name="com.foobar.MyClass" /&gt;
77 &lt;Method name="someMethod" /&gt;
78 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
79 &lt;Priority value="2" /&gt;
80 &lt;/Match&gt;
81
82 </pre><p>
83 </p><p>8. AspectJ &#12467;&#12531;&#12497;&#12452;&#12521;&#12540;&#12395;&#12424;&#12387;&#12390;&#24341;&#12365;&#36215;&#12371;&#12373;&#12428;&#12427;&#12510;&#12452;&#12490;&#12540;&#12496;&#12464;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377; (AspectJ &#12398;&#38283;&#30330;&#32773;&#12391;&#12418;&#12394;&#12356;&#38480;&#12426;&#12289;&#12381;&#12428;&#12425;&#12398;&#12496;&#12464;&#12395;&#38306;&#24515;&#12434;&#25345;&#12388;&#12371;&#12392;&#12399;&#12394;&#12356;&#12392;&#32771;&#12360;&#12414;&#12377;)&#12290;</p><pre class="programlisting">
84
85 &lt;Match&gt;
86 &lt;Class name="~.*\$AjcClosure\d+" /&gt;
87 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
88 &lt;Method name="run" /&gt;
89 &lt;/Match&gt;
90 &lt;Match&gt;
91 &lt;Bug pattern="UUF_UNUSED_FIELD" /&gt;
92 &lt;Field name="~ajc\$.*" /&gt;
93 &lt;/Match&gt;
94
95 </pre><p>
96 </p><p>9. &#22522;&#30436;&#12467;&#12540;&#12489;&#12398;&#29305;&#23450;&#12398;&#37096;&#20998;&#12395;&#23550;&#12377;&#12427;&#12496;&#12464;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;</p><pre class="programlisting">
97
98 &lt;!-- &#12377;&#12409;&#12390;&#12398;&#12497;&#12483;&#12465;&#12540;&#12472;&#12395;&#12354;&#12427; Messages &#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427; unused fields &#35686;&#21578;&#12395;&#19968;&#33268;&#12290; --&gt;
99 &lt;Match&gt;
100 &lt;Class name="~.*\.Messages" /&gt;
101 &lt;Bug code="UUF" /&gt;
102 &lt;/Match&gt;
103 &lt;!-- &#12377;&#12409;&#12390;&#12398; internal &#12497;&#12483;&#12465;&#12540;&#12472;&#20869;&#12398; mutable statics &#35686;&#21578;&#12395;&#19968;&#33268;&#12290; --&gt;
104 &lt;Match&gt;
105 &lt;Package name="~.*\.internal" /&gt;
106 &lt;Bug code="MS" /&gt;
107 &lt;/Match&gt;
108 &lt;!-- ui &#12497;&#12483;&#12465;&#12540;&#12472;&#38542;&#23652;&#20869;&#12398; anonymoous inner classes &#35686;&#21578;&#12395;&#19968;&#33268;&#12290; --&gt;
109 &lt;Match&gt;
110 &lt;Package name="~com\.foobar\.fooproject\.ui.*" /&gt;
111 &lt;Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" /&gt;
112 &lt;/Match&gt;
113
114 </pre><p>
115 </p><p>10. &#29305;&#23450;&#12398;&#12471;&#12464;&#12491;&#12481;&#12515;&#12540;&#12434;&#25345;&#12388;&#12501;&#12451;&#12540;&#12523;&#12489;&#12414;&#12383;&#12399;&#12513;&#12477;&#12483;&#12489;&#12398;&#12496;&#12464;&#12395;&#19968;&#33268;&#12373;&#12379;&#12414;&#12377;&#12290;</p><pre class="programlisting">
116
117 &lt;!-- &#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12398; main(String[]) &#12513;&#12477;&#12483;&#12489;&#12395;&#23550;&#12377;&#12427; System.exit(...) usage &#35686;&#21578;&#12395;&#19968;&#33268;&#12290; --&gt;
118 &lt;Match&gt;
119 &lt;Method returns="void" name="main" params="java.lang.String[]" /&gt;
120 &lt;Method pattern="DM_EXIT" /&gt;
121 &lt;/Match&gt;
122 &lt;!-- &#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12398; com.foobar.DebugInfo &#22411;&#12398;&#12501;&#12451;&#12540;&#12523;&#12489;&#12395;&#23550;&#12377;&#12427; UuF &#35686;&#21578;&#12395;&#19968;&#33268;&#12290; --&gt;
123 &lt;Match&gt;
124 &lt;Field type="com.foobar.DebugInfo" /&gt;
125 &lt;Bug code="UuF" /&gt;
126 &lt;/Match&gt;
127
128 </pre><p>
129
130 </p></div><div class="sect1" title="6. &#23436;&#20840;&#12394;&#20363;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2065"></a>6. &#23436;&#20840;&#12394;&#20363;</h2></div></div></div><pre class="programlisting">
131
132 &lt;FindBugsFilter&gt;
133 &lt;Match&gt;
134 &lt;Class name="com.foobar.ClassNotToBeAnalyzed" /&gt;
135 &lt;/Match&gt;
136
137 &lt;Match&gt;
138 &lt;Class name="com.foobar.ClassWithSomeBugsMatched" /&gt;
139 &lt;Bug code="DE,UrF,SIC" /&gt;
140 &lt;/Match&gt;
141
142 &lt;!-- XYZ &#36949;&#21453;&#12395;&#19968;&#33268;&#12290;--&gt;
143 &lt;Match&gt;
144 &lt;Bug code="XYZ" /&gt;
145 &lt;/Match&gt;
146
147 &lt;!-- "AnotherClass" &#12398;&#29305;&#23450;&#12398;&#12513;&#12477;&#12483;&#12489;&#12398; doublecheck &#36949;&#21453;&#12395;&#19968;&#33268;&#12290;--&gt;
148 &lt;Match&gt;
149 &lt;Class name="com.foobar.AnotherClass" /&gt;
150 &lt;Or&gt;
151 &lt;Method name="nonOverloadedMethod" /&gt;
152 &lt;Method name="frob" params="int,java.lang.String" returns="void" /&gt;
153 &lt;Method name="blat" params="" returns="boolean" /&gt;
154 &lt;/Or&gt;
155 &lt;Bug code="DC" /&gt;
156 &lt;/Match&gt;
157
158 &lt;!-- dead local store (&#20778;&#20808;&#24230; (&#20013;)) &#12395;&#38306;&#12377;&#12427;&#35492;&#26908;&#20986;&#12364;&#12354;&#12427;&#12513;&#12477;&#12483;&#12489;&#12290;--&gt;
159 &lt;Match&gt;
160 &lt;Class name="com.foobar.MyClass" /&gt;
161 &lt;Method name="someMethod" /&gt;
162 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
163 &lt;Priority value="2" /&gt;
164 &lt;/Match&gt;
165 &lt;/FindBugsFilter&gt;
166
167 </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="eclipse.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="analysisprops.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;7&#31456; <span class="application">FindBugs</span>&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;5&#31456; FindBugs GUI &#12398;&#20351;&#29992;&#26041;&#27861;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="running.html" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;"><link rel="next" href="anttask.html" title="&#31532;6&#31456; FindBugs&#8482; Ant &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;5&#31456; <span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="running.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="anttask.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;5&#31456; FindBugs GUI &#12398;&#20351;&#29992;&#26041;&#27861;"><div class="titlepage"><div><div><h2 class="title"><a name="gui"></a>&#31532;5&#31456; <span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="gui.html#d0e1058">1. &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#20316;&#25104;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1099">2. &#20998;&#26512;&#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1104">3. &#32080;&#26524;&#12398;&#38322;&#35239;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1119">4. &#20445;&#23384;&#12392;&#35501;&#12415;&#36796;&#12415;</a></span></dt></dl></div><p>&#12371;&#12398;&#31456;&#12391;&#12399;&#12289;<span class="application">FindBugs</span> &#12464;&#12521;&#12501;&#12451;&#12459;&#12523;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473; (GUI) &#12398;&#20351;&#29992;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><div class="sect1" title="1. &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#20316;&#25104;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1058"></a>1. &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#20316;&#25104;</h2></div></div></div><p><span class="command"><strong>findbugs</strong></span> &#12467;&#12510;&#12531;&#12489;&#12391; <span class="application">FindBugs</span> &#12434;&#36215;&#21205;&#12375;&#12390;&#12363;&#12425;&#12289;&#12513;&#12491;&#12517;&#12540;&#12391; <span class="guimenu">File</span> &#8594; <span class="guimenuitem">New Project</span> &#12434;&#36984;&#25246;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12381;&#12358;&#12377;&#12427;&#12392;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#12480;&#12452;&#12450;&#12525;&#12464;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;:</p><div class="mediaobject"><img src="project-dialog.png"></div><p>
3 </p><p>&#12300;Class archives and directories to analyze&#12301;&#12486;&#12461;&#12473;&#12488;&#12501;&#12451;&#12540;&#12523;&#12489;&#12398;&#27178;&#12395;&#12354;&#12427; &#12300;Add&#12301;&#12508;&#12479;&#12531;&#12434;&#25276;&#12377;&#12392;&#12289;&#12496;&#12464;&#12434;&#20998;&#26512;&#12377;&#12427; java &#12463;&#12521;&#12473;&#12434;&#21547;&#12435;&#12391;&#12356;&#12427; Java &#12450;&#12540;&#12459;&#12452;&#12502;&#12501;&#12449;&#12452;&#12523; (zip, jar, ear, or war file) &#12434;&#36984;&#25246;&#12375;&#12390;&#25351;&#23450;&#12391;&#12365;&#12414;&#12377;&#12290;&#35079;&#25968;&#12398; &#12450;&#12540;&#12459;&#12452;&#12502;/&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#36861;&#21152;&#12377;&#12427;&#12371;&#12392;&#12364;&#21487;&#33021;&#12391;&#12377;&#12290;</p><p>&#12414;&#12383;&#12289;&#20998;&#26512;&#12434;&#34892;&#12358; Java &#12450;&#12540;&#12459;&#12452;&#12502;&#12398;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12434;&#21547;&#12435;&#12384;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;&#12381;&#12358;&#12377;&#12427;&#12392;&#12289;&#12496;&#12464;&#12398;&#21487;&#33021;&#24615;&#12364;&#12354;&#12427;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12398;&#22580;&#25152;&#12364;&#12289;<span class="application">FindBugs</span> &#19978;&#12391;&#12495;&#12452;&#12521;&#12452;&#12488;&#12375;&#12390;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12399;&#12289;Java &#12497;&#12483;&#12465;&#12540;&#12472;&#38542;&#23652;&#12398;&#12523;&#12540;&#12488;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#25351;&#23450;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#12518;&#12540;&#12470;&#12398;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12364; <code class="varname">org.foobar.myapp</code> &#12497;&#12483;&#12465;&#12540;&#12472;&#12398;&#20013;&#12395;&#12354;&#12427;&#22580;&#21512;&#12399;&#12289; <code class="filename">org</code> &#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;&#35242;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12522;&#12473;&#12488;&#12395;&#25351;&#23450;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p><p>&#12418;&#12358;&#12402;&#12392;&#12388;&#12289;&#20219;&#24847;&#25351;&#23450;&#12398;&#25163;&#38918;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12381;&#12428;&#12399;&#12289;&#35036;&#21161;&#29992;&#12398; Jar &#12501;&#12449;&#12452;&#12523;&#12362;&#12424;&#12403;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434; &#12300;Auxiliary classpath locations&#12301;&#12398;&#12456;&#12531;&#12488;&#12522;&#12540;&#12395;&#36861;&#21152;&#12377;&#12427;&#12371;&#12392;&#12391;&#12377;&#12290;&#20998;&#26512;&#12377;&#12427;&#12450;&#12540;&#12459;&#12452;&#12502;/&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#12418;&#27161;&#28310;&#12398;&#23455;&#34892;&#26178;&#12463;&#12521;&#12473;&#12497;&#12473;&#12395;&#12418;&#21547;&#12414;&#12428;&#12390;&#12356;&#12394;&#12356;&#12463;&#12521;&#12473;&#12434;&#12289;&#20998;&#26512;&#12377;&#12427;&#12450;&#12540;&#12459;&#12452;&#12502;/&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12364;&#21442;&#29031;&#12375;&#12390;&#12356;&#12427;&#22580;&#21512;&#12399;&#12289;&#12371;&#12398;&#38917;&#30446;&#12434;&#35373;&#23450;&#12375;&#12383;&#26041;&#12364;&#12356;&#12356;&#12391;&#12375;&#12423;&#12358;&#12290;&#12463;&#12521;&#12473;&#38542;&#23652;&#12395;&#38306;&#12377;&#12427;&#24773;&#22577;&#12434;&#20351;&#29992;&#12377;&#12427;&#12496;&#12464;&#12487;&#12451;&#12486;&#12463;&#12479;&#12364;&#12289; <span class="application">FindBugs</span> &#12395;&#12399;&#12356;&#12367;&#12388;&#12363;&#12354;&#12426;&#12414;&#12377;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;<span class="application">FindBugs</span> &#12364;&#20998;&#26512;&#12434;&#34892;&#12358;&#12463;&#12521;&#12473;&#12398;&#23436;&#20840;&#12394;&#12463;&#12521;&#12473;&#38542;&#23652;&#12434;&#21442;&#29031;&#12391;&#12365;&#12428;&#12400;&#12289;&#12424;&#12426;&#27491;&#30906;&#12394;&#20998;&#26512;&#32080;&#26524;&#12434;&#21462;&#24471;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="2. &#20998;&#26512;&#12398;&#23455;&#34892;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1099"></a>2. &#20998;&#26512;&#12398;&#23455;&#34892;</h2></div></div></div><p>&#12450;&#12540;&#12459;&#12452;&#12502;&#12289;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12362;&#12424;&#12403;&#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;&#25351;&#23450;&#12364;&#12391;&#12365;&#12428;&#12400;&#12289;&#12300;Finish&#12301;&#12508;&#12479;&#12531;&#12434;&#25276;&#12375;&#12390; Jar &#12501;&#12449;&#12452;&#12523;&#12395;&#21547;&#12414;&#12428;&#12427;&#12463;&#12521;&#12473;&#12395;&#23550;&#12377;&#12427;&#20998;&#26512;&#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;&#24040;&#22823;&#12394;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12434;&#21476;&#12356;&#12467;&#12531;&#12500;&#12517;&#12540;&#12479;&#19978;&#12391;&#23455;&#34892;&#12377;&#12427;&#12392;&#12289;&#12363;&#12394;&#12426;&#12398;&#26178;&#38291;(&#25968;&#21313;&#20998;)&#12364;&#12363;&#12363;&#12427;&#12371;&#12392;&#12395;&#27880;&#24847;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#22823;&#23481;&#37327;&#12513;&#12514;&#12522;&#12391;&#12354;&#12427;&#26368;&#36817;&#12398;&#12467;&#12531;&#12500;&#12517;&#12540;&#12479;&#12394;&#12425;&#12289;&#22823;&#12365;&#12394;&#12503;&#12525;&#12464;&#12521;&#12512;&#12391;&#12354;&#12387;&#12390;&#12418;&#25968;&#20998;&#31243;&#24230;&#12391;&#20998;&#26512;&#12391;&#12365;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="3. &#32080;&#26524;&#12398;&#38322;&#35239;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1104"></a>3. &#32080;&#26524;&#12398;&#38322;&#35239;</h2></div></div></div><p>&#20998;&#26512;&#12364;&#23436;&#20102;&#12377;&#12427;&#12392;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#30011;&#38754;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377; :</p><div class="mediaobject"><img src="example-details.png"></div><p>
4 </p><p>&#24038;&#19978;&#12398;&#12506;&#12452;&#12531;&#12395;&#12399;&#12496;&#12464;&#38542;&#23652;&#12484;&#12522;&#12540;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#12371;&#12428;&#12399;&#12289;&#20998;&#26512;&#12391;&#12415;&#12388;&#12363;&#12387;&#12383;&#12496;&#12464;&#12398;&#26908;&#32034;&#32080;&#26524;&#12364;&#38542;&#23652;&#30340;&#12395;&#34920;&#31034;&#12373;&#12428;&#12383;&#12418;&#12398;&#12391;&#12377;&#12290;</p><p>&#19978;&#37096;&#12398;&#12506;&#12452;&#12531;&#12391;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#36984;&#25246;&#12377;&#12427;&#12392;&#12289;&#19979;&#37096;&#12398;&#12300;Details&#12301;&#12506;&#12452;&#12531;&#12395;&#12496;&#12464;&#12398;&#35443;&#32048;&#35500;&#26126;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#26356;&#12395;&#12289;&#12477;&#12540;&#12473;&#12364;&#12415;&#12388;&#12363;&#12428;&#12400;&#12289;&#21491;&#19978;&#12398;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12506;&#12452;&#12531;&#12395;&#12496;&#12464;&#12398;&#20986;&#29694;&#31623;&#25152;&#12395;&#35442;&#24403;&#12377;&#12427;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12364;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;&#19978;&#22259;&#12398;&#20363;&#12391;&#34920;&#31034;&#12373;&#12428;&#12390;&#12356;&#12427;&#12496;&#12464;&#12399;&#12289;&#12473;&#12488;&#12522;&#12540;&#12512;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12364;&#12463;&#12525;&#12540;&#12474;&#12373;&#12428;&#12390;&#12356;&#12394;&#12356;&#12392;&#12356;&#12358;&#12418;&#12398;&#12391;&#12377;&#12290;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12539;&#12454;&#12451;&#12531;&#12489;&#12454;&#12395;&#12362;&#12356;&#12390;&#24403;&#35442;&#12473;&#12488;&#12522;&#12540;&#12512;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12434;&#29983;&#25104;&#12375;&#12390;&#12356;&#12427;&#34892;&#12364;&#12495;&#12452;&#12521;&#12452;&#12488;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;</p><p>&#12496;&#12464;&#12398;&#26908;&#32034;&#32080;&#26524;&#12395;&#23550;&#12375;&#12390;&#12486;&#12461;&#12473;&#12488;&#12391;&#27880;&#37320;&#12434;&#20837;&#12428;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#38542;&#23652;&#12484;&#12522;&#12540;&#22259;&#12398;&#12377;&#12368;&#19979;&#12395;&#12354;&#12427;&#12486;&#12461;&#12473;&#12488;&#12508;&#12483;&#12463;&#12473;&#12395;&#27880;&#37320;&#12434;&#20837;&#21147;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#35352;&#37682;&#12375;&#12390;&#12362;&#12365;&#12383;&#12356;&#24773;&#22577;&#12434;&#20309;&#12391;&#12418;&#33258;&#30001;&#12395;&#20837;&#21147;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12496;&#12464;&#32080;&#26524;&#12501;&#12449;&#12452;&#12523;&#12398;&#20445;&#23384;&#12362;&#12424;&#12403;&#35501;&#12415;&#36796;&#12415;&#12434;&#34892;&#12387;&#12383;&#12392;&#12365;&#12395;&#12289;&#27880;&#37320;&#12418;&#20445;&#23384;&#12373;&#12428;&#12414;&#12377;&#12290;</p></div><div class="sect1" title="4. &#20445;&#23384;&#12392;&#35501;&#12415;&#36796;&#12415;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1119"></a>4. &#20445;&#23384;&#12392;&#35501;&#12415;&#36796;&#12415;</h2></div></div></div><p>&#12513;&#12491;&#12517;&#12540;&#38917;&#30446;&#12363;&#12425; <span class="guimenu">File</span> &#8594; <span class="guimenuitem">Save as...</span> &#12434;&#36984;&#25246;&#12377;&#12427;&#12392;&#12289;&#12518;&#12540;&#12470;&#12540;&#12398;&#20316;&#26989;&#32080;&#26524;&#12434;&#20445;&#23384;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12300;Save as...&#12301;&#12480;&#12452;&#12450;&#12525;&#12464;&#12395;&#12354;&#12427;&#12489;&#12525;&#12483;&#12503;&#12480;&#12454;&#12531;&#12539;&#12522;&#12473;&#12488;&#12398;&#20013;&#12363;&#12425;&#12300;FindBugs analysis results (.xml)&#12301;&#12434;&#36984;&#25246;&#12371;&#12392;&#12391;&#12289;&#12518;&#12540;&#12470;&#12540;&#12364;&#25351;&#23450;&#12375;&#12383; jar &#12501;&#12449;&#12452;&#12523;&#12522;&#12473;&#12488;&#12420;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12394;&#12393;&#12398;&#20316;&#26989;&#32080;&#26524;&#12434;&#20445;&#23384;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;jar &#12501;&#12449;&#12452;&#12523;&#12522;&#12473;&#12488;&#12398;&#12415;&#12434;&#20445;&#23384;&#12377;&#12427;&#36984;&#25246;&#32930; (&#12300;FindBugs project file (.fbp)&#12301;) &#12420;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12398;&#12415;&#12434;&#20445;&#23384;&#12377;&#12427;&#36984;&#25246;&#32930; (&#12300;FindBugs analysis file (.fba)&#12301;) &#12418;&#12354;&#12426;&#12414;&#12377;&#12290;&#20445;&#23384;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289;&#12513;&#12491;&#12517;&#12540;&#38917;&#30446;&#12363;&#12425; <span class="guimenu">File</span> &#8594; <span class="guimenuitem">Open...</span> &#12434;&#36984;&#25246;&#12377;&#12427;&#12371;&#12392;&#12391;&#12289;&#35501;&#12415;&#36796;&#12416;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="running.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="anttask.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;4&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;6&#31456; <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="next" href="introduction.html" title="&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="application">FindBugs</span>&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;</th></tr><tr><td width="20%" align="left">&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="introduction.html">&#27425;&#12408;</a></td></tr></table><hr></div><div lang="ja" class="book" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><div class="titlepage"><div><div><h1 class="title"><a name="findbugs-manual"></a><span class="application">FindBugs</span>&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="surname">Hovemeyer</span> <span class="firstname">David</span> [FAMILY Given]</h3></div><div class="author"><h3 class="author"><span class="surname">Pugh</span> <span class="firstname">William</span> [FAMILY Given]</h3></div></div></div><div><p class="copyright">&#35069;&#20316;&#33879;&#20316; &copy; 2003, 2004, 2005, 2006, 2008 University of Maryland</p></div><div><div class="legalnotice" title="&#27861;&#24459;&#19978;&#12398;&#36890;&#30693;"><a name="d0e35"></a><p>&#12371;&#12398;&#12510;&#12491;&#12517;&#12450;&#12523;&#12399;&#12289;&#12463;&#12522;&#12456;&#12452;&#12486;&#12451;&#12502;&#12539;&#12467;&#12514;&#12531;&#12474;&#34920;&#31034;-&#38750;&#21942;&#21033;-&#32153;&#25215;&#12395;&#22522;&#12389;&#12367;&#20351;&#29992;&#35377;&#35582;&#12364;&#12394;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#20351;&#29992;&#35377;&#35582;&#26360;&#12434;&#12372;&#35239;&#12395;&#12394;&#12427;&#22580;&#21512;&#12399;&#12289; <a class="ulink" href="http://creativecommons.org/licenses/by-nc-sa/1.0/deed.ja" target="_top">http://creativecommons.org/licenses/by-nc-sa/1.0/</a> &#12395;&#12450;&#12463;&#12475;&#12473;&#12377;&#12427;&#12363;&#12289;&#12463;&#12522;&#12456;&#12452;&#12486;&#12451;&#12502;&#12539;&#12467;&#12514;&#12531;&#12474;(559 Nathan Abbott Way, Stanford, California 94305, USA)&#12395;&#26360;&#31777;&#12434;&#36865;&#20184;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p>&#21517;&#31216;&#12300;FindBugs&#12301;&#12362;&#12424;&#12403; FindBugs &#12398;&#12525;&#12468;&#12399;&#12289;&#12513;&#12522;&#12540;&#12521;&#12531;&#12489;&#22823;&#23398;&#12398;&#30331;&#37682;&#21830;&#27161;&#12391;&#12377;&#12290;</p></div></div><div><p class="pubdate">17:16:15 EST, 22 November, 2013</p></div></div><hr></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="chapter"><a href="introduction.html">1. &#12399;&#12376;&#12417;&#12395;</a></span></dt><dd><dl><dt><span class="sect1"><a href="introduction.html#d0e74">1. &#24517;&#35201;&#26465;&#20214;</a></span></dt></dl></dd><dt><span class="chapter"><a href="installing.html">2. <span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</a></span></dt><dd><dl><dt><span class="sect1"><a href="installing.html#d0e102">1. &#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</a></span></dt></dl></dd><dt><span class="chapter"><a href="building.html">3. <span class="application">FindBugs</span>&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;</a></span></dt><dd><dl><dt><span class="sect1"><a href="building.html#d0e175">1. &#21069;&#25552;&#26465;&#20214;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e258">2. &#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e271">3. <code class="filename">local.properties</code> &#12398;&#20462;&#27491;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e326">4. <span class="application">Ant</span> &#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="building.html#d0e420">5. &#12477;&#12540;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12363;&#12425;&#12398; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</a></span></dt></dl></dd><dt><span class="chapter"><a href="running.html">4. <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</a></span></dt><dd><dl><dt><span class="sect1"><a href="running.html#d0e455">1. &#12463;&#12452;&#12483;&#12463;&#12539;&#12473;&#12479;&#12540;&#12488;</a></span></dt><dt><span class="sect1"><a href="running.html#d0e493">2. <span class="application">FindBugs</span> &#12398;&#36215;&#21205;</a></span></dt><dt><span class="sect1"><a href="running.html#commandLineOptions">3. &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</a></span></dt></dl></dd><dt><span class="chapter"><a href="gui.html">5. <span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dd><dl><dt><span class="sect1"><a href="gui.html#d0e1058">1. &#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#20316;&#25104;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1099">2. &#20998;&#26512;&#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1104">3. &#32080;&#26524;&#12398;&#38322;&#35239;</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1119">4. &#20445;&#23384;&#12392;&#35501;&#12415;&#36796;&#12415;</a></span></dt></dl></dd><dt><span class="chapter"><a href="anttask.html">6. <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dd><dl><dt><span class="sect1"><a href="anttask.html#d0e1173">1. <span class="application">Ant</span> &#12479;&#12473;&#12463;&#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1209">2. build.xml &#12398;&#26360;&#12365;&#26041;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1278">3. &#12479;&#12473;&#12463;&#12398;&#23455;&#34892;</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1303">4. &#12497;&#12521;&#12513;&#12540;&#12479;&#12540;</a></span></dt></dl></dd><dt><span class="chapter"><a href="eclipse.html">7. <span class="application">FindBugs</span>&#8482; Eclipse &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dd><dl><dt><span class="sect1"><a href="eclipse.html#d0e1604">1. &#24517;&#35201;&#26465;&#20214;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1611">2. &#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1658">3. &#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1681">4. &#12488;&#12521;&#12502;&#12523;&#12471;&#12517;&#12540;&#12486;&#12451;&#12531;&#12464;</a></span></dt></dl></dd><dt><span class="chapter"><a href="filter.html">8. &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</a></span></dt><dd><dl><dt><span class="sect1"><a href="filter.html#d0e1709">1. &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;&#12398;&#27010;&#35201;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1759">2. &#12510;&#12483;&#12481;&#12531;&#12464;&#26465;&#20214;&#12398;&#31278;&#39006;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1958">3. Java &#35201;&#32032;&#21517;&#12510;&#12483;&#12481;&#12531;&#12464;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1982">4. &#30041;&#24847;&#20107;&#38917;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2012">5. &#20363;</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2065">6. &#23436;&#20840;&#12394;&#20363;</a></span></dt></dl></dd><dt><span class="chapter"><a href="analysisprops.html">9. &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</a></span></dt><dt><span class="chapter"><a href="annotations.html">10. &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;</a></span></dt><dt><span class="chapter"><a href="rejarForAnalysis.html">11. rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;</a></span></dt><dt><span class="chapter"><a href="datamining.html">12. <span class="application">FindBugs</span>&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;</a></span></dt><dd><dl><dt><span class="sect1"><a href="datamining.html#commands">1. &#12467;&#12510;&#12531;&#12489;</a></span></dt><dt><span class="sect1"><a href="datamining.html#examples">2. &#20363;</a></span></dt><dt><span class="sect1"><a href="datamining.html#antexample">3. Ant &#12398;&#20363;</a></span></dt></dl></dd><dt><span class="chapter"><a href="license.html">13. &#12521;&#12452;&#12475;&#12531;&#12473;</a></span></dt><dt><span class="chapter"><a href="acknowledgments.html">14. &#35613;&#36766;</a></span></dt><dd><dl><dt><span class="sect1"><a href="acknowledgments.html#d0e3438">1. &#36002;&#29486;&#32773;</a></span></dt><dt><span class="sect1"><a href="acknowledgments.html#d0e3561">2. &#20351;&#29992;&#12375;&#12390;&#12356;&#12427;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;</a></span></dt></dl></dd></dl></div><div class="list-of-tables"><p><b>&#34920;&#12398;&#19968;&#35239;</b></p><dl><dt>9.1. <a href="analysisprops.html#analysisproptable">&#35373;&#23450;&#21487;&#33021;&#12394;&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</a></dt><dt>12.1. <a href="datamining.html#computeBugHistoryTable">computeBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</a></dt><dt>12.2. <a href="datamining.html#filterOptionsTable">filterBugs &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</a></dt><dt>12.3. <a href="datamining.html#mineBugHistoryOptionsTable">mineBugHistory &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</a></dt><dt>12.4. <a href="datamining.html#mineBugHistoryColumns">mineBugHistory &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;</a></dt><dt>12.5. <a href="datamining.html#defectDensityColumns">defectDensity &#20986;&#21147;&#12398;&#12459;&#12521;&#12512;&#19968;&#35239;</a></dt><dt>12.6. <a href="datamining.html#convertXmlToTextTable">convertXmlToText &#12467;&#12510;&#12531;&#12489;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</a></dt><dt>12.7. <a href="datamining.html#setBugDatabaseInfoOptions">setBugDatabaseInfo &#12458;&#12503;&#12471;&#12519;&#12531;&#19968;&#35239;</a></dt><dt>12.8. <a href="datamining.html#listBugDatabaseInfoColumns">listBugDatabaseInfo &#12459;&#12521;&#12512;&#19968;&#35239;</a></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="introduction.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right" valign="top">&nbsp;&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;2&#31456; FindBugs&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="introduction.html" title="&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;"><link rel="next" href="building.html" title="&#31532;3&#31456; FindBugs&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;2&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="introduction.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="building.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;2&#31456; FindBugs&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;"><div class="titlepage"><div><div><h2 class="title"><a name="installing"></a>&#31532;2&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="installing.html#d0e102">1. &#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</a></span></dt></dl></div><p>&#12371;&#12398;&#31456;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><div class="sect1" title="1. &#37197;&#24067;&#29289;&#12398;&#23637;&#38283;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e102"></a>1. &#37197;&#24067;&#29289;&#12398;&#23637;&#38283;</h2></div></div></div><p><span class="application">FindBugs</span> &#12434;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12377;&#12427;&#26368;&#12418;&#31777;&#21336;&#12394;&#26041;&#27861;&#12399;&#12289;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12377;&#12427;&#12371;&#12392;&#12391;&#12377;&#12290; &#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12399;&#12289; <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.tar.gz?download" target="_top">gzipped tar &#24418;&#24335;</a> &#12362;&#12424;&#12403; <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.zip?download" target="_top">zip &#24418;&#24335;</a> &#12364;&#12381;&#12428;&#12382;&#12428;&#20837;&#25163;&#21487;&#33021;&#12391;&#12377;&#12290;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12375;&#12390;&#12365;&#12383;&#12425;&#12289;&#12381;&#12428;&#12434;&#20219;&#24847;&#12398;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#23637;&#38283;&#12375;&#12414;&#12377;&#12290;</p><p>gzipped tar &#24418;&#24335;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;&#26041;&#27861;&#20363;:</p><pre class="screen">
3 <code class="prompt">$ </code><span class="command"><strong>gunzip -c findbugs-2.0.3.tar.gz | tar xvf -</strong></span>
4 </pre><p>
5 </p><p>zip &#24418;&#24335;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;&#26041;&#27861;&#20363;:</p><pre class="screen">
6 <code class="prompt">C:\Software&gt;</code><span class="command"><strong>unzip findbugs-2.0.3.zip</strong></span>
7 </pre><p>
8 </p><p>&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12398;&#23637;&#38283;&#12377;&#12427;&#12392;&#12289;&#36890;&#24120;&#12399; <code class="filename">findbugs-2.0.3</code> &#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12364;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540; <code class="filename">C:\Software</code> &#12391;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12434;&#23637;&#38283;&#12377;&#12427;&#12392;&#12289;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540; <code class="filename">C:\Software\findbugs-2.0.3</code> &#12395; <span class="application">FindBugs</span> &#12399;&#23637;&#38283;&#12373;&#12428;&#12414;&#12377;&#12290;&#12371;&#12398;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12364; <span class="application">FindBugs</span> &#12398;&#12507;&#12540;&#12512;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12510;&#12491;&#12517;&#12450;&#12523;&#12391;&#12399;&#12289;&#12371;&#12398;&#12507;&#12540;&#12512;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434; <em class="replaceable"><code>$FINDBUGS_HOME</code></em> (Windows&#12391;&#12399; <em class="replaceable"><code>%FINDBUGS_HOME%</code></em>) &#12434;&#29992;&#12356;&#12390;&#21442;&#29031;&#12375;&#12414;&#12377;&#12290;</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="introduction.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="building.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;3&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="next" href="installing.html" title="&#31532;2&#31456; FindBugs&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="installing.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;"><div class="titlepage"><div><div><h2 class="title"><a name="introduction"></a>&#31532;1&#31456; &#12399;&#12376;&#12417;&#12395;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="introduction.html#d0e74">1. &#24517;&#35201;&#26465;&#20214;</a></span></dt></dl></div><p><span class="application">FindBugs</span>&#8482; &#12399;&#12289;Java &#12503;&#12525;&#12464;&#12521;&#12512;&#12398;&#20013;&#12398;&#12496;&#12464;&#12434;&#35211;&#12388;&#12369;&#12427;&#12503;&#12525;&#12464;&#12521;&#12512;&#12391;&#12377;&#12290;&#12371;&#12398;&#12503;&#12525;&#12464;&#12521;&#12512;&#12399;&#12289;&#12300;&#12496;&#12464; &#12497;&#12479;&#12540;&#12531;&#12301;&#12398;&#23455;&#20363;&#12434;&#25506;&#12375;&#12414;&#12377;&#12290;&#12300;&#12496;&#12464; &#12497;&#12479;&#12540;&#12531;&#12301;&#12392;&#12399;&#12289;&#12456;&#12521;&#12540;&#12392;&#12394;&#12427;&#21487;&#33021;&#24615;&#12398;&#39640;&#12356;&#12467;&#12540;&#12489;&#12398;&#20107;&#20363;&#12391;&#12377;&#12290;</p><p>&#12371;&#12398;&#25991;&#26360;&#12399;&#12289;<span class="application">FindBugs</span> &#12496;&#12540;&#12472;&#12519;&#12531; 2.0.3 &#12395;&#12388;&#12356;&#12390;&#35500;&#26126;&#12375;&#12390;&#12414;&#12377;&#12290;&#31169;&#12383;&#12385;&#12399;&#12289; <span class="application">FindBugs</span> &#12395;&#23550;&#12377;&#12427;&#12501;&#12451;&#12540;&#12489;&#12496;&#12483;&#12463;&#12434;&#24515;&#24453;&#12385;&#12395;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12393;&#12358;&#12382;&#12289; <a class="ulink" href="http://findbugs.sourceforge.net" target="_top"><span class="application">FindBugs</span> Web &#12506;&#12540;&#12472;</a> &#12395;&#12450;&#12463;&#12475;&#12473;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;<span class="application">FindBugs</span> &#12395;&#12388;&#12356;&#12390;&#12398;&#26368;&#26032;&#24773;&#22577;&#12289;&#36899;&#32097;&#20808;&#12362;&#12424;&#12403; <span class="application">FindBugs</span> &#12513;&#12540;&#12522;&#12531;&#12464;&#12522;&#12473;&#12488;&#12394;&#12393;&#12398;&#12469;&#12509;&#12540;&#12488;&#24773;&#22577;&#12434;&#20837;&#25163;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="sect1" title="1. &#24517;&#35201;&#26465;&#20214;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e74"></a>1. &#24517;&#35201;&#26465;&#20214;</h2></div></div></div><p><span class="application">FindBugs</span> &#12434;&#20351;&#29992;&#12377;&#12427;&#12395;&#12399;&#12289; <a class="ulink" href="http://java.sun.com/j2se" target="_top">Java 2 Standard Edition</a>, &#12496;&#12540;&#12472;&#12519;&#12531; 1.5 &#20197;&#38477;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12392;&#20114;&#25563;&#24615;&#12398;&#12354;&#12427;&#12521;&#12531;&#12479;&#12452;&#12512;&#29872;&#22659;&#12364;&#24517;&#35201;&#12391;&#12377;&#12290;<span class="application">FindBugs</span> &#12399;&#12289;&#12503;&#12521;&#12483;&#12488;&#12501;&#12457;&#12540;&#12512;&#38750;&#20381;&#23384;&#12391;&#12354;&#12426;&#12289; GNU/Linux &#12289; Windows &#12289; MacOS X &#12503;&#12521;&#12483;&#12488;&#12501;&#12457;&#12540;&#12512;&#19978;&#12391;&#21205;&#20316;&#12377;&#12427;&#12371;&#12392;&#12364;&#30693;&#12425;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;</p><p><span class="application">FindBugs</span> &#12434;&#20351;&#29992;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289;&#23569;&#12394;&#12367;&#12392;&#12418; 512 MB &#12398;&#12513;&#12514;&#12522;&#12364;&#24517;&#35201;&#12391;&#12377;&#12290;&#24040;&#22823;&#12394;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12434;&#35299;&#26512;&#12377;&#12427;&#12383;&#12417;&#12395;&#12399;&#12289;&#12381;&#12428;&#12424;&#12426;&#22810;&#12367;&#12398;&#12513;&#12514;&#12522;&#12364;&#24517;&#35201;&#12392;&#12373;&#12428;&#12427;&#12371;&#12392;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="installing.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">FindBugs</span>&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;2&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="datamining.html" title="&#31532;12&#31456; FindBugs&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;"><link rel="next" href="acknowledgments.html" title="&#31532;14&#31456; &#35613;&#36766;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="datamining.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="acknowledgments.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;"><div class="titlepage"><div><div><h2 class="title"><a name="license"></a>&#31532;13&#31456; &#12521;&#12452;&#12475;&#12531;&#12473;</h2></div></div></div><p>&#21517;&#31216;&#12300;FindBugs&#12301;&#12362;&#12424;&#12403; FindBugs &#12398;&#12525;&#12468;&#12399;&#12289;&#12513;&#12522;&#12540;&#12521;&#12531;&#12489;&#22823;&#23398;&#12398;&#30331;&#37682;&#21830;&#27161;&#12391;&#12377;&#12290;FindBugs &#12399;&#12501;&#12522;&#12540;&#12477;&#12501;&#12488;&#12454;&#12455;&#12450;&#12391;&#12354;&#12426;&#12289; <a class="ulink" href="http://www.gnu.org/licenses/lgpl.html" target="_top">Lesser GNU Public License</a> &#12398;&#26465;&#20214;&#12391;&#37197;&#24067;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;&#20351;&#29992;&#25215;&#35582;&#26360;&#12434;&#20837;&#25163;&#12375;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289; <span class="application">FindBugs</span> &#37197;&#24067;&#29289;&#12395;&#21547;&#12414;&#12428;&#12427; <code class="filename">LICENSE.txt</code> &#12501;&#12449;&#12452;&#12523;&#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p>&#26368;&#26032;&#12496;&#12540;&#12472;&#12519;&#12531;&#12398; FindBugs &#12362;&#12424;&#12403; &#12381;&#12398;&#12477;&#12540;&#12473;&#12467;&#12540;&#12489;&#12399; <a class="ulink" href="http://findbugs.sourceforge.net" target="_top">FindBugs web &#12506;&#12540;&#12472;</a> &#12391;&#20837;&#25163;&#12391;&#12365;&#12414;&#12377;&#12290;</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datamining.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="acknowledgments.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;12&#31456; <span class="application">FindBugs</span>&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;14&#31456; &#35613;&#36766;</td></tr></table></div></body></html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="annotations.html" title="&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;"><link rel="next" href="datamining.html" title="&#31532;12&#31456; FindBugs&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="annotations.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="datamining.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;"><div class="titlepage"><div><div><h2 class="title"><a name="rejarForAnalysis"></a>&#31532;11&#31456; rejarForAnalysis &#12398;&#20351;&#29992;&#26041;&#27861;</h2></div></div></div><p>&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12395;&#22810;&#12367;&#12398; jar &#12501;&#12449;&#12452;&#12523; &#12364;&#12354;&#12387;&#12383;&#12426;&#12289; jar &#12501;&#12449;&#12452;&#12523;&#12364;&#22810;&#12367;&#12398;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12395;&#28857;&#22312;&#12375;&#12383;&#12426;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289; <span class="command"><strong>rejarForAnalysis </strong></span> &#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#12392; FindBugs &#12398;&#23455;&#34892;&#12364;&#27604;&#36611;&#30340;&#31777;&#21336;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12473;&#12463;&#12522;&#12503;&#12488;&#12399;&#12289;&#25968;&#22810;&#12356; jar &#12501;&#12449;&#12452;&#12523;&#12434;&#38598;&#12417;&#12390; 1 &#12388;&#12398;&#22823;&#12365;&#12394; jar &#12501;&#12449;&#12452;&#12523;&#12395;&#32080;&#21512;&#12375;&#12414;&#12377;&#12290;&#12381;&#12358;&#12377;&#12427;&#12392;&#12289;&#20998;&#26512;&#26178;&#12395;FindBugs &#12395; jar &#12501;&#12449;&#12452;&#12523;&#12434;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#27604;&#36611;&#30340;&#31777;&#21336;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12473;&#12463;&#12522;&#12503;&#12488;&#12399;&#12289; unix &#12471;&#12473;&#12486;&#12512;&#12398; 'find' &#12467;&#12510;&#12531;&#12489;&#12392;&#32068;&#12415;&#21512;&#12431;&#12379;&#12427;&#12392;&#12392;&#12426;&#12431;&#12369;&#26377;&#29992;&#12395;&#12394;&#12426;&#12414;&#12377; ; &#27425;&#12395;&#20363;&#12434;&#31034;&#12375;&#12414;&#12377;&#12290; <span class="command"><strong>find . -name '*.jar' | xargs rejarForAnalysis </strong></span>.</p><p>&#12414;&#12383;&#12289; <span class="command"><strong>rejarForAnalysis</strong></span> &#12473;&#12463;&#12522;&#12503;&#12488;&#12399;&#24040;&#22823;&#12394;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12434;&#35079;&#25968;&#12398; jar &#12501;&#12449;&#12452;&#12523;&#12395;&#20998;&#21106;&#12377;&#12427;&#12371;&#12392;&#12395;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12398;&#12463;&#12521;&#12473;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289;&#35079;&#25968;&#12398; jar &#12501;&#12449;&#12452;&#12523;&#12395;&#22343;&#31561;&#12395;&#37197;&#20998;&#12373;&#12428;&#12414;&#12377;&#12290;&#12371;&#12428;&#12399;&#12289;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20840;&#20307;&#12395;&#23550;&#12375;&#12390; FindBugs &#12434;&#23455;&#34892;&#12377;&#12427;&#12392;&#26178;&#38291;&#12392;&#12513;&#12514;&#12522;&#28040;&#36027;&#12364;&#33879;&#12375;&#12356;&#22580;&#21512;&#12395;&#26377;&#29992;&#12391;&#12377;&#12290;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#20840;&#20307;&#12395;&#23550;&#12375;&#12390; FindBugs &#12434;&#23455;&#34892;&#12377;&#12427;&#20195;&#12431;&#12426;&#12395;&#12289; <span class="command"><strong> rejarForAnalysis</strong></span> &#12391;&#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12434;&#21547;&#12416;&#22823;&#12365;&#12394; jar &#12501;&#12449;&#12452;&#12523;&#12434;&#27083;&#31689;&#12375;&#12414;&#12377;&#12290;&#32154;&#12356;&#12390;&#12289; <span class="command"><strong>rejarForAnalysis</strong></span> &#12434;&#20877;&#12403;&#23455;&#34892;&#12375;&#12390;&#35079;&#25968;&#12398; jar &#12501;&#12449;&#12452;&#12523;&#12395;&#20998;&#21106;&#12375;&#12414;&#12377;&#12290;&#12381;&#12375;&#12390;&#12289;&#21508;&#12293;&#12398; jar &#12501;&#12449;&#12452;&#12523;&#12395;&#23550;&#12375;&#12390;&#38918;&#12395; FindBugs &#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;&#12381;&#12398;&#38555;&#12289; <span class="command"><strong>-auxclasspath</strong></span> &#12395;&#26368;&#21021;&#12395; 1 &#12388;&#12395;&#12414;&#12392;&#12417;&#12383; jar &#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p><p><span class="command"><strong>rejarForAnalysis</strong></span> &#12473;&#12463;&#12522;&#12503;&#12488;&#12395;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#20197;&#19979;&#12395;&#31034;&#12375;&#12414;&#12377; :</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-maxAge</strong></span> <em class="replaceable"><code>&#26085;&#25968;</code></em></span></dt><dd><p>&#26368;&#24460;&#12395;&#26356;&#26032;&#12373;&#12428;&#12383;&#26085;&#12363;&#12425;&#12398;&#32076;&#36942;&#26178;&#38291;&#12434;&#26085;&#21336;&#20301;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377; (&#25351;&#23450;&#12375;&#12383;&#26085;&#25968;&#12424;&#12426;&#21476;&#12356; jar &#12501;&#12449;&#12452;&#12523;&#12399;&#28961;&#35222;&#12373;&#12428;&#12414;&#12377;)&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-inputFileList</strong></span> <em class="replaceable"><code>&#12501;&#12449;&#12452;&#12523;&#21517;</code></em></span></dt><dd><p>jar &#12501;&#12449;&#12452;&#12523;&#21517;&#12434;&#35352;&#36617;&#12375;&#12383;&#12486;&#12461;&#12473;&#12488;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-maxClasses</strong></span> <em class="replaceable"><code>&#12463;&#12521;&#12473;&#25968;</code></em></span></dt><dd><p>analysis*.jar &#12501;&#12449;&#12452;&#12523; 1 &#12501;&#12449;&#12452;&#12523;&#12395;&#23550;&#12377;&#12427;&#12463;&#12521;&#12473;&#12398;&#26368;&#22823;&#25968;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-prefix</strong></span> <em class="replaceable"><code>&#12503;&#12524;&#12501;&#12451;&#12483;&#12463;&#12473;</code></em></span></dt><dd><p>&#20998;&#26512;&#12377;&#12427;&#12463;&#12521;&#12473;&#21517;&#12398;&#12503;&#12524;&#12501;&#12451;&#12483;&#12463;&#12473;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377; (&#20363;&#12289; edu.umd.cs.) &#12290;</p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="annotations.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="datamining.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;10&#31456; &#12450;&#12494;&#12486;&#12540;&#12471;&#12519;&#12531;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;12&#31456; <span class="application">FindBugs</span>&#8482; &#12395;&#12424;&#12427;&#12487;&#12540;&#12479;&#12539;&#12510;&#12452;&#12491;&#12531;&#12464;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="up" href="index.html" title="FindBugs&#8482; &#12510;&#12491;&#12517;&#12450;&#12523;"><link rel="prev" href="building.html" title="&#31532;3&#31456; FindBugs&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;"><link rel="next" href="gui.html" title="&#31532;5&#31456; FindBugs GUI &#12398;&#20351;&#29992;&#26041;&#27861;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">&#31532;4&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="building.html">&#25147;&#12427;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="gui.html">&#27425;&#12408;</a></td></tr></table><hr></div><div class="chapter" title="&#31532;4&#31456; FindBugs&#8482; &#12398;&#23455;&#34892;"><div class="titlepage"><div><div><h2 class="title"><a name="running"></a>&#31532;4&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#23455;&#34892;</h2></div></div></div><div class="toc"><p><b>&#30446;&#27425;</b></p><dl><dt><span class="sect1"><a href="running.html#d0e455">1. &#12463;&#12452;&#12483;&#12463;&#12539;&#12473;&#12479;&#12540;&#12488;</a></span></dt><dt><span class="sect1"><a href="running.html#d0e493">2. <span class="application">FindBugs</span> &#12398;&#36215;&#21205;</a></span></dt><dt><span class="sect1"><a href="running.html#commandLineOptions">3. &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</a></span></dt></dl></div><p><span class="application">FindBugs</span> &#12395;&#12399;2&#12388;&#12398;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12377;&#12394;&#12431;&#12385;&#12289;&#12464;&#12521;&#12501;&#12451;&#12459;&#12523;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473; (GUI) &#12362;&#12424;&#12403; &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12391;&#12377;&#12290;&#12371;&#12398;&#31456;&#12391;&#12399;&#12289;&#12381;&#12428;&#12382;&#12428;&#12398;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12398;&#23455;&#34892;&#26041;&#27861;&#12395;&#12388;&#12356;&#12390;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;</p><div class="warning" title="&#35686;&#21578;" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[&#35686;&#21578;]" src="warning.png"></td><th align="left">&#35686;&#21578;</th></tr><tr><td align="left" valign="top"><p>&#12371;&#12398;&#31456;&#12399;&#12289;&#29694;&#22312;&#26360;&#12365;&#30452;&#12375;&#20013;&#12391;&#12377;&#12290;&#26360;&#12365;&#30452;&#12375;&#12399;&#12414;&#12384;&#23436;&#20102;&#12375;&#12390;&#12356;&#12414;&#12379;&#12435;&#12290;</p></td></tr></table></div><div class="sect1" title="1. &#12463;&#12452;&#12483;&#12463;&#12539;&#12473;&#12479;&#12540;&#12488;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e455"></a>1. &#12463;&#12452;&#12483;&#12463;&#12539;&#12473;&#12479;&#12540;&#12488;</h2></div></div></div><p>Windows &#12471;&#12473;&#12486;&#12512;&#12391; <span class="application">FindBugs</span> &#12434;&#36215;&#21205;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289; <code class="filename"><em class="replaceable"><code>%FINDBUGS_HOME%</code></em>\lib\findbugs.jar</code> &#12501;&#12449;&#12452;&#12523;&#12434;&#12480;&#12502;&#12523;&#12463;&#12522;&#12483;&#12463;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290; <span class="application">FindBugs</span> GUI &#12364;&#36215;&#21205;&#12375;&#12414;&#12377;&#12290;</p><p>Unix &#12289; Linux &#12414;&#12383;&#12399; Mac OS X &#12471;&#12473;&#12486;&#12512;&#12398;&#22580;&#21512;&#12399;&#12289;<code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin/findbugs</code> &#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#23455;&#34892;&#12377;&#12427;&#12363;&#12289;&#20197;&#19979;&#12398;&#12467;&#12510;&#12531;&#12489;&#12434;&#23455;&#34892;&#12375;&#12414;&#12377;&#12290;</p><pre class="screen">
3 <span class="command"><strong>java -jar <em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar</strong></span></pre><p>&#12371;&#12428;&#12391;&#12289; <span class="application">FindBugs</span> GUI &#12364;&#36215;&#21205;&#12375;&#12414;&#12377;&#12290;</p><p>GUI &#12398;&#20351;&#29992;&#26041;&#27861;&#12395;&#12388;&#12356;&#12390;&#12399;&#12289; <a class="xref" href="gui.html" title="&#31532;5&#31456; FindBugs GUI &#12398;&#20351;&#29992;&#26041;&#27861;">5&#31456;<i><span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></div><div class="sect1" title="2. FindBugs &#12398;&#36215;&#21205;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e493"></a>2. <span class="application">FindBugs</span> &#12398;&#36215;&#21205;</h2></div></div></div><p>&#12371;&#12398;&#12475;&#12463;&#12471;&#12519;&#12531;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12398;&#36215;&#21205;&#26041;&#27861;&#12434;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12434;&#36215;&#21205;&#12377;&#12427;&#12395;&#12399;2&#12388;&#12398;&#26041;&#27861;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12377;&#12394;&#12431;&#12385;&#12289;&#30452;&#25509;&#36215;&#21205;&#12377;&#12427;&#26041;&#27861;&#12289;&#12362;&#12424;&#12403;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#26041;&#27861;&#12391;&#12377;&#12290;</p><div class="sect2" title="2.1. FindBugs &#12398;&#30452;&#25509;&#36215;&#21205;"><div class="titlepage"><div><div><h3 class="title"><a name="directInvocation"></a>2.1. <span class="application">FindBugs</span> &#12398;&#30452;&#25509;&#36215;&#21205;</h3></div></div></div><p>&#26368;&#21021;&#12395;&#36848;&#12409;&#12427; <span class="application">FindBugs</span> &#12398;&#36215;&#21205;&#26041;&#27861;&#12399;&#12289; <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar</code> &#12434;&#30452;&#25509;&#23455;&#34892;&#12377;&#12427;&#26041;&#27861;&#12391;&#12377;&#12290;JVM (<span class="command"><strong>java</strong></span>) &#23455;&#34892;&#12503;&#12525;&#12464;&#12521;&#12512;&#12398; <span class="command"><strong>-jar</strong></span> &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12473;&#12452;&#12483;&#12481;&#12434;&#20351;&#29992;&#12375;&#12414;&#12377;&#12290;(<span class="application">FindBugs</span>&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12364; 1.3.5 &#12424;&#12426;&#21069;&#12398;&#22580;&#21512;&#12399;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;)</p><p><span class="application">FindBugs</span> &#12434;&#30452;&#25509;&#36215;&#21205;&#12377;&#12427;&#12383;&#12417;&#12398;&#12289;&#19968;&#33324;&#30340;&#12394;&#27083;&#25991;&#12399;&#20197;&#19979;&#12398;&#12424;&#12358;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;</p><pre class="screen">
4 <span class="command"><strong>java <em class="replaceable"><code>[JVM &#24341;&#25968;]</code></em> -jar <em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar <em class="replaceable"><code>&#12458;&#12503;&#12471;&#12519;&#12531;&#8230;</code></em></strong></span>
5 </pre><p>
6 </p><div class="sect3" title="2.1.1. &#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12398;&#36984;&#25246;"><div class="titlepage"><div><div><h4 class="title"><a name="chooseUI"></a>2.1.1. &#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12398;&#36984;&#25246;</h4></div></div></div><p>1 &#30058;&#30446;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289;&#36215;&#21205;&#12377;&#12427; <span class="application">FindBugs</span> &#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12434;&#36984;&#25246;&#12377;&#12427;&#12383;&#12417;&#12398;&#12418;&#12398;&#12391;&#12377;&#12290;&#25351;&#23450;&#21487;&#33021;&#12394;&#20516;&#12399;&#27425;&#12398;&#36890;&#12426;&#12391;&#12377;:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
7 <span class="command"><strong>-gui</strong></span>: &#12464;&#12521;&#12501;&#12451;&#12459;&#12523;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473; (GUI) &#12434;&#36215;&#21205;&#12375;&#12414;&#12377;&#12290;</p></li><li class="listitem"><p>
8 <span class="command"><strong>-textui</strong></span>: &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12434;&#36215;&#21205;&#12375;&#12414;&#12377;&#12290;</p></li><li class="listitem"><p>
9 <span class="command"><strong>-version</strong></span>: <span class="application">FindBugs</span> &#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#30058;&#21495;&#12434;&#34920;&#31034;&#12375;&#12414;&#12377;&#12290;</p></li><li class="listitem"><p>
10 <span class="command"><strong>-help</strong></span>: <span class="application">FindBugs</span> &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12398;&#12504;&#12523;&#12503;&#24773;&#22577;&#12434;&#34920;&#31034;&#12375;&#12414;&#12377;&#12290;</p></li><li class="listitem"><p>
11 <span class="command"><strong>-gui1</strong></span>: &#26368;&#21021;&#12395;&#20316;&#25104;&#12373;&#12428;&#12383; <span class="application">FindBugs</span> &#12464;&#12521;&#12501;&#12451;&#12459;&#12523;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;(&#12377;&#12391;&#12395;&#24259;&#27490;&#12373;&#12428;&#12469;&#12509;&#12540;&#12488;&#12373;&#12428;&#12390;&#12356;&#12394;&#12356;)&#12434;&#36215;&#21205;&#12375;&#12414;&#12377;&#12290;</p></li></ul></div></div><div class="sect3" title="2.1.2. Java &#20206;&#24819;&#12510;&#12471;&#12531; (JVM) &#24341;&#25968;"><div class="titlepage"><div><div><h4 class="title"><a name="jvmArgs"></a>2.1.2. Java &#20206;&#24819;&#12510;&#12471;&#12531; (JVM) &#24341;&#25968;</h4></div></div></div><p><span class="application">FindBugs</span> &#12434;&#36215;&#21205;&#12377;&#12427;&#38555;&#12395;&#26377;&#29992;&#12394; Java &#20206;&#24819;&#12510;&#12471;&#12531; &#24341;&#25968;&#12434;&#12356;&#12367;&#12388;&#12363;&#32057;&#20171;&#12375;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-Xmx<em class="replaceable"><code>NN</code></em>m</strong></span></span></dt><dd><p>Java &#12498;&#12540;&#12503;&#12469;&#12452;&#12474;&#12398;&#26368;&#22823;&#20516;&#12434; <em class="replaceable"><code>NN</code></em> &#12513;&#12460;&#12496;&#12452;&#12488;&#12395;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12399;&#19968;&#33324;&#30340;&#12395;&#22823;&#23481;&#37327;&#12398;&#12513;&#12514;&#12522;&#12469;&#12452;&#12474;&#12434;&#24517;&#35201;&#12392;&#12375;&#12414;&#12377;&#12290;&#22823;&#12365;&#12394;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12391;&#12399;&#12289; 1500 &#12513;&#12460;&#12496;&#12452;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#12371;&#12392;&#12418;&#29645;&#12375;&#12367;&#12354;&#12426;&#12414;&#12379;&#12435;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-D<em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></strong></span></span></dt><dd><p>Java &#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#24341;&#25968; <span class="command"><strong>-Duser.language=ja</strong></span> &#12434;&#20351;&#29992;&#12377;&#12427;&#12392; GUI &#25991;&#35328;&#12364;&#26085;&#26412;&#35486;&#12391;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd></dl></div></div></div><div class="sect2" title="2.2. &#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12375;&#12383; FindBugs &#12398;&#36215;&#21205;"><div class="titlepage"><div><div><h3 class="title"><a name="wrapperScript"></a>2.2. &#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12375;&#12383; <span class="application">FindBugs</span> &#12398;&#36215;&#21205;</h3></div></div></div><p><span class="application">FindBugs</span> &#12434;&#36215;&#21205;&#12377;&#12427;&#12418;&#12358;&#12402;&#12392;&#12388;&#12398;&#26041;&#27861;&#12399;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#20351;&#29992;&#12377;&#12427;&#26041;&#27861;&#12391;&#12377;&#12290;</p><p>Unix &#31995;&#12398;&#12471;&#12473;&#12486;&#12512;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#12467;&#12510;&#12531;&#12489;&#12391;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#36215;&#21205;&#12375;&#12414;&#12377; :</p><pre class="screen">
12 <code class="prompt">$ </code><span class="command"><strong><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin/findbugs <em class="replaceable"><code>&#12458;&#12503;&#12471;&#12519;&#12531;&#8230;</code></em></strong></span>
13 </pre><p>
14 </p><p>Windows &#12471;&#12473;&#12486;&#12512;&#12395;&#12362;&#12356;&#12390;&#12399;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12434;&#36215;&#21205;&#12377;&#12427;&#12467;&#12510;&#12531;&#12489;&#12399;&#27425;&#12398;&#12424;&#12358;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;</p><pre class="screen">
15 <code class="prompt">C:\My Directory&gt;</code><span class="command"><strong><em class="replaceable"><code>%FINDBUGS_HOME%</code></em>\bin\findbugs.bat <em class="replaceable"><code>&#12458;&#12503;&#12471;&#12519;&#12531;&#8230;</code></em></strong></span>
16 </pre><p>
17 </p><p>Unix &#31995;&#12471;&#12473;&#12486;&#12512; &#12362;&#12424;&#12403; Windows &#12471;&#12473;&#12486;&#12512;&#12398;&#12393;&#12385;&#12425;&#12395;&#12362;&#12356;&#12390;&#12418;&#12289;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540; <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin</code> &#12434;&#29872;&#22659;&#22793;&#25968; <code class="filename">PATH</code> &#12395;&#36861;&#21152;&#12377;&#12427;&#12384;&#12369;&#12391;&#12289; <span class="command"><strong>findbugs</strong></span> &#12467;&#12510;&#12531;&#12489;&#12434;&#20351;&#29992;&#12375;&#12390; FindBugs &#12434;&#36215;&#21205;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="sect3" title="2.2.1. &#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h4 class="title"><a name="wrapperOptions"></a>2.2.1. &#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</h4></div></div></div><p><span class="application">FindBugs</span> &#12398;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12399;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#12469;&#12509;&#12540;&#12488;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;&#12371;&#12428;&#12425;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399; <span class="application">FindBugs</span> &#12503;&#12525;&#12464;&#12521;&#12512; &#33258;&#20307;&#12364;&#25805;&#20316;&#12377;&#12427;&#12398;&#12391;&#12399;<span class="emphasis"><em>&#12394;&#12367;</em></span>&#12289;&#12393;&#12385;&#12425;&#12363;&#12392;&#12356;&#12360;&#12400;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12398;&#26041;&#12364;&#20966;&#29702;&#12434;&#34892;&#12356;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-jvmArgs <em class="replaceable"><code>&#24341;&#25968;</code></em></strong></span></span></dt><dd><p>JVM &#12395;&#21463;&#12369;&#28193;&#12373;&#12428;&#12427;&#24341;&#25968;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#20363;&#12360;&#12400;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394; JVM &#12503;&#12525;&#12497;&#12486;&#12451;&#12364;&#35373;&#23450;&#12391;&#12365;&#12414;&#12377;:</p><pre class="screen">
18 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -jvmArgs "-Duser.language=ja" <em class="replaceable"><code>myApp.jar</code></em></strong></span>
19 </pre><p>
20 </p></dd><dt><span class="term"><span class="command"><strong>-javahome <em class="replaceable"><code>&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;</code></em></strong></span></span></dt><dd><p><span class="application">FindBugs</span> &#12398;&#23455;&#34892;&#12395;&#20351;&#29992;&#12377;&#12427; JRE (Java &#12521;&#12531;&#12479;&#12452;&#12512;&#29872;&#22659;) &#12364;&#12452;&#12531;&#12473;&#12488;&#12540;&#12523;&#12373;&#12428;&#12390;&#12356;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-maxHeap <em class="replaceable"><code>&#12469;&#12452;&#12474;</code></em></strong></span></span></dt><dd><p>Java &#12498;&#12540;&#12503;&#12469;&#12452;&#12474;&#12398;&#26368;&#22823;&#20516;&#12434;&#12513;&#12460;&#12496;&#12452;&#12488;&#21336;&#20301;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12399;&#12289; 256 &#12391;&#12377;&#12290;&#24040;&#22823;&#12394;&#12503;&#12525;&#12464;&#12521;&#12512;&#12420;&#12521;&#12452;&#12502;&#12521;&#12522;&#12434;&#20998;&#26512;&#12377;&#12427;&#12395;&#12399;&#12289;&#12418;&#12387;&#12392;&#22823;&#12365;&#12394;&#12513;&#12514;&#12522;&#12540;&#23481;&#37327;&#12364;&#24517;&#35201;&#12395;&#12394;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-debug</strong></span></span></dt><dd><p>&#12487;&#12451;&#12486;&#12463;&#12479;&#23455;&#34892;&#12362;&#12424;&#12403;&#12463;&#12521;&#12473;&#20998;&#26512;&#12398;&#12488;&#12524;&#12540;&#12473;&#24773;&#22577;&#12364;&#27161;&#28310;&#20986;&#21147;&#12395;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;&#20998;&#26512;&#12364;&#20104;&#26399;&#12379;&#12378;&#22833;&#25943;&#12375;&#12383;&#38555;&#12398;&#12289;&#12488;&#12521;&#12502;&#12523;&#12471;&#12517;&#12540;&#12486;&#12451;&#12531;&#12464;&#12395;&#26377;&#29992;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-property</strong></span> <em class="replaceable"><code>name=value</code></em></span></dt><dd><p>&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#20351;&#29992;&#12375;&#12390;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290; <span class="application">FindBugs</span> &#12399;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;&#12434;&#20351;&#29992;&#12375;&#12390;&#20998;&#26512;&#29305;&#24615;&#12398;&#35373;&#23450;&#12434;&#34892;&#12356;&#12414;&#12377;&#12290;<a class="xref" href="analysisprops.html" title="&#31532;9&#31456; &#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;">9&#31456;<i>&#20998;&#26512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12540;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#35079;&#25968;&#25351;&#23450;&#12375;&#12390;&#12289;&#35079;&#25968;&#12398;&#12471;&#12473;&#12486;&#12512;&#12503;&#12525;&#12497;&#12486;&#12451;&#12434;&#35373;&#23450;&#12377;&#12427;&#12371;&#12392;&#12364;&#21487;&#33021;&#12391;&#12377;&#12290;&#27880;: Windows &#12398;&#22810;&#12367;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&#12391;&#12399;&#12289; <em class="replaceable"><code>name=value</code></em> &#25991;&#23383;&#21015;&#12434;&#24341;&#29992;&#31526;&#12391;&#22258;&#12416;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></dd></dl></div></div></div></div><div class="sect1" title="3. &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="commandLineOptions"></a>3. &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</h2></div></div></div><p>&#12371;&#12398;&#12475;&#12463;&#12471;&#12519;&#12531;&#12391;&#12399;&#12289; <span class="application">FindBugs</span> &#12364;&#12469;&#12509;&#12540;&#12488;&#12377;&#12427;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12395;&#12388;&#12356;&#12390;&#35500;&#26126;&#12375;&#12414;&#12377;&#12290;&#12371;&#12371;&#12391;&#31034;&#12377;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289; <span class="application">FindBugs</span> &#30452;&#25509;&#36215;&#21205;&#12289;&#12414;&#12383;&#12399;&#12289;&#12521;&#12483;&#12503;&#12375;&#12390;&#12356;&#12427;&#12473;&#12463;&#12522;&#12503;&#12488;&#12395;&#12424;&#12427;&#36215;&#21205;&#12391;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="sect2" title="3.1. &#20849;&#36890;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h3 class="title"><a name="d0e778"></a>3.1. &#20849;&#36890;&#12398;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12458;&#12503;&#12471;&#12519;&#12531;</h3></div></div></div><p>&#12371;&#12371;&#12391;&#31034;&#12377;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289; GUI &#12362;&#12424;&#12403; &#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12398;&#20001;&#26041;&#12391;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-effort:min</strong></span></span></dt><dd><p>&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#25351;&#23450;&#12377;&#12427;&#12392;&#12289;&#31934;&#24230;&#12434;&#19978;&#12370;&#12427;&#12383;&#12417;&#12395;&#22823;&#37327;&#12398;&#12513;&#12514;&#12522;&#12540;&#12434;&#28040;&#36027;&#12377;&#12427;&#20998;&#26512;&#12364;&#28961;&#21177;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;<span class="application">FindBugs</span> &#12398;&#23455;&#34892;&#26178;&#12395;&#12513;&#12514;&#12522;&#12540;&#19981;&#36275;&#12395;&#12394;&#12387;&#12383;&#12426;&#12289;&#20998;&#26512;&#12434;&#23436;&#20102;&#12377;&#12427;&#12414;&#12391;&#12395;&#30064;&#24120;&#12395;&#38263;&#12356;&#26178;&#38291;&#12364;&#12363;&#12363;&#12427;&#22580;&#21512;&#12395;&#35430;&#12375;&#12390;&#12415;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-effort:max</strong></span></span></dt><dd><p>&#31934;&#24230;&#12364;&#39640;&#12367;&#12289;&#12424;&#12426;&#22810;&#12367;&#12398;&#12496;&#12464;&#12434;&#26908;&#20986;&#12377;&#12427;&#20998;&#26512;&#12434;&#26377;&#21177;&#12395;&#12375;&#12414;&#12377;&#12290;&#12383;&#12384;&#12375;&#12289;&#22810;&#12367;&#12398;&#12513;&#12514;&#12522;&#12540;&#23481;&#37327;&#12434;&#24517;&#35201;&#12392;&#12375;&#12289;&#12414;&#12383;&#12289;&#23436;&#20102;&#12414;&#12391;&#12398;&#26178;&#38291;&#12364;&#22810;&#12367;&#12363;&#12363;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-project</strong></span> <em class="replaceable"><code>project</code></em></span></dt><dd><p>&#20998;&#26512;&#12377;&#12427;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#25351;&#23450;&#12377;&#12427;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12501;&#12449;&#12452;&#12523;&#12395;&#12399;&#12289; GUI &#12434;&#20351;&#12387;&#12390;&#20316;&#25104;&#12375;&#12383;&#12418;&#12398;&#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#12398;&#25313;&#24373;&#23376;&#12399;&#12289;&#19968;&#33324;&#30340;&#12395;&#12399; <code class="filename">.fb</code> &#12414;&#12383;&#12399; <code class="filename">.fbp</code> &#12391;&#12377;&#12290;</p></dd></dl></div></div><div class="sect2" title="3.2. GUI &#12458;&#12503;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h3 class="title"><a name="d0e818"></a>3.2. GUI &#12458;&#12503;&#12471;&#12519;&#12531;</h3></div></div></div><p>&#12371;&#12371;&#12391;&#31034;&#12377;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289;&#12464;&#12521;&#12501;&#12451;&#12459;&#12523;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12391;&#12398;&#12415;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-look:</strong></span><em class="replaceable"><code>plastic|gtk|native</code></em></span></dt><dd><p>Swing &#12398;&#12523;&#12483;&#12463;&#12539;&#12450;&#12531;&#12489;&#12539;&#12501;&#12451;&#12540;&#12523;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;</p></dd></dl></div><p>
21 </p></div><div class="sect2" title="3.3. &#12486;&#12461;&#12473;&#12488;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12458;&#12503;&#12471;&#12519;&#12531;"><div class="titlepage"><div><div><h3 class="title"><a name="d0e834"></a>3.3. &#12486;&#12461;&#12473;&#12488;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12458;&#12503;&#12471;&#12519;&#12531;</h3></div></div></div><p>&#12371;&#12371;&#12391;&#31034;&#12377;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289;&#12486;&#12461;&#12473;&#12488;&#12518;&#12540;&#12470;&#12540;&#12452;&#12531;&#12479;&#12501;&#12455;&#12540;&#12473;&#12391;&#12398;&#12415;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-sortByClass</strong></span></span></dt><dd><p>&#22577;&#21578;&#12373;&#12428;&#12427;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12434;&#12463;&#12521;&#12473;&#21517;&#12391;&#12477;&#12540;&#12488;&#12375;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-include</strong></span> <em class="replaceable"><code>filterFile.xml</code></em></span></dt><dd><p><em class="replaceable"><code>filterFile.xml</code></em> &#12391;&#25351;&#23450;&#12375;&#12383;&#12501;&#12451;&#12523;&#12479;&#12540;&#12395;&#19968;&#33268;&#12375;&#12383;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12398;&#12415;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;<a class="xref" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;">8&#31456;<i>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-exclude</strong></span> <em class="replaceable"><code>filterFile.xml</code></em></span></dt><dd><p><em class="replaceable"><code>filterFile.xml</code></em> &#12391;&#25351;&#23450;&#12375;&#12383;&#12501;&#12451;&#12523;&#12479;&#12540;&#12395;&#19968;&#33268;&#12375;&#12383;&#12496;&#12464;&#26908;&#32034;&#32080;&#26524;&#12399;&#22577;&#21578;&#12373;&#12428;&#12414;&#12379;&#12435;&#12290;<a class="xref" href="filter.html" title="&#31532;8&#31456; &#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;">8&#31456;<i>&#12501;&#12451;&#12523;&#12479;&#12540;&#12501;&#12449;&#12452;&#12523;</i></a> &#12434;&#21442;&#29031;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-onlyAnalyze</strong></span> <em class="replaceable"><code>com.foobar.MyClass,com.foobar.mypkg.*</code></em></span></dt><dd><p>&#12467;&#12531;&#12510;&#21306;&#20999;&#12426;&#12391;&#25351;&#23450;&#12375;&#12383;&#12463;&#12521;&#12473;&#12362;&#12424;&#12403;&#12497;&#12483;&#12465;&#12540;&#12472;&#12398;&#12415;&#12395;&#38480;&#23450;&#12375;&#12390;&#12289;&#12496;&#12464;&#26908;&#20986;&#12398;&#20998;&#26512;&#12434;&#34892;&#12358;&#12424;&#12358;&#12395;&#12375;&#12414;&#12377;&#12290;&#12501;&#12451;&#12523;&#12479;&#12540;&#12392;&#36949;&#12387;&#12390;&#12289;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#20351;&#12358;&#12392;&#19968;&#33268;&#12375;&#12394;&#12356;&#12463;&#12521;&#12473;&#12362;&#12424;&#12403;&#12497;&#12483;&#12465;&#12540;&#12472;&#12395;&#23550;&#12377;&#12427;&#20998;&#26512;&#12398;&#23455;&#34892;&#12434;&#22238;&#36991;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#22823;&#12365;&#12394;&#12503;&#12525;&#12472;&#12455;&#12463;&#12488;&#12395;&#12362;&#12356;&#12390;&#12289;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#27963;&#29992;&#12377;&#12427;&#12392;&#20998;&#26512;&#12395;&#12363;&#12363;&#12427;&#26178;&#38291;&#12434;&#22823;&#12365;&#12367;&#21066;&#28187;&#12377;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#21487;&#33021;&#24615;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;(&#12375;&#12363;&#12375;&#12394;&#12364;&#12425;&#12289;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12398;&#20840;&#20307;&#12391;&#23455;&#34892;&#12375;&#12390;&#12356;&#12394;&#12356;&#12383;&#12417;&#12395;&#19981;&#27491;&#30906;&#12394;&#32080;&#26524;&#12434;&#20986;&#12375;&#12390;&#12375;&#12414;&#12358;&#12487;&#12451;&#12486;&#12463;&#12479;&#12364;&#12354;&#12427;&#21487;&#33021;&#24615;&#12418;&#12354;&#12426;&#12414;&#12377;&#12290;) &#12463;&#12521;&#12473;&#12399;&#12497;&#12483;&#12465;&#12540;&#12472;&#12418;&#21547;&#12435;&#12384;&#23436;&#20840;&#12394;&#21517;&#21069;&#12434;&#25351;&#23450;&#12377;&#12427;&#24517;&#35201;&#12364;&#12354;&#12426;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12497;&#12483;&#12465;&#12540;&#12472;&#12399;&#12289; Java &#12398; <code class="literal">import</code> &#25991;&#12391;&#12497;&#12483;&#12465;&#12540;&#12472;&#19979;&#12398;&#12377;&#12409;&#12390;&#12398;&#12463;&#12521;&#12473;&#12434;&#12452;&#12531;&#12509;&#12540;&#12488;&#12377;&#12427;&#12392;&#12365;&#12392;&#21516;&#12376;&#26041;&#27861;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290; (&#12377;&#12394;&#12431;&#12385;&#12289;&#12497;&#12483;&#12465;&#12540;&#12472;&#12398;&#23436;&#20840;&#12394;&#21517;&#21069;&#12395; <code class="literal">.*</code> &#12434;&#20184;&#12369;&#21152;&#12360;&#12383;&#24418;&#12391;&#12377;&#12290;)<code class="literal">.*</code> &#12398;&#20195;&#12431;&#12426;&#12395; <code class="literal">.-</code> &#12434;&#25351;&#23450;&#12377;&#12427;&#12392;&#12289;&#12469;&#12502;&#12497;&#12483;&#12465;&#12540;&#12472;&#12418;&#21547;&#12417;&#12390;&#12377;&#12409;&#12390;&#12364;&#20998;&#26512;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-low</strong></span></span></dt><dd><p>&#12377;&#12409;&#12390;&#12398;&#12496;&#12464;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-medium</strong></span></span></dt><dd><p>&#20778;&#20808;&#24230; (&#20013;) &#12362;&#12424;&#12403;&#20778;&#20808;&#24230; (&#39640;) &#12398;&#12496;&#12464;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;&#12371;&#12428;&#12399;&#12289;&#12487;&#12501;&#12457;&#12523;&#12488;&#12398;&#35373;&#23450;&#20516;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-high</strong></span></span></dt><dd><p>&#20778;&#20808;&#24230; (&#39640;) &#12398;&#12496;&#12464;&#12398;&#12415;&#12364;&#22577;&#21578;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-relaxed</strong></span></span></dt><dd><p>&#25163;&#25244;&#12365;&#22577;&#21578;&#12514;&#12540;&#12489;&#12391;&#12377;&#12290;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12434;&#25351;&#23450;&#12377;&#12427;&#12392;&#12289;&#22810;&#12367;&#12398;&#12487;&#12451;&#12486;&#12463;&#12479;&#12395;&#12362;&#12356;&#12390; &#35492;&#26908;&#20986;&#12434;&#22238;&#36991;&#12377;&#12427;&#12383;&#12417;&#12398;&#12498;&#12517;&#12540;&#12522;&#12473;&#12486;&#12451;&#12483;&#12463;&#27231;&#33021;&#12364;&#25233;&#27490;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-xml</strong></span></span></dt><dd><p>&#12496;&#12464;&#22577;&#21578;&#12364; XML &#12391;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;&#20316;&#25104;&#12373;&#12428;&#12383; XML &#12487;&#12540;&#12479;&#12399; &#12289;&#24460;&#12391; GUI &#12391;&#35211;&#12427;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399; <span class="command"><strong>-xml:withMessages</strong></span> &#12392;&#25351;&#23450;&#12377;&#12427;&#12371;&#12392;&#12418;&#12391;&#12365;&#12414;&#12377;&#12290;&#12371;&#12358;&#12377;&#12427;&#12392; &#20986;&#21147; XML &#12395;&#12399; &#21508;&#12496;&#12464;&#12395;&#38306;&#12375;&#12390;&#20154;&#38291;&#12395;&#35501;&#12416;&#12371;&#12392;&#12364;&#12391;&#12365;&#12427;&#12513;&#12483;&#12475;&#12540;&#12472;&#12364;&#21547;&#12414;&#12428;&#12427;&#12424;&#12358;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12391;&#20316;&#25104;&#12373;&#12428;&#12383; XML &#12501;&#12449;&#12452;&#12523;&#12399; &#22577;&#21578;&#26360;&#12395;&#22793;&#25563;&#12377;&#12427;&#12398;&#12364;&#31777;&#21336;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-html</strong></span></span></dt><dd><p>HTML &#20986;&#21147;&#12364;&#29983;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12391;&#12399; <span class="application">FindBugs</span> &#12399; <code class="filename">default.xsl</code> <a class="ulink" href="http://www.w3.org/TR/xslt" target="_top">XSLT</a> &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#20351;&#29992;&#12375;&#12390; HTML &#20986;&#21147;&#12434;&#29983;&#25104;&#12375;&#12414;&#12377;: &#12371;&#12398;&#12501;&#12449;&#12452;&#12523;&#12399;&#12289; <code class="filename">findbugs.jar</code> &#12398;&#20013;&#12289;&#12414;&#12383;&#12399;&#12289; <span class="application">FindBugs</span> &#12398;&#12477;&#12540;&#12473;&#37197;&#24067;&#29289;&#12418;&#12375;&#12367;&#12399;&#12496;&#12452;&#12490;&#12522;&#37197;&#24067;&#29289;&#12398;&#20013;&#12395;&#12354;&#12426;&#12414;&#12377;&#12290;&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12395;&#12399;&#12289;&#27425;&#12398;&#12424;&#12358;&#12394;&#12496;&#12522;&#12456;&#12540;&#12471;&#12519;&#12531;&#12418;&#23384;&#22312;&#12375;&#12414;&#12377;&#12290;&#12377;&#12394;&#12431;&#12385;&#12289; <span class="command"><strong>-html:plain.xsl</strong></span> &#12289; <span class="command"><strong>-html:fancy.xsl</strong></span> &#12362;&#12424;&#12403; <span class="command"><strong>-html:fancy-hist.xsl</strong></span> &#12391;&#12377;&#12290;<code class="filename">plain.xsl</code> &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12399; Javascript &#12420; DOM &#12434;&#21033;&#29992;&#12375;&#12414;&#12379;&#12435;&#12290;&#12375;&#12383;&#12364;&#12387;&#12390;&#12289;&#21476;&#12356;Web &#12502;&#12521;&#12454;&#12470;&#20351;&#29992;&#26178;&#12420;&#21360;&#21047;&#26178;&#12395;&#12418;&#27604;&#36611;&#30340;&#12358;&#12414;&#12367;&#34920;&#31034;&#12373;&#12428;&#12427;&#12391;&#12375;&#12423;&#12358;&#12290;<code class="filename">fancy.xsl</code> &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12399; DOM &#12392; Javascript &#12434;&#21033;&#29992;&#12375;&#12390;&#12490;&#12499;&#12466;&#12540;&#12471;&#12519;&#12531;&#12434;&#34892;&#12356;&#12414;&#12377;&#12290;&#12414;&#12383;&#12289;&#12499;&#12472;&#12517;&#12450;&#12523;&#34920;&#31034;&#12395; CSS &#12434;&#20351;&#29992;&#12375;&#12414;&#12377;&#12290;<span class="command"><strong>fancy-hist.xsl</strong></span> &#12399; <span class="command"><strong>fancy.xsl</strong></span> &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#26356;&#12395;&#36914;&#21270;&#12373;&#12379;&#12383;&#12418;&#12398;&#12391;&#12377;&#12290;DOM &#12420; Javascript &#12434;&#12405;&#12435;&#12384;&#12435;&#12395;&#39366;&#20351;&#12375;&#12390;&#12289;&#12496;&#12464;&#12398;&#19968;&#35239;&#12434;&#21205;&#30340;&#12395;&#12501;&#12451;&#12523;&#12479;&#12522;&#12531;&#12464;&#12375;&#12414;&#12377;&#12290;</p><p>&#12518;&#12540;&#12470;&#12540;&#33258;&#36523;&#12398; XSLT &#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12434;&#29992;&#12356;&#12390; HTML &#12408;&#12398;&#22793;&#25563;&#12434;&#34892;&#12356;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289; <span class="command"><strong>-html:<em class="replaceable"><code>myStylesheet.xsl</code></em></strong></span> &#12398;&#12424;&#12358;&#12395;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12371;&#12371;&#12391;&#12289; <em class="replaceable"><code>myStylesheet.xsl</code></em> &#12399;&#12518;&#12540;&#12470;&#12540;&#12364;&#20351;&#29992;&#12375;&#12383;&#12356;&#12473;&#12479;&#12452;&#12523;&#12471;&#12540;&#12488;&#12398;&#12501;&#12449;&#12452;&#12523;&#21517;&#12391;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-emacs</strong></span></span></dt><dd><p>&#12496;&#12464;&#22577;&#21578;&#12364; Emacs &#24418;&#24335;&#12391;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-xdocs</strong></span></span></dt><dd><p>&#12496;&#12464;&#22577;&#21578;&#12364; xdoc XML &#24418;&#24335;&#12391;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;Apache Maven&#12391;&#20351;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-output</strong></span> <em class="replaceable"><code>&#12501;&#12449;&#12452;&#12523;&#21517;</code></em></span></dt><dd><p>&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12395;&#20986;&#21147;&#32080;&#26524;&#12364;&#20316;&#25104;&#12373;&#12428;&#12414;&#12377;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-outputFile</strong></span> <em class="replaceable"><code>&#12501;&#12449;&#12452;&#12523;&#21517;</code></em></span></dt><dd><p>&#12371;&#12398;&#24341;&#25968;&#12399;&#12289;&#20351;&#29992;&#12377;&#12409;&#12365;&#12391;&#12399;&#12354;&#12426;&#12414;&#12379;&#12435;&#12290;&#20195;&#12431;&#12426;&#12395;&#12289; <span class="command"><strong>-output</strong></span> &#12434;&#20351;&#29992;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-nested</strong></span><em class="replaceable"><code>[:true|false]</code></em></span></dt><dd><p>&#12371;&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;&#12289;&#12501;&#12449;&#12452;&#12523;&#12420;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12398;&#20013;&#12391;&#20837;&#12428;&#23376;&#12395;&#12394;&#12387;&#12383; jar &#12362;&#12424;&#12403; zip &#12501;&#12449;&#12452;&#12523;&#12434;&#20998;&#26512;&#12377;&#12427;&#12363;&#12393;&#12358;&#12363;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#12487;&#12501;&#12457;&#12523;&#12488;&#12391;&#12399;&#12289;&#20837;&#12428;&#23376;&#12395;&#12394;&#12387;&#12383; jar &#12362;&#12424;&#12403; zip &#12501;&#12449;&#12452;&#12523;&#12418;&#20998;&#26512;&#12375;&#12414;&#12377;&#12290;&#20837;&#12428;&#23376;&#12395;&#12394;&#12387;&#12383; jar &#12362;&#12424;&#12403; zip &#12501;&#12449;&#12452;&#12523;&#12398;&#20998;&#26512;&#12377;&#12427;&#12434;&#28961;&#21177;&#12395;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289; <span class="command"><strong>-nested:false</strong></span> &#12434;&#12467;&#12510;&#12531;&#12489;&#12521;&#12452;&#12531;&#24341;&#25968;&#12395;&#36861;&#21152;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;</p></dd><dt><span class="term"><span class="command"><strong>-auxclasspath</strong></span> <em class="replaceable"><code>&#12463;&#12521;&#12473;&#12497;&#12473;</code></em></span></dt><dd><p>&#20998;&#26512;&#26178;&#12395;&#20351;&#29992;&#12377;&#12427;&#35036;&#21161;&#12463;&#12521;&#12473;&#12497;&#12473;&#12434;&#35373;&#23450;&#12375;&#12414;&#12377;&#12290;&#20998;&#26512;&#12377;&#12427;&#12503;&#12525;&#12464;&#12521;&#12512;&#12391;&#20351;&#29992;&#12377;&#12427;jar&#12501;&#12449;&#12452;&#12523;&#12420;&#12463;&#12521;&#12473;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12540;&#12434;&#12377;&#12409;&#12390;&#25351;&#23450;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#35036;&#21161;&#12463;&#12521;&#12473;&#12497;&#12473;&#12395;&#25351;&#23450;&#12375;&#12383;&#12463;&#12521;&#12473;&#12399;&#20998;&#26512;&#12398;&#23550;&#35937;&#12395;&#12399;&#12394;&#12426;&#12414;&#12379;&#12435;&#12290;</p></dd></dl></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="building.html">&#25147;&#12427;</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="gui.html">&#27425;&#12408;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;3&#31456; <span class="application">FindBugs</span>&#8482; &#12398;&#12477;&#12540;&#12523;&#12363;&#12425;&#12398;&#12499;&#12523;&#12489;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#12507;&#12540;&#12512;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;5&#31456; <span class="application">FindBugs</span> GUI &#12398;&#20351;&#29992;&#26041;&#27861;</td></tr></table></div></body></html>
Binary diff not shown
0 <html>
1 <head>
2 <title>FindBugs Links</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs Links</h1>
57
58 <p> This page contains links to related projects,
59 including tools that are similar to FindBugs.
60
61 <h2>FindBugs Add-Ons</h2>
62
63 <ul>
64 <li> <a href="http://fb-contrib.sourceforge.net/">fb-contrib</a>: additional bug detectors for use with
65 FindBugs. The lead FindBugs team does not vouch for the relevance, accuracy or wisdom of the warnings
66 generated by any third-party plugin.
67 <li> <a href="http://www.tobject.de/development/findbugs.html">FindBugs Eclipse plugin</a>.&nbsp;
68 This is now included as part of FindBugs.
69 <!--<li> <a href="http://maven-plugins.sourceforge.net/maven-findbugs-plugin/index.html">Maven FindBugs plugin</a>.&nbsp;-->
70 <!--Maven is a Java project management and project comprehension tool.&nbsp;-->
71 <!--The Maven FindBugs plugin allows FindBugs reports to be generated-->
72 <!--from within Maven.-->
73 <li> <a href="http://mojo.codehaus.org/findbugs-maven-plugin/">Maven2 FindBugs plugin</a>.&nbsp;
74 Maven2 is the latest version of the Java project management and project comprehension tool.&nbsp;
75 The Maven2 FindBugs plugin allows FindBugs reports to be generated
76 from within Maven.
77 <li> <a href="http://qalab.sourceforge.net/">QALab</a> records and aggregates
78 the results of static analysis (including FindBugs results)
79 over time.&nbsp; Features include charts of warnings over time
80 and summary reports showing hot spots in the source code.</li>
81 </ul>
82
83 <h2>Similar Tools</h2>
84
85 <h3>Open source tools</h3>
86
87 <ul>
88 <li> <a href="http://artho.com/jlint/index.shtml">JLint</a>.&nbsp; A static analysis tool
89 to find race conditions, locking errors, null pointer uses,
90 and a number of other problems in Java programs.
91 <li> <a href="http://pmd.sourceforge.net/">PMD</a>.&nbsp; PMD scans Java
92 source code for potential problems.
93 <li> <a href="http://checkstyle.sourceforge.net/">Checkstyle</a>.&nbsp;
94 Checkstyle is a style checker for Java.
95 </ul>
96
97 <h3>Commercial tools and services</h3>
98
99 <ul>
100 <li> <a href="http://www.jutils.com">lint4j</a>: lint tool for Java programs
101 <li> <a href="http://www.parasoft.com/">JTest</a>: automatically generates
102 <a href="http://junit.org/">JUnit</a> tests for Java classes.&nbsp;
103 Also checks for many kinds of coding errors.
104 <li> <a href="http://www.sureshotsoftware.com/javalint/">JiveLint</a>.&nbsp; Another
105 lint utility for Java programs.&nbsp; Finds hashcode/equals problems,
106 string reference comparisons, and more.&nbsp; Free 15 day demo.
107 </ul>
108
109
110 <hr> <p>
111 <script language="JavaScript" type="text/javascript">
112 <!---//hide script from old browsers
113 document.write( "Last updated "+ document.lastModified + "." );
114 //end hiding contents --->
115 </script>
116 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
117 <p>
118 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
119
120 </td>
121
122 </tr></table>
123
124 </body>
125 </html>
0 <html>
1 <head>
2 <title>FindBugs Mailing Lists</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs Mailing Lists</h1>
57
58 <p> There are two mailing lists for FindBugs.
59 <ul>
60 <li> <a href="http://www.cs.umd.edu/mailman/listinfo/findbugs-announce">Findbugs-announce</a>
61 is a low volume (moderated) list for announcements of new releases.
62 </li><li> <a href="http://www.cs.umd.edu/mailman/listinfo/findbugs-discuss">Findbugs-discuss</a>
63 is for discussion of planned features, bugs, development issues, etc.&nbsp; Note
64 that you must be a subscriber in order to post messages to the list.
65 </li>
66 </ul>
67
68
69 <hr> <p>
70 <script language="JavaScript" type="text/javascript">
71 <!---//hide script from old browsers
72 document.write( "Last updated "+ document.lastModified + "." );
73 //end hiding contents --->
74 </script>
75 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
76 <p>
77 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
78
79 </td>
80
81 </tr></table>
82
83 </body>
84 </html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;14.&nbsp;Acknowledgments</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="license.html" title="Chapter&nbsp;13.&nbsp;License"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;14.&nbsp;Acknowledgments</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="license.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;</td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;14.&nbsp;Acknowledgments"><div class="titlepage"><div><div><h2 class="title"><a name="acknowledgments"></a>Chapter&nbsp;14.&nbsp;Acknowledgments</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="acknowledgments.html#d0e3629">1. Contributors</a></span></dt><dt><span class="sect1"><a href="acknowledgments.html#d0e3752">2. Software Used</a></span></dt></dl></div><div class="sect1" title="1.&nbsp;Contributors"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e3629"></a>1.&nbsp;Contributors</h2></div></div></div><p><span class="application">FindBugs</span> was originally written by Bill Pugh (<code class="email">&lt;<a class="email" href="mailto:pugh@cs.umd.edu">pugh@cs.umd.edu</a>&gt;</code>).
3 David Hovemeyer (<code class="email">&lt;<a class="email" href="mailto:daveho@cs.umd.edu">daveho@cs.umd.edu</a>&gt;</code>) implemented some of the
4 detectors, added the Swing GUI, and is a co-maintainer.</p><p>Mike Fagan (<code class="email">&lt;<a class="email" href="mailto:mfagan@tde.com">mfagan@tde.com</a>&gt;</code>) contributed the <span class="application">Ant</span> build script,
5 the <span class="application">Ant</span> task, and several enhancements and bug fixes to the GUI.</p><p>Germano Leichsenring contributed Japanese translations of the bug
6 summaries.</p><p>David Li contributed the Emacs bug report format.</p><p>Peter D. Stout contributed recursive detection of Class-Path
7 attributes in analyzed Jar files, German translations of
8 text used in the Swing GUI, and other fixes.</p><p>Peter Friese wrote the <span class="application">FindBugs</span> Eclipse plugin.</p><p>Rohan Lloyd contributed several Mac OS X enhancements,
9 bug detector improvements,
10 and maintains the Fink package for <span class="application">FindBugs</span>.</p><p>Hiroshi Okugawa translated the <span class="application">FindBugs</span> manual and
11 more of the bug summaries into Japanese.</p><p>Phil Crosby enhanced the Eclipse plugin to add a view
12 to display the bug details.</p><p>Dave Brosius fixed a number of bugs, added user preferences
13 to the Swing GUI, improved several bug detectors, and
14 contributed the string concatenation detector.</p><p>Thomas Klaeger contributed a number of bug fixes and
15 bug detector improvements.</p><p>Andrei Loskutov made a number of improvements to the
16 Eclipse plugin.</p><p>Brian Goetz contributed a major refactoring of the
17 visitor classes to improve readability and understandability.</p><p> Pete Angstadt fixed several problems in the Swing GUI.</p><p>Francis Lalonde provided a task resource file for the
18 FindBugs Ant task.</p><p>Garvin LeClaire contributed support for output in
19 Xdocs format, for use by Maven.</p><p>Holger Stenzhorn contributed improved German translations of items
20 in the Swing GUI.</p><p>Juha Knuutila contributed Finnish translations of items
21 in the Swing GUI.</p><p>Tanel Lebedev contributed Estonian translations of items
22 in the Swing GUI.</p><p>Hanai Shisei (ruimo) contributed full Japanese translations of
23 bug messages, and text used in the Swing GUI.</p><p>David Cotton contributed Fresh translations for bug
24 messages and for the Swing GUI.</p><p>Michael Tamm contributed support for the "errorProperty" attribute
25 in the Ant task.</p><p>Thomas Kuehne improved the German translation of the Swing GUI.</p><p>Len Trigg improved source file support for the Emacs output mode.</p><p>Greg Bentz provided a fix for the hashcode/equals detector.</p><p>K. Hashimoto contributed internationalization fixes and several other
26 bug fixes.</p><p>
27 Glenn Boysko contributed support for ignoring specified local
28 variables in the dead local store detector.
29 </p><p>
30 Jay Dunning contributed a detector to find equality comparisons
31 of floating-point values, and overhauled the analysis summary
32 report and its representation in the saved XML format.
33 </p><p>
34 Olivier Parent contributed updated French translations for bug descriptions and
35 Swing GUI.
36 </p><p>
37 Chris Nappin contributed the <code class="filename">plain.xsl</code>
38 stylesheet.
39 </p><p>
40 Etienne Giraudy contributed the <code class="filename">fancy.xsl</code> and <code class="filename">fancy-hist.xsl</code>
41 stylesheets, and made improvements to the <span class="command"><strong>-xml:withMessages</strong></span>
42 option.
43 </p><p>
44 Takashi Okamoto fixed bugs in the project preferences dialog
45 in the Eclipse plugin, and contributed to its internationalization and localization.
46 </p><p>Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.</p><p>Jeff Knox contributed support for the warningsProperty attribute
47 in the Ant task.</p><p>Peter Hendriks extended the Eclipse plugin preferences,
48 and fixed a bug related to renaming the Eclipse plugin ID.</p><p>Mark McKay contributed an Ant task to launch the findbugs frame.</p><p>Dieter von Holten (dvholten) contributed
49 some German improvements to findbugs_de.properties.</p><p>If you have contributed to <span class="application">FindBugs</span>, but aren't mentioned above,
50 please send email to <code class="email">&lt;<a class="email" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>&gt;</code> (and also accept
51 our humble apologies).</p></div><div class="sect1" title="2.&nbsp;Software Used"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e3752"></a>2.&nbsp;Software Used</h2></div></div></div><p><span class="application">FindBugs</span> uses several open-source software packages, without which its
52 development would have been much more difficult.</p><div class="sect2" title="2.1.&nbsp;BCEL"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3759"></a>2.1.&nbsp;BCEL</h3></div></div></div><p><span class="application">FindBugs</span> includes software developed by the Apache Software Foundation
53 (<a class="ulink" href="http://www.apache.org/" target="_top">http://www.apache.org/</a>).
54 Specifically, it uses the <a class="ulink" href="http://jakarta.apache.org/bcel/" target="_top">Byte Code
55 Engineering Library</a>.</p></div><div class="sect2" title="2.2.&nbsp;ASM"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3772"></a>2.2.&nbsp;ASM</h3></div></div></div><p><span class="application">FindBugs</span> uses the <a class="ulink" href="http://asm.objectweb.org/" target="_top">ASM</a>
56 bytecode framework, which is distributed under the following license:</p><div class="blockquote"><blockquote class="blockquote"><p>
57 Copyright (c) 2000-2005 INRIA, France Telecom
58 All rights reserved.
59 </p><p>
60 Redistribution and use in source and binary forms, with or without
61 modification, are permitted provided that the following conditions
62 are met:
63 </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
64 Redistributions of source code must retain the above copyright
65 notice, this list of conditions and the following disclaimer.
66 </p></li><li class="listitem"><p>
67 Redistributions in binary form must reproduce the above copyright
68 notice, this list of conditions and the following disclaimer in the
69 documentation and/or other materials provided with the distribution.
70 </p></li><li class="listitem"><p>
71 Neither the name of the copyright holders nor the names of its
72 contributors may be used to endorse or promote products derived from
73 this software without specific prior written permission.
74 </p></li></ol></div><p>
75 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
76 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
77 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
78 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
79 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
80 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
81 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
82 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
83 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
84 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
85 THE POSSIBILITY OF SUCH DAMAGE.
86 </p></blockquote></div></div><div class="sect2" title="2.3.&nbsp;DOM4J"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3799"></a>2.3.&nbsp;DOM4J</h3></div></div></div><p><span class="application">FindBugs</span> uses <a class="ulink" href="http://dom4j.org" target="_top">DOM4J</a>, which is
87 distributed under the following license:</p><div class="blockquote"><blockquote class="blockquote"><p>
88 Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
89 </p><p>
90 Redistribution and use of this software and associated documentation
91 ("Software"), with or without modification, are permitted provided that
92 the following conditions are met:
93 </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
94 Redistributions of source code must retain copyright statements and
95 notices. Redistributions must also contain a copy of this document.
96 </p></li><li class="listitem"><p>
97 Redistributions in binary form must reproduce the above copyright
98 notice, this list of conditions and the following disclaimer in the
99 documentation and/or other materials provided with the distribution.
100 </p></li><li class="listitem"><p>
101 The name "DOM4J" must not be used to endorse or promote products
102 derived from this Software without prior written permission
103 of MetaStuff, Ltd. For written permission, please contact
104 <code class="email">&lt;<a class="email" href="mailto:dom4j-info@metastuff.com">dom4j-info@metastuff.com</a>&gt;</code>.
105 </p></li><li class="listitem"><p>
106 Products derived from this Software may not be called "DOM4J" nor may
107 "DOM4J" appear in their names without prior written permission of
108 MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
109 </p></li><li class="listitem"><p>
110 Due credit should be given to the DOM4J Project (<a class="ulink" href="http://dom4j.org/" target="_top">http://dom4j.org/</a>).
111 </p></li></ol></div><p>
112 THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS''
113 AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
114 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
115 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS
116 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
117 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
118 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
119 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
120 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
121 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
122 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
123 </p></blockquote></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="license.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;</td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;13.&nbsp;License&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;9.&nbsp;Analysis Properties</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files"><link rel="next" href="annotations.html" title="Chapter&nbsp;10.&nbsp;Annotations"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;9.&nbsp;Analysis Properties</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="filter.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="annotations.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;9.&nbsp;Analysis Properties"><div class="titlepage"><div><div><h2 class="title"><a name="analysisprops"></a>Chapter&nbsp;9.&nbsp;Analysis Properties</h2></div></div></div><p>
3 <span class="application">FindBugs</span> allows several aspects of the analyses it performs to be
4 customized. System properties are used to configure these options.
5 This chapter describes the configurable analysis options.
6 </p><p>
7 The analysis options have two main purposes. First, they allow you
8 to inform <span class="application">FindBugs</span> about the meaning of methods in your application,
9 so that it can produce more accurate results, or produce fewer
10 false warnings. Second, they allow you to configure the precision
11 of the analysis performed. Reducing analysis precision can save
12 memory and analysis time, at the expense of missing some real bugs,
13 or producing more false warnings.
14 </p><p>
15 The analysis options are set using the <span class="command"><strong>-property</strong></span>
16 command line option. For example:
17 </p><pre class="screen">
18 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -property "cfg.noprune=true" <em class="replaceable"><code>myApp.jar</code></em></strong></span>
19 </pre><p>
20 </p><p>
21 The list of configurable analysis properties is shown in
22 <a class="xref" href="analysisprops.html#analysisproptable" title="Table&nbsp;9.1.&nbsp;Configurable Analysis Properties">Table&nbsp;9.1, &#8220;Configurable Analysis Properties&#8221;</a>.
23 </p><div class="table"><a name="analysisproptable"></a><p class="title"><b>Table&nbsp;9.1.&nbsp;Configurable Analysis Properties</b></p><div class="table-contents"><table summary="Configurable Analysis Properties" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Property Name</th><th align="left">Value</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">findbugs.assertionmethods</td><td align="left">Comma-separated list of fully qualified method names:
24 e.g., "com.foo.MyClass.checkAssertion"</td><td align="left">This property specifies the names of methods that are used
25 to check program assertions. Specifying these methods allows
26 the null pointer dereference bug detector to avoid reporting
27 false warnings for values which are checked by assertion
28 methods.</td></tr><tr><td align="left">findbugs.de.comment</td><td align="left">true or false</td><td align="left">If true, the DroppedException detector scans source code
29 for empty catch blocks for a comment, and if one is found, does
30 not report a warning.</td></tr><tr><td align="left">findbugs.maskedfields.locals</td><td align="left">true or false</td><td align="left">If true, emit low priority warnings for local variables
31 which obscure fields. Default is false.</td></tr><tr><td align="left">findbugs.nullderef.assumensp</td><td align="left">true or false</td><td align="left">not used
32 (intention: If true, the null dereference detector assumes that any
33 reference value returned from a method or passed to a method
34 in a parameter might be null. Default is false. Note that
35 enabling this property will very likely cause a large number
36 of false warnings to be produced.)</td></tr><tr><td align="left">findbugs.refcomp.reportAll</td><td align="left">true or false</td><td align="left">If true, all suspicious reference comparisons
37 using the == and != operators are reported.&nbsp; If false,
38 only one such warning is issued per method.&nbsp; Default
39 is false.</td></tr><tr><td align="left">findbugs.sf.comment</td><td align="left">true or false</td><td align="left">If true, the SwitchFallthrough detector will only report
40 warnings for cases where the source code does not have a comment
41 containing the words "fall" or "nobreak". (An accurate source
42 path must be used for this feature to work correctly.)
43 This helps find cases where the switch fallthrough is likely
44 to be unintentional.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="filter.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="annotations.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;8.&nbsp;Filter Files&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;10.&nbsp;Annotations</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;10.&nbsp;Annotations</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="analysisprops.html" title="Chapter&nbsp;9.&nbsp;Analysis Properties"><link rel="next" href="rejarForAnalysis.html" title="Chapter&nbsp;11.&nbsp;Using rejarForAnalysis"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;10.&nbsp;Annotations</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="analysisprops.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="rejarForAnalysis.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;10.&nbsp;Annotations"><div class="titlepage"><div><div><h2 class="title"><a name="annotations"></a>Chapter&nbsp;10.&nbsp;Annotations</h2></div></div></div><p>
3 <span class="application">FindBugs</span> supports several annotations to express the developer's intent
4 so that FindBugs can issue warnings more appropriately. You need to use
5 Java 5 to use annotations, and must place the annotations.jar and jsr305.jar
6 files in the classpath while compiling your program.
7 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.CheckForNull</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
8 <p>
9 The annotated element might be null, and uses of the element should check for null.
10 When this annotation is applied to a method it applies to the method return value.
11 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.CheckReturnValue</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Method, Constructor
12 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
13 <span class="command"><strong>priority:</strong></span>The priority of the warning (HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
14 </p><p>
15 <span class="command"><strong>explanation:</strong></span>A textual explaination of why the return value should be checked. Default value:"".
16 </p></dd></dl></div><p>
17 This annotation is used to denote a method whose return value should always be checked after invoking the method.
18 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotation</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
19 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
20 <span class="command"><strong>value:</strong></span>Annotation class objects. More than one class can be specified.
21 </p><p>
22 <span class="command"><strong>priority:</strong></span>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
23 </p></dd></dl></div><p>
24 Indicates that all members of the class or package should be annotated with the default
25 value of the supplied annotation classes. This would be used for behavior annotations
26 such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use
27 @DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only
28 on those parameters, methods or fields that you want to allow to be null.
29 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
30 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
31 <span class="command"><strong>value:</strong></span>Annotation class objects. More than one class can be specified.
32 </p><p>
33 <span class="command"><strong>priority:</strong></span>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
34 </p></dd></dl></div><p>
35 This is same as the DefaultAnnotation except it only applys to fields.
36 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
37 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
38 <span class="command"><strong>value:</strong></span>Annotation class objects. More than one class can be specified.
39 </p><p>
40 <span class="command"><strong>priority:</strong></span>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
41 </p></dd></dl></div><p>
42 This is same as the DefaultAnnotation except it only applys to methods.
43 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Package
44 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
45 <span class="command"><strong>value:</strong></span>Annotation class objects. More than one class can be specified.
46 </p><p>
47 <span class="command"><strong>priority:</strong></span>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
48 </p></dd></dl></div><p>
49 This is same as the DefaultAnnotation except it only applys to method parameters.
50 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.NonNull</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
51 <p>
52 The annotated element must not be null.
53 Annotated fields must not be null after construction has completed. Annotated methods must have non-null return values.
54 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.Nullable</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
55 <p>
56 The annotated element could be null under some circumstances. In general, this means
57 developers will have to read the documentation to determine when a null value is
58 acceptable and whether it is neccessary to check for a null value. FindBugs will
59 treat the annotated items as though they had no annotation.
60 </p><p>
61 In pratice this annotation is useful only for overriding an overarching NonNull
62 annotation.
63 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.OverrideMustInvoke</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Method
64 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
65 <span class="command"><strong>value:</strong></span>Specify when the super invocation should be
66 performed (FIRST, ANYTIME, LAST). Default value:ANYTIME.
67 </p></dd></dl></div><p>
68 Used to annotate a method that, if overridden, must (or should) be invoke super
69 in the overriding method. Examples of such methods include finalize() and clone().
70 The argument to the method indicates when the super invocation should occur:
71 at any time, at the beginning of the overriding method, or at the end of the overriding method.
72 (This anotation is not implmemented in FindBugs as of September 8, 2006).
73 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.PossiblyNull</strong></span></span></dt><dd><p>
74 This annotation is deprecated. Use CheckForNull instead.
75 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.SuppressWarnings</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Type, Field, Method, Parameter, Constructor, Package
76 <div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>[Parameter]</strong></span></span></dt><dd><p>
77 <span class="command"><strong>value:</strong></span>The name of the warning. More than one name can be specified.
78 </p><p>
79 <span class="command"><strong>justification:</strong></span>Reason why the warning should be ignored. Default value:"".
80 </p></dd></dl></div><p>
81 The set of warnings that are to be suppressed by the compiler in the annotated element.
82 Duplicate names are permitted. The second and successive occurrences of a name are ignored.
83 The presence of unrecognized warning names is <span class="emphasis"><em>not</em></span> an error: Compilers
84 must ignore any warning names they do not recognize. They are, however, free to emit a
85 warning if an annotation contains an unrecognized warning name. Compiler vendors should
86 document the warning names they support in conjunction with this annotation type. They
87 are encouraged to cooperate to ensure that the same names work across multiple compilers.
88 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.UnknownNullness</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
89 <p>
90 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
91 </p></dd><dt><span class="term"><span class="command"><strong>edu.umd.cs.findbugs.annotations.UnknownNullness</strong></span></span></dt><dd><span class="command"><strong>[Target]</strong></span> Field, Method, Parameter
92 <p>
93 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
94 </p></dd></dl></div><p>
95 <span class="application">FindBugs</span> also supports the following annotations:
96 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">net.jcip.annotations.GuardedBy</li><li class="listitem">net.jcip.annotations.Immutable</li><li class="listitem">net.jcip.annotations.NotThreadSafe</li><li class="listitem">net.jcip.annotations.ThreadSafe</li></ul></div><p>
97 </p><p>
98 You can refer the JCIP annotation <a class="ulink" href="http://jcip.net/annotations/doc/index.html" target="_top">
99 API documentation</a> at <a class="ulink" href="http://jcip.net/" target="_top">Java Concurrency in Practice</a>.
100 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="analysisprops.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="rejarForAnalysis.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;9.&nbsp;Analysis Properties&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;11.&nbsp;Using rejarForAnalysis</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="gui.html" title="Chapter&nbsp;5.&nbsp;Using the FindBugs GUI"><link rel="next" href="eclipse.html" title="Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gui.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="eclipse.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task"><div class="titlepage"><div><div><h2 class="title"><a name="anttask"></a>Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="anttask.html#d0e1205">1. Installing the <span class="application">Ant</span> task</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1243">2. Modifying build.xml</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1314">3. Executing the task</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1339">4. Parameters</a></span></dt></dl></div><p>
3 This chapter describes how to integrate <span class="application">FindBugs</span> into a build script
4 for <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a>, which is a popular Java build
5 and deployment tool. Using the <span class="application">FindBugs</span> <span class="application">Ant</span> task, your build script can
6 automatically run <span class="application">FindBugs</span> on your Java code.
7 </p><p>
8 The <span class="application">Ant</span> task was generously contributed by Mike Fagan.
9 </p><div class="sect1" title="1.&nbsp;Installing the Ant task"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1205"></a>1.&nbsp;Installing the <span class="application">Ant</span> task</h2></div></div></div><p>
10 To install the <span class="application">Ant</span> task, simply copy <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs-ant.jar</code>
11 into the <code class="filename">lib</code> subdirectory of your <span class="application">Ant</span> installation.
12
13 </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>It is strongly recommended that you use the <span class="application">Ant</span> task with the version
14 of <span class="application">FindBugs</span> it was included with. We do not guarantee that the <span class="application">Ant</span> task Jar file
15 will work with any version of <span class="application">FindBugs</span> other than the one it was included with.</p></td></tr></table></div><p>
16 </p></div><div class="sect1" title="2.&nbsp;Modifying build.xml"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1243"></a>2.&nbsp;Modifying build.xml</h2></div></div></div><p>
17 To incorporate <span class="application">FindBugs</span> into <code class="filename">build.xml</code> (the build script
18 for <span class="application">Ant</span>), you first need to add a task definition. This should appear as follows:
19
20 </p><pre class="screen">
21 &lt;taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/&gt;
22 </pre><p>
23
24 The task definition specifies that when a <code class="literal">findbugs</code> element is
25 seen in <code class="filename">build.xml</code>, it should use the indicated class to execute the task.
26 </p><p>
27 After you have added the task definition, you can define a target
28 which uses the <code class="literal">findbugs</code> task. Here is an example
29 which could be added to the <code class="filename">build.xml</code> for the
30 Apache <a class="ulink" href="http://jakarta.apache.org/bcel/" target="_top">BCEL</a> library.
31
32 </p><pre class="screen">
33 &lt;property name="findbugs.home" value="/export/home/daveho/work/findbugs" /&gt;
34
35 &lt;target name="findbugs" depends="jar"&gt;
36 &lt;findbugs home="${findbugs.home}"
37 output="xml"
38 outputFile="bcel-fb.xml" &gt;
39 &lt;auxClasspath path="${basedir}/lib/Regex.jar" /&gt;
40 &lt;sourcePath path="${basedir}/src/java" /&gt;
41 &lt;class location="${basedir}/bin/bcel.jar" /&gt;
42 &lt;/findbugs&gt;
43 &lt;/target&gt;
44 </pre><p>
45
46 The <code class="literal">findbugs</code> element must have the <code class="literal">home</code>
47 attribute set to the directory in which <span class="application">FindBugs</span> is installed; in other words,
48 <em class="replaceable"><code>$FINDBUGS_HOME</code></em>. See <a class="xref" href="installing.html" title="Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;">Chapter&nbsp;2, <i>Installing <span class="application">FindBugs</span>&#8482;</i></a>.
49 </p><p>
50 This target will execute <span class="application">FindBugs</span> on <code class="filename">bcel.jar</code>, which is the
51 Jar file produced by BCEL's build script. (By making it depend on the "jar"
52 target, we ensure that the library is fully compiled before running <span class="application">FindBugs</span> on it.)
53 The output of <span class="application">FindBugs</span> will be saved in XML format to a file called
54 <code class="filename">bcel-fb.xml</code>.
55 An auxiliary Jar file, <code class="filename">Regex.jar</code>, is added to the aux classpath,
56 because it is referenced by the main BCEL library. A source path is specified
57 so that the saved bug data will have accurate references to the BCEL source code.
58 </p></div><div class="sect1" title="3.&nbsp;Executing the task"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1314"></a>3.&nbsp;Executing the task</h2></div></div></div><p>
59 Here is an example of invoking <span class="application">Ant</span> from the command line, using the <code class="literal">findbugs</code>
60 target defined above.
61
62 </p><pre class="screen">
63 <code class="prompt">[daveho@noir]$</code> <span class="command"><strong>ant findbugs</strong></span>
64 Buildfile: build.xml
65
66 init:
67
68 compile:
69
70 examples:
71
72 jar:
73
74 findbugs:
75 [findbugs] Running FindBugs...
76 [findbugs] Bugs were found
77 [findbugs] Output saved to bcel-fb.xml
78
79 BUILD SUCCESSFUL
80 Total time: 35 seconds
81 </pre><p>
82
83 In this case, because we saved the bug results in an XML file, we can
84 use the <span class="application">FindBugs</span> GUI to view the results; see <a class="xref" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">Chapter&nbsp;4, <i>Running <span class="application">FindBugs</span>&#8482;</i></a>.
85 </p></div><div class="sect1" title="4.&nbsp;Parameters"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1339"></a>4.&nbsp;Parameters</h2></div></div></div><p>This section describes the parameters that may be specified when
86 using the <span class="application">FindBugs</span> task.
87
88 </p><div class="variablelist"><dl><dt><span class="term"><code class="literal">class</code></span></dt><dd><p>
89 A optional nested element specifying which classes to analyze. The <code class="literal">class</code>
90 element must specify a <code class="literal">location</code> attribute which names the
91 archive file (jar, zip, etc.), directory, or class file to be analyzed. Multiple <code class="literal">class</code>
92 elements may be specified as children of a single <code class="literal">findbugs</code> element.
93 </p><p>In addition to or instead of specifying a <code class="literal">class</code> element,
94 the <span class="application">FindBugs</span> task can contain one or more <code class="literal">fileset</code> element(s) that
95 specify files to be analyzed.
96 For example, you might use a fileset to specify that all of the jar files in a directory
97 should be analyzed.
98 </p></dd><dt><span class="term"><code class="literal">auxClasspath</code></span></dt><dd><p>
99 An optional nested element which specifies a classpath (Jar files or directories)
100 containing classes used by the analyzed library or application, but which
101 you don't want to analyze. It is specified the same way as
102 <span class="application">Ant</span>'s <code class="literal">classpath</code> element for the Java task.
103 </p></dd><dt><span class="term"><code class="literal">sourcePath</code></span></dt><dd><p>
104 An optional nested element which specifies a source directory path
105 containing source files used to compile the Java code being analyzed.
106 By specifying a source path, any generated XML bug output will have
107 complete source information, which allows later viewing in the
108 GUI.
109 </p></dd><dt><span class="term"><code class="literal">home</code></span></dt><dd><p>
110 A required attribute.
111 It must be set to the name of the directory where <span class="application">FindBugs</span> is installed.
112 </p></dd><dt><span class="term"><code class="literal">quietErrors</code></span></dt><dd><p>
113 An optional boolean attribute.
114 If true, reports of serious analysis errors and missing classes will
115 be suppressed in the <span class="application">FindBugs</span> output. Default is false.
116 </p></dd><dt><span class="term"><code class="literal">reportLevel</code></span></dt><dd><p>
117 An optional attribute. It specifies
118 the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs.
119 If set to "medium" (the default), low confidence issues are supressed.
120 If set to "high", only high confidence bugs are reported.
121 </p></dd><dt><span class="term"><code class="literal">output</code></span></dt><dd><p>
122 Optional attribute.
123 It specifies the output format. If set to "xml" (the default), output
124 is in XML format.
125 If set to "xml:withMessages", output is in XML format augmented with
126 human-readable messages. (You should use this format if you plan
127 to generate a report using an XSL stylesheet.)
128 If set to "html", output is in HTML formatted (default stylesheet is default.xsl).
129 If set to "text", output is in ad-hoc text format.
130 If set to "emacs", output is in <a class="ulink" href="http://www.gnu.org/software/emacs/" target="_top">Emacs</a> error message format.
131 If set to "xdocs", output is xdoc XML for use with Apache Maven.
132 </p></dd><dt><span class="term"><code class="literal">stylesheet</code></span></dt><dd><p>
133 Optional attribute.
134 It specifies the stylesheet to use to generate html output when the output is set to html.
135 Stylesheets included in the FindBugs distribution include default.xsl, fancy.xsl, fancy-hist.xsl, plain.xsl, and summary.xsl.
136 The default value, if no stylesheet attribute is provided, is default.xsl.
137
138 </p></dd><dt><span class="term"><code class="literal">sort</code></span></dt><dd><p>
139 Optional attribute. If the <code class="literal">output</code> attribute
140 is set to "text", then the <code class="literal">sort</code> attribute specifies
141 whether or not reported bugs are sorted by class. Default is true.
142 </p></dd><dt><span class="term"><code class="literal">outputFile</code></span></dt><dd><p>
143 Optional attribute. If specified, names the output file in which the
144 <span class="application">FindBugs</span> output will be saved. By default, the output is displayed
145 directly by <span class="application">Ant</span>.
146 </p></dd><dt><span class="term"><code class="literal">debug</code></span></dt><dd><p>
147 Optional boolean attribute. If set to true, <span class="application">FindBugs</span> prints diagnostic
148 information about which classes are being analyzed, and which bug pattern
149 detectors are being run. Default is false.
150 </p></dd><dt><span class="term"><code class="literal">effort</code></span></dt><dd><p>
151 Set the analysis effort level. The value specified should be
152 one of <code class="literal">min</code>, <code class="literal">default</code>,
153 or <code class="literal">max</code>. See <a class="xref" href="running.html#commandLineOptions" title="3.&nbsp;Command-line Options">Section&nbsp;3, &#8220;Command-line Options&#8221;</a>
154 for more information about setting the analysis level.
155 </p></dd><dt><span class="term"><code class="literal">conserveSpace</code></span></dt><dd><p>Synonym for effort="min".</p></dd><dt><span class="term"><code class="literal">workHard</code></span></dt><dd><p>Synonym for effort="max".</p></dd><dt><span class="term"><code class="literal">visitors</code></span></dt><dd><p>
156 Optional attribute. It specifies a comma-separated list of bug detectors
157 which should be run. The bug detectors are specified by their class names,
158 without any package qualification. By default, all detectors which are
159 not disabled by default are run.
160 </p></dd><dt><span class="term"><code class="literal">omitVisitors</code></span></dt><dd><p>
161 Optional attribute. It is like the <code class="literal">visitors</code> attribute,
162 except it specifies detectors which will <span class="emphasis"><em>not</em></span> be run.
163 </p></dd><dt><span class="term"><code class="literal">excludeFilter</code></span></dt><dd><p>
164 Optional attribute. It specifies the filename of a filter specifying bugs
165 to exclude from being reported. See <a class="xref" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files">Chapter&nbsp;8, <i>Filter Files</i></a>.
166 </p></dd><dt><span class="term"><code class="literal">includeFilter</code></span></dt><dd><p>
167 Optional attribute. It specifies the filename of a filter specifying
168 which bugs are reported. See <a class="xref" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files">Chapter&nbsp;8, <i>Filter Files</i></a>.
169 </p></dd><dt><span class="term"><code class="literal">projectFile</code></span></dt><dd><p>
170 Optional attribute. It specifies the name of a project file.
171 Project files are created by the <span class="application">FindBugs</span> GUI, and specify classes,
172 aux classpath entries, and source directories. By naming a project,
173 you don't need to specify any <code class="literal">class</code> elements,
174 nor do you need to specify <code class="literal">auxClasspath</code> or
175 <code class="literal">sourcePath</code> attributes.
176 See <a class="xref" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">Chapter&nbsp;4, <i>Running <span class="application">FindBugs</span>&#8482;</i></a> for how to create a project.
177 </p></dd><dt><span class="term"><code class="literal">jvmargs</code></span></dt><dd><p>
178 Optional attribute. It specifies any arguments that should be passed
179 to the Java virtual machine used to run <span class="application">FindBugs</span>. You may need to
180 use this attribute to specify flags to increase the amount of memory
181 the JVM may use if you are analyzing a very large program.
182 </p></dd><dt><span class="term"><code class="literal">systemProperty</code></span></dt><dd><p>
183 Optional nested element. If specified, defines a system property.
184 The <code class="literal">name</code> attribute specifies the name of the
185 system property, and the <code class="literal">value</code> attribute specifies
186 the value of the system property.
187 </p></dd><dt><span class="term"><code class="literal">timeout</code></span></dt><dd><p>
188 Optional attribute. It specifies the amount of time, in milliseconds,
189 that the Java process executing <span class="application">FindBugs</span> may run before it is
190 assumed to be hung and is terminated. The default is 600,000
191 milliseconds, which is ten minutes. Note that for very large
192 programs, <span class="application">FindBugs</span> may require more than ten minutes to complete its
193 analysis.
194 </p></dd><dt><span class="term"><code class="literal">failOnError</code></span></dt><dd><p>
195 Optional boolean attribute. Whether to abort the build process if there is an
196 error running <span class="application">FindBugs</span>. Defaults to "false"
197 </p></dd><dt><span class="term"><code class="literal">errorProperty</code></span></dt><dd><p>
198 Optional attribute which specifies the name of a property that
199 will be set to "true" if an error occurs while running <span class="application">FindBugs</span>.
200 </p></dd><dt><span class="term"><code class="literal">warningsProperty</code></span></dt><dd><p>
201 Optional attribute which specifies the name of a property
202 that will be set to "true" if any warnings are reported by
203 <span class="application">FindBugs</span> on the analyzed program.
204 </p></dd><dt><span class="term"><code class="literal">userPreferencesFile</code></span></dt><dd><p>
205 Optional attribute. Set the path of the user preferences file to use, which might override some of the options abobe.
206 Specifying <code class="literal">userPreferencesFile</code> as first argument would mean some later
207 options will override them, as last argument would mean they will override some previous options).
208 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
209 line execution.
210 </p></dd></dl></div><p>
211
212
213 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gui.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="eclipse.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;5.&nbsp;Using the <span class="application">FindBugs</span> GUI&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="installing.html" title="Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;"><link rel="next" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="installing.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="running.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source"><div class="titlepage"><div><div><h2 class="title"><a name="building"></a>Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="building.html#d0e173">1. Prerequisites</a></span></dt><dt><span class="sect1"><a href="building.html#d0e262">2. Extracting the Source Distribution</a></span></dt><dt><span class="sect1"><a href="building.html#d0e275">3. Modifying <code class="filename">local.properties</code></a></span></dt><dt><span class="sect1"><a href="building.html#d0e333">4. Running <span class="application">Ant</span></a></span></dt><dt><span class="sect1"><a href="building.html#d0e427">5. Running <span class="application">FindBugs</span>&#8482; from a source directory</a></span></dt></dl></div><p>
3 This chapter describes how to build <span class="application">FindBugs</span> from source code. Unless you are
4 interesting in modifying <span class="application">FindBugs</span>, you will probably want to skip to the
5 <a class="link" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">next chapter</a>.
6 </p><div class="sect1" title="1.&nbsp;Prerequisites"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e173"></a>1.&nbsp;Prerequisites</h2></div></div></div><p>
7 To compile <span class="application">FindBugs</span> from source, you will need the following:
8 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
9 The <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download" target="_top"><span class="application">FindBugs</span> source distribution</a>
10 </p></li><li class="listitem"><p>
11 <a class="ulink" href="http://java.sun.com/j2se/" target="_top">JDK 1.5.0 or later</a>
12 </p></li><li class="listitem"><p>
13 <a class="ulink" href="http://ant.apache.org/" target="_top">Apache <span class="application">Ant</span></a>, version 1.6.3 or later
14 </p></li></ul></div><p>
15 </p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>
16 The version of <span class="application">Ant</span> included as <code class="filename">/usr/bin/ant</code> on
17 Redhat Linux systems will <span class="emphasis"><em>not</em></span> work for compiling
18 <span class="application">FindBugs</span>. We recommend you install a binary distribution of <span class="application">Ant</span>
19 downloaded from the <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span> website</a>.
20 Make sure that when you run <span class="application">Ant</span> your <em class="replaceable"><code>JAVA_HOME</code></em>
21 environment variable points to the directory in which you installed
22 JDK 1.5 (or later).
23 </p></td></tr></table></div><p>
24 If you want to be able to generate formatted versions of the <span class="application">FindBugs</span> documentation,
25 you will also need the following software:
26 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
27 The <a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/index.html" target="_top">DocBook XSL Stylesheets</a>.
28 These are required to convert the <span class="application">FindBugs</span> manual into HTML format.
29 </p></li><li class="listitem"><p>
30 The <a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT Processor</a>.
31 (Also required for converting the <span class="application">FindBugs</span> manual to HTML.)
32 </p></li></ul></div><p>
33 </p></div><div class="sect1" title="2.&nbsp;Extracting the Source Distribution"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e262"></a>2.&nbsp;Extracting the Source Distribution</h2></div></div></div><p>
34 After you download the source distribution, you'll need to extract it into
35 a working directory. A typical command to do this is:
36
37 </p><pre class="screen">
38 <code class="prompt">$ </code><span class="command"><strong>unzip findbugs-2.0.3-source.zip</strong></span>
39 </pre><p>
40
41 </p></div><div class="sect1" title="3.&nbsp;Modifying local.properties"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e275"></a>3.&nbsp;Modifying <code class="filename">local.properties</code></h2></div></div></div><p>
42 If you intend to build the FindBugs documentation,
43 you will need to modify the <code class="filename">local.properties</code> file
44 used by the <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a>
45 <code class="filename">build.xml</code> file to build <span class="application">FindBugs</span>.
46 If you do not want to build the FindBugs documentation, then you
47 can ignore this file.
48 </p><p>
49 The <code class="filename">local.properties</code> overrides definitions
50 in the <code class="filename">build.properties</code> file.
51 The <code class="filename">build.properties</code> file looks something like this:
52 </p><pre class="programlisting">
53
54 # User Configuration:
55 # This section must be modified to reflect your system.
56
57 local.software.home =/export/home/daveho/linux
58
59 # Set this to the directory containing the DocBook Modular XSL Stylesheets
60 # from http://docbook.sourceforge.net/projects/xsl/
61
62 xsl.stylesheet.home =${local.software.home}/docbook/docbook-xsl-1.71.1
63
64 # Set this to the directory where Saxon (http://saxon.sourceforge.net/)
65 # is installed.
66
67 saxon.home =${local.software.home}/java/saxon-6.5.5
68
69 </pre><p>
70 </p><p>
71 The <code class="varname">xsl.stylesheet.home</code> property specifies the full
72 path to the directory where you have installed the
73 <a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/" target="_top">DocBook Modular XSL
74 Stylesheets</a>. You only need to specify this property if you will be
75 generating the <span class="application">FindBugs</span> documentation.
76 </p><p>
77 The <code class="varname">saxon.home</code> property is the full path to the
78 directory where you installed the <a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT Processor</a>.
79 You only need to specify this property if you will be
80 generating the <span class="application">FindBugs</span> documentation.
81 </p></div><div class="sect1" title="4.&nbsp;Running Ant"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e333"></a>4.&nbsp;Running <span class="application">Ant</span></h2></div></div></div><p>
82 Once you have extracted the source distribution,
83 made sure that <span class="application">Ant</span> is installed,
84 modified <code class="filename">build.properties</code> (optional),
85 and configured the tools (such as <span class="application">Saxon</span>),
86 you are ready to build <span class="application">FindBugs</span>. Invoking <span class="application">Ant</span> is a simple matter
87 of running the command
88 </p><pre class="screen">
89 <code class="prompt">$ </code><span class="command"><strong>ant <em class="replaceable"><code>target</code></em></strong></span>
90 </pre><p>
91 where <em class="replaceable"><code>target</code></em> is one of the following:
92 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>build</strong></span></span></dt><dd><p>
93 This target compiles the code for <span class="application">FindBugs</span>. It is the default target.
94 </p></dd><dt><span class="term"><span class="command"><strong>docs</strong></span></span></dt><dd><p>
95 This target formats the documentation. (It also compiles some of
96 the source code as a side-effect.)
97 </p></dd><dt><span class="term"><span class="command"><strong>runjunit</strong></span></span></dt><dd><p>
98 This target compiles and runs the internal JUnit tests included
99 in <span class="application">FindBugs</span>. It will print an error message if any unit
100 tests fail.
101 </p></dd><dt><span class="term"><span class="command"><strong>bindist</strong></span></span></dt><dd><p>
102 Builds a binary distribution of <span class="application">FindBugs</span>.
103 The target creates both <code class="filename">.zip</code> and
104 <code class="filename">.tar.gz</code> archives.
105 </p></dd></dl></div><p>
106 </p><p>
107 After running an <span class="application">Ant</span> command, you should see output similar to
108 the following (after some other messages regarding the tasks that
109 <span class="application">Ant</span> is running):
110 </p><pre class="screen">
111 <code class="computeroutput">
112 BUILD SUCCESSFUL
113 Total time: 17 seconds
114 </code>
115 </pre><p>
116 </p></div><div class="sect1" title="5.&nbsp;Running FindBugs&#8482; from a source directory"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e427"></a>5.&nbsp;Running <span class="application">FindBugs</span>&#8482; from a source directory</h2></div></div></div><p>
117 The <span class="application">Ant</span> build script for <span class="application">FindBugs</span> is written such that after
118 building the <span class="command"><strong>build</strong></span> target, the working directory
119 is set up just like a binary distribution. So, the information about
120 running <span class="application">FindBugs</span> in <a class="xref" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">Chapter&nbsp;4, <i>Running <span class="application">FindBugs</span>&#8482;</i></a>
121 applies to source distributions, too.
122 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="installing.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="running.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;2.&nbsp;Installing <span class="application">FindBugs</span>&#8482;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;4.&nbsp;Running <span class="application">FindBugs</span>&#8482;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;12.&nbsp;Data mining of bugs with FindBugs&#8482;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="rejarForAnalysis.html" title="Chapter&nbsp;11.&nbsp;Using rejarForAnalysis"><link rel="next" href="license.html" title="Chapter&nbsp;13.&nbsp;License"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;12.&nbsp;Data mining of bugs with <span class="application">FindBugs</span>&#8482;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rejarForAnalysis.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="license.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;12.&nbsp;Data mining of bugs with FindBugs&#8482;"><div class="titlepage"><div><div><h2 class="title"><a name="datamining"></a>Chapter&nbsp;12.&nbsp;Data mining of bugs with <span class="application">FindBugs</span>&#8482;</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="datamining.html#commands">1. Commands</a></span></dt><dt><span class="sect1"><a href="datamining.html#examples">2. Examples</a></span></dt><dt><span class="sect1"><a href="datamining.html#antexample">3. Ant example</a></span></dt></dl></div><p>
3 FindBugs incorporates an ability to perform sophisticated queries on bug
4 databases and track warnings across multiple versions of code being
5 studied, allowing you to do things such as seeing when a bug was first introduced, examining
6 just the warnings that have been introduced since the last release, or graphing the number
7 of infinite recursive loops in your code over time.</p><p>
8 These techniques all depend upon the XML format used by FindBugs for storing warnings.
9 These XML files usually contain just the warnings from one particular analysis run, but
10 they can also store the results from analyzing a sequence of software builds or versions.
11 </p><p>
12 Any FindBugs XML bug database contains a version name and timestamp.
13 FindBugs tries to compute a timestamp from the timestamps of the files that
14 are analyzed (e.g., the timestamp is intended to be the time the class files
15 were generated, not analyzed). Each bug database also contains a version name.
16 Both the version name and timestamp can be set manually using the
17 <span class="command"><strong>setBugDatabaseInfo</strong></span> (<a class="xref" href="datamining.html#setBugDatabaseInfo" title="1.7.&nbsp;setBugDatabaseInfo">Section&nbsp;1.7, &#8220;setBugDatabaseInfo&#8221;</a>) command.
18 </p><p>A multiversion bug database assigns a sequence number to each version of
19 the analyzed code. These sequence numbers are simply successive integers,
20 starting at 0 (e.g., a bug database for 4 versions of the code will contain
21 versions 0..3). The bug database will also record the name and timestamp for
22 each version. The <span class="command"><strong>filterBugs</strong></span> command allows you to refer
23 to a version by sequence number, name or timestamp.</p><p>
24 You can take a sequence (or pair) of single version bug databases and create
25 from them a multiversion bug database, or combine a multiversion bug database
26 with a sequence of later single-version bug databases.</p><p>
27 Some of these commands can be invoked as ant tasks. See below for specifics
28 on how to invoke them and what attributes and arguments they take. All of
29 the examples assume that the <code class="literal">findbugs.lib</code>
30 <code class="literal">refid</code> is set correctly. Here is one way to set it:
31 </p><pre class="programlisting">
32
33 &lt;!-- findbugs task definition --&gt;
34 &lt;property name="findbugs.home" value="/your/path/to/findbugs" /&gt;
35 &lt;path id="findbugs.lib"&gt;
36 &lt;fileset dir="${findbugs.home}/lib"&gt;
37 &lt;include name="findbugs-ant.jar"/&gt;
38 &lt;/fileset&gt;
39 &lt;/path&gt;
40
41 </pre><div class="sect1" title="1.&nbsp;Commands"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="commands"></a>1.&nbsp;Commands</h2></div></div></div><p>
42 All tools for FindBugs data mining are can be invoked from the command line,
43 and some of the more useful tools can also be invoked from an
44 ant build file.</p><p>
45 Briefly, the command-line tools are:</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#unionBugs" title="1.1.&nbsp;unionBugs">unionBugs</a></strong></span></span></dt><dd><p>
46 combine the results from separate analysis of disjoint
47 classes
48 </p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#computeBugHistory" title="1.2.&nbsp;computeBugHistory">computeBugHistory</a></strong></span></span></dt><dd><p>Merge bug warnings from multiple versions of
49 analyzed code into
50 a single multiversion bug database. This can either be used
51 to add more versions to an existing multiversion database,
52 or to create a multiversion database from a sequence of single version
53 bug warning databases.</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#setBugDatabaseInfo" title="1.7.&nbsp;setBugDatabaseInfo">setBugDatabaseInfo</a></strong></span></span></dt><dd><p>Set information such as the revision name or
54 timestamp in an XML bug database</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#listBugDatabaseInfo" title="1.8.&nbsp;listBugDatabaseInfo">listBugDatabaseInfo</a></strong></span></span></dt><dd><p>List information such as the revision name and
55 timestamp for a list of XML bug databases</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#filterBugs" title="1.3.&nbsp;filterBugs">filterBugs</a></strong></span></span></dt><dd><p>Select a subset of a bug database</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#mineBugHistory" title="1.4.&nbsp;mineBugHistory">mineBugHistory</a></strong></span></span></dt><dd><p>Generate a tabular listing of the number of warnings in each
56 version of a multiversion bug database</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#defectDensity" title="1.5.&nbsp;defectDensity">defectDensity</a></strong></span></span></dt><dd><p>List information about defect density
57 (warnings per 1000 NCSS)
58 for the entire project and each class and package</p></dd><dt><span class="term"><span class="command"><strong><a class="link" href="datamining.html#convertXmlToText" title="1.6.&nbsp;convertXmlToText">convertXmlToText</a></strong></span></span></dt><dd><p>Convert bug warnings in XML format to
59 a textual one-line-per-bug format, or to HTML</p></dd></dl></div><div class="sect2" title="1.1.&nbsp;unionBugs"><div class="titlepage"><div><div><h3 class="title"><a name="unionBugs"></a>1.1.&nbsp;unionBugs</h3></div></div></div><p>
60 If you have, for example, separately analyzing each jar file used in an application,
61 you can use this command to combine the separately generated xml bug warning files into
62 a single file containing all of the warnings.</p><p>Do <span class="emphasis"><em>not</em></span> use this command to combine results from analyzing different versions of the same
63 file; use <span class="command"><strong>computeBugHistory</strong></span> instead.</p><p>Specify the xml files on the command line. The result is sent to standard output.</p></div><div class="sect2" title="1.2.&nbsp;computeBugHistory"><div class="titlepage"><div><div><h3 class="title"><a name="computeBugHistory"></a>1.2.&nbsp;computeBugHistory</h3></div></div></div><p>Use this command to generate a bug database containing information from different builds or versions
64 of software you are analyzing.
65 History is taken from the first file provided as input; any following
66 files should be single version bug databases (if they contain history, the history in those
67 files will be ignored).</p><p>By default, output is written to the standard output.
68 </p><p>This functionality may also can be accessed from ant.
69 First create a taskdef for <span class="command"><strong>computeBugHistory</strong></span> in your
70 build file:
71 </p><pre class="programlisting">
72
73 &lt;taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"&gt;
74 &lt;classpath refid="findbugs.lib" /&gt;
75 &lt;/taskdef&gt;
76
77 </pre><p>Attributes for this ant task are listed in the following table.
78 To specify input files, nest them inside with a
79 <code class="literal">&lt;datafile&gt;</code> element. For example:
80 </p><pre class="programlisting">
81
82 &lt;computeBugHistory home="${findbugs.home}" ...&gt;
83 &lt;datafile name="analyze1.xml"/&gt;
84 &lt;datafile name="analyze2.xml"/&gt;
85 &lt;/computeBugHistory&gt;
86
87 </pre><div class="table"><a name="computeBugHistoryTable"></a><p class="title"><b>Table&nbsp;12.1.&nbsp;Options for computeBugHistory command</b></p><div class="table-contents"><table summary="Options for computeBugHistory command" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Command-line option</th><th align="left">Ant attribute</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">-output &lt;file&gt;</td><td align="left">output="&lt;file&gt;"</td><td align="left">save output in the named file (may also be an input file)</td></tr><tr><td align="left">-overrideRevisionNames[:truth]</td><td align="left">overrideRevisionNames="[true|false]"</td><td align="left">override revision names for each version with names computed from the filenames</td></tr><tr><td align="left">-noPackageMoves[:truth]</td><td align="left">noPackageMoves="[true|false]"</td><td align="left">if a class has moved to another package, treat warnings in that class as seperate</td></tr><tr><td align="left">-preciseMatch[:truth]</td><td align="left">preciseMatch="[true|false]"</td><td align="left">require bug patterns to match precisely</td></tr><tr><td align="left">-precisePriorityMatch[:truth]</td><td align="left">precisePriorityMatch="[true|false]"</td><td align="left">consider two warnings as the same only if priorities match exactly</td></tr><tr><td align="left">-quiet[:truth]</td><td align="left">quiet="[true|false]"</td><td align="left">don't generate any output to standard out unless there is an error</td></tr><tr><td align="left">-withMessages[:truth]</td><td align="left">withMessages="[true|false]"</td><td align="left">include human-readable messages describing the warnings in XML output</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.3.&nbsp;filterBugs"><div class="titlepage"><div><div><h3 class="title"><a name="filterBugs"></a>1.3.&nbsp;filterBugs</h3></div></div></div><p>This command is used to select a subset of warnings from a FindBugs XML warning file
88 and write the selected subset to a new FindBugs warning file.</p><p>
89 This command takes a sequence of options, and either zero, one or two
90 filenames of findbugs xml bug files on the command line.</p><p>If no file names are provided, the command reads from standard input
91 and writes to standard output. If one file name is provided,
92 it reads from the file and writes to standard output.
93 If two file names are provided, it reads from the first and writes the output
94 to the second file name.</p><p>This functionality may also can be accessed from ant.
95 First create a taskdef for <span class="command"><strong>filterBugs</strong></span> in your
96 build file:
97 </p><pre class="programlisting">
98
99 &lt;taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask"&gt;
100 &lt;classpath refid="findbugs.lib" /&gt;
101 &lt;/taskdef&gt;
102
103 </pre><p>Attributes for this ant task are listed in the following table.
104 To specify an input file either use the input attribute or nest it inside
105 the ant call with a <code class="literal">&lt;datafile&gt;</code> element. For example:
106 </p><pre class="programlisting">
107
108 &lt;filterBugs home="${findbugs.home}" ...&gt;
109 &lt;datafile name="analyze.xml"/&gt;
110 &lt;/filterBugs&gt;
111
112 </pre><div class="table"><a name="filterOptionsTable"></a><p class="title"><b>Table&nbsp;12.2.&nbsp;Options for filterBugs command</b></p><div class="table-contents"><table summary="Options for filterBugs command" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Command-line option</th><th align="left">Ant attribute</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">use file as input</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">output results to file</td></tr><tr><td align="left">-not</td><td align="left">not="[true|false]"</td><td align="left">reverse (all) switches for the filter</td></tr><tr><td align="left">-withSource[:truth]</td><td align="left">withSource="[true|false]"</td><td align="left">only warnings for switch source is available</td></tr><tr><td align="left">-exclude &lt;filter file&gt;</td><td align="left">exclude="&lt;filter file&gt;"</td><td align="left">exclude bugs matching given filter</td></tr><tr><td align="left">-include &lt;filter file&gt;</td><td align="left">include="&lt;filter file&gt;"</td><td align="left">include only bugs matching given filter</td></tr><tr><td align="left">-annotation &lt;text&gt;</td><td align="left">annotation="&lt;text&gt;"</td><td align="left">allow only warnings containing this text in a manual annotation</td></tr><tr><td align="left">-after &lt;when&gt;</td><td align="left">after="&lt;when&gt;"</td><td align="left">allow only warnings that first occurred after this version</td></tr><tr><td align="left">-before &lt;when&gt;</td><td align="left">before="&lt;when&gt;"</td><td align="left">allow only warnings that first occurred before this version</td></tr><tr><td align="left">-first &lt;when&gt;</td><td align="left">first="&lt;when&gt;"</td><td align="left">allow only warnings that first occurred in this version</td></tr><tr><td align="left">-last &lt;when&gt;</td><td align="left">last="&lt;when&gt;"</td><td align="left">allow only warnings that last occurred in this version</td></tr><tr><td align="left">-fixed &lt;when&gt;</td><td align="left">fixed="&lt;when&gt;"</td><td align="left">allow only warnings that last occurred in the previous version (clobbers <code class="option">-last</code>)</td></tr><tr><td align="left">-present &lt;when&gt;</td><td align="left">present="&lt;when&gt;"</td><td align="left">allow only warnings present in this version</td></tr><tr><td align="left">-absent &lt;when&gt;</td><td align="left">absent="&lt;when&gt;"</td><td align="left">allow only warnings absent in this version</td></tr><tr><td align="left">-active[:truth]</td><td align="left">active="[true|false]"</td><td align="left">allow only warnings alive in the last sequence number</td></tr><tr><td align="left">-introducedByChange[:truth]</td><td align="left">introducedByChange="[true|false]"</td><td align="left">allow only warnings introduced by a change of an existing class</td></tr><tr><td align="left">-removedByChange[:truth]</td><td align="left">removedByChange="[true|false]"</td><td align="left">allow only warnings removed by a change of a persisting class</td></tr><tr><td align="left">-newCode[:truth]</td><td align="left">newCode="[true|false]"</td><td align="left">allow only warnings introduced by the addition of a new class</td></tr><tr><td align="left">-removedCode[:truth]</td><td align="left">removedCode="[true|false]"</td><td align="left">allow only warnings removed by removal of a class</td></tr><tr><td align="left">-priority &lt;level&gt;</td><td align="left">priority="&lt;level&gt;"</td><td align="left">allow only warnings with this priority or higher</td></tr><tr><td align="left">-maxRank &lt;rank&gt;</td><td align="left">rank="[1..20]"</td><td align="left">allow only warnings with this rank or lower</td></tr><tr><td align="left">-class &lt;pattern&gt;</td><td align="left">class="&lt;class&gt;"</td><td align="left">allow only bugs whose primary class name matches this pattern</td></tr><tr><td align="left">-bugPattern &lt;pattern&gt;</td><td align="left">bugPattern="&lt;pattern&gt;"</td><td align="left">allow only bugs whose type matches this pattern</td></tr><tr><td align="left">-category &lt;category&gt;</td><td align="left">category="&lt;category&gt;"</td><td align="left">allow only warnings with a category that starts with this string</td></tr><tr><td align="left">-designation &lt;designation&gt;</td><td align="left">designation="&lt;designation&gt;"</td><td align="left">allow only warnings with this designation (e.g., -designation SHOULD_FIX)</td></tr><tr><td align="left">-withMessages[:truth] </td><td align="left">withMessages="[true|false]"</td><td align="left">the generated XML should contain textual messages</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.4.&nbsp;mineBugHistory"><div class="titlepage"><div><div><h3 class="title"><a name="mineBugHistory"></a>1.4.&nbsp;mineBugHistory</h3></div></div></div><p>This command generates a table containing counts of the numbers of warnings
113 in each version of a multiversion bug database.</p><p>This functionality may also can be accessed from ant.
114 First create a taskdef for <span class="command"><strong>mineBugHistory</strong></span> in your
115 build file:
116 </p><pre class="programlisting">
117
118 &lt;taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"&gt;
119 &lt;classpath refid="findbugs.lib" /&gt;
120 &lt;/taskdef&gt;
121
122 </pre><p>Attributes for this ant task are listed in the following table.
123 To specify an input file either use the <code class="literal">input</code>
124 attribute or nest it inside the ant call with a
125 <code class="literal">&lt;datafile&gt;</code> element. For example:
126 </p><pre class="programlisting">
127
128 &lt;mineBugHistory home="${findbugs.home}" ...&gt;
129 &lt;datafile name="analyze.xml"/&gt;
130 &lt;/mineBugHistory&gt;
131
132 </pre><div class="table"><a name="mineBugHistoryOptionsTable"></a><p class="title"><b>Table&nbsp;12.3.&nbsp;Options for mineBugHistory command</b></p><div class="table-contents"><table summary="Options for mineBugHistory command" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Command-line option</th><th align="left">Ant attribute</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">use file as input</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">write output to file</td></tr><tr><td align="left">-formatDates</td><td align="left">formatDates="[true|false]"</td><td align="left">render dates in textual form</td></tr><tr><td align="left">-noTabs</td><td align="left">noTabs="[true|false]"</td><td align="left">delimit columns with groups of spaces instead of tabs (see below)</td></tr><tr><td align="left">-summary</td><td align="left">summary="[true|false]"</td><td align="left">output terse summary of changes over the last ten entries</td></tr></tbody></table></div></div><br class="table-break"><p>
133 The <code class="option">-noTabs</code> output can be easier to read from a shell
134 with a fixed-width font.
135 Because numeric columns are right-justified, spaces may precede the
136 first column value. This option also causes <code class="option">-formatDates</code>
137 to render dates in terser format without embedded whitespace.
138 </p><p>The table is a tab-separated (barring <code class="option">-noTabs</code>)
139 table with the following columns:</p><div class="table"><a name="mineBugHistoryColumns"></a><p class="title"><b>Table&nbsp;12.4.&nbsp;Columns in mineBugHistory output</b></p><div class="table-contents"><table summary="Columns in mineBugHistory output" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">Title</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">seq</td><td align="left">Sequence number (successive integers, starting at 0)</td></tr><tr><td align="left">version</td><td align="left">Version name</td></tr><tr><td align="left">time</td><td align="left">Release timestamp</td></tr><tr><td align="left">classes</td><td align="left">Number of classes analyzed</td></tr><tr><td align="left">NCSS</td><td align="left">Non Commenting Source Statements</td></tr><tr><td align="left">added</td><td align="left">Count of new warnings for a class that existed in the previous version</td></tr><tr><td align="left">newCode</td><td align="left">Count of new warnings for a class that did not exist in the previous version</td></tr><tr><td align="left">fixed</td><td align="left">Count of warnings removed from a class that remains in the current version</td></tr><tr><td align="left">removed</td><td align="left">Count of warnings in the previous version for a class that is not present in the current version</td></tr><tr><td align="left">retained</td><td align="left">Count of warnings that were in both the previous and current version</td></tr><tr><td align="left">dead</td><td align="left">Warnings that were present in earlier versions but in neither the current version or the immediately preceeding version</td></tr><tr><td align="left">active</td><td align="left">Total warnings present in the current version</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.5.&nbsp;defectDensity"><div class="titlepage"><div><div><h3 class="title"><a name="defectDensity"></a>1.5.&nbsp;defectDensity</h3></div></div></div><p>
140 This command lists information about defect density (warnings per 1000 NCSS) for the entire project and each class and package.
141 It can either be invoked with no files specified on the command line (in which case it reads from standard input)
142 or with one file specified on the command line.</p><p>It generates a table with the following columns, and with one
143 row for the entire project, and one row for each package or class that contains at least
144 4 warnings.</p><div class="table"><a name="defectDensityColumns"></a><p class="title"><b>Table&nbsp;12.5.&nbsp;Columns in defectDensity output</b></p><div class="table-contents"><table summary="Columns in defectDensity output" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">Title</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">kind</td><td align="left">project, package or class</td></tr><tr><td align="left">name</td><td align="left">The name of the project, package or class</td></tr><tr><td align="left">density</td><td align="left">Number of warnings generated per 1000 lines of NCSS.</td></tr><tr><td align="left">bugs</td><td align="left">Number of warnings</td></tr><tr><td align="left">NCSS</td><td align="left">Calculated number of NCSS</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.6.&nbsp;convertXmlToText"><div class="titlepage"><div><div><h3 class="title"><a name="convertXmlToText"></a>1.6.&nbsp;convertXmlToText</h3></div></div></div><p>
145 This command converts a warning collection in XML format to a text
146 format with one line per warning, or to HTML.
147 </p><p>This functionality may also can be accessed from ant.
148 First create a taskdef for <span class="command"><strong>convertXmlToText</strong></span> in your
149 build file:
150 </p><pre class="programlisting">
151
152 &lt;taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask"&gt;
153 &lt;classpath refid="findbugs.lib" /&gt;
154 &lt;/taskdef&gt;
155
156 </pre><p>Attributes for this ant task are listed in the following table.</p><div class="table"><a name="convertXmlToTextTable"></a><p class="title"><b>Table&nbsp;12.6.&nbsp;Options for convertXmlToText command</b></p><div class="table-contents"><table summary="Options for convertXmlToText command" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Command-line option</th><th align="left">Ant attribute</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;filename&gt;"</td><td align="left">use file as input</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;filename&gt;"</td><td align="left">output results to file</td></tr><tr><td align="left">-longBugCodes</td><td align="left">longBugCodes="[true|false]"</td><td align="left">use the full bug pattern code instead of two-letter abbreviation</td></tr><tr><td align="left">&nbsp;</td><td align="left">format="text"</td><td align="left">generate plain text output with one bug per line (command-line default)</td></tr><tr><td align="left">-html[:stylesheet]</td><td align="left">format="html:&lt;stylesheet&gt;"</td><td align="left">generate output with specified stylesheet (see below), or default.xsl if unspecified</td></tr></tbody></table></div></div><br class="table-break"><p>
157 You may specify plain.xsl, default.xsl, fancy.xsl, fancy-hist.xsl,
158 or your own XSL stylesheet for the -html/format option.
159 Despite the name of this option, you may specify
160 a stylesheet that emits something other than html.
161 When applying a stylesheet other than those included
162 with FindBugs (listed above), the -html/format option should be used
163 with a path or URL to the stylesheet.
164 </p></div><div class="sect2" title="1.7.&nbsp;setBugDatabaseInfo"><div class="titlepage"><div><div><h3 class="title"><a name="setBugDatabaseInfo"></a>1.7.&nbsp;setBugDatabaseInfo</h3></div></div></div><p>
165 This command sets meta-information in a specified warning collection.
166 It takes the following options:
167 </p><p>This functionality may also can be accessed from ant.
168 First create a taskdef for <span class="command"><strong>setBugDatabaseInfo</strong></span> in your
169 build file:
170 </p><pre class="programlisting">
171
172 &lt;taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"&gt;
173 &lt;classpath refid="findbugs.lib" /&gt;
174 &lt;/taskdef&gt;
175
176 </pre><p>Attributes for this ant task are listed in the following table.
177 To specify an input file either use the <code class="literal">input</code>
178 attribute or nest it inside the ant call with a
179 <code class="literal">&lt;datafile&gt;</code> element. For example:
180 </p><pre class="programlisting">
181
182 &lt;setBugDatabaseInfo home="${findbugs.home}" ...&gt;
183 &lt;datafile name="analyze.xml"/&gt;
184 &lt;/setBugDatabaseInfo&gt;
185
186 </pre><div class="table"><a name="setBugDatabaseInfoOptions"></a><p class="title"><b>Table&nbsp;12.7.&nbsp;setBugDatabaseInfo Options</b></p><div class="table-contents"><table summary="setBugDatabaseInfo Options" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Command-line option</th><th align="left">Ant attribute</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">&nbsp;</td><td align="left">input="&lt;file&gt;"</td><td align="left">use file as input</td></tr><tr><td align="left">&nbsp;</td><td align="left">output="&lt;file&gt;"</td><td align="left">write output to file</td></tr><tr><td align="left">-name &lt;name&gt;</td><td align="left">name="&lt;name&gt;"</td><td align="left">set name for (last) revision</td></tr><tr><td align="left">-timestamp &lt;when&gt;</td><td align="left">timestamp="&lt;when&gt;"</td><td align="left">set timestamp for (last) revision</td></tr><tr><td align="left">-source &lt;directory&gt;</td><td align="left">source="&lt;directory&gt;"</td><td align="left">add specified directory to the source search path</td></tr><tr><td align="left">-findSource &lt;directory&gt;</td><td align="left">findSource="&lt;directory&gt;"</td><td align="left">find and add all relevant source directions contained within specified directory</td></tr><tr><td align="left">-suppress &lt;filter file&gt;</td><td align="left">suppress="&lt;filter file&gt;"</td><td align="left">suppress warnings matched by this file (replaces previous suppressions)</td></tr><tr><td align="left">-withMessages</td><td align="left">withMessages="[true|false]"</td><td align="left">add textual messages to XML</td></tr><tr><td align="left">-resetSource</td><td align="left">resetSource="[true|false]"</td><td align="left">remove all source search paths</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="1.8.&nbsp;listBugDatabaseInfo"><div class="titlepage"><div><div><h3 class="title"><a name="listBugDatabaseInfo"></a>1.8.&nbsp;listBugDatabaseInfo</h3></div></div></div><p>This command takes a list of zero or more xml bug database filenames on the command line.
187 If zero file names are provided, it reads from standard input and does not generate
188 a table header.</p><p>There is only one option: <code class="option">-formatDates</code> renders dates
189 in textual form.
190 </p><p>The output is a table one row per bug database and the following columns:</p><div class="table"><a name="listBugDatabaseInfoColumns"></a><p class="title"><b>Table&nbsp;12.8.&nbsp;listBugDatabaseInfo Columns</b></p><div class="table-contents"><table summary="listBugDatabaseInfo Columns" border="1"><colgroup><col><col></colgroup><thead><tr><th align="left">Column</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left">version</td><td align="left">version name</td></tr><tr><td align="left">time</td><td align="left">Release timestamp</td></tr><tr><td align="left">classes</td><td align="left">Number of classes analyzed</td></tr><tr><td align="left">NCSS</td><td align="left">Non Commenting Source Statements analyzed</td></tr><tr><td align="left">total</td><td align="left">Total number of warnings of all kinds</td></tr><tr><td align="left">high</td><td align="left">Total number of high priority warnings of all kinds</td></tr><tr><td align="left">medium</td><td align="left">Total number of medium/normal priority warnings of all kinds</td></tr><tr><td align="left">low</td><td align="left">Total number of low priority warnings of all kinds</td></tr><tr><td align="left">filename</td><td align="left">filename of database</td></tr></tbody></table></div></div><br class="table-break"></div></div><div class="sect1" title="2.&nbsp;Examples"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="examples"></a>2.&nbsp;Examples</h2></div></div></div><div class="sect2" title="2.1.&nbsp;Mining history using proveded shell scrips"><div class="titlepage"><div><div><h3 class="title"><a name="unixscriptsexamples"></a>2.1.&nbsp;Mining history using proveded shell scrips</h3></div></div></div><p>In all of the following, the commands are given in a directory that contains
191 directories jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60.</p><p>You can use the command:</p><pre class="screen">
192 computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
193 </pre><p>to generate the following output:</p><pre class="screen">
194 seq version time classes NCSS added newCode fixed removed retained dead active
195 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4
196 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4
197 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2
198 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1
199 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1
200 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1
201 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1
202 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1
203 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1
204 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1
205 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1
206 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1
207 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1
208 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1
209 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1
210 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1
211 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1
212 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2
213 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2
214 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2
215 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2
216 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2
217 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3
218 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5
219 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5
220 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5
221 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5
222 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5
223 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4
224 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4
225 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3
226 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3
227 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3
228 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4
229 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4
230 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4
231 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3
232 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3
233 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3
234 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3
235 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3
236 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3
237 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3
238 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3
239 </pre><p>
240 We could also generate that information directly, without creating an intermediate db.xml file, using the command
241 </p><pre class="screen">
242 computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
243 </pre><p>We can then use that information to display a graph showing the number of infinite recursive loops
244 found by FindBugs in each build of Sun's JDK1.6.0. The blue area indicates the number of infinite
245 recursive loops in that build, the red area above it indicates the number of infinite recursive loops that existed
246 in some previous version but not in the current version (thus, the combined height of the red and blue areas
247 is guaranteed to never decrease, and goes up whenever a new infinite recursive loop bug is introduced). The height
248 of the red area is computed as the sum of the fixed, removed and dead values for each version.
249 The reductions in builds 13 and 14 came after Sun was notified about the bugs found by FindBugs in the JDK.
250 </p><div class="mediaobject"><img src="infiniteRecursiveLoops.png"></div><p>
251 Given the db.xml file that contains the results for all the jdk1.6.0 builds, the following command will show the history of high and medium priority correctness warnings:
252 </p><pre class="screen">
253 filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
254 </pre><p>
255 generating the table:
256 </p><pre class="screen">
257 seq version time classes NCSS added newCode fixed removed retained dead active
258 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075
259 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075
260 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072
261 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072
262 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071
263 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070
264 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070
265 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069
266 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069
267 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066
268 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065
269 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065
270 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034
271 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034
272 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034
273 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035
274 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035
275 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036
276 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070
277 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070
278 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070
279 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070
280 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110
281 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253
282 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253
283 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253
284 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246
285 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246
286 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263
287 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244
288 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388
289 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388
290 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399
291 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422
292 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435
293 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433
294 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422
295 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422
296 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420
297 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397
298 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397
299 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397
300 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398
301 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398
302 44 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396
303 </pre></div><div class="sect2" title="2.2.&nbsp;Incremental history maintenance"><div class="titlepage"><div><div><h3 class="title"><a name="incrementalhistory"></a>2.2.&nbsp;Incremental history maintenance</h3></div></div></div><p>
304 If db.xml contains the results of running findbugs over builds b12 - b60, we can update db.xml to include the results of analyzing b61 with the commands:
305 </p><pre class="screen">
306 computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
307 </pre></div></div><div class="sect1" title="3.&nbsp;Ant example"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="antexample"></a>3.&nbsp;Ant example</h2></div></div></div><p>
308 Here is a complete ant script example for both running findbugs and running a chain of data-mining tools afterward:
309 </p><pre class="screen">
310
311 &lt;project name="analyze_asm_util" default="findbugs"&gt;
312 &lt;!-- findbugs task definition --&gt;
313 &lt;property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" /&gt;
314 &lt;property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" /&gt;
315
316 &lt;path id="findbugs.lib"&gt;
317 &lt;fileset dir="${findbugs.home}/lib"&gt;
318 &lt;include name="findbugs-ant.jar"/&gt;
319 &lt;/fileset&gt;
320 &lt;/path&gt;
321
322 &lt;taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"&gt;
323 &lt;classpath refid="findbugs.lib" /&gt;
324 &lt;/taskdef&gt;
325
326 &lt;taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask"&gt;
327 &lt;classpath refid="findbugs.lib" /&gt;
328 &lt;/taskdef&gt;
329
330 &lt;taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask"&gt;
331 &lt;classpath refid="findbugs.lib" /&gt;
332 &lt;/taskdef&gt;
333
334 &lt;taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask"&gt;
335 &lt;classpath refid="findbugs.lib" /&gt;
336 &lt;/taskdef&gt;
337
338 &lt;!-- findbugs task definition --&gt;
339 &lt;target name="findbugs"&gt;
340 &lt;antcall target="analyze" /&gt;
341 &lt;antcall target="mine" /&gt;
342 &lt;/target&gt;
343
344 &lt;!-- analyze task --&gt;
345 &lt;target name="analyze"&gt;
346 &lt;!-- run findbugs against asm-util --&gt;
347 &lt;findbugs home="${findbugs.home}"
348 output="xml:withMessages"
349 timeout="90000000"
350 reportLevel="experimental"
351 workHard="true"
352 effort="max"
353 adjustExperimental="true"
354 jvmargs="${jvmargs}"
355 failOnError="true"
356 outputFile="out.xml"
357 projectName="Findbugs"
358 debug="false"&gt;
359 &lt;class location="asm-util-3.0.jar" /&gt;
360 &lt;/findbugs&gt;
361 &lt;/target&gt;
362
363 &lt;target name="mine"&gt;
364
365 &lt;!-- Set info to the latest analysis --&gt;
366 &lt;setBugDatabaseInfo home="${findbugs.home}"
367 withMessages="true"
368 name="asm-util-3.0.jar"
369 input="out.xml"
370 output="out-rel.xml"/&gt;
371
372 &lt;!-- Checking if history file already exists (out-hist.xml) --&gt;
373 &lt;condition property="mining.historyfile.available"&gt;
374 &lt;available file="out-hist.xml"/&gt;
375 &lt;/condition&gt;
376 &lt;condition property="mining.historyfile.notavailable"&gt;
377 &lt;not&gt;
378 &lt;available file="out-hist.xml"/&gt;
379 &lt;/not&gt;
380 &lt;/condition&gt;
381
382 &lt;!-- this target is executed if the history file do not exist (first run) --&gt;
383 &lt;antcall target="history-init"&gt;
384 &lt;param name="data.file" value="out-rel.xml" /&gt;
385 &lt;param name="hist.file" value="out-hist.xml" /&gt;
386 &lt;/antcall&gt;
387 &lt;!-- else this one is executed --&gt;
388 &lt;antcall target="history"&gt;
389 &lt;param name="data.file" value="out-rel.xml" /&gt;
390 &lt;param name="hist.file" value="out-hist.xml" /&gt;
391 &lt;param name="hist.summary.file" value="out-hist.txt" /&gt;
392 &lt;/antcall&gt;
393 &lt;/target&gt;
394
395 &lt;!-- Initializing history file --&gt;
396 &lt;target name="history-init" if="mining.historyfile.notavailable"&gt;
397 &lt;copy file="${data.file}" tofile="${hist.file}" /&gt;
398 &lt;/target&gt;
399
400 &lt;!-- Computing bug history --&gt;
401 &lt;target name="history" if="mining.historyfile.available"&gt;
402 &lt;!-- Merging ${data.file} into ${hist.file} --&gt;
403 &lt;computeBugHistory home="${findbugs.home}"
404 withMessages="true"
405 output="${hist.file}"&gt;
406 &lt;dataFile name="${hist.file}"/&gt;
407 &lt;dataFile name="${data.file}"/&gt;
408 &lt;/computeBugHistory&gt;
409
410 &lt;!-- Compute history into ${hist.summary.file} --&gt;
411 &lt;mineBugHistory home="${findbugs.home}"
412 formatDates="true"
413 noTabs="true"
414 input="${hist.file}"
415 output="${hist.summary.file}"/&gt;
416 &lt;/target&gt;
417
418 &lt;/project&gt;
419
420 </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="rejarForAnalysis.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="license.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;11.&nbsp;Using rejarForAnalysis&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;13.&nbsp;License</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="anttask.html" title="Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task"><link rel="next" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="eclipse.html#d0e1662">1. Requirements</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1670">2. Installation</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1717">3. Using the Plugin</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1748">4. Extending the Eclipse Plugin (since 2.0.0)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1802">5. Troubleshooting</a></span></dt></dl></div><p>
3 The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to be used within
4 the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE.
5 The FindBugs Eclipse plugin was generously contributed by Peter Friese.
6 Phil Crosby and Andrei Loskutov contributed major improvements
7 to the plugin.
8 </p><div class="sect1" title="1.&nbsp;Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1662"></a>1.&nbsp;Requirements</h2></div></div></div><p>
9 To use the <span class="application">FindBugs</span> Plugin for Eclipse, you need Eclipse 3.3 or later,
10 and JRE/JDK 1.5 or later.
11 </p></div><div class="sect1" title="2.&nbsp;Installation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1670"></a>2.&nbsp;Installation</h2></div></div></div><p>
12 We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates.
13 There are three different update sites</p><div class="variablelist" title="FindBugs Eclipse update sites"><p class="title"><b>FindBugs Eclipse update sites</b></p><dl><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p>
14 Only provides official releases of FindBugs.
15 </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-candidate/" target="_top">http://findbugs.cs.umd.edu/eclipse-candidate/</a></span></dt><dd><p>
16 Provides official releases and release candidates of FindBugs.
17 </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily/</a></span></dt><dd><p>
18 Provides the daily build of FindBugs. No testing other than that it compiles.
19 </p></dd></dl></div><p>You can also manually
20 download the plugin from the following link:
21 <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download" target="_top">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</a>.
22 Extract it in Eclipse's "plugins" subdirectory.
23 (So &lt;eclipse_install_dir&gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png
24 should be the path to the <span class="application">FindBugs</span> logo.)
25
26 </p><p>
27 Once the plugin is extracted, start Eclipse and choose
28 <span class="guimenu">Help</span> &#8594; <span class="guimenuitem">About Eclipse Platform</span> &#8594; <span class="guimenuitem">Plug-in Details</span>.
29 You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project".
30 </p></div><div class="sect1" title="3.&nbsp;Using the Plugin"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1717"></a>3.&nbsp;Using the Plugin</h2></div></div></div><p>
31 To get started, right click on a Java project in Package Explorer,
32 and select the option labeled "Find Bugs".
33 <span class="application">FindBugs</span> will run, and problem markers (displayed in source
34 windows, and also in the Eclipse Problems view) will point to
35 locations in your code which have been identified as potential instances
36 of bug patterns.
37 </p><p>
38 You can also run <span class="application">FindBugs</span> on existing java archives (jar, ear, zip, war etc). Simply
39 create an empty Java project and attach archives to the project classpath. Having that, you
40 can now right click the archive node in Package Explorer and select the option labeled
41 "Find Bugs". If you additionally configure the source code locations for the binaries,
42 <span class="application">FindBugs</span> will also link the generated warnings to the right source files.
43 </p><p>
44 You may customize how <span class="application">FindBugs</span> runs by opening the Properties
45 dialog for a Java project, and choosing the "Findbugs" property page.
46 Options you may choose include:
47 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
48 Enable or disable the "Run FindBugs Automatically" checkbox.
49 When enabled, FindBugs will run every time you modify a Java class
50 within the project.
51 </p></li><li class="listitem"><p>
52 Choose minimum warning priority and enabled bug categories.
53 These options will choose which warnings are shown.
54 For example, if you select the "Medium" warning priority,
55 only Medium and High priority warnings will be shown.
56 Similarly, if you uncheck the "Style" checkbox, no warnings
57 in the Style category will be displayed.
58 </p></li><li class="listitem"><p>
59 Select detectors. The table allows you to select which detectors
60 you want to enable for your project.
61 </p></li></ul></div></div><div class="sect1" title="4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1748"></a>4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)</h2></div></div></div><p>
62 Eclipse plugin supports contribution of custom <span class="application">FindBugs</span> detectors (see also
63 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
64 for more information). There are two ways to contribute custom plugins to the Eclipse:
65 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
66 Existing standard <span class="application">FindBugs</span> detector packages can be configured via
67 <span class="guimenu">Window</span> &#8594; <span class="guimenuitem">Preferences</span> &#8594; <span class="guimenuitem">Java</span> &#8594; <span class="guimenuitem"><span class="application">FindBugs</span></span> &#8594; <span class="guimenuitem">Misc. Settings</span> &#8594; <span class="guimenuitem">Custom Detectors</span>.
68 Simply specify there locations of any additional plugin libraries.
69 </p><p>
70 The benefit of this solution is that already existing detector packages can be
71 used "as is", and that you can quickly verify the quality of third party detectors.
72 The drawback is that you have to apply this settings in each
73 new Eclipse workspace, and this settings can't be shared between team members.
74 </p></li><li class="listitem"><p>
75 It is possible to contribute custom detectors via standard Eclipse extensions mechanism.
76 </p><p>
77 Please check the documentation of the
78 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd" target="_top">
79 findBugsEclipsePlugin/schema/detectorPlugins.exsd</a>
80 extension point how to update the plugin.xml. Existing <span class="application">FindBugs</span> detector plugins can
81 be easily "extended" to be full featured <span class="application">FindBugs</span> AND Eclipse detector plugins.
82 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and
83 update your build scripts to not to override the MANIFEST.MF during the build.
84 </p><p>
85 The benefit of this solution is that for given (shared) Eclipse installation
86 each team member has exactly same detectors set, and there is no need to configure
87 anything anymore. The (really small) precondition
88 is that you have to convert your existing detectors package to the valid
89 Eclipse plugin. You can do this even for third-party detector packages.
90 Another major differentiator is the ability to extend the default FindBugs
91 classpath at runtime with required third party libraries (see
92 <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
93 for more information).
94 </p></li></ul></div></div><div class="sect1" title="5.&nbsp;Troubleshooting"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1802"></a>5.&nbsp;Troubleshooting</h2></div></div></div><p>
95 This section lists common problems with the plugin and (if known) how to resolve them.
96 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
97 If you see OutOfMemory error dialogs after starting <span class="application">FindBugs</span> analysis in Eclipse,
98 please increase JVM available memory: change eclipse.ini and add the lines below
99 to the end of the file:
100 </p><pre class="programlisting">
101 -vmargs
102 -Xmx1000m
103 </pre><p>
104 Important: the configuration arguments starting with the line "-vmargs" must
105 be last lines in the eclipse.ini file, and only one argument per line is allowed!
106 </p></li><li class="listitem"><p>
107 If you do not see any <span class="application">FindBugs</span> problem markers (in your source
108 windows or in the Problems View), you may need to change your
109 Problems View filter settings. See
110 <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information.
111 </p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;8.&nbsp;Filter Files</td></tr></table></div></body></html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;8.&nbsp;Filter Files</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="eclipse.html" title="Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin"><link rel="next" href="analysisprops.html" title="Chapter&nbsp;9.&nbsp;Analysis Properties"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;8.&nbsp;Filter Files</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="eclipse.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="analysisprops.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;8.&nbsp;Filter Files"><div class="titlepage"><div><div><h2 class="title"><a name="filter"></a>Chapter&nbsp;8.&nbsp;Filter Files</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="filter.html#d0e1838">1. Introduction to Filter Files</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1888">2. Types of Match clauses</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2136">3. Java element name matching</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2161">4. Caveats</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2191">5. Examples</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2249">6. Complete Example</a></span></dt></dl></div><p>
3 Filter files may be used to include or exclude bug reports for particular classes
4 and methods. This chapter explains how to use filter files.
5
6 </p><div class="note" title="Planned Features" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Planned Features"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="note.png"></td><th align="left">Planned Features</th></tr><tr><td align="left" valign="top"><p>
7 Filters are currently only supported by the Command Line interface.
8 Eventually, filter support will be added to the GUI.
9 </p></td></tr></table></div><p>
10 </p><div class="sect1" title="1.&nbsp;Introduction to Filter Files"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1838"></a>1.&nbsp;Introduction to Filter Files</h2></div></div></div><p>
11 Conceptually, a filter matches bug instances against a set of criteria.
12 By defining a filter, you can select bug instances for special treatment;
13 for example, to exclude or include them in a report.
14 </p><p>
15 A filter file is an <a class="ulink" href="http://www.w3.org/XML/" target="_top">XML</a> document with a top-level <code class="literal">FindBugsFilter</code> element
16 which has some number of <code class="literal">Match</code> elements as children. Each <code class="literal">Match</code>
17 element represents a predicate which is applied to generated bug instances.
18 Usually, a filter will be used to exclude bug instances. For example:
19
20 </p><pre class="screen">
21 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -exclude <em class="replaceable"><code>myExcludeFilter.xml</code></em> <em class="replaceable"><code>myApp.jar</code></em></strong></span>
22 </pre><p>
23
24 However, a filter could also be used to select bug instances to specifically
25 report:
26
27 </p><pre class="screen">
28 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -include <em class="replaceable"><code>myIncludeFilter.xml</code></em> <em class="replaceable"><code>myApp.jar</code></em></strong></span>
29 </pre><p>
30 </p><p>
31 <code class="literal">Match</code> elements contain children, which are conjuncts of the predicate.
32 In other words, each of the children must be true for the predicate to be true.
33 </p></div><div class="sect1" title="2.&nbsp;Types of Match clauses"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1888"></a>2.&nbsp;Types of Match clauses</h2></div></div></div><div class="variablelist"><dl><dt><span class="term"><code class="literal">&lt;Bug&gt;</code></span></dt><dd><p>
34 This element specifies a particular bug pattern or patterns to match.
35 The <code class="literal">pattern</code> attribute is a comma-separated list of
36 bug pattern types. You can find the bug pattern types for particular
37 warnings by looking at the output produced by the <span class="command"><strong>-xml</strong></span>
38 output option (the <code class="literal">type</code> attribute of <code class="literal">BugInstance</code>
39 elements), or from the <a class="ulink" href="../bugDescriptions.html" target="_top">bug
40 descriptions document</a>.
41 </p><p>
42 For more coarse-grained matching, use <code class="literal">code</code> attribute. It takes
43 a comma-separated list of bug abbreviations. For most-coarse grained matching use
44 <code class="literal">category</code> attriute, that takes a comma separated list of bug category names:
45 <code class="literal">CORRECTNESS</code>, <code class="literal">MT_CORRECTNESS</code>,
46 <code class="literal">BAD_PRACTICICE</code>, <code class="literal">PERFORMANCE</code>, <code class="literal">STYLE</code>.
47 </p><p>
48 If more than one of the attributes mentioned above are specified on the same
49 <code class="literal">&lt;Bug&gt;</code> element, all bug patterns that match either one of specified
50 pattern names, or abreviations, or categories will be matched.
51 </p><p>
52 As a backwards compatibility measure, <code class="literal">&lt;BugPattern&gt;</code> and
53 <code class="literal">&lt;BugCode&gt;</code> elements may be used instead of
54 <code class="literal">&lt;Bug&gt;</code> element. Each of these uses a
55 <code class="literal">name</code> attribute for specifying accepted values list. Support for these
56 elements may be removed in a future release.
57 </p></dd><dt><span class="term"><code class="literal">&lt;Confidence&gt;</code></span></dt><dd><p>
58 This element matches warnings with a particular bug confidence.
59 The <code class="literal">value</code> attribute should be an integer value:
60 1 to match high-confidence warnings, 2 to match normal-confidence warnings,
61 or 3 to match low-confidence warnings. &lt;Confidence&gt; replaced
62 &lt;Priority&gt; in 2.0.0 release.
63 </p></dd><dt><span class="term"><code class="literal">&lt;Priority&gt;</code></span></dt><dd><p>
64 Same as <code class="literal">&lt;Confidence&gt;</code>, exists for backward compatibility.
65 </p></dd><dt><span class="term"><code class="literal">&lt;Rank&gt;</code></span></dt><dd><p>
66 This element matches warnings with a particular bug rank.
67 The <code class="literal">value</code> attribute should be an integer value
68 between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling,
69 and 15 to 20 of concern bugs.
70 </p></dd><dt><span class="term"><code class="literal">&lt;Package&gt;</code></span></dt><dd><p>
71 This element matches warnings associated with classes within the package specified
72 using <code class="literal">name</code> attribute. Nested packages are not included (along the
73 lines of Java import statement). However matching multiple packages can be achieved
74 easily using regex name match.
75 </p></dd><dt><span class="term"><code class="literal">&lt;Class&gt;</code></span></dt><dd><p>
76 This element matches warnings associated with a particular class. The
77 <code class="literal">name</code> attribute is used to specify the exact or regex match pattern
78 for the class name.
79 </p><p>
80 As a backward compatibility measure, instead of element of this type, you can use
81 <code class="literal">class</code> attribute on a <code class="literal">Match</code> element to specify
82 exact an class name or <code class="literal">classregex</code> attribute to specify a regular
83 expression to match the class name against.
84 </p><p>
85 If the <code class="literal">Match</code> element contains neither a <code class="literal">Class</code> element,
86 nor a <code class="literal">class</code> / <code class="literal">classregex</code> attribute, the predicate will apply
87 to all classes. Such predicate is likely to match more bug instances than you want, unless it is
88 refined further down with apropriate method or field predicates.
89 </p></dd><dt><span class="term"><code class="literal">&lt;Method&gt;</code></span></dt><dd><p>This element specifies a method. The <code class="literal">name</code> is used to specify
90 the exact or regex match pattern for the method name.
91 The <code class="literal">params</code> attribute is a comma-separated list
92 of the types of the method's parameters. The <code class="literal">returns</code> attribute is
93 the method's return type. In <code class="literal">params</code> and <code class="literal">returns</code>, class names
94 must be fully qualified. (E.g., "java.lang.String" instead of just
95 "String".) If one of the latter attributes is specified the other is required for creating a method signature.
96 Note that you can provide either <code class="literal">name</code> attribute or <code class="literal">params</code>
97 and <code class="literal">returns</code> attributes or all three of them. This way you can provide various kinds of
98 name and signature based matches.
99 </p></dd><dt><span class="term"><code class="literal">&lt;Field&gt;</code></span></dt><dd><p>This element specifies a field. The <code class="literal">name</code> attribute is is used to specify
100 the exact or regex match pattern for the field name. You can also filter fields according to their signature -
101 use <code class="literal">type</code> attribute to specify fully qualified type of the field. You can specify eiter or both
102 of these attributes in order to perform name / signature based matches.
103 </p></dd><dt><span class="term"><code class="literal">&lt;Local&gt;</code></span></dt><dd><p>This element specifies a local variable. The <code class="literal">name</code> attribute is is used to specify
104 the exact or regex match pattern for the local variable name. Local variables are variables defined within a method.
105 </p></dd><dt><span class="term"><code class="literal">&lt;Or&gt;</code></span></dt><dd><p>
106 This element combines <code class="literal">Match</code> clauses as disjuncts. I.e., you can put two
107 <code class="literal">Method</code> elements in an <code class="literal">Or</code> clause in order to match either method.
108 </p></dd><dt><span class="term"><code class="literal">&lt;And&gt;</code></span></dt><dd><p>
109 This element combines <code class="literal">Match</code> clauses which both must evaluate to true. I.e., you can put
110 <code class="literal">Bug</code> and <code class="literal">Priority</code> elements in an <code class="literal">And</code> clause in order
111 to match specific bugs with given priority only.
112 </p></dd><dt><span class="term"><code class="literal">&lt;Not&gt;</code></span></dt><dd><p>
113 This element inverts the included child <code class="literal">Match</code>. I.e., you can put a
114 <code class="literal">Bug</code> element in a <code class="literal">Not</code> clause in order to match any bug
115 excluding the given one.
116 </p></dd></dl></div></div><div class="sect1" title="3.&nbsp;Java element name matching"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2136"></a>3.&nbsp;Java element name matching</h2></div></div></div><p>
117 If the <code class="literal">name</code> attribute of <code class="literal">Class</code>, <code class="literal">Method</code> or
118 <code class="literal">Field</code> starts with the ~ character the rest of attribute content is interpreted as
119 a Java regular expression that is matched against the names of the Java element in question.
120 </p><p>
121 Note that the pattern is matched against whole element name and therefore .* clauses need to be used
122 at pattern beginning and/or end to perform substring matching.
123 </p><p>
124 See <a class="ulink" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html" target="_top"><code class="literal">java.util.regex.Pattern</code></a>
125 documentation for pattern syntax.
126 </p></div><div class="sect1" title="4.&nbsp;Caveats"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2161"></a>4.&nbsp;Caveats</h2></div></div></div><p>
127 <code class="literal">Match</code> clauses can only match information that is actually contained in the
128 bug instances. Every bug instance has a class, so in general, excluding
129 bugs by class will work.
130 </p><p>
131 Some bug instances have two (or more) classes. For example, the DE (dropped exception)
132 bugs report both the class containing the method where the dropped exception
133 happens, and the class which represents the type of the dropped exception.
134 Only the <span class="emphasis"><em>first</em></span> (primary) class is matched against <code class="literal">Match</code> clauses.
135 So, for example, if you want to suppress IC (initialization circularity)
136 reports for classes "com.foobar.A" and "com.foobar.B", you would use
137 two <code class="literal">Match</code> clauses:
138
139 </p><pre class="programlisting">
140 &lt;Match&gt;
141 &lt;Class name="com.foobar.A" /&gt;
142 &lt;Bug code="IC" /&gt;
143 &lt;/Match&gt;
144
145 &lt;Match&gt;
146 &lt;Class name="com.foobar.B" /&gt;
147 &lt;Bug code="IC" /&gt;
148 &lt;/Match&gt;
149 </pre><p>
150
151 By explicitly matching both classes, you ensure that the IC bug instance will be
152 matched regardless of which class involved in the circularity happens to be
153 listed first in the bug instance. (Of course, this approach might accidentally
154 supress circularities involving "com.foobar.A" or "com.foobar.B" and a third
155 class.)
156 </p><p>
157 Many kinds of bugs report what method they occur in. For those bug instances,
158 you can put <code class="literal">Method</code> clauses in the <code class="literal">Match</code> element and they should work
159 as expected.
160 </p></div><div class="sect1" title="5.&nbsp;Examples"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2191"></a>5.&nbsp;Examples</h2></div></div></div><p>
161 1. Match all bug reports for a class.
162
163 </p><pre class="programlisting">
164
165 &lt;Match&gt;
166 &lt;Class name="com.foobar.MyClass" /&gt;
167 &lt;/Match&gt;
168
169 </pre><p>
170
171 </p><p>
172 2. Match certain tests from a class by specifying their abbreviations.
173 </p><pre class="programlisting">
174
175 &lt;Match&gt;
176 &lt;Class name="com.foobar.MyClass"/ &gt;
177 &lt;Bug code="DE,UrF,SIC" /&gt;
178 &lt;/Match&gt;
179
180 </pre><p>
181 </p><p>
182 3. Match certain tests from all classes by specifying their abbreviations.
183
184 </p><pre class="programlisting">
185
186 &lt;Match&gt;
187 &lt;Bug code="DE,UrF,SIC" /&gt;
188 &lt;/Match&gt;
189
190 </pre><p>
191 </p><p>
192 4. Match certain tests from all classes by specifying their category.
193
194 </p><pre class="programlisting">
195
196 &lt;Match&gt;
197 &lt;Bug category="PERFORMANCE" /&gt;
198 &lt;/Match&gt;
199
200 </pre><p>
201 </p><p>
202 5. Match bug types from specified methods of a class by their abbreviations.
203
204 </p><pre class="programlisting">
205
206 &lt;Match&gt;
207 &lt;Class name="com.foobar.MyClass" /&gt;
208 &lt;Or&gt;
209 &lt;Method name="frob" params="int,java.lang.String" returns="void" /&gt;
210 &lt;Method name="blat" params="" returns="boolean" /&gt;
211 &lt;/Or&gt;
212 &lt;Bug code="DC" /&gt;
213 &lt;/Match&gt;
214
215 </pre><p>
216 </p><p>
217 6. Match a particular bug pattern in a particular method.
218
219 </p><pre class="programlisting">
220
221 &lt;!-- A method with an open stream false positive. --&gt;
222 &lt;Match&gt;
223 &lt;Class name="com.foobar.MyClass" /&gt;
224 &lt;Method name="writeDataToFile" /&gt;
225 &lt;Bug pattern="OS_OPEN_STREAM" /&gt;
226 &lt;/Match&gt;
227
228 </pre><p>
229 </p><p>
230 7. Match a particular bug pattern with a given priority in a particular method.
231
232 </p><pre class="programlisting">
233
234 &lt;!-- A method with a dead local store false positive (medium priority). --&gt;
235 &lt;Match&gt;
236 &lt;Class name="com.foobar.MyClass" /&gt;
237 &lt;Method name="someMethod" /&gt;
238 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
239 &lt;Priority value="2" /&gt;
240 &lt;/Match&gt;
241
242 </pre><p>
243 </p><p>
244 8. Match minor bugs introduced by AspectJ compiler (you are probably not interested in these unless
245 you are an AspectJ developer).
246
247 </p><pre class="programlisting">
248
249 &lt;Match&gt;
250 &lt;Class name="~.*\$AjcClosure\d+" /&gt;
251 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
252 &lt;Method name="run" /&gt;
253 &lt;/Match&gt;
254 &lt;Match&gt;
255 &lt;Bug pattern="UUF_UNUSED_FIELD" /&gt;
256 &lt;Field name="~ajc\$.*" /&gt;
257 &lt;/Match&gt;
258
259 </pre><p>
260 </p><p>
261 9. Match bugs in specific parts of the code base
262
263 </p><pre class="programlisting">
264
265 &lt;!-- match unused fields warnings in Messages classes in all packages --&gt;
266 &lt;Match&gt;
267 &lt;Class name="~.*\.Messages" /&gt;
268 &lt;Bug code="UUF" /&gt;
269 &lt;/Match&gt;
270 &lt;!-- match mutable statics warnings in all internal packages --&gt;
271 &lt;Match&gt;
272 &lt;Package name="~.*\.internal" /&gt;
273 &lt;Bug code="MS" /&gt;
274 &lt;/Match&gt;
275 &lt;!-- match anonymoous inner classes warnings in ui package hierarchy --&gt;
276 &lt;Match&gt;
277 &lt;Package name="~com\.foobar\.fooproject\.ui.*" /&gt;
278 &lt;Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" /&gt;
279 &lt;/Match&gt;
280
281 </pre><p>
282 </p><p>
283 10. Match bugs on fields or methods with specific signatures
284 </p><pre class="programlisting">
285
286 &lt;!-- match System.exit(...) usage warnings in void main(String[]) methods in all classes --&gt;
287 &lt;Match&gt;
288 &lt;Method returns="void" name="main" params="java.lang.String[]" /&gt;
289 &lt;Bug pattern="DM_EXIT" /&gt;
290 &lt;/Match&gt;
291 &lt;!-- match UuF warnings on fields of type com.foobar.DebugInfo on all classes --&gt;
292 &lt;Match&gt;
293 &lt;Field type="com.foobar.DebugInfo" /&gt;
294 &lt;Bug code="UuF" /&gt;
295 &lt;/Match&gt;
296
297 </pre><p>
298 </p><p>
299 11. Match bugs using the Not filter operator
300 </p><pre class="programlisting">
301
302 &lt;!-- ignore all bugs in test classes, except for those bugs specifically relating to JUnit tests --&gt;
303 &lt;!-- i.e. filter bug if ( classIsJUnitTest &amp;&amp; ! bugIsRelatedToJUnit ) --&gt;
304 &lt;Match&gt;
305 &lt;!-- the Match filter is equivalent to a logical 'And' --&gt;
306
307 &lt;Class name="~.*\.*Test" /&gt;
308 &lt;!-- test classes are suffixed by 'Test' --&gt;
309
310 &lt;Not&gt;
311 &lt;Bug code="IJU" /&gt; &lt;!-- 'IJU' is the code for bugs related to JUnit test code --&gt;
312 &lt;/Not&gt;
313 &lt;/Match&gt;
314
315 </pre><p>
316 </p></div><div class="sect1" title="6.&nbsp;Complete Example"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e2249"></a>6.&nbsp;Complete Example</h2></div></div></div><pre class="programlisting">
317
318 &lt;FindBugsFilter&gt;
319 &lt;Match&gt;
320 &lt;Class name="com.foobar.ClassNotToBeAnalyzed" /&gt;
321 &lt;/Match&gt;
322
323 &lt;Match&gt;
324 &lt;Class name="com.foobar.ClassWithSomeBugsMatched" /&gt;
325 &lt;Bug code="DE,UrF,SIC" /&gt;
326 &lt;/Match&gt;
327
328 &lt;!-- Match all XYZ violations. --&gt;
329 &lt;Match&gt;
330 &lt;Bug code="XYZ" /&gt;
331 &lt;/Match&gt;
332
333 &lt;!-- Match all doublecheck violations in these methods of "AnotherClass". --&gt;
334 &lt;Match&gt;
335 &lt;Class name="com.foobar.AnotherClass" /&gt;
336 &lt;Or&gt;
337 &lt;Method name="nonOverloadedMethod" /&gt;
338 &lt;Method name="frob" params="int,java.lang.String" returns="void" /&gt;
339 &lt;Method name="blat" params="" returns="boolean" /&gt;
340 &lt;/Or&gt;
341 &lt;Bug code="DC" /&gt;
342 &lt;/Match&gt;
343
344 &lt;!-- A method with a dead local store false positive (medium priority). --&gt;
345 &lt;Match&gt;
346 &lt;Class name="com.foobar.MyClass" /&gt;
347 &lt;Method name="someMethod" /&gt;
348 &lt;Bug pattern="DLS_DEAD_LOCAL_STORE" /&gt;
349 &lt;Priority value="2" /&gt;
350 &lt;/Match&gt;
351
352 &lt;!-- All bugs in test classes, except for JUnit-specific bugs --&gt;
353 &lt;Match&gt;
354 &lt;Class name="~.*\.*Test" /&gt;
355 &lt;Not&gt;
356 &lt;Bug code="IJU" /&gt;
357 &lt;/Not&gt;
358 &lt;/Match&gt;
359
360 &lt;/FindBugsFilter&gt;
361
362 </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="eclipse.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="analysisprops.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;9.&nbsp;Analysis Properties</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;5.&nbsp;Using the FindBugs GUI</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;"><link rel="next" href="anttask.html" title="Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;5.&nbsp;Using the <span class="application">FindBugs</span> GUI</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="running.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="anttask.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;5.&nbsp;Using the FindBugs GUI"><div class="titlepage"><div><div><h2 class="title"><a name="gui"></a>Chapter&nbsp;5.&nbsp;Using the <span class="application">FindBugs</span> GUI</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="gui.html#d0e1092">1. Creating a Project</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1134">2. Running the Analysis</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1139">3. Browsing Results</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1154">4. Saving and Opening</a></span></dt></dl></div><p>
3 This chapter describes how to use the <span class="application">FindBugs</span> graphical user interface (GUI).
4 </p><div class="sect1" title="1.&nbsp;Creating a Project"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1092"></a>1.&nbsp;Creating a Project</h2></div></div></div><p>
5 After you have started <span class="application">FindBugs</span> using the <span class="command"><strong>findbugs</strong></span> command,
6 choose the <span class="guimenu">File</span> &#8594; <span class="guimenuitem">New Project</span>
7 menu item. You will see a dialog which looks like this:
8 </p><div class="mediaobject"><img src="project-dialog.png"></div><p>
9 </p><p>
10 Use the "Add" button next to "Classpath to analyze" to select a Java archive
11 file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple
12 archives/directories.
13 </p><p>
14 You can also add the source directories which contain
15 the source code for the Java archives you are analyzing. This will enable
16 <span class="application">FindBugs</span> to highlight the source code which contains a possible error.
17 The source directories you add should be the roots of the Java
18 package hierarchy. For example, if your application is contained in the
19 <code class="varname">org.foobar.myapp</code> package, you should add the
20 parent directory of the <code class="filename">org</code> directory
21 to the source directory list for the project.
22 </p><p>
23 Another optional step is to add additional Jar files or directories as
24 "Auxiliary classpath locations" entries. You should do this if the archives and directories you are analyzing
25 have references to other classes which are not included in the analyzed
26 archives/directories and are not in the standard runtime classpath. Some of the bug
27 pattern detectors in <span class="application">FindBugs</span> make use of class hierarchy information,
28 so you will get more accurate results if the entire class hierarchy is
29 available which <span class="application">FindBugs</span> performs its analysis.
30 </p></div><div class="sect1" title="2.&nbsp;Running the Analysis"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1134"></a>2.&nbsp;Running the Analysis</h2></div></div></div><p>
31 Once you have added all of the archives, directories, and source directories,
32 click the "Analyze" button to analyze the classes contained in the
33 Jar files. Note that for a very large program on an older computer,
34 this may take quite a while (tens of minutes). A recent computer with
35 ample memory will typically be able to analyze a large program in only a
36 few minutes.
37 </p></div><div class="sect1" title="3.&nbsp;Browsing Results"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1139"></a>3.&nbsp;Browsing Results</h2></div></div></div><p>
38 When the analysis completes, you will see a screen like the following:
39 </p><div class="mediaobject"><img src="example-details.png"></div><p>
40 </p><p>
41 The upper left-hand pane of the window shows the bug tree; this is a hierarchical
42 representation of all of the potential bugs detected in the analyzed
43 Jar files.
44 </p><p>
45 When you select a particular bug instance in the top pane, you will
46 see a description of the bug in the "Details" tab of the bottom pane.
47 In addition, the source code pane on the upper-right will show the
48 program source code where the potential bug occurs, if source is available.
49 In the above example, the bug is a stream object that is not closed. The
50 source code window highlights the line where the stream object is created.
51 </p><p>
52 You may add a textual annotations to bug instances. To do so, type them
53 into the text box just below the hierarchical view. You can type any
54 information which you would like to record. When you load and save bug
55 results files, the annotations are preserved.
56 </p></div><div class="sect1" title="4.&nbsp;Saving and Opening"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1154"></a>4.&nbsp;Saving and Opening</h2></div></div></div><p>
57 You may use the <span class="guimenu">File</span> &#8594; <span class="guimenuitem">Save as...</span>
58 menu option to save your work. To save your work, including the jar
59 file lists you specified and all bug results, choose
60 "FindBugs analysis results (.xml)" from the drop-down list in the
61 "Save as..." dialog. There are also options for saving just the jar
62 file lists ("FindBugs project file (.fbp)") or just the results
63 ("FindBugs analysis file (.fba)").
64 A saved file may be loaded with the
65 <span class="guimenu">File</span> &#8594; <span class="guimenuitem">Open...</span>
66 menu option.
67 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="running.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="anttask.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;4.&nbsp;Running <span class="application">FindBugs</span>&#8482;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task</td></tr></table></div></body></html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>FindBugs&#8482; Manual</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="next" href="introduction.html" title="Chapter&nbsp;1.&nbsp;Introduction"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="application">FindBugs</span>&#8482; Manual</th></tr><tr><td width="20%" align="left">&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="introduction.html">Next</a></td></tr></table><hr></div><div lang="en" class="book" title="FindBugs&#8482; Manual"><div class="titlepage"><div><div><h1 class="title"><a name="findbugs-manual"></a><span class="application">FindBugs</span>&#8482; Manual</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">David</span> <span class="othername">H.</span> <span class="surname">Hovemeyer</span></h3></div><div class="author"><h3 class="author"><span class="firstname">William</span> <span class="othername">W.</span> <span class="surname">Pugh</span></h3></div></div></div><div><p class="copyright">Copyright &copy; 2003 - 2012 University of Maryland</p></div><div><div class="legalnotice" title="Legal Notice"><a name="d0e27"></a><p>
3 This manual is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License.
4 To view a copy of this license, visit
5 <a class="ulink" href="http://creativecommons.org/licenses/by-nc-sa/1.0/" target="_top">http://creativecommons.org/licenses/by-nc-sa/1.0/</a>
6 or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
7 </p><p>
8 The name FindBugs and the FindBugs logo are trademarked by the University of Maryland.
9 </p></div></div><div><p class="pubdate">17:16:15 EST, 22 November, 2013</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="introduction.html">1. Introduction</a></span></dt><dd><dl><dt><span class="sect1"><a href="introduction.html#d0e67">1. Requirements</a></span></dt></dl></dd><dt><span class="chapter"><a href="installing.html">2. Installing <span class="application">FindBugs</span>&#8482;</a></span></dt><dd><dl><dt><span class="sect1"><a href="installing.html#d0e98">1. Extracting the Distribution</a></span></dt></dl></dd><dt><span class="chapter"><a href="building.html">3. Building <span class="application">FindBugs</span>&#8482; from Source</a></span></dt><dd><dl><dt><span class="sect1"><a href="building.html#d0e173">1. Prerequisites</a></span></dt><dt><span class="sect1"><a href="building.html#d0e262">2. Extracting the Source Distribution</a></span></dt><dt><span class="sect1"><a href="building.html#d0e275">3. Modifying <code class="filename">local.properties</code></a></span></dt><dt><span class="sect1"><a href="building.html#d0e333">4. Running <span class="application">Ant</span></a></span></dt><dt><span class="sect1"><a href="building.html#d0e427">5. Running <span class="application">FindBugs</span>&#8482; from a source directory</a></span></dt></dl></dd><dt><span class="chapter"><a href="running.html">4. Running <span class="application">FindBugs</span>&#8482;</a></span></dt><dd><dl><dt><span class="sect1"><a href="running.html#d0e465">1. Quick Start</a></span></dt><dt><span class="sect1"><a href="running.html#d0e503">2. Executing <span class="application">FindBugs</span></a></span></dt><dt><span class="sect1"><a href="running.html#commandLineOptions">3. Command-line Options</a></span></dt></dl></dd><dt><span class="chapter"><a href="gui.html">5. Using the <span class="application">FindBugs</span> GUI</a></span></dt><dd><dl><dt><span class="sect1"><a href="gui.html#d0e1092">1. Creating a Project</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1134">2. Running the Analysis</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1139">3. Browsing Results</a></span></dt><dt><span class="sect1"><a href="gui.html#d0e1154">4. Saving and Opening</a></span></dt></dl></dd><dt><span class="chapter"><a href="anttask.html">6. Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task</a></span></dt><dd><dl><dt><span class="sect1"><a href="anttask.html#d0e1205">1. Installing the <span class="application">Ant</span> task</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1243">2. Modifying build.xml</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1314">3. Executing the task</a></span></dt><dt><span class="sect1"><a href="anttask.html#d0e1339">4. Parameters</a></span></dt></dl></dd><dt><span class="chapter"><a href="eclipse.html">7. Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</a></span></dt><dd><dl><dt><span class="sect1"><a href="eclipse.html#d0e1662">1. Requirements</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1670">2. Installation</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1717">3. Using the Plugin</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1748">4. Extending the Eclipse Plugin (since 2.0.0)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1802">5. Troubleshooting</a></span></dt></dl></dd><dt><span class="chapter"><a href="filter.html">8. Filter Files</a></span></dt><dd><dl><dt><span class="sect1"><a href="filter.html#d0e1838">1. Introduction to Filter Files</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e1888">2. Types of Match clauses</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2136">3. Java element name matching</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2161">4. Caveats</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2191">5. Examples</a></span></dt><dt><span class="sect1"><a href="filter.html#d0e2249">6. Complete Example</a></span></dt></dl></dd><dt><span class="chapter"><a href="analysisprops.html">9. Analysis Properties</a></span></dt><dt><span class="chapter"><a href="annotations.html">10. Annotations</a></span></dt><dt><span class="chapter"><a href="rejarForAnalysis.html">11. Using rejarForAnalysis</a></span></dt><dt><span class="chapter"><a href="datamining.html">12. Data mining of bugs with <span class="application">FindBugs</span>&#8482;</a></span></dt><dd><dl><dt><span class="sect1"><a href="datamining.html#commands">1. Commands</a></span></dt><dt><span class="sect1"><a href="datamining.html#examples">2. Examples</a></span></dt><dt><span class="sect1"><a href="datamining.html#antexample">3. Ant example</a></span></dt></dl></dd><dt><span class="chapter"><a href="license.html">13. License</a></span></dt><dt><span class="chapter"><a href="acknowledgments.html">14. Acknowledgments</a></span></dt><dd><dl><dt><span class="sect1"><a href="acknowledgments.html#d0e3629">1. Contributors</a></span></dt><dt><span class="sect1"><a href="acknowledgments.html#d0e3752">2. Software Used</a></span></dt></dl></dd></dl></div><div class="list-of-tables"><p><b>List of Tables</b></p><dl><dt>9.1. <a href="analysisprops.html#analysisproptable">Configurable Analysis Properties</a></dt><dt>12.1. <a href="datamining.html#computeBugHistoryTable">Options for computeBugHistory command</a></dt><dt>12.2. <a href="datamining.html#filterOptionsTable">Options for filterBugs command</a></dt><dt>12.3. <a href="datamining.html#mineBugHistoryOptionsTable">Options for mineBugHistory command</a></dt><dt>12.4. <a href="datamining.html#mineBugHistoryColumns">Columns in mineBugHistory output</a></dt><dt>12.5. <a href="datamining.html#defectDensityColumns">Columns in defectDensity output</a></dt><dt>12.6. <a href="datamining.html#convertXmlToTextTable">Options for convertXmlToText command</a></dt><dt>12.7. <a href="datamining.html#setBugDatabaseInfoOptions">setBugDatabaseInfo Options</a></dt><dt>12.8. <a href="datamining.html#listBugDatabaseInfoColumns">listBugDatabaseInfo Columns</a></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="introduction.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;1.&nbsp;Introduction</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="introduction.html" title="Chapter&nbsp;1.&nbsp;Introduction"><link rel="next" href="building.html" title="Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;2.&nbsp;Installing <span class="application">FindBugs</span>&#8482;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="introduction.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="building.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;"><div class="titlepage"><div><div><h2 class="title"><a name="installing"></a>Chapter&nbsp;2.&nbsp;Installing <span class="application">FindBugs</span>&#8482;</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="installing.html#d0e98">1. Extracting the Distribution</a></span></dt></dl></div><p>
3 This chapter explains how to install <span class="application">FindBugs</span>.
4 </p><div class="sect1" title="1.&nbsp;Extracting the Distribution"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e98"></a>1.&nbsp;Extracting the Distribution</h2></div></div></div><p>
5 The easiest way to install <span class="application">FindBugs</span> is to download a binary distribution.
6 Binary distributions are available in
7 <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.tar.gz?download" target="_top">gzipped tar format</a> and
8 <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.zip?download" target="_top">zip format</a>.
9 Once you have downloaded a binary distribution, extract it into a directory of your choice.
10 </p><p>
11 Extracting a gzipped tar format distribution:
12 </p><pre class="screen">
13 <code class="prompt">$ </code><span class="command"><strong>gunzip -c findbugs-2.0.3.tar.gz | tar xvf -</strong></span>
14 </pre><p>
15 </p><p>
16 Extracting a zip format distribution:
17 </p><pre class="screen">
18 <code class="prompt">C:\Software&gt;</code><span class="command"><strong>unzip findbugs-2.0.3.zip</strong></span>
19 </pre><p>
20 </p><p>
21 Usually, extracting a binary distribution will create a directory ending in
22 <code class="filename">findbugs-2.0.3</code>. For example, if you extracted
23 the binary distribution from the <code class="filename">C:\Software</code>
24 directory, then the <span class="application">FindBugs</span> software will be extracted into the directory
25 <code class="filename">C:\Software\findbugs-2.0.3</code>.
26 This directory is the <span class="application">FindBugs</span> home directory. We'll refer to it as
27 <em class="replaceable"><code>$FINDBUGS_HOME</code></em> (or <em class="replaceable"><code>%FINDBUGS_HOME%</code></em> for Windows) throughout this manual.
28 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="introduction.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="building.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;1.&nbsp;Introduction&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;1.&nbsp;Introduction</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="index.html" title="FindBugs&#8482; Manual"><link rel="next" href="installing.html" title="Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;1.&nbsp;Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="installing.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;1.&nbsp;Introduction"><div class="titlepage"><div><div><h2 class="title"><a name="introduction"></a>Chapter&nbsp;1.&nbsp;Introduction</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="introduction.html#d0e67">1. Requirements</a></span></dt></dl></div><p> <span class="application">FindBugs</span>&#8482; is a program to find bugs in Java programs. It looks for instances
3 of "bug patterns" --- code instances that are likely to be errors.</p><p> This document describes version 2.0.3 of <span class="application">FindBugs</span>.We
4 are very interested in getting your feedback on <span class="application">FindBugs</span>. Please visit
5 the <a class="ulink" href="http://findbugs.sourceforge.net" target="_top"><span class="application">FindBugs</span> web page</a> for
6 the latest information on <span class="application">FindBugs</span>, contact information, and support resources such
7 as information about the <span class="application">FindBugs</span> mailing lists.</p><div class="sect1" title="1.&nbsp;Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e67"></a>1.&nbsp;Requirements</h2></div></div></div><p> To use <span class="application">FindBugs</span>, you need a runtime environment compatible with
8 <a class="ulink" href="http://java.sun.com/j2se" target="_top">Java 2 Standard Edition</a>, version 1.5 or later.
9 <span class="application">FindBugs</span> is platform independent, and is known to run on GNU/Linux, Windows, and
10 MacOS X platforms.</p><p>You should have at least 512 MB of memory to use <span class="application">FindBugs</span>.
11 To analyze very large projects, more memory may be needed.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="installing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">FindBugs</span>&#8482; Manual&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;2.&nbsp;Installing <span class="application">FindBugs</span>&#8482;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;13.&nbsp;License</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="datamining.html" title="Chapter&nbsp;12.&nbsp;Data mining of bugs with FindBugs&#8482;"><link rel="next" href="acknowledgments.html" title="Chapter&nbsp;14.&nbsp;Acknowledgments"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;13.&nbsp;License</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="datamining.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="acknowledgments.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;13.&nbsp;License"><div class="titlepage"><div><div><h2 class="title"><a name="license"></a>Chapter&nbsp;13.&nbsp;License</h2></div></div></div><p>
3 The name FindBugs and the FindBugs logo is trademarked by the University
4 of Maryland.
5 FindBugs is free software distributed under the terms of the
6 <a class="ulink" href="http://www.gnu.org/licenses/lgpl.html" target="_top">Lesser GNU Public License</a>.
7 You should have received a copy of the license in the file <code class="filename">LICENSE.txt</code>
8 in the <span class="application">FindBugs</span> distribution.
9 </p><p>
10 You can find the latest version of FindBugs, along with its source code, from the
11 <a class="ulink" href="http://findbugs.sourceforge.net" target="_top">FindBugs web page</a>.
12 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datamining.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="acknowledgments.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;12.&nbsp;Data mining of bugs with <span class="application">FindBugs</span>&#8482;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;14.&nbsp;Acknowledgments</td></tr></table></div></body></html>
Binary diff not shown
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;11.&nbsp;Using rejarForAnalysis</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="annotations.html" title="Chapter&nbsp;10.&nbsp;Annotations"><link rel="next" href="datamining.html" title="Chapter&nbsp;12.&nbsp;Data mining of bugs with FindBugs&#8482;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;11.&nbsp;Using rejarForAnalysis</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="annotations.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="datamining.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;11.&nbsp;Using rejarForAnalysis"><div class="titlepage"><div><div><h2 class="title"><a name="rejarForAnalysis"></a>Chapter&nbsp;11.&nbsp;Using rejarForAnalysis</h2></div></div></div><p>
3 If your project consists of many jarfiles or the jarfiles are scattered
4 over many directories, you may wish to use the <span class="command"><strong>rejarForAnalysis
5 </strong></span> script to make
6 FindBugs invocation easier. The script collects many jarfiles and combines them
7 into a single, large jarfile that can then be easily passed to FindBugs for
8 analysis. This can be particularly useful in combination with the 'find' command
9 on unix systems; e.g. <span class="command"><strong>find . -name '*.jar' | xargs rejarForAnalysis
10 </strong></span>.
11 </p><p>
12 The <span class="command"><strong>rejarForAnalysis</strong></span> script
13 can also be used to split a very large project up into a set of jarfiles with
14 the project classfiles evenly divided between them. This is useful when running
15 FindBugs on the entire project is not practical due to time or memory consumption.
16 Instead of running FindBugs on the entire project, you may use <span class="command"><strong>
17 rejarForAnalysis</strong></span> build one large, all-inclusive jarfile
18 containing all classes, invoke <span class="command"><strong>rejarForAnalysis</strong></span>
19 again to split the project into multiple jarfiles, then run FindBugs
20 on each divided jarfiles in turn, specifying the the all-inclusive jarfile in
21 the <span class="command"><strong>-auxclasspath</strong></span>.
22 </p><p>
23 These are the options accepted by the <span class="command"><strong>rejarForAnalysis</strong></span> script:
24 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-maxAge</strong></span> <em class="replaceable"><code>days</code></em></span></dt><dd><p>
25 Maximum age in days (ignore jar files older than this).
26 </p></dd><dt><span class="term"><span class="command"><strong>-inputFileList</strong></span> <em class="replaceable"><code>filename</code></em></span></dt><dd><p>
27 Text file containing names of jar files.
28 </p></dd><dt><span class="term"><span class="command"><strong>-maxClasses</strong></span> <em class="replaceable"><code>num</code></em></span></dt><dd><p>
29 Maximum number of classes per analysis*.jar file.
30 </p></dd><dt><span class="term"><span class="command"><strong>-prefix</strong></span> <em class="replaceable"><code>class name prefix</code></em></span></dt><dd><p>
31 Prefix of class names that should be analyzed (e.g., edu.umd.cs.).
32 </p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="annotations.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="datamining.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;10.&nbsp;Annotations&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;12.&nbsp;Data mining of bugs with <span class="application">FindBugs</span>&#8482;</td></tr></table></div></body></html>
0 <html><head>
1 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2 <title>Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="building.html" title="Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source"><link rel="next" href="gui.html" title="Chapter&nbsp;5.&nbsp;Using the FindBugs GUI"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;4.&nbsp;Running <span class="application">FindBugs</span>&#8482;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="building.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="gui.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;"><div class="titlepage"><div><div><h2 class="title"><a name="running"></a>Chapter&nbsp;4.&nbsp;Running <span class="application">FindBugs</span>&#8482;</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="running.html#d0e465">1. Quick Start</a></span></dt><dt><span class="sect1"><a href="running.html#d0e503">2. Executing <span class="application">FindBugs</span></a></span></dt><dt><span class="sect1"><a href="running.html#commandLineOptions">3. Command-line Options</a></span></dt></dl></div><p>
3 <span class="application">FindBugs</span> has two user interfaces: a graphical user interface (GUI) and a
4 command line user interface. This chapter describes
5 how to run each of these user interfaces.
6 </p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>
7 This chapter is in the process of being re-written.
8 The rewrite is not complete yet.
9 </p></td></tr></table></div><div class="sect1" title="1.&nbsp;Quick Start"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e465"></a>1.&nbsp;Quick Start</h2></div></div></div><p>
10 If you are running <span class="application">FindBugs</span> on a Windows system,
11 double-click on the file <code class="filename"><em class="replaceable"><code>%FINDBUGS_HOME%</code></em>\lib\findbugs.jar</code> to start the <span class="application">FindBugs</span> GUI.
12 </p><p>
13 On a Unix, Linux, or Mac OS X system, run the <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin/findbugs</code>
14 script, or run the command </p><pre class="screen">
15 <span class="command"><strong>java -jar <em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar</strong></span></pre><p>
16 to run the <span class="application">FindBugs</span> GUI.
17 </p><p>
18 Refer to <a class="xref" href="gui.html" title="Chapter&nbsp;5.&nbsp;Using the FindBugs GUI">Chapter&nbsp;5, <i>Using the <span class="application">FindBugs</span> GUI</i></a> for information on how to use the GUI.
19 </p></div><div class="sect1" title="2.&nbsp;Executing FindBugs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e503"></a>2.&nbsp;Executing <span class="application">FindBugs</span></h2></div></div></div><p>
20 This section describes how to invoke the <span class="application">FindBugs</span> program.
21 There are two ways to invoke <span class="application">FindBugs</span>: directly, or using a
22 wrapper script.
23 </p><div class="sect2" title="2.1.&nbsp;Direct invocation of FindBugs"><div class="titlepage"><div><div><h3 class="title"><a name="directInvocation"></a>2.1.&nbsp;Direct invocation of <span class="application">FindBugs</span></h3></div></div></div><p>
24 The preferred method of running <span class="application">FindBugs</span> is to directly execute
25 <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar</code> using the <span class="command"><strong>-jar</strong></span>
26 command line switch of the JVM (<span class="command"><strong>java</strong></span>) executable.
27 (Versions of <span class="application">FindBugs</span> prior to 1.3.5 required a wrapper script
28 to invoke <span class="application">FindBugs</span>.)
29 </p><p>
30 The general syntax of invoking <span class="application">FindBugs</span> directly is the following:
31 </p><pre class="screen">
32 <span class="command"><strong>java <em class="replaceable"><code>[JVM arguments]</code></em> -jar <em class="replaceable"><code>$FINDBUGS_HOME</code></em>/lib/findbugs.jar <em class="replaceable"><code>options...</code></em></strong></span>
33 </pre><p>
34 </p><div class="sect3" title="2.1.1.&nbsp;Choosing the User Interface"><div class="titlepage"><div><div><h4 class="title"><a name="chooseUI"></a>2.1.1.&nbsp;Choosing the User Interface</h4></div></div></div><p>
35 The first command line option chooses the <span class="application">FindBugs</span> user interface to execute.
36 Possible values are:
37 </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
38 <span class="command"><strong>-gui</strong></span>: runs the graphical user interface (GUI)
39 </p></li><li class="listitem"><p>
40 <span class="command"><strong>-textui</strong></span>: runs the command line user interface
41 </p></li><li class="listitem"><p>
42 <span class="command"><strong>-version</strong></span>: displays the <span class="application">FindBugs</span> version number
43 </p></li><li class="listitem"><p>
44 <span class="command"><strong>-help</strong></span>: displays help information for the
45 <span class="application">FindBugs</span> command line user interface
46 </p></li><li class="listitem"><p>
47 <span class="command"><strong>-gui1</strong></span>: executes the original (obsolete)
48 <span class="application">FindBugs</span> graphical user interface
49 </p></li></ul></div></div><div class="sect3" title="2.1.2.&nbsp;Java Virtual Machine (JVM) arguments"><div class="titlepage"><div><div><h4 class="title"><a name="jvmArgs"></a>2.1.2.&nbsp;Java Virtual Machine (JVM) arguments</h4></div></div></div><p>
50 Several Java Virtual Machine arguments are useful when invoking
51 <span class="application">FindBugs</span>.
52 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-Xmx<em class="replaceable"><code>NN</code></em>m</strong></span></span></dt><dd><p>
53 Set the maximum Java heap size to <em class="replaceable"><code>NN</code></em>
54 megabytes. <span class="application">FindBugs</span> generally requires a large amount of
55 memory. For a very large project, using 1500 megabytes
56 is not unusual.
57 </p></dd><dt><span class="term"><span class="command"><strong>-D<em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></strong></span></span></dt><dd><p>
58 Set a Java system property. For example, you might use the
59 argument <span class="command"><strong>-Duser.language=ja</strong></span> to display
60 GUI messages in Japanese.
61 </p></dd></dl></div></div></div><div class="sect2" title="2.2.&nbsp;Invocation of FindBugs using a wrapper script"><div class="titlepage"><div><div><h3 class="title"><a name="wrapperScript"></a>2.2.&nbsp;Invocation of <span class="application">FindBugs</span> using a wrapper script</h3></div></div></div><p>
62 Another way to run <span class="application">FindBugs</span> is to use a wrapper script.
63 </p><p>
64 On Unix-like systems, use the following command to invoke the wrapper script:
65 </p><pre class="screen">
66 <code class="prompt">$ </code><span class="command"><strong><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin/findbugs <em class="replaceable"><code>options...</code></em></strong></span>
67 </pre><p>
68 </p><p>
69 On Windows systems, the command to invoke the wrapper script is
70 </p><pre class="screen">
71 <code class="prompt">C:\My Directory&gt;</code><span class="command"><strong><em class="replaceable"><code>%FINDBUGS_HOME%</code></em>\bin\findbugs.bat <em class="replaceable"><code>options...</code></em></strong></span>
72 </pre><p>
73 </p><p>
74 On both Unix-like and Windows systems, you can simply add the <code class="filename"><em class="replaceable"><code>$FINDBUGS_HOME</code></em>/bin</code>
75 directory to your <code class="filename">PATH</code> environment variable and then invoke
76 FindBugs using the <span class="command"><strong>findbugs</strong></span> command.
77 </p><div class="sect3" title="2.2.1.&nbsp;Wrapper script command line options"><div class="titlepage"><div><div><h4 class="title"><a name="wrapperOptions"></a>2.2.1.&nbsp;Wrapper script command line options</h4></div></div></div><p>The <span class="application">FindBugs</span> wrapper scripts support the following command-line options.
78 Note that these command line options are <span class="emphasis"><em>not</em></span> handled by
79 the <span class="application">FindBugs</span> program per se; rather, they are handled by the wrapper
80 script.
81 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-jvmArgs <em class="replaceable"><code>args</code></em></strong></span></span></dt><dd><p>
82 Specifies arguments to pass to the JVM. For example, you might want
83 to set a JVM property:
84 </p><pre class="screen">
85 <code class="prompt">$ </code><span class="command"><strong>findbugs -textui -jvmArgs "-Duser.language=ja" <em class="replaceable"><code>myApp.jar</code></em></strong></span>
86 </pre><p>
87 </p></dd><dt><span class="term"><span class="command"><strong>-javahome <em class="replaceable"><code>directory</code></em></strong></span></span></dt><dd><p>
88 Specifies the directory containing the JRE (Java Runtime Environment) to
89 use to execute <span class="application">FindBugs</span>.
90 </p></dd><dt><span class="term"><span class="command"><strong>-maxHeap <em class="replaceable"><code>size</code></em></strong></span></span></dt><dd><p>
91 Specifies the maximum Java heap size in megabytes. The default is 256.
92 More memory may be required to analyze very large programs or libraries.
93 </p></dd><dt><span class="term"><span class="command"><strong>-debug</strong></span></span></dt><dd><p>
94 Prints a trace of detectors run and classes analyzed to standard output.
95 Useful for troubleshooting unexpected analysis failures.
96 </p></dd><dt><span class="term"><span class="command"><strong>-property</strong></span> <em class="replaceable"><code>name=value</code></em></span></dt><dd><p>
97 This option sets a system property.&nbsp; <span class="application">FindBugs</span> uses system properties
98 to configure analysis options. See <a class="xref" href="analysisprops.html" title="Chapter&nbsp;9.&nbsp;Analysis Properties">Chapter&nbsp;9, <i>Analysis Properties</i></a>.
99 You can use this option multiple times in order to set multiple properties.
100 Note: In most versions of Windows, the <em class="replaceable"><code>name=value</code></em>
101 string must be in quotes.
102 </p></dd></dl></div></div></div></div><div class="sect1" title="3.&nbsp;Command-line Options"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="commandLineOptions"></a>3.&nbsp;Command-line Options</h2></div></div></div><p>
103 This section describes the command line options supported by <span class="application">FindBugs</span>.
104 These command line options may be used when invoking <span class="application">FindBugs</span> directly,
105 or when using a wrapper script.
106 </p><div class="sect2" title="3.1.&nbsp;Common command-line options"><div class="titlepage"><div><div><h3 class="title"><a name="d0e796"></a>3.1.&nbsp;Common command-line options</h3></div></div></div><p>
107 These options may be used with both the GUI and command-line interfaces.
108 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-effort:min</strong></span></span></dt><dd><p>
109 This option disables analyses that increase precision but also
110 increase memory consumption. You may want to try this option if
111 you find that <span class="application">FindBugs</span> runs out of memory, or takes an unusually
112 long time to complete its analysis.
113 </p></dd><dt><span class="term"><span class="command"><strong>-effort:max</strong></span></span></dt><dd><p>
114 Enable analyses which increase precision and find more bugs, but which
115 may require more memory and take more time to complete.
116 </p></dd><dt><span class="term"><span class="command"><strong>-project</strong></span> <em class="replaceable"><code>project</code></em></span></dt><dd><p>
117 Specify a project to be analyzed. The project file you specify should
118 be one that was created using the GUI interface. It will typically end
119 in the extension <code class="filename">.fb</code> or <code class="filename">.fbp</code>.
120 </p></dd></dl></div></div><div class="sect2" title="3.2.&nbsp;GUI Options"><div class="titlepage"><div><div><h3 class="title"><a name="d0e836"></a>3.2.&nbsp;GUI Options</h3></div></div></div><p>
121 These options are only accepted by the Graphical User Interface.
122
123 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-look:</strong></span><em class="replaceable"><code>plastic|gtk|native</code></em></span></dt><dd><p>
124 Set Swing look and feel.
125 </p></dd></dl></div><p>
126 </p></div><div class="sect2" title="3.3.&nbsp;Text UI Options"><div class="titlepage"><div><div><h3 class="title"><a name="d0e852"></a>3.3.&nbsp;Text UI Options</h3></div></div></div><p>
127 These options are only accepted by the Text User Interface.
128 </p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>-sortByClass</strong></span></span></dt><dd><p>
129 Sort reported bug instances by class name.
130 </p></dd><dt><span class="term"><span class="command"><strong>-include</strong></span> <em class="replaceable"><code>filterFile.xml</code></em></span></dt><dd><p>
131 Only report bug instances that match the filter specified by <em class="replaceable"><code>filterFile.xml</code></em>.
132 See <a class="xref" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files">Chapter&nbsp;8, <i>Filter Files</i></a>.
133 </p></dd><dt><span class="term"><span class="command"><strong>-exclude</strong></span> <em class="replaceable"><code>filterFile.xml</code></em></span></dt><dd><p>
134 Report all bug instances except those matching the filter specified by <em class="replaceable"><code>filterFile.xml</code></em>.
135 See <a class="xref" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files">Chapter&nbsp;8, <i>Filter Files</i></a>.
136 </p></dd><dt><span class="term"><span class="command"><strong>-onlyAnalyze</strong></span> <em class="replaceable"><code>com.foobar.MyClass,com.foobar.mypkg.*</code></em></span></dt><dd><p>
137 Restrict analysis to find bugs to given comma-separated list of
138 classes and packages.
139 Unlike filtering, this option avoids running analysis on
140 classes and packages that are not explicitly matched:
141 for large projects, this may greatly reduce the amount of time
142 needed to run the analysis. (However, some detectors may produce
143 inaccurate results if they aren't run on the entire application.)
144 Classes should be specified using their full classnames (including
145 package), and packages should be specified in the same way
146 they would in a Java <code class="literal">import</code> statement to
147 import all classes in the package (i.e., add <code class="literal">.*</code>
148 to the full name of the package).
149 Replace <code class="literal">.*</code> with <code class="literal">.-</code> to also
150 analyze all subpackages.
151 </p></dd><dt><span class="term"><span class="command"><strong>-low</strong></span></span></dt><dd><p>
152 Report all bugs.
153 </p></dd><dt><span class="term"><span class="command"><strong>-medium</strong></span></span></dt><dd><p>
154 Report medium and high priority bugs. This is the default setting.
155 </p></dd><dt><span class="term"><span class="command"><strong>-high</strong></span></span></dt><dd><p>
156 Report only high priority bugs.
157 </p></dd><dt><span class="term"><span class="command"><strong>-relaxed</strong></span></span></dt><dd><p>
158 Relaxed reporting mode. For many detectors, this option
159 suppresses the heuristics used to avoid reporting false positives.
160 </p></dd><dt><span class="term"><span class="command"><strong>-xml</strong></span></span></dt><dd><p>
161 Produce the bug reports as XML. The XML data produced may be
162 viewed in the GUI at a later time. You may also specify this
163 option as <span class="command"><strong>-xml:withMessages</strong></span>; when this variant
164 of the option is used, the XML output will contain human-readable
165 messages describing the warnings contained in the file.
166 XML files generated this way are easy to transform into reports.
167 </p></dd><dt><span class="term"><span class="command"><strong>-html</strong></span></span></dt><dd><p>
168 Generate HTML output. By default, <span class="application">FindBugs</span> will use the <code class="filename">default.xsl</code>
169 <a class="ulink" href="http://www.w3.org/TR/xslt" target="_top">XSLT</a>
170 stylesheet to generate the HTML: you can find this file in <code class="filename">findbugs.jar</code>,
171 or in the <span class="application">FindBugs</span> source or binary distributions. Variants of this option include
172 <span class="command"><strong>-html:plain.xsl</strong></span>, <span class="command"><strong>-html:fancy.xsl</strong></span> and <span class="command"><strong>-html:fancy-hist.xsl</strong></span>.
173 The <code class="filename">plain.xsl</code> stylesheet does not use Javascript or DOM,
174 and may work better with older web browsers, or for printing. The <code class="filename">fancy.xsl</code>
175 stylesheet uses DOM and Javascript for navigation and CSS for
176 visual presentation. The <span class="command"><strong>fancy-hist.xsl</strong></span> an evolution of <span class="command"><strong>fancy.xsl</strong></span> stylesheet.
177 It makes an extensive use of DOM and Javascript for dynamically filtering the lists of bugs.
178 </p><p>
179 If you want to specify your own
180 XSLT stylesheet to perform the transformation to HTML, specify the option as
181 <span class="command"><strong>-html:<em class="replaceable"><code>myStylesheet.xsl</code></em></strong></span>,
182 where <em class="replaceable"><code>myStylesheet.xsl</code></em> is the filename of the
183 stylesheet you want to use.
184 </p></dd><dt><span class="term"><span class="command"><strong>-emacs</strong></span></span></dt><dd><p>
185 Produce the bug reports in Emacs format.
186 </p></dd><dt><span class="term"><span class="command"><strong>-xdocs</strong></span></span></dt><dd><p>
187 Produce the bug reports in xdoc XML format for use with Apache Maven.
188 </p></dd><dt><span class="term"><span class="command"><strong>-output</strong></span> <em class="replaceable"><code>filename</code></em></span></dt><dd><p>
189 Produce the output in the specified file.
190 </p></dd><dt><span class="term"><span class="command"><strong>-outputFile</strong></span> <em class="replaceable"><code>filename</code></em></span></dt><dd><p>
191 This argument is deprecated. Use <span class="command"><strong>-output</strong></span> instead.
192 </p></dd><dt><span class="term"><span class="command"><strong>-nested</strong></span><em class="replaceable"><code>[:true|false]</code></em></span></dt><dd><p>
193 This option enables or disables scanning of nested jar and zip files found in
194 the list of files and directories to be analyzed.
195 By default, scanning of nested jar/zip files is enabled.
196 To disable it, add <span class="command"><strong>-nested:false</strong></span> to the command line
197 arguments.
198 </p></dd><dt><span class="term"><span class="command"><strong>-auxclasspath</strong></span> <em class="replaceable"><code>classpath</code></em></span></dt><dd><p>
199 Set the auxiliary classpath for analysis. This classpath should include all
200 jar files and directories containing classes that are part of the program
201 being analyzed but you do not want to have analyzed for bugs.
202 </p></dd><dt><span class="term"><span class="command"><strong>-userPrefs</strong></span> <em class="replaceable"><code>edu.umd.cs.findbugs.core.prefs</code></em></span></dt><dd><p>
203 Set the path of the user preferences file to use, which might override some of the options abobe.
204 Specifying <code class="literal">userPrefs</code> as first argument would mean some later
205 options will override them, as last argument would mean they will override some previous options).
206 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
207 line execution.
208 </p></dd></dl></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="building.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="gui.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;5.&nbsp;Using the <span class="application">FindBugs</span> GUI</td></tr></table></div></body></html>
Binary diff not shown
0 <?xml version='1.0'?>
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 version='1.0'
3 xmlns="http://www.w3.org/TR/xhtml1/transitional"
4 exclude-result-prefixes="#default">
5
6 <!-- build.xml will substitute the real path to fo/docbook.xsl here. -->
7 <xsl:import href="/Users/pugh/tools/docbook-xsl-1.76.1/fo/docbook.xsl"/>
8
9 <!-- Enumerate sections. -->
10 <xsl:variable name="section.autolabel">1</xsl:variable>
11
12 <!-- Use graphics in admonitions -->
13 <xsl:variable name="admon.graphics">1</xsl:variable>
14
15 <!-- Admonition graphics are in the "manual" subdirectory. -->
16 <xsl:variable name="admon.graphics.path">manual/</xsl:variable>
17
18 <!-- Included graphics are also in the "manual" subdirectory. -->
19 <xsl:variable name="img.src.path">manual/</xsl:variable>
20
21 <!-- Default image width is 5 inches - otherwise, they become much too large.
22 FIXME: for some reason, this isn't honored. Blech.
23 -->
24 <xsl:variable name="default.image.width">5in</xsl:variable>
25
26 <!-- Just put chapters and sect1s in the TOC. -->
27 <xsl:variable name="toc.section.depth">1</xsl:variable>
28
29 </xsl:stylesheet>
0 <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2 "file:../etc/docbook/docbookx.dtd" [
3 <!ENTITY FindBugs "<application>FindBugs</application>">
4 <!ENTITY Ant "<application>Ant</application>">
5 <!ENTITY Saxon "<application>Saxon</application>">
6 <!ENTITY FBHome "<replaceable>$FINDBUGS_HOME</replaceable>">
7 <!ENTITY FBHomeWin "<replaceable>&#x25;FINDBUGS_HOME&#x25;</replaceable>">
8 <!ENTITY nbsp "&#160;">
9 ]>
10
11 <book lang="en" id="findbugs-manual">
12
13 <bookinfo>
14 <title>&FindBugs;&trade; Manual</title>
15
16 <authorgroup>
17 <author>
18 <firstname>David</firstname>
19 <othername>H.</othername>
20 <surname>Hovemeyer</surname>
21 </author>
22 <author>
23 <firstname>William</firstname>
24 <othername>W.</othername>
25 <surname>Pugh</surname>
26 </author>
27 </authorgroup>
28
29 <copyright>
30 <year>2003 - 2012</year>
31 <holder>University of Maryland</holder>
32 </copyright>
33
34 <legalnotice>
35 <para>
36 This manual is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License.
37 To view a copy of this license, visit
38 <ulink url="http://creativecommons.org/licenses/by-nc-sa/1.0/">http://creativecommons.org/licenses/by-nc-sa/1.0/</ulink>
39 or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
40 </para>
41 <para>
42 The name FindBugs and the FindBugs logo are trademarked by the University of Maryland.
43 </para>
44 </legalnotice>
45
46 <edition>2.0.3</edition>
47
48 <pubdate>17:16:15 EST, 22 November, 2013</pubdate>
49
50 </bookinfo>
51
52 <!--
53 **************************************************************************
54 Introduction
55 **************************************************************************
56 -->
57
58 <chapter id="introduction">
59 <title>Introduction</title>
60
61 <para> &FindBugs;&trade; is a program to find bugs in Java programs. It looks for instances
62 of "bug patterns" --- code instances that are likely to be errors.</para>
63
64 <para> This document describes version 2.0.3 of &FindBugs;.We
65 are very interested in getting your feedback on &FindBugs;. Please visit
66 the <ulink url="http://findbugs.sourceforge.net">&FindBugs; web page</ulink> for
67 the latest information on &FindBugs;, contact information, and support resources such
68 as information about the &FindBugs; mailing lists.</para>
69
70 <sect1>
71 <title>Requirements</title>
72 <para> To use &FindBugs;, you need a runtime environment compatible with
73 <ulink url="http://java.sun.com/j2se">Java 2 Standard Edition</ulink>, version 1.5 or later.
74 &FindBugs; is platform independent, and is known to run on GNU/Linux, Windows, and
75 MacOS X platforms.</para>
76
77 <para>You should have at least 512 MB of memory to use &FindBugs;.
78 To analyze very large projects, more memory may be needed.</para>
79 </sect1>
80
81 </chapter>
82
83 <!--
84 **************************************************************************
85 Installing FindBugs
86 **************************************************************************
87 -->
88
89 <chapter id="installing">
90 <title>Installing &FindBugs;&trade;</title>
91
92 <para>
93 This chapter explains how to install &FindBugs;.
94 </para>
95
96 <sect1>
97 <title>Extracting the Distribution</title>
98
99 <para>
100 The easiest way to install &FindBugs; is to download a binary distribution.
101 Binary distributions are available in
102 <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.tar.gz?download">gzipped tar format</ulink> and
103 <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.zip?download">zip format</ulink>.
104 Once you have downloaded a binary distribution, extract it into a directory of your choice.
105 </para>
106
107 <para>
108 Extracting a gzipped tar format distribution:
109 <screen>
110 <prompt>$ </prompt><command>gunzip -c findbugs-2.0.3.tar.gz | tar xvf -</command>
111 </screen>
112 </para>
113
114 <para>
115 Extracting a zip format distribution:
116 <screen>
117 <prompt>C:\Software></prompt><command>unzip findbugs-2.0.3.zip</command>
118 </screen>
119 </para>
120
121 <para>
122 Usually, extracting a binary distribution will create a directory ending in
123 <filename class="directory">findbugs-2.0.3</filename>. For example, if you extracted
124 the binary distribution from the <filename class="directory">C:\Software</filename>
125 directory, then the &FindBugs; software will be extracted into the directory
126 <filename class="directory">C:\Software\findbugs-2.0.3</filename>.
127 This directory is the &FindBugs; home directory. We'll refer to it as
128 &FBHome; (or &FBHomeWin; for Windows) throughout this manual.
129 </para>
130 </sect1>
131
132 </chapter>
133
134 <!--
135 **************************************************************************
136 Compiling FindBugs from Source
137 **************************************************************************
138 -->
139
140 <chapter id="building">
141 <title>Building &FindBugs;&trade; from Source</title>
142
143 <para>
144 This chapter describes how to build &FindBugs; from source code. Unless you are
145 interesting in modifying &FindBugs;, you will probably want to skip to the
146 <link linkend="running">next chapter</link>.
147 </para>
148
149 <sect1>
150 <title>Prerequisites</title>
151
152 <para>
153 To compile &FindBugs; from source, you will need the following:
154 <itemizedlist>
155 <listitem>
156 <para>
157 The <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download"
158 >&FindBugs; source distribution</ulink>
159 </para>
160 </listitem>
161 <listitem>
162 <para>
163 <ulink url="http://java.sun.com/j2se/">JDK 1.5.0 or later</ulink>
164 </para>
165 </listitem>
166 <listitem>
167 <para>
168 <ulink url="http://ant.apache.org/">Apache &Ant;</ulink>, version 1.6.3 or later
169 </para>
170 </listitem>
171 </itemizedlist>
172 </para>
173
174 <warning>
175 <para>
176 The version of &Ant; included as <filename>/usr/bin/ant</filename> on
177 Redhat Linux systems will <emphasis>not</emphasis> work for compiling
178 &FindBugs;. We recommend you install a binary distribution of &Ant;
179 downloaded from the <ulink url="http://ant.apache.org/">&Ant; website</ulink>.
180 Make sure that when you run &Ant; your <replaceable>JAVA_HOME</replaceable>
181 environment variable points to the directory in which you installed
182 JDK 1.5 (or later).
183 </para>
184 </warning>
185
186 <para>
187 If you want to be able to generate formatted versions of the &FindBugs; documentation,
188 you will also need the following software:
189 <itemizedlist>
190 <listitem>
191 <para>
192 The <ulink url="http://docbook.sourceforge.net/projects/xsl/index.html">DocBook XSL Stylesheets</ulink>.
193 These are required to convert the &FindBugs; manual into HTML format.
194 </para>
195 </listitem>
196 <listitem>
197 <para>
198 The <ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT Processor</ulink>.
199 (Also required for converting the &FindBugs; manual to HTML.)
200 </para>
201 </listitem>
202 <!--
203 <listitem>
204 <para>
205 </para>
206 </listitem>
207 -->
208 </itemizedlist>
209 </para>
210
211 </sect1>
212
213 <sect1>
214 <title>Extracting the Source Distribution</title>
215 <para>
216 After you download the source distribution, you'll need to extract it into
217 a working directory. A typical command to do this is:
218
219 <screen>
220 <prompt>$ </prompt><command>unzip findbugs-2.0.3-source.zip</command>
221 </screen>
222
223 </para>
224 </sect1>
225
226 <sect1>
227 <title>Modifying <filename>local.properties</filename></title>
228 <para>
229 If you intend to build the FindBugs documentation,
230 you will need to modify the <filename>local.properties</filename> file
231 used by the <ulink url="http://ant.apache.org/">&Ant;</ulink>
232 <filename>build.xml</filename> file to build &FindBugs;.
233 If you do not want to build the FindBugs documentation, then you
234 can ignore this file.
235 </para>
236
237 <para>
238 The <filename>local.properties</filename> overrides definitions
239 in the <filename>build.properties</filename> file.
240 The <filename>build.properties</filename> file looks something like this:
241 <programlisting>
242 <![CDATA[
243 # User Configuration:
244 # This section must be modified to reflect your system.
245
246 local.software.home =/export/home/daveho/linux
247
248 # Set this to the directory containing the DocBook Modular XSL Stylesheets
249 # from http://docbook.sourceforge.net/projects/xsl/
250
251 xsl.stylesheet.home =${local.software.home}/docbook/docbook-xsl-1.71.1
252
253 # Set this to the directory where Saxon (http://saxon.sourceforge.net/)
254 # is installed.
255
256 saxon.home =${local.software.home}/java/saxon-6.5.5
257 ]]>
258 </programlisting>
259 </para>
260
261 <para>
262 The <varname>xsl.stylesheet.home</varname> property specifies the full
263 path to the directory where you have installed the
264 <ulink url="http://docbook.sourceforge.net/projects/xsl/">DocBook Modular XSL
265 Stylesheets</ulink>. You only need to specify this property if you will be
266 generating the &FindBugs; documentation.
267 </para>
268
269 <para>
270 The <varname>saxon.home</varname> property is the full path to the
271 directory where you installed the <ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT Processor</ulink>.
272 You only need to specify this property if you will be
273 generating the &FindBugs; documentation.
274 </para>
275
276 </sect1>
277
278 <sect1>
279 <title>Running &Ant;</title>
280
281 <para>
282 Once you have extracted the source distribution,
283 made sure that &Ant; is installed,
284 modified <filename>build.properties</filename> (optional),
285 and configured the tools (such as &Saxon;),
286 you are ready to build &FindBugs;. Invoking &Ant; is a simple matter
287 of running the command
288 <screen>
289 <prompt>$ </prompt><command>ant <replaceable>target</replaceable></command>
290 </screen>
291 where <replaceable>target</replaceable> is one of the following:
292 <variablelist>
293 <varlistentry>
294 <term><command>build</command></term>
295 <listitem>
296 <para>
297 This target compiles the code for &FindBugs;. It is the default target.
298 </para>
299 </listitem>
300 </varlistentry>
301
302 <varlistentry>
303 <term><command>docs</command></term>
304 <listitem>
305 <para>
306 This target formats the documentation. (It also compiles some of
307 the source code as a side-effect.)
308 </para>
309 </listitem>
310 </varlistentry>
311
312 <varlistentry>
313 <term><command>runjunit</command></term>
314 <listitem>
315 <para>
316 This target compiles and runs the internal JUnit tests included
317 in &FindBugs;. It will print an error message if any unit
318 tests fail.
319 </para>
320 </listitem>
321 </varlistentry>
322
323 <varlistentry>
324 <term><command>bindist</command></term>
325 <listitem>
326 <para>
327 Builds a binary distribution of &FindBugs;.
328 The target creates both <filename>.zip</filename> and
329 <filename>.tar.gz</filename> archives.
330 </para>
331 </listitem>
332 </varlistentry>
333 </variablelist>
334 </para>
335
336 <para>
337 After running an &Ant; command, you should see output similar to
338 the following (after some other messages regarding the tasks that
339 &Ant; is running):
340 <screen>
341 <computeroutput>
342 BUILD SUCCESSFUL
343 Total time: 17 seconds
344 </computeroutput>
345 </screen>
346 </para>
347
348 </sect1>
349
350 <sect1>
351 <title>Running &FindBugs;&trade; from a source directory</title>
352 <para>
353 The &Ant; build script for &FindBugs; is written such that after
354 building the <command>build</command> target, the working directory
355 is set up just like a binary distribution. So, the information about
356 running &FindBugs; in <xref linkend="running" />
357 applies to source distributions, too.
358 </para>
359 </sect1>
360
361 </chapter>
362
363
364 <!--
365 **************************************************************************
366 Running FindBugs
367 **************************************************************************
368 -->
369
370 <chapter id="running">
371 <title>Running &FindBugs;&trade;</title>
372
373 <para>
374 &FindBugs; has two user interfaces: a graphical user interface (GUI) and a
375 command line user interface. This chapter describes
376 how to run each of these user interfaces.
377 </para>
378
379 <warning>
380 <para>
381 This chapter is in the process of being re-written.
382 The rewrite is not complete yet.
383 </para>
384 </warning>
385
386 <!--
387 <sect1>
388 <title>Executing the &FindBugs;&trade; GUI</title>
389 </sect1>
390 -->
391
392 <sect1>
393 <title>Quick Start</title>
394 <para>
395 If you are running &FindBugs; on a Windows system,
396 double-click on the file <filename>&FBHomeWin;\lib\findbugs.jar</filename> to start the &FindBugs; GUI.
397 </para>
398
399 <para>
400 On a Unix, Linux, or Mac OS X system, run the <filename>&FBHome;/bin/findbugs</filename>
401 script, or run the command <screen>
402 <command>java -jar &FBHome;/lib/findbugs.jar</command></screen>
403 to run the &FindBugs; GUI.
404 </para>
405
406 <para>
407 Refer to <xref linkend="gui"/> for information on how to use the GUI.
408 </para>
409 </sect1>
410
411 <sect1>
412
413 <title>Executing &FindBugs;</title>
414
415 <para>
416 This section describes how to invoke the &FindBugs; program.
417 There are two ways to invoke &FindBugs;: directly, or using a
418 wrapper script.
419 </para>
420
421
422 <sect2 id="directInvocation">
423 <title>Direct invocation of &FindBugs;</title>
424
425 <para>
426 The preferred method of running &FindBugs; is to directly execute
427 <filename>&FBHome;/lib/findbugs.jar</filename> using the <command>-jar</command>
428 command line switch of the JVM (<command>java</command>) executable.
429 (Versions of &FindBugs; prior to 1.3.5 required a wrapper script
430 to invoke &FindBugs;.)
431 </para>
432
433 <para>
434 The general syntax of invoking &FindBugs; directly is the following:
435 <screen>
436 <command>java <replaceable>[JVM arguments]</replaceable> -jar &FBHome;/lib/findbugs.jar <replaceable>options...</replaceable></command>
437 </screen>
438 </para>
439
440 <!--
441 <para>
442 By default, executing <filename>findbugs.jar</filename> runs the
443 &FindBugs; graphical user interface (GUI). On windows systems,
444 you can double-click on <filename>findbugs.jar</filename> to launch
445 the GUI. From a command line, the command
446 <screen>
447 java -jar <replaceable>&FBHome;</replaceable>/lib/findbugs.jar</screen>
448 will launch the GUI.
449 </para>
450 -->
451
452 <sect3 id="chooseUI">
453 <title>Choosing the User Interface</title>
454
455 <para>
456 The first command line option chooses the &FindBugs; user interface to execute.
457 Possible values are:
458 </para>
459 <itemizedlist>
460 <listitem>
461 <para>
462 <command>-gui</command>: runs the graphical user interface (GUI)
463 </para>
464 </listitem>
465
466 <listitem>
467 <para>
468 <command>-textui</command>: runs the command line user interface
469 </para>
470 </listitem>
471
472 <listitem>
473 <para>
474 <command>-version</command>: displays the &FindBugs; version number
475 </para>
476 </listitem>
477
478 <listitem>
479 <para>
480 <command>-help</command>: displays help information for the
481 &FindBugs; command line user interface
482 </para>
483 </listitem>
484
485 <listitem>
486 <para>
487 <command>-gui1</command>: executes the original (obsolete)
488 &FindBugs; graphical user interface
489 </para>
490 </listitem>
491 </itemizedlist>
492
493 </sect3>
494
495 <sect3 id="jvmArgs">
496 <title>Java Virtual Machine (JVM) arguments</title>
497
498 <para>
499 Several Java Virtual Machine arguments are useful when invoking
500 &FindBugs;.
501 </para>
502
503 <variablelist>
504 <varlistentry>
505 <term><command>-Xmx<replaceable>NN</replaceable>m</command></term>
506 <listitem>
507 <para>
508 Set the maximum Java heap size to <replaceable>NN</replaceable>
509 megabytes. &FindBugs; generally requires a large amount of
510 memory. For a very large project, using 1500 megabytes
511 is not unusual.
512 </para>
513 </listitem>
514 </varlistentry>
515
516 <varlistentry>
517 <term><command>-D<replaceable>name</replaceable>=<replaceable>value</replaceable></command></term>
518 <listitem>
519 <para>
520 Set a Java system property. For example, you might use the
521 argument <command>-Duser.language=ja</command> to display
522 GUI messages in Japanese.
523 </para>
524 </listitem>
525 </varlistentry>
526
527 <!--
528 <varlistentry>
529 <term></term>
530 <listitem>
531 <para>
532 </para>
533 </listitem>
534 </varlistentry>
535 -->
536 </variablelist>
537 </sect3>
538
539 </sect2>
540
541 <sect2 id="wrapperScript">
542 <title>Invocation of &FindBugs; using a wrapper script</title>
543
544 <para>
545 Another way to run &FindBugs; is to use a wrapper script.
546 </para>
547
548 <para>
549 On Unix-like systems, use the following command to invoke the wrapper script:
550 <screen>
551 <prompt>$ </prompt><command>&FBHome;/bin/findbugs <replaceable>options...</replaceable></command>
552 </screen>
553 </para>
554
555 <para>
556 On Windows systems, the command to invoke the wrapper script is
557 <screen>
558 <prompt>C:\My Directory></prompt><command>&FBHomeWin;\bin\findbugs.bat <replaceable>options...</replaceable></command>
559 </screen>
560 </para>
561
562 <para>
563 On both Unix-like and Windows systems, you can simply add the <filename><replaceable>$FINDBUGS_HOME</replaceable>/bin</filename>
564 directory to your <filename>PATH</filename> environment variable and then invoke
565 FindBugs using the <command>findbugs</command> command.
566 </para>
567
568 <sect3 id="wrapperOptions">
569 <title>Wrapper script command line options</title>
570 <para>The &FindBugs; wrapper scripts support the following command-line options.
571 Note that these command line options are <emphasis>not</emphasis> handled by
572 the &FindBugs; program per se; rather, they are handled by the wrapper
573 script.
574 </para>
575 <variablelist>
576 <varlistentry>
577 <term><command>-jvmArgs <replaceable>args</replaceable></command></term>
578 <listitem>
579 <para>
580 Specifies arguments to pass to the JVM. For example, you might want
581 to set a JVM property:
582 <screen>
583 <prompt>$ </prompt><command>findbugs -textui -jvmArgs "-Duser.language=ja" <replaceable>myApp.jar</replaceable></command>
584 </screen>
585 </para>
586 </listitem>
587 </varlistentry>
588
589 <varlistentry>
590 <term><command>-javahome <replaceable>directory</replaceable></command></term>
591 <listitem>
592 <para>
593 Specifies the directory containing the JRE (Java Runtime Environment) to
594 use to execute &FindBugs;.
595 </para>
596 </listitem>
597 </varlistentry>
598
599 <varlistentry>
600 <term><command>-maxHeap <replaceable>size</replaceable></command></term>
601 <listitem>
602 <para>
603 Specifies the maximum Java heap size in megabytes. The default is 256.
604 More memory may be required to analyze very large programs or libraries.
605 </para>
606 </listitem>
607 </varlistentry>
608
609 <varlistentry>
610 <term><command>-debug</command></term>
611 <listitem>
612 <para>
613 Prints a trace of detectors run and classes analyzed to standard output.
614 Useful for troubleshooting unexpected analysis failures.
615 </para>
616 </listitem>
617 </varlistentry>
618
619 <varlistentry>
620 <term><command>-property</command> <replaceable>name=value</replaceable></term>
621 <listitem>
622 <para>
623 This option sets a system property.&nbsp; &FindBugs; uses system properties
624 to configure analysis options. See <xref linkend="analysisprops"/>.
625 You can use this option multiple times in order to set multiple properties.
626 Note: In most versions of Windows, the <replaceable>name=value</replaceable>
627 string must be in quotes.
628 </para>
629 </listitem>
630 </varlistentry>
631
632 </variablelist>
633
634 </sect3>
635
636 </sect2>
637
638 </sect1>
639
640 <sect1 id="commandLineOptions">
641 <title>Command-line Options</title>
642
643 <!--
644 <para>
645
646 There are two ways to invoke &FindBugs;. The first invokes the the Graphical User Interface (GUI):
647
648 <screen>
649 <prompt>$ </prompt><command>findbugs <replaceable>[standard options]</replaceable> <replaceable>[GUI options]</replaceable></command>
650 </screen>
651
652 The second invokes the Command Line Interface (Text UI):
653
654 <screen>
655 <prompt>$ </prompt><command>findbugs -textui <replaceable>[standard options]</replaceable> <replaceable>[Text UI options]</replaceable></command>
656 </screen>
657 </para>
658 -->
659
660 <para>
661 This section describes the command line options supported by &FindBugs;.
662 These command line options may be used when invoking &FindBugs; directly,
663 or when using a wrapper script.
664 </para>
665
666 <sect2>
667 <title>Common command-line options</title>
668
669 <para>
670 These options may be used with both the GUI and command-line interfaces.
671 </para>
672
673 <variablelist>
674
675 <varlistentry>
676 <term><command>-effort:min</command></term>
677 <listitem>
678 <para>
679 This option disables analyses that increase precision but also
680 increase memory consumption. You may want to try this option if
681 you find that &FindBugs; runs out of memory, or takes an unusually
682 long time to complete its analysis.
683 </para>
684 </listitem>
685 </varlistentry>
686
687
688 <varlistentry>
689 <term><command>-effort:max</command></term>
690 <listitem>
691 <para>
692 Enable analyses which increase precision and find more bugs, but which
693 may require more memory and take more time to complete.
694 </para>
695 </listitem>
696 </varlistentry>
697
698 <varlistentry>
699 <term><command>-project</command> <replaceable>project</replaceable></term>
700 <listitem>
701 <para>
702 Specify a project to be analyzed. The project file you specify should
703 be one that was created using the GUI interface. It will typically end
704 in the extension <filename>.fb</filename> or <filename>.fbp</filename>.
705 </para>
706 </listitem>
707 </varlistentry>
708
709 <!--
710 <varlistentry>
711 <term><command></command></term>
712 <listitem>
713 <para>
714
715 </para>
716 </listitem>
717 </varlistentry>
718 -->
719
720 </variablelist>
721
722 </sect2>
723
724 <sect2>
725 <title>GUI Options</title>
726
727 <para>
728 These options are only accepted by the Graphical User Interface.
729
730 <variablelist>
731 <varlistentry>
732 <term><command>-look:</command><replaceable>plastic|gtk|native</replaceable></term>
733 <listitem>
734 <para>
735 Set Swing look and feel.
736 </para>
737 </listitem>
738 </varlistentry>
739
740 </variablelist>
741 </para>
742 </sect2>
743
744 <sect2>
745 <title>Text UI Options</title>
746
747 <para>
748 These options are only accepted by the Text User Interface.
749 </para>
750
751 <variablelist>
752 <varlistentry>
753 <term><command>-sortByClass</command></term>
754 <listitem>
755 <para>
756 Sort reported bug instances by class name.
757 </para>
758 </listitem>
759 </varlistentry>
760
761 <varlistentry>
762 <term><command >-include</command> <replaceable>filterFile.xml</replaceable></term>
763 <listitem>
764 <para>
765 Only report bug instances that match the filter specified by <replaceable>filterFile.xml</replaceable>.
766 See <xref linkend="filter" />.
767 </para>
768 </listitem>
769 </varlistentry>
770
771 <varlistentry>
772 <term><command >-exclude</command> <replaceable>filterFile.xml</replaceable></term>
773 <listitem>
774 <para>
775 Report all bug instances except those matching the filter specified by <replaceable>filterFile.xml</replaceable>.
776 See <xref linkend="filter" />.
777 </para>
778 </listitem>
779 </varlistentry>
780
781 <varlistentry>
782 <term><command>-onlyAnalyze</command> <replaceable>com.foobar.MyClass,com.foobar.mypkg.*</replaceable></term>
783 <listitem>
784 <para>
785 Restrict analysis to find bugs to given comma-separated list of
786 classes and packages.
787 Unlike filtering, this option avoids running analysis on
788 classes and packages that are not explicitly matched:
789 for large projects, this may greatly reduce the amount of time
790 needed to run the analysis. (However, some detectors may produce
791 inaccurate results if they aren't run on the entire application.)
792 Classes should be specified using their full classnames (including
793 package), and packages should be specified in the same way
794 they would in a Java <literal>import</literal> statement to
795 import all classes in the package (i.e., add <literal>.*</literal>
796 to the full name of the package).
797 Replace <literal>.*</literal> with <literal>.-</literal> to also
798 analyze all subpackages.
799 </para>
800 </listitem>
801 </varlistentry>
802
803 <varlistentry>
804 <term><command>-low</command></term>
805 <listitem>
806 <para>
807 Report all bugs.
808 </para>
809 </listitem>
810 </varlistentry>
811
812 <varlistentry>
813 <term><command>-medium</command></term>
814 <listitem>
815 <para>
816 Report medium and high priority bugs. This is the default setting.
817 </para>
818 </listitem>
819 </varlistentry>
820
821 <varlistentry>
822 <term><command>-high</command></term>
823 <listitem>
824 <para>
825 Report only high priority bugs.
826 </para>
827 </listitem>
828 </varlistentry>
829
830 <varlistentry>
831 <term><command>-relaxed</command></term>
832 <listitem>
833 <para>
834 Relaxed reporting mode. For many detectors, this option
835 suppresses the heuristics used to avoid reporting false positives.
836 </para>
837 </listitem>
838 </varlistentry>
839
840 <varlistentry>
841 <term><command>-xml</command></term>
842 <listitem>
843 <para>
844 Produce the bug reports as XML. The XML data produced may be
845 viewed in the GUI at a later time. You may also specify this
846 option as <command>-xml:withMessages</command>; when this variant
847 of the option is used, the XML output will contain human-readable
848 messages describing the warnings contained in the file.
849 XML files generated this way are easy to transform into reports.
850 </para>
851 </listitem>
852 </varlistentry>
853
854 <varlistentry>
855 <term><command>-html</command></term>
856 <listitem>
857 <para>
858 Generate HTML output. By default, &FindBugs; will use the <filename>default.xsl</filename>
859 <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink>
860 stylesheet to generate the HTML: you can find this file in <filename>findbugs.jar</filename>,
861 or in the &FindBugs; source or binary distributions. Variants of this option include
862 <command>-html:plain.xsl</command>, <command>-html:fancy.xsl</command> and <command>-html:fancy-hist.xsl</command>.
863 The <filename>plain.xsl</filename> stylesheet does not use Javascript or DOM,
864 and may work better with older web browsers, or for printing. The <filename>fancy.xsl</filename>
865 stylesheet uses DOM and Javascript for navigation and CSS for
866 visual presentation. The <command>fancy-hist.xsl</command> an evolution of <command>fancy.xsl</command> stylesheet.
867 It makes an extensive use of DOM and Javascript for dynamically filtering the lists of bugs.
868 </para>
869
870 <para>
871 If you want to specify your own
872 XSLT stylesheet to perform the transformation to HTML, specify the option as
873 <command>-html:<replaceable>myStylesheet.xsl</replaceable></command>,
874 where <replaceable>myStylesheet.xsl</replaceable> is the filename of the
875 stylesheet you want to use.
876 </para>
877 </listitem>
878 </varlistentry>
879
880 <varlistentry>
881 <term><command>-emacs</command></term>
882 <listitem>
883 <para>
884 Produce the bug reports in Emacs format.
885 </para>
886 </listitem>
887 </varlistentry>
888
889 <varlistentry>
890 <term><command>-xdocs</command></term>
891 <listitem>
892 <para>
893 Produce the bug reports in xdoc XML format for use with Apache Maven.
894 </para>
895 </listitem>
896 </varlistentry>
897
898 <varlistentry>
899 <term><command>-output</command> <replaceable>filename</replaceable></term>
900 <listitem>
901 <para>
902 Produce the output in the specified file.
903 </para>
904 </listitem>
905 </varlistentry>
906
907 <varlistentry>
908 <term><command>-outputFile</command> <replaceable>filename</replaceable></term>
909 <listitem>
910 <para>
911 This argument is deprecated. Use <command>-output</command> instead.
912 </para>
913 </listitem>
914 </varlistentry>
915
916 <varlistentry>
917 <term><command>-nested</command><replaceable>[:true|false]</replaceable></term>
918 <listitem>
919 <para>
920 This option enables or disables scanning of nested jar and zip files found in
921 the list of files and directories to be analyzed.
922 By default, scanning of nested jar/zip files is enabled.
923 To disable it, add <command>-nested:false</command> to the command line
924 arguments.
925 </para>
926 </listitem>
927 </varlistentry>
928
929 <varlistentry>
930 <term><command>-auxclasspath</command> <replaceable>classpath</replaceable></term>
931 <listitem>
932 <para>
933 Set the auxiliary classpath for analysis. This classpath should include all
934 jar files and directories containing classes that are part of the program
935 being analyzed but you do not want to have analyzed for bugs.
936 </para>
937 </listitem>
938 </varlistentry>
939
940 <varlistentry>
941 <term><command>-userPrefs</command> <replaceable>edu.umd.cs.findbugs.core.prefs</replaceable></term>
942 <listitem>
943 <para>
944 Set the path of the user preferences file to use, which might override some of the options abobe.
945 Specifying <literal>userPrefs</literal> as first argument would mean some later
946 options will override them, as last argument would mean they will override some previous options).
947 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
948 line execution.
949 </para>
950 </listitem>
951 </varlistentry>
952
953 <!--
954 <varlistentry>
955 <term><command></command> <replaceable></replaceable></term>
956 <listitem>
957 <para>
958 </para>
959 </listitem>
960 </varlistentry>
961 -->
962
963 </variablelist>
964
965 </sect2>
966 </sect1>
967
968
969 </chapter>
970
971 <chapter id="gui">
972 <title>Using the &FindBugs; GUI</title>
973
974 <para>
975 This chapter describes how to use the &FindBugs; graphical user interface (GUI).
976 </para>
977
978 <sect1>
979 <title>Creating a Project</title>
980 <para>
981 After you have started &FindBugs; using the <command>findbugs</command> command,
982 choose the <menuchoice><guimenu>File</guimenu><guimenuitem>New Project</guimenuitem></menuchoice>
983 menu item. You will see a dialog which looks like this:
984 <mediaobject>
985 <imageobject>
986 <imagedata fileref="project-dialog.png" />
987 </imageobject>
988 </mediaobject>
989 </para>
990
991 <para>
992 Use the "Add" button next to "Classpath to analyze" to select a Java archive
993 file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple
994 archives/directories.
995 </para>
996
997 <para>
998 You can also add the source directories which contain
999 the source code for the Java archives you are analyzing. This will enable
1000 &FindBugs; to highlight the source code which contains a possible error.
1001 The source directories you add should be the roots of the Java
1002 package hierarchy. For example, if your application is contained in the
1003 <varname>org.foobar.myapp</varname> package, you should add the
1004 parent directory of the <filename class="directory">org</filename> directory
1005 to the source directory list for the project.
1006 </para>
1007
1008 <para>
1009 Another optional step is to add additional Jar files or directories as
1010 "Auxiliary classpath locations" entries. You should do this if the archives and directories you are analyzing
1011 have references to other classes which are not included in the analyzed
1012 archives/directories and are not in the standard runtime classpath. Some of the bug
1013 pattern detectors in &FindBugs; make use of class hierarchy information,
1014 so you will get more accurate results if the entire class hierarchy is
1015 available which &FindBugs; performs its analysis.
1016 </para>
1017
1018 </sect1>
1019
1020 <sect1>
1021 <title>Running the Analysis</title>
1022 <para>
1023 Once you have added all of the archives, directories, and source directories,
1024 click the "Analyze" button to analyze the classes contained in the
1025 Jar files. Note that for a very large program on an older computer,
1026 this may take quite a while (tens of minutes). A recent computer with
1027 ample memory will typically be able to analyze a large program in only a
1028 few minutes.
1029 </para>
1030 </sect1>
1031
1032 <sect1>
1033 <title>Browsing Results</title>
1034
1035 <para>
1036 When the analysis completes, you will see a screen like the following:
1037 <mediaobject>
1038 <imageobject>
1039 <imagedata fileref="example-details.png" />
1040 </imageobject>
1041 </mediaobject>
1042 </para>
1043
1044 <para>
1045 The upper left-hand pane of the window shows the bug tree; this is a hierarchical
1046 representation of all of the potential bugs detected in the analyzed
1047 Jar files.
1048 </para>
1049
1050 <para>
1051 When you select a particular bug instance in the top pane, you will
1052 see a description of the bug in the "Details" tab of the bottom pane.
1053 In addition, the source code pane on the upper-right will show the
1054 program source code where the potential bug occurs, if source is available.
1055 In the above example, the bug is a stream object that is not closed. The
1056 source code window highlights the line where the stream object is created.
1057 </para>
1058
1059 <para>
1060 You may add a textual annotations to bug instances. To do so, type them
1061 into the text box just below the hierarchical view. You can type any
1062 information which you would like to record. When you load and save bug
1063 results files, the annotations are preserved.
1064 </para>
1065
1066 </sect1>
1067
1068 <sect1>
1069 <title>Saving and Opening</title>
1070
1071 <para>
1072 You may use the <menuchoice><guimenu>File</guimenu><guimenuitem>Save as...</guimenuitem></menuchoice>
1073 menu option to save your work. To save your work, including the jar
1074 file lists you specified and all bug results, choose
1075 "FindBugs analysis results (.xml)" from the drop-down list in the
1076 "Save as..." dialog. There are also options for saving just the jar
1077 file lists ("FindBugs project file (.fbp)") or just the results
1078 ("FindBugs analysis file (.fba)").
1079 A saved file may be loaded with the
1080 <menuchoice><guimenu>File</guimenu><guimenuitem>Open...</guimenuitem></menuchoice>
1081 menu option.
1082 </para>
1083
1084 </sect1>
1085
1086 <!--
1087 <sect1 id="textui">
1088 <title>Using the &FindBugs;&trade; Command Line Interface</title>
1089
1090 <para>
1091 The &FindBugs; Command Line Interface (or Text UI) can be used to
1092 analyze an application for bugs non-interactively. Each bug instance will be
1093 reported on a single line. All output is written to the standard output file descriptor.
1094 <xref linkend="filter" /> explains how bug reports may be filtered in order
1095 to get only the output you're interested in.
1096 </para>
1097
1098 <para>
1099 See <xref linkend="commandLineOptions" /> for a description of how to invoke the
1100 Command Line Interface.
1101 </para>
1102 </sect1>
1103 -->
1104
1105 </chapter>
1106
1107 <!--
1108 **************************************************************************
1109 Using the FindBugs Ant task
1110 **************************************************************************
1111 -->
1112
1113 <chapter id="anttask">
1114 <title>Using the &FindBugs;&trade; &Ant; task</title>
1115
1116 <para>
1117 This chapter describes how to integrate &FindBugs; into a build script
1118 for <ulink url="http://ant.apache.org/">&Ant;</ulink>, which is a popular Java build
1119 and deployment tool. Using the &FindBugs; &Ant; task, your build script can
1120 automatically run &FindBugs; on your Java code.
1121 </para>
1122
1123 <para>
1124 The &Ant; task was generously contributed by Mike Fagan.
1125 </para>
1126
1127 <sect1>
1128 <title>Installing the &Ant; task</title>
1129
1130 <para>
1131 To install the &Ant; task, simply copy <filename>&FBHome;/lib/findbugs-ant.jar</filename>
1132 into the <filename>lib</filename> subdirectory of your &Ant; installation.
1133
1134 <note>
1135 <para>It is strongly recommended that you use the &Ant; task with the version
1136 of &FindBugs; it was included with. We do not guarantee that the &Ant; task Jar file
1137 will work with any version of &FindBugs; other than the one it was included with.</para>
1138 </note>
1139 </para>
1140
1141 </sect1>
1142
1143 <sect1>
1144 <title>Modifying build.xml</title>
1145
1146 <para>
1147 To incorporate &FindBugs; into <filename>build.xml</filename> (the build script
1148 for &Ant;), you first need to add a task definition. This should appear as follows:
1149
1150 <screen>
1151 &lt;taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/&gt;
1152 </screen>
1153
1154 The task definition specifies that when a <literal>findbugs</literal> element is
1155 seen in <filename>build.xml</filename>, it should use the indicated class to execute the task.
1156 </para>
1157
1158 <para>
1159 After you have added the task definition, you can define a target
1160 which uses the <literal>findbugs</literal> task. Here is an example
1161 which could be added to the <filename>build.xml</filename> for the
1162 Apache <ulink url="http://jakarta.apache.org/bcel/">BCEL</ulink> library.
1163
1164 <screen>
1165 &lt;property name="findbugs.home" value="/export/home/daveho/work/findbugs" /&gt;
1166
1167 &lt;target name="findbugs" depends="jar"&gt;
1168 &lt;findbugs home="${findbugs.home}"
1169 output="xml"
1170 outputFile="bcel-fb.xml" &gt;
1171 &lt;auxClasspath path="${basedir}/lib/Regex.jar" /&gt;
1172 &lt;sourcePath path="${basedir}/src/java" /&gt;
1173 &lt;class location="${basedir}/bin/bcel.jar" /&gt;
1174 &lt;/findbugs&gt;
1175 &lt;/target&gt;
1176 </screen>
1177
1178 The <literal>findbugs</literal> element must have the <literal>home</literal>
1179 attribute set to the directory in which &FindBugs; is installed; in other words,
1180 &FBHome;. See <xref linkend="installing" />.
1181 </para>
1182
1183 <para>
1184 This target will execute &FindBugs; on <filename>bcel.jar</filename>, which is the
1185 Jar file produced by BCEL's build script. (By making it depend on the "jar"
1186 target, we ensure that the library is fully compiled before running &FindBugs; on it.)
1187 The output of &FindBugs; will be saved in XML format to a file called
1188 <filename>bcel-fb.xml</filename>.
1189 An auxiliary Jar file, <filename>Regex.jar</filename>, is added to the aux classpath,
1190 because it is referenced by the main BCEL library. A source path is specified
1191 so that the saved bug data will have accurate references to the BCEL source code.
1192 </para>
1193 </sect1>
1194
1195 <sect1>
1196 <title>Executing the task</title>
1197
1198 <para>
1199 Here is an example of invoking &Ant; from the command line, using the <literal>findbugs</literal>
1200 target defined above.
1201
1202 <screen>
1203 <prompt>[daveho@noir]$</prompt> <command>ant findbugs</command>
1204 Buildfile: build.xml
1205
1206 init:
1207
1208 compile:
1209
1210 examples:
1211
1212 jar:
1213
1214 findbugs:
1215 [findbugs] Running FindBugs...
1216 [findbugs] Bugs were found
1217 [findbugs] Output saved to bcel-fb.xml
1218
1219 BUILD SUCCESSFUL
1220 Total time: 35 seconds
1221 </screen>
1222
1223 In this case, because we saved the bug results in an XML file, we can
1224 use the &FindBugs; GUI to view the results; see <xref linkend="running"/>.
1225 </para>
1226
1227 </sect1>
1228
1229 <sect1>
1230 <title>Parameters</title>
1231
1232 <para>This section describes the parameters that may be specified when
1233 using the &FindBugs; task.
1234
1235 <variablelist>
1236
1237 <varlistentry>
1238 <term><literal>class</literal></term>
1239 <listitem>
1240 <para>
1241 A optional nested element specifying which classes to analyze. The <literal>class</literal>
1242 element must specify a <literal>location</literal> attribute which names the
1243 archive file (jar, zip, etc.), directory, or class file to be analyzed. Multiple <literal>class</literal>
1244 elements may be specified as children of a single <literal>findbugs</literal> element.
1245 </para>
1246 <para>In addition to or instead of specifying a <literal>class</literal> element,
1247 the &FindBugs; task can contain one or more <literal>fileset</literal> element(s) that
1248 specify files to be analyzed.
1249 For example, you might use a fileset to specify that all of the jar files in a directory
1250 should be analyzed.
1251 </para>
1252 </listitem>
1253 </varlistentry>
1254
1255 <varlistentry>
1256 <term><literal>auxClasspath</literal></term>
1257 <listitem>
1258 <para>
1259 An optional nested element which specifies a classpath (Jar files or directories)
1260 containing classes used by the analyzed library or application, but which
1261 you don't want to analyze. It is specified the same way as
1262 &Ant;'s <literal>classpath</literal> element for the Java task.
1263 </para>
1264 </listitem>
1265 </varlistentry>
1266
1267 <varlistentry>
1268 <term><literal>sourcePath</literal></term>
1269 <listitem>
1270 <para>
1271 An optional nested element which specifies a source directory path
1272 containing source files used to compile the Java code being analyzed.
1273 By specifying a source path, any generated XML bug output will have
1274 complete source information, which allows later viewing in the
1275 GUI.
1276 </para>
1277 </listitem>
1278 </varlistentry>
1279
1280 <varlistentry>
1281 <term><literal>home</literal></term>
1282 <listitem>
1283 <para>
1284 A required attribute.
1285 It must be set to the name of the directory where &FindBugs; is installed.
1286 </para>
1287 </listitem>
1288 </varlistentry>
1289
1290 <varlistentry>
1291 <term><literal>quietErrors</literal></term>
1292 <listitem>
1293 <para>
1294 An optional boolean attribute.
1295 If true, reports of serious analysis errors and missing classes will
1296 be suppressed in the &FindBugs; output. Default is false.
1297 </para>
1298 </listitem>
1299 </varlistentry>
1300
1301 <varlistentry>
1302 <term><literal>reportLevel</literal></term>
1303 <listitem>
1304 <para>
1305 An optional attribute. It specifies
1306 the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs.
1307 If set to "medium" (the default), low confidence issues are supressed.
1308 If set to "high", only high confidence bugs are reported.
1309 </para>
1310 </listitem>
1311 </varlistentry>
1312
1313 <varlistentry>
1314 <term><literal>output</literal></term>
1315 <listitem>
1316 <para>
1317 Optional attribute.
1318 It specifies the output format. If set to "xml" (the default), output
1319 is in XML format.
1320 If set to "xml:withMessages", output is in XML format augmented with
1321 human-readable messages. (You should use this format if you plan
1322 to generate a report using an XSL stylesheet.)
1323 If set to "html", output is in HTML formatted (default stylesheet is default.xsl).
1324 If set to "text", output is in ad-hoc text format.
1325 If set to "emacs", output is in <ulink url="http://www.gnu.org/software/emacs/">Emacs</ulink> error message format.
1326 If set to "xdocs", output is xdoc XML for use with Apache Maven.
1327 </para>
1328 </listitem>
1329 </varlistentry>
1330 <varlistentry>
1331 <term><literal>stylesheet</literal></term>
1332 <listitem>
1333 <para>
1334 Optional attribute.
1335 It specifies the stylesheet to use to generate html output when the output is set to html.
1336 Stylesheets included in the FindBugs distribution include default.xsl, fancy.xsl, fancy-hist.xsl, plain.xsl, and summary.xsl.
1337 The default value, if no stylesheet attribute is provided, is default.xsl.
1338
1339 </para>
1340 </listitem>
1341 </varlistentry>
1342
1343 <varlistentry>
1344 <term><literal>sort</literal></term>
1345 <listitem>
1346 <para>
1347 Optional attribute. If the <literal>output</literal> attribute
1348 is set to "text", then the <literal>sort</literal> attribute specifies
1349 whether or not reported bugs are sorted by class. Default is true.
1350 </para>
1351 </listitem>
1352 </varlistentry>
1353
1354 <varlistentry>
1355 <term><literal>outputFile</literal></term>
1356 <listitem>
1357 <para>
1358 Optional attribute. If specified, names the output file in which the
1359 &FindBugs; output will be saved. By default, the output is displayed
1360 directly by &Ant;.
1361 </para>
1362 </listitem>
1363 </varlistentry>
1364
1365 <varlistentry>
1366 <term><literal>debug</literal></term>
1367 <listitem>
1368 <para>
1369 Optional boolean attribute. If set to true, &FindBugs; prints diagnostic
1370 information about which classes are being analyzed, and which bug pattern
1371 detectors are being run. Default is false.
1372 </para>
1373 </listitem>
1374 </varlistentry>
1375
1376 <varlistentry>
1377 <term><literal>effort</literal></term>
1378 <listitem>
1379 <para>
1380 Set the analysis effort level. The value specified should be
1381 one of <literal>min</literal>, <literal>default</literal>,
1382 or <literal>max</literal>. See <xref linkend="commandLineOptions"/>
1383 for more information about setting the analysis level.
1384 </para>
1385 </listitem>
1386 </varlistentry>
1387
1388 <varlistentry>
1389 <term><literal>conserveSpace</literal></term>
1390 <listitem>
1391 <para>Synonym for effort="min".</para>
1392 </listitem>
1393 </varlistentry>
1394
1395 <varlistentry>
1396 <term><literal>workHard</literal></term>
1397 <listitem>
1398 <para>Synonym for effort="max".</para>
1399 </listitem>
1400 </varlistentry>
1401
1402 <varlistentry>
1403 <term><literal>visitors</literal></term>
1404 <listitem>
1405 <para>
1406 Optional attribute. It specifies a comma-separated list of bug detectors
1407 which should be run. The bug detectors are specified by their class names,
1408 without any package qualification. By default, all detectors which are
1409 not disabled by default are run.
1410 </para>
1411 </listitem>
1412 </varlistentry>
1413
1414 <varlistentry>
1415 <term><literal>omitVisitors</literal></term>
1416 <listitem>
1417 <para>
1418 Optional attribute. It is like the <literal>visitors</literal> attribute,
1419 except it specifies detectors which will <emphasis>not</emphasis> be run.
1420 </para>
1421 </listitem>
1422 </varlistentry>
1423
1424 <varlistentry>
1425 <term><literal>excludeFilter</literal></term>
1426 <listitem>
1427 <para>
1428 Optional attribute. It specifies the filename of a filter specifying bugs
1429 to exclude from being reported. See <xref linkend="filter" />.
1430 </para>
1431 </listitem>
1432 </varlistentry>
1433
1434 <varlistentry>
1435 <term><literal>includeFilter</literal></term>
1436 <listitem>
1437 <para>
1438 Optional attribute. It specifies the filename of a filter specifying
1439 which bugs are reported. See <xref linkend="filter" />.
1440 </para>
1441 </listitem>
1442 </varlistentry>
1443
1444 <varlistentry>
1445 <term><literal>projectFile</literal></term>
1446 <listitem>
1447 <para>
1448 Optional attribute. It specifies the name of a project file.
1449 Project files are created by the &FindBugs; GUI, and specify classes,
1450 aux classpath entries, and source directories. By naming a project,
1451 you don't need to specify any <literal>class</literal> elements,
1452 nor do you need to specify <literal>auxClasspath</literal> or
1453 <literal>sourcePath</literal> attributes.
1454 See <xref linkend="running"/> for how to create a project.
1455 </para>
1456 </listitem>
1457 </varlistentry>
1458
1459 <varlistentry>
1460 <term><literal>jvmargs</literal></term>
1461 <listitem>
1462 <para>
1463 Optional attribute. It specifies any arguments that should be passed
1464 to the Java virtual machine used to run &FindBugs;. You may need to
1465 use this attribute to specify flags to increase the amount of memory
1466 the JVM may use if you are analyzing a very large program.
1467 </para>
1468 </listitem>
1469 </varlistentry>
1470
1471 <varlistentry>
1472 <term><literal>systemProperty</literal></term>
1473 <listitem>
1474 <para>
1475 Optional nested element. If specified, defines a system property.
1476 The <literal>name</literal> attribute specifies the name of the
1477 system property, and the <literal>value</literal> attribute specifies
1478 the value of the system property.
1479 </para>
1480 </listitem>
1481 </varlistentry>
1482
1483 <varlistentry>
1484 <term><literal>timeout</literal></term>
1485 <listitem>
1486 <para>
1487 Optional attribute. It specifies the amount of time, in milliseconds,
1488 that the Java process executing &FindBugs; may run before it is
1489 assumed to be hung and is terminated. The default is 600,000
1490 milliseconds, which is ten minutes. Note that for very large
1491 programs, &FindBugs; may require more than ten minutes to complete its
1492 analysis.
1493 </para>
1494 </listitem>
1495 </varlistentry>
1496
1497 <varlistentry>
1498 <term><literal>failOnError</literal></term>
1499 <listitem>
1500 <para>
1501 Optional boolean attribute. Whether to abort the build process if there is an
1502 error running &FindBugs;. Defaults to "false"
1503 </para>
1504 </listitem>
1505 </varlistentry>
1506
1507 <varlistentry>
1508 <term><literal>errorProperty</literal></term>
1509 <listitem>
1510 <para>
1511 Optional attribute which specifies the name of a property that
1512 will be set to "true" if an error occurs while running &FindBugs;.
1513 </para>
1514 </listitem>
1515 </varlistentry>
1516
1517 <varlistentry>
1518 <term><literal>warningsProperty</literal></term>
1519 <listitem>
1520 <para>
1521 Optional attribute which specifies the name of a property
1522 that will be set to "true" if any warnings are reported by
1523 &FindBugs; on the analyzed program.
1524 </para>
1525 </listitem>
1526 </varlistentry>
1527
1528 <varlistentry>
1529 <term><literal>userPreferencesFile</literal></term>
1530 <listitem>
1531 <para>
1532 Optional attribute. Set the path of the user preferences file to use, which might override some of the options abobe.
1533 Specifying <literal>userPreferencesFile</literal> as first argument would mean some later
1534 options will override them, as last argument would mean they will override some previous options).
1535 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
1536 line execution.
1537 </para>
1538 </listitem>
1539 </varlistentry>
1540
1541 </variablelist>
1542
1543
1544 </para>
1545
1546 <!--
1547
1548 -->
1549
1550 </sect1>
1551
1552 </chapter>
1553
1554 <!--
1555 **************************************************************************
1556 Using the FindBugs Eclipse plugin
1557 **************************************************************************
1558 -->
1559
1560 <chapter id="eclipse">
1561 <title>Using the &FindBugs;&trade; Eclipse plugin</title>
1562
1563 <para>
1564 The FindBugs Eclipse plugin allows &FindBugs; to be used within
1565 the <ulink url="http://www.eclipse.org/">Eclipse</ulink> IDE.
1566 The FindBugs Eclipse plugin was generously contributed by Peter Friese.
1567 Phil Crosby and Andrei Loskutov contributed major improvements
1568 to the plugin.
1569 </para>
1570
1571 <sect1>
1572 <title>Requirements</title>
1573
1574 <para>
1575 To use the &FindBugs; Plugin for Eclipse, you need Eclipse 3.3 or later,
1576 and JRE/JDK 1.5 or later.
1577 </para>
1578
1579 </sect1>
1580
1581 <sect1>
1582 <title>Installation</title>
1583
1584 <para>
1585 We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates.
1586 There are three different update sites</para>
1587
1588 <variablelist><title>FindBugs Eclipse update sites</title>
1589 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse/">http://findbugs.cs.umd.edu/eclipse/</ulink></term>
1590
1591 <listitem>
1592 <para>
1593 Only provides official releases of FindBugs.
1594 </para>
1595 </listitem>
1596 </varlistentry>
1597
1598 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-candidate/">http://findbugs.cs.umd.edu/eclipse-candidate/</ulink></term>
1599
1600 <listitem>
1601 <para>
1602 Provides official releases and release candidates of FindBugs.
1603 </para>
1604 </listitem>
1605 </varlistentry>
1606
1607 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-daily/">http://findbugs.cs.umd.edu/eclipse-daily/</ulink></term>
1608
1609 <listitem>
1610 <para>
1611 Provides the daily build of FindBugs. No testing other than that it compiles.
1612 </para>
1613 </listitem>
1614 </varlistentry>
1615 </variablelist>
1616
1617 <para>You can also manually
1618 download the plugin from the following link:
1619 <ulink url="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download"
1620 >http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</ulink>.
1621 Extract it in Eclipse's "plugins" subdirectory.
1622 (So &lt;eclipse_install_dir&gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png
1623 should be the path to the &FindBugs; logo.)
1624
1625 </para>
1626
1627 <para>
1628 Once the plugin is extracted, start Eclipse and choose
1629 <menuchoice>
1630 <guimenu>Help</guimenu>
1631 <guimenuitem>About Eclipse Platform</guimenuitem>
1632 <guimenuitem>Plug-in Details</guimenuitem>
1633 </menuchoice>.
1634 You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project".
1635 </para>
1636 </sect1>
1637
1638 <sect1>
1639 <title>Using the Plugin</title>
1640
1641 <para>
1642 To get started, right click on a Java project in Package Explorer,
1643 and select the option labeled "Find Bugs".
1644 &FindBugs; will run, and problem markers (displayed in source
1645 windows, and also in the Eclipse Problems view) will point to
1646 locations in your code which have been identified as potential instances
1647 of bug patterns.
1648 </para>
1649 <para>
1650 You can also run &FindBugs; on existing java archives (jar, ear, zip, war etc). Simply
1651 create an empty Java project and attach archives to the project classpath. Having that, you
1652 can now right click the archive node in Package Explorer and select the option labeled
1653 "Find Bugs". If you additionally configure the source code locations for the binaries,
1654 &FindBugs; will also link the generated warnings to the right source files.
1655 </para>
1656 <para>
1657 You may customize how &FindBugs; runs by opening the Properties
1658 dialog for a Java project, and choosing the "Findbugs" property page.
1659 Options you may choose include:
1660 </para>
1661
1662 <itemizedlist>
1663 <listitem>
1664 <para>
1665 Enable or disable the "Run FindBugs Automatically" checkbox.
1666 When enabled, FindBugs will run every time you modify a Java class
1667 within the project.
1668 </para>
1669 </listitem>
1670
1671 <listitem>
1672 <para>
1673 Choose minimum warning priority and enabled bug categories.
1674 These options will choose which warnings are shown.
1675 For example, if you select the "Medium" warning priority,
1676 only Medium and High priority warnings will be shown.
1677 Similarly, if you uncheck the "Style" checkbox, no warnings
1678 in the Style category will be displayed.
1679 </para>
1680 </listitem>
1681
1682 <listitem>
1683 <para>
1684 Select detectors. The table allows you to select which detectors
1685 you want to enable for your project.
1686 </para>
1687 </listitem>
1688 </itemizedlist>
1689
1690 </sect1>
1691
1692 <sect1>
1693 <title>Extending the Eclipse Plugin (since 2.0.0)</title>
1694 <para>
1695 Eclipse plugin supports contribution of custom &FindBugs; detectors (see also
1696 <ulink url="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt">AddingDetectors.txt</ulink>
1697 for more information). There are two ways to contribute custom plugins to the Eclipse:
1698 </para>
1699 <itemizedlist>
1700 <listitem>
1701 <para>
1702 Existing standard &FindBugs; detector packages can be configured via
1703 <menuchoice>
1704 <guimenu>Window</guimenu>
1705 <guimenuitem>Preferences</guimenuitem>
1706 <guimenuitem>Java</guimenuitem>
1707 <guimenuitem>&FindBugs;</guimenuitem>
1708 <guimenuitem>Misc. Settings</guimenuitem>
1709 <guimenuitem>Custom Detectors</guimenuitem>
1710 </menuchoice>.
1711 Simply specify there locations of any additional plugin libraries.
1712 </para>
1713
1714 <para>
1715 The benefit of this solution is that already existing detector packages can be
1716 used "as is", and that you can quickly verify the quality of third party detectors.
1717 The drawback is that you have to apply this settings in each
1718 new Eclipse workspace, and this settings can't be shared between team members.
1719 </para>
1720 </listitem>
1721
1722 <listitem>
1723 <para>
1724 It is possible to contribute custom detectors via standard Eclipse extensions mechanism.
1725 </para>
1726
1727 <para>
1728 Please check the documentation of the
1729 <ulink url="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd">
1730 findBugsEclipsePlugin/schema/detectorPlugins.exsd</ulink>
1731 extension point how to update the plugin.xml. Existing &FindBugs; detector plugins can
1732 be easily "extended" to be full featured &FindBugs; AND Eclipse detector plugins.
1733 Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and
1734 update your build scripts to not to override the MANIFEST.MF during the build.
1735 </para>
1736
1737 <para>
1738 The benefit of this solution is that for given (shared) Eclipse installation
1739 each team member has exactly same detectors set, and there is no need to configure
1740 anything anymore. The (really small) precondition
1741 is that you have to convert your existing detectors package to the valid
1742 Eclipse plugin. You can do this even for third-party detector packages.
1743 Another major differentiator is the ability to extend the default FindBugs
1744 classpath at runtime with required third party libraries (see
1745 <ulink url="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt">AddingDetectors.txt</ulink>
1746 for more information).
1747 </para>
1748 </listitem>
1749
1750 </itemizedlist>
1751
1752 </sect1>
1753
1754 <sect1>
1755 <title>Troubleshooting</title>
1756
1757 <para>
1758 This section lists common problems with the plugin and (if known) how to resolve them.
1759 </para>
1760
1761 <itemizedlist>
1762 <listitem>
1763 <para>
1764 If you see OutOfMemory error dialogs after starting &FindBugs; analysis in Eclipse,
1765 please increase JVM available memory: change eclipse.ini and add the lines below
1766 to the end of the file:
1767 <programlisting>
1768 -vmargs
1769 -Xmx1000m
1770 </programlisting>
1771 Important: the configuration arguments starting with the line "-vmargs" must
1772 be last lines in the eclipse.ini file, and only one argument per line is allowed!
1773 </para>
1774 </listitem>
1775 <listitem>
1776 <para>
1777 If you do not see any &FindBugs; problem markers (in your source
1778 windows or in the Problems View), you may need to change your
1779 Problems View filter settings. See
1780 <ulink url="http://findbugs.sourceforge.net/FAQ.html#q7">http://findbugs.sourceforge.net/FAQ.html#q7</ulink> for more information.
1781 </para>
1782 </listitem>
1783
1784 </itemizedlist>
1785
1786 </sect1>
1787
1788
1789 </chapter>
1790
1791
1792 <!--
1793 **************************************************************************
1794 Filter files
1795 **************************************************************************
1796 -->
1797
1798 <chapter id="filter">
1799 <title>Filter Files</title>
1800
1801 <para>
1802 Filter files may be used to include or exclude bug reports for particular classes
1803 and methods. This chapter explains how to use filter files.
1804
1805 <note>
1806 <title>Planned Features</title>
1807 <para>
1808 Filters are currently only supported by the Command Line interface.
1809 Eventually, filter support will be added to the GUI.
1810 </para>
1811 </note>
1812 </para>
1813
1814
1815 <sect1>
1816 <title>Introduction to Filter Files</title>
1817
1818 <para>
1819 Conceptually, a filter matches bug instances against a set of criteria.
1820 By defining a filter, you can select bug instances for special treatment;
1821 for example, to exclude or include them in a report.
1822 </para>
1823
1824 <para>
1825 A filter file is an <ulink url="http://www.w3.org/XML/">XML</ulink> document with a top-level <literal>FindBugsFilter</literal> element
1826 which has some number of <literal>Match</literal> elements as children. Each <literal>Match</literal>
1827 element represents a predicate which is applied to generated bug instances.
1828 Usually, a filter will be used to exclude bug instances. For example:
1829
1830 <screen>
1831 <prompt>$ </prompt><command>findbugs -textui -exclude <replaceable>myExcludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command>
1832 </screen>
1833
1834 However, a filter could also be used to select bug instances to specifically
1835 report:
1836
1837 <screen>
1838 <prompt>$ </prompt><command>findbugs -textui -include <replaceable>myIncludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command>
1839 </screen>
1840 </para>
1841
1842 <para>
1843 <literal>Match</literal> elements contain children, which are conjuncts of the predicate.
1844 In other words, each of the children must be true for the predicate to be true.
1845 </para>
1846
1847 </sect1>
1848
1849 <sect1>
1850 <title>Types of Match clauses</title>
1851
1852 <variablelist>
1853 <varlistentry>
1854 <term><literal>&lt;Bug&gt;</literal></term>
1855 <listitem><para>
1856 This element specifies a particular bug pattern or patterns to match.
1857 The <literal>pattern</literal> attribute is a comma-separated list of
1858 bug pattern types. You can find the bug pattern types for particular
1859 warnings by looking at the output produced by the <command>-xml</command>
1860 output option (the <literal>type</literal> attribute of <literal>BugInstance</literal>
1861 elements), or from the <ulink url="../bugDescriptions.html">bug
1862 descriptions document</ulink>.
1863 </para><para>
1864 For more coarse-grained matching, use <literal>code</literal> attribute. It takes
1865 a comma-separated list of bug abbreviations. For most-coarse grained matching use
1866 <literal>category</literal> attriute, that takes a comma separated list of bug category names:
1867 <literal>CORRECTNESS</literal>, <literal>MT_CORRECTNESS</literal>,
1868 <literal>BAD_PRACTICICE</literal>, <literal>PERFORMANCE</literal>, <literal>STYLE</literal>.
1869 </para><para>
1870 If more than one of the attributes mentioned above are specified on the same
1871 <literal>&lt;Bug&gt;</literal> element, all bug patterns that match either one of specified
1872 pattern names, or abreviations, or categories will be matched.
1873 </para><para>
1874 As a backwards compatibility measure, <literal>&lt;BugPattern&gt;</literal> and
1875 <literal>&lt;BugCode&gt;</literal> elements may be used instead of
1876 <literal>&lt;Bug&gt;</literal> element. Each of these uses a
1877 <literal>name</literal> attribute for specifying accepted values list. Support for these
1878 elements may be removed in a future release.
1879 </para></listitem>
1880 </varlistentry>
1881
1882 <varlistentry>
1883 <term><literal>&lt;Confidence&gt;</literal></term>
1884 <listitem>
1885 <para>
1886 This element matches warnings with a particular bug confidence.
1887 The <literal>value</literal> attribute should be an integer value:
1888 1 to match high-confidence warnings, 2 to match normal-confidence warnings,
1889 or 3 to match low-confidence warnings. &lt;Confidence&gt; replaced
1890 &lt;Priority&gt; in 2.0.0 release.
1891 </para>
1892 </listitem>
1893 </varlistentry>
1894
1895 <varlistentry>
1896 <term><literal>&lt;Priority&gt;</literal></term>
1897 <listitem>
1898 <para>
1899 Same as <literal>&lt;Confidence&gt;</literal>, exists for backward compatibility.
1900 </para>
1901 </listitem>
1902 </varlistentry>
1903
1904 <varlistentry>
1905 <term><literal>&lt;Rank&gt;</literal></term>
1906 <listitem>
1907 <para>
1908 This element matches warnings with a particular bug rank.
1909 The <literal>value</literal> attribute should be an integer value
1910 between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling,
1911 and 15 to 20 of concern bugs.
1912 </para>
1913 </listitem>
1914 </varlistentry>
1915
1916 <varlistentry>
1917 <term><literal>&lt;Package&gt;</literal></term>
1918 <listitem>
1919 <para>
1920 This element matches warnings associated with classes within the package specified
1921 using <literal>name</literal> attribute. Nested packages are not included (along the
1922 lines of Java import statement). However matching multiple packages can be achieved
1923 easily using regex name match.
1924 </para>
1925 </listitem>
1926 </varlistentry>
1927
1928 <varlistentry>
1929 <term><literal>&lt;Class&gt;</literal></term>
1930 <listitem>
1931 <para>
1932 This element matches warnings associated with a particular class. The
1933 <literal>name</literal> attribute is used to specify the exact or regex match pattern
1934 for the class name.
1935 </para>
1936
1937 <para>
1938 As a backward compatibility measure, instead of element of this type, you can use
1939 <literal>class</literal> attribute on a <literal>Match</literal> element to specify
1940 exact an class name or <literal>classregex</literal> attribute to specify a regular
1941 expression to match the class name against.
1942 </para>
1943
1944 <para>
1945 If the <literal>Match</literal> element contains neither a <literal>Class</literal> element,
1946 nor a <literal>class</literal> / <literal>classregex</literal> attribute, the predicate will apply
1947 to all classes. Such predicate is likely to match more bug instances than you want, unless it is
1948 refined further down with apropriate method or field predicates.
1949 </para>
1950 </listitem>
1951 </varlistentry>
1952
1953 <varlistentry>
1954 <term><literal>&lt;Method&gt;</literal></term>
1955
1956 <listitem><para>This element specifies a method. The <literal>name</literal> is used to specify
1957 the exact or regex match pattern for the method name.
1958 The <literal>params</literal> attribute is a comma-separated list
1959 of the types of the method's parameters. The <literal>returns</literal> attribute is
1960 the method's return type. In <literal>params</literal> and <literal>returns</literal>, class names
1961 must be fully qualified. (E.g., "java.lang.String" instead of just
1962 "String".) If one of the latter attributes is specified the other is required for creating a method signature.
1963 Note that you can provide either <literal>name</literal> attribute or <literal>params</literal>
1964 and <literal>returns</literal> attributes or all three of them. This way you can provide various kinds of
1965 name and signature based matches.
1966 </para></listitem>
1967 </varlistentry>
1968
1969 <varlistentry>
1970 <term><literal>&lt;Field&gt;</literal></term>
1971
1972 <listitem><para>This element specifies a field. The <literal>name</literal> attribute is is used to specify
1973 the exact or regex match pattern for the field name. You can also filter fields according to their signature -
1974 use <literal>type</literal> attribute to specify fully qualified type of the field. You can specify eiter or both
1975 of these attributes in order to perform name / signature based matches.
1976 </para></listitem>
1977 </varlistentry>
1978
1979 <varlistentry>
1980 <term><literal>&lt;Local&gt;</literal></term>
1981
1982 <listitem><para>This element specifies a local variable. The <literal>name</literal> attribute is is used to specify
1983 the exact or regex match pattern for the local variable name. Local variables are variables defined within a method.
1984 </para></listitem>
1985 </varlistentry>
1986
1987 <varlistentry>
1988 <term><literal>&lt;Or&gt;</literal></term>
1989 <listitem><para>
1990 This element combines <literal>Match</literal> clauses as disjuncts. I.e., you can put two
1991 <literal>Method</literal> elements in an <literal>Or</literal> clause in order to match either method.
1992 </para></listitem>
1993 </varlistentry>
1994 <varlistentry>
1995 <term><literal>&lt;And&gt;</literal></term>
1996 <listitem><para>
1997 This element combines <literal>Match</literal> clauses which both must evaluate to true. I.e., you can put
1998 <literal>Bug</literal> and <literal>Priority</literal> elements in an <literal>And</literal> clause in order
1999 to match specific bugs with given priority only.
2000 </para></listitem>
2001 </varlistentry>
2002 <varlistentry>
2003 <term><literal>&lt;Not&gt;</literal></term>
2004 <listitem><para>
2005 This element inverts the included child <literal>Match</literal>. I.e., you can put a
2006 <literal>Bug</literal> element in a <literal>Not</literal> clause in order to match any bug
2007 excluding the given one.
2008 </para></listitem>
2009 </varlistentry>
2010 </variablelist>
2011
2012 </sect1>
2013
2014 <sect1>
2015 <title>Java element name matching</title>
2016
2017 <para>
2018 If the <literal>name</literal> attribute of <literal>Class</literal>, <literal>Method</literal> or
2019 <literal>Field</literal> starts with the ~ character the rest of attribute content is interpreted as
2020 a Java regular expression that is matched against the names of the Java element in question.
2021 </para>
2022
2023 <para>
2024 Note that the pattern is matched against whole element name and therefore .* clauses need to be used
2025 at pattern beginning and/or end to perform substring matching.
2026 </para>
2027
2028 <para>
2029 See <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html"><literal>java.util.regex.Pattern</literal></ulink>
2030 documentation for pattern syntax.
2031 </para>
2032 </sect1>
2033
2034 <sect1>
2035 <title>Caveats</title>
2036
2037 <para>
2038 <literal>Match</literal> clauses can only match information that is actually contained in the
2039 bug instances. Every bug instance has a class, so in general, excluding
2040 bugs by class will work.
2041 </para>
2042
2043 <para>
2044 Some bug instances have two (or more) classes. For example, the DE (dropped exception)
2045 bugs report both the class containing the method where the dropped exception
2046 happens, and the class which represents the type of the dropped exception.
2047 Only the <emphasis>first</emphasis> (primary) class is matched against <literal>Match</literal> clauses.
2048 So, for example, if you want to suppress IC (initialization circularity)
2049 reports for classes "com.foobar.A" and "com.foobar.B", you would use
2050 two <literal>Match</literal> clauses:
2051
2052 <programlisting>
2053 &lt;Match&gt;
2054 &lt;Class name="com.foobar.A" /&gt;
2055 &lt;Bug code="IC" /&gt;
2056 &lt;/Match&gt;
2057
2058 &lt;Match&gt;
2059 &lt;Class name="com.foobar.B" /&gt;
2060 &lt;Bug code="IC" /&gt;
2061 &lt;/Match&gt;
2062 </programlisting>
2063
2064 By explicitly matching both classes, you ensure that the IC bug instance will be
2065 matched regardless of which class involved in the circularity happens to be
2066 listed first in the bug instance. (Of course, this approach might accidentally
2067 supress circularities involving "com.foobar.A" or "com.foobar.B" and a third
2068 class.)
2069 </para>
2070
2071 <para>
2072 Many kinds of bugs report what method they occur in. For those bug instances,
2073 you can put <literal>Method</literal> clauses in the <literal>Match</literal> element and they should work
2074 as expected.
2075 </para>
2076
2077 </sect1>
2078
2079 <sect1>
2080 <title>Examples</title>
2081
2082 <para>
2083 1. Match all bug reports for a class.
2084
2085 <programlisting>
2086 <![CDATA[
2087 <Match>
2088 <Class name="com.foobar.MyClass" />
2089 </Match>
2090 ]]>
2091 </programlisting>
2092
2093 </para>
2094
2095 <para>
2096 2. Match certain tests from a class by specifying their abbreviations.
2097 <programlisting>
2098 <![CDATA[
2099 <Match>
2100 <Class name="com.foobar.MyClass"/ >
2101 <Bug code="DE,UrF,SIC" />
2102 </Match>
2103 ]]>
2104 </programlisting>
2105 </para>
2106
2107 <para>
2108 3. Match certain tests from all classes by specifying their abbreviations.
2109
2110 <programlisting>
2111 <![CDATA[
2112 <Match>
2113 <Bug code="DE,UrF,SIC" />
2114 </Match>
2115 ]]>
2116 </programlisting>
2117 </para>
2118
2119 <para>
2120 4. Match certain tests from all classes by specifying their category.
2121
2122 <programlisting>
2123 <![CDATA[
2124 <Match>
2125 <Bug category="PERFORMANCE" />
2126 </Match>
2127 ]]>
2128 </programlisting>
2129 </para>
2130
2131 <para>
2132 5. Match bug types from specified methods of a class by their abbreviations.
2133
2134 <programlisting>
2135 <![CDATA[
2136 <Match>
2137 <Class name="com.foobar.MyClass" />
2138 <Or>
2139 <Method name="frob" params="int,java.lang.String" returns="void" />
2140 <Method name="blat" params="" returns="boolean" />
2141 </Or>
2142 <Bug code="DC" />
2143 </Match>
2144 ]]>
2145 </programlisting>
2146 </para>
2147
2148 <para>
2149 6. Match a particular bug pattern in a particular method.
2150
2151 <programlisting>
2152 <![CDATA[
2153 <!-- A method with an open stream false positive. -->
2154 <Match>
2155 <Class name="com.foobar.MyClass" />
2156 <Method name="writeDataToFile" />
2157 <Bug pattern="OS_OPEN_STREAM" />
2158 </Match>
2159 ]]>
2160 </programlisting>
2161 </para>
2162
2163 <para>
2164 7. Match a particular bug pattern with a given priority in a particular method.
2165
2166 <programlisting>
2167 <![CDATA[
2168 <!-- A method with a dead local store false positive (medium priority). -->
2169 <Match>
2170 <Class name="com.foobar.MyClass" />
2171 <Method name="someMethod" />
2172 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
2173 <Priority value="2" />
2174 </Match>
2175 ]]>
2176 </programlisting>
2177 </para>
2178
2179 <para>
2180 8. Match minor bugs introduced by AspectJ compiler (you are probably not interested in these unless
2181 you are an AspectJ developer).
2182
2183 <programlisting>
2184 <![CDATA[
2185 <Match>
2186 <Class name="~.*\$AjcClosure\d+" />
2187 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
2188 <Method name="run" />
2189 </Match>
2190 <Match>
2191 <Bug pattern="UUF_UNUSED_FIELD" />
2192 <Field name="~ajc\$.*" />
2193 </Match>
2194 ]]>
2195 </programlisting>
2196 </para>
2197
2198 <para>
2199 9. Match bugs in specific parts of the code base
2200
2201 <programlisting>
2202 <![CDATA[
2203 <!-- match unused fields warnings in Messages classes in all packages -->
2204 <Match>
2205 <Class name="~.*\.Messages" />
2206 <Bug code="UUF" />
2207 </Match>
2208 <!-- match mutable statics warnings in all internal packages -->
2209 <Match>
2210 <Package name="~.*\.internal" />
2211 <Bug code="MS" />
2212 </Match>
2213 <!-- match anonymoous inner classes warnings in ui package hierarchy -->
2214 <Match>
2215 <Package name="~com\.foobar\.fooproject\.ui.*" />
2216 <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
2217 </Match>
2218 ]]>
2219 </programlisting>
2220 </para>
2221
2222 <para>
2223 10. Match bugs on fields or methods with specific signatures
2224 <programlisting>
2225 <![CDATA[
2226 <!-- match System.exit(...) usage warnings in void main(String[]) methods in all classes -->
2227 <Match>
2228 <Method returns="void" name="main" params="java.lang.String[]" />
2229 <Bug pattern="DM_EXIT" />
2230 </Match>
2231 <!-- match UuF warnings on fields of type com.foobar.DebugInfo on all classes -->
2232 <Match>
2233 <Field type="com.foobar.DebugInfo" />
2234 <Bug code="UuF" />
2235 </Match>
2236 ]]>
2237 </programlisting>
2238 </para>
2239
2240
2241 <para>
2242 11. Match bugs using the Not filter operator
2243 <programlisting>
2244 <![CDATA[
2245 <!-- ignore all bugs in test classes, except for those bugs specifically relating to JUnit tests -->
2246 <!-- i.e. filter bug if ( classIsJUnitTest && ! bugIsRelatedToJUnit ) -->
2247 <Match>
2248 <!-- the Match filter is equivalent to a logical 'And' -->
2249
2250 <Class name="~.*\.*Test" />
2251 <!-- test classes are suffixed by 'Test' -->
2252
2253 <Not>
2254 <Bug code="IJU" /> <!-- 'IJU' is the code for bugs related to JUnit test code -->
2255 </Not>
2256 </Match>
2257 ]]>
2258 </programlisting>
2259 </para>
2260
2261 </sect1>
2262
2263 <sect1>
2264 <title>Complete Example</title>
2265
2266 <programlisting>
2267 <![CDATA[
2268 <FindBugsFilter>
2269 <Match>
2270 <Class name="com.foobar.ClassNotToBeAnalyzed" />
2271 </Match>
2272
2273 <Match>
2274 <Class name="com.foobar.ClassWithSomeBugsMatched" />
2275 <Bug code="DE,UrF,SIC" />
2276 </Match>
2277
2278 <!-- Match all XYZ violations. -->
2279 <Match>
2280 <Bug code="XYZ" />
2281 </Match>
2282
2283 <!-- Match all doublecheck violations in these methods of "AnotherClass". -->
2284 <Match>
2285 <Class name="com.foobar.AnotherClass" />
2286 <Or>
2287 <Method name="nonOverloadedMethod" />
2288 <Method name="frob" params="int,java.lang.String" returns="void" />
2289 <Method name="blat" params="" returns="boolean" />
2290 </Or>
2291 <Bug code="DC" />
2292 </Match>
2293
2294 <!-- A method with a dead local store false positive (medium priority). -->
2295 <Match>
2296 <Class name="com.foobar.MyClass" />
2297 <Method name="someMethod" />
2298 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
2299 <Priority value="2" />
2300 </Match>
2301
2302 <!-- All bugs in test classes, except for JUnit-specific bugs -->
2303 <Match>
2304 <Class name="~.*\.*Test" />
2305 <Not>
2306 <Bug code="IJU" />
2307 </Not>
2308 </Match>
2309
2310 </FindBugsFilter>
2311 ]]>
2312 </programlisting>
2313
2314 </sect1>
2315
2316
2317 </chapter>
2318
2319
2320 <!--
2321 **************************************************************************
2322 Analysis properties
2323 **************************************************************************
2324 -->
2325
2326 <chapter id="analysisprops">
2327 <title>Analysis Properties</title>
2328
2329 <para>
2330 &FindBugs; allows several aspects of the analyses it performs to be
2331 customized. System properties are used to configure these options.
2332 This chapter describes the configurable analysis options.
2333 </para>
2334
2335 <para>
2336 The analysis options have two main purposes. First, they allow you
2337 to inform &FindBugs; about the meaning of methods in your application,
2338 so that it can produce more accurate results, or produce fewer
2339 false warnings. Second, they allow you to configure the precision
2340 of the analysis performed. Reducing analysis precision can save
2341 memory and analysis time, at the expense of missing some real bugs,
2342 or producing more false warnings.
2343 </para>
2344
2345 <para>
2346 The analysis options are set using the <command>-property</command>
2347 command line option. For example:
2348 <screen>
2349 <prompt>$ </prompt><command>findbugs -textui -property "cfg.noprune=true" <replaceable>myApp.jar</replaceable></command>
2350 </screen>
2351 </para>
2352
2353 <para>
2354 The list of configurable analysis properties is shown in
2355 <xref linkend="analysisproptable"/>.
2356 </para>
2357
2358 <table id="analysisproptable">
2359 <title>Configurable Analysis Properties</title>
2360 <tgroup cols="3" align="left">
2361 <thead>
2362 <row>
2363 <entry>Property Name</entry>
2364 <entry>Value</entry>
2365 <entry>Meaning</entry>
2366 </row>
2367 </thead>
2368 <tbody>
2369 <!--
2370 <row>
2371 <entry>cfg.noprune</entry>
2372 <entry>true or false</entry>
2373 <entry>If true, infeasible exception edges are not pruned from
2374 the control flow graphs of analyzed methods. This option
2375 increases the speed of the analysis (by about 20%-30%),
2376 but causes some detectors to produce more false warnings.</entry>
2377 </row>
2378 -->
2379 <row>
2380 <entry>findbugs.assertionmethods</entry>
2381 <entry>Comma-separated list of fully qualified method names:
2382 e.g., "com.foo.MyClass.checkAssertion"</entry>
2383 <entry>This property specifies the names of methods that are used
2384 to check program assertions. Specifying these methods allows
2385 the null pointer dereference bug detector to avoid reporting
2386 false warnings for values which are checked by assertion
2387 methods.</entry>
2388 </row>
2389 <row>
2390 <entry>findbugs.de.comment</entry>
2391 <entry>true or false</entry>
2392 <entry>If true, the DroppedException detector scans source code
2393 for empty catch blocks for a comment, and if one is found, does
2394 not report a warning.</entry>
2395 </row>
2396 <row>
2397 <entry>findbugs.maskedfields.locals</entry>
2398 <entry>true or false</entry>
2399 <entry>If true, emit low priority warnings for local variables
2400 which obscure fields. Default is false.</entry>
2401 </row>
2402 <row>
2403 <entry>findbugs.nullderef.assumensp</entry>
2404 <entry>true or false</entry>
2405 <entry>not used
2406 (intention: If true, the null dereference detector assumes that any
2407 reference value returned from a method or passed to a method
2408 in a parameter might be null. Default is false. Note that
2409 enabling this property will very likely cause a large number
2410 of false warnings to be produced.)</entry>
2411 </row>
2412 <row>
2413 <entry>findbugs.refcomp.reportAll</entry>
2414 <entry>true or false</entry>
2415 <entry>If true, all suspicious reference comparisons
2416 using the == and != operators are reported.&nbsp; If false,
2417 only one such warning is issued per method.&nbsp; Default
2418 is false.</entry>
2419 </row>
2420 <row>
2421 <entry>findbugs.sf.comment</entry>
2422 <entry>true or false</entry>
2423 <entry>If true, the SwitchFallthrough detector will only report
2424 warnings for cases where the source code does not have a comment
2425 containing the words "fall" or "nobreak". (An accurate source
2426 path must be used for this feature to work correctly.)
2427 This helps find cases where the switch fallthrough is likely
2428 to be unintentional.</entry>
2429 </row>
2430 <!-- see others at src/doc/manual/sysprops.html
2431 <row>
2432 <entry></entry>
2433 <entry></entry>
2434 <entry></entry>
2435 </row>
2436 -->
2437 </tbody>
2438 </tgroup>
2439 </table>
2440
2441 </chapter>
2442
2443 <!--
2444 **************************************************************************
2445 Annotations
2446 ***************************************************************************
2447 -->
2448
2449 <chapter id="annotations">
2450 <title>Annotations</title>
2451
2452 <para>
2453 &FindBugs; supports several annotations to express the developer's intent
2454 so that FindBugs can issue warnings more appropriately. You need to use
2455 Java 5 to use annotations, and must place the annotations.jar and jsr305.jar
2456 files in the classpath while compiling your program.
2457 </para>
2458
2459 <variablelist>
2460 <varlistentry>
2461 <term><command>edu.umd.cs.findbugs.annotations.CheckForNull</command></term>
2462 <listitem>
2463 <command>[Target]</command> Field, Method, Parameter
2464 </listitem>
2465 <listitem>
2466 <para>
2467 The annotated element might be null, and uses of the element should check for null.
2468 When this annotation is applied to a method it applies to the method return value.
2469 </para>
2470 </listitem>
2471 </varlistentry>
2472
2473 <varlistentry>
2474 <term><command>edu.umd.cs.findbugs.annotations.CheckReturnValue</command></term>
2475 <listitem>
2476 <command>[Target]</command> Method, Constructor
2477 </listitem>
2478 <listitem>
2479 <variablelist>
2480 <varlistentry>
2481 <term><command>[Parameter]</command></term>
2482 <listitem>
2483 <para>
2484 <command>priority:</command>The priority of the warning (HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
2485 </para>
2486 </listitem>
2487 <listitem>
2488 <para>
2489 <command>explanation:</command>A textual explaination of why the return value should be checked. Default value:"".
2490 </para>
2491 </listitem>
2492 </varlistentry>
2493 </variablelist>
2494 </listitem>
2495 <listitem>
2496 <para>
2497 This annotation is used to denote a method whose return value should always be checked after invoking the method.
2498 </para>
2499 </listitem>
2500 </varlistentry>
2501
2502 <varlistentry>
2503 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotation</command></term>
2504 <listitem>
2505 <command>[Target]</command> Type, Package
2506 </listitem>
2507 <listitem>
2508 <variablelist>
2509 <varlistentry>
2510 <term><command>[Parameter]</command></term>
2511 <listitem>
2512 <para>
2513 <command>value:</command>Annotation class objects. More than one class can be specified.
2514 </para>
2515 </listitem>
2516 <listitem>
2517 <para>
2518 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
2519 </para>
2520 </listitem>
2521 </varlistentry>
2522 </variablelist>
2523 </listitem>
2524 <listitem>
2525 <para>
2526 Indicates that all members of the class or package should be annotated with the default
2527 value of the supplied annotation classes. This would be used for behavior annotations
2528 such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use
2529 @DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only
2530 on those parameters, methods or fields that you want to allow to be null.
2531 </para>
2532 </listitem>
2533 </varlistentry>
2534
2535 <varlistentry>
2536 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields</command></term>
2537 <listitem>
2538 <command>[Target]</command> Type, Package
2539 </listitem>
2540 <listitem>
2541 <variablelist>
2542 <varlistentry>
2543 <term><command>[Parameter]</command></term>
2544 <listitem>
2545 <para>
2546 <command>value:</command>Annotation class objects. More than one class can be specified.
2547 </para>
2548 </listitem>
2549 <listitem>
2550 <para>
2551 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
2552 </para>
2553 </listitem>
2554 </varlistentry>
2555 </variablelist>
2556 </listitem>
2557 <listitem>
2558 <para>
2559 This is same as the DefaultAnnotation except it only applys to fields.
2560 </para>
2561 </listitem>
2562 </varlistentry>
2563
2564 <varlistentry>
2565 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods</command></term>
2566 <listitem>
2567 <command>[Target]</command> Type, Package
2568 </listitem>
2569 <listitem>
2570 <variablelist>
2571 <varlistentry>
2572 <term><command>[Parameter]</command></term>
2573 <listitem>
2574 <para>
2575 <command>value:</command>Annotation class objects. More than one class can be specified.
2576 </para>
2577 </listitem>
2578 <listitem>
2579 <para>
2580 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
2581 </para>
2582 </listitem>
2583 </varlistentry>
2584 </variablelist>
2585 </listitem>
2586 <listitem>
2587 <para>
2588 This is same as the DefaultAnnotation except it only applys to methods.
2589 </para>
2590 </listitem>
2591 </varlistentry>
2592
2593 <varlistentry>
2594 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters</command></term>
2595 <listitem>
2596 <command>[Target]</command> Type, Package
2597 </listitem>
2598 <listitem>
2599 <variablelist>
2600 <varlistentry>
2601 <term><command>[Parameter]</command></term>
2602 <listitem>
2603 <para>
2604 <command>value:</command>Annotation class objects. More than one class can be specified.
2605 </para>
2606 </listitem>
2607 <listitem>
2608 <para>
2609 <command>priority:</command>Default priority(HIGH, MEDIUM, LOW, IGNORE). Default value:MEDIUM.
2610 </para>
2611 </listitem>
2612 </varlistentry>
2613 </variablelist>
2614 </listitem>
2615 <listitem>
2616 <para>
2617 This is same as the DefaultAnnotation except it only applys to method parameters.
2618 </para>
2619 </listitem>
2620 </varlistentry>
2621
2622 <varlistentry>
2623 <term><command>edu.umd.cs.findbugs.annotations.NonNull</command></term>
2624 <listitem>
2625 <command>[Target]</command> Field, Method, Parameter
2626 </listitem>
2627 <listitem>
2628 <para>
2629 The annotated element must not be null.
2630 Annotated fields must not be null after construction has completed. Annotated methods must have non-null return values.
2631 </para>
2632 </listitem>
2633 </varlistentry>
2634
2635 <varlistentry>
2636 <term><command>edu.umd.cs.findbugs.annotations.Nullable</command></term>
2637 <listitem>
2638 <command>[Target]</command> Field, Method, Parameter
2639 </listitem>
2640 <listitem>
2641 <para>
2642 The annotated element could be null under some circumstances. In general, this means
2643 developers will have to read the documentation to determine when a null value is
2644 acceptable and whether it is neccessary to check for a null value. FindBugs will
2645 treat the annotated items as though they had no annotation.
2646 </para>
2647 <para>
2648 In pratice this annotation is useful only for overriding an overarching NonNull
2649 annotation.
2650 </para>
2651 </listitem>
2652 </varlistentry>
2653
2654 <varlistentry>
2655 <term><command>edu.umd.cs.findbugs.annotations.OverrideMustInvoke</command></term>
2656 <listitem>
2657 <command>[Target]</command> Method
2658 </listitem>
2659 <listitem>
2660 <variablelist>
2661 <varlistentry>
2662 <term><command>[Parameter]</command></term>
2663 <listitem>
2664 <para>
2665 <command>value:</command>Specify when the super invocation should be
2666 performed (FIRST, ANYTIME, LAST). Default value:ANYTIME.
2667 </para>
2668 </listitem>
2669 </varlistentry>
2670 </variablelist>
2671 </listitem>
2672 <listitem>
2673 <para>
2674 Used to annotate a method that, if overridden, must (or should) be invoke super
2675 in the overriding method. Examples of such methods include finalize() and clone().
2676 The argument to the method indicates when the super invocation should occur:
2677 at any time, at the beginning of the overriding method, or at the end of the overriding method.
2678 (This anotation is not implmemented in FindBugs as of September 8, 2006).
2679 </para>
2680 </listitem>
2681 </varlistentry>
2682
2683 <varlistentry>
2684 <term><command>edu.umd.cs.findbugs.annotations.PossiblyNull</command></term>
2685 <listitem>
2686 <para>
2687 This annotation is deprecated. Use CheckForNull instead.
2688 </para>
2689 </listitem>
2690 </varlistentry>
2691
2692 <varlistentry>
2693 <term><command>edu.umd.cs.findbugs.annotations.SuppressWarnings</command></term>
2694 <listitem>
2695 <command>[Target]</command> Type, Field, Method, Parameter, Constructor, Package
2696 </listitem>
2697 <listitem>
2698 <variablelist>
2699 <varlistentry>
2700 <term><command>[Parameter]</command></term>
2701 <listitem>
2702 <para>
2703 <command>value:</command>The name of the warning. More than one name can be specified.
2704 </para>
2705 </listitem>
2706 <listitem>
2707 <para>
2708 <command>justification:</command>Reason why the warning should be ignored. Default value:"".
2709 </para>
2710 </listitem>
2711 </varlistentry>
2712 </variablelist>
2713 </listitem>
2714 <listitem>
2715 <para>
2716 The set of warnings that are to be suppressed by the compiler in the annotated element.
2717 Duplicate names are permitted. The second and successive occurrences of a name are ignored.
2718 The presence of unrecognized warning names is <emphasis>not</emphasis> an error: Compilers
2719 must ignore any warning names they do not recognize. They are, however, free to emit a
2720 warning if an annotation contains an unrecognized warning name. Compiler vendors should
2721 document the warning names they support in conjunction with this annotation type. They
2722 are encouraged to cooperate to ensure that the same names work across multiple compilers.
2723 </para>
2724 </listitem>
2725 </varlistentry>
2726
2727 <varlistentry>
2728 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term>
2729 <listitem>
2730 <command>[Target]</command> Field, Method, Parameter
2731 </listitem>
2732 <listitem>
2733 <para>
2734 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
2735 </para>
2736 </listitem>
2737 </varlistentry>
2738
2739 <varlistentry>
2740 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term>
2741 <listitem>
2742 <command>[Target]</command> Field, Method, Parameter
2743 </listitem>
2744 <listitem>
2745 <para>
2746 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
2747 </para>
2748 </listitem>
2749 </varlistentry>
2750 </variablelist>
2751
2752 <para>
2753 &FindBugs; also supports the following annotations:
2754 <itemizedlist>
2755 <listitem>net.jcip.annotations.GuardedBy</listitem>
2756 <listitem>net.jcip.annotations.Immutable</listitem>
2757 <listitem>net.jcip.annotations.NotThreadSafe</listitem>
2758 <listitem>net.jcip.annotations.ThreadSafe</listitem>
2759 </itemizedlist>
2760 </para>
2761 <para>
2762 You can refer the JCIP annotation <ulink url="http://jcip.net/annotations/doc/index.html">
2763 API documentation</ulink> at <ulink url="http://jcip.net/">Java Concurrency in Practice</ulink>.
2764 </para>
2765 </chapter>
2766
2767 <!--
2768 **************************************************************************
2769 Using rejarForAnalysis
2770 **************************************************************************
2771 -->
2772
2773 <chapter id="rejarForAnalysis">
2774 <title>Using rejarForAnalysis</title>
2775
2776 <para>
2777 If your project consists of many jarfiles or the jarfiles are scattered
2778 over many directories, you may wish to use the <command>rejarForAnalysis
2779 </command> script to make
2780 FindBugs invocation easier. The script collects many jarfiles and combines them
2781 into a single, large jarfile that can then be easily passed to FindBugs for
2782 analysis. This can be particularly useful in combination with the 'find' command
2783 on unix systems; e.g. <command>find . -name '*.jar' | xargs rejarForAnalysis
2784 </command>.
2785 </para>
2786
2787 <para>
2788 The <command>rejarForAnalysis</command> script
2789 can also be used to split a very large project up into a set of jarfiles with
2790 the project classfiles evenly divided between them. This is useful when running
2791 FindBugs on the entire project is not practical due to time or memory consumption.
2792 Instead of running FindBugs on the entire project, you may use <command>
2793 rejarForAnalysis</command> build one large, all-inclusive jarfile
2794 containing all classes, invoke <command>rejarForAnalysis</command>
2795 again to split the project into multiple jarfiles, then run FindBugs
2796 on each divided jarfiles in turn, specifying the the all-inclusive jarfile in
2797 the <command>-auxclasspath</command>.
2798 </para>
2799
2800 <para>
2801 These are the options accepted by the <command>rejarForAnalysis</command> script:
2802 </para>
2803
2804 <variablelist>
2805 <varlistentry>
2806 <term><command>-maxAge</command> <replaceable>days</replaceable></term>
2807 <listitem>
2808 <para>
2809 Maximum age in days (ignore jar files older than this).
2810 </para>
2811 </listitem>
2812 </varlistentry>
2813 <varlistentry>
2814 <term><command>-inputFileList</command> <replaceable>filename</replaceable></term>
2815 <listitem>
2816 <para>
2817 Text file containing names of jar files.
2818 </para>
2819 </listitem>
2820 </varlistentry>
2821 <varlistentry>
2822 <term><command>-maxClasses</command> <replaceable>num</replaceable></term>
2823 <listitem>
2824 <para>
2825 Maximum number of classes per analysis*.jar file.
2826 </para>
2827 </listitem>
2828 </varlistentry>
2829 <varlistentry>
2830 <term><command>-prefix</command> <replaceable>class name prefix</replaceable></term>
2831 <listitem>
2832 <para>
2833 Prefix of class names that should be analyzed (e.g., edu.umd.cs.).
2834 </para>
2835 </listitem>
2836 </varlistentry>
2837 </variablelist>
2838 </chapter>
2839
2840 <!--
2841 **************************************************************************
2842 Data mining
2843 **************************************************************************
2844 -->
2845
2846 <chapter id="datamining">
2847 <title>Data mining of bugs with &FindBugs;&trade;</title>
2848
2849 <para>
2850 FindBugs incorporates an ability to perform sophisticated queries on bug
2851 databases and track warnings across multiple versions of code being
2852 studied, allowing you to do things such as seeing when a bug was first introduced, examining
2853 just the warnings that have been introduced since the last release, or graphing the number
2854 of infinite recursive loops in your code over time.</para>
2855
2856 <para>
2857 These techniques all depend upon the XML format used by FindBugs for storing warnings.
2858 These XML files usually contain just the warnings from one particular analysis run, but
2859 they can also store the results from analyzing a sequence of software builds or versions.
2860 </para>
2861
2862 <para>
2863 Any FindBugs XML bug database contains a version name and timestamp.
2864 FindBugs tries to compute a timestamp from the timestamps of the files that
2865 are analyzed (e.g., the timestamp is intended to be the time the class files
2866 were generated, not analyzed). Each bug database also contains a version name.
2867 Both the version name and timestamp can be set manually using the
2868 <command>setBugDatabaseInfo</command> (<xref linkend="setBugDatabaseInfo" />) command.
2869 </para>
2870
2871 <para>A multiversion bug database assigns a sequence number to each version of
2872 the analyzed code. These sequence numbers are simply successive integers,
2873 starting at 0 (e.g., a bug database for 4 versions of the code will contain
2874 versions 0..3). The bug database will also record the name and timestamp for
2875 each version. The <command>filterBugs</command> command allows you to refer
2876 to a version by sequence number, name or timestamp.</para>
2877
2878 <para>
2879 You can take a sequence (or pair) of single version bug databases and create
2880 from them a multiversion bug database, or combine a multiversion bug database
2881 with a sequence of later single-version bug databases.</para>
2882
2883 <para>
2884 Some of these commands can be invoked as ant tasks. See below for specifics
2885 on how to invoke them and what attributes and arguments they take. All of
2886 the examples assume that the <literal>findbugs.lib</literal>
2887 <literal>refid</literal> is set correctly. Here is one way to set it:
2888 </para>
2889
2890 <programlisting>
2891 <![CDATA[
2892 <!-- findbugs task definition -->
2893 <property name="findbugs.home" value="/your/path/to/findbugs" />
2894 <path id="findbugs.lib">
2895 <fileset dir="${findbugs.home}/lib">
2896 <include name="findbugs-ant.jar"/>
2897 </fileset>
2898 </path>
2899 ]]>
2900 </programlisting>
2901
2902 <sect1 id="commands">
2903 <title>Commands</title>
2904
2905 <para>
2906 All tools for FindBugs data mining are can be invoked from the command line,
2907 and some of the more useful tools can also be invoked from an
2908 ant build file.</para>
2909
2910 <para>
2911 Briefly, the command-line tools are:</para>
2912
2913 <variablelist>
2914 <varlistentry>
2915 <term><command><link linkend="unionBugs">unionBugs</link></command></term>
2916 <listitem>
2917 <para>
2918 combine the results from separate analysis of disjoint
2919 classes
2920 </para>
2921 </listitem>
2922 </varlistentry>
2923 <varlistentry>
2924 <term><command><link linkend="computeBugHistory">computeBugHistory</link></command></term>
2925 <listitem>
2926 <para>Merge bug warnings from multiple versions of
2927 analyzed code into
2928 a single multiversion bug database. This can either be used
2929 to add more versions to an existing multiversion database,
2930 or to create a multiversion database from a sequence of single version
2931 bug warning databases.</para>
2932 </listitem>
2933 </varlistentry>
2934 <varlistentry>
2935 <term><command><link linkend="setBugDatabaseInfo">setBugDatabaseInfo</link></command></term>
2936 <listitem>
2937 <para>Set information such as the revision name or
2938 timestamp in an XML bug database</para>
2939 </listitem>
2940 </varlistentry>
2941 <varlistentry>
2942 <term><command><link linkend="listBugDatabaseInfo">listBugDatabaseInfo</link></command></term>
2943 <listitem>
2944 <para>List information such as the revision name and
2945 timestamp for a list of XML bug databases</para>
2946 </listitem>
2947 </varlistentry>
2948 <varlistentry>
2949 <term><command><link linkend="filterBugs">filterBugs</link></command></term>
2950 <listitem>
2951 <para>Select a subset of a bug database</para>
2952 </listitem>
2953 </varlistentry>
2954 <varlistentry>
2955 <term><command><link linkend="mineBugHistory">mineBugHistory</link></command></term>
2956 <listitem>
2957 <para>Generate a tabular listing of the number of warnings in each
2958 version of a multiversion bug database</para>
2959 </listitem>
2960 </varlistentry>
2961 <varlistentry>
2962 <term><command><link linkend="defectDensity">defectDensity</link></command></term>
2963 <listitem>
2964 <para>List information about defect density
2965 (warnings per 1000 NCSS)
2966 for the entire project and each class and package</para>
2967 </listitem>
2968 </varlistentry>
2969 <varlistentry>
2970 <term><command><link linkend="convertXmlToText">convertXmlToText</link></command></term>
2971 <listitem>
2972 <para>Convert bug warnings in XML format to
2973 a textual one-line-per-bug format, or to HTML</para>
2974 </listitem>
2975 </varlistentry>
2976 </variablelist>
2977
2978
2979 <sect2 id="unionBugs">
2980 <title>unionBugs</title>
2981
2982 <para>
2983 If you have, for example, separately analyzing each jar file used in an application,
2984 you can use this command to combine the separately generated xml bug warning files into
2985 a single file containing all of the warnings.</para>
2986
2987 <para>Do <emphasis>not</emphasis> use this command to combine results from analyzing different versions of the same
2988 file; use <command>computeBugHistory</command> instead.</para>
2989
2990 <para>Specify the xml files on the command line. The result is sent to standard output.</para>
2991 </sect2>
2992
2993 <sect2 id="computeBugHistory">
2994 <title>computeBugHistory</title>
2995
2996 <para>Use this command to generate a bug database containing information from different builds or versions
2997 of software you are analyzing.
2998 History is taken from the first file provided as input; any following
2999 files should be single version bug databases (if they contain history, the history in those
3000 files will be ignored).</para>
3001 <para>By default, output is written to the standard output.
3002 </para>
3003
3004 <para>This functionality may also can be accessed from ant.
3005 First create a taskdef for <command>computeBugHistory</command> in your
3006 build file:
3007 </para>
3008
3009 <programlisting>
3010 <![CDATA[
3011 <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
3012 <classpath refid="findbugs.lib" />
3013 </taskdef>
3014 ]]>
3015 </programlisting>
3016
3017 <para>Attributes for this ant task are listed in the following table.
3018 To specify input files, nest them inside with a
3019 <literal>&lt;datafile&gt;</literal> element. For example:
3020 </para>
3021
3022 <programlisting>
3023 <![CDATA[
3024 <computeBugHistory home="${findbugs.home}" ...>
3025 <datafile name="analyze1.xml"/>
3026 <datafile name="analyze2.xml"/>
3027 </computeBugHistory>
3028 ]]>
3029 </programlisting>
3030
3031 <table id="computeBugHistoryTable">
3032 <title>Options for computeBugHistory command</title>
3033 <tgroup cols="3" align="left">
3034 <thead>
3035 <row>
3036 <entry>Command-line option</entry>
3037 <entry>Ant attribute</entry>
3038 <entry>Meaning</entry>
3039 </row>
3040 </thead>
3041 <tbody>
3042 <row><entry>-output &lt;file&gt;</entry> <entry>output="&lt;file&gt;"</entry> <entry>save output in the named file (may also be an input file)</entry></row>
3043 <row><entry>-overrideRevisionNames[:truth]</entry> <entry>overrideRevisionNames="[true|false]"</entry><entry>override revision names for each version with names computed from the filenames</entry></row>
3044 <row><entry>-noPackageMoves[:truth]</entry> <entry>noPackageMoves="[true|false]"</entry><entry>if a class has moved to another package, treat warnings in that class as seperate</entry></row>
3045 <row><entry>-preciseMatch[:truth]</entry> <entry>preciseMatch="[true|false]"</entry><entry>require bug patterns to match precisely</entry></row>
3046 <row><entry>-precisePriorityMatch[:truth]</entry> <entry>precisePriorityMatch="[true|false]"</entry><entry>consider two warnings as the same only if priorities match exactly</entry></row>
3047 <row><entry>-quiet[:truth]</entry> <entry>quiet="[true|false]"</entry><entry>don't generate any output to standard out unless there is an error</entry></row>
3048 <row><entry>-withMessages[:truth]</entry> <entry>withMessages="[true|false]"</entry><entry>include human-readable messages describing the warnings in XML output</entry></row>
3049 </tbody>
3050 </tgroup>
3051 </table>
3052
3053 </sect2>
3054 <sect2 id="filterBugs">
3055 <title>filterBugs</title>
3056 <para>This command is used to select a subset of warnings from a FindBugs XML warning file
3057 and write the selected subset to a new FindBugs warning file.</para>
3058 <para>
3059 This command takes a sequence of options, and either zero, one or two
3060 filenames of findbugs xml bug files on the command line.</para>
3061 <para>If no file names are provided, the command reads from standard input
3062 and writes to standard output. If one file name is provided,
3063 it reads from the file and writes to standard output.
3064 If two file names are provided, it reads from the first and writes the output
3065 to the second file name.</para>
3066
3067 <para>This functionality may also can be accessed from ant.
3068 First create a taskdef for <command>filterBugs</command> in your
3069 build file:
3070 </para>
3071
3072 <programlisting>
3073 <![CDATA[
3074 <taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask">
3075 <classpath refid="findbugs.lib" />
3076 </taskdef>
3077 ]]>
3078 </programlisting>
3079
3080 <para>Attributes for this ant task are listed in the following table.
3081 To specify an input file either use the input attribute or nest it inside
3082 the ant call with a <literal>&lt;datafile&gt;</literal> element. For example:
3083 </para>
3084
3085 <programlisting>
3086 <![CDATA[
3087 <filterBugs home="${findbugs.home}" ...>
3088 <datafile name="analyze.xml"/>
3089 </filterBugs>
3090 ]]>
3091 </programlisting>
3092
3093 <table id="filterOptionsTable">
3094 <title>Options for filterBugs command</title>
3095 <tgroup cols="3" align="left">
3096 <thead>
3097 <row>
3098 <entry>Command-line option</entry>
3099 <entry>Ant attribute</entry>
3100 <entry>Meaning</entry>
3101 </row>
3102 </thead>
3103 <tbody>
3104 <row><entry></entry> <entry>input="&lt;file&gt;"</entry> <entry>use file as input</entry></row>
3105 <row><entry></entry> <entry>output="&lt;file&gt;"</entry> <entry>output results to file</entry></row>
3106 <row><entry>-not</entry> <entry>not="[true|false]"</entry> <entry>reverse (all) switches for the filter</entry></row>
3107 <row><entry>-withSource[:truth]</entry> <entry>withSource="[true|false]"</entry> <entry>only warnings for switch source is available</entry></row>
3108 <row><entry>-exclude &lt;filter file&gt;</entry><entry>exclude="&lt;filter file&gt;"</entry> <entry>exclude bugs matching given filter</entry></row>
3109 <row><entry>-include &lt;filter file&gt;</entry><entry>include="&lt;filter file&gt;"</entry> <entry>include only bugs matching given filter</entry></row>
3110 <row><entry>-annotation &lt;text&gt;</entry> <entry>annotation="&lt;text&gt;"</entry> <entry>allow only warnings containing this text in a manual annotation</entry></row>
3111 <row><entry>-after &lt;when&gt;</entry> <entry>after="&lt;when&gt;"</entry> <entry>allow only warnings that first occurred after this version</entry></row>
3112 <row><entry>-before &lt;when&gt;</entry> <entry>before="&lt;when&gt;"</entry> <entry>allow only warnings that first occurred before this version</entry></row>
3113 <row><entry>-first &lt;when&gt;</entry> <entry>first="&lt;when&gt;"</entry> <entry>allow only warnings that first occurred in this version</entry></row>
3114 <row><entry>-last &lt;when&gt;</entry> <entry>last="&lt;when&gt;"</entry> <entry>allow only warnings that last occurred in this version</entry></row>
3115 <row><entry>-fixed &lt;when&gt;</entry> <entry>fixed="&lt;when&gt;"</entry> <entry>allow only warnings that last occurred in the previous version (clobbers <option>-last</option>)</entry></row>
3116 <row><entry>-present &lt;when&gt;</entry> <entry>present="&lt;when&gt;"</entry> <entry>allow only warnings present in this version</entry></row>
3117 <row><entry>-absent &lt;when&gt;</entry> <entry>absent="&lt;when&gt;"</entry> <entry>allow only warnings absent in this version</entry></row>
3118 <row><entry>-active[:truth]</entry> <entry>active="[true|false]"</entry> <entry>allow only warnings alive in the last sequence number</entry></row>
3119 <row><entry>-introducedByChange[:truth]</entry> <entry>introducedByChange="[true|false]"</entry><entry>allow only warnings introduced by a change of an existing class</entry></row>
3120 <row><entry>-removedByChange[:truth]</entry> <entry>removedByChange="[true|false]"</entry> <entry>allow only warnings removed by a change of a persisting class</entry></row>
3121 <row><entry>-newCode[:truth]</entry> <entry>newCode="[true|false]"</entry> <entry>allow only warnings introduced by the addition of a new class</entry></row>
3122 <row><entry>-removedCode[:truth]</entry> <entry>removedCode="[true|false]"</entry> <entry>allow only warnings removed by removal of a class</entry></row>
3123 <row><entry>-priority &lt;level&gt;</entry> <entry>priority="&lt;level&gt;"</entry> <entry>allow only warnings with this priority or higher</entry></row>
3124 <row><entry>-maxRank &lt;rank&gt;</entry> <entry>rank="[1..20]"</entry> <entry>allow only warnings with this rank or lower</entry></row>
3125 <row><entry>-class &lt;pattern&gt;</entry> <entry>class="&lt;class&gt;"</entry> <entry>allow only bugs whose primary class name matches this pattern</entry></row>
3126 <row><entry>-bugPattern &lt;pattern&gt;</entry> <entry>bugPattern="&lt;pattern&gt;"</entry> <entry>allow only bugs whose type matches this pattern</entry></row>
3127 <row><entry>-category &lt;category&gt;</entry> <entry>category="&lt;category&gt;"</entry> <entry>allow only warnings with a category that starts with this string</entry></row>
3128 <row><entry>-designation &lt;designation&gt;</entry> <entry>designation="&lt;designation&gt;"</entry> <entry>allow only warnings with this designation (e.g., -designation SHOULD_FIX)</entry></row>
3129 <row><entry>-withMessages[:truth] </entry> <entry>withMessages="[true|false]"</entry> <entry>the generated XML should contain textual messages</entry></row>
3130 </tbody>
3131 </tgroup>
3132 </table>
3133
3134 </sect2>
3135
3136 <sect2 id="mineBugHistory">
3137 <title>mineBugHistory</title>
3138 <para>This command generates a table containing counts of the numbers of warnings
3139 in each version of a multiversion bug database.</para>
3140
3141
3142 <para>This functionality may also can be accessed from ant.
3143 First create a taskdef for <command>mineBugHistory</command> in your
3144 build file:
3145 </para>
3146
3147 <programlisting>
3148 <![CDATA[
3149 <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
3150 <classpath refid="findbugs.lib" />
3151 </taskdef>
3152 ]]>
3153 </programlisting>
3154
3155 <para>Attributes for this ant task are listed in the following table.
3156 To specify an input file either use the <literal>input</literal>
3157 attribute or nest it inside the ant call with a
3158 <literal>&lt;datafile&gt;</literal> element. For example:
3159 </para>
3160
3161 <programlisting>
3162 <![CDATA[
3163 <mineBugHistory home="${findbugs.home}" ...>
3164 <datafile name="analyze.xml"/>
3165 </mineBugHistory>
3166 ]]>
3167 </programlisting>
3168
3169 <table id="mineBugHistoryOptionsTable">
3170 <title>Options for mineBugHistory command</title>
3171 <tgroup cols="3" align="left">
3172 <thead>
3173 <row>
3174 <entry>Command-line option</entry>
3175 <entry>Ant attribute</entry>
3176 <entry>Meaning</entry>
3177 </row>
3178 </thead>
3179 <tbody>
3180 <row><entry></entry> <entry>input="&lt;file&gt;"</entry> <entry>use file as input</entry></row>
3181 <row><entry></entry> <entry>output="&lt;file&gt;"</entry> <entry>write output to file</entry></row>
3182 <row><entry>-formatDates</entry> <entry>formatDates="[true|false]"</entry> <entry>render dates in textual form</entry></row>
3183 <row><entry>-noTabs</entry> <entry>noTabs="[true|false]"</entry> <entry>delimit columns with groups of spaces instead of tabs (see below)</entry></row>
3184 <row><entry>-summary</entry> <entry>summary="[true|false]"</entry> <entry>output terse summary of changes over the last ten entries</entry></row>
3185 </tbody>
3186 </tgroup>
3187 </table>
3188
3189 <para>
3190 The <option>-noTabs</option> output can be easier to read from a shell
3191 with a fixed-width font.
3192 Because numeric columns are right-justified, spaces may precede the
3193 first column value. This option also causes <option>-formatDates</option>
3194 to render dates in terser format without embedded whitespace.
3195 </para>
3196
3197 <para>The table is a tab-separated (barring <option>-noTabs</option>)
3198 table with the following columns:</para>
3199
3200 <table id="mineBugHistoryColumns">
3201 <title>Columns in mineBugHistory output</title>
3202 <tgroup cols="2" align="left">
3203 <thead>
3204 <row>
3205 <entry>Title</entry>
3206 <entry>Meaning</entry>
3207 </row>
3208 </thead>
3209 <tbody>
3210 <row><entry>seq</entry><entry>Sequence number (successive integers, starting at 0)</entry></row>
3211 <row><entry>version</entry><entry>Version name</entry></row>
3212 <row><entry>time</entry><entry>Release timestamp</entry></row>
3213 <row><entry>classes</entry><entry>Number of classes analyzed</entry></row>
3214 <row><entry>NCSS</entry><entry>Non Commenting Source Statements</entry></row>
3215 <row><entry>added</entry><entry>Count of new warnings for a class that existed in the previous version</entry></row>
3216 <row><entry>newCode</entry><entry>Count of new warnings for a class that did not exist in the previous version</entry></row>
3217 <row><entry>fixed</entry><entry>Count of warnings removed from a class that remains in the current version</entry></row>
3218 <row><entry>removed</entry><entry>Count of warnings in the previous version for a class that is not present in the current version</entry></row>
3219 <row><entry>retained</entry><entry>Count of warnings that were in both the previous and current version</entry></row>
3220 <row><entry>dead</entry><entry>Warnings that were present in earlier versions but in neither the current version or the immediately preceeding version</entry></row>
3221 <row><entry>active</entry><entry>Total warnings present in the current version</entry></row>
3222 </tbody>
3223 </tgroup>
3224 </table>
3225 </sect2>
3226
3227 <sect2 id="defectDensity">
3228 <title>defectDensity</title>
3229 <para>
3230 This command lists information about defect density (warnings per 1000 NCSS) for the entire project and each class and package.
3231 It can either be invoked with no files specified on the command line (in which case it reads from standard input)
3232 or with one file specified on the command line.</para>
3233 <para>It generates a table with the following columns, and with one
3234 row for the entire project, and one row for each package or class that contains at least
3235 4 warnings.</para>
3236 <table id="defectDensityColumns">
3237 <title>Columns in defectDensity output</title>
3238 <tgroup cols="2" align="left">
3239 <thead>
3240 <row>
3241 <entry>Title</entry>
3242 <entry>Meaning</entry>
3243 </row>
3244 </thead>
3245 <tbody>
3246 <row><entry>kind</entry><entry>project, package or class</entry></row>
3247 <row><entry>name</entry><entry>The name of the project, package or class</entry></row>
3248 <row><entry>density</entry><entry>Number of warnings generated per 1000 lines of NCSS.</entry></row>
3249 <row><entry>bugs</entry><entry>Number of warnings</entry></row>
3250 <row><entry>NCSS</entry><entry>Calculated number of NCSS</entry></row>
3251 </tbody>
3252 </tgroup>
3253 </table>
3254 </sect2>
3255
3256 <sect2 id="convertXmlToText">
3257 <title>convertXmlToText</title>
3258
3259 <para>
3260 This command converts a warning collection in XML format to a text
3261 format with one line per warning, or to HTML.
3262 </para>
3263
3264 <para>This functionality may also can be accessed from ant.
3265 First create a taskdef for <command>convertXmlToText</command> in your
3266 build file:
3267 </para>
3268
3269 <programlisting>
3270 <![CDATA[
3271 <taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask">
3272 <classpath refid="findbugs.lib" />
3273 </taskdef>
3274 ]]>
3275 </programlisting>
3276
3277 <para>Attributes for this ant task are listed in the following table.</para>
3278
3279 <table id="convertXmlToTextTable">
3280 <title>Options for convertXmlToText command</title>
3281 <tgroup cols="3" align="left">
3282 <thead>
3283 <row>
3284 <entry>Command-line option</entry>
3285 <entry>Ant attribute</entry>
3286 <entry>Meaning</entry>
3287 </row>
3288 </thead>
3289 <tbody>
3290 <row><entry></entry> <entry>input="&lt;filename&gt;"</entry> <entry>use file as input</entry></row>
3291 <row><entry></entry> <entry>output="&lt;filename&gt;"</entry> <entry>output results to file</entry></row>
3292 <row><entry>-longBugCodes</entry> <entry>longBugCodes="[true|false]"</entry> <entry>use the full bug pattern code instead of two-letter abbreviation</entry></row>
3293 <row><entry></entry> <entry>format="text"</entry> <entry>generate plain text output with one bug per line (command-line default)</entry></row>
3294 <row><entry>-html[:stylesheet]</entry> <entry>format="html:&lt;stylesheet&gt;"</entry> <entry>generate output with specified stylesheet (see below), or default.xsl if unspecified</entry></row>
3295 </tbody>
3296 </tgroup>
3297 </table>
3298
3299 <para>
3300 You may specify plain.xsl, default.xsl, fancy.xsl, fancy-hist.xsl,
3301 or your own XSL stylesheet for the -html/format option.
3302 Despite the name of this option, you may specify
3303 a stylesheet that emits something other than html.
3304 When applying a stylesheet other than those included
3305 with FindBugs (listed above), the -html/format option should be used
3306 with a path or URL to the stylesheet.
3307 </para>
3308 </sect2>
3309
3310 <sect2 id="setBugDatabaseInfo">
3311 <title>setBugDatabaseInfo</title>
3312
3313 <para>
3314 This command sets meta-information in a specified warning collection.
3315 It takes the following options:
3316 </para>
3317
3318 <para>This functionality may also can be accessed from ant.
3319 First create a taskdef for <command>setBugDatabaseInfo</command> in your
3320 build file:
3321 </para>
3322
3323 <programlisting>
3324 <![CDATA[
3325 <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
3326 <classpath refid="findbugs.lib" />
3327 </taskdef>
3328 ]]>
3329 </programlisting>
3330
3331 <para>Attributes for this ant task are listed in the following table.
3332 To specify an input file either use the <literal>input</literal>
3333 attribute or nest it inside the ant call with a
3334 <literal>&lt;datafile&gt;</literal> element. For example:
3335 </para>
3336
3337 <programlisting>
3338 <![CDATA[
3339 <setBugDatabaseInfo home="${findbugs.home}" ...>
3340 <datafile name="analyze.xml"/>
3341 </setBugDatabaseInfo>
3342 ]]>
3343 </programlisting>
3344
3345 <table id="setBugDatabaseInfoOptions">
3346 <title>setBugDatabaseInfo Options</title>
3347 <tgroup cols="3" align="left">
3348 <thead>
3349 <row>
3350 <entry>Command-line option</entry>
3351 <entry>Ant attribute</entry>
3352 <entry>Meaning</entry>
3353 </row>
3354 </thead>
3355 <tbody>
3356 <row><entry></entry> <entry>input="&lt;file&gt;"</entry> <entry>use file as input</entry></row>
3357 <row><entry></entry> <entry>output="&lt;file&gt;"</entry> <entry>write output to file</entry></row>
3358 <row><entry>-name &lt;name&gt;</entry> <entry>name="&lt;name&gt;"</entry> <entry>set name for (last) revision</entry></row>
3359 <row><entry>-timestamp &lt;when&gt;</entry> <entry>timestamp="&lt;when&gt;"</entry> <entry>set timestamp for (last) revision</entry></row>
3360 <row><entry>-source &lt;directory&gt;</entry> <entry>source="&lt;directory&gt;"</entry> <entry>add specified directory to the source search path</entry></row>
3361 <row><entry>-findSource &lt;directory&gt;</entry> <entry>findSource="&lt;directory&gt;"</entry> <entry>find and add all relevant source directions contained within specified directory</entry></row>
3362 <row><entry>-suppress &lt;filter file&gt;</entry> <entry>suppress="&lt;filter file&gt;"</entry> <entry>suppress warnings matched by this file (replaces previous suppressions)</entry></row>
3363 <row><entry>-withMessages</entry> <entry>withMessages="[true|false]"</entry> <entry>add textual messages to XML</entry></row>
3364 <row><entry>-resetSource</entry> <entry>resetSource="[true|false]"</entry> <entry>remove all source search paths</entry></row>
3365 </tbody>
3366 </tgroup>
3367 </table>
3368 </sect2>
3369
3370 <sect2 id="listBugDatabaseInfo">
3371 <title>listBugDatabaseInfo</title>
3372
3373 <para>This command takes a list of zero or more xml bug database filenames on the command line.
3374 If zero file names are provided, it reads from standard input and does not generate
3375 a table header.</para>
3376
3377 <para>There is only one option: <option>-formatDates</option> renders dates
3378 in textual form.
3379 </para>
3380
3381 <para>The output is a table one row per bug database and the following columns:</para>
3382 <table id="listBugDatabaseInfoColumns">
3383 <title>listBugDatabaseInfo Columns</title>
3384 <tgroup cols="2" align="left">
3385 <thead>
3386 <row>
3387 <entry>Column</entry>
3388 <entry>Meaning</entry>
3389 </row>
3390 </thead>
3391 <tbody>
3392 <row><entry>version</entry><entry>version name</entry></row>
3393 <row><entry>time</entry><entry>Release timestamp</entry></row>
3394 <row><entry>classes</entry><entry>Number of classes analyzed</entry></row>
3395 <row><entry>NCSS</entry><entry>Non Commenting Source Statements analyzed</entry></row>
3396 <row><entry>total</entry><entry>Total number of warnings of all kinds</entry></row>
3397 <row><entry>high</entry><entry>Total number of high priority warnings of all kinds</entry></row>
3398 <row><entry>medium</entry><entry>Total number of medium/normal priority warnings of all kinds</entry></row>
3399 <row><entry>low</entry><entry>Total number of low priority warnings of all kinds</entry></row>
3400 <row><entry>filename</entry><entry>filename of database</entry></row>
3401 <!--
3402 <row><entry></entry><entry></entry></row>
3403 <row><entry></entry><entry></entry></row>
3404 <row><entry></entry><entry></entry></row>
3405 <row><entry></entry><entry></entry></row>
3406 <row><entry></entry><entry></entry></row>
3407 <row><entry></entry><entry></entry></row>
3408 -->
3409 </tbody>
3410 </tgroup>
3411 </table>
3412
3413 </sect2>
3414
3415 </sect1>
3416
3417 <sect1 id="examples">
3418 <title>Examples</title>
3419 <sect2 id="unixscriptsexamples">
3420 <title>Mining history using proveded shell scrips</title>
3421 <para>In all of the following, the commands are given in a directory that contains
3422 directories jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60.</para>
3423
3424 <para>You can use the command:</para>
3425 <screen>
3426 computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
3427 </screen>
3428 <para>to generate the following output:</para>
3429
3430 <screen>
3431 seq version time classes NCSS added newCode fixed removed retained dead active
3432 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 4 0 0 0 0 4
3433 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 4 0 4
3434 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 0 0 2 0 2 0 2
3435 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 0 0 1 0 1 2 1
3436 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 0 0 1 3 1
3437 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 0 0 1 3 1
3438 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1 3 1
3439 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 0 0 1 3 1
3440 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1 3 1
3441 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 0 0 1 3 1
3442 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 0 0 0 0 1 3 1
3443 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1 3 1
3444 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 0 0 0 0 1 3 1
3445 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1 3 1
3446 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1 3 1
3447 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 0 0 0 0 1 3 1
3448 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 0 0 0 0 1 3 1
3449 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1 3 2
3450 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 0 0 0 2 3 2
3451 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 2 3 2
3452 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 0 0 0 2 3 2
3453 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 0 0 0 0 2 3 2
3454 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 0 1 0 0 2 3 3
3455 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 0 2 0 0 3 3 5
3456 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 5 3 5
3457 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 0 0 0 0 5 3 5
3458 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 0 0 0 0 5 3 5
3459 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 5 3 5
3460 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 0 0 1 0 4 3 4
3461 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 0 0 0 0 4 4 4
3462 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 0 0 1 0 3 4 3
3463 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 3 5 3
3464 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 0 0 0 0 3 5 3
3465 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 1 0 0 0 3 5 4
3466 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 0 0 0 0 4 5 4
3467 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 0 0 4 5 4
3468 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 0 0 1 0 3 5 3
3469 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 3 6 3
3470 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 0 0 0 0 3 6 3
3471 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 0 0 0 0 3 6 3
3472 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 3 6 3
3473 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 0 0 0 3 6 3
3474 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 0 0 0 0 3 6 3
3475 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 3 6 3
3476 </screen>
3477
3478 <para>
3479 We could also generate that information directly, without creating an intermediate db.xml file, using the command
3480 </para>
3481
3482 <screen>
3483 computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
3484 </screen>
3485
3486 <para>We can then use that information to display a graph showing the number of infinite recursive loops
3487 found by FindBugs in each build of Sun's JDK1.6.0. The blue area indicates the number of infinite
3488 recursive loops in that build, the red area above it indicates the number of infinite recursive loops that existed
3489 in some previous version but not in the current version (thus, the combined height of the red and blue areas
3490 is guaranteed to never decrease, and goes up whenever a new infinite recursive loop bug is introduced). The height
3491 of the red area is computed as the sum of the fixed, removed and dead values for each version.
3492 The reductions in builds 13 and 14 came after Sun was notified about the bugs found by FindBugs in the JDK.
3493 </para>
3494 <mediaobject>
3495 <imageobject>
3496 <imagedata fileref="infiniteRecursiveLoops.png" />
3497 </imageobject>
3498 </mediaobject>
3499
3500 <para>
3501 Given the db.xml file that contains the results for all the jdk1.6.0 builds, the following command will show the history of high and medium priority correctness warnings:
3502 </para>
3503
3504 <screen>
3505 filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
3506 </screen>
3507
3508 <para>
3509 generating the table:
3510 </para>
3511
3512 <screen>
3513 seq version time classes NCSS added newCode fixed removed retained dead active
3514 0 jdk1.6.0-b12 "Thu Nov 11 09:07:20 EST 2004" 13128 811569 0 1075 0 0 0 0 1075
3515 1 jdk1.6.0-b13 "Thu Nov 18 06:02:06 EST 2004" 13128 811570 0 0 0 0 1075 0 1075
3516 2 jdk1.6.0-b14 "Thu Dec 02 06:12:26 EST 2004" 13145 811786 3 0 6 0 1069 0 1072
3517 3 jdk1.6.0-b15 "Thu Dec 09 06:07:04 EST 2004" 13174 811693 2 1 3 0 1069 6 1072
3518 4 jdk1.6.0-b16 "Thu Dec 16 06:21:28 EST 2004" 13175 811715 0 0 1 0 1071 9 1071
3519 5 jdk1.6.0-b17 "Thu Dec 23 06:27:22 EST 2004" 13176 811974 0 0 1 0 1070 10 1070
3520 6 jdk1.6.0-b19 "Thu Jan 13 06:41:16 EST 2005" 13176 812011 0 0 0 0 1070 11 1070
3521 7 jdk1.6.0-b21 "Thu Jan 27 05:57:52 EST 2005" 13177 812173 0 0 1 0 1069 11 1069
3522 8 jdk1.6.0-b23 "Thu Feb 10 05:44:36 EST 2005" 13179 812188 0 0 0 0 1069 12 1069
3523 9 jdk1.6.0-b26 "Thu Mar 03 06:04:02 EST 2005" 13199 811770 0 0 2 1 1066 12 1066
3524 10 jdk1.6.0-b27 "Thu Mar 10 04:48:38 EST 2005" 13189 812440 1 0 1 1 1064 15 1065
3525 11 jdk1.6.0-b28 "Thu Mar 17 02:54:22 EST 2005" 13185 812056 0 0 0 0 1065 17 1065
3526 12 jdk1.6.0-b29 "Thu Mar 24 03:09:20 EST 2005" 13117 809468 3 0 8 26 1031 17 1034
3527 13 jdk1.6.0-b30 "Thu Mar 31 02:53:32 EST 2005" 13118 809501 0 0 0 0 1034 51 1034
3528 14 jdk1.6.0-b31 "Thu Apr 07 03:00:14 EDT 2005" 13117 809572 0 0 0 0 1034 51 1034
3529 15 jdk1.6.0-b32 "Thu Apr 14 02:56:56 EDT 2005" 13169 811096 1 1 0 1 1033 51 1035
3530 16 jdk1.6.0-b33 "Thu Apr 21 02:46:22 EDT 2005" 13187 811942 3 0 2 1 1032 52 1035
3531 17 jdk1.6.0-b34 "Thu Apr 28 02:49:00 EDT 2005" 13195 813488 0 1 0 0 1035 55 1036
3532 18 jdk1.6.0-b35 "Thu May 05 02:49:04 EDT 2005" 13457 829837 0 36 2 0 1034 55 1070
3533 19 jdk1.6.0-b36 "Thu May 12 02:59:46 EDT 2005" 13462 831278 0 0 0 0 1070 57 1070
3534 20 jdk1.6.0-b37 "Thu May 19 02:55:08 EDT 2005" 13464 831971 0 1 1 0 1069 57 1070
3535 21 jdk1.6.0-b38 "Thu May 26 03:08:16 EDT 2005" 13564 836565 1 7 2 6 1062 58 1070
3536 22 jdk1.6.0-b39 "Fri Jun 03 03:10:48 EDT 2005" 13856 849992 6 39 5 0 1065 66 1110
3537 23 jdk1.6.0-b40 "Thu Jun 09 03:30:28 EDT 2005" 15972 959619 7 147 11 0 1099 71 1253
3538 24 jdk1.6.0-b41 "Thu Jun 16 03:19:22 EDT 2005" 15972 959619 0 0 0 0 1253 82 1253
3539 25 jdk1.6.0-b42 "Fri Jun 24 03:38:54 EDT 2005" 15966 958581 3 0 1 2 1250 82 1253
3540 26 jdk1.6.0-b43 "Thu Jul 14 03:09:34 EDT 2005" 16041 960544 5 11 15 8 1230 85 1246
3541 27 jdk1.6.0-b44 "Thu Jul 21 03:05:54 EDT 2005" 16041 960547 0 0 0 0 1246 108 1246
3542 28 jdk1.6.0-b45 "Thu Jul 28 03:26:10 EDT 2005" 16037 960606 19 0 2 0 1244 108 1263
3543 29 jdk1.6.0-b46 "Thu Aug 04 03:02:48 EDT 2005" 15936 951355 13 1 1 32 1230 110 1244
3544 30 jdk1.6.0-b47 "Thu Aug 11 03:18:56 EDT 2005" 15964 952387 163 8 7 20 1217 143 1388
3545 31 jdk1.6.0-b48 "Thu Aug 18 08:10:40 EDT 2005" 15970 953421 0 0 0 0 1388 170 1388
3546 32 jdk1.6.0-b49 "Thu Aug 25 03:24:38 EDT 2005" 16048 958940 1 11 1 0 1387 170 1399
3547 33 jdk1.6.0-b50 "Thu Sep 01 01:52:40 EDT 2005" 16287 974937 19 27 16 7 1376 171 1422
3548 34 jdk1.6.0-b51 "Thu Sep 08 01:55:36 EDT 2005" 16362 979377 1 15 3 0 1419 194 1435
3549 35 jdk1.6.0-b52 "Thu Sep 15 02:04:08 EDT 2005" 16477 979399 0 0 1 1 1433 197 1433
3550 36 jdk1.6.0-b53 "Thu Sep 22 02:00:28 EDT 2005" 16019 957900 13 12 16 20 1397 199 1422
3551 37 jdk1.6.0-b54 "Thu Sep 29 01:54:34 EDT 2005" 16019 957900 0 0 0 0 1422 235 1422
3552 38 jdk1.6.0-b55 "Thu Oct 06 01:54:14 EDT 2005" 16051 959014 1 4 7 0 1415 235 1420
3553 39 jdk1.6.0-b56 "Thu Oct 13 01:54:12 EDT 2005" 16211 970835 6 8 37 0 1383 242 1397
3554 40 jdk1.6.0-b57 "Thu Oct 20 01:55:26 EDT 2005" 16279 971627 0 0 0 0 1397 279 1397
3555 41 jdk1.6.0-b58 "Thu Oct 27 01:56:30 EDT 2005" 16283 971945 0 1 1 0 1396 279 1397
3556 42 jdk1.6.0-b59 "Thu Nov 03 01:56:58 EST 2005" 16232 972193 6 0 5 0 1392 280 1398
3557 43 jdk1.6.0-b60 "Thu Nov 10 01:54:18 EST 2005" 16235 972346 0 0 0 0 1398 285 1398
3558 44 jdk1.6.0-b61 "Thu Nov 17 01:58:42 EST 2005" 16202 971134 2 0 4 0 1394 285 1396
3559 </screen>
3560 </sect2>
3561
3562 <sect2 id="incrementalhistory">
3563 <title>Incremental history maintenance</title>
3564
3565 <para>
3566 If db.xml contains the results of running findbugs over builds b12 - b60, we can update db.xml to include the results of analyzing b61 with the commands:
3567 </para>
3568 <screen>
3569 computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
3570 </screen>
3571 </sect2>
3572
3573 </sect1>
3574
3575 <sect1 id="antexample">
3576 <title>Ant example</title>
3577 <para>
3578 Here is a complete ant script example for both running findbugs and running a chain of data-mining tools afterward:
3579 </para>
3580 <screen>
3581 <![CDATA[
3582 <project name="analyze_asm_util" default="findbugs">
3583 <!-- findbugs task definition -->
3584 <property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" />
3585 <property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" />
3586
3587 <path id="findbugs.lib">
3588 <fileset dir="${findbugs.home}/lib">
3589 <include name="findbugs-ant.jar"/>
3590 </fileset>
3591 </path>
3592
3593 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
3594 <classpath refid="findbugs.lib" />
3595 </taskdef>
3596
3597 <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
3598 <classpath refid="findbugs.lib" />
3599 </taskdef>
3600
3601 <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
3602 <classpath refid="findbugs.lib" />
3603 </taskdef>
3604
3605 <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
3606 <classpath refid="findbugs.lib" />
3607 </taskdef>
3608
3609 <!-- findbugs task definition -->
3610 <target name="findbugs">
3611 <antcall target="analyze" />
3612 <antcall target="mine" />
3613 </target>
3614
3615 <!-- analyze task -->
3616 <target name="analyze">
3617 <!-- run findbugs against asm-util -->
3618 <findbugs home="${findbugs.home}"
3619 output="xml:withMessages"
3620 timeout="90000000"
3621 reportLevel="experimental"
3622 workHard="true"
3623 effort="max"
3624 adjustExperimental="true"
3625 jvmargs="${jvmargs}"
3626 failOnError="true"
3627 outputFile="out.xml"
3628 projectName="Findbugs"
3629 debug="false">
3630 <class location="asm-util-3.0.jar" />
3631 </findbugs>
3632 </target>
3633
3634 <target name="mine">
3635
3636 <!-- Set info to the latest analysis -->
3637 <setBugDatabaseInfo home="${findbugs.home}"
3638 withMessages="true"
3639 name="asm-util-3.0.jar"
3640 input="out.xml"
3641 output="out-rel.xml"/>
3642
3643 <!-- Checking if history file already exists (out-hist.xml) -->
3644 <condition property="mining.historyfile.available">
3645 <available file="out-hist.xml"/>
3646 </condition>
3647 <condition property="mining.historyfile.notavailable">
3648 <not>
3649 <available file="out-hist.xml"/>
3650 </not>
3651 </condition>
3652
3653 <!-- this target is executed if the history file do not exist (first run) -->
3654 <antcall target="history-init">
3655 <param name="data.file" value="out-rel.xml" />
3656 <param name="hist.file" value="out-hist.xml" />
3657 </antcall>
3658 <!-- else this one is executed -->
3659 <antcall target="history">
3660 <param name="data.file" value="out-rel.xml" />
3661 <param name="hist.file" value="out-hist.xml" />
3662 <param name="hist.summary.file" value="out-hist.txt" />
3663 </antcall>
3664 </target>
3665
3666 <!-- Initializing history file -->
3667 <target name="history-init" if="mining.historyfile.notavailable">
3668 <copy file="${data.file}" tofile="${hist.file}" />
3669 </target>
3670
3671 <!-- Computing bug history -->
3672 <target name="history" if="mining.historyfile.available">
3673 <!-- Merging ${data.file} into ${hist.file} -->
3674 <computeBugHistory home="${findbugs.home}"
3675 withMessages="true"
3676 output="${hist.file}">
3677 <dataFile name="${hist.file}"/>
3678 <dataFile name="${data.file}"/>
3679 </computeBugHistory>
3680
3681 <!-- Compute history into ${hist.summary.file} -->
3682 <mineBugHistory home="${findbugs.home}"
3683 formatDates="true"
3684 noTabs="true"
3685 input="${hist.file}"
3686 output="${hist.summary.file}"/>
3687 </target>
3688
3689 </project>
3690 ]]>
3691 </screen>
3692 </sect1>
3693 </chapter>
3694
3695
3696 <!--
3697 **************************************************************************
3698 License
3699 **************************************************************************
3700 -->
3701
3702 <chapter id="license">
3703 <title>License</title>
3704
3705 <para>
3706 The name FindBugs and the FindBugs logo is trademarked by the University
3707 of Maryland.
3708 FindBugs is free software distributed under the terms of the
3709 <ulink url="http://www.gnu.org/licenses/lgpl.html">Lesser GNU Public License</ulink>.
3710 You should have received a copy of the license in the file <filename>LICENSE.txt</filename>
3711 in the &FindBugs; distribution.
3712 </para>
3713
3714 <para>
3715 You can find the latest version of FindBugs, along with its source code, from the
3716 <ulink url="http://findbugs.sourceforge.net">FindBugs web page</ulink>.
3717 </para>
3718
3719 </chapter>
3720
3721
3722 <!--
3723 **************************************************************************
3724 Acknowledgments
3725 **************************************************************************
3726 -->
3727 <chapter id="acknowledgments">
3728 <title>Acknowledgments</title>
3729
3730 <sect1>
3731 <title>Contributors</title>
3732
3733 <para>&FindBugs; was originally written by Bill Pugh (<email>pugh@cs.umd.edu</email>).
3734 David Hovemeyer (<email>daveho@cs.umd.edu</email>) implemented some of the
3735 detectors, added the Swing GUI, and is a co-maintainer.</para>
3736
3737 <para>Mike Fagan (<email>mfagan@tde.com</email>) contributed the &Ant; build script,
3738 the &Ant; task, and several enhancements and bug fixes to the GUI.</para>
3739
3740 <para>Germano Leichsenring contributed Japanese translations of the bug
3741 summaries.</para>
3742
3743 <para>David Li contributed the Emacs bug report format.</para>
3744
3745 <para>Peter D. Stout contributed recursive detection of Class-Path
3746 attributes in analyzed Jar files, German translations of
3747 text used in the Swing GUI, and other fixes.</para>
3748
3749 <para>Peter Friese wrote the &FindBugs; Eclipse plugin.</para>
3750
3751 <para>Rohan Lloyd contributed several Mac OS X enhancements,
3752 bug detector improvements,
3753 and maintains the Fink package for &FindBugs;.</para>
3754
3755 <para>Hiroshi Okugawa translated the &FindBugs; manual and
3756 more of the bug summaries into Japanese.</para>
3757
3758 <para>Phil Crosby enhanced the Eclipse plugin to add a view
3759 to display the bug details.</para>
3760
3761 <para>Dave Brosius fixed a number of bugs, added user preferences
3762 to the Swing GUI, improved several bug detectors, and
3763 contributed the string concatenation detector.</para>
3764
3765 <para>Thomas Klaeger contributed a number of bug fixes and
3766 bug detector improvements.</para>
3767
3768 <para>Andrei Loskutov made a number of improvements to the
3769 Eclipse plugin.</para>
3770
3771 <para>Brian Goetz contributed a major refactoring of the
3772 visitor classes to improve readability and understandability.</para>
3773
3774 <para> Pete Angstadt fixed several problems in the Swing GUI.</para>
3775
3776 <para>Francis Lalonde provided a task resource file for the
3777 FindBugs Ant task.</para>
3778
3779 <para>Garvin LeClaire contributed support for output in
3780 Xdocs format, for use by Maven.</para>
3781
3782 <para>Holger Stenzhorn contributed improved German translations of items
3783 in the Swing GUI.</para>
3784
3785 <para>Juha Knuutila contributed Finnish translations of items
3786 in the Swing GUI.</para>
3787
3788 <para>Tanel Lebedev contributed Estonian translations of items
3789 in the Swing GUI.</para>
3790
3791 <para>Hanai Shisei (ruimo) contributed full Japanese translations of
3792 bug messages, and text used in the Swing GUI.</para>
3793
3794 <para>David Cotton contributed Fresh translations for bug
3795 messages and for the Swing GUI.</para>
3796
3797 <para>Michael Tamm contributed support for the "errorProperty" attribute
3798 in the Ant task.</para>
3799
3800 <para>Thomas Kuehne improved the German translation of the Swing GUI.</para>
3801
3802 <para>Len Trigg improved source file support for the Emacs output mode.</para>
3803
3804 <para>Greg Bentz provided a fix for the hashcode/equals detector.</para>
3805
3806 <para>K. Hashimoto contributed internationalization fixes and several other
3807 bug fixes.</para>
3808
3809 <para>
3810 Glenn Boysko contributed support for ignoring specified local
3811 variables in the dead local store detector.
3812 </para>
3813
3814 <para>
3815 Jay Dunning contributed a detector to find equality comparisons
3816 of floating-point values, and overhauled the analysis summary
3817 report and its representation in the saved XML format.
3818 </para>
3819
3820 <para>
3821 Olivier Parent contributed updated French translations for bug descriptions and
3822 Swing GUI.
3823 </para>
3824
3825 <para>
3826 Chris Nappin contributed the <filename>plain.xsl</filename>
3827 stylesheet.
3828 </para>
3829
3830 <para>
3831 Etienne Giraudy contributed the <filename>fancy.xsl</filename> and <filename>fancy-hist.xsl</filename>
3832 stylesheets, and made improvements to the <command>-xml:withMessages</command>
3833 option.
3834 </para>
3835
3836 <para>
3837 Takashi Okamoto fixed bugs in the project preferences dialog
3838 in the Eclipse plugin, and contributed to its internationalization and localization.
3839 </para>
3840
3841 <para>Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.</para>
3842
3843 <para>Jeff Knox contributed support for the warningsProperty attribute
3844 in the Ant task.</para>
3845
3846 <para>Peter Hendriks extended the Eclipse plugin preferences,
3847 and fixed a bug related to renaming the Eclipse plugin ID.</para>
3848
3849 <para>Mark McKay contributed an Ant task to launch the findbugs frame.</para>
3850
3851 <para>Dieter von Holten (dvholten) contributed
3852 some German improvements to findbugs_de.properties.</para>
3853
3854
3855 <para>If you have contributed to &FindBugs;, but aren't mentioned above,
3856 please send email to <email>findbugs@cs.umd.edu</email> (and also accept
3857 our humble apologies).</para>
3858
3859 </sect1>
3860
3861 <sect1>
3862 <title>Software Used</title>
3863
3864 <para>&FindBugs; uses several open-source software packages, without which its
3865 development would have been much more difficult.</para>
3866
3867 <sect2>
3868 <title>BCEL</title>
3869 <para>&FindBugs; includes software developed by the Apache Software Foundation
3870 (<ulink url="http://www.apache.org/">http://www.apache.org/</ulink>).
3871 Specifically, it uses the <ulink url="http://jakarta.apache.org/bcel/">Byte Code
3872 Engineering Library</ulink>.</para>
3873 </sect2>
3874
3875 <sect2>
3876 <title>ASM</title>
3877 <para>&FindBugs; uses the <ulink url="http://asm.objectweb.org/">ASM</ulink>
3878 bytecode framework, which is distributed under the following license:</para>
3879
3880 <blockquote>
3881 <para>
3882 Copyright (c) 2000-2005 INRIA, France Telecom
3883 All rights reserved.
3884 </para>
3885
3886 <para>
3887 Redistribution and use in source and binary forms, with or without
3888 modification, are permitted provided that the following conditions
3889 are met:
3890 </para>
3891
3892 <orderedlist numeration="arabic">
3893 <listitem><para>
3894 Redistributions of source code must retain the above copyright
3895 notice, this list of conditions and the following disclaimer.
3896 </para></listitem>
3897 <listitem><para>
3898 Redistributions in binary form must reproduce the above copyright
3899 notice, this list of conditions and the following disclaimer in the
3900 documentation and/or other materials provided with the distribution.
3901 </para></listitem>
3902 <listitem><para>
3903 Neither the name of the copyright holders nor the names of its
3904 contributors may be used to endorse or promote products derived from
3905 this software without specific prior written permission.
3906 </para></listitem>
3907 </orderedlist>
3908
3909 <para>
3910 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3911 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3912 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3913 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
3914 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3915 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3916 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3917 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3918 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3919 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3920 THE POSSIBILITY OF SUCH DAMAGE.
3921 </para>
3922 </blockquote>
3923 </sect2>
3924
3925 <sect2>
3926 <title>DOM4J</title>
3927 <para>&FindBugs; uses <ulink url="http://dom4j.org">DOM4J</ulink>, which is
3928 distributed under the following license:</para>
3929
3930 <blockquote>
3931 <para>
3932 Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
3933 </para>
3934
3935 <para>
3936 Redistribution and use of this software and associated documentation
3937 ("Software"), with or without modification, are permitted provided that
3938 the following conditions are met:
3939 </para>
3940
3941 <orderedlist numeration="arabic">
3942 <listitem><para>
3943 Redistributions of source code must retain copyright statements and
3944 notices. Redistributions must also contain a copy of this document.
3945 </para></listitem>
3946 <listitem><para>
3947 Redistributions in binary form must reproduce the above copyright
3948 notice, this list of conditions and the following disclaimer in the
3949 documentation and/or other materials provided with the distribution.
3950 </para></listitem>
3951 <listitem><para>
3952 The name "DOM4J" must not be used to endorse or promote products
3953 derived from this Software without prior written permission
3954 of MetaStuff, Ltd. For written permission, please contact
3955 <email>dom4j-info@metastuff.com</email>.
3956 </para></listitem>
3957 <listitem><para>
3958 Products derived from this Software may not be called "DOM4J" nor may
3959 "DOM4J" appear in their names without prior written permission of
3960 MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
3961 </para></listitem>
3962 <listitem><para>
3963 Due credit should be given to the DOM4J Project (<ulink url="http://dom4j.org/">http://dom4j.org/</ulink>).
3964 </para></listitem>
3965 </orderedlist>
3966
3967 <para>
3968 THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS''
3969 AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3970 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3971 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS
3972 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3973 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3974 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
3975 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3976 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3977 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3978 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3979 </para>
3980 </blockquote>
3981
3982 </sect2>
3983
3984 </sect1>
3985
3986 </chapter>
3987
3988
3989 </book>
0 <?xml version='1.0'?>
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 version='1.0'
3 xmlns="http://www.w3.org/TR/xhtml1/transitional"
4 exclude-result-prefixes="#default">
5
6 <!-- build.xml will substitute the real path to chunk.xsl here. -->
7 <xsl:import href="/Users/pugh/tools/docbook-xsl-1.76.1/html/chunk.xsl"/>
8
9 <xsl:template name="user.header.content">
10
11 </xsl:template>
12
13 <!-- This causes the stylesheet to put chapters in a single HTML file,
14 rather than putting individual sections into separate files. -->
15 <xsl:variable name="chunk.section.depth">0</xsl:variable>
16
17 <!-- Put the HTML in the "manual" directory. -->
18 <xsl:variable name="base.dir">manual/</xsl:variable>
19
20 <!-- Enumerate sections. -->
21 <xsl:variable name="section.autolabel">1</xsl:variable>
22
23 <!-- Name the HTML files based on the id of the document elements. -->
24 <xsl:variable name="use.id.as.filename">1</xsl:variable>
25
26 <!-- Use graphics in admonitions -->
27 <xsl:variable name="admon.graphics">1</xsl:variable>
28
29 <!-- Admonition graphics are in the same place as the generated HTML. -->
30 <xsl:variable name="admon.graphics.path"></xsl:variable>
31
32 <!-- Just put chapters and sect1s in the TOC. -->
33 <xsl:variable name="toc.section.depth">1</xsl:variable>
34
35 </xsl:stylesheet>
0 <?xml version="1.0" encoding="UTF-8"?>
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://findbugs.googlecode.com/svn/trunk/findbugs/etc/docbook/docbookx.dtd"
2 [
3 <!ENTITY FindBugs "<application>FindBugs</application>">
4 <!ENTITY Ant "<application>Ant</application>">
5 <!ENTITY Saxon "<application>Saxon</application>">
6 <!ENTITY FBHome "<replaceable>$FINDBUGS_HOME</replaceable>">
7 <!ENTITY FBHomeWin "<replaceable>&#x25;FINDBUGS_HOME&#x25;</replaceable>">
8 <!ENTITY nbsp "&#160;">
9 ]>
10 <book lang="ja" id="findbugs-manual">
11
12 <bookinfo>
13 <title>&FindBugs;&trade; マニュアル</title>
14
15 <authorgroup>
16 <author>
17 <firstname>David</firstname>
18 <othername>H.</othername>
19 <surname>Hovemeyer</surname>
20 </author>
21 <author>
22 <firstname>William</firstname>
23 <othername>W.</othername>
24 <surname>Pugh</surname>
25 </author>
26 </authorgroup>
27
28 <copyright>
29 <year>2003</year>
30 <year>2004</year>
31 <year>2005</year>
32 <year>2006</year>
33 <year>2008</year>
34 <holder>University of Maryland</holder>
35 </copyright>
36
37 <legalnotice>
38 <para>このマニュアルは、クリエイティブ・コモンズ表示-非営利-継承に基づく使用許諾がなされています。使用許諾書をご覧になる場合は、 <ulink url="http://creativecommons.org/licenses/by-nc-sa/1.0/deed.ja">http://creativecommons.org/licenses/by-nc-sa/1.0/</ulink> にアクセスするか、クリエイティブ・コモンズ(559 Nathan Abbott Way, Stanford, California 94305, USA)に書簡を送付してください。</para>
39 <para>名称「FindBugs」および FindBugs のロゴは、メリーランド大学の登録商標です。</para>
40 </legalnotice>
41
42 <edition>2.0.3</edition>
43
44 <pubdate>17:16:15 EST, 22 November, 2013</pubdate>
45
46 </bookinfo>
47
48 <!--
49 **************************************************************************
50 Introduction
51 **************************************************************************
52 -->
53
54 <chapter id="introduction">
55 <title>はじめに</title>
56
57 <para>&FindBugs;&trade; は、Java プログラムの中のバグを見つけるプログラムです。このプログラムは、「バグ パターン」の実例を探します。「バグ パターン」とは、エラーとなる可能性の高いコードの事例です。</para>
58
59 <para>この文書は、&FindBugs; バージョン 2.0.3 について説明してます。私たちは、 &FindBugs; に対するフィードバックを心待ちにしています。どうぞ、 <ulink url="http://findbugs.sourceforge.net">&FindBugs; Web ページ</ulink> にアクセスしてください。&FindBugs; についての最新情報、連絡先および &FindBugs; メーリングリストなどのサポート情報を入手することができます。</para>
60
61 <sect1>
62 <title>必要条件</title>
63 <para>&FindBugs; を使用するには、 <ulink url="http://java.sun.com/j2se">Java 2 Standard Edition</ulink>, バージョン 1.5 以降のバージョンと互換性のあるランタイム環境が必要です。&FindBugs; は、プラットフォーム非依存であり、 GNU/Linux 、 Windows 、 MacOS X プラットフォーム上で動作することが知られています。</para>
64
65 <para>&FindBugs; を使用するためには、少なくとも 512 MB のメモリが必要です。巨大なプロジェクトを解析するためには、それより多くのメモリが必要とされることがあります。</para>
66 </sect1>
67
68 </chapter>
69
70 <!--
71 **************************************************************************
72 Installing FindBugs
73 **************************************************************************
74 -->
75
76 <chapter id="installing">
77 <title>&FindBugs;&trade; のインストール</title>
78
79 <para>この章では、 &FindBugs; のインストール方法を説明します。</para>
80
81 <sect1>
82 <title>配布物の展開</title>
83
84 <para>&FindBugs; をインストールする最も簡単な方法は、バイナリ配布物をダウンロードすることです。 バイナリ配布物は、 <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.tar.gz?download">gzipped tar 形式</ulink> および <ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3.zip?download">zip 形式</ulink> がそれぞれ入手可能です。バイナリ配布物をダウンロードしてきたら、それを任意のディレクトリーに展開します。</para>
85
86 <para>gzipped tar 形式配布物の展開方法例:<screen>
87 <prompt>$ </prompt><command>gunzip -c findbugs-2.0.3.tar.gz | tar xvf -</command>
88 </screen>
89 </para>
90
91 <para>zip 形式配布物の展開方法例:<screen>
92 <prompt>C:\Software&gt;</prompt><command>unzip findbugs-2.0.3.zip</command>
93 </screen>
94 </para>
95
96 <para>バイナリ配布物の展開すると、通常は <filename class="directory">findbugs-2.0.3</filename> ディレクトリーが作成されます。例えば、ディレクトリー <filename class="directory">C:\Software</filename> でバイナリ配布物を展開すると、ディレクトリー <filename class="directory">C:\Software\findbugs-2.0.3</filename> に &FindBugs; は展開されます。このディレクトリーが &FindBugs; のホームディレクトリーになります。このマニュアルでは、このホームディレクトリーを &FBHome; (Windowsでは &FBHomeWin;) を用いて参照します。</para>
97 </sect1>
98
99 </chapter>
100
101 <!--
102 **************************************************************************
103 Compiling FindBugs from Source
104 **************************************************************************
105 -->
106
107 <chapter id="building">
108 <title>&FindBugs;&trade; のソールからのビルド</title>
109
110 <para>この章では、 &FindBugs; をソースコードからビルドする方法を説明します。&FindBugs; を修正することに興味がないのであれば、 <link linkend="running">次の章</link> に進んでください。</para>
111
112 <sect1>
113 <title>前提条件</title>
114
115 <para>ソースから &FindBugs; をコンパイルするためには、以下のものが必要です。<itemizedlist>
116 <listitem>
117 <para><ulink url="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download">&FindBugs; のソース配布物</ulink>
118 </para>
119 </listitem>
120 <listitem>
121 <para>
122 <ulink url="http://java.sun.com/j2se/">JDK 1.5.0 ベータ またはそれ以降</ulink>
123 </para>
124 </listitem>
125 <listitem>
126 <para>
127 <ulink url="http://ant.apache.org/">Apache &Ant;</ulink>, バージョン 1.6.3 またはそれ以降</para>
128 </listitem>
129 </itemizedlist>
130 </para>
131
132 <warning>
133 <para>Redhat Linux システムの <filename>/usr/bin/ant</filename> に同梱されている &Ant; のバージョンでは、 &FindBugs; のコンパイルは<emphasis>うまくできません</emphasis>。<ulink url="http://ant.apache.org/">&Ant; web サイト</ulink>からバイナリ配布物をダウンロードしてインストールすることを推奨します。&Ant; を実行する場合は、 環境変数 <replaceable>JAVA_HOME</replaceable> が JDK 1.5 (またはそれ以降)をインストールしたディレクトリーを指していることを確認してください。</para>
134 </warning>
135
136 <para>体裁の整った &FindBugs; のドキュメントを生成したい場合は、以下のソフトウェアも必要となります:<itemizedlist>
137 <listitem>
138 <para><ulink url="http://docbook.sourceforge.net/projects/xsl/index.html">DocBook XSL スタイルシート</ulink>。&FindBugs; のマニュアルを HTML に変換するのに必要です。</para>
139 </listitem>
140 <listitem>
141 <para><ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT プロセッサー</ulink>。(同様に、 &FindBugs; のマニュアルを HTML に変換するのに必要です。)</para>
142 </listitem>
143 <!--
144 <listitem>
145 <para>
146 </para>
147 </listitem>
148 -->
149 </itemizedlist>
150 </para>
151
152 </sect1>
153
154 <sect1>
155 <title>ソース配布物の展開</title>
156 <para>ソース配布物をダウンロードした後に、それを作業用ディレクトリーに展開する必要があります。通常は、次のようなコマンドで展開を行います:<screen>
157 <prompt>$ </prompt><command>unzip findbugs-2.0.3-source.zip</command>
158 </screen>
159
160 </para>
161 </sect1>
162
163 <sect1>
164 <title><filename>local.properties</filename> の修正</title>
165 <para>FindBugs のドキュメントをビルドするためには、 <filename>local.properties</filename> ファイルを修正する必要があります。このファイルは、 &FindBugs; をビルドする際に <ulink url="http://ant.apache.org/">&Ant;</ulink> <filename>build.xml</filename> ファイルが参照します。FindBugs のドキュメントをビルドしない場合は、このファイルは無視してもかまいません。</para>
166
167 <para><filename>local.properties</filename> での定義は、 <filename>build.properties</filename> ファイルでの定義に優先します。<filename>build.properties</filename> は次のような内容です:<programlisting>
168 <![CDATA[
169 # User Configuration:
170 # This section must be modified to reflect your system.
171
172 local.software.home =/export/home/daveho/linux
173
174 # Set this to the directory containing the DocBook Modular XSL Stylesheets
175 # from http://docbook.sourceforge.net/projects/xsl/
176
177 xsl.stylesheet.home =${local.software.home}/docbook/docbook-xsl-1.71.1
178
179 # Set this to the directory where Saxon (http://saxon.sourceforge.net/)
180 # is installed.
181
182 saxon.home =${local.software.home}/java/saxon-6.5.5
183 ]]>
184 </programlisting>
185 </para>
186
187 <para><varname>xsl.stylesheet.home</varname> プロパティーには、<ulink url="http://docbook.sourceforge.net/projects/xsl/">DocBook Modular XSL スタイルシート</ulink>がインストールしてあるディレクトリーの絶対パスを指定します。&FindBugs; ドキュメントを生成しようと考えている場合にのみ、このプロパティーを指定する必要があります。</para>
188
189 <para><varname>saxon.home</varname> プロパティーには、<ulink url="http://saxon.sourceforge.net/">&Saxon; XSLT プロセッサー</ulink>がインストールしてあるディレクトリーの絶対パスを指定します。&FindBugs; ドキュメントを生成しようと考えている場合にのみ、このプロパティーを指定する必要があります。</para>
190
191 </sect1>
192
193 <sect1>
194 <title>&Ant; の実行</title>
195
196 <para>ソース配布物の展開、 &Ant; のインストール、<filename>build.properties</filename>(<filename>local.properties</filename>) の修正 (これは任意) およびツール (&Saxon; など)の環境構築ができれば、 &FindBugs; をビルドするための準備は完了です。&Ant; の起動する方法は、単にコマンドを実行するだけです。<screen>
197 <prompt>$ </prompt><command>ant <replaceable>target</replaceable></command>
198 </screen><replaceable>target</replaceable> には以下のいずれかを指定します: <variablelist> <varlistentry> <term><command>build</command></term>
199 <listitem>
200 <para>このターゲットは、 &FindBugs; のコードをコンパイルします。これは、デフォルトのターゲットです。</para>
201 </listitem>
202 </varlistentry>
203
204 <varlistentry>
205 <term><command>docs</command></term>
206 <listitem>
207 <para>このターゲットは、ドキュメントの整形を行います(また、副作用としていくつかのソースのコンパイルも行います。)</para>
208 </listitem>
209 </varlistentry>
210
211 <varlistentry>
212 <term><command>runjunit</command></term>
213 <listitem>
214 <para>このターゲットは、コンパイルを行い &FindBugs; が持っている JUnit テストを実行します。ユニットテストが失敗した場合は、エラーメッセージが表示されます。</para>
215 </listitem>
216 </varlistentry>
217
218 <varlistentry>
219 <term><command>bindist</command></term>
220 <listitem>
221 <para>&FindBugs; のバイナリ配布物を構築します。このターゲットは、 <filename>.zip</filename> および <filename>.tar.gz</filename> のアーカイブをそれぞれ作成します。</para>
222 </listitem>
223 </varlistentry>
224 </variablelist>
225 </para>
226
227 <para>&Ant; コマンドの実行後、次のような出力が表示されるはずです。 (この前に &Ant; が実行したタスクに関するメッセージもいくらか出力されます。):<screen>
228 <computeroutput>
229 BUILD SUCCESSFUL
230 Total time: 17 seconds
231 </computeroutput>
232 </screen>
233 </para>
234
235 </sect1>
236
237 <sect1>
238 <title>ソースディレクトリーからの &FindBugs;&trade; の実行</title>
239 <para><command>build</command> ターゲットの実行が終了すると、バイナリ配布物と同様の状態が作業ディレクトリーに構築されるように &FindBugs; の&Ant; ビルドスクリプトは記述されています。したがって、<xref linkend="running"/> の &FindBugs; の実行に関する情報はソース配布物の場合にも応用できます。</para>
240 </sect1>
241
242 </chapter>
243
244
245 <!--
246 **************************************************************************
247 Running FindBugs
248 **************************************************************************
249 -->
250
251 <chapter id="running">
252 <title>&FindBugs;&trade; の実行</title>
253
254 <para>&FindBugs; には2つのユーザーインタフェースがあります。すなわち、グラフィカルユーザーインタフェース (GUI) および コマンドラインインタフェースです。この章では、それぞれのインタフェースの実行方法について説明します。</para>
255
256 <warning>
257 <para>この章は、現在書き直し中です。書き直しはまだ完了していません。</para>
258 </warning>
259
260 <!--
261 <sect1>
262 <title>Executing the &FindBugs;&trade; GUI</title>
263 </sect1>
264 -->
265
266 <sect1>
267 <title>クイック・スタート</title>
268 <para>Windows システムで &FindBugs; を起動する場合は、 <filename>&FBHomeWin;\lib\findbugs.jar</filename> ファイルをダブルクリックしてください。 &FindBugs; GUI が起動します。</para>
269
270 <para>Unix 、 Linux または Mac OS X システムの場合は、<filename>&FBHome;/bin/findbugs</filename> スクリプトを実行するか、以下のコマンドを実行します。<screen>
271 <command>java -jar &FBHome;/lib/findbugs.jar</command></screen>これで、 &FindBugs; GUI が起動します。</para>
272
273 <para>GUI の使用方法については、 <xref linkend="gui"/> を参照してください。</para>
274 </sect1>
275
276 <sect1>
277
278 <title>&FindBugs; の起動</title>
279
280 <para>このセクションでは、 &FindBugs; の起動方法を説明します。&FindBugs; を起動するには2つの方法があります。すなわち、直接起動する方法、および、ラップしているスクリプトを使用する方法です。</para>
281
282
283 <sect2 id="directInvocation">
284 <title>&FindBugs; の直接起動</title>
285
286 <para>最初に述べる &FindBugs; の起動方法は、 <filename>&FBHome;/lib/findbugs.jar</filename> を直接実行する方法です。JVM (<command>java</command>) 実行プログラムの <command>-jar</command> コマンドラインスイッチを使用します。(&FindBugs;のバージョンが 1.3.5 より前の場合は、ラップしているスクリプトを使用する必要があります。)</para>
287
288 <para>&FindBugs; を直接起動するための、一般的な構文は以下のようになります。<screen>
289 <command>java <replaceable>[JVM 引数]</replaceable> -jar &FBHome;/lib/findbugs.jar <replaceable>オプション…</replaceable></command>
290 </screen>
291 </para>
292
293 <!--
294 <para>
295 By default, executing <filename>findbugs.jar</filename> runs the
296 &FindBugs; graphical user interface (GUI). On windows systems,
297 you can double-click on <filename>findbugs.jar</filename> to launch
298 the GUI. From a command line, the command
299 <screen>
300 java -jar <replaceable>&FBHome;</replaceable>/lib/findbugs.jar</screen>
301 will launch the GUI.
302 </para>
303 -->
304
305 <sect3 id="chooseUI">
306 <title> ユーザーインタフェースの選択</title>
307
308 <para>1 番目のコマンドラインオプションは、起動する &FindBugs; ユーザーインタフェースを選択するためのものです。指定可能な値は次の通りです:</para>
309 <itemizedlist>
310 <listitem>
311 <para>
312 <command>-gui</command>: グラフィカルユーザーインタフェース (GUI) を起動します。</para>
313 </listitem>
314
315 <listitem>
316 <para>
317 <command>-textui</command>: コマンドラインインタフェースを起動します。</para>
318 </listitem>
319
320 <listitem>
321 <para>
322 <command>-version</command>: &FindBugs; のバージョン番号を表示します。</para>
323 </listitem>
324
325 <listitem>
326 <para>
327 <command>-help</command>: &FindBugs; コマンドラインインタフェースのヘルプ情報を表示します。</para>
328 </listitem>
329
330 <listitem>
331 <para>
332 <command>-gui1</command>: 最初に作成された &FindBugs; グラフィカルユーザーインタフェース(すでに廃止されサポートされていない)を起動します。</para>
333 </listitem>
334 </itemizedlist>
335
336 </sect3>
337
338 <sect3 id="jvmArgs">
339 <title>Java 仮想マシン (JVM) 引数</title>
340
341 <para>&FindBugs; を起動する際に有用な Java 仮想マシン 引数をいくつか紹介します。</para>
342
343 <variablelist>
344 <varlistentry>
345 <term><command>-Xmx<replaceable>NN</replaceable>m</command></term>
346 <listitem>
347 <para>Java ヒープサイズの最大値を <replaceable>NN</replaceable> メガバイトに設定します。&FindBugs; は一般的に大容量のメモリサイズを必要とします。大きなプロジェクトでは、 1500 メガバイトを使用することも珍しくありません。</para>
348 </listitem>
349 </varlistentry>
350
351 <varlistentry>
352 <term><command>-D<replaceable>name</replaceable>=<replaceable>value</replaceable></command></term>
353 <listitem>
354 <para>Java システムプロパティーを設定します。例えば、引数 <command>-Duser.language=ja</command> を使用すると GUI 文言が日本語で表示されます。</para>
355 </listitem>
356 </varlistentry>
357
358 <!--
359 <varlistentry>
360 <term></term>
361 <listitem>
362 <para>
363 </para>
364 </listitem>
365 </varlistentry>
366 -->
367 </variablelist>
368 </sect3>
369
370 </sect2>
371
372 <sect2 id="wrapperScript">
373 <title>ラップしているスクリプトを使用した &FindBugs; の起動</title>
374
375 <para>&FindBugs; を起動するもうひとつの方法は、ラップしているスクリプトを使用する方法です。</para>
376
377 <para>Unix 系のシステムにおいては、次のようなコマンドでラップしているスクリプトを起動します :<screen>
378 <prompt>$ </prompt><command>&FBHome;/bin/findbugs <replaceable>オプション…</replaceable></command>
379 </screen>
380 </para>
381
382 <para>Windows システムにおいては、ラップしているスクリプトを起動するコマンドは次のようになります。<screen>
383 <prompt>C:\My Directory&gt;</prompt><command>&FBHomeWin;\bin\findbugs.bat <replaceable>オプション…</replaceable></command>
384 </screen>
385 </para>
386
387 <para>Unix 系システム および Windows システムのどちらにおいても、ディレクトリー <filename><replaceable>$FINDBUGS_HOME</replaceable>/bin</filename> を環境変数 <filename>PATH</filename> に追加するだけで、 <command>findbugs</command> コマンドを使用して FindBugs を起動することができます。</para>
388
389 <sect3 id="wrapperOptions">
390 <title>ラップしているスクリプトのコマンドラインオプション</title>
391 <para>&FindBugs; のラップしているスクリプトは、次のようなコマンドラインオプションをサポートしています。これらのコマンドラインオプションは &FindBugs; プログラム 自体が操作するのでは<emphasis>なく</emphasis>、どちらかといえば、ラップしているスクリプトの方が処理を行います。</para>
392 <variablelist>
393 <varlistentry>
394 <term><command>-jvmArgs <replaceable>引数</replaceable></command></term>
395 <listitem>
396 <para>JVM に受け渡される引数を指定します。例えば、次のような JVM プロパティが設定できます:<screen>
397 <prompt>$ </prompt><command>findbugs -textui -jvmArgs &quot;-Duser.language=ja&quot; <replaceable>myApp.jar</replaceable></command>
398 </screen>
399 </para>
400 </listitem>
401 </varlistentry>
402
403 <varlistentry>
404 <term><command>-javahome <replaceable>ディレクトリー</replaceable></command></term>
405 <listitem>
406 <para>&FindBugs; の実行に使用する JRE (Java ランタイム環境) がインストールされているディレクトリーを指定します。</para>
407 </listitem>
408 </varlistentry>
409
410 <varlistentry>
411 <term><command>-maxHeap <replaceable>サイズ</replaceable></command></term>
412 <listitem>
413 <para>Java ヒープサイズの最大値をメガバイト単位で指定します。デフォルトは、 256 です。巨大なプログラムやライブラリを分析するには、もっと大きなメモリー容量が必要になる可能性があります。</para>
414 </listitem>
415 </varlistentry>
416
417 <varlistentry>
418 <term><command>-debug</command></term>
419 <listitem>
420 <para>ディテクタ実行およびクラス分析のトレース情報が標準出力に出力されます。分析が予期せず失敗した際の、トラブルシューティングに有用です。</para>
421 </listitem>
422 </varlistentry>
423
424 <varlistentry>
425 <term><command>-property</command> <replaceable>name=value</replaceable></term>
426 <listitem>
427 <para>このオプションを使用してシステムプロパティーを設定することができます。 &FindBugs; はシステムプロパティーを使用して分析特性の設定を行います。<xref linkend="analysisprops"/> を参照してください。このオプションを複数指定して、複数のシステムプロパティを設定することが可能です。注: Windows の多くのバージョンでは、 <replaceable>name=value</replaceable> 文字列を引用符で囲む必要があります。</para>
428 </listitem>
429 </varlistentry>
430
431 </variablelist>
432
433 </sect3>
434
435 </sect2>
436
437 </sect1>
438
439 <sect1 id="commandLineOptions">
440 <title>コマンドラインオプション</title>
441
442 <!--
443 <para>
444
445 There are two ways to invoke &FindBugs;. The first invokes the the Graphical User Interface (GUI):
446
447 <screen>
448 <prompt>$ </prompt><command>findbugs <replaceable>[standard options]</replaceable> <replaceable>[GUI options]</replaceable></command>
449 </screen>
450
451 The second invokes the Command Line Interface (Text UI):
452
453 <screen>
454 <prompt>$ </prompt><command>findbugs -textui <replaceable>[standard options]</replaceable> <replaceable>[Text UI options]</replaceable></command>
455 </screen>
456 </para>
457 -->
458
459 <para>このセクションでは、 &FindBugs; がサポートするコマンドラインオプションについて説明します。ここで示すコマンドラインオプションは、 &FindBugs; 直接起動、または、ラップしているスクリプトによる起動で使用できます。</para>
460
461 <sect2>
462 <title>共通のコマンドラインオプション</title>
463
464 <para>ここで示すオプションは、 GUI および コマンドラインインタフェースの両方で使用できます。</para>
465
466 <variablelist>
467
468 <varlistentry>
469 <term><command>-effort:min</command></term>
470 <listitem>
471 <para>このオプションを指定すると、精度を上げるために大量のメモリーを消費する分析が無効になります。&FindBugs; の実行時にメモリー不足になったり、分析を完了するまでに異常に長い時間がかかる場合に試してみてください。</para>
472 </listitem>
473 </varlistentry>
474
475
476 <varlistentry>
477 <term><command>-effort:max</command></term>
478 <listitem>
479 <para>精度が高く、より多くのバグを検出する分析を有効にします。ただし、多くのメモリー容量を必要とし、また、完了までの時間が多くかかる可能性があります。</para>
480 </listitem>
481 </varlistentry>
482
483 <varlistentry>
484 <term><command>-project</command> <replaceable>project</replaceable></term>
485 <listitem>
486 <para>分析するプロジェクトを指定します。指定するプロジェクトファイルには、 GUI を使って作成したものを使用してください。ファイルの拡張子は、一般的には <filename>.fb</filename> または <filename>.fbp</filename> です。</para>
487 </listitem>
488 </varlistentry>
489
490 <!--
491 <varlistentry>
492 <term><command></command></term>
493 <listitem>
494 <para>
495
496 </para>
497 </listitem>
498 </varlistentry>
499 -->
500
501 </variablelist>
502
503 </sect2>
504
505 <sect2>
506 <title>GUI オプション</title>
507
508 <para>ここで示すオプションは、グラフィカルユーザーインタフェースでのみ使用できます。<variablelist> <varlistentry> <term><command>-look:</command><replaceable>plastic|gtk|native</replaceable></term>
509 <listitem>
510 <para>Swing のルック・アンド・フィールを設定します。</para>
511 </listitem>
512 </varlistentry>
513
514 </variablelist>
515 </para>
516 </sect2>
517
518 <sect2>
519 <title>テキストユーザーインタフェースオプション</title>
520
521 <para>ここで示すオプションは、テキストユーザーインタフェースでのみ使用できます。</para>
522
523 <variablelist>
524 <varlistentry>
525 <term><command>-sortByClass</command></term>
526 <listitem>
527 <para>報告されるバグ検索結果をクラス名でソートします。</para>
528 </listitem>
529 </varlistentry>
530
531 <varlistentry>
532 <term><command>-include</command> <replaceable>filterFile.xml</replaceable></term>
533 <listitem>
534 <para><replaceable>filterFile.xml</replaceable> で指定したフィルターに一致したバグ検索結果のみ報告されます。<xref linkend="filter"/> を参照してください。</para>
535 </listitem>
536 </varlistentry>
537
538 <varlistentry>
539 <term><command>-exclude</command> <replaceable>filterFile.xml</replaceable></term>
540 <listitem>
541 <para><replaceable>filterFile.xml</replaceable> で指定したフィルターに一致したバグ検索結果は報告されません。<xref linkend="filter"/> を参照してください。</para>
542 </listitem>
543 </varlistentry>
544
545 <varlistentry>
546 <term><command>-onlyAnalyze</command> <replaceable>com.foobar.MyClass,com.foobar.mypkg.*</replaceable></term>
547 <listitem>
548 <para>コンマ区切りで指定したクラスおよびパッケージのみに限定して、バグ検出の分析を行うようにします。フィルターと違って、このオプションを使うと一致しないクラスおよびパッケージに対する分析の実行を回避することができます。大きなプロジェクトにおいて、このオプションを活用すると分析にかかる時間を大きく削減することができる可能性があります。(しかしながら、アプリケーションの全体で実行していないために不正確な結果を出してしまうディテクタがある可能性もあります。) クラスはパッケージも含んだ完全な名前を指定する必要があります。また、パッケージは、 Java の <literal>import</literal> 文でパッケージ下のすべてのクラスをインポートするときと同じ方法で指定します。 (すなわち、パッケージの完全な名前に <literal>.*</literal> を付け加えた形です。)<literal>.*</literal> の代わりに <literal>.-</literal> を指定すると、サブパッケージも含めてすべてが分析されます。</para>
549 </listitem>
550 </varlistentry>
551
552 <varlistentry>
553 <term><command>-low</command></term>
554 <listitem>
555 <para>すべてのバグが報告されます。</para>
556 </listitem>
557 </varlistentry>
558
559 <varlistentry>
560 <term><command>-medium</command></term>
561 <listitem>
562 <para>優先度 (中) および優先度 (高) のバグが報告されます。これは、デフォルトの設定値です。</para>
563 </listitem>
564 </varlistentry>
565
566 <varlistentry>
567 <term><command>-high</command></term>
568 <listitem>
569 <para>優先度 (高) のバグのみが報告されます。</para>
570 </listitem>
571 </varlistentry>
572
573 <varlistentry>
574 <term><command>-relaxed</command></term>
575 <listitem>
576 <para>手抜き報告モードです。このオプションを指定すると、多くのディテクタにおいて 誤検出を回避するためのヒューリスティック機能が抑止されます。</para>
577 </listitem>
578 </varlistentry>
579
580 <varlistentry>
581 <term><command>-xml</command></term>
582 <listitem>
583 <para>バグ報告が XML で作成されます。作成された XML データは 、後で GUI で見ることができます。このオプションは <command>-xml:withMessages</command> と指定することもできます。こうすると 出力 XML には 各バグに関して人間に読むことができるメッセージが含まれるようになります。このオプションで作成された XML ファイルは 報告書に変換するのが簡単です。</para>
584 </listitem>
585 </varlistentry>
586
587 <varlistentry>
588 <term><command>-html</command></term>
589 <listitem>
590 <para>HTML 出力が生成されます。デフォルトでは &FindBugs; は <filename>default.xsl</filename> <ulink url="http://www.w3.org/TR/xslt">XSLT</ulink> スタイルシートを使用して HTML 出力を生成します: このファイルは、 <filename>findbugs.jar</filename> の中、または、 &FindBugs; のソース配布物もしくはバイナリ配布物の中にあります。このオプションには、次のようなバリエーションも存在します。すなわち、 <command>-html:plain.xsl</command> 、 <command>-html:fancy.xsl</command> および <command>-html:fancy-hist.xsl</command> です。<filename>plain.xsl</filename> スタイルシートは Javascript や DOM を利用しません。したがって、古いWeb ブラウザ使用時や印刷時にも比較的うまく表示されるでしょう。<filename>fancy.xsl</filename> スタイルシートは DOM と Javascript を利用してナビゲーションを行います。また、ビジュアル表示に CSS を使用します。<command>fancy-hist.xsl</command> は <command>fancy.xsl</command> スタイルシートを更に進化させたものです。DOM や Javascript をふんだんに駆使して、バグの一覧を動的にフィルタリングします。</para>
591
592 <para>ユーザー自身の XSLT スタイルシートを用いて HTML への変換を行いたい場合は、 <command>-html:<replaceable>myStylesheet.xsl</replaceable></command> のように指定してください。ここで、 <replaceable>myStylesheet.xsl</replaceable> はユーザーが使用したいスタイルシートのファイル名です。</para>
593 </listitem>
594 </varlistentry>
595
596 <varlistentry>
597 <term><command>-emacs</command></term>
598 <listitem>
599 <para>バグ報告が Emacs 形式で作成されます。</para>
600 </listitem>
601 </varlistentry>
602
603 <varlistentry>
604 <term><command>-xdocs</command></term>
605 <listitem>
606 <para>バグ報告が xdoc XML 形式で作成されます。Apache Mavenで使用できます。</para>
607 </listitem>
608 </varlistentry>
609
610 <varlistentry>
611 <term><command>-output</command> <replaceable>ファイル名</replaceable></term>
612 <listitem>
613 <para>指定したファイルに出力結果が作成されます。</para>
614 </listitem>
615 </varlistentry>
616
617 <varlistentry>
618 <term><command>-outputFile</command> <replaceable>ファイル名</replaceable></term>
619 <listitem>
620 <para>この引数は、使用すべきではありません。代わりに、 <command>-output</command> を使用してください。</para>
621 </listitem>
622 </varlistentry>
623
624 <varlistentry>
625 <term><command>-nested</command><replaceable>[:true|false]</replaceable></term>
626 <listitem>
627 <para>このオプションは、ファイルやディレクトリーの中で入れ子になった jar および zip ファイルを分析するかどうかを指定します。デフォルトでは、入れ子になった jar および zip ファイルも分析します。入れ子になった jar および zip ファイルの分析するを無効にする場合は、 <command>-nested:false</command> をコマンドライン引数に追加してください。</para>
628 </listitem>
629 </varlistentry>
630
631 <varlistentry>
632 <term><command>-auxclasspath</command> <replaceable>クラスパス</replaceable></term>
633 <listitem>
634 <para>分析時に使用する補助クラスパスを設定します。分析するプログラムで使用するjarファイルやクラスディレクトリーをすべて指定してください。補助クラスパスに指定したクラスは分析の対象にはなりません。</para>
635 </listitem>
636 </varlistentry>
637
638 <!--
639 <varlistentry>
640 <term><command></command> <replaceable></replaceable></term>
641 <listitem>
642 <para>
643 </para>
644 </listitem>
645 </varlistentry>
646 -->
647
648 </variablelist>
649
650 </sect2>
651 </sect1>
652
653
654 </chapter>
655
656 <chapter id="gui">
657 <title>&FindBugs; GUI の使用方法</title>
658
659 <para>この章では、&FindBugs; グラフィカルユーザーインタフェース (GUI) の使用方法を説明します。</para>
660
661 <sect1>
662 <title>プロジェクトの作成</title>
663 <para><command>findbugs</command> コマンドで &FindBugs; を起動してから、メニューで <menuchoice><guimenu>File</guimenu><guimenuitem>New Project</guimenuitem></menuchoice> を選択してください。そうすると、次のようなダイアログが表示されます:<mediaobject>
664 <imageobject>
665 <imagedata fileref="project-dialog.png"/>
666 </imageobject>
667 </mediaobject>
668 </para>
669
670 <para>「Class archives and directories to analyze」テキストフィールドの横にある 「Add」ボタンを押すと、バグを分析する java クラスを含んでいる Java アーカイブファイル (zip, jar, ear, or war file) を選択して指定できます。複数の アーカイブ/ディレクトリーを追加することが可能です。</para>
671
672 <para>また、分析を行う Java アーカイブのソースコードを含んだソースディレクトリーを指定することもできます。そうすると、バグの可能性があるソースコードの場所が、&FindBugs; 上でハイライトして表示されます。ソースディレクトリーは、Java パッケージ階層のルートディレクトリーを指定する必要があります。例えば、ユーザのアプリケーションが <varname>org.foobar.myapp</varname> パッケージの中にある場合は、 <filename class="directory">org</filename> ディレクトリーの親ディレクトリーをソースディレクトリーリストに指定する必要があります。</para>
673
674 <para>もうひとつ、任意指定の手順があります。それは、補助用の Jar ファイルおよびディレクトリーを 「Auxiliary classpath locations」のエントリーに追加することです。分析するアーカイブ/ディレクトリーにも標準の実行時クラスパスにも含まれていないクラスを、分析するアーカイブ/ディレクトリーが参照している場合は、この項目を設定した方がいいでしょう。クラス階層に関する情報を使用するバグディテクタが、 &FindBugs; にはいくつかあります。したがって、&FindBugs; が分析を行うクラスの完全なクラス階層を参照できれば、より正確な分析結果を取得することができます。</para>
675
676 </sect1>
677
678 <sect1>
679 <title>分析の実行</title>
680 <para>アーカイブ、ディレクトリーおよびソースディレクトリーの指定ができれば、「Finish」ボタンを押して Jar ファイルに含まれるクラスに対する分析を実行します。巨大なプロジェクトを古いコンピュータ上で実行すると、かなりの時間(数十分)がかかることに注意してください。大容量メモリである最近のコンピュータなら、大きなプログラムであっても数分程度で分析できます。</para>
681 </sect1>
682
683 <sect1>
684 <title>結果の閲覧</title>
685
686 <para>分析が完了すると、次のような画面が表示されます :<mediaobject>
687 <imageobject>
688 <imagedata fileref="example-details.png"/>
689 </imageobject>
690 </mediaobject>
691 </para>
692
693 <para>左上のペインにはバグ階層ツリーが表示されます。これは、分析でみつかったバグの検索結果が階層的に表示されたものです。</para>
694
695 <para>上部のペインでバグ検索結果を選択すると、下部の「Details」ペインにバグの詳細説明が表示されます。更に、ソースがみつかれば、右上のソースコードペインにバグの出現箇所に該当するソースコードが表示されます。上図の例で表示されているバグは、ストリームオブジェクトがクローズされていないというものです。ソースコード・ウィンドウにおいて当該ストリームオブジェクトを生成している行がハイライトされています。</para>
696
697 <para>バグの検索結果に対してテキストで注釈を入れることができます。階層ツリー図のすぐ下にあるテキストボックスに注釈を入力してください。記録しておきたい情報を何でも自由に入力することができます。バグ結果ファイルの保存および読み込みを行ったときに、注釈も保存されます。</para>
698
699 </sect1>
700
701 <sect1>
702 <title>保存と読み込み</title>
703
704 <para>メニュー項目から <menuchoice><guimenu>File</guimenu><guimenuitem>Save as...</guimenuitem></menuchoice> を選択すると、ユーザーの作業結果を保存することができます。「Save as...」ダイアログにあるドロップダウン・リストの中から「FindBugs analysis results (.xml)」を選択ことで、ユーザーが指定した jar ファイルリストやバグ検索結果などの作業結果を保存することができます。また、jar ファイルリストのみを保存する選択肢 (「FindBugs project file (.fbp)」) やバグ検索結果のみを保存する選択肢 (「FindBugs analysis file (.fba)」) もあります。保存したファイルは、メニュー項目から <menuchoice><guimenu>File</guimenu><guimenuitem>Open...</guimenuitem></menuchoice> を選択することで、読み込むことができます。</para>
705
706 </sect1>
707
708 <!--
709 <sect1 id="textui">
710 <title>Using the &FindBugs;&trade; Command Line Interface</title>
711
712 <para>
713 The &FindBugs; Command Line Interface (or Text UI) can be used to
714 analyze an application for bugs non-interactively. Each bug instance will be
715 reported on a single line. All output is written to the standard output file descriptor.
716 <xref linkend="filter" /> explains how bug reports may be filtered in order
717 to get only the output you're interested in.
718 </para>
719
720 <para>
721 See <xref linkend="commandLineOptions" /> for a description of how to invoke the
722 Command Line Interface.
723 </para>
724 </sect1>
725 -->
726
727 </chapter>
728
729 <!--
730 **************************************************************************
731 Using the FindBugs Ant task
732 **************************************************************************
733 -->
734
735 <chapter id="anttask">
736 <title>&FindBugs;&trade; &Ant; タスクの使用方法</title>
737
738 <para>この章では、 &FindBugs; を <ulink url="http://ant.apache.org/">&Ant;</ulink> のビルドスクリプトに組み入れる方法について説明します。 <ulink url="http://ant.apache.org/">&Ant;</ulink> は、ビルドや配備を行うことができる Java でよく使用されるツールです。&FindBugs; &Ant; タスクを使用すると、 ビルドスクリプトを作成して機械的に &FindBugs; による Java コードの分析を実行することができます。</para>
739
740 <para>この &Ant; タスクは、 Mike Fagan 氏の多大な貢献によるものです。</para>
741
742 <sect1>
743 <title>&Ant; タスクのインストール</title>
744
745 <para>&Ant; タスクのインストールは、 <filename>&FBHome;/lib/findbugs-ant.jar</filename> を &Ant; インストールディレクトリーの<filename>lib</filename> サブディレクトリーにコピーするだけです。<note>
746 <para>使用する &Ant; タスクと &FindBugs; 本体は、同梱されていた同じバージョンのものを使用することを強く推奨します。別のバージョンの &FindBugs; に含まれていた &Ant; タスク Jar ファイルでの動作は保証しません。</para>
747 </note>
748 </para>
749
750 </sect1>
751
752 <sect1>
753 <title>build.xml の書き方</title>
754
755 <para>&FindBugs; を <filename>build.xml</filename> (&Ant; ビルドスクリプト) に組み入れるためにはまず、タスク定義を記述する必要があります。タスク定義は次のように記述します。:<screen>
756 &lt;taskdef name=&quot;findbugs&quot; classname=&quot;edu.umd.cs.findbugs.anttask.FindBugsTask&quot;/&gt;
757 </screen>タスク定義は、 <literal>findbugs</literal> 要素を <filename>build.xml</filename> 上に記述したとき、そのタスクの実行に使用されるクラスを指定します。</para>
758
759 <para>タスク定義の記述をすれば、<literal>findbugs</literal> タスクを使ってターゲットを定義できます。次に示すのは、 Apache <ulink url="http://jakarta.apache.org/bcel/">BCEL</ulink> ライブラリーを分析する場合を想定した <filename>build.xml</filename> の記述例です。<screen>
760 &lt;property name=&quot;findbugs.home&quot; value=&quot;/export/home/daveho/work/findbugs&quot; /&gt;
761
762 &lt;target name=&quot;findbugs&quot; depends=&quot;jar&quot;&gt;
763 &lt;findbugs home=&quot;${findbugs.home}&quot;
764 output=&quot;xml&quot;
765 outputFile=&quot;bcel-fb.xml&quot; &gt;
766 &lt;auxClasspath path=&quot;${basedir}/lib/Regex.jar&quot; /&gt;
767 &lt;sourcePath path=&quot;${basedir}/src/java&quot; /&gt;
768 &lt;class location=&quot;${basedir}/bin/bcel.jar&quot; /&gt;
769 &lt;/findbugs&gt;
770 &lt;/target&gt;
771 </screen><literal>findbugs</literal> 要素には、 <literal>home</literal> 属性が必須です。 &FindBugs; のインストールディレクトリーすなわち &FBHome; の値を設定します。<xref linkend="installing"/> を参照してください。</para>
772
773 <para>このターゲットは <filename>bcel.jar</filename> に対して &FindBugs; を実行します。この Jar ファイルは、 BCEL ビルドスクリプトによって作成されるものです。(上記のターゲットが「jar」ターゲットに依存している (depends) と設定することにより、 &FindBugs; が実行される前に当該ライブラリーが完全にコンパイルされていることを保証しています。) &FindBugs; の出力は、 XML 形式で <filename>bcel-fb.xml</filename> ファイルに保存されます。補助 Jar ファイル <filename>Regex.jar</filename> を aux classpath に記述しています。なぜなら、当該 Jar ファイルが BCEL メイン・ライブラリーから参照されるからです。source path を指定することで、保存されるバグデータに BCEL ソースコードへの正確な参照が記述されます。</para>
774 </sect1>
775
776 <sect1>
777 <title>タスクの実行</title>
778
779 <para>コマンドラインから &Ant; を起動する例を次に示します。前述の <literal>findbugs</literal> ターゲットを使用しています。<screen>
780 <prompt>[daveho@noir]$</prompt> <command>ant findbugs</command>
781 Buildfile: build.xml
782
783 init:
784
785 compile:
786
787 examples:
788
789 jar:
790
791 findbugs:
792 [findbugs] Running FindBugs...
793 [findbugs] Bugs were found
794 [findbugs] Output saved to bcel-fb.xml
795
796 BUILD SUCCESSFUL
797 Total time: 35 seconds
798 </screen>この事例においては、XML ファイルでバグ検索結果を保存しているので、 &FindBugs; GUI を使って結果を参照することができます。 <xref linkend="running"/> を参照してください。</para>
799
800 </sect1>
801
802 <sect1>
803 <title>パラメーター</title>
804
805 <para>このセクションでは、 &FindBugs; タスクを使用する際に、指定することができるパラメーターについて説明します。<variablelist> <varlistentry> <term><literal>class</literal></term>
806 <listitem>
807 <para>分析の対象となるクラス群を指定するためのネストされる要素です。<literal>class</literal> 要素には <literal>location</literal> 属性の指定が必須です。分析対象となるアーカイブファイル (jar, zip, 他)、ディレクトリーまたはクラスファイルの名前を記述します。1 つの <literal>findbugs</literal> 要素に対して、複数の <literal>class</literal> 子要素を指定することができます。</para>
808 </listitem>
809 </varlistentry>
810
811 <varlistentry>
812 <term><literal>auxClasspath</literal></term>
813 <listitem>
814 <para>任意指定のネストされる要素です。分析対象のライブラリーまたはアプリケーションによって使用されているが分析の対象にはしたくないクラスを含んでいるクラスパス (Jar ファイルまたはディレクトリー) を指定します。 &Ant; の Java タスクにある <literal>classpath</literal> 要素 と同じ方法で指定することができます。</para>
815 </listitem>
816 </varlistentry>
817
818 <varlistentry>
819 <term><literal>sourcePath</literal></term>
820 <listitem>
821 <para>任意指定のネストされる要素です。分析対象 Java コードのコンパイル時に使用したソースファイルを含んでいるソースディレクトリーへのパスを指定します。ソースパスを指定することにより、生成される XML のバグ出力結果に完全なソース情報をもたせることができ、後になって GUI で参照することができます。</para>
822 </listitem>
823 </varlistentry>
824
825 <varlistentry>
826 <term><literal>home</literal></term>
827 <listitem>
828 <para>必須属性です。&FindBugs; がインストールされているディレクトリー名を設定します。</para>
829 </listitem>
830 </varlistentry>
831
832 <varlistentry>
833 <term><literal>quietErrors</literal></term>
834 <listitem>
835 <para>任意指定のブール値属性です。true を設定すると、深刻な分析エラー発生やクラスがみつからないといった情報が &FindBugs; 出力に記録されません。デフォルトは、 false です。</para>
836 </listitem>
837 </varlistentry>
838
839 <varlistentry>
840 <term><literal>reportLevel</literal></term>
841 <listitem>
842 <para>任意指定の属性です。報告されるバグの優先度のしきい値を指定します。「low」に設定すると、すべてのバグが報告されます。「medium」 (デフォルト) に設定すると、優先度 (中)および優先度 (高)のバグが報告されます。「high」に設定すると、優先度 (高) のバグのみが報告されます。</para>
843 </listitem>
844 </varlistentry>
845
846 <varlistentry>
847 <term><literal>output</literal></term>
848 <listitem>
849 <para>任意指定の属性です。出力形式を指定します。「xml」 (デフォルト) に設定すると、出力は XML 形式になります。「xml:withMessages」 に設定すると、出力は人間が読めるメッセージ が追加された XML 形式になります。(XSL スタイルシートを使ってレポートを作成することを計画している場合はこの形式を使用してください。) 「html」に設定すると、出力は HTML 形式(デフォルトのスタイルシートは default.xsl) になります。 「text」に設定すると、出力は特別なテキスト形式になります。「emacs」に設定すると、出力は <ulink url="http://www.gnu.org/software/emacs/">Emacs</ulink> エラーメッセージ形式になります。「xdocs」に設定すると、出力は Apache Maven で使用できる xdoc XML になります。</para>
850 </listitem>
851 </varlistentry>
852 <varlistentry>
853 <term><literal>stylesheet</literal></term>
854 <listitem>
855 <para>任意指定の属性です。output 属性 に html を指定した場合に、 HTML 出力作成に使用されるスタイルシートを指定します。FindBugs 配布物に含まれているスタイルシートは、 default.xsl、 fancy.xsl 、 fancy-hist.xsl 、 plain.xsl および summary.xsl です。デフォルト値は default.xsl です。</para>
856 </listitem>
857 </varlistentry>
858
859 <varlistentry>
860 <term><literal>sort</literal></term>
861 <listitem>
862 <para>任意指定の属性です。<literal>output</literal> 属性に「text」を指定した場合に、バグの報告をクラス順にソートするかどうかを <literal>sort</literal> 属性で指定します。デフォルトは、 true です。</para>
863 </listitem>
864 </varlistentry>
865
866 <varlistentry>
867 <term><literal>outputFile</literal></term>
868 <listitem>
869 <para>任意指定の属性です。指定した場合、&FindBugs; の出力はその名前のファイルへと保存されます。省略時、出力は &Ant; によって直接表示されます。</para>
870 </listitem>
871 </varlistentry>
872
873 <varlistentry>
874 <term><literal>debug</literal></term>
875 <listitem>
876 <para>任意指定のブール値属性です。true に設定すると、 &FindBugs; は 診断情報を出力します。どのクラスを分析しているか、どのパグパターンディテクタが実行されているか、という情報が表示されます。デフォルトは、 false です。</para>
877 </listitem>
878 </varlistentry>
879
880 <varlistentry>
881 <term><literal>effort</literal></term>
882 <listitem>
883 <para>分析の活動レベルを設定します。<literal>min</literal> 、<literal>default</literal> または <literal>max</literal> のいずれかの値を設定してください。分析レベルの設定に関する詳細情報は、 <xref linkend="commandLineOptions"/> を参照してください。</para>
884 </listitem>
885 </varlistentry>
886
887 <varlistentry>
888 <term><literal>conserveSpace</literal></term>
889 <listitem>
890 <para>effort=&quot;min&quot; と同義です。</para>
891 </listitem>
892 </varlistentry>
893
894 <varlistentry>
895 <term><literal>workHard</literal></term>
896 <listitem>
897 <para>effort=&quot;max&quot; と同義です。</para>
898 </listitem>
899 </varlistentry>
900
901 <varlistentry>
902 <term><literal>visitors</literal></term>
903 <listitem>
904 <para>任意指定の属性です。どのバグディテクタを実行するかをコンマ区切りのリストで指定します。バグディテクタはパッケージ指定なしのクラス名で指定します。省略時、デフォルトで無効化されているものを除くすべてのディテクタが実行されます。</para>
905 </listitem>
906 </varlistentry>
907
908 <varlistentry>
909 <term><literal>omitVisitors</literal></term>
910 <listitem>
911 <para>任意指定の属性です。<literal>visitors</literal> 属性と似ていますが、こちらは <emphasis>実行されない</emphasis> ディテクタを指定します。</para>
912 </listitem>
913 </varlistentry>
914
915 <varlistentry>
916 <term><literal>excludeFilter</literal></term>
917 <listitem>
918 <para>任意指定の属性です。フィルターファイル名を指定します。報告から除外されるバグを指定します。<xref linkend="filter"/> を参照してください。</para>
919 </listitem>
920 </varlistentry>
921
922 <varlistentry>
923 <term><literal>includeFilter</literal></term>
924 <listitem>
925 <para>任意指定の属性です。フィルターファイル名を指定します。報告されるバグを指定します。<xref linkend="filter"/> を参照してください。</para>
926 </listitem>
927 </varlistentry>
928
929 <varlistentry>
930 <term><literal>projectFile</literal></term>
931 <listitem>
932 <para>任意指定の属性です。プロジェクトファイル名を指定します。プロジェクトファイルは、 &FindBugs; GUI で作成します。分析されるクラス、および、補助クラスパス、ソースディレクトリーが記入されてます。プロジェクトファイルを指定した場合は、 <literal>class</literal> 要素・ <literal>auxClasspath</literal> 属性および <literal>sourcePath</literal> 属性を設定する必要はありません。プロジェクトの作成方法は、 <xref linkend="running"/> を参照してください。</para>
933 </listitem>
934 </varlistentry>
935
936 <varlistentry>
937 <term><literal>jvmargs</literal></term>
938 <listitem>
939 <para>任意指定の属性です。&FindBugs; を実行している Java 仮想マシンに対して受け渡される引数を指定します。巨大なプログラムを分析する場合に、 JVM が使用するメモリ容量を増やす指定をするためにこの引数を利用する必要があるかもしれません。</para>
940 </listitem>
941 </varlistentry>
942
943 <varlistentry>
944 <term><literal>systemProperty</literal></term>
945 <listitem>
946 <para>任意指定のネストされる要素です。指定した場合、Java システムプロパティーを定義します。<literal>name</literal> 属性にはシステムプロパティーの名前を指定します。そして、 <literal>value</literal> 属性にはシステムプロパティの値を指定します。</para>
947 </listitem>
948 </varlistentry>
949
950 <varlistentry>
951 <term><literal>timeout</literal></term>
952 <listitem>
953 <para>任意指定の属性です。&FindBugs; を実行している Java プロセス の実行許容時間をミリ秒単位で指定します。時間を超過するとハングアップしていると判断してプロセスが終了されます。デフォルトは、 600,000 ミリ秒 (10 分) です。巨大なプログラムの場合は、 &FindBugs; が分析を完了するまでに 10 分 以上掛かる可能性があることに注意してください。</para>
954 </listitem>
955 </varlistentry>
956
957 <varlistentry>
958 <term><literal>failOnError</literal></term>
959 <listitem>
960 <para>任意指定のブール値属性です。&FindBugs; の実行中にエラーがあった場合に、ビルドプロセス自体を打ち切って異常終了させるかどうかを指定します。デフォルトは、「false」です。</para>
961 </listitem>
962 </varlistentry>
963
964 <varlistentry>
965 <term><literal>errorProperty</literal></term>
966 <listitem>
967 <para>任意指定の属性です。&FindBugs; の実行中にエラーが発生した場合に、「true」が設定されるプロパティーの名前を指定します。</para>
968 </listitem>
969 </varlistentry>
970
971 <varlistentry>
972 <term><literal>warningsProperty</literal></term>
973 <listitem>
974 <para>任意指定の属性です。&FindBugs; が分析したプログラムにバグ報告が 1 件でもある場合に、「true」が設定されるプロパティーの名前を指定します。</para>
975 </listitem>
976 </varlistentry>
977
978 </variablelist>
979
980
981 </para>
982
983 <!--
984
985 -->
986
987 </sect1>
988
989 </chapter>
990
991 <!--
992 **************************************************************************
993 Using the FindBugs Eclipse plugin
994 **************************************************************************
995 -->
996
997 <chapter id="eclipse">
998 <title>&FindBugs;&trade; Eclipse プラグインの使用方法</title>
999
1000 <para>FindBugs Eclipse プラグインを使用することによって、 &FindBugs; を <ulink url="http://www.eclipse.org/">Eclipse</ulink> IDE で使用することができるようになります。このFindBugs Eclipse プラグインは、 Peter Friese 氏の多大な貢献によるものです。Phil Crosby 氏 と Andrei Loskutov 氏は、プラグインの重要な改良に貢献しました。</para>
1001
1002 <sect1>
1003 <title>必要条件</title>
1004
1005 <para>&FindBugs; Eclipse Plugin を使用するためには、 Eclipse 3.3 あるいはそれ以降のバージョン、また、 JRE/JDK 1.5 あるいはそれ以降のバージョンが必要です。</para>
1006
1007 </sect1>
1008
1009 <sect1>
1010 <title>インストール</title>
1011
1012 <para>更新サイトが提供されています。更新サイトを利用して、機械的に FindBugs を Eclipse にインストールできます。また自動的に、最新版のアップデートを照会してインストールすることもできます。内容の異なる 3 つの更新サイトが存在します。</para>
1013
1014 <variablelist><title>FindBugs Eclipse 更新サイト一覧</title>
1015 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse/">http://findbugs.cs.umd.edu/eclipse/</ulink></term>
1016
1017 <listitem>
1018 <para>FindBugs の公式リリース物を提供します。</para>
1019 </listitem>
1020 </varlistentry>
1021
1022 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-candidate/">http://findbugs.cs.umd.edu/eclips-candidate/</ulink></term>
1023
1024 <listitem>
1025 <para>FindBugsの公式リリース物に加えて、公式リリース候補版を提供します。</para>
1026 </listitem>
1027 </varlistentry>
1028
1029 <varlistentry><term><ulink url="http://findbugs.cs.umd.edu/eclipse-daily/">http://findbugs.cs.umd.edu/eclipse-daily/</ulink></term>
1030
1031 <listitem>
1032 <para>FindBugsの日次ビルド物を提供します。コンパイルができること以上のテストは行われていません。</para>
1033 </listitem>
1034 </varlistentry>
1035 </variablelist>
1036
1037 <para>また、次に示すリンクから手動でプラグインをダウンロードすることもできます : <ulink url="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</ulink>. 展開して Eclipse の「plugins」サブディレクトリーに入れてください。(そうすると、 &lt;eclipse インストールディレクトリー &gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png が &FindBugs; のロゴファイルへのパスになるはずです。)</para>
1038
1039 <para>プラグインの展開ができたら、 Eclipse を起動して <menuchoice> <guimenu>Help</guimenu> <guimenuitem>About Eclipse Platform</guimenuitem> <guimenuitem>Plug-in Details</guimenuitem> </menuchoice> を選択してください。「FindBugs Project」から提供された「FindBugs Plug-in」というプラグインがあることを確認してください。</para>
1040 </sect1>
1041
1042 <sect1>
1043 <title>プラグインの使用方法</title>
1044
1045 <para>実行するには、 Java プロジェクト上で右クリックして「Find Bugs」を選択します。&FindBugs; が実行されて、バグパターンの実例の可能性があると識別されたコード箇所に問題マーカーがつきます。 (ソース画面および Eclipse 問題ビューに表示されます。)</para>
1046
1047 <para>Java プロジェクトのプロパティーダイアログを開いて「Findbugs」プロパティーページを選択することで、 &FindBugs; の動作をカスタマイズすることができます。選択できる項目には次のようなものがあります :</para>
1048
1049 <itemizedlist>
1050 <listitem>
1051 <para>「Run FindBugs Automatically」チェックボックスの設定。チェックすると、プロジェクト内の Java クラスが修正されるたびに FindBugs が実行されます。</para>
1052 </listitem>
1053
1054 <listitem>
1055 <para>優先度とバグカテゴリーの選択。これらのオプションは、どの警告を表示するかを選択します。例えば、優先度で 「Medium」 を選択すると、優先度 (中) および優先度 (高) の警告のみが表示されます。同様に、「Style」チェックボックスのチェックマークを外すと、Style カテゴリーに属する警告は表示されません。</para>
1056 </listitem>
1057
1058 <listitem>
1059 <para>ディテクタの選択。表からプロジェクトで有効にしたいディテクタを選択することができます。</para>
1060 </listitem>
1061 </itemizedlist>
1062
1063 </sect1>
1064
1065 <sect1>
1066 <title>トラブルシューティング</title>
1067
1068 <para>&FindBugs; Eclipse プラグインは、まだ実験段階です。このセクションでは、プラグインに関する一般的な問題と (判明していれば) それらの問題の解決方法を記述します。</para>
1069
1070 <itemizedlist>
1071 <listitem>
1072 <para>&FindBugs; 問題マーカーが (ソース画面および問題ビューに) 表示されない場合は、問題ビューのフィルター設定を変更してください。詳細情報は <ulink url="http://findbugs.sourceforge.net/FAQ.html#q7">http://findbugs.sourceforge.net/FAQ.html#q7</ulink> を参照してください。</para>
1073 </listitem>
1074
1075 </itemizedlist>
1076
1077 </sect1>
1078
1079
1080 </chapter>
1081
1082
1083 <!--
1084 **************************************************************************
1085 Filter files
1086 **************************************************************************
1087 -->
1088
1089 <chapter id="filter">
1090 <title>フィルターファイル</title>
1091
1092 <para>フィルターファイルを使用することで、特定のクラスやメソッドをバグ報告に含めたりバグ報告から除外したりすることができます。この章では、フィルターファイルの使用方法を説明します。<note>
1093 <title>計画されている機能</title>
1094 <para>フィルターは現在、コマンドラインインタフェースでのみサポートされています。最終的には、フィルターのサポートは GUI にも追加される予定です。</para>
1095 </note>
1096 </para>
1097
1098
1099 <sect1>
1100 <title>フィルターファイルの概要</title>
1101
1102 <para>概念的に言えば、フィルターはバグ検索結果をある基準と照合します。フィルターを定義することで、 特別な取り扱いをするバグ検索結果を選択することができます。例えば、あるバグ検索結果をバグ報告に含めたり、バグ報告から除外したりすることができます。</para>
1103
1104 <para>フィルターファイルは、 <ulink url="http://www.w3.org/XML/">XML</ulink> 文書です。最上位要素が <literal>FindBugsFilter</literal> 要素 であり、その子要素として <literal>Match</literal> 要素を複数個定義します。それぞれの <literal>Match</literal> 要素は、生成されたバグ検索結果に適用される述部にあたります。通常、フィルターはバグ検索結果を除外するために使用します。次に、例を示します:<screen>
1105 <prompt>$ </prompt><command>findbugs -textui -exclude <replaceable>myExcludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command>
1106 </screen>また一方で、的をしぼった報告を得るためにバグ報告結果を選択するためにフィルターを使用することも考えられます :<screen>
1107 <prompt>$ </prompt><command>findbugs -textui -include <replaceable>myIncludeFilter.xml</replaceable> <replaceable>myApp.jar</replaceable></command>
1108 </screen>
1109 </para>
1110
1111 <para>
1112 <literal>Match</literal> 要素は子要素を持ちます。それらの子要素は論理積で述部になります。つまり、述部が真であるためには、すべての子要素が真である必要があります。</para>
1113
1114 </sect1>
1115
1116 <sect1>
1117 <title>マッチング条件の種類</title>
1118
1119 <variablelist>
1120 <varlistentry>
1121 <term><literal>&lt;Bug&gt;</literal></term>
1122 <listitem><para>この要素は、バグパターンを指定して照合します。<literal>pattern</literal> 属性には、コンマ区切りでバグパターン類型のリストを指定します。どの警告がどのバグパターン類型にあたるかは、 <command>-xml</command> オプションをつかって出力されたもの (<literal>BugInstance</literal> 要素の <literal>type</literal> 属性) を見るか、または、 <ulink url="../../bugDescriptions.html">バグ解説ドキュメント</ulink>を参照してください。</para><para>もっと粒度の粗い照合を行いたいときは、 <literal>code</literal> 属性を使用してください。バグ略称のコンマ区切りのリストで指定できます。さらに粒度の粗い照合を行いたいときは、 <literal>category</literal> 属性を使用してください。次に示す、バグカテゴリー名のコンマ区切りのリストで指定できます : <literal>CORRECTNESS</literal>, <literal>MT_CORRECTNESS</literal>, <literal>BAD_PRACTICICE</literal>, <literal>PERFORMANCE</literal>, <literal>STYLE</literal>.</para><para>同じ <literal>&lt;Bug&gt;</literal> 要素に上記の属性を複数指定した場合は、バグパターン名、バグ略称、バグカテゴリーのいずれか1つでも該当すれば、バグパターンは合致すると判定されます。</para><para>下位互換性を持たせたい場合は、 <literal>&lt;Bug&gt;</literal> 要素の代わりに <literal>&lt;BugPattern&gt;</literal> 要素および <literal>&lt;BugCode&gt;</literal> 要素を使用してください。これらの要素はそれぞれ、 <literal>name</literal> 属性で値のリストを指定します。これらの要素は、将来サポートされなくなる可能性があります。</para></listitem>
1123 </varlistentry>
1124
1125 <varlistentry>
1126 <term><literal>&lt;Priority&gt;</literal></term>
1127 <listitem>
1128 <para>この要素は、特定の優先度をもつ警告を照合します。<literal>value</literal> 属性には、整数値を指定します : 1 は優先度(高)、また、 2 は優先度(中) 、 3 は優先度(低) を示します。</para>
1129 </listitem>
1130 </varlistentry>
1131
1132
1133 <varlistentry>
1134 <term><literal>&lt;Package&gt;</literal></term>
1135 <listitem>
1136 <para>この要素は、 <literal>name</literal> 属性で指定した特定のパッケージ内にあるクラスに関連した警告を照合します。入れ子のパッケージは含まれません (Java import 文に従っています) 。しかしながら、正規表現を使うと複数パッケージにマッチさせることは簡単にできます。</para>
1137 </listitem>
1138 </varlistentry>
1139
1140 <varlistentry>
1141 <term><literal>&lt;Class&gt;</literal></term>
1142 <listitem>
1143 <para>この要素は、特定のクラスに関連した警告を照合します。<literal>name</literal> 属性を使用して、照合するクラス名をクラス名そのものか、または、正規表現で指定します。</para>
1144
1145 <para>下位互換性を持たせたい場合は、この要素の代わりに <literal>Match</literal> 要素を使用してください。クラス名そのものの指定は <literal>class</literal> 属性を、クラス名を正規表現で指定する場合は <literal>classregex</literal> 属性をそれぞれ使用してください</para>
1146
1147 <para>もし <literal>Match</literal> 要素に <literal>Class</literal> 要素が無かったり、 <literal>class</literal> / <literal>classregex</literal> 属性が無かったりした場合は、すべてのクラスに適用されます。その場合、想定外に多くのバグ検索結果が一致してしまうことがあり得ます。その場合は、適当なメソッドやフィールドで絞り込んでください。</para>
1148 </listitem>
1149 </varlistentry>
1150
1151 <varlistentry>
1152 <term><literal>&lt;Method&gt;</literal></term>
1153
1154 <listitem><para>この要素は、メソッドを指定します。<literal>name</literal> 属性を使用して、照合するメソッド名をメソッド名そのものか、または、正規表現で指定します。<literal>params</literal> 属性には、コンマ区切りでメソッド引数の型のリストを指定します。<literal>returns</literal> 属性にはメソッドの戻り値の型を指定します。<literal>params</literal> および <literal>returns</literal> においては、クラス名は完全修飾名である必要があります。(例えば、単に &quot;String&quot; ではなく &quot;java.lang.String&quot; としてください。) <literal>params</literal> <literal>returns</literal> のどちらか一方を指定した場合は、もう一方の属性の指定も必須です。なぜならば、メソッドシグニチャーを構築のために必要だからです。<literal>name</literal> 属性、<literal>params</literal> 属性 および <literal>returns</literal> 属性または 3 つの 属性すべて、のどれかを条件とすることできることを意味しています。このように、名前とシグニチャーに基づく様々な種類の条件を規定できます。</para></listitem>
1155 </varlistentry>
1156
1157 <varlistentry>
1158 <term><literal>&lt;Field&gt;</literal></term>
1159
1160 <listitem><para>この要素は、フィールドを指定します。<literal>name</literal> 属性を使用して、照合するフィールド名をフィールド名そのものか、または、正規表現で指定します。また、フィールドのシグニチャーに照らしたフィルタリングをすることができます。 <literal>type</literal> 属性を使用して、フィールドの型を完全修飾名で指定してください。名前とシグニチャーに基づく条件を規定するために、その2つの属性を両方とも指定することができます。</para></listitem>
1161 </varlistentry>
1162
1163 <varlistentry>
1164 <term><literal>&lt;Local&gt;</literal></term>
1165
1166 <listitem><para>この要素は、ローカル変数を指定します。<literal>name</literal> 属性を使用して、照合するローカル変数名をローカル変数名そのものか、または、正規表現で指定します。ローカル変数とは、メソッド内で定義した変数です。</para></listitem>
1167 </varlistentry>
1168
1169 <varlistentry>
1170 <term><literal>&lt;Or&gt;</literal></term>
1171 <listitem><para>この要素は、論理和として <literal>Match</literal> 条項を結合します。すなわち、2つの <literal>Method</literal> 要素を <literal>Or</literal> 条項に入れることで、どちらか一方のメソッドでマッチさせることができます。</para></listitem>
1172 </varlistentry>
1173 </variablelist>
1174
1175 </sect1>
1176
1177 <sect1>
1178 <title>Java 要素名マッチング</title>
1179
1180 <para><literal>Class</literal> 、 <literal>Method</literal> または <literal>Field</literal> の <literal>name</literal> 属性が文字 ~ で始まっている場合は、属性値の残りの部分を Java の正規表現として解釈します。そうして、当該 Java 要素の名前に対しての照合が行われます。</para>
1181
1182 <para>パターンの照合は要素の名前全体に対して行われることに注意してください。そのため、部分一致照合を行いたい場合はパターン文字列の前後に .* を付加して使用する必要があります。</para>
1183
1184 <para>パターンの構文規則に関しては、 <ulink url="http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/util/regex/Pattern.html"><literal>java.util.regex.Pattern</literal></ulink> のドキュメントを参照してください。</para>
1185 </sect1>
1186
1187 <sect1>
1188 <title>留意事項</title>
1189
1190 <para>
1191 <literal>Match</literal> 条項は、バグ検索結果に実際に含まれている情報にのみ一致します。すべてのバグ検索結果はクラスを持っています。したがって、一般的に言って、バグを除外するためにはクラスを用いて行うとうまくいくことが多いです。</para>
1192
1193 <para>バグ検索結果の中には、2個以上のクラスを保持しているものもあります。例えば、 DE (dropped exception : 例外の無視) バグは、 例外の無視が発生したメソッドを持っているクラスと、 無視された例外の型を表すクラスの両方を含んだ形で報告されます。<literal>Match</literal> 条項とは、 <emphasis>1番目</emphasis> (主) のクラスのみが照合されます。したがって、例えば、クラス &quot;com.foobar.A&quot; 、 &quot;com.foobar.B&quot; 間での IC (initialization circularity : 初期化時の処理循環) バグ報告を抑止したい場合、以下に示すように 2つの <literal>Match</literal> 条項を使用します :<programlisting>
1194 &lt;Match&gt;
1195 &lt;Class name=&quot;com.foobar.A&quot; /&gt;
1196 &lt;Bug code=&quot;IC&quot; /&gt;
1197 &lt;/Match&gt;
1198
1199 &lt;Match&gt;
1200 &lt;Class name=&quot;com.foobar.B&quot; /&gt;
1201 &lt;Bug code=&quot;IC&quot; /&gt;
1202 &lt;/Match&gt;
1203 </programlisting>明示的に両方のクラスで照合することによって、循環しているどちらのクラスがバグ検索結果の 1 番目になっているかに関係なく一致させることができます。(もちろんこの方法は、処理循環が &quot;com.foobar.A&quot; 、 &quot;com.foobar.B&quot; に加えて3番目のクラスも含んでいる場合は図らずも失敗してしまう恐れがあります。)</para>
1204
1205 <para>多くの種類のバグ報告は、自身が出現したメソッドを報告します。それらのバグ検索結果に対しては、 <literal>Method</literal> 条項を <literal>Match</literal> 要素に加えると期待通りの動作をするでしょう。</para>
1206
1207 </sect1>
1208
1209 <sect1>
1210 <title>例</title>
1211
1212 <para>1. 特定のクラスに対するすべてのバグ報告に一致させます。<programlisting>
1213 <![CDATA[
1214 <Match>
1215 <Class name="com.foobar.MyClass" />
1216 </Match>
1217 ]]>
1218 </programlisting>
1219
1220 </para>
1221
1222 <para>2. バグ略称を指定して、特定のクラスに対する特定の検査項目に一致させます。<programlisting>
1223 <![CDATA[
1224 <Match>
1225 <Class name="com.foobar.MyClass"/ >
1226 <Bug code="DE,UrF,SIC" />
1227 </Match>
1228 ]]>
1229 </programlisting>
1230 </para>
1231
1232 <para>3. バグ略称を指定して、すべてのクラスに対する特定の検査項目に一致させます。<programlisting>
1233 <![CDATA[
1234 <Match>
1235 <Bug code="DE,UrF,SIC" />
1236 </Match>
1237 ]]>
1238 </programlisting>
1239 </para>
1240
1241 <para>4. バグカテゴリーを指定して、すべてのクラスに対する特定の検査項目に一致させます。<programlisting>
1242 <![CDATA[
1243 <Match>
1244 <Bug category="PERFORMANCE" />
1245 </Match>
1246 ]]>
1247 </programlisting>
1248 </para>
1249
1250 <para>5. バグ略称を指定して、特定のクラスの指定されたメソッドに対する特定のバグ種別に一致させます。<programlisting>
1251 <![CDATA[
1252 <Match>
1253 <Class name="com.foobar.MyClass" />
1254 <Or>
1255 <Method name="frob" params="int,java.lang.String" returns="void" />
1256 <Method name="blat" params="" returns="boolean" />
1257 </Or>
1258 <Bug code="DC" />
1259 </Match>
1260 ]]>
1261 </programlisting>
1262 </para>
1263
1264 <para>6. 特定のメソッドに対する特定のバグパターンに一致させます。<programlisting>
1265 <![CDATA[
1266 <!-- open stream に関する誤検出があるメソッド。-->
1267 <Match>
1268 <Class name="com.foobar.MyClass" />
1269 <Method name="writeDataToFile" />
1270 <Bug pattern="OS_OPEN_STREAM" />
1271 </Match>
1272 ]]>
1273 </programlisting>
1274 </para>
1275
1276 <para>7. 特定のメソッドに対する特定の優先度を付与された特定のバグパターンに一致させます。<programlisting>
1277 <![CDATA[
1278 <!-- dead local store (優先度 (中)) に関する誤検出があるメソッド。-->
1279 <Match>
1280 <Class name="com.foobar.MyClass" />
1281 <Method name="someMethod" />
1282 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
1283 <Priority value="2" />
1284 </Match>
1285 ]]>
1286 </programlisting>
1287 </para>
1288
1289 <para>8. AspectJ コンパイラーによって引き起こされるマイナーバグに一致させます (AspectJ の開発者でもない限り、それらのバグに関心を持つことはないと考えます)。<programlisting>
1290 <![CDATA[
1291 <Match>
1292 <Class name="~.*\$AjcClosure\d+" />
1293 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
1294 <Method name="run" />
1295 </Match>
1296 <Match>
1297 <Bug pattern="UUF_UNUSED_FIELD" />
1298 <Field name="~ajc\$.*" />
1299 </Match>
1300 ]]>
1301 </programlisting>
1302 </para>
1303
1304 <para>9. 基盤コードの特定の部分に対するバグに一致させます<programlisting>
1305 <![CDATA[
1306 <!-- すべてのパッケージにある Messages クラスに対する unused fields 警告に一致。 -->
1307 <Match>
1308 <Class name="~.*\.Messages" />
1309 <Bug code="UUF" />
1310 </Match>
1311 <!-- すべての internal パッケージ内の mutable statics 警告に一致。 -->
1312 <Match>
1313 <Package name="~.*\.internal" />
1314 <Bug code="MS" />
1315 </Match>
1316 <!-- ui パッケージ階層内の anonymoous inner classes 警告に一致。 -->
1317 <Match>
1318 <Package name="~com\.foobar\.fooproject\.ui.*" />
1319 <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
1320 </Match>
1321 ]]>
1322 </programlisting>
1323 </para>
1324
1325 <para>10. 特定のシグニチャーを持つフィールドまたはメソッドのバグに一致させます。<programlisting>
1326 <![CDATA[
1327 <!-- すべてのクラスの main(String[]) メソッドに対する System.exit(...) usage 警告に一致。 -->
1328 <Match>
1329 <Method returns="void" name="main" params="java.lang.String[]" />
1330 <Method pattern="DM_EXIT" />
1331 </Match>
1332 <!-- すべてのクラスの com.foobar.DebugInfo 型のフィールドに対する UuF 警告に一致。 -->
1333 <Match>
1334 <Field type="com.foobar.DebugInfo" />
1335 <Bug code="UuF" />
1336 </Match>
1337 ]]>
1338 </programlisting>
1339
1340 </para>
1341
1342 </sect1>
1343
1344 <sect1>
1345 <title>完全な例</title>
1346
1347 <programlisting>
1348 <![CDATA[
1349 <FindBugsFilter>
1350 <Match>
1351 <Class name="com.foobar.ClassNotToBeAnalyzed" />
1352 </Match>
1353
1354 <Match>
1355 <Class name="com.foobar.ClassWithSomeBugsMatched" />
1356 <Bug code="DE,UrF,SIC" />
1357 </Match>
1358
1359 <!-- XYZ 違反に一致。-->
1360 <Match>
1361 <Bug code="XYZ" />
1362 </Match>
1363
1364 <!-- "AnotherClass" の特定のメソッドの doublecheck 違反に一致。-->
1365 <Match>
1366 <Class name="com.foobar.AnotherClass" />
1367 <Or>
1368 <Method name="nonOverloadedMethod" />
1369 <Method name="frob" params="int,java.lang.String" returns="void" />
1370 <Method name="blat" params="" returns="boolean" />
1371 </Or>
1372 <Bug code="DC" />
1373 </Match>
1374
1375 <!-- dead local store (優先度 (中)) に関する誤検出があるメソッド。-->
1376 <Match>
1377 <Class name="com.foobar.MyClass" />
1378 <Method name="someMethod" />
1379 <Bug pattern="DLS_DEAD_LOCAL_STORE" />
1380 <Priority value="2" />
1381 </Match>
1382 </FindBugsFilter>
1383 ]]>
1384 </programlisting>
1385
1386 </sect1>
1387
1388
1389 </chapter>
1390
1391
1392 <!--
1393 **************************************************************************
1394 Analysis properties
1395 **************************************************************************
1396 -->
1397
1398 <chapter id="analysisprops">
1399 <title>分析プロパティー</title>
1400
1401 <para>&FindBugs; は分析する場合にいくつかの観点を持っています。そして、観点をカスタマイズして実行することができます。システムプロパティーを使って、それらのオプションを設定します。この章では、分析オプションの設定方法を説明します。</para>
1402
1403 <para>分析オプションの主な目的は、 2 つあります。1 番目は、 &FindBugs; に対して分析されるアプリケーションのメソッドの意味を伝えることです。そうすることで &FindBugs; がより正確な結果を出すことができ、誤検出を減らすことができます。2 番目に、分析を行うに当たりその精度を設定できるようにすることです。分析の精度を落とすことで、メモリ使用量と分析時間を減らすことができます。ただし、本当のバグを見逃したり、誤検出の数が増えるという代償があります。</para>
1404
1405 <para>コマンドラインオプション <command>-property</command> を使って、分析オプションを設定することができます。次に、例を示します:<screen>
1406 <prompt>$ </prompt><command>findbugs -textui -property &quot;cfg.noprune=true&quot; <replaceable>myApp.jar</replaceable></command>
1407 </screen>
1408 </para>
1409
1410 <para>設定することができる分析オプションの一覧を <xref linkend="analysisproptable"/> に示します。</para>
1411
1412 <table id="analysisproptable">
1413 <title>設定可能な分析プロパティー</title>
1414 <tgroup cols="3" align="left">
1415 <thead>
1416 <row>
1417 <entry>プロパティー名</entry>
1418 <entry>設定値</entry>
1419 <entry>目的</entry>
1420 </row>
1421 </thead>
1422 <tbody>
1423 <!--
1424 <row>
1425 <entry>cfg.noprune</entry>
1426 <entry>true or false</entry>
1427 <entry>If true, infeasible exception edges are not pruned from
1428 the control flow graphs of analyzed methods. This option
1429 increases the speed of the analysis (by about 20%-30%),
1430 but causes some detectors to produce more false warnings.</entry>
1431 </row>
1432 -->
1433 <row>
1434 <entry>findbugs.assertionmethods</entry>
1435 <entry>コンマ区切りの完全修飾メソッド名リスト : 例、 &quot;com.foo.MyClass.checkAssertion&quot;</entry>
1436 <entry>このプロパティーには、プログラムが正しいことをチェックするために使われるメソッドを指定します。これらのメソッドを指定することで、 チェックメソッドで確認した値に対する null 参照アクセスディテクタの誤検出を回避できます。</entry>
1437 </row>
1438 <row>
1439 <entry>findbugs.de.comment</entry>
1440 <entry>true または false</entry>
1441 <entry>true に設定すると、 DroppedException (無視された例外) ディテクタは空の catch ブロック にコメントが無いか探します。そして、コメントがみつかった場合には警告が報告されません。</entry>
1442 </row>
1443 <row>
1444 <entry>findbugs.maskedfields.locals</entry>
1445 <entry>true または false</entry>
1446 <entry>true に設定すると、フィールドを隠蔽しているローカル変数に対して優先度(低)の警告が発行されます。デフォルトは、 false です。</entry>
1447 </row>
1448 <row>
1449 <entry>findbugs.nullderef.assumensp</entry>
1450 <entry>true または false</entry>
1451 <entry>使用されません。 (意図 : true に設定すると、null 参照アクセスディテクタはメソッドからの戻り値、または、メソッドに受け渡される引数を null であると仮定します。デフォルトは、 false です。このプロパティーを有効にすると、大量の誤検出が生成されるであろうことに注意してください。)</entry>
1452 </row>
1453 <row>
1454 <entry>findbugs.refcomp.reportAll</entry>
1455 <entry>true または false</entry>
1456 <entry>true に設定すると、 == および != 演算子を使っている疑わしい参照比較がすべて報告されます。 false に設定すると、同様の警告は 1 メソッドにつき 1 つしか発行されません。デフォルトは、 false です。</entry>
1457 </row>
1458 <row>
1459 <entry>findbugs.sf.comment</entry>
1460 <entry>true または false</entry>
1461 <entry>true に設定すると、 SwitchFallthrough ディテクタはソースコードに「fall」または「nobreak」という単語を含んだコメントを記載していない caseラベル に限り警告を報告します。(この機能が正しく動作するためには、正確なソースパスが必要です。) これにより、意図的ではない switch 文の fallthrough を発見し易くなります。</entry>
1462 </row>
1463 <!-- see others at src/doc/manual/sysprops.html
1464 <row>
1465 <entry></entry>
1466 <entry></entry>
1467 <entry></entry>
1468 </row>
1469 -->
1470 </tbody>
1471 </tgroup>
1472 </table>
1473
1474 </chapter>
1475
1476 <!--
1477 **************************************************************************
1478 Annotations
1479 ***************************************************************************
1480 -->
1481
1482 <chapter id="annotations">
1483 <title>アノテーション</title>
1484
1485 <para>&FindBugs; はいくつかのアノテーションをサポートしています。開発者の意図を明確にすることで、 FindBugs はより的確に警告を発行することができます。アノテーションを使用するためには Java 5 が必要であり、 annotations.jar および jsr305.jar ファイルをコンパイル時のクラスパスに含める必要があります。</para>
1486
1487 <variablelist>
1488 <varlistentry>
1489 <term><command>edu.umd.cs.findbugs.annotations.CheckForNull</command></term>
1490 <listitem>
1491 <command>[Target]</command> Field, Method, Parameter
1492 </listitem>
1493 <listitem>
1494 <para>アノテーションをつけた要素は、 null である可能性があります。したがって、当該要素を使用する際は null チェックをするべきです。このアノテーションをメソッドに適用すると、メソッドの戻り値に適用されます。</para>
1495 </listitem>
1496 </varlistentry>
1497
1498 <varlistentry>
1499 <term><command>edu.umd.cs.findbugs.annotations.CheckReturnValue</command></term>
1500 <listitem>
1501 <command>[Target]</command> Method, Constructor
1502 </listitem>
1503 <listitem>
1504 <variablelist>
1505 <varlistentry>
1506 <term><command>[Parameter]</command></term>
1507 <listitem>
1508 <para>
1509 <command>priority:</command> 警告の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。</para>
1510 </listitem>
1511 <listitem>
1512 <para>
1513 <command>explanation:</command>戻り値をチェックしなけばならない理由をテキストで説明します。デフォルト値 :&quot;&quot;。</para>
1514 </listitem>
1515 </varlistentry>
1516 </variablelist>
1517 </listitem>
1518 <listitem>
1519 <para>このアノテーションを使用して、呼出し後に戻り値をチェックすべきメソッドを表すことができます。</para>
1520 </listitem>
1521 </varlistentry>
1522
1523 <varlistentry>
1524 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotation</command></term>
1525 <listitem>
1526 <command>[Target]</command> Type, Package
1527 </listitem>
1528 <listitem>
1529 <variablelist>
1530 <varlistentry>
1531 <term><command>[Parameter]</command></term>
1532 <listitem>
1533 <para>
1534 <command>value:</command>アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。</para>
1535 </listitem>
1536 <listitem>
1537 <para>
1538 <command>priority:</command>省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。</para>
1539 </listitem>
1540 </varlistentry>
1541 </variablelist>
1542 </listitem>
1543 <listitem>
1544 <para>
1545 Indicates that all members of the class or package should be annotated with the default
1546 value of the supplied annotation classes. This would be used for behavior annotations
1547 such as @NonNull, @CheckForNull, or @CheckReturnValue. In particular, you can use
1548 @DefaultAnnotation(NonNull.class) on a class or package, and then use @Nullable only
1549 on those parameters, methods or fields that you want to allow to be null.
1550 </para>
1551 </listitem>
1552 </varlistentry>
1553
1554 <varlistentry>
1555 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForFields</command></term>
1556 <listitem>
1557 <command>[Target]</command> Type, Package
1558 </listitem>
1559 <listitem>
1560 <variablelist>
1561 <varlistentry>
1562 <term><command>[Parameter]</command></term>
1563 <listitem>
1564 <para>
1565 <command>value:</command>アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。</para>
1566 </listitem>
1567 <listitem>
1568 <para>
1569 <command>priority:</command>省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。</para>
1570 </listitem>
1571 </varlistentry>
1572 </variablelist>
1573 </listitem>
1574 <listitem>
1575 <para>
1576 This is same as the DefaultAnnotation except it only applys to fields.
1577 </para>
1578 </listitem>
1579 </varlistentry>
1580
1581 <varlistentry>
1582 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForMethods</command></term>
1583 <listitem>
1584 <command>[Target]</command> Type, Package
1585 </listitem>
1586 <listitem>
1587 <variablelist>
1588 <varlistentry>
1589 <term><command>[Parameter]</command></term>
1590 <listitem>
1591 <para>
1592 <command>value:</command>アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。</para>
1593 </listitem>
1594 <listitem>
1595 <para>
1596 <command>priority:</command>省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。</para>
1597 </listitem>
1598 </varlistentry>
1599 </variablelist>
1600 </listitem>
1601 <listitem>
1602 <para>
1603 This is same as the DefaultAnnotation except it only applys to methods.
1604 </para>
1605 </listitem>
1606 </varlistentry>
1607
1608 <varlistentry>
1609 <term><command>edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters</command></term>
1610 <listitem>
1611 <command>[Target]</command> Type, Package
1612 </listitem>
1613 <listitem>
1614 <variablelist>
1615 <varlistentry>
1616 <term><command>[Parameter]</command></term>
1617 <listitem>
1618 <para>
1619 <command>value:</command>アノテーションクラスのclassオブジェクト。複数のクラスを指定することができます。</para>
1620 </listitem>
1621 <listitem>
1622 <para>
1623 <command>priority:</command>省略時の優先度を指定します (HIGH, MEDIUM, LOW, IGNORE) 。デフォルト値 :MEDIUM。</para>
1624 </listitem>
1625 </varlistentry>
1626 </variablelist>
1627 </listitem>
1628 <listitem>
1629 <para>
1630 This is same as the DefaultAnnotation except it only applys to method parameters.
1631 </para>
1632 </listitem>
1633 </varlistentry>
1634
1635 <varlistentry>
1636 <term><command>edu.umd.cs.findbugs.annotations.NonNull</command></term>
1637 <listitem>
1638 <command>[Target]</command> Field, Method, Parameter
1639 </listitem>
1640 <listitem>
1641 <para>アノテーションをつけた要素は、 null であってはいけません。アノテーションをつけたフィールドは、構築完了後 null であってはいけません。アノテーションをつけたメソッドは、 null ではない値を戻り値としなければなりません。</para>
1642 </listitem>
1643 </varlistentry>
1644
1645 <varlistentry>
1646 <term><command>edu.umd.cs.findbugs.annotations.Nullable</command></term>
1647 <listitem>
1648 <command>[Target]</command> Field, Method, Parameter
1649 </listitem>
1650 <listitem>
1651 <para>アノテーションをつけた要素は、 null であってはいけません。In general, this means developers will have to read the documentation to determine when a null value is acceptable and whether it is neccessary to check for a null value. FindBugs will treat the annotated items as though they had no annotation.</para>
1652 <para>
1653 In pratice this annotation is useful only for overriding an overarching NonNull
1654 annotation.
1655 </para>
1656 </listitem>
1657 </varlistentry>
1658
1659 <varlistentry>
1660 <term><command>edu.umd.cs.findbugs.annotations.OverrideMustInvoke</command></term>
1661 <listitem>
1662 <command>[Target]</command> Method
1663 </listitem>
1664 <listitem>
1665 <variablelist>
1666 <varlistentry>
1667 <term><command>[Parameter]</command></term>
1668 <listitem>
1669 <para>
1670 <command>value:</command>Specify when the super invocation should be
1671 performed (FIRST, ANYTIME, LAST). Default value:ANYTIME.
1672 </para>
1673 </listitem>
1674 </varlistentry>
1675 </variablelist>
1676 </listitem>
1677 <listitem>
1678 <para>
1679 Used to annotate a method that, if overridden, must (or should) be invoke super
1680 in the overriding method. Examples of such methods include finalize() and clone().
1681 The argument to the method indicates when the super invocation should occur:
1682 at any time, at the beginning of the overriding method, or at the end of the overriding method.
1683 (This anotation is not implmemented in FindBugs as of September 8, 2006).
1684 </para>
1685 </listitem>
1686 </varlistentry>
1687
1688 <varlistentry>
1689 <term><command>edu.umd.cs.findbugs.annotations.PossiblyNull</command></term>
1690 <listitem>
1691 <para>
1692 This annotation is deprecated. Use CheckForNull instead.
1693 </para>
1694 </listitem>
1695 </varlistentry>
1696
1697 <varlistentry>
1698 <term><command>edu.umd.cs.findbugs.annotations.SuppressWarnings</command></term>
1699 <listitem>
1700 <command>[Target]</command> Type, Field, Method, Parameter, Constructor, Package
1701 </listitem>
1702 <listitem>
1703 <variablelist>
1704 <varlistentry>
1705 <term><command>[Parameter]</command></term>
1706 <listitem>
1707 <para>
1708 <command>value:</command>The name of the warning. More than one name can be specified.
1709 </para>
1710 </listitem>
1711 <listitem>
1712 <para>
1713 <command>justification:</command>Reason why the warning should be ignored. デフォルト値 :&quot;&quot;。</para>
1714 </listitem>
1715 </varlistentry>
1716 </variablelist>
1717 </listitem>
1718 <listitem>
1719 <para>
1720 The set of warnings that are to be suppressed by the compiler in the annotated element.
1721 Duplicate names are permitted. The second and successive occurrences of a name are ignored.
1722 The presence of unrecognized warning names is <emphasis>not</emphasis> an error: Compilers
1723 must ignore any warning names they do not recognize. They are, however, free to emit a
1724 warning if an annotation contains an unrecognized warning name. Compiler vendors should
1725 document the warning names they support in conjunction with this annotation type. They
1726 are encouraged to cooperate to ensure that the same names work across multiple compilers.
1727 </para>
1728 </listitem>
1729 </varlistentry>
1730
1731 <varlistentry>
1732 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term>
1733 <listitem>
1734 <command>[Target]</command> Field, Method, Parameter
1735 </listitem>
1736 <listitem>
1737 <para>
1738 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
1739 </para>
1740 </listitem>
1741 </varlistentry>
1742
1743 <varlistentry>
1744 <term><command>edu.umd.cs.findbugs.annotations.UnknownNullness</command></term>
1745 <listitem>
1746 <command>[Target]</command> Field, Method, Parameter
1747 </listitem>
1748 <listitem>
1749 <para>
1750 Used to indicate that the nullness of the target is unknown, or my vary in unknown ways in subclasses.
1751 </para>
1752 </listitem>
1753 </varlistentry>
1754 </variablelist>
1755
1756 <para>また、 &FindBugs; 次に示すアノテーションもサポートしています。 :<itemizedlist>
1757 <listitem>net.jcip.annotations.GuardedBy</listitem>
1758 <listitem>net.jcip.annotations.Immutable</listitem>
1759 <listitem>net.jcip.annotations.NotThreadSafe</listitem>
1760 <listitem>net.jcip.annotations.ThreadSafe</listitem>
1761 </itemizedlist>
1762 </para>
1763 <para><ulink url="http://jcip.net/">Java Concurrency in Practice</ulink> の <ulink url="http://jcip.net/annotations/doc/index.html"> API ドキュメント</ulink> を参照してください。</para>
1764 </chapter>
1765
1766 <!--
1767 **************************************************************************
1768 Using rejarForAnalysis
1769 **************************************************************************
1770 -->
1771
1772 <chapter id="rejarForAnalysis">
1773 <title>rejarForAnalysis の使用方法</title>
1774
1775 <para>プロジェクトに多くの jar ファイル があったり、 jar ファイルが多くのディレクトリに点在したりする場合は、 <command>rejarForAnalysis </command> スクリプトを使用すると FindBugs の実行が比較的簡単になります。このスクリプトは、数多い jar ファイルを集めて 1 つの大きな jar ファイルに結合します。そうすると、分析時にFindBugs に jar ファイルを設定することが比較的簡単になります。このスクリプトは、 unix システムの 'find' コマンドと組み合わせるととりわけ有用になります ; 次に例を示します。 <command>find . -name '*.jar' | xargs rejarForAnalysis </command>.</para>
1776
1777 <para>また、 <command>rejarForAnalysis</command> スクリプトは巨大なプロジェクトを複数の jar ファイルに分割することに使用できます。プロジェクトのクラスファイルは、複数の jar ファイルに均等に配分されます。これは、プロジェクト全体に対して FindBugs を実行すると時間とメモリ消費が著しい場合に有用です。プロジェクト全体に対して FindBugs を実行する代わりに、 <command> rejarForAnalysis</command> ですべてのクラスを含む大きな jar ファイルを構築します。続いて、 <command>rejarForAnalysis</command> を再び実行して複数の jar ファイルに分割します。そして、各々の jar ファイルに対して順に FindBugs を実行します。その際、 <command>-auxclasspath</command> に最初に 1 つにまとめた jar ファイルを指定してください。</para>
1778
1779 <para><command>rejarForAnalysis</command> スクリプトに指定することができるオプションを以下に示します :</para>
1780
1781 <variablelist>
1782 <varlistentry>
1783 <term><command>-maxAge</command> <replaceable>日数</replaceable></term>
1784 <listitem>
1785 <para>最後に更新された日からの経過時間を日単位で指定します (指定した日数より古い jar ファイルは無視されます)。</para>
1786 </listitem>
1787 </varlistentry>
1788 <varlistentry>
1789 <term><command>-inputFileList</command> <replaceable>ファイル名</replaceable></term>
1790 <listitem>
1791 <para>jar ファイル名を記載したテキストファイルを指定します。</para>
1792 </listitem>
1793 </varlistentry>
1794 <varlistentry>
1795 <term><command>-maxClasses</command> <replaceable>クラス数</replaceable></term>
1796 <listitem>
1797 <para>analysis*.jar ファイル 1 ファイルに対するクラスの最大数を指定します。</para>
1798 </listitem>
1799 </varlistentry>
1800 <varlistentry>
1801 <term><command>-prefix</command> <replaceable>プレフィックス</replaceable></term>
1802 <listitem>
1803 <para>分析するクラス名のプレフィックスを指定します (例、 edu.umd.cs.) 。</para>
1804 </listitem>
1805 </varlistentry>
1806 </variablelist>
1807 </chapter>
1808
1809 <!--
1810 **************************************************************************
1811 Data mining
1812 **************************************************************************
1813 -->
1814
1815 <chapter id="datamining">
1816 <title>&FindBugs;&trade; によるデータ・マイニング</title>
1817
1818 <para>バグデータベースへの高機能の問い合わせ機能、および、調査対象のコードの複数のバージョンにわたる警告の追跡記録機能を、 FindBugs は内蔵しています。これらを使って次のようなことができます。すなわち、いつバグが最初持ち込まれたかを捜し出すこと、最終リリース以後持ち込まれた警告の分析を行うこと、または、無限再起ループの数を時間軸でグラフにすることです。</para>
1819
1820 <para>これらの技術は、 FindBugs が警告の保存に使う XML 書式を使用します。これらの XML ファイルは、通常、特定の 1 分析に対する警告が入れられています。しかしそれらには、一連のソフトウェアのビルドやバージョンに対する分析結果を格納することもできます。</para>
1821
1822 <para>すべての FindBugs XML バグデータベースには、バージョン名とタイム・スタンプ が入れられています。FindBugs は分析が行われるファイルの更新時刻からタイム・スタンプを計算します (例えば、タイム・スタンプはクラスファイルの生成時刻になるようになっています。分析が行われた時刻ではありません) 。各々のバグデータベースには、バージョン名も入れられています。バージョン名とタイム・スタンプは、 <command>setBugDatabaseInfo</command> (<xref linkend="setBugDatabaseInfo"/>) コマンドを使用して手動で設定することもできます。</para>
1823
1824 <para>複数バージョンを格納するバグデータベースにおいては、分析されるコードの各バージョンごとにシーケンス番号が割り当てられます。これらのシーケンス番号は単に 0 から始まる連続する整数値です (例えば、 4 つのコードバージョンを格納するバグデータベースには、バージョン 0~3 が入れられます) 。バグデータベースにはまた、各バージョンの名前とタイム・スタンプがそれぞれ記録されます。<command>filterBugs</command> コマンドを使用すると、シーケンス番号、バージョン名またはタイム・スタンプからバージョンを参照することができます。</para>
1825
1826 <para>1 バージョンを格納するバグデータベースの集合から、 1 個の複数バージョンバグデータベースを作成することができます。また、複数バージョンバグデータベースに対して、それ以後に作成された 1 バージョンのバグデータベースを結合することができます。</para>
1827
1828 <para>これらのコマンドのいくつかは、 ant タスクとして実行することができます。コマンドの実行方法および属性・引数の詳細は、以下を参照してください。以下のすべての例においては、 <literal>findbugs.lib</literal> <literal>refid</literal> が正しく設定されていることを前提としています。設定方法の一例を次に示します :</para>
1829
1830 <programlisting>
1831 <![CDATA[
1832 <!-- findbugs タスク定義 -->
1833 <property name="findbugs.home" value="/your/path/to/findbugs" />
1834 <path id="findbugs.lib">
1835 <fileset dir="${findbugs.home}/lib">
1836 <include name="findbugs-ant.jar"/>
1837 </fileset>
1838 </path>
1839 ]]>
1840 </programlisting>
1841
1842 <sect1 id="commands">
1843 <title>コマンド</title>
1844
1845 <para>FindBugs データ・マイニング ツールはすべてコマンドラインから実行することができます。また、いくつかのより有用なコマンドは、 ant ビルドファイルから実行することができます。</para>
1846
1847 <para>コマンドラインツールについて簡単に説明します :</para>
1848
1849 <variablelist>
1850 <varlistentry>
1851 <term><command><link linkend="unionBugs">unionBugs</link></command></term>
1852 <listitem>
1853 <para>別のクラスに対する別個の分析結果を結合します。</para>
1854 </listitem>
1855 </varlistentry>
1856 <varlistentry>
1857 <term><command><link linkend="computeBugHistory">computeBugHistory</link></command></term>
1858 <listitem>
1859 <para>複数バージョンから得られた複数のバグ警告を、マージして 1 個の複数バージョンバグデータベースにします。これを使って、既存の複数バージョンバグデータベースに更にバージョンを追加したり、 1 バージョンを格納するバグデータベースの集合から 1 個の複数バージョンバグデータベースを作成したり、できます。</para>
1860 </listitem>
1861 </varlistentry>
1862 <varlistentry>
1863 <term><command><link linkend="setBugDatabaseInfo">setBugDatabaseInfo</link></command></term>
1864 <listitem>
1865 <para>リビジョン名やタイム・スタンプなどの情報を XML データベースに設定します。</para>
1866 </listitem>
1867 </varlistentry>
1868 <varlistentry>
1869 <term><command><link linkend="listBugDatabaseInfo">listBugDatabaseInfo</link></command></term>
1870 <listitem>
1871 <para>XML データベースにあるリビジョン名やタイム・スタンプなどの情報を一覧表示します。</para>
1872 </listitem>
1873 </varlistentry>
1874 <varlistentry>
1875 <term><command><link linkend="filterBugs">filterBugs</link></command></term>
1876 <listitem>
1877 <para>バグデータベースの部分集合を選択します。</para>
1878 </listitem>
1879 </varlistentry>
1880 <varlistentry>
1881 <term><command><link linkend="mineBugHistory">mineBugHistory</link></command></term>
1882 <listitem>
1883 <para>複数バージョンバグデータベースの各バージョン毎の警告数を一覧にした表を作成します。</para>
1884 </listitem>
1885 </varlistentry>
1886 <varlistentry>
1887 <term><command><link linkend="defectDensity">defectDensity</link></command></term>
1888 <listitem>
1889 <para>プロジェクト全体およびクラス毎・パッケージ毎の不良密度 (1000 NCSS 毎の警告数) に関する情報を一覧表示します。</para>
1890 </listitem>
1891 </varlistentry>
1892 <varlistentry>
1893 <term><command><link linkend="convertXmlToText">convertXmlToText</link></command></term>
1894 <listitem>
1895 <para>XML 形式のバグ警告を、 1 行 1 バグのテキスト形式、または、HTML形式に変換します。</para>
1896 </listitem>
1897 </varlistentry>
1898 </variablelist>
1899
1900
1901 <sect2 id="unionBugs">
1902 <title>unionBugs</title>
1903
1904 <para>分析するのにアプリケーションの jar ファイルを分割している場合、このコマンドを使用することで、別個に生成された XML バグ警告ファイルをすべての警告を含んでいる 1 つの ファイルにすることができます。</para>
1905
1906 <para>同じファイルの異なるバージョンを分析した結果を結合する場合は、このコマンドを<emphasis>使用しないでください</emphasis>。代わりに <command>computeBugHistory</command> を使用してください。</para>
1907
1908 <para>XML ファイルは、コマンドラインで指定してください。結果は、標準出力に送られます。</para>
1909 </sect2>
1910
1911 <sect2 id="computeBugHistory">
1912 <title>computeBugHistory</title>
1913
1914 <para>このコマンドを使用することで、分析するソフトウェアの異なるビルドまたはバージョンの情報を含むバグデータベースを生成することができます入力として提供したファイルの 1 番目のファイルから履歴が取得されます。後に続くファイルは 1 バージョンのバグデータベースであるようにしてください (もし、履歴を持っていたとしても無視されます) 。</para>
1915 <para>デフォルトでは、結果は標準出力に送られます。</para>
1916
1917 <para>この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに <command>computeBugHistory</command> を taskdef で定義します :</para>
1918
1919 <programlisting>
1920 <![CDATA[
1921 <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
1922 <classpath refid="findbugs.lib" />
1923 </taskdef>
1924 ]]>
1925 </programlisting>
1926
1927 <para>この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 <literal>&lt;datafile&gt;</literal> 要素を入れ子にして入れてください。次に、例を示します:</para>
1928
1929 <programlisting>
1930 <![CDATA[
1931 <computeBugHistory home="${findbugs.home}" ...>
1932 <datafile name="analyze1.xml"/>
1933 <datafile name="analyze2.xml"/>
1934 </computeBugHistory>
1935 ]]>
1936 </programlisting>
1937
1938 <table id="computeBugHistoryTable">
1939 <title>computeBugHistory コマンドのオプション一覧</title>
1940 <tgroup cols="3" align="left">
1941 <thead>
1942 <row>
1943 <entry>コマンドラインオプション</entry>
1944 <entry>Ant 属性</entry>
1945 <entry>目的</entry>
1946 </row>
1947 </thead>
1948 <tbody>
1949 <row><entry>-output &lt;file&gt;</entry> <entry>output=&quot;&lt;file&gt;&quot;</entry> <entry>出力結果を保存するファイル名を指定します。 (同時に入力ファイルにもなりえます)</entry></row>
1950 <row><entry>-overrideRevisionNames[:truth]</entry> <entry>overrideRevisionNames=&quot;[true|false]&quot;</entry><entry>ファイル名から算出されるそれぞれのバージョン名を指定変更します。</entry></row>
1951 <row><entry>-noPackageMoves[:truth]</entry> <entry>noPackageMoves=&quot;[true|false]&quot;</entry><entry>パッケージを移動したクラスがある場合、当該クラスの警告は別の存在として扱われます。</entry></row>
1952 <row><entry>-preciseMatch[:truth]</entry> <entry>preciseMatch=&quot;[true|false]&quot;</entry><entry>バグパターンが正確に一致することを要求します。</entry></row>
1953 <row><entry>-precisePriorityMatch[:truth]</entry> <entry>precisePriorityMatch=&quot;[true|false]&quot;</entry><entry>優先度が正確に一致した場合のみ警告が同一であると判断されます。</entry></row>
1954 <row><entry>-quiet[:truth]</entry> <entry>quiet=&quot;[true|false]&quot;</entry><entry>エラーが発生しない限り、標準出力には何も表示されません。</entry></row>
1955 <row><entry>-withMessages[:truth]</entry> <entry>withMessages=&quot;[true|false]&quot;</entry><entry>出力 XML に人間が読むことができるバグメッセージが含まれます。</entry></row>
1956 </tbody>
1957 </tgroup>
1958 </table>
1959
1960 </sect2>
1961 <sect2 id="filterBugs">
1962 <title>filterBugs</title>
1963 <para>このコマンドを使用することで、 FindBugs XML 警告ファイルから一部分を選び出して新規 FindBugs 警告ファイルに選択された部分を書き込むことができます。</para>
1964 <para>このコマンドには、オプション群に続いて 0 個から 2 個の findbugs xml バグファイルを指定することができます。</para>
1965 <para>ファイル名をひとつも指定しない場合は、標準入力から読んで標準出力に出力されます。ファイル名を 1 個 指定した場合は、指定したファイルから読んで標準出力に出力されます。ファイル名を 2 個 指定した場合は、 1 番目に指定したファイルから読んで 2 番目に指定したファイルに出力されます。</para>
1966
1967 <para>この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに <command>filterBugs</command> を taskdef で定義します :</para>
1968
1969 <programlisting>
1970 <![CDATA[
1971 <taskdef name="filterBugs" classname="edu.umd.cs.findbugs.anttask.FilterBugsTask">
1972 <classpath refid="findbugs.lib" />
1973 </taskdef>
1974 ]]>
1975 </programlisting>
1976
1977 <para>この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 <literal>input</literal> 属性を使用するか、 <literal>&lt;datafile&gt;</literal> 要素を入れ子にして入れてください。次に、例を示します:</para>
1978
1979 <programlisting>
1980 <![CDATA[
1981 <filterBugs home="${findbugs.home}" ...>
1982 <datafile name="analyze.xml"/>
1983 </filterBugs>
1984 ]]>
1985 </programlisting>
1986
1987 <table id="filterOptionsTable">
1988 <title>filterBugs コマンドのオプション一覧</title>
1989 <tgroup cols="3" align="left">
1990 <thead>
1991 <row>
1992 <entry>コマンドラインオプション</entry>
1993 <entry>Ant 属性</entry>
1994 <entry>目的</entry>
1995 </row>
1996 </thead>
1997 <tbody>
1998 <row><entry/> <entry>input=&quot;&lt;file&gt;&quot;</entry> <entry>入力ファイルを指定します。</entry></row>
1999 <row><entry/> <entry>output=&quot;&lt;file&gt;&quot;</entry> <entry>出力ファイルを指定します。</entry></row>
2000 <row><entry>-not</entry> <entry>not=&quot;[true|false]&quot;</entry> <entry>フィルターのスイッチを反転します。</entry></row>
2001 <row><entry>-withSource[:truth]</entry> <entry>withSource=&quot;[true|false]&quot;</entry> <entry>ソースが入手可能な警告のみ出力されます。</entry></row>
2002 <row><entry>-exclude &lt;filter file&gt;</entry><entry>exclude=&quot;&lt;filter file&gt;&quot;</entry> <entry>フィルターに一致するバグが除外されます。</entry></row>
2003 <row><entry>-include &lt;filter file&gt;</entry><entry>include=&quot;&lt;filter file&gt;&quot;</entry> <entry>フィルターに一致するバグのみを含まれます。</entry></row>
2004 <row><entry>-annotation &lt;text&gt;</entry> <entry>annotation=&quot;&lt;text&gt;&quot;</entry> <entry>手で入力した注釈に指定した文言を含む警告のみ出力されます。</entry></row>
2005 <row><entry>-after &lt;when&gt;</entry> <entry>after=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンより後に初めて出現した警告のみ出力されます。</entry></row>
2006 <row><entry>-before &lt;when&gt;</entry> <entry>before=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンより前に初めて出現した警告のみ出力されます。</entry></row>
2007 <row><entry>-first &lt;when&gt;</entry> <entry>first=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンに初めて出現した警告のみ出力されます。</entry></row>
2008 <row><entry>-last &lt;when&gt;</entry> <entry>last=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンが出現した最後である警告のみ出力されます。</entry></row>
2009 <row><entry>-fixed &lt;when&gt;</entry> <entry>fixed=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンの前回のバージョンが出現した最後である警告のみ出力されます。 (<option>-last</option> に優先します)。</entry></row>
2010 <row><entry>-present &lt;when&gt;</entry> <entry>present=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンに存在する警告のみ出力されます。</entry></row>
2011 <row><entry>-absent &lt;when&gt;</entry> <entry>absent=&quot;&lt;when&gt;&quot;</entry> <entry>指定したバージョンに存在しない警告のみ出力されます。</entry></row>
2012 <row><entry>-active[:truth]</entry> <entry>active=&quot;[true|false]&quot;</entry> <entry>最終通番に存在する警告のみ出力されます。</entry></row>
2013 <row><entry>-introducedByChange[:truth]</entry> <entry>introducedByChange=&quot;[true|false]&quot;</entry><entry>存在するクラスの変更によってもたらされた警告のみ出力されます。</entry></row>
2014 <row><entry>-removedByChange[:truth]</entry> <entry>removedByChange=&quot;[true|false]&quot;</entry> <entry>存在するクラスの変更によって除去された警告のみ出力されます。</entry></row>
2015 <row><entry>-newCode[:truth]</entry> <entry>newCode=&quot;[true|false]&quot;</entry> <entry>新クラスの追加によってもたらされた警告のみ出力されます。</entry></row>
2016 <row><entry>-removedCode[:truth]</entry> <entry>removedCode=&quot;[true|false]&quot;</entry> <entry>クラスの削除によって除去された警告のみ出力されます。</entry></row>
2017 <row><entry>-priority &lt;level&gt;</entry> <entry>priority=&quot;&lt;level&gt;&quot;</entry> <entry>指定した優先度以上の優先度をもつ警告のみ出力されます。</entry></row>
2018 <row><entry>-class &lt;pattern&gt;</entry> <entry>class=&quot;&lt;class&gt;&quot;</entry> <entry>指定したパターンに一致する主クラスをもつ警告のみ出力されます。</entry></row>
2019 <row><entry>-bugPattern &lt;pattern&gt;</entry> <entry>bugPattern=&quot;&lt;pattern&gt;&quot;</entry> <entry>指定したパターンに一致するバグ種別をもつ警告のみ出力されます。</entry></row>
2020 <row><entry>-category &lt;category&gt;</entry> <entry>category=&quot;&lt;category&gt;&quot;</entry> <entry>指定した文字列で始まるカテゴリーの警告のみ出力されます。</entry></row>
2021 <row><entry>-designation &lt;designation&gt;</entry> <entry>designation=&quot;&lt;designation&gt;&quot;</entry> <entry>指定したバグ分類指定をもつ警告のみ出力されます。 (例、 -designation SHOULD_FIX)</entry></row>
2022 <row><entry>-withMessages[:truth] </entry> <entry>withMessages=&quot;[true|false]&quot;</entry> <entry>テキストメッセージを含んだ XML が生成されます。</entry></row>
2023 </tbody>
2024 </tgroup>
2025 </table>
2026
2027 </sect2>
2028
2029 <sect2 id="mineBugHistory">
2030 <title>mineBugHistory</title>
2031 <para>このコマンドを使用することで、複数バージョンバグデータベースの各バージョン毎の警告数を一覧にした表を作成することができます。</para>
2032
2033
2034 <para>この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに <command>mineBugHistory</command> を taskdef で定義します :</para>
2035
2036 <programlisting>
2037 <![CDATA[
2038 <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
2039 <classpath refid="findbugs.lib" />
2040 </taskdef>
2041 ]]>
2042 </programlisting>
2043
2044 <para>この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 <literal>input</literal> 属性を使用するか、 <literal>&lt;datafile&gt;</literal> 要素を入れ子にして入れてください。次に、例を示します:</para>
2045
2046 <programlisting>
2047 <![CDATA[
2048 <mineBugHistory home="${findbugs.home}" ...>
2049 <datafile name="analyze.xml"/>
2050 </mineBugHistory>
2051 ]]>
2052 </programlisting>
2053
2054 <table id="mineBugHistoryOptionsTable">
2055 <title>mineBugHistory コマンドのオプション一覧</title>
2056 <tgroup cols="3" align="left">
2057 <thead>
2058 <row>
2059 <entry>コマンドラインオプション</entry>
2060 <entry>Ant 属性</entry>
2061 <entry>目的</entry>
2062 </row>
2063 </thead>
2064 <tbody>
2065 <row><entry/> <entry>input=&quot;&lt;file&gt;&quot;</entry> <entry>入力ファイルを指定します。</entry></row>
2066 <row><entry/> <entry>output=&quot;&lt;file&gt;&quot;</entry> <entry>出力ファイルを指定します。</entry></row>
2067 <row><entry>-formatDates</entry> <entry>formatDates=&quot;[true|false]&quot;</entry> <entry>データがテキスト形式で描画されます。</entry></row>
2068 <row><entry>-noTabs</entry> <entry>noTabs=&quot;[true|false]&quot;</entry> <entry>タブの代わりに複数スペースでカラムが区切られます (下記参照)。</entry></row>
2069 <row><entry>-summary</entry> <entry>summary=&quot;[true|false]&quot;</entry> <entry>最新 10 件の変更の要約が出力されます。</entry></row>
2070 </tbody>
2071 </tgroup>
2072 </table>
2073
2074 <para><option>-noTabs</option> 出力を使うことで、固定幅フォントのシェルで読み易くなります。数値カラムは右寄せされるので、スペースがカラム値の前に挿入されます。また、このオプションを使用した場合、 <option>-formatDates</option> を指定したときに要約の日付を描画するのに空白が埋め込まれなくなります。</para>
2075
2076 <para>出力される表は、 (<option>-noTabs</option> が無ければ) タブ区切りで次に示すカラムから成ります :</para>
2077
2078 <table id="mineBugHistoryColumns">
2079 <title>mineBugHistory 出力のカラム一覧</title>
2080 <tgroup cols="2" align="left">
2081 <thead>
2082 <row>
2083 <entry>表題</entry>
2084 <entry>目的</entry>
2085 </row>
2086 </thead>
2087 <tbody>
2088 <row><entry>seq</entry><entry>シーケンス番号 (0 始まりの連続した整数値)</entry></row>
2089 <row><entry>version</entry><entry>バージョン名</entry></row>
2090 <row><entry>time</entry><entry>リリースされた日時</entry></row>
2091 <row><entry>classes</entry><entry>分析されたクラス数</entry></row>
2092 <row><entry>NCSS</entry><entry>コメント文を除いた命令数 (Non Commenting Source Statements)</entry></row>
2093 <row><entry>added</entry><entry>前回のバージョンに存在したクラスにおける新規警告数</entry></row>
2094 <row><entry>newCode</entry><entry>前回のバージョンに存在しなかったクラスにおける新規警告数</entry></row>
2095 <row><entry>fixed</entry><entry>現在のバージョンに存在するクラスにおける除去された警告数</entry></row>
2096 <row><entry>removed</entry><entry>現在のバージョンに存在しないクラスの前回のバージョンにおける警告数</entry></row>
2097 <row><entry>retained</entry><entry>現在のバージョンと前回のバージョンの両方に存在する警告の数</entry></row>
2098 <row><entry>dead</entry><entry>以前のバージョンに存在したが現在のバージョンにも直前のバージョンにも存在しない警告の数</entry></row>
2099 <row><entry>active</entry><entry>現在のバージョンに存在する警告総数</entry></row>
2100 </tbody>
2101 </tgroup>
2102 </table>
2103 </sect2>
2104
2105 <sect2 id="defectDensity">
2106 <title>defectDensity</title>
2107 <para>このコマンドを使用することで、プロジェクト全体およびクラス毎・パッケージ毎の不良密度 (1000 NCSS 毎の警告数) に関する情報を一覧表示できます。標準入力から読み込む場合はファイル指定なしで、そうでなければ、コマンドラインでファイルを指定して、このコマンドを実行します。</para>
2108 <para>出力される表は、次に示すカラムから成ります。また、プロジェクト全体情報の行、および、4 個以上の警告を含んでいる各パッケージ情報または各クラス情報の行も出力されます。</para>
2109 <table id="defectDensityColumns">
2110 <title>defectDensity 出力のカラム一覧</title>
2111 <tgroup cols="2" align="left">
2112 <thead>
2113 <row>
2114 <entry>表題</entry>
2115 <entry>目的</entry>
2116 </row>
2117 </thead>
2118 <tbody>
2119 <row><entry>kind</entry><entry>プロジェクト (project)、パッケージ (package) またはクラス (class)</entry></row>
2120 <row><entry>name</entry><entry>プロジェクト、パッケージまたはクラスの名前</entry></row>
2121 <row><entry>density</entry><entry> 1000 NCSS 毎の警告数</entry></row>
2122 <row><entry>bugs</entry><entry>警告数</entry></row>
2123 <row><entry>NCSS</entry><entry>コメント文を除いた命令数 (Non Commenting Source Statements) </entry></row>
2124 </tbody>
2125 </tgroup>
2126 </table>
2127 </sect2>
2128
2129 <sect2 id="convertXmlToText">
2130 <title>convertXmlToText</title>
2131
2132 <para>このコマンドを使用することで、XML 形式のバグ警告を、 1 行 1 バグのテキスト形式、または、HTML形式に変換することができます。</para>
2133
2134 <para>この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに <command>convertXmlToText</command> を taskdef で定義します :</para>
2135
2136 <programlisting>
2137 <![CDATA[
2138 <taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask">
2139 <classpath refid="findbugs.lib" />
2140 </taskdef>
2141 ]]>
2142 </programlisting>
2143
2144 <para>この ant タスクに指定できる属性を、下表に一覧で示します。</para>
2145
2146 <table id="convertXmlToTextTable">
2147 <title>convertXmlToText コマンドのオプション一覧</title>
2148 <tgroup cols="3" align="left">
2149 <thead>
2150 <row>
2151 <entry>コマンドラインオプション</entry>
2152 <entry>Ant 属性</entry>
2153 <entry>目的</entry>
2154 </row>
2155 </thead>
2156 <tbody>
2157 <row><entry/> <entry>input=&quot;&lt;filename&gt;&quot;</entry> <entry>入力ファイルを指定します。</entry></row>
2158 <row><entry/> <entry>output=&quot;&lt;filename&gt;&quot;</entry> <entry>出力ファイルを指定します。</entry></row>
2159 <row><entry>-longBugCodes</entry> <entry>longBugCodes=&quot;[true|false]&quot;</entry> <entry>2 文字のバグ略称の代わりに、省略なしのバグパターンコードを使用します。</entry></row>
2160 <row><entry/> <entry>format=&quot;text&quot;</entry> <entry>プレーンテキストの出力が作成されます。1 行につき 1 つのバグが出力されます。コマンドライン時のデフォルトです。</entry></row>
2161 <row><entry>-html[:stylesheet]</entry> <entry>format=&quot;html:&lt;stylesheet&gt;&quot;</entry> <entry>指定されたスタイルシートを使用して出力が作成されます (下記参照) 。省略した場合は、 default.xsl が使用されます。</entry></row>
2162 </tbody>
2163 </tgroup>
2164 </table>
2165
2166 <para>-html/format オプションには、plain.xsl 、 default.xsl 、 fancy.xsl 、 fancy-hist.xsl または ユーザ自身が作成した XSL スタイルシートのいずれかを指定することができます。オプション名をよそに、 html 以外の形式を出力するスタイルシートを指定することもできます。FindBugs に含まれているスタイルシート(上述)以外のスタイルシートを使用する場合は、オプション -html/format で当該スタイルシートへのパスまたは URL を指定してください。</para>
2167 </sect2>
2168
2169 <sect2 id="setBugDatabaseInfo">
2170 <title>setBugDatabaseInfo</title>
2171
2172 <para>このコマンドを使用することで、指定したバグ警告にメタ情報を設定することができます。このコマンドには次に示すオプションがあります:</para>
2173
2174 <para>この機能は、 ant からも使用することができます。まず次に示すように、ビルドファイルに <command>setBugDatabaseInfo</command> を taskdef で定義します :</para>
2175
2176 <programlisting>
2177 <![CDATA[
2178 <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
2179 <classpath refid="findbugs.lib" />
2180 </taskdef>
2181 ]]>
2182 </programlisting>
2183
2184 <para>この ant タスクに指定できる属性を、下表に一覧で示します。入力ファイルを指定するには、 <literal>input</literal> 属性を使用するか、 <literal>&lt;datafile&gt;</literal> 要素を入れ子にして入れてください。次に、例を示します:</para>
2185
2186 <programlisting>
2187 <![CDATA[
2188 <setBugDatabaseInfo home="${findbugs.home}" ...>
2189 <datafile name="analyze.xml"/>
2190 </setBugDatabaseInfo>
2191 ]]>
2192 </programlisting>
2193
2194 <table id="setBugDatabaseInfoOptions">
2195 <title>setBugDatabaseInfo オプション一覧</title>
2196 <tgroup cols="3" align="left">
2197 <thead>
2198 <row>
2199 <entry>コマンドラインオプション</entry>
2200 <entry>Ant 属性</entry>
2201 <entry>目的</entry>
2202 </row>
2203 </thead>
2204 <tbody>
2205 <row><entry/> <entry>input=&quot;&lt;file&gt;&quot;</entry> <entry>入力ファイルを指定します。</entry></row>
2206 <row><entry/> <entry>output=&quot;&lt;file&gt;&quot;</entry> <entry>出力ファイルを指定します。</entry></row>
2207 <row><entry>-name &lt;name&gt;</entry> <entry>name=&quot;&lt;name&gt;&quot;</entry> <entry>最新リビジョンの名前を設定します。</entry></row>
2208 <row><entry>-timestamp &lt;when&gt;</entry> <entry>timestamp=&quot;&lt;when&gt;&quot;</entry> <entry>最新リビジョンのタイム・スタンプを設定します。</entry></row>
2209 <row><entry>-source &lt;directory&gt;</entry> <entry>source=&quot;&lt;directory&gt;&quot;</entry> <entry>ソースを検索するディレクトリーを追加指定します。</entry></row>
2210 <row><entry>-findSource &lt;directory&gt;</entry> <entry>findSource=&quot;&lt;directory&gt;&quot;</entry> <entry>指定したディレクトリー内を検索して関連するソースの場所を追加します。</entry></row>
2211 <row><entry>-suppress &lt;filter file&gt;</entry> <entry>suppress=&quot;&lt;filter file&gt;&quot;</entry> <entry>指定したファイルに一致する警告を抑止します (以前に指定した抑止設定は置き換えられます)。</entry></row>
2212 <row><entry>-withMessages</entry> <entry>withMessages=&quot;[true|false]&quot;</entry> <entry>XMLにテキストメッセージを追加します。</entry></row>
2213 <row><entry>-resetSource</entry> <entry>resetSource=&quot;[true|false]&quot;</entry> <entry>ソース検索パスをすべて削除します。</entry></row>
2214 </tbody>
2215 </tgroup>
2216 </table>
2217 </sect2>
2218
2219 <sect2 id="listBugDatabaseInfo">
2220 <title>listBugDatabaseInfo</title>
2221
2222 <para>このコマンドの実行においては、コマンドラインで 0 個以上の xml バグデータベースファイル名を指定します。ファイル名を1つも指定しなければ、標準出力から読み込みを行いテーブルのヘッダーは生成されません。</para>
2223
2224 <para>このコマンドには 1 つだけオプションがあります : <option>-formatDates</option> を指定するとテキスト形式でデータが描画されます。</para>
2225
2226 <para>出力される表は、各バグデータベースごとに行を持ち、次に示すカラムから成ります :</para>
2227 <table id="listBugDatabaseInfoColumns">
2228 <title>listBugDatabaseInfo カラム一覧</title>
2229 <tgroup cols="2" align="left">
2230 <thead>
2231 <row>
2232 <entry>カラム</entry>
2233 <entry>目的</entry>
2234 </row>
2235 </thead>
2236 <tbody>
2237 <row><entry>version</entry><entry>バージョン名</entry></row>
2238 <row><entry>time</entry><entry>リリースされた日時</entry></row>
2239 <row><entry>classes</entry><entry>分析されたクラス数</entry></row>
2240 <row><entry>NCSS</entry><entry>コメント文を除いた命令数 (Non Commenting Source Statements)</entry></row>
2241 <row><entry>total</entry><entry>全警告数</entry></row>
2242 <row><entry>high</entry><entry>優先度(高)の警告の総数</entry></row>
2243 <row><entry>medium</entry><entry>優先度(中)の警告の総数</entry></row>
2244 <row><entry>low</entry><entry>優先度(低)の警告の総数</entry></row>
2245 <row><entry>filename</entry><entry>データベースのファイル名</entry></row>
2246 <!--
2247 <row><entry></entry><entry></entry></row>
2248 <row><entry></entry><entry></entry></row>
2249 <row><entry></entry><entry></entry></row>
2250 <row><entry></entry><entry></entry></row>
2251 <row><entry></entry><entry></entry></row>
2252 <row><entry></entry><entry></entry></row>
2253 -->
2254 </tbody>
2255 </tgroup>
2256 </table>
2257
2258 </sect2>
2259
2260 </sect1>
2261
2262 <sect1 id="examples">
2263 <title>例</title>
2264 <sect2 id="unixscriptsexamples">
2265 <title>提供されたシェル・スクリプトを使用しての履歴マイニング</title>
2266 <para>以下はすべて、 jdk1.6.0-b12, jdk1.6.0-b13, ..., jdk1.6.0-b60 のディレクトリに対してコマンドを実行しています。</para>
2267
2268 <para>以下のコマンドを実行してみます :</para>
2269 <screen>
2270 computeBugHistory jdk1.6.0-b* | filterBugs -bugPattern IL_ | mineBugHistory -formatDates
2271 </screen>
2272 <para>すると、次のような出力が行われます :</para>
2273
2274 <screen>
2275 seq version time classes NCSS added newCode fixed removed retained dead active
2276 0 jdk1.6.0-b12 &quot;Thu Nov 11 09:07:20 EST 2004&quot; 13128 811569 0 4 0 0 0 0 4
2277 1 jdk1.6.0-b13 &quot;Thu Nov 18 06:02:06 EST 2004&quot; 13128 811570 0 0 0 0 4 0 4
2278 2 jdk1.6.0-b14 &quot;Thu Dec 02 06:12:26 EST 2004&quot; 13145 811786 0 0 2 0 2 0 2
2279 3 jdk1.6.0-b15 &quot;Thu Dec 09 06:07:04 EST 2004&quot; 13174 811693 0 0 1 0 1 2 1
2280 4 jdk1.6.0-b16 &quot;Thu Dec 16 06:21:28 EST 2004&quot; 13175 811715 0 0 0 0 1 3 1
2281 5 jdk1.6.0-b17 &quot;Thu Dec 23 06:27:22 EST 2004&quot; 13176 811974 0 0 0 0 1 3 1
2282 6 jdk1.6.0-b19 &quot;Thu Jan 13 06:41:16 EST 2005&quot; 13176 812011 0 0 0 0 1 3 1
2283 7 jdk1.6.0-b21 &quot;Thu Jan 27 05:57:52 EST 2005&quot; 13177 812173 0 0 0 0 1 3 1
2284 8 jdk1.6.0-b23 &quot;Thu Feb 10 05:44:36 EST 2005&quot; 13179 812188 0 0 0 0 1 3 1
2285 9 jdk1.6.0-b26 &quot;Thu Mar 03 06:04:02 EST 2005&quot; 13199 811770 0 0 0 0 1 3 1
2286 10 jdk1.6.0-b27 &quot;Thu Mar 10 04:48:38 EST 2005&quot; 13189 812440 0 0 0 0 1 3 1
2287 11 jdk1.6.0-b28 &quot;Thu Mar 17 02:54:22 EST 2005&quot; 13185 812056 0 0 0 0 1 3 1
2288 12 jdk1.6.0-b29 &quot;Thu Mar 24 03:09:20 EST 2005&quot; 13117 809468 0 0 0 0 1 3 1
2289 13 jdk1.6.0-b30 &quot;Thu Mar 31 02:53:32 EST 2005&quot; 13118 809501 0 0 0 0 1 3 1
2290 14 jdk1.6.0-b31 &quot;Thu Apr 07 03:00:14 EDT 2005&quot; 13117 809572 0 0 0 0 1 3 1
2291 15 jdk1.6.0-b32 &quot;Thu Apr 14 02:56:56 EDT 2005&quot; 13169 811096 0 0 0 0 1 3 1
2292 16 jdk1.6.0-b33 &quot;Thu Apr 21 02:46:22 EDT 2005&quot; 13187 811942 0 0 0 0 1 3 1
2293 17 jdk1.6.0-b34 &quot;Thu Apr 28 02:49:00 EDT 2005&quot; 13195 813488 0 1 0 0 1 3 2
2294 18 jdk1.6.0-b35 &quot;Thu May 05 02:49:04 EDT 2005&quot; 13457 829837 0 0 0 0 2 3 2
2295 19 jdk1.6.0-b36 &quot;Thu May 12 02:59:46 EDT 2005&quot; 13462 831278 0 0 0 0 2 3 2
2296 20 jdk1.6.0-b37 &quot;Thu May 19 02:55:08 EDT 2005&quot; 13464 831971 0 0 0 0 2 3 2
2297 21 jdk1.6.0-b38 &quot;Thu May 26 03:08:16 EDT 2005&quot; 13564 836565 0 0 0 0 2 3 2
2298 22 jdk1.6.0-b39 &quot;Fri Jun 03 03:10:48 EDT 2005&quot; 13856 849992 0 1 0 0 2 3 3
2299 23 jdk1.6.0-b40 &quot;Thu Jun 09 03:30:28 EDT 2005&quot; 15972 959619 0 2 0 0 3 3 5
2300 24 jdk1.6.0-b41 &quot;Thu Jun 16 03:19:22 EDT 2005&quot; 15972 959619 0 0 0 0 5 3 5
2301 25 jdk1.6.0-b42 &quot;Fri Jun 24 03:38:54 EDT 2005&quot; 15966 958581 0 0 0 0 5 3 5
2302 26 jdk1.6.0-b43 &quot;Thu Jul 14 03:09:34 EDT 2005&quot; 16041 960544 0 0 0 0 5 3 5
2303 27 jdk1.6.0-b44 &quot;Thu Jul 21 03:05:54 EDT 2005&quot; 16041 960547 0 0 0 0 5 3 5
2304 28 jdk1.6.0-b45 &quot;Thu Jul 28 03:26:10 EDT 2005&quot; 16037 960606 0 0 1 0 4 3 4
2305 29 jdk1.6.0-b46 &quot;Thu Aug 04 03:02:48 EDT 2005&quot; 15936 951355 0 0 0 0 4 4 4
2306 30 jdk1.6.0-b47 &quot;Thu Aug 11 03:18:56 EDT 2005&quot; 15964 952387 0 0 1 0 3 4 3
2307 31 jdk1.6.0-b48 &quot;Thu Aug 18 08:10:40 EDT 2005&quot; 15970 953421 0 0 0 0 3 5 3
2308 32 jdk1.6.0-b49 &quot;Thu Aug 25 03:24:38 EDT 2005&quot; 16048 958940 0 0 0 0 3 5 3
2309 33 jdk1.6.0-b50 &quot;Thu Sep 01 01:52:40 EDT 2005&quot; 16287 974937 1 0 0 0 3 5 4
2310 34 jdk1.6.0-b51 &quot;Thu Sep 08 01:55:36 EDT 2005&quot; 16362 979377 0 0 0 0 4 5 4
2311 35 jdk1.6.0-b52 &quot;Thu Sep 15 02:04:08 EDT 2005&quot; 16477 979399 0 0 0 0 4 5 4
2312 36 jdk1.6.0-b53 &quot;Thu Sep 22 02:00:28 EDT 2005&quot; 16019 957900 0 0 1 0 3 5 3
2313 37 jdk1.6.0-b54 &quot;Thu Sep 29 01:54:34 EDT 2005&quot; 16019 957900 0 0 0 0 3 6 3
2314 38 jdk1.6.0-b55 &quot;Thu Oct 06 01:54:14 EDT 2005&quot; 16051 959014 0 0 0 0 3 6 3
2315 39 jdk1.6.0-b56 &quot;Thu Oct 13 01:54:12 EDT 2005&quot; 16211 970835 0 0 0 0 3 6 3
2316 40 jdk1.6.0-b57 &quot;Thu Oct 20 01:55:26 EDT 2005&quot; 16279 971627 0 0 0 0 3 6 3
2317 41 jdk1.6.0-b58 &quot;Thu Oct 27 01:56:30 EDT 2005&quot; 16283 971945 0 0 0 0 3 6 3
2318 42 jdk1.6.0-b59 &quot;Thu Nov 03 01:56:58 EST 2005&quot; 16232 972193 0 0 0 0 3 6 3
2319 43 jdk1.6.0-b60 &quot;Thu Nov 10 01:54:18 EST 2005&quot; 16235 972346 0 0 0 0 3 6 3
2320 </screen>
2321
2322 <para>次に示すコマンドを実行すると、db.xml 中間ファイルを生成することなく直接同じ情報を作成できます。</para>
2323
2324 <screen>
2325 computeBugHistory jdk1.6.0-b*/jre/lib/rt.xml | filterBugs -bugPattern IL_ db.xml | mineBugHistory -formatDates
2326 </screen>
2327
2328 <para>この情報を使って、 Sun JDK1.6.0 の各ビルドにおいて FindBugs によって発見された無限再起ループの数を表すグラフを表示します。青色の領域は、当該ビルドにおける無限再起ループの数を表しています。その上に描かれている赤色の領域は、以前のバージョンには存在したが当該バージョンでは除去された無限再起ループの数を表しています。 (したがって、赤色の領域と青色の領域を足し合わせた高さは決して減少しないことが保証されています。そして、新たに無限再起ループのバグが持ち込まれた時点で増加します) 。赤色の領域の高さは、当該バージョンにおいて修正または削除されたバグ数の合計で算出されます。バージョン 13 および 14 において見られる減少は、 FindBugs を使用して見つかった JDK のバグの報告を Sun が受け取ったことによるものです。</para>
2329 <mediaobject>
2330 <imageobject>
2331 <imagedata fileref="infiniteRecursiveLoops.png"/>
2332 </imageobject>
2333 </mediaobject>
2334
2335 <para>db.xml ファイルは、 jdk1.6.0 のすべてのビルドに対する検索結果を保持しています。したがって、次に示すコマンドを実行することで、優先度(高)または優先度(低)の正確性に関する警告の履歴が表示されます :</para>
2336
2337 <screen>
2338 filterBugs -priority M -category C db.xml | mineBugHistory -formatDates
2339 </screen>
2340
2341 <para>作成される表の例 :</para>
2342
2343 <screen>
2344 seq version time classes NCSS added newCode fixed removed retained dead active
2345 0 jdk1.6.0-b12 &quot;Thu Nov 11 09:07:20 EST 2004&quot; 13128 811569 0 1075 0 0 0 0 1075
2346 1 jdk1.6.0-b13 &quot;Thu Nov 18 06:02:06 EST 2004&quot; 13128 811570 0 0 0 0 1075 0 1075
2347 2 jdk1.6.0-b14 &quot;Thu Dec 02 06:12:26 EST 2004&quot; 13145 811786 3 0 6 0 1069 0 1072
2348 3 jdk1.6.0-b15 &quot;Thu Dec 09 06:07:04 EST 2004&quot; 13174 811693 2 1 3 0 1069 6 1072
2349 4 jdk1.6.0-b16 &quot;Thu Dec 16 06:21:28 EST 2004&quot; 13175 811715 0 0 1 0 1071 9 1071
2350 5 jdk1.6.0-b17 &quot;Thu Dec 23 06:27:22 EST 2004&quot; 13176 811974 0 0 1 0 1070 10 1070
2351 6 jdk1.6.0-b19 &quot;Thu Jan 13 06:41:16 EST 2005&quot; 13176 812011 0 0 0 0 1070 11 1070
2352 7 jdk1.6.0-b21 &quot;Thu Jan 27 05:57:52 EST 2005&quot; 13177 812173 0 0 1 0 1069 11 1069
2353 8 jdk1.6.0-b23 &quot;Thu Feb 10 05:44:36 EST 2005&quot; 13179 812188 0 0 0 0 1069 12 1069
2354 9 jdk1.6.0-b26 &quot;Thu Mar 03 06:04:02 EST 2005&quot; 13199 811770 0 0 2 1 1066 12 1066
2355 10 jdk1.6.0-b27 &quot;Thu Mar 10 04:48:38 EST 2005&quot; 13189 812440 1 0 1 1 1064 15 1065
2356 11 jdk1.6.0-b28 &quot;Thu Mar 17 02:54:22 EST 2005&quot; 13185 812056 0 0 0 0 1065 17 1065
2357 12 jdk1.6.0-b29 &quot;Thu Mar 24 03:09:20 EST 2005&quot; 13117 809468 3 0 8 26 1031 17 1034
2358 13 jdk1.6.0-b30 &quot;Thu Mar 31 02:53:32 EST 2005&quot; 13118 809501 0 0 0 0 1034 51 1034
2359 14 jdk1.6.0-b31 &quot;Thu Apr 07 03:00:14 EDT 2005&quot; 13117 809572 0 0 0 0 1034 51 1034
2360 15 jdk1.6.0-b32 &quot;Thu Apr 14 02:56:56 EDT 2005&quot; 13169 811096 1 1 0 1 1033 51 1035
2361 16 jdk1.6.0-b33 &quot;Thu Apr 21 02:46:22 EDT 2005&quot; 13187 811942 3 0 2 1 1032 52 1035
2362 17 jdk1.6.0-b34 &quot;Thu Apr 28 02:49:00 EDT 2005&quot; 13195 813488 0 1 0 0 1035 55 1036
2363 18 jdk1.6.0-b35 &quot;Thu May 05 02:49:04 EDT 2005&quot; 13457 829837 0 36 2 0 1034 55 1070
2364 19 jdk1.6.0-b36 &quot;Thu May 12 02:59:46 EDT 2005&quot; 13462 831278 0 0 0 0 1070 57 1070
2365 20 jdk1.6.0-b37 &quot;Thu May 19 02:55:08 EDT 2005&quot; 13464 831971 0 1 1 0 1069 57 1070
2366 21 jdk1.6.0-b38 &quot;Thu May 26 03:08:16 EDT 2005&quot; 13564 836565 1 7 2 6 1062 58 1070
2367 22 jdk1.6.0-b39 &quot;Fri Jun 03 03:10:48 EDT 2005&quot; 13856 849992 6 39 5 0 1065 66 1110
2368 23 jdk1.6.0-b40 &quot;Thu Jun 09 03:30:28 EDT 2005&quot; 15972 959619 7 147 11 0 1099 71 1253
2369 24 jdk1.6.0-b41 &quot;Thu Jun 16 03:19:22 EDT 2005&quot; 15972 959619 0 0 0 0 1253 82 1253
2370 25 jdk1.6.0-b42 &quot;Fri Jun 24 03:38:54 EDT 2005&quot; 15966 958581 3 0 1 2 1250 82 1253
2371 26 jdk1.6.0-b43 &quot;Thu Jul 14 03:09:34 EDT 2005&quot; 16041 960544 5 11 15 8 1230 85 1246
2372 27 jdk1.6.0-b44 &quot;Thu Jul 21 03:05:54 EDT 2005&quot; 16041 960547 0 0 0 0 1246 108 1246
2373 28 jdk1.6.0-b45 &quot;Thu Jul 28 03:26:10 EDT 2005&quot; 16037 960606 19 0 2 0 1244 108 1263
2374 29 jdk1.6.0-b46 &quot;Thu Aug 04 03:02:48 EDT 2005&quot; 15936 951355 13 1 1 32 1230 110 1244
2375 30 jdk1.6.0-b47 &quot;Thu Aug 11 03:18:56 EDT 2005&quot; 15964 952387 163 8 7 20 1217 143 1388
2376 31 jdk1.6.0-b48 &quot;Thu Aug 18 08:10:40 EDT 2005&quot; 15970 953421 0 0 0 0 1388 170 1388
2377 32 jdk1.6.0-b49 &quot;Thu Aug 25 03:24:38 EDT 2005&quot; 16048 958940 1 11 1 0 1387 170 1399
2378 33 jdk1.6.0-b50 &quot;Thu Sep 01 01:52:40 EDT 2005&quot; 16287 974937 19 27 16 7 1376 171 1422
2379 34 jdk1.6.0-b51 &quot;Thu Sep 08 01:55:36 EDT 2005&quot; 16362 979377 1 15 3 0 1419 194 1435
2380 35 jdk1.6.0-b52 &quot;Thu Sep 15 02:04:08 EDT 2005&quot; 16477 979399 0 0 1 1 1433 197 1433
2381 36 jdk1.6.0-b53 &quot;Thu Sep 22 02:00:28 EDT 2005&quot; 16019 957900 13 12 16 20 1397 199 1422
2382 37 jdk1.6.0-b54 &quot;Thu Sep 29 01:54:34 EDT 2005&quot; 16019 957900 0 0 0 0 1422 235 1422
2383 38 jdk1.6.0-b55 &quot;Thu Oct 06 01:54:14 EDT 2005&quot; 16051 959014 1 4 7 0 1415 235 1420
2384 39 jdk1.6.0-b56 &quot;Thu Oct 13 01:54:12 EDT 2005&quot; 16211 970835 6 8 37 0 1383 242 1397
2385 40 jdk1.6.0-b57 &quot;Thu Oct 20 01:55:26 EDT 2005&quot; 16279 971627 0 0 0 0 1397 279 1397
2386 41 jdk1.6.0-b58 &quot;Thu Oct 27 01:56:30 EDT 2005&quot; 16283 971945 0 1 1 0 1396 279 1397
2387 42 jdk1.6.0-b59 &quot;Thu Nov 03 01:56:58 EST 2005&quot; 16232 972193 6 0 5 0 1392 280 1398
2388 43 jdk1.6.0-b60 &quot;Thu Nov 10 01:54:18 EST 2005&quot; 16235 972346 0 0 0 0 1398 285 1398
2389 44 jdk1.6.0-b61 &quot;Thu Nov 17 01:58:42 EST 2005&quot; 16202 971134 2 0 4 0 1394 285 1396
2390 </screen>
2391 </sect2>
2392
2393 <sect2 id="incrementalhistory">
2394 <title>増分履歴メンテナンス</title>
2395
2396 <para>仮に、 db.xml がビルド b12 - b60 に対する findbugs 実行結果を保持している場合、次に示すコマンドを実行することで、 db.xml に b61 に対する実行結果を追加することができます :</para>
2397 <screen>
2398 computeBugHistory -output db.xml db.xml jdk1.6.0-b61/jre/lib/rt.xml
2399 </screen>
2400 </sect2>
2401
2402 </sect1>
2403
2404 <sect1 id="antexample">
2405 <title>Ant の例</title>
2406 <para>findbugs の実行とその後のデータ・マイニングツールの活用の両方を実行している ant スクリプトの完全な例を以下に示します :</para>
2407 <screen>
2408 <![CDATA[
2409 <project name="analyze_asm_util" default="findbugs">
2410 <!-- findbugs タスク定義 -->
2411 <property name="findbugs.home" value="/Users/ben/Documents/workspace/findbugs/findbugs" />
2412 <property name="jvmargs" value="-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN -Dfindbugs.home=${findbugs.home}" />
2413
2414 <path id="findbugs.lib">
2415 <fileset dir="${findbugs.home}/lib">
2416 <include name="findbugs-ant.jar"/>
2417 </fileset>
2418 </path>
2419
2420 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
2421 <classpath refid="findbugs.lib" />
2422 </taskdef>
2423
2424 <taskdef name="computeBugHistory" classname="edu.umd.cs.findbugs.anttask.ComputeBugHistoryTask">
2425 <classpath refid="findbugs.lib" />
2426 </taskdef>
2427
2428 <taskdef name="setBugDatabaseInfo" classname="edu.umd.cs.findbugs.anttask.SetBugDatabaseInfoTask">
2429 <classpath refid="findbugs.lib" />
2430 </taskdef>
2431
2432 <taskdef name="mineBugHistory" classname="edu.umd.cs.findbugs.anttask.MineBugHistoryTask">
2433 <classpath refid="findbugs.lib" />
2434 </taskdef>
2435
2436 <!-- findbugs タスク定義 -->
2437 <target name="findbugs">
2438 <antcall target="analyze" />
2439 <antcall target="mine" />
2440 </target>
2441
2442 <!-- 分析を行うタスク-->
2443 <target name="analyze">
2444 <!-- asm-util に対して findbugs を実行する -->
2445 <findbugs home="${findbugs.home}"
2446 output="xml:withMessages"
2447 timeout="90000000"
2448 reportLevel="experimental"
2449 workHard="true"
2450 effort="max"
2451 adjustExperimental="true"
2452 jvmargs="${jvmargs}"
2453 failOnError="true"
2454 outputFile="out.xml"
2455 projectName="Findbugs"
2456 debug="false">
2457 <class location="asm-util-3.0.jar" />
2458 </findbugs>
2459 </target>
2460
2461 <target name="mine">
2462
2463 <!-- 最新の分析結果に情報を設定する -->
2464 <setBugDatabaseInfo home="${findbugs.home}"
2465 withMessages="true"
2466 name="asm-util-3.0.jar"
2467 input="out.xml"
2468 output="out-rel.xml"/>
2469
2470 <!-- 履歴ファイル (out-hist.xml) が既に存在するかどうかを確認する -->
2471 <condition property="mining.historyfile.available">
2472 <available file="out-hist.xml"/>
2473 </condition>
2474 <condition property="mining.historyfile.notavailable">
2475 <not>
2476 <available file="out-hist.xml"/>
2477 </not>
2478 </condition>
2479
2480 <!-- このターゲットは、履歴ファイルが存在しないとき (初回) だけ実行されます -->
2481 <antcall target="history-init">
2482 <param name="data.file" value="out-rel.xml" />
2483 <param name="hist.file" value="out-hist.xml" />
2484 </antcall>
2485 <!-- 上記以外の場合に実行されます -->
2486 <antcall target="history">
2487 <param name="data.file" value="out-rel.xml" />
2488 <param name="hist.file" value="out-hist.xml" />
2489 <param name="hist.summary.file" value="out-hist.txt" />
2490 </antcall>
2491 </target>
2492
2493 <!-- 履歴ファイルを初期化します -->
2494 <target name="history-init" if="mining.historyfile.notavailable">
2495 <copy file="${data.file}" tofile="${hist.file}" />
2496 </target>
2497
2498 <!-- バグ履歴を算出します -->
2499 <target name="history" if="mining.historyfile.available">
2500 <!-- ${data.file} を ${hist.file} にマージします -->
2501 <computeBugHistory home="${findbugs.home}"
2502 withMessages="true"
2503 output="${hist.file}">
2504 <dataFile name="${hist.file}"/>
2505 <dataFile name="${data.file}"/>
2506 </computeBugHistory>
2507
2508 <!-- 履歴を算出して ${hist.summary.file} に出力します -->
2509 <mineBugHistory home="${findbugs.home}"
2510 formatDates="true"
2511 noTabs="true"
2512 input="${hist.file}"
2513 output="${hist.summary.file}"/>
2514 </target>
2515
2516 </project>
2517 ]]>
2518 </screen>
2519 </sect1>
2520 </chapter>
2521
2522
2523 <!--
2524 **************************************************************************
2525 License
2526 **************************************************************************
2527 -->
2528
2529 <chapter id="license">
2530 <title>ライセンス</title>
2531
2532 <para>名称「FindBugs」および FindBugs のロゴは、メリーランド大学の登録商標です。FindBugs はフリーソフトウェアであり、 <ulink url="http://www.gnu.org/licenses/lgpl.html">Lesser GNU Public License</ulink> の条件で配布されています。使用承諾書を入手したい場合は、 &FindBugs; 配布物に含まれる <filename>LICENSE.txt</filename> ファイルを参照してください。</para>
2533
2534 <para>最新バージョンの FindBugs および そのソースコードは <ulink url="http://findbugs.sourceforge.net">FindBugs web ページ</ulink> で入手できます。</para>
2535
2536 </chapter>
2537
2538
2539 <!--
2540 **************************************************************************
2541 Acknowledgments
2542 **************************************************************************
2543 -->
2544 <chapter id="acknowledgments">
2545 <title>謝辞</title>
2546
2547 <sect1>
2548 <title>貢献者</title>
2549
2550 <para>&FindBugs; was originally written by Bill Pugh (<email>pugh@cs.umd.edu</email>).
2551 David Hovemeyer (<email>daveho@cs.umd.edu</email>) implemented some of the
2552 detectors, added the Swing GUI, and is a co-maintainer.</para>
2553
2554 <para>Mike Fagan (<email>mfagan@tde.com</email>) contributed the &Ant; build script,
2555 the &Ant; task, and several enhancements and bug fixes to the GUI.</para>
2556
2557 <para>Germano Leichsenring contributed Japanese translations of the bug
2558 summaries.</para>
2559
2560 <para>David Li contributed the Emacs bug report format.</para>
2561
2562 <para>Peter D. Stout contributed recursive detection of Class-Path
2563 attributes in analyzed Jar files, German translations of
2564 text used in the Swing GUI, and other fixes.</para>
2565
2566 <para>Peter Friese wrote the &FindBugs; Eclipse plugin.</para>
2567
2568 <para>Rohan Lloyd contributed several Mac OS X enhancements,
2569 bug detector improvements,
2570 and maintains the Fink package for &FindBugs;.</para>
2571
2572 <para>Hiroshi Okugawa translated the &FindBugs; manual and
2573 more of the bug summaries into Japanese.</para>
2574
2575 <para>Phil Crosby enhanced the Eclipse plugin to add a view
2576 to display the bug details.</para>
2577
2578 <para>Dave Brosius fixed a number of bugs, added user preferences
2579 to the Swing GUI, improved several bug detectors, and
2580 contributed the string concatenation detector.</para>
2581
2582 <para>Thomas Klaeger contributed a number of bug fixes and
2583 bug detector improvements.</para>
2584
2585 <para>Andrei Loskutov made a number of improvements to the
2586 Eclipse plugin.</para>
2587
2588 <para>Brian Goetz contributed a major refactoring of the
2589 visitor classes to improve readability and understandability.</para>
2590
2591 <para> Pete Angstadt fixed several problems in the Swing GUI.</para>
2592
2593 <para>Francis Lalonde provided a task resource file for the
2594 FindBugs Ant task.</para>
2595
2596 <para>Garvin LeClaire contributed support for output in
2597 Xdocs format, for use by Maven.</para>
2598
2599 <para>Holger Stenzhorn contributed improved German translations of items
2600 in the Swing GUI.</para>
2601
2602 <para>Juha Knuutila contributed Finnish translations of items
2603 in the Swing GUI.</para>
2604
2605 <para>Tanel Lebedev contributed Estonian translations of items
2606 in the Swing GUI.</para>
2607
2608 <para>Hanai Shisei (ruimo) contributed full Japanese translations of
2609 bug messages, and text used in the Swing GUI.</para>
2610
2611 <para>David Cotton contributed Fresh translations for bug
2612 messages and for the Swing GUI.</para>
2613
2614 <para>Michael Tamm contributed support for the &quot;errorProperty&quot; attribute
2615 in the Ant task.</para>
2616
2617 <para>Thomas Kuehne improved the German translation of the Swing GUI.</para>
2618
2619 <para>Len Trigg improved source file support for the Emacs output mode.</para>
2620
2621 <para>Greg Bentz provided a fix for the hashcode/equals detector.</para>
2622
2623 <para>K. Hashimoto contributed internationalization fixes and several other
2624 bug fixes.</para>
2625
2626 <para>
2627 Glenn Boysko contributed support for ignoring specified local
2628 variables in the dead local store detector.
2629 </para>
2630
2631 <para>
2632 Jay Dunning contributed a detector to find equality comparisons
2633 of floating-point values, and overhauled the analysis summary
2634 report and its representation in the saved XML format.
2635 </para>
2636
2637 <para>
2638 Olivier Parent contributed updated French translations for bug descriptions and
2639 Swing GUI.
2640 </para>
2641
2642 <para>
2643 Chris Nappin contributed the <filename>plain.xsl</filename>
2644 stylesheet.
2645 </para>
2646
2647 <para>
2648 Etienne Giraudy contributed the <filename>fancy.xsl</filename> and <filename>fancy-hist.xsl</filename>
2649 stylesheets, and made improvements to the <command>-xml:withMessages</command>
2650 option.
2651 </para>
2652
2653 <para>
2654 Takashi Okamoto fixed bugs in the project preferences dialog
2655 in the Eclipse plugin, and contributed to its internationalization and localization.
2656 </para>
2657
2658 <para>Thomas Einwaller fixed bugs in the project preferences dialog in the Eclipse plugin.</para>
2659
2660 <para>Jeff Knox contributed support for the warningsProperty attribute
2661 in the Ant task.</para>
2662
2663 <para>Peter Hendriks extended the Eclipse plugin preferences,
2664 and fixed a bug related to renaming the Eclipse plugin ID.</para>
2665
2666 <para>Mark McKay contributed an Ant task to launch the findbugs frame.</para>
2667
2668 <para>Dieter von Holten (dvholten) contributed
2669 some German improvements to findbugs_de.properties.</para>
2670
2671
2672 <para>If you have contributed to &FindBugs;, but aren't mentioned above,
2673 please send email to <email>findbugs@cs.umd.edu</email> (and also accept
2674 our humble apologies).</para>
2675
2676 </sect1>
2677
2678 <sect1>
2679 <title>使用しているソフトウェア</title>
2680
2681 <para>&FindBugs; は、いくつかのオープンソースソフトウェアパッケージを使用しています。これらがなければ、 &FindBugs; の開発は、より一層困難なものになったことでしょう。</para>
2682
2683 <sect2>
2684 <title>BCEL</title>
2685 <para>&FindBugs; includes software developed by the Apache Software Foundation
2686 (<ulink url="http://www.apache.org/">http://www.apache.org/</ulink>).
2687 Specifically, it uses the <ulink url="http://jakarta.apache.org/bcel/">Byte Code
2688 Engineering Library</ulink>.</para>
2689 </sect2>
2690
2691 <sect2>
2692 <title>ASM</title>
2693 <para>&FindBugs; uses the <ulink url="http://asm.objectweb.org/">ASM</ulink>
2694 bytecode framework, which is distributed under the following license:</para>
2695
2696 <blockquote>
2697 <para>
2698 Copyright (c) 2000-2005 INRIA, France Telecom
2699 All rights reserved.
2700 </para>
2701
2702 <para>
2703 Redistribution and use in source and binary forms, with or without
2704 modification, are permitted provided that the following conditions
2705 are met:
2706 </para>
2707
2708 <orderedlist numeration="arabic">
2709 <listitem><para>
2710 Redistributions of source code must retain the above copyright
2711 notice, this list of conditions and the following disclaimer.
2712 </para></listitem>
2713 <listitem><para>
2714 Redistributions in binary form must reproduce the above copyright
2715 notice, this list of conditions and the following disclaimer in the
2716 documentation and/or other materials provided with the distribution.
2717 </para></listitem>
2718 <listitem><para>
2719 Neither the name of the copyright holders nor the names of its
2720 contributors may be used to endorse or promote products derived from
2721 this software without specific prior written permission.
2722 </para></listitem>
2723 </orderedlist>
2724
2725 <para>
2726 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
2727 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2728 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2729 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2730 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2731 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2732 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2733 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2734 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2735 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2736 THE POSSIBILITY OF SUCH DAMAGE.
2737 </para>
2738 </blockquote>
2739 </sect2>
2740
2741 <sect2>
2742 <title>DOM4J</title>
2743 <para>&FindBugs; uses <ulink url="http://dom4j.org">DOM4J</ulink>, which is
2744 distributed under the following license:</para>
2745
2746 <blockquote>
2747 <para>
2748 Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
2749 </para>
2750
2751 <para>
2752 Redistribution and use of this software and associated documentation
2753 (&quot;Software&quot;), with or without modification, are permitted provided that
2754 the following conditions are met:
2755 </para>
2756
2757 <orderedlist numeration="arabic">
2758 <listitem><para>
2759 Redistributions of source code must retain copyright statements and
2760 notices. Redistributions must also contain a copy of this document.
2761 </para></listitem>
2762 <listitem><para>
2763 Redistributions in binary form must reproduce the above copyright
2764 notice, this list of conditions and the following disclaimer in the
2765 documentation and/or other materials provided with the distribution.
2766 </para></listitem>
2767 <listitem><para>
2768 The name &quot;DOM4J&quot; must not be used to endorse or promote products
2769 derived from this Software without prior written permission
2770 of MetaStuff, Ltd. For written permission, please contact
2771 <email>dom4j-info@metastuff.com</email>.
2772 </para></listitem>
2773 <listitem><para>
2774 Products derived from this Software may not be called &quot;DOM4J&quot; nor may
2775 &quot;DOM4J&quot; appear in their names without prior written permission of
2776 MetaStuff, Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
2777 </para></listitem>
2778 <listitem><para>
2779 Due credit should be given to the DOM4J Project (<ulink url="http://dom4j.org/">http://dom4j.org/</ulink>).
2780 </para></listitem>
2781 </orderedlist>
2782
2783 <para>
2784 THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS''
2785 AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2786 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2787 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS
2788 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2789 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2790 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2791 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2792 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2793 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2794 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2795 </para>
2796 </blockquote>
2797
2798 </sect2>
2799
2800 </sect1>
2801
2802 </chapter>
2803
2804
2805 </book>
0 <html>
1 <head>
2 <title>FindBugs Performance Improvements and Regressions</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%">
9 <tr>
10
11
12 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
13 <table width="100%" cellspacing="0" border="0">
14 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
15
16 <tr><td>&nbsp;</td></tr>
17
18 <tr><td><b>Docs and Info</b></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
31
32 <tr><td>&nbsp;</td></tr>
33
34 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
35
36 <tr><td>&nbsp;</td></tr>
37
38 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
39
40 <tr><td>&nbsp;</td></tr>
41
42 <tr><td><b>Development</b></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
52 </table>
53 </td>
54
55 <td align="left" valign="top">
56
57 <h1>FindBugs Performance Improvements and Regressions</h1> I did a performance check against 179
58 benchmarks applications I regularly test against. Overall (total the total time to analyze all 179
59 benchmarks), FindBugs 2.0 gives a 9% performance improvement over 1.3.9. 154 of the 179 benchmarks saw
60 performance improvements; 24 saw regressions. All of the benchmarks that saw regressions of more than
61 10% were small benchmarks (analyzed in less than 60 seconds), which makes consistent benchmarking
62 particularly difficult. I'm working to repeat the benchmarks, see if the results are consistent. I took
63 a look, and couldn't find anything that stood out as being a performance glitch in FindBugs. I haven't
64 yet done benchmarking with constrained memory. It is possible that you may need to increase the heap
65 size for FindBugs 2.0.
66
67 <h2>Important Request</h2>
68 <p> If you are seeing any significant performance regressions in FindBugs 2.0,
69 I very much need your help. Please either email <a href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
70 or file <a href="http://sourceforge.net/tracker/?atid=614693&amp;group_id=96405&amp;func=browse">a
71 bug report</a>.&nbsp;with the following information from the xml file for your project (from both the
72 1.3.9 and 2.0.0 version if possible). Sending me your code or pointing me to a open source repository
73 would be great, but I know that isn't feasible for a lot of projects. The information I'm requesting
74 doesn't include any information about the code being analyzed other than the total size of the code
75 being analyzed and the total number of issues found at the different confidence levels. The
76 &lt;FindBugsSummary ... &gt; start tag. For example: <quote> <pre>
77 &lt;FindBugsSummary timestamp="Tue, 30 Dec 2008 21:29:52 -0500"
78 total_classes="206" referenced_classes="325" total_bugs="72" total_size="7654" num_packages="21"
79 vm_version="20.4-b02-402" cpu_seconds="62.52" clock_seconds="22.01"
80 peak_mbytes="112.21" alloc_mbytes="1683.38" gc_seconds="1.19"
81 priority_3="56" priority_2="14" priority_1="2"&gt;
82 </pre> </quote> The &lt;FindBugsProfile&gt;...&lt;/FindBugsProfile&gt; element. For example: <quote>
83 <pre>
84 &lt;FindBugsProfile&gt;
85 &lt;ClassProfile name="edu.umd.cs.findbugs.detect.IncompatMask" totalMilliseconds="11"
86 invocations="206" avgMicrosecondsPerInvocation="55" maxMicrosecondsPerInvocation="475"
87 standardDeviationMircosecondsPerInvocation="75"/&gt;
88 &lt;ClassProfile name="edu.umd.cs.findbugs.detect.FindFinalizeInvocations" totalMilliseconds="11"
89 invocations="206" avgMicrosecondsPerInvocation="55" maxMicrosecondsPerInvocation="402"
90 standardDeviationMircosecondsPerInvocation="69"/&gt;
91 &lt;ClassProfile name="edu.umd.cs.findbugs.classfile.engine.bcel.LockDataflowFactory" totalMilliseconds="11"
92 invocations="23" avgMicrosecondsPerInvocation="515" maxMicrosecondsPerInvocation="2637"
93 standardDeviationMircosecondsPerInvocation="639"/&gt;
94 ...
95 &lt;/FindBugsProfile&gt;
96 </pre> </quote>
97 <hr> <p>
98 <script language="JavaScript" type="text/javascript">
99 <!---//hide script from old browsers
100 document.write( "Last updated "+ document.lastModified + "." );
101 //end hiding contents --->
102 </script>
103 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
104 <p>
105 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
106
107 </td>
108
109 </tr>
110 </table>
111
112 </body>
113 </html>
0 Create a directory that contains exactly all the files to upload. For example:
1 eclipsePlugin-1.3.6.20081104-source.zip findbugs-1.3.6-rc3-source.zip findbugs-1.3.6-rc3.zip
2 edu.umd.cs.findbugs.plugin.eclipse_1.3.6.20081104.zip findbugs-1.3.6-rc3.tar.gz
3
4 cd to that directory
5 sftp username,findbugs@frs.sourceforge.net
6 sftp> cd /home/frs/project/f/fi/findbugs/findbugs/RELEASE
7 sftp> mput findbugs-*
8 sftp> cd "../../findbugs eclipse plugin/RELEASE
9 fstp> mput edu.* eclipsePlugin*
10 fstp> quit
11
12 Add releases via:
13 https://sourceforge.net/project/admin/editpackages.php?group_id=96405
14
15
16 release daily/candidate/final eclipse plugins
17
18 From findbugs directory, do:
19 rsync -avz web/ username,findbugs@web.sourceforge.net:htdocs/
20
21 For a full release, make a branch in the svn repository:
22
23
24 svn copy "https://findbugs.googlecode.com/svn/trunk" "https://findbugs.googlecode.com/svn/branches/1.X.X"
25
26 For a release candidate, send email to findbugs-discuss and findbugs-core. For a full release, send email to findbugs-announce.
0
1 We have a list of plugins.
2
3 In any particular context, some plugins are enabled.
4
5 DetectorFactoryCollection:
6 Core plugin
7 Collection of plugins
8 Collection of DetectorFactories
9 Adjustment ranker
10
11 I18N
12 ResourceBundles
13 bugPatternMap
14 bugCodeMap
15 categoryDescriptionMap
16
17 Plugin
18 collection of DetectorFactory
19 bug patterns, codes, etc.
20 component plugins
21 bug ranker
22 enabled
23 plugin loader
24
25 CloudFactory
26 registeredClouds
27
0
1 Plugins can be specified in three different ways:
2 * For a standard FindBugd distro, they can be put into the plugins directory
3 * For a JAWS distro, the file pluginlist.properties contains
4 a list of URLs to plugins. These URLs can be relative or absolute. If they
5 are absolute, they are relative to jar file that contained the pluginlist.properties
6 file.
7 * You can define properties findbugs.plugin.*. Each such property defines a URL
8 for a plugin
Binary diff not shown
0 <html>
1 <head>
2 <title>FindBugs Documents and Publications</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs Documents and Publications</h1>
57
58 <p> This page lists documents, publications, and other sources
59 of information about FindBugs.
60
61 <h2>General Information</h2>
62
63 <ul>
64 <li> The <a href="manual/index.html">FindBugs manual</a> describes how to
65 install and use FindBugs.
66 <li> A <a href="http://www.simeji.com/findbugs/doc/manual_ja/index.html">Japanese translation</a>
67 of the FindBugs manual contributed by Hiroshi Okugawa.
68 <li> A <a href="bugDescriptions.html">list of bug patterns reported by FindBugs</a>.
69 <li> The <a href="FAQ.html">FindBugs FAQ</a> contains answers to frequently asked
70 questions about FindBugs.
71 </ul>
72
73 <h2>Publications</h2>
74
75 <ul>
76 <li> <a href="http://findbugs.sourceforge.net/docs/oopsla2004.pdf">Finding Bugs is Easy</a>, a
77 paper that appeared in the December 2004 issue of SIGPLAN Notices.&nbsp;
78 An extended abstract of the paper appeared in the OOPSLA 2004 Companion,
79 as part of the Onward! track of the conference.&nbsp;
80
81 <!--
82 The raw data
83 we used in the empirical evaluation section is available:
84 <ul>
85 <li> <a href="http://findbugs.sourceforge.net/data/classpath-0.08.xml">classpath-0.08.xml</a>
86 <li> <a href="http://findbugs.sourceforge.net/data/drjava-stable-20040326.xml">drjava-stable-20040326.xml</a>
87 <li> <a href="http://findbugs.sourceforge.net/data/eclipse-3.0.xml">eclipse-3.0.xml</a>
88 <li> <a href="http://findbugs.sourceforge.net/data/jboss-4.0.0RC1.xml">jboss-4.0.0RC1.xml</a>
89 <li> <a href="http://findbugs.sourceforge.net/data/jedit-4.2pre15.xml">jedit-4.2pre15.xml</a>
90 <li> <a href="http://findbugs.sourceforge.net/data/rt-1.5-59.xml">rt-1.5-59.xml</a>
91 </ul>
92 -->
93 <li> <a href="http://www.cs.umd.edu/~jfoster/papers/issre04.pdf">A Comparison of Bug Finding Tools for Java</a>, by Nick Rutar, Christian Almazan, and Jeff Foster,
94 compares several bug checkers for Java, including FindBugs.
95 <li> Chris Grindstaff has written a two-part article about FindBugs
96 (<a href="http://www-106.ibm.com/developerworks/java/library/j-findbug1/">Part 1</a>,
97 <a href="http://www-106.ibm.com/developerworks/java/library/j-findbug2/">Part 2</a>)
98 for IBM developerWorks.
99 </ul>
100
101 <!--
102 <h2>Presentations</h2>
103 <ul>
104 <li> <a href="http://findbugs.sourceforge.net/docs/oopsla2004-slides.pdf">Presentation slides</a>
105 from a talk given by David Hovemeyer at OOPSLA 2004.
106 <li> <a href="http://findbugs.sourceforge.net/docs/FindBugsTalk2.pdf">Presentation slides</a>
107 from a talk given by Bill Pugh at the
108 <a href="http://fc-md.umd.edu/fcmd/index.html"
109 >Fraunhofer Center for Experimental Software Engineering</a>,
110 July 2004
111 <li> <a href="http://findbugs.sourceforge.net/docs/FindBugsJavaOne.pdf">Finding Bugs is Easy</a>,
112 a presentation given by David Hovemeyer and Bill Pugh
113 at <a href="http://java.sun.com/javaone/">JavaOne 2004</a>,
114 June 2004
115 <li> <a href="http://findbugs.sourceforge.net/docs/FindBugsJKeller.pdf">Presentation slides</a>
116 from J. Keller's presentation at the FindBugs JavaOne BOF,
117 June 2004
118 </ul>
119 -->
120
121
122 <hr> <p>
123 <script language="JavaScript" type="text/javascript">
124 <!---//hide script from old browsers
125 document.write( "Last updated "+ document.lastModified + "." );
126 //end hiding contents --->
127 </script>
128 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
129 <p>
130 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
131
132 </td>
133
134 </tr></table>
135
136 </body>
137 </html>
0 <html>
1 <head>
2 <title>Reporting Bugs in FindBugs</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>Reporting Bugs in FindBugs</h1>
57
58 <p>
59 First of all, if you find a bug in FindBugs, and have the
60 skills to fix it, we encourage you to unleash the power of open source and
61 <a href="contributing.html">send us a patch</a>.&nbsp; We will gladly
62 credit you on our website and in the manual.
63 </p>
64
65 <p>
66 Please report bugs using the
67 <a href="http://sourceforge.net/tracker/?atid=614693&group_id=96405&func=browse">Sourceforge
68 bugs tracker</a>.&nbsp; Note that you need to be logged in to sourceforge to
69 use the bug tracker.
70 </p>
71
72 <p>
73 If you cannot use the Sourceforge tracker, you can try sending
74 email to the <a href="http://www.cs.umd.edu/mailman/listinfo/findbugs-discuss"
75 >findbugs-discuss mailing list</a>.&nbsp; You must be subscribed
76 to the list to post a message.
77 </p>
78
79 <p>
80 Finally, as a last resort, you can email <a href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>.&nbsp;
81 However, such emails are much less likely to be handled in a timely manner than
82 posts to the tracker or mailing list.
83 </p>
84
85 <h2>False and Inaccurate Warnings</h2>
86
87 <p>
88 Like most bug-detection tools based on static analysis, FindBugs
89 issues some warnings that do not correspond to real bugs.&nbsp;
90 While in general we would like to make the percentage of such warnings
91 small, we can never fully eliminate them.
92 </p>
93
94 <h2>Information to include</h2>
95
96 <p>
97 When reporting a bug, please include the following information:
98 </p>
99 <ul>
100 <li>Complete list of steps to reproduce the problem</li>
101 <li>If the error occurs during analysis, a jar file, class file,
102 or self-contained Java class that demonstrates the problem</li>
103 <li>FindBugs version</li>
104 <li>JDK/JRE version</li>
105 <li>Host operating system</li>
106 <li>Any exception traces, Eclipse error log entries, etc. that might
107 be relevant</li>
108 </ul>
109
110
111 <hr> <p>
112 <script language="JavaScript" type="text/javascript">
113 <!---//hide script from old browsers
114 document.write( "Last updated "+ document.lastModified + "." );
115 //end hiding contents --->
116 </script>
117 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
118 <p>
119 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
120
121 </td>
122
123 </tr></table>
124
125 </body>
126 </html>
0 <html>
1 <head>
2 <title>FindBugs sourceInfo file</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4 </head>
5 <body>
6
7 <table width="100%"><tr>
8
9
10 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
11 <table width="100%" cellspacing="0" border="0">
12 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
13
14 <tr><td>&nbsp;</td></tr>
15
16 <tr><td><b>Docs and Info</b></td></tr>
17 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
29
30 <tr><td>&nbsp;</td></tr>
31
32 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
33
34 <tr><td>&nbsp;</td></tr>
35
36 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
37
38 <tr><td>&nbsp;</td></tr>
39
40 <tr><td><b>Development</b></td></tr>
41 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
50 </table>
51 </td>
52
53 <td align="left" valign="top">
54
55 <h1>FindBugs sourceInfo file</h1>
56
57 <p>The FindBugs analysis engine can be invoked with an optional sourceInfo
58 file. This file gives line number ranges for classes, files and methods. This
59 information is an alternative to getting line number information
60 from the classfiles for methods. Since classfiles only contain line number
61 information
62 for methods, without a sourceInfo file we can't provide line numbers for fields,
63 and for classes we just use the line numbers of the methods in the class.
64
65 <p>The first line of the file should be
66 <pre>
67 sourceInfo version 1.0
68 </pre>
69
70 <p>Following that are a series of lines, each describing a class, field, or method. For each, a starting and ending line number is provided. For example, the following sourceInfo file:
71 <pre>
72 sourceInfo version 1.0
73 a.C,3,8
74 a.C,x,4,4
75 a.C,y,4,4
76 a.C,<init>()V,8,8
77 a.C,f(I)I,5,5
78 a.C,g(Ljava/lang/Object;)I,6,7
79 </pre>
80 provides the following information about the class a.C:
81 <ul>
82 <li> fields x and y are both declared on line 4.
83 <li> the method <code>int f(int)</code> is defined on line 5.
84 <li> the method <code>int g(Object)</code> is defined on lines 6-7.
85 <li> the void constructor for a.C is defined on line 8.
86 </ul>
87 The classnames should be the same format as used by Class.getName():
88 packages are separated by ., inner class names are separated by $.
89 Thus, if the class a.C had an inner class X and it was onb lines 10-15 of the file, the sourceInfo file might contain:
90
91 <pre>
92 a.C$X,10,15
93 </pre>
94
95
96 </table>
97
98
99 <hr> <p>
100 <script language="JavaScript" type="text/javascript">
101 <!---//hide script from old browsers
102 document.write( "Last updated "+ document.lastModified + "." );
103 //end hiding contents --->
104 </script>
105 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
106 <p>
107 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
108
109 </td>
110
111 </tr></table>
112
113 </body>
114 </html>
0 <html>
1 <head>
2 <title>FindBugs Optional System Properties</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4 </head>
5 <body>
6
7 <table width="100%"><tr>
8
9
10 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
11 <table width="100%" cellspacing="0" border="0">
12 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
13
14 <tr><td>&nbsp;</td></tr>
15
16 <tr><td><b>Docs and Info</b></td></tr>
17 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
29
30 <tr><td>&nbsp;</td></tr>
31
32 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
33
34 <tr><td>&nbsp;</td></tr>
35
36 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
37
38 <tr><td>&nbsp;</td></tr>
39
40 <tr><td><b>Development</b></td></tr>
41 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
50 </table>
51 </td>
52
53 <td align="left" valign="top">
54
55 <h1>FindBugs Optional System Properties</h1>
56
57 <p> These system properties can be added to the command line to alter the way
58 findbugs works. These options should be considered experimental. The description
59 gives information if the field is set to true.
60 </p>
61
62 <table width="100%" border="1">
63 <tr bgColor="#F0F0F0"><th>System Property</th><th>Description</th></tr>
64
65 <tr>
66 <td>findbugs.assertionmethods</td>
67 <td>methods supplied by user that have assertions</td>
68 </tr>
69 <tr>
70 <td>findbugs.checkreturn.loadtraining
71 <br/>findbugs.checkreturn.savetraining</td>
72 <td>file name to read/write list of methods whose return values must be checked</td>
73 </tr>
74 <tr>
75 <td>findbugs.de.comment</td>
76 <td>Don't report empty catch blocks if a source comment is found in the block.</td>
77 </tr>
78 <tr>
79 <td>findbugs.dls.exclusions</td>
80 <td>local variables that will be excluded from Dead Local Store</td>
81 </tr>
82 <tr>
83 <td>findbugs.fis.unsyncFactor</td>
84 <td>Default value is 2.0, which means that we report a bug if more than 1/3 of accesses are unsynchronized.</td>
85 </tr>
86 <tr>
87 <td>findbugs.fis.writeBias</td>
88 <td>Default value is 2.0. The idea is that this should be above 1.0, because unsynchronized writes are more dangerous than unsynchronized reads.</td>
89 </tr>
90 <tr>
91 <td>fundbugs.gui.bugCount</td>
92 <td>?</td>
93 </tr>
94 <tr>
95 <td>findbugs.maskedfields.locals</td>
96 <td>Report on local variables that mask fields.</td>
97 </tr>
98 <tr>
99 <td>findbugs.nullderef.assumensp</td>
100 <td>sets value for IsNullValueAnalysisFeatures.UNKNOWN_VALUES_ARE_NSP, but is not used by FindBugs</td>
101 </tr>
102 <tr>
103 <td>findbugs.refcomp.reportAll</td>
104 <td>?</td>
105 </tr>
106 <tr>
107 <td>findbugs.report.SummaryHTML</td>
108 <td>emit SummaryHTML element</td>
109 </tr>
110 <tr>
111 <td>findbugs.sf.comment</td>
112 <td>Ignore switch fall thru bugs if a comment is found with 'fall' or 'nobreak'
113 </tr>
114 <tr>
115 <td>ba.checkAssertions</td>
116 <td>throw excptions on certain illegal class type signatures</td>
117 </tr>
118 <tr>
119 <td>ba.verifyIntegrity</td>
120 <td>enable data structure integrity checks</td>
121 </tr>
122 <tr>
123 <td>BCPMethodReturnCheck.java</td>
124 <td>Add methods to the list requiring a check. (format: "class:method:sig|...")</td>
125 </tr>
126 <tr>
127 <td>dataflow.stackonly</td>
128 <td>?</td>
129 </tr>
130 <tr>
131 <td>fis.eval</td>
132 <td>?</td>
133 </tr>
134 <tr>
135 <td>fis.noAdjustSubclass</td>
136 <td>Adjust field so its class name is the same as the type of reference it is accessed through.</td>
137 </tr>
138 <tr>
139 <td>fos.allowWUS</td>
140 <td>Ignore wrapping streams that are wrapping uninteresting streams (like in memory streams).</td>
141 </tr>
142 <tr>
143 <td>ic.createInstance</td>
144 <td>?</td>
145 </tr>
146 <tr>
147 <td>inva.ncpExtraBranch</td>
148 <td>?</td>
149 </tr>
150 <tr>
151 <td>inva.noAssertHack</td>
152 <td>?</td>
153 </tr>
154 <tr>
155 <td>inva.noSplitDowngradeNSP</td>
156 <td>?</td>
157 </tr>
158 <tr>
159 <td>inva.noSwitchDefaultAsException</td>
160 <td>Don't consider switch default cases as exception paths.</td>
161 </tr>
162 <tr>
163 <td>lineNumberBug</td>
164 <td>Disable the workaround for the bug in BCEL 5.0's LineNumberTable class.</td>
165 </tr>
166 <tr>
167 <td>ma.ugly</td>
168 <td>Report method signature with method class and name.</td>
169 </tr>
170 <tr>
171 <td>mrc.checkall</td>
172 <td>Check for 1.5-specific method return values being ignored even if runtime Java predates 1.5.</td>
173 </tr>
174 <tr>
175 <td>ta.accurateExceptions</td>
176 <td>?</td>
177 </tr>
178 <tr>
179 <td>vna.noRLE</td>
180 <td>Perform redundant load elimination and forward substitution (but not in a correctness-preserving way).</td>
181 </tr>
182
183 </table>
184
185
186 <hr> <p>
187 <script language="JavaScript" type="text/javascript">
188 <!---//hide script from old browsers
189 document.write( "Last updated "+ document.lastModified + "." );
190 //end hiding contents --->
191 </script>
192 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
193 <p>
194 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
195
196 </td>
197
198 </tr></table>
199
200 </body>
201 </html>
0 <html>
1 <head>
2 <title>FindBugs Development Team</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css">
4
5 </head>
6 <body>
7
8 <table width="100%"><tr>
9
10
11 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
12 <table width="100%" cellspacing="0" border="0">
13 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
14
15 <tr><td>&nbsp;</td></tr>
16
17 <tr><td><b>Docs and Info</b></td></tr>
18 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
19 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
30
31 <tr><td>&nbsp;</td></tr>
32
33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
34
35 <tr><td>&nbsp;</td></tr>
36
37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
38
39 <tr><td>&nbsp;</td></tr>
40
41 <tr><td><b>Development</b></td></tr>
42 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
43 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
51 </table>
52 </td>
53
54 <td align="left" valign="top">
55
56 <h1>FindBugs Development Team</h1>
57
58 <p> These are the current active members of the FindBugs development team:
59
60 <ul>
61 <li> <a href="http://www.cs.umd.edu/~pugh">Bill Pugh</a> (project lead and primary developer)
62 <li> <a href="http://andrei.gmxhome.de/privat.html">Andrey Loskutov</a>(Eclipse plugin)
63 <li> <a href="http://keithlea.com">Keith Lea</a> (web cloud)
64 </li>
65 </ul>
66
67 <p>Previous and/or inactive members of the FindBugs development team include
68 <ul>
69 <li> <a href="http://goose.ycp.edu/~dhovemey/">David Hovemeyer</a> (project founder),
70 did Ph.D. thesis on FindBugs
71 <li> Nay Ayewah
72 <li> Ben Langmead
73 <li> Tomas Pollak (Eclipse plugin tests)
74 <li> Phil Crosby
75 <li> Peter Friese (Eclipse plugin)
76 <li> Dave Brosius
77 <li> Brian Goetz
78 <li> Rohan Lloyd
79 </ul>
80
81
82 <hr> <p>
83 <script language="JavaScript" type="text/javascript">
84 <!---//hide script from old browsers
85 document.write( "Last updated "+ document.lastModified + "." );
86 //end hiding contents --->
87 </script>
88 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
89 <p>
90 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
91
92 </td>
93
94 </tr></table>
95
96 </body>
97 </html>
Binary diff not shown
0 <html>
1 <head>
2 <title>Update checking in FindBugs</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css" />
4
5 </head>
6
7 <body>
8
9 <table width="100%">
10 <tr>
11
12
13 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
14 <table width="100%" cellspacing="0" border="0">
15 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
16
17 <tr><td>&nbsp;</td></tr>
18
19 <tr><td><b>Docs and Info</b></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
31 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
32
33 <tr><td>&nbsp;</td></tr>
34
35 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
36
37 <tr><td>&nbsp;</td></tr>
38
39 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
40
41 <tr><td>&nbsp;</td></tr>
42
43 <tr><td><b>Development</b></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
52 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
53 </table>
54 </td>
55
56 <td align="left" valign="top">
57
58 <h1>Update checking in FindBugs</h1>
59
60 <p>When FindBugs is run, it now checks for updated versions of FindBugs or plugins. As a side effect
61 of this, our server sees a request for whether there are any updated version of FindBugs available.
62 Third party plugins can independently receive this same information. We are recording
63 information about the operating system, Java version, locale, and Findbugs entry point (ant, command line,
64 GUI, etc), in order to better understand our users.
65
66 <p>For example, here is an example of the information that would be sent to the server:
67 <pre>
68 &lt;?xml version="1.0" encoding="UTF-8"?>
69
70 &lt;findbugs-invocation version="2.0.0-rc1" app-name="UpdateChecker" app-version="" entry-point="UpdateChecker" os="Mac OS X"
71 java-version="1.6" language="en" country="US" uuid="-4bcf8f48ba2842d2"&gt;
72 &lt;plugin id="edu.umd.cs.findbugs.plugins.core" name="Core FindBugs plugin" version="2.0.0-rc1"/&gt;
73 &lt;plugin id="edu.umd.cs.findbugs.plugins.appengine" name="FindBugs Cloud Plugin" version=""/&gt;
74 &lt;plugin id="edu.umd.cs.findbugs.plugins.poweruser" name="Power user commnand line tools" version=""/&gt;
75 &lt;/findbugs-invocation&gt;
76 </pre>
77
78 <p>You can run the main method of edu.umd.cs.findbugs.updates.UpdateChecker to see what would be reported
79 for you, and whether update checking is disabled and/or redirected (e.g., run
80 <pre> java -classpath ~/findbugs/lib/findbugs.jar edu.umd.cs.findbugs.updates.UpdateChecker</pre>
81
82 <p>There is one element of the information sent that needs explanation: the uuid. Since we don't report anything like username,
83 when we receive a bunch of update checks from a particular ip address, we don't know if that is one person running FindBugs many times
84 on a single machine, or many users running FindBugs on many different machines So we generate a random 64 bit integer,
85 store it in the Java user preferences, and report that on each use.
86
87 <h2>Disabling or redirecting update checks</h2>
88 <p>Some organizations or individuals may have policies or preferences to not let us know any information about
89 their running of FindBugs. Note that we do not collect any information about the code being analuzed.
90 Even so, we understand that is very important for a few of our users,
91 and provide several ways for you to disable or redirect FindBugs update checks.
92 <ul>
93 <li>There is a FindBugs plugin, noUpdateChecks.jar, which is in findbugs/optionalPlugin in the standard distribution.
94 If this plugin enabled, all update checks are disabled. You can move that plugin from findbugs/optionalPlugin to findbugs/plugin,
95 to disable it for all users of that distribution. You can also copy it to <pre>~/.findbugs/plugin</pre>,
96 which will disable it for your account for any distribution of FindBugs you invoke (NOTE: double check location
97 of personal FindBugs plugin installation for Windows User).
98 <li>There are noUpdateChecks distributions of FindBugs available from SourceForge. This come with the noUpdateChecks plugin
99 already moved to findbugs/plugin, and the webCloudClient.jar plug in the optional plugin directory (where it is disabled by default).
100
101 <li>You can also redirect all update checks to a local server. This allows you to collect information about who is using
102 what versions of FindBugs in your organization, and keep all of that information private.
103 <li>All of the plugins from the FindBugs project use <pre>http://update.findbugs.org/update-check</pre> as the
104 host we use for update checks. If you wish to ensure that no one from your organization accidently reports any usage
105 information to the FindBugs project, you can blacklist that URL in your firewall
106 <ul>
107 <li>You can also block <pre>http://findbugs-cloud.appspot.com</pre>, the host we use for our publicly hosted
108 repository of bug evaluations (e.g., evaluations in open source projects such as the JDK, Eclipse and GlassFish).
109 While people have to explicitly request that their evaluations be stored into the FindBugs cloud, you
110 can block it to ensure that no one accidently shares evaluations of your own code to the FindBugs cloud. You can also
111 remove the WebCloudClient
112
113 </ul>
114 </li>
115 </ul>
116
117
118 </tr>
119 </table>
120
121 </body>
122 </html>
0 <html>
1 <head>
2 <title>FindBugs&trade; Users and Supporters</title>
3 <link rel="stylesheet" type="text/css" href="findbugs.css" />
4
5 </head>
6
7 <body>
8
9 <table width="100%">
10 <tr>
11
12
13 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%">
14 <table width="100%" cellspacing="0" border="0">
15 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr>
16
17 <tr><td>&nbsp;</td></tr>
18
19 <tr><td><b>Docs and Info</b></td></tr>
20 <tr><td><font size="-1"><a class="sidebar" href="findbugs2.html">FindBugs 2.0</a></font></td></tr>
21 <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr>
22 <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr>
23 <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr>
24 <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr>
25 <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr>
26 <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/&#26085;&#26412;&#35486;)</a></font></td></tr>
27 <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr>
28 <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr>
29 <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr>
30 <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr>
31 <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr>
32
33 <tr><td>&nbsp;</td></tr>
34
35 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr>
36
37 <tr><td>&nbsp;</td></tr>
38
39 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr>
40
41 <tr><td>&nbsp;</td></tr>
42
43 <tr><td><b>Development</b></td></tr>
44 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr>
45 <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr>
46 <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr>
47 <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr>
48 <tr><td><font size="-1"><a class="sidebar" href="api/index.html">API</a> <a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></tr>
49 <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr>
50 <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr>
51 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr>
52 <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr>
53 </table>
54 </td>
55
56 <td align="left" valign="top">
57
58 <!--
59 <p>
60 <a href="http://findbugs.sourceforge.net/"><img src="buggy-sm.png" alt="FindBugs logo" border="0" /></a>
61 <a href="http://www.umd.edu/"><img src="informal.png" alt="UMD logo" border="0" /></a>
62 </p>
63 -->
64
65 <h1>
66 FindBugs Users
67 </h1>
68
69 <p>
70 There are a
71 <em>lot</em> of FindBugs users; as of September 2006, we've had
72 more than 270,000 downloads.
73
74 </p>
75 <p>
76 FindBugs is used in many companies and organizations. We don't
77 have a list of all the users of FindBugs, and we don't have
78 permission to identify many of the companies where we know
79 FindBugs is being used (getting this permission often involves red
80 tape and lawyers). But here are some statics from Google Analytics
81 showing unique visitors to the FindBugs web pages for the months
82 of June through August, 2006.
83
84 </p>
85 <p align="center">
86 <img src="customers/geoLocation.png" alt="Downloads by country">
87 </p>
88 <p align="center">
89 <img src="customers/geoMap.png" alt="Cities with the most downloads">
90
91 </p>
92 <h2>
93 FindBugs Users
94 </h2>
95 <p>
96 The following companies, projects and organizations have given us
97 permission to identify them as FindBugs users and/or have
98 publically stated that they use FindBugs. Send email to
99 <a href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a> if
100 you'd like to be listed here.
101 </p>
102
103 <table cellpadding="10pt" align="center">
104 <tr>
105 <td align="center">
106 <a href="http://itasoftware.com/"><img
107 src="customers/ITAsoftware.png" alt="ITA Software">
108 </a>
109 </td>
110 <td align="center">
111 <a href="https://glassfish.dev.java.net/"><img
112 src="customers/glassfish.png" alt="Glassfish">
113 </a>
114 </td>
115 </tr>
116 <tr>
117 <td align="center">
118 <a href="https://javaserverfaces.dev.java.net/">Java Server
119 Faces</a>
120 </td>
121 <td align="center">
122 <a href="http://www.objectlab.co.uk/"><img
123 src="http://www.objectlab.co.uk/images/objectlab-web-noblue.gif"
124 alt="ObjectLab">
125 </a>
126 </td>
127 </tr>
128 <tr>
129 <td align="center">
130 <a href="http://www.sat4j.org/"><img
131 src="customers/sat4j.png" alt="SAT 4j">
132 </a>
133 </td>
134 <td align="center">
135 <a href="http://www.sleepycat.com/"><img
136 src="customers/sleepycat.png" alt="SleepyCat">
137 </a>
138 </td>
139 </tr>
140 </table>
141 <h2>
142 FindBugs Supporters
143 </h2>
144 <p>
145 The following companies, organizations and institutions provide
146 financial support for FindBugs. Tax deductable donations to
147 support FindBugs can be made to the University of Maryland.
148
149 </p>
150
151 <table cellpadding="10pt" align="center">
152
153 <tr>
154 <td align="center">
155 <a href="http://www.google.com"><img
156 src="customers/google.png" alt="Google">
157 </a>
158 </td>
159 </tr>
160 <tr>
161 <td align="center">
162 <a href="http://www.sun.com"><img src="customers/sun.png"
163 alt="Sun Microsystems">
164 </a>
165 </td>
166 <td align="center">
167 <a href="http://www.nsf.gov/"><img src="customers/nsf.png"
168 alt="National Science Foundation">
169 </a>
170 </td>
171 </tr>
172 <tr>
173 <td align="center">
174 <a href="http://www.cs.umd.edu/"><img
175 src="customers/logo_umd.png" alt="Univ. of Maryland">
176 </a>
177 </td>
178 </tr>
179 </table>
180
181
182
183 <hr> <p>
184 <script language="JavaScript" type="text/javascript">
185 <!---//hide script from old browsers
186 document.write( "Last updated "+ document.lastModified + "." );
187 //end hiding contents --->
188 </script>
189 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a>
190 <p>
191 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
192
193 </td align="center">
194 </tr>
195 </table>
196
197 </body>
198 </html>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: FindbugsAnnotations
33 Bundle-SymbolicName: findbugsAnnotations
4 Bundle-Version: 2.0.2
4 Bundle-Version: 2.0.3
55 Export-Package: edu.umd.cs.findbugs.annotations,
66 javax.annotation,
77 javax.annotation.concurrent,
0 Manifest-Version: 1.0
1 Bundle-ManifestVersion: 2
2 Bundle-Name: FindbugsInternalAnnotations
3 Bundle-SymbolicName: findbugsInternalAnnotations
4 Bundle-Version: 2.0.3
5 Export-Package: edu.umd.cs.findbugs.annotations
6 Bundle-RequiredExecutionEnvironment: J2SE-1.5
00 Manifest-Version: 1.0
11 Main-Class: edu.umd.cs.findbugs.LaunchAppropriateUI
2 Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.1.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.4.jar
2 Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar
00 Manifest-Version: 1.0
11 Main-Class: edu.umd.cs.findbugs.LaunchAppropriateUI
2 Class-Path: findbugs.jar bcel.jar dom4j-1.6.1.jar jaxen-1.1.1.jar plastic.jar
2 Class-Path: bcel.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-3.3.jar asm-tree-3.3.jar asm-commons-3.3.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar plastic.jar
241241 use="optional"/>
242242
243243 <xs:attribute name="rank" type="xs:unsignedInt" use="optional"/>
244 <xs:attribute name="cweid" type="xs:unsignedInt" use="optional"/>
244245
245246
246247 </xs:complexType>
103103 -3 BugPattern NP_IMMEDIATE_DEREFERENCE_OF_READLINE
104104 +5 BugPattern TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK
105105 +5 BugPattern TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK
106 +3 BugPattern IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD
106107 -6 BugPattern TESTING
107108 -2 BugPattern PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS
108109 -2 BugPattern DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS
109110 +3 BugPattern RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE
111 -4 BugKind FB
110112 -4 BugKind EC
111113 +1 BugKind RCN
112114 +1 BugKind NP
(No changes)
00 <FindbugsPlugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11 xsi:noNamespaceSchemaLocation="findbugsplugin.xsd"
2 pluginid="edu.umd.cs.findbugs.plugins.core"
2 pluginid="edu.umd.cs.findbugs.plugins.core"
33 version="USE_FINDBUGS_VERSION"
44 provider="FindBugs project" website="http://findbugs.sourceforge.net"
55 update-url="http://update.findbugs.org/update-check">
6
6
77 <!--
88 Plugin descriptor for FindBugs "core" plugin.
99 This plugin is enabled by default.
1111 <Cloud id="edu.umd.cs.findbugs.cloud.doNothingCloud"
1212 cloudClass="edu.umd.cs.findbugs.cloud.DoNothingCloud"
1313 usernameClass="edu.umd.cs.findbugs.cloud.username.NoNameLookup"/>
14
14
1515 <PluginComponent id="edu.umd.cs.findbugs.bugReporter.SuppressI18N"
1616 componentKind="edu.umd.cs.findbugs.bugReporter.BugReporterDecorator"
1717 componentClass="edu.umd.cs.findbugs.bugReporter.SuppressionDecorator"
4343 disabled="true">
4444 <Property key="category">MALICIOUS_CODE</Property>
4545 </PluginComponent>
46
46
4747
4848 <FindBugsMain cmd="addMessages" kind="poweruser" class="edu.umd.cs.findbugs.AddMessages"/>
4949 <FindBugsMain cmd="analyze" analysis="true" class="edu.umd.cs.findbugs.FindBugs2"/>
5252 <FindBugsMain cmd="help" class="edu.umd.cs.findbugs.ShowHelp"/>
5353 <FindBugsMain cmd="version" class="edu.umd.cs.findbugs.Version"/>
5454 <FindBugsMain cmd="filter" class="edu.umd.cs.findbugs.workflow.Filter"/>
55 <FindBugsMain cmd="set" class="edu.umd.cs.findbugs.workflow.SetBugDatabaseInfo"/>
56
55 <FindBugsMain cmd="set" class="edu.umd.cs.findbugs.workflow.SetBugDatabaseInfo"/>
56
5757 <FindBugsMain cmd="history" kind="history" class="edu.umd.cs.findbugs.workflow.MineBugHistory"/>
5858 <FindBugsMain cmd="union" kind="history" class="edu.umd.cs.findbugs.workflow.UnionResults"/>
5959 <FindBugsMain cmd="merge" kind="history" class="edu.umd.cs.findbugs.workflow.Update"/>
60
61 <FindBugsMain cmd="dis" kind="utility" class="edu.umd.cs.findbugs.visitclass.PrintClass"/>
62
60
61 <FindBugsMain cmd="dis" kind="utility" class="edu.umd.cs.findbugs.visitclass.PrintClass"/>
62 <FindBugsMain cmd="errors" class="edu.umd.cs.findbugs.workflow.ListErrors"/>
63
6364 <OrderingConstraints>
6465 <SplitPass>
6566 <Earlier class="edu.umd.cs.findbugs.detect.FieldItemSummary"/>
187188 class="edu.umd.cs.findbugs.detect.NoteCheckReturnValueAnnotations"/>
188189 <Later class="edu.umd.cs.findbugs.detect.MethodReturnCheck"/>
189190 </SplitPass>
190 <!-- NoteNonNullAnnotations, NoteUnconditionalParamDerefs
191 should happen in an earlier pass than FindNullDeref. -->
192 <SplitPass>
193 <Earlier class="edu.umd.cs.findbugs.detect.NoteNonNullAnnotations"/>
194 <Later class="edu.umd.cs.findbugs.detect.TrainUnconditionalDerefParams"
195 />
196 </SplitPass>
197 <SplitPass>
198 <Earlier class="edu.umd.cs.findbugs.detect.NoteNonNullAnnotations"/>
199 <Later class="edu.umd.cs.findbugs.detect.FindNullDeref"/>
200 </SplitPass>
191
201192 <SplitPass>
202193 <Earlier class="edu.umd.cs.findbugs.detect.NoteJCIPAnnotation"/>
203194 <Later class="edu.umd.cs.findbugs.detect.FindInconsistentSync2"/>
246237 <Earlier class="edu.umd.cs.findbugs.detect.UnreadFields"/>
247238 <Later class="edu.umd.cs.findbugs.detect.ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass" />
248239 </WithinPass>
249 <SplitPass>
250 <Earlier class="edu.umd.cs.findbugs.detect.NoteNonNullAnnotations"/>
251 <Later class="edu.umd.cs.findbugs.detect.NoteUnconditionalParamDerefs" />
252 </SplitPass>
253240 <SplitPass>
254241 <Earlier class="edu.umd.cs.findbugs.detect.Methods"/>
255242 <Later class="edu.umd.cs.findbugs.detect.NoteUnconditionalParamDerefs" />
303290 <Detector class="edu.umd.cs.findbugs.detect.FieldItemSummary" speed="fast" reports=""
304291 hidden="true"/>
305292 <Detector class="edu.umd.cs.findbugs.detect.NoteNonNullAnnotations" speed="fast"
306 reports="" hidden="true"/>
293 reports="" hidden="true" disabled="true"/>
307294 <Detector class="edu.umd.cs.findbugs.detect.NoteUnconditionalParamDerefs" speed="slow"
308295 reports="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT,NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE"/>
309296 <Detector class="edu.umd.cs.findbugs.detect.NoteNonnullReturnValues" speed="slow"
310 reports="" hidden="true"/>
297 reports="" hidden="true" disabled="true"/>
311298 <Detector class="edu.umd.cs.findbugs.detect.SynchronizeOnClassLiteralNotGetClass"
312299 speed="fast" reports="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL"
313300 hidden="false"/>
319306 reports="VO_VOLATILE_REFERENCE_TO_ARRAY,VO_VOLATILE_INCREMENT"/>
320307 <Detector class="edu.umd.cs.findbugs.detect.InheritanceUnsafeGetResource" speed="fast"
321308 reports="UI_INHERITANCE_UNSAFE_GETRESOURCE"/>
322 <Detector class="edu.umd.cs.findbugs.detect.EmptyZipFileEntry" speed="moderate"
309 <Detector class="edu.umd.cs.findbugs.detect.EmptyZipFileEntry" speed="moderate" disabled="true"
323310 reports="AM_CREATES_EMPTY_ZIP_FILE_ENTRY,AM_CREATES_EMPTY_JAR_FILE_ENTRY"/>
324311 <Detector class="edu.umd.cs.findbugs.detect.DoInsideDoPrivileged" speed="fast"
325312 reports="DP_DO_INSIDE_DO_PRIVILEGED,DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/>
377364 <Detector class="edu.umd.cs.findbugs.detect.URLProblems" speed="fast"
378365 reports="DMI_BLOCKING_METHODS_ON_URL,DMI_COLLECTION_OF_URLS"/>
379366 <Detector class="edu.umd.cs.findbugs.detect.DumbMethods" speed="fast"
380 reports="NP_IMMEDIATE_DEREFERENCE_OF_READLINE,RV_01_TO_INT,DM_RUN_FINALIZERS_ON_EXIT,DM_STRING_CTOR,DM_STRING_VOID_CTOR,DM_STRING_TOSTRING,DM_GC,DM_BOOLEAN_CTOR,DM_EXIT,DM_CONVERT_CASE,SW_SWING_METHODS_INVOKED_IN_SWING_THREAD,DM_BOXED_PRIMITIVE_TOSTRING,DM_NEW_FOR_GETCLASS,DM_NEXTINT_VIA_NEXTDOUBLE,DM_USELESS_THREAD,DM_MONITOR_WAIT_ON_CONDITION,DMI_CALLING_NEXT_FROM_HASNEXT,RV_REM_OF_HASHCODE,RV_REM_OF_RANDOM_INT,RV_ABSOLUTE_VALUE_OF_RANDOM_INT,RV_ABSOLUTE_VALUE_OF_HASHCODE,BIT_ADD_OF_SIGNED_BYTE,BIT_IOR_OF_SIGNED_BYTE,INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE,INT_BAD_COMPARISON_WITH_SIGNED_BYTE,INT_BAD_REM_BY_1,DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION,INT_VACUOUS_COMPARISON,BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS,DMI_RANDOM_USED_ONLY_ONCE,DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT,DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED,DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR,DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS,DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD,DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE,INT_VACUOUS_BIT_OPERATION,DMI_COLLECTION_OF_URLS,INT_BAD_COMPARISON_WITH_INT_VALUE,DMI_DOH,DMI_ARGUMENTS_WRONG_ORDER"/>
367 reports="NP_IMMEDIATE_DEREFERENCE_OF_READLINE,RV_01_TO_INT,DM_RUN_FINALIZERS_ON_EXIT,DM_STRING_CTOR,DM_STRING_VOID_CTOR,DM_STRING_TOSTRING,DM_GC,DM_BOOLEAN_CTOR,DM_EXIT,DM_CONVERT_CASE,SW_SWING_METHODS_INVOKED_IN_SWING_THREAD,DM_BOXED_PRIMITIVE_TOSTRING,DM_BOXED_PRIMITIVE_FOR_PARSING,DM_NEW_FOR_GETCLASS,DM_NEXTINT_VIA_NEXTDOUBLE,DM_USELESS_THREAD,DM_MONITOR_WAIT_ON_CONDITION,DMI_CALLING_NEXT_FROM_HASNEXT,RV_REM_OF_HASHCODE,RV_REM_OF_RANDOM_INT,RV_ABSOLUTE_VALUE_OF_RANDOM_INT,RV_ABSOLUTE_VALUE_OF_HASHCODE,BIT_ADD_OF_SIGNED_BYTE,BIT_IOR_OF_SIGNED_BYTE,INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE,INT_BAD_COMPARISON_WITH_SIGNED_BYTE,INT_BAD_REM_BY_1,DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION,INT_VACUOUS_COMPARISON,BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS,DMI_RANDOM_USED_ONLY_ONCE,DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT,DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED,DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR,DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS,DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD,DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE,INT_VACUOUS_BIT_OPERATION,DMI_COLLECTION_OF_URLS,INT_BAD_COMPARISON_WITH_INT_VALUE,DMI_DOH,DMI_ARGUMENTS_WRONG_ORDER"/>
381368 <Detector class="edu.umd.cs.findbugs.detect.NumberConstructor" speed="fast"
382369 disabled="false" reports="DM_NUMBER_CTOR,DM_FP_NUMBER_CTOR"/>
383370 <Detector class="edu.umd.cs.findbugs.detect.FindSqlInjection" speed="moderate"
453440 <Detector class="edu.umd.cs.findbugs.detect.FindUnreleasedLock" speed="moderate"
454441 requirejre="1.5" reports="UL_UNRELEASED_LOCK,UL_UNRELEASED_LOCK_EXCEPTION_PATH"/>
455442 <Detector class="edu.umd.cs.findbugs.detect.FindRefComparison" speed="slow"
456 reports="ES_COMPARING_STRINGS_WITH_EQ,ES_COMPARING_PARAMETER_STRING_WITH_EQ,RC_REF_COMPARISON,RC_REF_COMPARISON_BAD_PRACTICE,RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN,EC_UNRELATED_TYPES,EC_NULL_ARG,EC_UNRELATED_CLASS_AND_INTERFACE,EC_UNRELATED_INTERFACES,EC_ARRAY_AND_NONARRAY,EC_INCOMPATIBLE_ARRAY_COMPARE,EC_BAD_ARRAY_COMPARE,EC_UNRELATED_TYPES_USING_POINTER_EQUALITY"/>
443 reports="ES_COMPARING_STRINGS_WITH_EQ,ES_COMPARING_PARAMETER_STRING_WITH_EQ,RC_REF_COMPARISON,RC_REF_COMPARISON_BAD_PRACTICE,RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN,EC_UNRELATED_TYPES,EC_NULL_ARG,EC_UNRELATED_CLASS_AND_INTERFACE,EC_UNRELATED_INTERFACES,EC_ARRAY_AND_NONARRAY,EC_INCOMPATIBLE_ARRAY_COMPARE,EC_BAD_ARRAY_COMPARE,EC_UNRELATED_TYPES_USING_POINTER_EQUALITY,DMI_DOH"/>
457444 <Detector class="edu.umd.cs.findbugs.detect.FindMismatchedWaitOrNotify" speed="moderate"
458445 reports="MWN_MISMATCHED_WAIT,MWN_MISMATCHED_NOTIFY"/>
459446 <Detector class="edu.umd.cs.findbugs.detect.FindEmptySynchronizedBlock" speed="fast"
490477 <Detector class="edu.umd.cs.findbugs.detect.SuspiciousThreadInterrupted" speed="fast"
491478 reports="STI_INTERRUPTED_ON_CURRENTTHREAD,STI_INTERRUPTED_ON_UNKNOWNTHREAD"/>
492479 <Detector class="edu.umd.cs.findbugs.detect.FindDeadLocalStores" speed="moderate"
493 reports="DLS_DEAD_LOCAL_STORE,IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN,DLS_DEAD_LOCAL_STORE_OF_NULL,DLS_DEAD_STORE_OF_CLASS_LITERAL,DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD"/>
480 reports="DLS_DEAD_LOCAL_STORE,IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN,DLS_DEAD_LOCAL_STORE_OF_NULL,DLS_DEAD_STORE_OF_CLASS_LITERAL,DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD,DLS_DEAD_LOCAL_INCREMENT_IN_RETURN"/>
494481 <Detector class="edu.umd.cs.findbugs.detect.FindMaskedFields" speed="fast"
495482 reports="MF_METHOD_MASKS_FIELD,MF_CLASS_MASKS_FIELD"/>
496483 <Detector class="edu.umd.cs.findbugs.detect.WrongMapIterator" speed="fast"
520507 <Detector class="edu.umd.cs.findbugs.detect.IDivResultCastToDouble" speed="fast"
521508 reports="ICAST_IDIV_CAST_TO_DOUBLE,ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL,ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND"/>
522509 <Detector class="edu.umd.cs.findbugs.detect.FindBadCast2" speed="fast"
523 reports="BC_BAD_CAST_TO_CONCRETE_COLLECTION,BC_BAD_CAST_TO_ABSTRACT_COLLECTION,BC_UNCONFIRMED_CAST,BC_UNCONFIRMED_CAST_OF_RETURN_VALUE,BC_IMPOSSIBLE_CAST,BC_IMPOSSIBLE_INSTANCEOF,BC_VACUOUS_INSTANCEOF,NP_NULL_INSTANCEOF,BC_IMPOSSIBLE_DOWNCAST,BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY" />
510 reports="BC_BAD_CAST_TO_CONCRETE_COLLECTION,BC_BAD_CAST_TO_ABSTRACT_COLLECTION,BC_UNCONFIRMED_CAST,BC_UNCONFIRMED_CAST_OF_RETURN_VALUE,BC_IMPOSSIBLE_CAST,BC_IMPOSSIBLE_INSTANCEOF,BC_VACUOUS_INSTANCEOF,NP_NULL_INSTANCEOF,BC_IMPOSSIBLE_DOWNCAST,BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY" />
524511
525512 <Detector class="edu.umd.cs.findbugs.detect.FindUseOfNonSerializableValue"
526513 speed="fast" reports="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION,DMI_NONSERIALIZABLE_OBJECT_WRITTEN"/>
595582 hidden="false"/>
596583 <Detector class="edu.umd.cs.findbugs.detect.DefaultEncodingDetector" speed="fast"
597584 reports="DM_DEFAULT_ENCODING"/>
585 <Detector class="edu.umd.cs.findbugs.detect.CheckRelaxingNullnessAnnotation" speed="fast"
586 reports="NP_METHOD_RETURN_RELAXING_ANNOTATION,NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION"/>
598587
599588 <!-- Bug Categories -->
600589 <BugCategory category="NOISE" hidden="true"/>
601
590
602591 <!-- Bug Codes -->
603592 <BugCode abbrev="USELESS_STRING"/>
604593 <BugCode abbrev="DMI" cweid="440"/>
644633 <BugPattern abbrev="NP" type="NP_SYNC_AND_NULL_CHECK_FIELD" category="MT_CORRECTNESS"
645634 cweid="585"/>
646635 <BugPattern abbrev="NP" type="NP_BOOLEAN_RETURN_NULL" category="BAD_PRACTICE"/>
647 <BugPattern abbrev="NP" type="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" category="CORRECTNESS"/>
636 <BugPattern abbrev="NP" type="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" category="CORRECTNESS"/>
648637 <BugPattern abbrev="VR" type="VR_UNRESOLVABLE_REFERENCE" category="CORRECTNESS"
649638 experimental="true"/>
650639 <BugPattern abbrev="SW" type="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD"
715704 <BugPattern abbrev="Bx" type="DM_FP_NUMBER_CTOR" category="PERFORMANCE"/>
716705 <BugPattern abbrev="Dm" type="DM_CONVERT_CASE" category="I18N"/>
717706 <BugPattern abbrev="Bx" type="DM_BOXED_PRIMITIVE_TOSTRING" category="PERFORMANCE"/>
707 <BugPattern abbrev="Bx" type="DM_BOXED_PRIMITIVE_FOR_PARSING" category="PERFORMANCE"/>
718708 <BugPattern abbrev="Bx" type="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR"
719709 category="CORRECTNESS"/>
720710 <BugPattern abbrev="Bx" type="BX_UNBOXING_IMMEDIATELY_REBOXED" category="PERFORMANCE"/>
10331023 <BugPattern abbrev="STI" type="STI_INTERRUPTED_ON_CURRENTTHREAD" category="CORRECTNESS"/>
10341024 <BugPattern abbrev="STI" type="STI_INTERRUPTED_ON_UNKNOWNTHREAD" category="CORRECTNESS"/>
10351025 <BugPattern abbrev="DLS" type="DLS_DEAD_LOCAL_STORE_IN_RETURN" category="STYLE"/>
1026 <BugPattern abbrev="DLS" type="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN" category="CORRECTNESS"/>
10361027 <BugPattern abbrev="DLS" type="DLS_DEAD_STORE_OF_CLASS_LITERAL" category="CORRECTNESS"/>
10371028 <BugPattern abbrev="DLS" type="DLS_DEAD_LOCAL_STORE" category="STYLE"/>
10381029 <BugPattern abbrev="DLS" type="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD" category="STYLE"/>
10711062 <BugPattern abbrev="BC" type="BC_BAD_CAST_TO_CONCRETE_COLLECTION" category="STYLE"/>
10721063 <BugPattern abbrev="BC" type="BC_UNCONFIRMED_CAST" category="STYLE"/>
10731064 <BugPattern abbrev="BC" type="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" category="STYLE"/>
1074
1065
10751066 <BugPattern abbrev="BC" type="BC_IMPOSSIBLE_CAST_PRIMITIVE_ARRAY" category="CORRECTNESS"
10761067 deprecated="true"/>
10771068 <!-- deprecated in favor of BC_IMPOSSIBLE_CAST -->
11581149 <BugPattern abbrev="LG" type="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE"
11591150 category="EXPERIMENTAL"/>
11601151 <BugPattern abbrev="Dm" type="DM_DEFAULT_ENCODING" category="I18N" />
1152 <BugPattern abbrev="NP" type="NP_METHOD_RETURN_RELAXING_ANNOTATION" category="STYLE" />
1153 <BugPattern abbrev="NP" type="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION" category="STYLE" />
1154 <BugPattern abbrev="NP" type="NP_METHOD_PARAMETER_RELAXING_ANNOTATION" category="STYLE" deprecated="true" />
11611155 </FindbugsPlugin>
5353
5454 <FindBugsMain cmd="dis" class="edu.umd.cs.findbugs.workflow.PrintClass">
5555 <Description>Disassemble a class file</Description>
56 </FindBugsMain>
57 <FindBugsMain cmd="errors" class="edu.umd.cs.findbugs.workflowListErrors">
58 <Description>List analysis errors stored in results file
59 </Description>
5660 </FindBugsMain>
5761
5862 <!-- On changing this, please also update default cloud id in FindbugsPlugin -->
218222 <Detector class="edu.umd.cs.findbugs.detect.CheckImmutableAnnotation">
219223 <Details>
220224 <![CDATA[
221 <p> Looks for violations of the rules for classes annotated as net.jcip.annotations.Immutable.</p>
225 <p> Looks for violations of the rules for classes annotated as net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable.</p>
222226 ]]>
223227 </Details>
224228 </Detector>
15531557 ]]>
15541558 </Details>
15551559 </Detector>
1560 <Detector class="edu.umd.cs.findbugs.detect.CheckRelaxingNullnessAnnotation">
1561 <Details>
1562 <![CDATA[
1563 <p>Checks that overriding methods do not relax @Nonnull (made @CheckForNull) on return values
1564 or @CheckForNull (made @Nonnull) on parameters.</p>
1565 ]]>
1566 </Details>
1567 </Detector>
15561568 <!--
15571569 **********************************************************************
15581570 BugPatterns
21582170 </BugPattern>
21592171 <BugPattern type="DP_DO_INSIDE_DO_PRIVILEGED">
21602172 <ShortDescription>Method invoked that should be only be invoked inside a doPrivileged block</ShortDescription>
2161 <LongDescription>invocation of {2}, which should be invoked from within a doPrivileged block, in {1}</LongDescription>
2173 <LongDescription>Invocation of {2}, which should be invoked from within a doPrivileged block, in {1}</LongDescription>
21622174 <Details>
21632175 <![CDATA[
21642176 <p> This code invokes a method that requires a security permission check.
21702182 <BugPattern type="DP_DO_INSIDE_DO_PRIVILEDGED">
21712183 <!-- misspelled for backward compatibility -->
21722184 <ShortDescription>Method invoked that should be only be invoked inside a doPrivileged block</ShortDescription>
2173 <LongDescription>invocation of {2}, which should be invoked from within a doPrivileged block, in {1}</LongDescription>
2185 <LongDescription>Invocation of {2}, which should be invoked from within a doPrivileged block, in {1}</LongDescription>
21742186 <Details>
21752187 <![CDATA[
21762188 <p> This code invokes a method that requires a security permission check.
21952207 <LongDescription>{1.givenClass} should be final since {0} is marked as Immutable. </LongDescription>
21962208 <Details>
21972209 <![CDATA[
2198 <p> The class is annotated with net.jcip.annotations.Immutable, and the rules for that annotation require
2199 that all fields are final.
2210 <p> The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable,
2211 and the rules for those annotations require that all fields are final.
22002212 .</p>
22012213 ]]>
22022214 </Details>
22282240 </BugPattern>
22292241 <BugPattern type="DMI_BLOCKING_METHODS_ON_URL">
22302242 <ShortDescription>The equals and hashCode methods of URL are blocking</ShortDescription>
2231 <LongDescription>invocation of {2}, which blocks to do domain name resolution, in {1}</LongDescription>
2243 <LongDescription>Invocation of {2}, which blocks to do domain name resolution, in {1}</LongDescription>
22322244 <Details>
22332245 <![CDATA[
22342246 <p> The equals and hashCode
22412253 </BugPattern>
22422254 <BugPattern type="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">
22432255 <ShortDescription>Can't use reflection to check for presence of annotation without runtime retention</ShortDescription>
2244 <LongDescription>use of reflection to check for the presence the annotation {3} which doesn't have runtime retention, in {1}</LongDescription>
2256 <LongDescription>Use of reflection to check for the presence the annotation {3} which doesn't have runtime retention, in {1}</LongDescription>
22452257 <Details>
22462258 <![CDATA[
22472259 <p> Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection
24592471 ]]>
24602472 </Details>
24612473 </BugPattern>
2474 <BugPattern type="DM_BOXED_PRIMITIVE_FOR_PARSING">
2475 <ShortDescription>Boxing/unboxing to parse a primitive</ShortDescription>
2476 <LongDescription>Boxing/unboxing to parse a primitive {1}</LongDescription>
2477 <Details>
2478 <![CDATA[
2479 <p>A boxed primitive is created from a String, just to extract the unboxed primitive value.
2480 It is more efficient to just call the static parseXXX method.</p>
2481 ]]>
2482 </Details>
2483 </BugPattern>
24622484 <BugPattern type="DM_NEW_FOR_GETCLASS">
24632485 <ShortDescription>Method allocates an object, only to get the class object</ShortDescription>
24642486 <LongDescription>{1} allocates an object, only to get the class object</LongDescription>
26352657 </BugPattern>
26362658 <BugPattern type="FI_EXPLICIT_INVOCATION">
26372659 <ShortDescription>Explicit invocation of finalizer</ShortDescription>
2638 <LongDescription>explicit invocation of {2} in {1}</LongDescription>
2660 <LongDescription>Explicit invocation of {2} in {1}</LongDescription>
26392661 <Details>
26402662 <![CDATA[
26412663 <p> This method contains an explicit invocation of the <code>finalize()</code>
26752697 </BugPattern>
26762698 <BugPattern type="EQ_DONT_DEFINE_EQUALS_FOR_ENUM">
26772699 <ShortDescription>Covariant equals() method defined for enum</ShortDescription>
2678 <LongDescription>enum {0} defines equals({0.givenClass})</LongDescription>
2700 <LongDescription>Enum {0} defines equals({0.givenClass})</LongDescription>
26792701 <Details>
26802702 <![CDATA[
26812703 <p> This class defines an enumeration, and equality on enumerations are defined
31063128 <LongDescription>{1.givenClass} not guarded against concurrent access; locked {2}% of time</LongDescription>
31073129 <Details>
31083130 <![CDATA[
3109 <p> This field is annotated with net.jcip.annotations.GuardedBy,
3110 but can be accessed in a way that seems to violate the annotation.</p>
3131 <p> This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy,
3132 but can be accessed in a way that seems to violate those annotations.</p>
31113133 ]]>
31123134 </Details>
31133135 </BugPattern>
31363158 </p>
31373159 <ul>
31383160 <li> The class contains a mix of locked and unlocked accesses,</li>
3161 <li> The class is <b>not</b> annotated as javax.annotation.concurrent.NotThreadSafe,</li>
31393162 <li> At least one locked access was performed by one of the class's own methods, and</li>
31403163 <li> The number of unsynchronized field accesses (reads and writes) was no more than
31413164 one third of all accesses, with writes being weighed twice as high as reads</li>
31773200 </BugPattern>
31783201 <BugPattern type="MS_EXPOSE_REP">
31793202 <ShortDescription>Public static method may expose internal representation by returning array</ShortDescription>
3180 <LongDescription>public static {1} may expose internal representation by returning {2.givenClass}</LongDescription>
3203 <LongDescription>Public static {1} may expose internal representation by returning {2.givenClass}</LongDescription>
31813204 <Details>
31823205 <![CDATA[
31833206 <p> A public static method returns a reference to
37383761 </Details>
37393762 </BugPattern>
37403763 <BugPattern type="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">
3741 <ShortDescription>Ambiguous invocation of either an inherited or outer method</ShortDescription>
3742 <LongDescription>Ambiguous invocation of either an outer or inherited method {2} in {1}</LongDescription>
3743 <Details>
3744 <![CDATA[
3745 <p> An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. By the Java semantics,
3764 <ShortDescription>Potentially ambiguous invocation of either an inherited or outer method</ShortDescription>
3765 <LongDescription>Potentially ambiguous invocation of either an outer or inherited method {2} in {1}</LongDescription>
3766 <Details>
3767 <![CDATA[
3768 <p>
3769 An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class.
3770 For example, you invoke <code>foo(17)</code>, which is defined in both a superclass and in an outer method.
3771 By the Java semantics,
37463772 it will be resolved to invoke the inherited method, but this may not be want
3747 you intend. If you really intend to invoke the inherited method,
3773 you intend.
3774 </p>
3775 <p>If you really intend to invoke the inherited method,
37483776 invoke it by invoking the method on super (e.g., invoke super.foo(17)), and
37493777 thus it will be clear to other readers of your code and to FindBugs
37503778 that you want to invoke the inherited method, not the method in the outer class.
3779 </p>
3780 <p>If you call <code>this.foo(17)</code>, then the inherited method will be invoked. However, since FindBugs only looks at
3781 classfiles, it
3782 can't tell the difference between an invocation of <code>this.foo(17)</code> and <code>foo(17)</code>, it will still
3783 complain about a potential ambiguous invocation.
37513784 </p>
37523785 ]]>
37533786 </Details>
40134046 </Details>
40144047 </BugPattern>
40154048 <BugPattern type="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">
4016 <ShortDescription>private readResolve method not inherited by subclasses</ShortDescription>
4017 <LongDescription>private readResolve method in {0} not inherited by subclasses.</LongDescription>
4049 <ShortDescription>Private readResolve method not inherited by subclasses</ShortDescription>
4050 <LongDescription>Private readResolve method in {0} not inherited by subclasses.</LongDescription>
40184051 <Details>
40194052 <![CDATA[
40204053 <p> This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses.
46094642
46104643 <BugPattern type="RV_RETURN_VALUE_IGNORED_INFERRED">
46114644 <ShortDescription>Method ignores return value, is this OK?</ShortDescription>
4612 <LongDescription>return value of {2.givenClass} ignored, is this OK in {1}</LongDescription>
4645 <LongDescription>Return value of {2.givenClass} ignored, is this OK in {1}</LongDescription>
46134646 <Details>
46144647 <![CDATA[
46154648 <p>This code calls a method and ignores the return value. The return value
46304663
46314664 <BugPattern type="RV_RETURN_VALUE_IGNORED">
46324665 <ShortDescription>Method ignores return value</ShortDescription>
4633 <LongDescription>return value of {2.givenClass} ignored in {1}</LongDescription>
4666 <LongDescription>Return value of {2.givenClass} ignored in {1}</LongDescription>
46344667 <Details>
46354668 <![CDATA[
46364669 <p> The return value of this method should be checked. One common
46604693
46614694 <BugPattern type="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">
46624695 <ShortDescription>Method ignores exceptional return value</ShortDescription>
4663 <LongDescription>exceptional return value of {2} ignored in {1}</LongDescription>
4696 <LongDescription>Exceptional return value of {2} ignored in {1}</LongDescription>
46644697 <Details>
46654698 <![CDATA[
46664699 <p> This method returns a value that is not checked. The return value should be checked
61416174 </BugPattern>
61426175 <BugPattern type="EC_INCOMPATIBLE_ARRAY_COMPARE">
61436176 <ShortDescription>equals(...) used to compare incompatible arrays</ShortDescription>
6144 <LongDescription>using equals to compare a {2.simpleClass} and a {3.simpleClass} in {1}</LongDescription>
6177 <LongDescription>Using equals to compare a {2.simpleClass} and a {3.simpleClass} in {1}</LongDescription>
61456178 <Details>
61466179 <![CDATA[
61476180 <p>
62266259 ]]>
62276260 </Details>
62286261 </BugPattern>
6262
62296263 <BugPattern type="DLS_DEAD_LOCAL_STORE_IN_RETURN">
62306264 <ShortDescription>Useless assignment in return statement</ShortDescription>
62316265 <LongDescription>Useless assignment in return from {1}</LongDescription>
62386272 ]]>
62396273 </Details>
62406274 </BugPattern>
6275 <BugPattern type="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">
6276 <ShortDescription>Useless increment in return statement</ShortDescription>
6277 <LongDescription>Useless increment in return from {1}</LongDescription>
6278 <Details>
6279 <![CDATA[
6280 <p>This statement has a return such as <code>return x++;</code>.
6281 A postfix increment/decrement does not impact the value of the expression,
6282 so this increment/decrement has no effect.
6283 Please verify that this statement does the right thing.
6284 </p>
6285 ]]>
6286 </Details>
6287 </BugPattern>
6288
6289
6290
62416291 <BugPattern type="DLS_DEAD_STORE_OF_CLASS_LITERAL">
62426292 <ShortDescription>Dead store of class literal</ShortDescription>
62436293 <LongDescription>Dead store of {3}.class in {1}</LongDescription>
66126662 </Details>
66136663 </BugPattern>
66146664 <BugPattern type="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">
6615 <ShortDescription>integral value cast to double and then passed to Math.ceil</ShortDescription>
6616 <LongDescription>integral value cast to double and then passed to Math.ceil in {1}</LongDescription>
6665 <ShortDescription>Integral value cast to double and then passed to Math.ceil</ShortDescription>
6666 <LongDescription>Integral value cast to double and then passed to Math.ceil in {1}</LongDescription>
66176667 <Details>
66186668 <![CDATA[
66196669 <p>
66326682 </Details>
66336683 </BugPattern>
66346684 <BugPattern type="ICAST_IDIV_CAST_TO_DOUBLE">
6635 <ShortDescription>integral division result cast to double or float</ShortDescription>
6636 <LongDescription>integral division result cast to double or float in {1}</LongDescription>
6685 <ShortDescription>Integral division result cast to double or float</ShortDescription>
6686 <LongDescription>Integral division result cast to double or float in {1}</LongDescription>
66376687 <Details>
66386688 <![CDATA[
66396689 <p>
68136863 </BugPattern>
68146864 <BugPattern type="VA_FORMAT_STRING_MISSING_ARGUMENT">
68156865 <ShortDescription>Format string references missing argument</ShortDescription>
6816 <LongDescription>format string "{3}" needs argument {5} but only {6} are provided in {1}</LongDescription>
6866 <LongDescription>Format string "{3}" needs argument {5} but only {6} are provided in {1}</LongDescription>
68176867 <Details>
68186868 <![CDATA[
68196869 <p>
70537103 </Details>
70547104 </BugPattern>
70557105 <BugPattern type="RE_POSSIBLE_UNINTENDED_PATTERN">
7056 <ShortDescription>"." used for regular expression</ShortDescription>
7057 <LongDescription>"." used for regular expression in {1}</LongDescription>
7106 <ShortDescription>"." or "|" used for regular expression</ShortDescription>
7107 <LongDescription>"." or "|" used for regular expression in {1}</LongDescription>
70587108 <Details>
70597109 <![CDATA[
70607110 <p>
7061 A String function is being invoked and "." is being passed
7111 A String function is being invoked and "." or "|" is being passed
70627112 to a parameter that takes a regular expression as an argument. Is this what you intended?
70637113 For example
7064 s.replaceAll(".", "/") will return a String in which <em>every</em>
7065 character has been replaced by a / character,
7066 and s.split(".") <em>always</em> returns a zero length array of String.
7114 <li>s.replaceAll(".", "/") will return a String in which <em>every</em> character has been replaced by a '/' character
7115 <li>s.split(".") <em>always</em> returns a zero length array of String
7116 <li>"ab|cd".replaceAll("|", "/") will return "/a/b/|/c/d/"
7117 <li>"ab|cd".split("|") will return array with six (!) elements: [, a, b, |, c, d]
70677118 </p>
70687119 ]]>
70697120 </Details>
72437294 </BugPattern>
72447295 <BugPattern type="DMI_BAD_MONTH">
72457296 <ShortDescription>Bad constant value for month</ShortDescription>
7246 <LongDescription>bad month value of {2} passed to {3} in {1}</LongDescription>
7297 <LongDescription>Bad month value of {2} passed to {3} in {1}</LongDescription>
72477298 <Details>
72487299 <![CDATA[
72497300 <p>
76647715 <![CDATA[
76657716 <p>
76667717 A value is being used in a way that requires the value be annotation with a type qualifier.
7667 The type qualifier is strict, so the tool rejects any values that do not have
7668 the appropriate annotation.
7718 The type qualifier is strict, so the tool rejects any values that do not have
7719 the appropriate annotation.
76697720 </p>
76707721
76717722 <p>
76727723 To coerce a value to have a strict annotation, define an identity function where the return value is annotated
7673 with the strict annotation.
7674 This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.
7724 with the strict annotation.
7725 This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.
76757726 </p>
76767727
76777728 ]]>
80088059 <![CDATA[
80098060 <p> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. </p>
80108061 ]]>
8062 </Details>
8063 </BugPattern>
8064 <BugPattern type="NP_METHOD_PARAMETER_RELAXING_ANNOTATION">
8065 <ShortDescription>Method tightens nullness annotation on parameter</ShortDescription>
8066 <LongDescription>Method {1} overrides the nullness annotation relaxing the ancestor method requirements on parameter.</LongDescription>
8067 <Details>
8068 <![CDATA[<p>
8069 A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter
8070 that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.
8071 Doing so violates the contract that the method should handle a null parameter.
8072 </p>]]>
8073 </Details>
8074 </BugPattern>
8075 <BugPattern type="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">
8076 <ShortDescription>Method tightens nullness annotation on parameter</ShortDescription>
8077 <LongDescription>Method {1} overrides the nullness annotation of parameter {2} in an incompatible way</LongDescription>
8078 <Details>
8079 <![CDATA[<p>
8080 A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter
8081 that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.
8082 Doing so violates the contract that the method should handle a null parameter.
8083 </p>]]>
8084 </Details>
8085 </BugPattern>
8086
8087 <BugPattern type="NP_METHOD_RETURN_RELAXING_ANNOTATION">
8088 <ShortDescription>Method relaxes nullness annotation on return value</ShortDescription>
8089 <LongDescription>Method {1} overrides the return value nullness annotation in an incompatible way.</LongDescription>
8090 <Details>
8091 <![CDATA[<p>
8092 A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated
8093 as returning a @Nonnull value,
8094 you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value.
8095 Doing so violates the contract that the method shouldn't return null.
8096 </p>]]>
80118097 </Details>
80128098 </BugPattern>
80138099 <!--
5353 <FindBugsMain cmd="dis" class="edu.umd.cs.findbugs.workflow.PrintClass">
5454 <Description>Disassemble a class file</Description>
5555 </FindBugsMain>
56 <FindBugsMain cmd="errors" class="edu.umd.cs.findbugs.workflowListErrors">
57 <Description>List analysis errors stored in results file</Description>
58 </FindBugsMain>
5659
5760 <!-- これを変えたら FindbugsPlugin のデフォルト ID も更新して下さい -->
5861 <Cloud id="edu.umd.cs.findbugs.cloud.doNothingCloud">
99102 <BugCategory category="CORRECTNESS">
100103 <Description>正確性</Description>
101104 <Abbreviation>C</Abbreviation>
102 <Details>バグの可能性 - おそらく、開発者が意図していなかったコードになっている明らかなコーディング間違い。
105 <Details>バグの可能性 - おそらく、開発者が意図していなかったコードになっている明らかなコーディング間違いです。
103106 我々は、低い誤検出率のために努力します。
104107 </Details>
105108 </BugCategory>
121124 <BugCategory category="BAD_PRACTICE">
122125 <Description>バッドプラクティス</Description>
123126 <Abbreviation>B</Abbreviation>
124 <Details>推奨または必須のコーディングプラクティスの違反です。たとえば、hashCode と equals の問題、cloneable イディオム、捨てられた例外、Serializable の問題、finalize の誤用など。
127 <Details>推奨または必須のコーディングプラクティスの違反です。たとえば、hashCode と equals の問題、cloneable イディオム、捨てられた例外、Serializable の問題、finalize の誤用などです。
125128 いくつかのグループは、バッドプラクティスを気にしないかもしれないが、我々は正確な解析をしようと努力します。
126129 </Details>
127130 </BugCategory>
129132 <BugCategory category="STYLE">
130133 <Description>危ないコード</Description>
131134 <Abbreviation>D</Abbreviation>
132 <Details>紛らわしいコード、変則的なコード、それ自身をエラーに導く方法で書かれたコード。
135 <Details>紛らわしいコード、変則的なコード、それ自身をエラーに導く方法で書かれたコードです。
133136 たとえば、ローカル変数への無効な代入、switch 文のフォールスルー、未確認のキャスト、null とわかっている値の冗長な null チェックなどです。
134137 より多くの誤検出を受け入れました。
135138 FindBugs の以前のバージョンでは、このカテゴリは Style として知られていました。
136     </Details>
139 </Details>
137140 </BugCategory>
138141
139142 <BugCategory category="PERFORMANCE">
248251 <Details>
249252 <![CDATA[
250253 <p>
251 このディテクタは、net.jcip.annotations.Immutable としてアノテートされたクラスのルール違反を探します。
254 このディテクタは、net.jcip.annotations.Immutable または javax.annotation.concurrent.Immutable としてアノテートされたクラスのルール違反を探します。
252255 </p>
253256 ]]>
254257 </Details>
513516 <Details>
514517 <![CDATA[
515518 <p>
516 このディテクタは、無名内部クラスに定義されたメソッドで、スーパークラスのメソッドをオーバーライドすることを意図しているのに、実際はオーバーライドになっていないメソッドを探します。
519 このディテクタは、無名内部クラスに定義されたメソッドで、スーパークラスのメソッドをオーバーライドすることを意図していますが、実際はオーバーライドになっていないメソッドを探します。
517520 </p>
518521 ]]>
519522 </Details>
604607 <Details>
605608 <![CDATA[
606609 <p>
607 このディテクタは、新しいディテクタをテストするためのフックです。通常、このディテクタは何もしません。
610 このディテクタは、新しいディテクタをテストするためのフックです。一般に、このディテクタは何もしません。
608611 </p>
609612 ]]>
610613 </Details>
614617 <Details>
615618 <![CDATA[
616619 <p>
617 このディテクタは、新しいディテクタをテストするためのフックです。通常、このディテクタは何もしません。
620 このディテクタは、新しいディテクタをテストするためのフックです。一般に、このディテクタは何もしません。
618621 </p>
619622 ]]>
620623 </Details>
634637 <Details>
635638 <![CDATA[
636639 <p>
637 このディテクタは、新しいディテクタをテストするためのフックです。通常、このディテクタは何もしません。
640 このディテクタは、新しいディテクタをテストするためのフックです。一般に、このディテクタは何もしません。
638641 </p>
639642 ]]>
640643 </Details>
648651 これらの警告はソフトウェアで実際のバグを発見するのではなく、データマイニング実験のコントロールとして役に立つことを目的とした偽のランダムノイズです。
649652 </p>
650653 <p>
651 このディテクタは、新しいディテクタをテストするためのフックです。通常、このディテクタは何もしません。
654 このディテクタは、新しいディテクタをテストするためのフックです。一般に、このディテクタは何もしません。
652655 </p>
653656 ]]>
654657 </Details>
789792 <Details>
790793 <![CDATA[
791794 <p>
792 このディテクタは、例外をキャッチしているのに何もしていないコードを探します。
795 このディテクタは、例外をキャッチしていますが、何もしていないコードを探します。
793796 </p>
794797 ]]>
795798 </Details>
11891192 中速ディテクタです。
11901193 </p>
11911194 <p>
1192 このディテクタを使用するために、補助クラスパスに <code>java.util.concurrent</code> パッケージ (またはパッケージ自体を解析している) が必要であることに注意してください。
1195 このディテクタを使用するために、補助クラスパスに java.util.concurrent パッケージ (またはパッケージ自体を解析している) が必要であることに注意してください。
11931196 </p>
11941197 ]]>
11951198 </Details>
12001203 <![CDATA[
12011204 <p>
12021205 このディテクタは、2つの参照値を == や != 演算子で比較している場所を探します。
1203 <code>java.lang.String</code> のような型のクラスで参照値を比較することは、通常誤りです。
1206 <code>java.lang.String</code> のような型のクラスで参照値を比較することは、一般に誤りです。
12041207 </p>
12051208 </p>
12061209 低速ディテクタです。
12841287 <Details>
12851288 <![CDATA[
12861289 <p>
1287 このディテクタは、JSR-166のロックで実行される通常の同期化を探します。
1290 このディテクタは、JSR-166のロックで実行される一般にの同期化を探します。
12881291 </p>
12891292 <p>
12901293 中速ディテクタです。
13321335 ]]>
13331336 </Details>
13341337 </Detector>
1335
13361338 <Detector class="edu.umd.cs.findbugs.detect.BadlyOverriddenAdapter">
13371339 <Details>
13381340 <![CDATA[
13471349 <Details>
13481350 <![CDATA[
13491351 <p>
1350 このディテクタは、列インデックス番号が0の <code>ResultSet</code>の getXXX または setXXX メソッドの呼び出しを探します。
1352 このディテクタは、列インデックス番号が0の <code>ResultSet</code> の getXXX または setXXX メソッドの呼び出しを探します。
13511353 <code>ResultSet</code> の列インデックス番号は1で始まるので、これは常に間違いです。
13521354 </p>
13531355 ]]>
13801382 <![CDATA[
13811383 <p>
13821384 このディテクタは、非スタティックな文脈から <code>Thread.interrupted()</code> の呼び出しを探します。
1383 それが <code>Thread.currentThread().interrupted()</code> から呼び出されるなら、役に立たない行為なので <code>Thread.interrupted()</code> を使用します。
1385 <code>Thread.currentThread().interrupted()</code> から呼び出されるなら、役に立たない行為なので <code>Thread.interrupted()</code> を使用します。
13841386 しかしながら、<code>interrupted</code> メソッドは常にカレントスレッドで呼び出されるので、任意のスレッドオブジェクトで呼び出すのはほぼ間違いなく誤りです。
13851387 </p>
13861388 ]]>
15021504 <![CDATA[
15031505 <p>
15041506 このディテクタは、スーパークラスと同じインタフェースを実装すると宣言しているサブクラスを探します。
1505 スーパークラスでインタフェースを実装するので、サブクラスで同じことをするのは冗長です。
1507 スーパークラスがインタフェースを実装しているので、サブクラスで同じことをするのは冗長です。
15061508 </p>
15071509 ]]>
15081510 </Details>
15751577 <Details>
15761578 <![CDATA[
15771579 <p>
1578 このディテクタは、それらが直列化可能であることを要求するコンテキストで、非Serializableなオブジェクトの使用方法を探します。
1580 このディテクタは、それらが直列化可能であることを要求するコンテキストで、非 Serializable オブジェクトの使用を探します。
15791581 </p>
15801582 ]]>
15811583 </Details>
15851587 <Details>
15861588 <![CDATA[
15871589 <p>
1588 このディテクタは、<code>ObjectOutput</code> の <code>writeObject</code> メソッドに渡された非直列化オブジェクトを探します。
1590 このディテクタは、<code>ObjectOutput</code> の <code>writeObject</code> メソッドに渡される非 Serializable オブジェクトを探します。
15891591 </p>
15901592 ]]>
15911593 </Details>
16271629 <Details>
16281630 <![CDATA[
16291631 <p>
1630 このディテクタは、2つの分岐に同じコードがあるために分岐が無効になっている if/else または switch 文を探します。
1631 これは2つの分岐に同じコードをコピー &amp; ペーストしていることが片方の分岐の間違ったロジックの原因になります。
1632 このディテクタは、2つの分岐に同じコードがある if/else または switch 文を探します。
1633 これは多くの場合、2つの分岐に同じコードをコピー &amp; ペーストしていることが片方の分岐の間違ったロジックの原因になります。
16321634 </p>
16331635 ]]>
16341636 </Details>
16401642 <p>
16411643 このディテクタは、所有クラスの private フィールドに書き込んでいる内部クラスを探します。
16421644 この場合、コンパイラは必ずこのフィールドへ書き込むことに使われるアクセッサーメソッドを生成します。
1643 可視性を protected に緩和することは、直接書き込むことを可能にします。
1645 可視性を protected に緩和することは、フィールドに直接書き込むことを可能にします。
16441646 </p>
16451647 ]]>
16461648 </Details>
16501652 <Details>
16511653 <![CDATA[
16521654 <p>
1653 このディテクタは、XML インタフェースを実装したクラスのインスタンスを作成しているコードを探します。
1655 このディテクタは、XML インタフェースを実装したクラスのインスタンスを直接生成しているコードを探します。
16541656 これらのオブジェクトを作成するために提供されたファクトリパターンを使用するのではなく、特定の実装にコードを結びつけます。
16551657 </p>
16561658 ]]>
16971699 <![CDATA[
16981700 <p>
16991701 このディテクタは、どのメソッドが null を返すのかを決定してファイルに保存します。
1700 結果ファイルは、null 参照解除ディテクタの精度を向上させるために後続のパスで使われるかもしれません。
1702 結果ファイルは、null 間接参照ディテクタの精度を向上させるために後続のパスで使われるかもしれません。
17011703 これはトレーニングパスなので警告は報告されません。
17021704 </p>
17031705 <p>
17121714 <![CDATA[
17131715 <p>
17141716 このディテクタは、どのメソッドが null 値のパラメータを無条件で利用するのかを決定してファイルに保存します。
1715 結果ファイルは、 null 参照解除ディテクタの精度を向上させるために後続のパスで使われるかもしれません。
1717 結果ファイルは、 null 間接参照ディテクタの精度を向上させるために後続のパスで使われるかもしれません。
17161718 これはトレーニングパスなので警告は報告されません。
17171719 </p>
17181720 <p>
17891791 無関係なクラス型による引数は決してコレクションの中に格納されることはありません。
17901792 たとえば、<code>foo</code> が <code>List&lt;String&gt;</code> で、<code>bar</code> が <code>StringBuffer</code> なら <code>foo.contains(bar)</code> の呼び出しは常に false を返すことになります。
17911793 </p>
1794 <p>
17921795 高速ディテクタです。
17931796 </p>
1794 </p>
17951797 ]]>
17961798 </Details>
17971799 </Detector>
18101812 <Details>
18111813 <![CDATA[
18121814 <p>
1813 これはデータフロー解析をテストするためにだけ使われる内部のディテクタです。
1815 これはデータフロー解析を検証するためにだけ使われる内部のディテクタです。
18141816 </p>
18151817 <p>
18161818 デフォルトでは有効にされません。
18621864 <Details>
18631865 <![CDATA[
18641866 <p>
1865 このディテクタは、スーパークラスのためにコンストラクタから呼び出されるメソッドをチェックします。
1867 このディテクタは、スーパークラスのためのコンストラクタから呼び出されるメソッドをチェックします。
18661868 </p>
18671869 ]]>
18681870 </Details>
18781880 ]]>
18791881 </Details>
18801882 </Detector>
1881
1883
1884 <Detector class="edu.umd.cs.findbugs.detect.CheckRelaxingNullnessAnnotation">
1885 <Details>
1886 <![CDATA[
1887 <p>
1888 このディテクタは、オーバライドメソッドが 戻り値またはパラメータの @CheckForNull (@Nonnullで作られた) で @Nonnull (@CheckForNull で作られた) を緩和していないことをチェックします。
1889 </p>
1890 ]]>
1891 </Details>
1892 </Detector>
1893
18821894 <!--
18831895 **********************************************************************
18841896 BugPatterns
18981910 </BugPattern>
18991911
19001912 <BugPattern type="NOISE_NULL_DEREFERENCE">
1901 <ShortDescription>null 値の利用に関する偽の警告</ShortDescription>
1902 <LongDescription>null 値の利用に関する偽の警告です。{1}</LongDescription>
1913 <ShortDescription>null ポインタ間接参照に関する偽の警告</ShortDescription>
1914 <LongDescription>null ポインタ間接参照に関する偽の警告です。{1}</LongDescription>
19031915 <Details>
19041916 <![CDATA[
19051917 <p>
19521964 <![CDATA[
19531965 <p>
19541966 このコードは、10進数の数にうまく変換されない double 値から BigDecimal を作成しています。
1955 たとえば、Java で new BigDecimal(0.1) と書くと0.1と正確に等しい BigDecimal (スケールが1で、スケールなしの値が1) が作成されると思うかもしれませんが
1967 たとえば、Java で <code>new BigDecimal(0.1)</code> と書くと、0.1と正確に等しい BigDecimal (スケールが1でスケールなしの値が1) が作成されると思うかもしれませんが
19561968 実際には0.1000000000000000055511151231257827021181583404541015625と等しくなります。
19571969 </p>
19581970 <p>
1959 おそらくBigDecimal.valueOf(double d) メソッドの使用が望ましいです。BigDecimal(たとえば、BigDecimal.valueOf(0.1) は0.1を与えます) を作成するためには double の文字列表現を使用します。
1971 おそらく <code>BigDecimal.valueOf(double d)</code> メソッドの使用が望ましいです。BigDecimal(たとえば、<code>BigDecimal.valueOf(0.1)</code> は0.1を与えます) を作成するためには double の文字列表現を使用します。
19601972 </p>
19611973 ]]>
19621974 </Details>
19681980 <Details>
19691981 <![CDATA[
19701982 <p>
1971 この実用的なメソッド呼び出しは、検査から明らかな理由で意味がないです。
1983 この部分的なメソッド呼び出しは、検査から明らかな理由で意味がありません。
19721984 </p>
19731985 ]]>
19741986 </Details>
19801992 <Details>
19811993 <![CDATA[
19821994 <p>
1983 この呼び出しはどんなオブジェクトも EasyMock メソッドに渡さないので何もしません。
1995 この呼び出しは EasyMock メソッドにどんなオブジェクトも渡さないので何もしません。
19841996 </p>
19851997 ]]>
19861998 </Details>
20062018 <Details>
20072019 <![CDATA[
20082020 <p>
2009 <code>ScheduledThreadPoolExecutor</code> は <code>ThreadPoolExecutor</code> から継承されますが、継承されたチューニングメソッドの一部は有用ではありません。
2010 特に、corePoolSize スレッドとアンバウンド形式のキューを使用する固定サイズプールとして動作するので、maximumPoolSize の調整は有用な効果がありません。<br>
2021 <code>ScheduledThreadPoolExecutor</code> は <code>ThreadPoolExecutor</code> から継承されますが継承されたチューニングメソッドの一部は有効ではありません。
2022 特に、corePoolSize スレッドとアンバウンド形式のキューを使用する固定サイズプールとして動作するので、maximumPoolSize の調整は有効な効果がありません。<br>
20112023 (<a href="http://java.sun.com/javase/ja/6/docs/ja/api/java/util/concurrent/ScheduledThreadPoolExecutor.html">Javadoc</a>)
20122024 </p>
2013
20142025 ]]>
20152026 </Details>
20162027 </BugPattern>
20212032 <Details>
20222033 <![CDATA[
20232034 <p>
2024 このメソッド呼び出しのすべてのターゲットが <code>UnsupportedOperationException</code> をスローします。
2035 このメソッド呼び出しのすべてのターゲットは <code>UnsupportedOperationException</code> をスローします。
20252036 </p>
20262037
20272038 ]]>
20372048 このコードは、空白または空のパスワードを使用してデータベース接続を作成しています。
20382049 これはデータベースがパスワードによって保護されていないことを示しています。
20392050 </p>
2040
20412051 ]]>
20422052 </Details>
20432053 </BugPattern>
20502060 このコードは、ハードコードされた定数パスワードを使用してデータベース接続を作成しています。
20512061 ソースコードかコンパイルされたコードへアクセスできる人なら誰でも簡単にパスワードを知ることができてしまいます。
20522062 </p>
2053
20542063 ]]>
20552064 </Details>
20562065 </BugPattern>
20612070 <Details>
20622071 <![CDATA[
20632072 <p>
2064 このコードは、信頼できない HTTP パラメータを使用して HTTP クッキーを構築しています。
2073 このコードは信頼できない HTTP パラメータを使用して HTTP クッキーを構築しています。
20652074 このクッキーが HTTP レスポンスに追加されるなら、HRS(HTTP レスポンススプリッティング) 脆弱性を可能にします。<br>
20662075 詳細は、<a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a> を参照してください。
20672076 </p>
20762085
20772086 <BugPattern type="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">
20782087 <ShortDescription>HTTP レスポンススプリッティング脆弱性</ShortDescription>
2079 <LongDescription>HTTP ヘッダ出力に HTTP パラメータをそのまま書き込んでいます。{1}</LongDescription>
2080 <Details>
2081 <![CDATA[
2082 <p>
2083 このコードは、HTTP ヘッダに HTTP パラメータをそのまま書き込んでいます。これは HRS(HTTP レスポンススプリッティング) 脆弱性を可能にします。<br>
2088 <LongDescription>HTTP ヘッダ出力に HTTP パラメータを直接書き込んでいます。{1}</LongDescription>
2089 <Details>
2090 <![CDATA[
2091 <p>
2092 このコードは、HTTP ヘッダに HTTP パラメータを直接書き込んでいます。これは HRS(HTTP レスポンススプリッティング) 脆弱性を可能にします。<br>
20842093 詳細は、<a href="http://en.wikipedia.org/wiki/HTTP_response_splitting">http://en.wikipedia.org/wiki/HTTP_response_splitting</a> を参照してください。
20852094 </p>
20862095 <p>
2087 FindBugs は、HRS のもっとも露骨で自明なケースだけを探します。
2096 FindBugs は、HRS の最も露骨で自明なケースだけを探します。
20882097 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
20892098 HRS を心配するなら、商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
20902099 </p>
21012110 詳細は、<a href="http://cwe.mitre.org/data/definitions/23.html">http://cwe.mitre.org/data/definitions/23.html</a> を参照してください。
21022111 </p>
21032112 <p>
2104 FindBugs は、相対パストラバーサルのもっとも露骨で自明なケースだけを探します。
2113 FindBugs は、相対パストラバーサルの最も露骨で自明なケースだけを探します。
21052114 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
21062115 相対パストラバーサルを心配するなら、商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
21072116 </p>
21182127 詳細は、<a href="http://cwe.mitre.org/data/definitions/36.html">http://cwe.mitre.org/data/definitions/36.html</a> を参照してください。
21192128 </p>
21202129 <p>
2121 FindBugs は、相対パストラバーサルのもっとも露骨で自明なケースだけを探します。
2130 FindBugs は、相対パストラバーサルの最も露骨で自明なケースだけを探します。
21222131 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
21232132 相対パストラバーサルを心配するなら、商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
21242133 </p>
21272136 </BugPattern>
21282137 <BugPattern type="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">
21292138 <ShortDescription>反射型クロスサイトスクリプティング脆弱性があるサーブレット</ShortDescription>
2130 <LongDescription>サーブレットの出力に HTTP パラメータをそのまま書き込んでいます。{1}</LongDescription>
2131 <Details>
2132 <![CDATA[
2133 <p>
2134 このコードは、サーブレットの出力に HTTP パラメータをそのまま書き込んでいます。これは反射型 XSS(クロスサイトスクリプティング) 脆弱性を可能にします。<br>
2139 <LongDescription>サーブレットの出力に HTTP パラメータを直接書き込んでいます。{1}</LongDescription>
2140 <Details>
2141 <![CDATA[
2142 <p>
2143 このコードは、サーブレットの出力に HTTP パラメータを直接書き込んでいます。これは反射型 XSS(クロスサイトスクリプティング) 脆弱性を可能にします。<br>
21352144 詳細は、<a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a> を参照してください。
21362145 </p>
21372146 <p>
2138 FindBugs は、XSS のもっとも露骨で自明なケースだけを探します。
2147 FindBugs は、XSS の最も露骨で自明なケースだけを探します。
21392148 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
21402149 XSS を心配するなら、商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
21412150 </p>
21452154
21462155 <BugPattern type="XSS_REQUEST_PARAMETER_TO_SEND_ERROR">
21472156 <ShortDescription>反射型クロスサイトスクリプティング脆弱性がエラーページにあるサーブレット</ShortDescription>
2148 <LongDescription>サーブレットのエラーページに HTTP パラメータをそのまま書き込んでいます。{1}</LongDescription>
2149 <Details>
2150 <![CDATA[
2151 <p>
2152 このコードは、サーブレットのエラーページに <code>HttpServletResponse.sendError</code> を使用して HTTP パラメータをそのまま書き込んでいます。
2157 <LongDescription>サーブレットのエラーページに HTTP パラメータを直接書き込んでいます。{1}</LongDescription>
2158 <Details>
2159 <![CDATA[
2160 <p>
2161 このコードは、サーブレットのエラーページに <code>HttpServletResponse.sendError</code> を使用して HTTP パラメータを直接書き込んでいます。
21532162 信頼できない入力を返すことは反射型 XSS(クロスサイトスクリプティング) 脆弱性を可能にします。<br>
21542163 詳細は、<a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a> を参照してください。
21552164 </p>
21562165 <p>
2157 FindBugs は、XSS のもっとも露骨で自明なケースだけを探します。
2166 FindBugs は、XSS の最も露骨で自明なケースだけを探します。
21582167 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
21592168 XSS を心配するなら、商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
21602169 </p>
21642173
21652174 <BugPattern type="XSS_REQUEST_PARAMETER_TO_JSP_WRITER">
21662175 <ShortDescription>反射型クロスサイトスクリプティング脆弱性がある JSP</ShortDescription>
2167 <LongDescription>JSP の出力に HTTP パラメータをそのまま書き込んでいます。{1.class}</LongDescription>
2168 <Details>
2169 <![CDATA[
2170 <p>
2171 このコードは、JSP の出力に HTTP パラメータをそのまま書き込んでいます。これは XSS(クロスサイトスクリプティング) 脆弱性を可能にします。<br>
2176 <LongDescription>JSP の出力に HTTP パラメータを直接書き込んでいます。{1.class}</LongDescription>
2177 <Details>
2178 <![CDATA[
2179 <p>
2180 このコードは、JSP の出力に HTTP パラメータを直接書き込んでいます。これは XSS(クロスサイトスクリプティング) 脆弱性を可能にします。<br>
21722181 詳細は、<a href="http://en.wikipedia.org/wiki/Cross-site_scripting">http://en.wikipedia.org/wiki/Cross-site_scripting</a> を参照してください。
21732182 </p>
21742183 <p>
2175 FindBugs は、XSS のもっとも露骨で自明なケースだけを探します。
2184 FindBugs は、XSS の最も露骨で自明なケースだけを探します。
21762185 FindBugs が何かを発見したならほぼ間違いなく FindBugs が報告しないより多くの脆弱性があるでしょう。
21772186 XSS に関して心配しているなら商用の静的解析ツールかペネトレーションテストツールの使用を真剣に検討するべきです。
21782187 </p>
21932202 この状況は、2つのスレッドが Swing コンポーネントにアクセスする可能性があり、デッドロックや、その他のスレッドに関する問題になる可能性がある重大な欠陥です。
21942203 <code>pack</code> メソッドの呼び出しはコンポーネントを実体化させます。実体化しているときに、イベントディスパッチスレッドがリスナへの通知を開始する可能性があります。
21952204 </p>
2196
21972205 ]]>
21982206 </Details>
21992207 </BugPattern>
22162224 <Details>
22172225 <![CDATA[
22182226 <p>
2219 このメソッドは、無条件でそれ自身を呼び出します。これは、スタックオーバーフローになる無限再帰ループを示しています。
2220 </p>
2221 ]]>
2222 </Details>
2223 </BugPattern>
2224
2227 このメソッドは、無条件で自分自身を呼び出します。これは、スタックオーバーフローになる無限再帰ループを示しています。
2228 </p>
2229 ]]>
2230 </Details>
2231 </BugPattern>
22252232
22262233 <BugPattern type="IL_CONTAINER_ADDED_TO_ITSELF">
22272234 <ShortDescription>コレクションは自分自身を追加している</ShortDescription>
22292236 <Details>
22302237 <![CDATA[
22312238 <p>
2232 コレクションは自分自身を追加しています。その結果、hashCode を計算すると <code>StackOverflowException</code> をスローします。
2239 コレクションは、自分自身を追加しています。その結果、hashCode を計算すると <code>StackOverflowException</code> をスローします。
22332240 </p>
22342241 ]]>
22352242 </Details>
22412248 <Details>
22422249 <![CDATA[
22432250 <p>
2244 これは配列に volatile 参照を宣言しています。それはあなたが望むものではないかもしれません。
2251 配列に volatile 参照を宣言していますが、あなたが望むものではないかもしれません。
22452252 配列への volatile 参照は、配列への参照の読み出し、書き込みは volatile として扱われますが、配列要素は volatile として扱われません。
2246 配列要素を volatile として扱いたいのであれば、J2SE 5.0で提供された <code>java.util.concurrent</code> パッケージのアトミック配列クラスを使用する必要があります。
2253 配列要素を volatile として扱いたいのであれば、J2SE 5.0で提供された java.util.concurrent パッケージのアトミック配列クラスを使用する必要があります。
22472254 </p>
22482255 ]]>
22492256 </Details>
22562263 <![CDATA[
22572264 <p>
22582265 このコードは、volatile フィールドをインクリメントしています。
2259 volatile フィールドのインクリメントは、アトミックではありません。
2266 volatile フィールドのインクリメントはアトミックではありません。
22602267 複数のスレッドが同時にフィールドをインクリメントすると、インクリメントが失われる可能性があります。
22612268 </p>
22622269 ]]>
22832290 <p>
22842291 Boolean.TRUE、Boolean.FALSE、null を返すメソッドはいつ事故が起きてもおかしくないです。
22852292 まるで論理型の値を返すかのように、このメソッドは呼び出される可能性があります。
2286 そして、コンパイラは Boolean 値のオートアンボクシングを挿入します。
2293 コンパイラは Boolean 値のオートアンボクシングを挿入します。
22872294 null 値が返されるなら NullPointerException が発生することになります。
22882295 </p>
22892296 ]]>
22902297 </Details>
22912298 </BugPattern>
22922299
2293   <BugPattern type="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">
2300 <BugPattern type="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">
22942301 <ShortDescription>非 null フィールドは初期化されていない</ShortDescription>
22952302 <LongDescription>非 null フィールド {2.name} は {1} によって初期化されていません。</LongDescription>
22962303 <Details>
22972304 <![CDATA[
22982305 <p>
2299 フィールドは、非 null としてマークされているが、コンストラクタで書き込まれていません。
2306 フィールドは、非 null としてマークされていますが、コンストラクタで書き込まれていません。
23002307 フィールドは、コンストラクタの間、ほかの場所で初期化されるか、または使用する前に常に初期化されるかもしれません。
23012308 </p>
23022309 ]]>
23112318 <p>
23122319 フィールドは同期化しているので、おそらく null ではないと思われます。
23132320 null のフィールドを同期化すると NullPointerException がスローされるので、null チェックは無意味になります。
2314 別のフィールドで同期化した方がよいです。
2321 別のフィールドで同期化したほうがよいです。
23152322 </p>
23162323 ]]>
23172324 </Details>
23242331 <![CDATA[
23252332 <p>
23262333 このコードには条件テストが2回、つまり、1つめの条件テストが正しいとき、2つめの条件テストが実行されます (たとえば、<code>x == 0 || x == 0</code>)。
2327 たぶん、2つめの条件テストは何か他のことを意図しています (たとえば、<code>x == 0 || y == 0</code>)。
2334 多分、2つめの条件テストは何か他のことを意図しています (たとえば、<code>x == 0 || y == 0</code>)。
23282335 </p>
23292336 ]]>
23302337 </Details>
23362343 <Details>
23372344 <![CDATA[
23382345 <p>
2339 このバグパターンは、新しい、不完全に実装されたバグディテクタによって生成されるだけです。
2340 </p>
2341 ]]>
2342 </Details>
2343 </BugPattern>
2344
2346 このバグパターンは、新しい不完全に実装されたバグディテクタによって生成されるだけです。
2347 </p>
2348 ]]>
2349 </Details>
2350 </BugPattern>
23452351
23462352 <BugPattern type="TESTING1">
23472353 <ShortDescription>テスト1</ShortDescription>
23492355 <Details>
23502356 <![CDATA[
23512357 <p>
2352 このバグパターンは、新しい、不完全に実装されたバグディテクタによって生成されるだけです。
2358 このバグパターンは、新しい不完全に実装されたバグディテクタによって生成されるだけです。
23532359 </p>
23542360 ]]>
23552361 </Details>
23622368 <Details>
23632369 <![CDATA[
23642370 <p>
2365 このバグパターンは、新しい、不完全に実装されたバグディテクタによって生成されるだけです。
2371 このバグパターンは、新しい不完全に実装されたバグディテクタによって生成されるだけです。
23662372 </p>
23672373 ]]>
23682374 </Details>
23742380 <Details>
23752381 <![CDATA[
23762382 <p>
2377 このバグパターンは、新しい、不完全に実装されたバグディテクタによって生成されるだけです。
2383 このバグパターンは、新しい不完全に実装されたバグディテクタによって生成されるだけです。
23782384 </p>
23792385 ]]>
23802386 </Details>
23812387 </BugPattern>
23822388
23832389 <BugPattern type="UNKNOWN">
2384 <ShortDescription>不明なバグパターン</ShortDescription>
2385 <LongDescription>不明なバグパターンです。{1}</LongDescription>
2390 <ShortDescription>未知のバグパターン</ShortDescription>
2391 <LongDescription>未知のバグパターンです。{1}</LongDescription>
23862392 <Details>
23872393 <![CDATA[
23882394 <p>
24282434 <Details>
24292435 <![CDATA[
24302436 <p>
2431 <code>IllegalMonitorStateException</code> は、通常設計上の欠陥 (ロックを保持していないオブジェクトで <code>wait</code> メソッドまたは <code>notify</code> メソッドを呼び出す) の場合にだけスローされます。
2437 <code>IllegalMonitorStateException</code> は、一般に設計上の欠陥 (ロックを保持していないオブジェクトで <code>wait</code> メソッドまたは <code>notify</code> メソッドを呼び出す) の場合にだけスローされます。
24322438 </p>
24332439 ]]>
24342440 </Details>
24512457
24522458 <BugPattern type="CN_IDIOM">
24532459 <ShortDescription>Cloneable を実装したクラスが clone メソッドを定義していないか、使用していない</ShortDescription>
2454 <LongDescription>クラス {0} は、Cloneable を実装しているのに clone メソッドを定義していないか使用していません。</LongDescription>
2455 <Details>
2456 <![CDATA[
2457 <p>
2458 このクラスは <code>Cloneable</code> を実装しているのに <code>clone</code> メソッドを定義していないか使用していません。
2460 <LongDescription>クラス {0} は、Cloneable を実装していますが、clone メソッドを定義していないか使用していません。</LongDescription>
2461 <Details>
2462 <![CDATA[
2463 <p>
2464 このクラスは、<code>Cloneable</code> を実装していますが、<code>clone</code> メソッドを定義していないか使用していません。
24592465 </p>
24602466 ]]>
24612467 </Details>
24682474 <![CDATA[
24692475 <p>
24702476 このクラスは、<code>Cloneable</code> を実装していないのに <code>clone</code> メソッドを定義しています。
2471 これが OK (たとえば、サブクラスのクローンの実装を自分自身で制御したい場合です) という状況もありますが、意図したことなのか確認してください。
2477 これが OK (たとえば、サブクラスのクローンの実装を自分自身で制御したい場合です) という状況もありますが意図したことなのか確認してください。
24722478 </p>
24732479 ]]>
24742480 </Details>
24982504 <![CDATA[
24992505 <p>
25002506 識別子は、Java の後のバージョンのキーワードとして予約されている単語です。
2501 コードは、Java の後のバージョンでコンパイルするために変更する必要があります。
2507 コードを Java の後のバージョンでコンパイルするためには変更する必要があります。
25022508 </p>
25032509 ]]>
25042510 </Details>
25112517 <![CDATA[
25122518 <p>
25132519 この識別子は、Java の後のバージョンのキーワードとして使われます。
2514 このコードと API を参照するどんなコードも、Java の後のバージョンでコンパイルするために変更する必要があります。
2520 このコードと API を参照するどんなコードも、Java の後のバージョンでコンパイルするためには変更する必要があります。
25152521 </p>
25162522 ]]>
25172523 </Details>
25242530 <![CDATA[
25252531 <p>
25262532 このメソッドは、例外を捨てているかもしれません。
2527 通常、キャッチした例外は何らかの方法で処理、または報告するべきです、あるいはメソッドからスローするべきです。
2533 一般にキャッチした例外は何らかの方法で処理、または報告するべきです、あるいはメソッドからスローするべきです。
25282534 </p>
25292535 ]]>
25302536 </Details>
25372543 <![CDATA[
25382544 <p>
25392545 このメソッドは例外を無視しているかもしれません。
2540 通常、例外は何らかの方法で処理、または報告するべきです、あるいはメソッドからスローするべきです。
2546 一般に例外は何らかの方法で処理、または報告するべきです、あるいはメソッドからスローするべきです。
25412547 </p>
25422548 ]]>
25432549 </Details>
25502556 <![CDATA[
25512557 <p>
25522558 このコードは、セキュリティ許可チェックが必要なメソッドを呼び出しています。
2553 このコードにセキュリティ許可が与えられるとしても、セキュリティ許可がないコードによって呼び出されるなら doPrivileged ブロック内で行う必要があります。
2559 このコードにセキュリティ許可が与えられるとしても、セキュリティ許可を持たないコードによって呼び出されるなら doPrivileged ブロックの中で呼び出す必要があります。
25542560 </p>
25552561 ]]>
25562562 </Details>
25742580 <Details>
25752581 <![CDATA[
25762582 <p>
2577 このコードはクラスローダを作成していますが、セキュリティマネージャがインストールされているなら権限が必要です。
2578 このコードがセキュリティ権限がないコードによって呼び出されるなら、クラスローダの作成は doPrivileged ブロック内で行う必要があります。
2583 このコードはクラスローダを作成していますが、セキュリティ管理がインストールされるなら許可が必要です。
2584 このコードがセキュリティ許可がないコードによって呼び出されるなら、クラスローダの作成は doPrivileged ブロックの中で行う必要があります。
25792585 </p>
25802586 ]]>
25812587 </Details>
25872593 <Details>
25882594 <![CDATA[
25892595 <p>
2590 クラスにはnet.jcip.annotations.Immutable でアノテートされています。
2591 Immutable アノテーションのルールは、すべてのフィールドを final にすることを義務づけます。
2596 クラスは、net.jcip.annotations.Immutable または javax.annotation.concurrent.Immutable でアノテートされています。
2597 アノテーションのルールは、すべてのフィールドが final であることを義務づけます。
25922598 </p>
25932599 ]]>
25942600 </Details>
26822688 <Details>
26832689 <![CDATA[
26842690 <p>
2685 <code>java.lang.String(String)</code> コンストラクタの使用はメモリを浪費します。
2691 <code>new String(String)</code> コンストラクタの使用はメモリを浪費します。
26862692 そのようにして構築されたオブジェクトと パラメータとして渡された <code>String</code> は機能的に区別がつかないからです。
26872693 引数の <code>String</code> をそのまま使用してください。
26882694 </p>
27232729 <Details>
27242730 <![CDATA[
27252731 <p>
2726 このコードは、明示的にガベージコレクションを呼び出しています。ベンチマークの特定の用途を除いて非常に疑わしいです。
2732 明示的にガベージコレクションを呼び出しています。ベンチマークの特定の用途を除いて非常に疑わしいです。
27272733 </p>
27282734 <p>
27292735 過去に、<code>close</code> メソッドや <code>finalize</code> メソッドでガベージコレクタを明示的に呼び出していた状況は、巨大なパフォーマンスブラックホールの原因となりました。
27402746 <![CDATA[
27412747 <p>
27422748 <code>java.lang.Boolean</code> の新しいインスタンスを作成するとメモリを浪費します。
2743 <code>Boolean</code> オブジェクトは不変で、2つの有用な値 (<code>Boolean.TRUE</code> と <code>Boolean.FALSE</code>) があります。
2749 <code>Boolean</code> オブジェクトは不変で、2つの有効な値 (<code>Boolean.TRUE</code> と <code>Boolean.FALSE</code>) があります。
27442750 その代わりに <code>Boolean</code> オブジェクトを作成するために、<code>Boolean.valueOf</code> メソッド (または J2SE 5.0 のオートボクシング) を使用してください。
27452751 </p>
27462752 ]]>
27582764 キャッシュに格納された値を使うことはインスタンスの作成を回避し、コードはより高速になります。
27592765 </p>
27602766 <p>
2761 -128から127までの値は、対応するキャッシュされたインスタンスを持つことが保証されています。
2767 -128から127までの値は対応するキャッシュされたインスタンスを持つことが保証されています。
27622768 そして、<code>valueOf</code> メソッドの使用は、コンストラクタを使用するより約3.5倍高速です。
27632769 定数範囲外の値は、両方のスタイルの性能は同じです。
27642770 </p>
27942800 文字列がプラットホームのデフォルトエンコーディングを使用して大文字、小文字に変換されています。
27952801 国際文字で使われると不適切な変換になるかもしれません。
27962802 </p>
2797 </p>
2798 <ul>
2799 <li>String.toUpperCase(Locale l)</li>
2800 <li>String.toLowerCase(Locale l)</li>
2801 </ul>
2802 </p>
2803 <ul>
2804 <li>String.toUpperCase(Locale l)</li>
2805 <li>String.toLowerCase(Locale l)</li>
2806 </ul>
28032807 ]]>
28042808 </Details>
28052809 </BugPattern>
28102814 <Details>
28112815 <![CDATA[
28122816 <p>
2813 ラップされたプリミティブ値は、3項演算子 (<code> b ? e1 : e2</code>) の評価の一部として、別のプリミティブ型にアンボクシングされて、変換されます。
2817 ラップされたプリミティブ値は、3項演算子 (<code> b ? e1 : e2</code>) の評価の一部として、別のプリミティブ型にアンボクシングされて変換されます。
28142818 Java 言語仕様では、<code>e1</code> と <code>e2</code> がラップされた数値なら値はアンボクシングされ、共通の型へと変換/型変換されます
28152819 (たとえば、<code>e1</code> が <code>Integer</code> で、<code>e2</code> が <code>Float</code> なら <code>e1</code> はアンボクシング (<code>int</code> に変換) され、<code>float</code> に変換され、ボクシング (<code>Float</code> に変換) されます)。
28162820 JLS セクション15.25を参照してください。
28262830 <![CDATA[
28272831 <p>
28282832 プリミティブ値がボクシングされて、すぐにアンボクシングされます。
2829 おそらく、アンボクシングされた値が必要な場所で、手動でボクシングをしているためです。
2833 おそらくアンボクシングされた値が必要な場所で、手動でボクシングをしているためです。
28302834 その結果、コンパイラにボクシングの機能を取り消すことを強制しています。
28312835 </p>
28322836 ]]>
28512855 <Details>
28522856 <![CDATA[
28532857 <p>
2854 プリミティブ値がコンストラクタでボクシングされて、すぐに異なるプリミティブ型に変換されます (たとえば、<code>new Double(d).intValue()</code>)。
2855 直接プリミティブ型の型変換を実行してください (たとえば、<code>(int) d</code>)。
2858 プリミティブ値がコンストラクタでボクシングされて、すぐに異なるプリミティブ型に変換されます (たとえば <code>new Double(d).intValue()</code>)。
2859 直接プリミティブ型の型変換を実行してください (たとえば <code>(int) d</code>)。
28562860 </p>
28572861 ]]>
28582862 </Details>
28642868 <![CDATA[
28652869 <p>
28662870 <code>toString</code> メソッドを呼び出すために、プリミティブ型のラッパクラスのインスタンスを作成しています。
2867 それよりもプリミティブ値を引数にとる static な <code>toString</code> メソッドを使用した方が効率的です。
2868 </p>
2869 <table>
2870 <tr><th>置換前</th><th>置換後</th></tr>
2871 <tr><td>new Integer(1).toString()</td><td>Integer.toString(1)</td></tr>
2872 <tr><td>new Long(1).toString()</td><td>Long.toString(1)</td></tr>
2873 <tr><td>new Float(1.0).toString()</td><td>Float.toString(1.0)</td></tr>
2874 <tr><td>new Double(1.0).toString()</td><td>Double.toString(1.0)</td></tr>
2875 <tr><td>new Byte(1).toString()</td><td>Byte.toString(1)</td></tr>
2876 <tr><td>new Short(1).toString()</td><td>Short.toString(1)</td></tr>
2877 <tr><td>new Boolean(true).toString()</td><td>Boolean.toString(true)</td></tr>
2878 </table>
2871 それよりもプリミティブ値を引数にとる static な <code>toString</code> メソッドを使用したほうが効率的です。
2872 </p>
2873 <table>
2874 <tr><th>置換前</th><th>置換後</th></tr>
2875 <tr><td>new Integer(1).toString()</td><td>Integer.toString(1)</td></tr>
2876 <tr><td>new Long(1).toString()</td><td>Long.toString(1)</td></tr>
2877 <tr><td>new Float(1.0).toString()</td><td>Float.toString(1.0)</td></tr>
2878 <tr><td>new Double(1.0).toString()</td><td>Double.toString(1.0)</td></tr>
2879 <tr><td>new Byte(1).toString()</td><td>Byte.toString(1)</td></tr>
2880 <tr><td>new Short(1).toString()</td><td>Short.toString(1)</td></tr>
2881 <tr><td>new Boolean(true).toString()</td><td>Boolean.toString(true)</td></tr>
2882 </table>
2883 ]]>
2884 </Details>
2885 </BugPattern>
2886
2887 <BugPattern type="DM_BOXED_PRIMITIVE_FOR_PARSING">
2888 <ShortDescription>ボクシング/アンボクシングはプリミティブを解析する</ShortDescription>
2889 <LongDescription>ボクシング/アンボクシングは、プリミティブ {1} を解析しています。</LongDescription>
2890 <Details>
2891 <![CDATA[
2892 <p>
2893 ボックス化されたプリミティブは、String から生成されていて、アンボックス化されたプリミティブ値を抽出します。
2894 static parseXXX メソッドを呼び出す方が効率的です。
2895 </p>
28792896 ]]>
28802897 </Details>
28812898 </BugPattern>
28872904 <![CDATA[
28882905 <p>
28892906 メソッドは、クラスオブジェクトを得るために、インスタンスを生成して <code>getClass</code> メソッドを呼び出しています。
2890 クラスリテラル (<code>Foo.class</code>) を使う方が簡単です。
2907 クラスリテラル (<code>Foo.class</code>) を使うほうが簡単です。
28912908 </p>
28922909 ]]>
28932910 </Details>
29562973 <![CDATA[
29572974 <p>
29582975 このコードは、定数でない文字列から SQL の <code>PreparedStatement</code> を作成しています。
2959 ユーザからのチェックされていない、汚染されたデータがこの文字列を作る際に使われるなら、PreparedStatement で予想外で望ましくない何かをするために SQL インジェクションが使われる可能性があります。
2976 ユーザからのチェックされていない汚染されたデータがこの文字列を作る際に使われるなら、PreparedStatement で予想外で望ましくない何かをするために SQL インジェクションが使われる可能性があります。
29602977 </p>
29612978 ]]>
29622979 </Details>
29682985 <Details>
29692986 <![CDATA[
29702987 <p>
2971 このメソッドは、スレッドを作成しているのに <code>Thread</code> クラスから派生した <code>run</code> メソッドも指定していないし、<code>Runnable</code> オブジェクトも渡していません。
2988 このメソッドは、<code>Thread</code> クラスから派生した <code>run</code> メソッドを指定していないか、<code>Runnable</code> オブジェクトを渡すことなく、スレッドを作成しています。
29722989 このスレッドは、時間の無駄です。
29732990 </p>
29742991 ]]>
29812998 <Details>
29822999 <![CDATA[
29833000 <p>
2984 このメソッドにはダブルチェックロッキングのインスタンスがあるかもしれません。
2985 このイディオムは、Java のメモリモデルでは正しくありません。<br>
3001 このメソッドにはダブルチェックロッキングのインスタンスがあるかもしれません。このイディオムは、Java のメモリモデルでは正しくありません。<br>
29863002 詳細は、<a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html" >http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a> を参照してください。
29873003 </p>
29883004 ]]>
29973013 <p>
29983014 このファイナライザは、フィールドを null にしています。
29993015 これは通常誤りでガベージコレクタを助けません。オブジェクトはいずれにしろガベージされます。
3016 </p>
30003017 ]]>
30013018 </Details>
30023019 </BugPattern>
30063023 <Details>
30073024 <![CDATA[
30083025 <p>
3009 このファイナライザは、フィールドを null にすること以外は何もしません。
3026 このファイナライザは、フィールドを null にすること以外に何もしません。
30103027 これはまったく無意味であり、オブジェクトがガベージされ、ファイナライズされ、再びガベージされることを要求しています。
30113028 <code>finalize</code> メソッドを削除するべきです。
30123029 </p>
30323049 <Details>
30333050 <![CDATA[
30343051 <p>
3035 空の <code>finalize</code> メソッドは役に立たないので、削除するべきです。
3052 空の <code>finalize</code> メソッドは役に立たないので削除するべきです。
30363053 </p>
30373054 ]]>
30383055 </Details>
30463063 <p>
30473064 この空の <code>finalize</code> メソッドは、明示的にスーパークラスによって定義されたどんなファイナライザの効果も無効にします。
30483065 スーパークラスのために定義されたどんなファイナライザアクションも実行されません。
3049 これが意図したことではない場合、このメソッドを削除してください。
3050 </p>
3066 これが意図したことではない場合、メソッドを削除してください。
3067 </p>
30513068 ]]>
30523069 </Details>
30533070 </BugPattern>
30723089 <![CDATA[
30733090 <p>
30743091 この <code>finalize</code> メソッドは、スーパークラスの <code>finalize</code> メソッドを呼び出していません。
3075 このため、スーパークラスのために定義されたどんなファイナライザアクションも実行されません。
3092 したがって、スーパークラスのために定義されたどんなファイナライザアクションも実行されません。
30763093 <code>super.finalize()</code> の呼び出しを追加してください。
30773094 </p>
30783095 ]]>
30903107 </p>
30913108 <p>
30923109 参照によってつながった複数のオブジェクトがファイナライズ可能になると、Java 仮想マシンはすべてのオブジェクトの <code>finalize</code> メソッドを呼び出します。
3093 おそらく、異なるスレッドで同時にです。
3110 おそらく異なるスレッドで同時にです。
30943111 したがって、クラス <i>X</i> の <code>finalize</code> メソッドの中から <i>X</i> によって参照されているオブジェクトの <code>finalize</code> メソッドを呼び出すのは、とりわけ間違った考えです。
30953112 なぜなら、オブジェクトがすでに別のスレッドによってファイナライズされているかもしれないからです。
30963113 </p>
31043121 <Details>
31053122 <![CDATA[
31063123 <p>
3107 この <code>equals</code> メソッドは、引数が互換性のない型 (すなわち、スーパタイプでもなく、<code>equals</code> メソッドを定義しているクラスのスーパータイプでもサブタイプでもないクラス) なのか確かめています。
3124 この <code>equals</code> メソッドは、引数が互換性のない型 (すなわちスーパタイプでもなく、<code>equals</code> メソッドを定義しているクラスのスーパータイプでもサブタイプでもないクラス) なのか確かめています。
31083125 たとえば、<code>Foo</code> クラスの <code>equals</code> メソッドはそのように見えるかもしれません。
31093126 </p>
31103127 <blockquote><pre>
31323149 <p>
31333150 このクラスは列挙を定義していて、列挙の等価性はオブジェクト同一性を使用して定義されています。
31343151 列挙値のために共変な <code>equals</code> メソッドを定義することは、非常に間違ったプラクティスです。
3135 2つの異なる列挙値が通常の <code>equals</code> メソッドでは「等価ではない」と判定され、共変な <code>equals</code> メソッドでは「等価」と判定されるからです。
3152 2つの異なる列挙値が一般にの <code>equals</code> メソッドでは「等価ではない」と判定され、共変な <code>equals</code> メソッドでは「等価」と判定されるからです。
31363153 共変な <code>equals</code> メソッドを定義しないでください。
31373154 </p>
31383155 ]]>
31603177 <p>
31613178 このクラスは、<code>equals</code> メソッドを定義していますが、<code>java.lang.Object</code> クラスの <code>equals(Object)</code> メソッドをオーバーライドしていません。
31623179 クラスは、<code>boolean equals(Object)</code> メソッドを定義するべきです。
3163 </p>
3180 </p>
31643181 ]]>
31653182 </Details>
31663183 </BugPattern>
31833200 <Details>
31843201 <![CDATA[
31853202 <p>
3186 このクラスは、<code>equals</code> メソッドを定義しているクラスを拡張してフィールドを追加しているのに <code>equals</code> メソッドを定義していません。
3203 このクラスは、<code>equals</code> メソッドを定義しているクラスを拡張してフィールドを追加していますが、<code>equals</code> メソッドを定義していません。
31873204 したがって、このクラスのインスタンスの等価性は、サブクラスと追加されたフィールドの同一性を無視します。
31883205 これが意図したことで、しかも、<code>equals</code> メソッドをオーバーライドする必要がないことを確実にしてください。
31893206 たとえ <code>equals</code> メソッドをオーバーライドする必要がないとしても、サブクラスのための <code>equals</code> メソッドが <code>super.equals(o)</code> を呼び出して結果を返すという事実を実証するために、いずれにしろ、<code>equals</code> メソッドをオーバーライドすることを検討してください。
31943211
31953212 <BugPattern type="EQ_SELF_NO_OBJECT">
31963213 <ShortDescription>共変な equals メソッドの定義</ShortDescription>
3197 <LongDescription>{0} は、equals({0.givenClass}) メソッドを定義しているのに equals(Object) を定義していません。</LongDescription>
3214 <LongDescription>{0} は、equals({0.givenClass}) メソッドを定義していますが、equals(Object) を定義していません。</LongDescription>
31983215 <Details>
31993216 <![CDATA[
32003217 <p>
32273244 <Details>
32283245 <![CDATA[
32293246 <p>
3230 このクラスは、サブクラスによって継承されるなら、壊れる <code>equlas</code> メソッドがあります。
3231 <code>equals</code> メソッドは、クラスリテラルを引数のクラスと比較しています (たとえば、<code>Foo</code> クラスで、<code>Foo.class == o.getClass()</code> のような判定を行っています)。
3232 それは、<code>this.getClass() == o.getClass()</code> の方がより良いです。
3247 このクラスは、サブクラスによる継承によって壊れる <code>equlas</code> メソッドがあります。
3248 <code>equals</code> メソッドは、クラスリテラルを引数のクラスと比較しています (たとえば、<code>Foo</code> クラスで <code>Foo.class == o.getClass()</code> のような判定を行っています)。
3249 <code>this.getClass() == o.getClass()</code> の方がより良いです。
32333250 </p>
32343251 ]]>
32353252 </Details>
32553272 <![CDATA[
32563273 <p>
32573274 このメソッドは、クラス名を比較することによって、2つのオブジェクトが同じクラスなのか確かめています。
3258 異なるクラスローダによってロードされたクラスなら同じ名前で異なるクラスがある可能性があります。
3275 異なるクラスローダによってロードされたクラスなら、同じ名前で異なるクラスがある可能性があります。
32593276 クラスオブジェクトが同じなのか確かめてください。
32603277 </p>
32613278 ]]>
32823299 <![CDATA[
32833300 <p>
32843301 このクラスでは、常に false を返す <code>equlas</code> メソッドを定義しています。
3285 これは、オブジェクトがそれ自身と等価ではないことを意味していて、このクラスの有用な Map や Set を作成できません。
3302 これは、オブジェクトがそれ自身と等価ではないことを意味していて、このクラスの有効な Map や Set を作成できません。
32863303 より根本的に、<code>equals</code> メソッドの要件の一つである反射性を満たしていないことになります。
32873304 </p>
32883305 <p>
33063323 <![CDATA[
33073324 <p>
33083325 巨大な文字列定数が複数のクラスファイルにわたって複製されています。
3309 final フィールドが文字列定数で初期化され、Java言語によって他のクラスからの final フィールドへのすべての参照がクラスファイルにインライン化されるからです。
3326 final フィールドが文字列定数で初期化され、Java 言語によって他のクラスからの final フィールドへのすべての参照がクラスファイルにインライン化されるからです。
33103327 </p>
33113328 <p>
33123329 JDK はこのバグを解決してサイズを1MB減らすことができました。<br>
33483365 <Details>
33493366 <![CDATA[
33503367 <p>
3351 このコードは、compareTo または compare メソッドの戻り値を無効にします。
3352 これは疑わしいか間違ったプログラミングプラクティスです、戻り値が Integer.MIN_VALUE なので、戻り値を無効にすることは結果の符号を無効にしません。
3368 このコードは、<code>compareTo</code> または <code>compare</code> メソッドの戻り値を無効にしています。
3369 これは疑わしいか間違ったプログラミングプラクティスです。戻り値が Integer.MIN_VALUE なので、戻り値を無効にすることは結果の符号を無効にしません。
33533370 結果を無効にするのではなくオペランドの順序を逆にすることによって、同じ意図した結果を得ることができます。
33543371 </p>
33553372 ]]>
33623379 <Details>
33633380 <![CDATA[
33643381 <p>
3365 場合によっては、この compareTo または compare メソッドは Integer.MIN_VALUE を返します。それは、非常に間違ったプラクティスです。
3366 compareTo メソッドの戻り値は結果の符号だけが重要なのです。
3367 しかし、compareTo メソッドの戻り値を無効にすることがあります。これが結果の符号を無効にすると予想します。
3368 戻り値が Integer.MIN_VALUE である場合を除きそうなります。Integer.MIN_VALUE よりも-1を返しなさい。
3382 いくつかの状況下では、この <code>compareTo</code> または <code>compare</code> メソッドは Integer.MIN_VALUE を返します。それは、非常に間違ったプラクティスです。
3383 <code>compareTo</code> メソッドの戻り値で重要なことは結果の符号だけです。
3384 しかし、結果の符号を無効にすることを期待して、<code>compareTo</code> メソッドの戻り値を無効にすることがあります。
3385 戻り値が Integer.MIN_VALUE である場合を除き、Integer.MIN_VALUE よりも-1を返します。
33693386 </p>
33703387 ]]>
33713388 </Details>
33923409 <p>
33933410 メソッド、フィールド、クラスは、ハッシュ可能なクラスが必要な文脈で、ハッシュ化できないクラスが使用される総称的なシグネチャを宣言しています。
33943411 クラスは、<code>equals</code> メソッドを宣言していますが、<code>hashCode</code> メソッドは <code>java.lang.Object</code> から継承しています。
3395 これは「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に従っていないので、ハッシュ化できません。
3412 これは「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に従っていないのでハッシュ化できません。
33963413 </p>
33973414 ]]>
33983415 </Details>
34033420 <Details>
34043421 <![CDATA[
34053422 <p>
3406 このクラスは、<code>equals(Object)</code> メソッドを定義しているのに <code>hashCode</code> メソッドを定義していません。
3423 このクラスは、<code>equals(Object)</code> メソッドを定義していますが、<code>hashCode</code> メソッドを定義していません。
34073424 これは「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に従っていません。
34083425 このクラスのインスタンスはハッシュデータ構造で使われています。最重要問題を修正する必要があります。
34093426 </p>
34193436 <p>
34203437 このクラスは、<code>hashCode</code> メソッドを定義していますが、 <code>equals</code> メソッドは <code>java.lang.Object</code> から継承しています (オブジェクトの参照比較で等価性を判定します)。
34213438 これは「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に従っているかもしれませんが、
3422 おそらく、<code>hashCode</code> メソッドをオーバーライドすることによって意図したことではないと思われます
3439 おそらく、<code>hashCode</code> メソッドをオーバーライドすることによって意図されたことではありません。
34233440 (<code>hashCode</code> メソッドをオーバーライドすることは、オブジェクトの同一性が単純な参照等価性よりも複雑な規約に基づくことを意味します)。
34243441 </p>
34253442 <p>
3426 このクラスのインスタンスが HashMap/HashTable に決して代入されるだろうと思わないなら、
3427 推奨される <code>hashCode</code> メソッドの実装は以下のようになります。
3443 このクラスのインスタンスが HashMap/HashTable に決して代入されるだろうと思わないなら推奨される <code>hashCode</code> メソッドの実装は以下のようになります。
34283444 </p>
34293445 <blockquote><pre>
34303446 public int hashCode() {
34433459 <![CDATA[
34443460 <p>
34453461 このクラスは、<code>compareTo(...)</code> メソッドを定義していますが、<code>equals</code> メソッドは <code>java.lang.Object</code> から継承しています。
3446 通常、<code>equals</code> メソッドが true を返す場合に限り、<code>compareTo</code> メソッドは0を返すべきです。
3462 一般に、<code>equals</code> メソッドが true を返す場合に限り、<code>compareTo</code> メソッドは0を返すべきです。
34473463 これが違反されるなら奇妙で予測できない失敗が PriorityQueue などのクラスで発生します。
34483464 J2SE 5.0では、<code>PriorityQueue.remove()</code> は <code>compareTo</code> メソッドを使用しますが、Java SE 6では、<code>equals</code> メソッドを使用します。
3465 </p>
34493466 <p>
34503467 Comparable インタフェースの compareTo メソッドの JavaDoc を以下に引用します。
34513468 </p>
34523469 <blockquote><p>
34533470 必須というわけではありませんが、<code>(x.compareTo(y)==0) == (x.equals(y))</code> であることが強く推奨されます。
3454 通常、<code>Comparable</code> インタフェースを実装しているクラスで、この条件に違反するクラスは明確にこの事実を示す必要があります。
3471 一般に、<code>Comparable</code> インタフェースを実装しているクラスで、この条件に違反するクラスは明確にこの事実を示す必要があります。
34553472 「注:このクラスは <code>equals</code> と一貫性のない自然順序付けを持ちます」などと明示することをお勧めします。
34563473 </p></blockquote>
34573474 ]]>
34593476 </BugPattern>
34603477
34613478 <BugPattern type="HE_HASHCODE_NO_EQUALS">
3462 <ShortDescription>hashCode メソッドを定義しているのに equals メソッドは定義していないクラス</ShortDescription>
3463 <LongDescription>{0} は、hashCode メソッドを定義しているのに equals メソッドは定義していません。</LongDescription>
3464 <Details>
3465 <![CDATA[
3466 <p>
3467 このクラスは、<code>hashCode</code> メソッドを定義しているのに <code>equals</code> メソッドは定義していません。
3479 <ShortDescription>hashCode メソッドを定義していますが equals メソッドは定義していないクラス</ShortDescription>
3480 <LongDescription>{0} は、hashCode メソッドを定義していますが、equals メソッドは定義していません。</LongDescription>
3481 <Details>
3482 <![CDATA[
3483 <p>
3484 このクラスは、<code>hashCode</code> メソッドを定義していますが、<code>equals</code> メソッドは定義していません。
34683485 これは「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に違反するかもしれません。
34693486 </p>
34703487 ]]>
34773494 <Details>
34783495 <![CDATA[
34793496 <p>
3480 このクラスは、<code>equals(Object)</code> をオーバーライドしているのに <code>hashCode</code> メソッドは <code>java.lang.Object</code> から継承しています (同一性ハッシュコード (Java 仮想マシンによってオブジェクトに代入された任意の値) を返します)。
3497 このクラスは、<code>equals(Object)</code> をオーバーライドしていますが、<code>hashCode</code> メソッドは <code>java.lang.Object</code> から継承しています (同一性ハッシュコード (Java 仮想マシンによってオブジェクトに代入された任意の値) を返します)。
34813498 したがって、「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に違反するかもしれません。
34823499 </p>
34833500 <p>
3484 このクラスのインスタンスが HashMap/HashTable に決して代入されるだろうと思わないなら、推奨される <code>hashCode</code> メソッドの実装は以下のようになります。
3501 このクラスのインスタンスが HashMap/HashTable に決して代入されるだろうと思わないなら推奨される <code>hashCode</code> メソッドの実装は以下のようになります。
34853502 </p>
34863503 <blockquote><pre>
34873504 public int hashCode() {
35033520 したがって、「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に違反するかもしれません。
35043521 </p>
35053522 <p>
3506 <code>hashCode</code> メソッドを定義したくない、またはオブジェクトが HashMap/Hashtable に決して格納されないだろうと思っているなら <code>UnsupportedOperationException</code> をスローする <code>hashCode()</code> メソッドを定義してください。
3523 <code>hashCode</code> メソッドを定義したくないまたはオブジェクトが HashMap/Hashtable に決して格納されないだろうと思っているなら <code>UnsupportedOperationException</code> をスローする <code>hashCode()</code> メソッドを定義してください。
35073524 </p>
35083525 ]]>
35093526 </Details>
35103527 </BugPattern>
35113528 <BugPattern type="HE_EQUALS_NO_HASHCODE">
3512 <ShortDescription>equals メソッドは定義しているのに hashCode メソッドは定義していないクラス</ShortDescription>
3513 <LongDescription>{0} は、equals メソッドを定義しているのに hashCode メソッドは定義していません。</LongDescription>
3514 <Details>
3515 <![CDATA[
3516 <p>
3517 このクラスは、<code>equals(Object)</code> メソッドをオーバーライドしているのに <code>hashCode</code> メソッドはオーバーライドしていません。
3529 <ShortDescription>equals メソッドは定義していますが hashCode メソッドは定義していないクラス</ShortDescription>
3530 <LongDescription>{0} は、equals メソッドを定義していますが、hashCode メソッドは定義していません。</LongDescription>
3531 <Details>
3532 <![CDATA[
3533 <p>
3534 このクラスは、<code>equals(Object)</code> メソッドをオーバーライドしていますが、<code>hashCode</code> メソッドはオーバーライドしていません。
35183535 したがって、「等価なオブジェクトは等価なハッシュコードを保持する必要がある」という <code>hashCode</code> メソッドの汎用規約に違反するかもしれません。
35193536 </p>
35203537 ]]>
35403557 <![CDATA[
35413558 <p>
35423559 このコードは、参照等価性のために == や != を使用して <code>java.lang.String</code> オブジェクトを比較しています。
3543 両方の文字列がソースファイルの定数か、<code>String.intern()</code> を使用して正準化されていない限り、同じ文字列は2つの異なる String オブジェクトによって表されるかもしれません。
3560 両方の文字列がソースファイルの定数か、<code>String.intern()</code> を使用して正準化されていないかぎり、同じ文字列は2つの異なる String オブジェクトによって表されるかもしれません。
35443561 その代わりに <code>equals(Object)</code> メソッドを使うことを検討してください。
35453562 </p>
35463563 ]]>
35543571 <![CDATA[
35553572 <p>
35563573 このコードは、参照等価性のために == や != を使用して <code>java.lang.String</code> パラメータを比較しています。
3557 文字列定数または正準化された文字列だけをメソッドに渡すことを呼び出し元に要求することは必要以上に脆弱で、測定可能な性能の向上をもたらしません。
3574 文字列定数または正準化された文字列だけをメソッドに渡すことを呼び出し元に要求することは必要以上に脆弱で測定可能な性能の向上をもたらしません。
35583575 その代わりに <code>equals(Object)</code> メソッドを使うことを検討してください。
35593576 </p>
35603577 ]]>
35813598 <Details>
35823599 <![CDATA[
35833600 <p>
3584 このフィールドは、<code>net.jcip.annotations.GuardedBy</code> でアノテートされているが、アノテーションに違反すると思われる方法でアクセスされる可能性があります。
3601 このフィールドは、net.jcip.annotations.GuardedBy または javax.annotation.concurrent.GuardedBy でアノテートされていますが、アノテーションに違反すると思われる方法でアクセスできます。
35853602 </p>
35863603 ]]>
35873604 </Details>
35933610 <Details>
35943611 <![CDATA[
35953612 <p>
3596 Web サーバは、通常サーブレットや JSP クラスのインスタンスを1つだけ作成します (すなわち、シングルトンとして扱います)。
3613 Web サーバは、一般的にサーブレットや JSP クラスのインスタンスを1つだけ作成します (すなわち、シングルトンとして扱います)。
35973614 複数のスレッドが複数同時に発生するリクエストを処理するためにインスタンスのメソッドを呼び出します。
3598 したがって、可変インスタンスフィールドは通常競合状態を作成します。
3615 したがって、可変インスタンスフィールドは一般に競合状態を作成します。
35993616 </p>
36003617 ]]>
36013618 </Details>
36113628 このバグレポートは、バグパターンディテクタが以下のように判断したことを示します。
36123629 </p>
36133630 <ul>
3614 <li>クラスにはロックされたアクセスとアンロックされたアクセスが混在していて、</li>
3631 <li>クラスは、ロックされたアクセスとアンロックされたアクセスが混在していて</li>
3632 <li>クラスは、javax.annotation.concurrent.NotThreadSafe としてアノテートされません</li>
36153633 <li>少なくとも1つのロックされたアクセスがクラス自身のメソッドの1つによって実行され、</li>
36163634 <li>読み出しの2倍の重み付けをした書き込みで、非同期フィールドのアクセス (読み出しと書き込み) 数がすべてのアクセスのわずか1/3</li>
36173635 </ul>
3618 <p>
3619 このバグパターンに合致する典型的なバグは、スレッドセーフを意図したクラスでメソッドを同期化するのを忘れていることです。
3620 </p>
3621 <p>
3622 ディテクタがどこでフィールドが同期化なしでアクセスされると信じていたかを示すコードの場所に「非同期アクセス」というラベルを付けられます。
3636 <p
3637 このバグパターンに合致する典型的なバグは、スレッドセーフを意図したクラスでメソッドを同期化させることを忘れていることです。
3638 </p>
3639 <p>
3640 ディテクタがどこでフィールドが同期化なしでアクセスされると信じていたかを示すコードの場所に「非同期アクセス」というラベルがついているノードを選択できます。
36233641 </p>
36243642 <p>
36253643 不正確ないろいろな原因がこのディテクタにあることに注意してください。
3626 たとえば、ディテクタはロックを保持されるすべての状況を静的に検出できるという訳ではありません。
3644 たとえば、ディテクタはロックを保持されるすべての状況を静的に検出できるというわけではありません。
36273645 また、ディテクタがロックされたアクセスとアンロックされたアクセスの区別が正確なときでも、問題のコードは依然として正しいかもしれません。
36283646 </p>
36293647 ]]>
36373655 <![CDATA[
36383656 <p>
36393657 <code>notify</code> メソッドまたは <code>notifyAll</code> メソッドへの呼び出しは可変オブジェクト状態にどんな (明らかな) 付随的な変更ももたらされませんでした。
3640 通常、別のスレッドが期待しているいくつかの条件が真になったので、モニタで <code>notify</code> メソッドが呼び出されます。
3658 一般に、別のスレッドが期待しているいくつかの条件が真になったので、モニタで <code>notify</code> メソッドが呼び出されます。
36413659 しかしながら、意味がある条件のために、両方のスレッドに見えるヒープオブジェクトを含まなければなりません。
36423660 </p>
36433661 <p>
36603678 ]]>
36613679 </Details>
36623680 </BugPattern>
3681
36633682 <BugPattern type="EI_EXPOSE_REP">
36643683 <ShortDescription>可変オブジェクトへの参照を返すことによって内部表現を暴露するかもしれないメソッド</ShortDescription>
36653684 <LongDescription>{1} は、{2.givenClass} を返すことによって内部表現を暴露するかもしれません。</LongDescription>
36663685 <Details>
36673686 <![CDATA[
36683687 <p>
3669 オブジェクトのフィールドのうちの1つに格納された可変オブジェクトの参照を返すと、オブジェクトの内部表現を暴露します。
3688 オブジェクトのフィールドに格納された可変オブジェクトの参照を返すと、オブジェクトの内部表現を暴露します。
36703689 インスタンスが信頼できないコードによってアクセスされるなら、可変オブジェクトのチェックされていない変更がセキュリティや他の重要なプロパティを危うくするでしょう。
36713690 何か違うことをする必要があります。オブジェクトの新しいコピーを返すことは、多くの状況でより良いアプローチです。
3672 ]]>
3673 </Details>
3674 </BugPattern>
3691 </p>
3692 ]]>
3693 </Details>
3694 </BugPattern>
3695
36753696 <BugPattern type="EI_EXPOSE_REP2">
36763697 <ShortDescription>可変オブジェクトへの参照を取り込むことによって内部表現を暴露するかもしれないメソッド</ShortDescription>
36773698 <LongDescription>{1} は、{2.givenClass} の中に外部の可変オブジェクトを格納することによって内部表現を暴露するかもしれません。</LongDescription>
36813702 このコードは、オブジェクトの内部表現に外部の可変オブジェクトの参照を格納しています。
36823703 インスタンスが信頼できないコードによってアクセスされるなら、可変オブジェクトのチェックされていない変更がセキュリティや他の重要なプロパティを危うくするでしょう。
36833704 何か違うことをする必要があります。オブジェクトの新しいコピーを返すことは、多くの状況でより良いアプローチです。
3684 </p>
3705 </p>
36853706 ]]>
36863707 </Details>
36873708 </BugPattern>
37063727 <![CDATA[
37073728 <p>
37083729 このメソッドは、スレッドで 明示的に <code>run</code> メソッドを呼び出しています。
3709 通常、クラスは新しいスレッドで自己の <code>run</code> メソッドを呼び出してもらうために <code>Runnable</code> インタフェースを実装します。
3730 一般に、クラスは新しいスレッドで自己の <code>run</code> メソッドを呼び出してもらうために <code>Runnable</code> インタフェースを実装します。
37103731 その場合は、<code>Thread.start()</code> を呼び出すのが正しいです。
37113732 </p>
37123733 ]]>
37353756 このコードは、短絡論理 (&amp;&amp; や ||) ではなく非短絡論理 (&amp; や |) を使用していると思われます。
37363757 さらに、左辺値によって右辺を評価したくない (例外のスローや演算が高くつく副作用があるため) と思っているのかもしれません。
37373758 非短絡論理は、左辺の結果がわかっていて推論できるときでも、両側の式が評価されます。
3738 左辺が右辺の評価でエラーを発生させるケースをガードするなら効率が悪く、エラーになる可能性があります。
3759 これは効率が悪く、右辺の評価でエラーが発生するケースを左辺でガードしているなら、結果としてエラーになる可能性があります。
37393760 </p>
37403761 <p>
37413762 詳細については、<a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java Language Specification</a> を参照してください。
37513772 <p>
37523773 このコードは、短絡論理 (&amp;&amp; や ||) ではなく非短絡論理 (&amp; や |) を使用していると思われます。
37533774 非短絡論理は、左辺の結果がわかっていて推論できるときでも、両側の式が評価されます。
3754 左辺が右辺の評価でエラーになるケースをガードするなら効率が悪くエラーになる可能性があります。
3755 </p>
3775 これは効率が悪く、右辺の評価でエラーが発生するケースを左辺でガードしているなら、結果としてエラーになる可能性があります。
3776 </p>
3777 <p>
37563778 詳細については、<a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">the Java Language Specification</a> を参照してください。
37573779 </p>
37583780 ]]>
37973819 <![CDATA[
37983820 <p>
37993821 このメソッドには条件制御フローによってガードされない <code>java.lang.Object.wait()</code> の呼び出しがあります。
3800 このコードは、<code>wait</code> メソッドを呼び出す前に、待機するつもりだった条件がすでに満たされていないことを確かめるべきです。
3822 このコードは、<code>wait</code> メソッドを呼び出す前に待機するつもりだった条件がすでに満たされていないことを確かめるべきです。
38013823 どんな前の通知も無視されます。
38023824 </p>
38033825 ]]>
38043826 </Details>
38053827 </BugPattern>
3828
38063829 <BugPattern type="UR_UNINIT_READ">
38073830 <ShortDescription>コンストラクタで初期化されていないフィールドを読み出している</ShortDescription>
38083831 <LongDescription>初期化されていないフィールド {2.name} を読み出しています。{1}</LongDescription>
38653888 <![CDATA[
38663889 <p>
38673890 このクラスには類似した名前の get メソッドと set メソッドがあり、set メソッドは同期化していて、get メソッドは同期化していません。
3868 get メソッドの呼び出し元がオブジェクトのための一貫した状態を必ずしも見るというわけではないので、実行時に間違った振る舞いになるかもしれません。
3891 get メソッドの呼び出し元がオブジェクトの一貫した状態を必ずしも見るというわけではないので、実行時に間違った振る舞いになるかもしれません。
38693892 get メソッドは同期化するべきです。
38703893 </p>
38713894 ]]>
38783901 <Details>
38793902 <![CDATA[
38803903 <p>
3881 循環がバグインスタンスによって参照される2つのクラスのスタティックイニシャライザで検出されました。
3882 多くの種類の予想外の振る舞いはそのような循環に起因するかもしれません。
3904 バグインスタンスによって参照される2つのクラスのスタティックイニシャライザで循環が検出されました。
3905 多くの種類の予想外の振る舞いは、そのような循環に起因するかもしれません。
38833906 </p>
38843907 ]]>
38853908 </Details>
38913914 <Details>
38923915 <![CDATA[
38933916 <p>
3894 クラスは、初期化中にサブクラスを積極的に使用しています。サブクラスはこの時点では、まだ初期化されていません。<br>
3917 クラスは、初期化中にサブクラスを積極的に使用しています。サブクラスはこの時点ではまだ初期化されていません。<br>
38953918 たとえば、以下のコードにおいて、<code>foo</code> は null です。
38963919 </p>
38973920 <blockquote><pre>
39033926 static CircularClassInitialization foo = InnerClassSingleton.singleton;
39043927 }
39053928 </pre></blockquote>
3906
39073929 ]]>
39083930 </Details>
39093931 </BugPattern>
39663988 }
39673989 </pre></blockquote>
39683990 <p>
3969 通常は2つの <code>Boolean</code> オブジェクトだけが存在しています。
3991 一般には2つの <code>Boolean</code> オブジェクトだけが存在しています。
39703992 このコードは他の無関係なコードと同じオブジェクトで同期化している可能性があるので、無応答やデッドロックの原因になります。
39713993 </p>
39723994 ]]>
40584080 このバグレポートは、バグパターンディテクタが以下のように判断したことをを示します。
40594081 </p>
40604082 <ul>
4061 <li>クラスにはロックされたアクセスとアンロックされたアクセスが混在していて、</li>
4083 <li>クラスにはロックされたアクセスとアンロックされたアクセスが混在していて</li>
40624084 <li>少なくとも1つのロックされたアクセスがクラス自身のメソッドの1つによって実行され、</li>
40634085 <li>読み出しの2倍の重み付けをした書き込みで、非同期フィールドのアクセス (読み出しと書き込み) 数がすべてのアクセスのわずか1/3</li>
40644086 </ul>
40674089 </p>
40684090 <p>
40694091 不正確のいろいろなソースがこのディテクタにあることに注意してください。
4070 たとえば、ディテクタはロックを保持されるすべての状況を静的に検出できるという訳ではありません。
4092 たとえば、ディテクタはロックを保持されるすべての状況を静的に検出できるというわけではありません。
40714093 また、ディテクタがロックされたアクセスとアンロックされたアクセスの区別が正確なときでも、問題のコードは依然として正しいかもしれません。
40724094 </p>
40734095 ]]>
40804102 <Details>
40814103 <![CDATA[
40824104 <p>
4083 このメソッドは、フィールドの同時更新に対して同期化でガードしようとしていますが、フィールドをガードするとフィールドではなく、参照されたオブジェクトのロックを獲得します。
4105 このメソッドは、フィールドの同時更新に対して同期化でガードしようとしています。しかし、フィールドをガードするとフィールドではなく、フィールドが参照するオブジェクトのロックを獲得します。
40844106 これはあなたが必要とする相互排除を提供しないかもしれません。
4085 そして、他のスレッドは (他の目的のための) 参照されたオブジェクトのロックを獲得するかもしれません。<br>
4107 他のスレッドは (他の目的のための) 参照されたオブジェクトのロックを獲得するかもしれません。<br>
40864108 このパターンの例は以下のようになります。
40874109 </p>
40884110 <blockquote><pre>
41064128 <Details>
41074129 <![CDATA[
41084130 <p>
4109 このメソッドは、可変フィールドから参照されているオブジェクトで同期化しています。
4110 異なるスレッドが異なるオブジェクトで同期化しているかもしれないので、これは有用な意味がある可能性が低いです。
4131 このメソッドは、可変フィールドから参照されたオブジェクトで同期化しています。
4132 異なるスレッドが異なるオブジェクトで同期化しているかもしれないので、これは有効な意味を持っている可能性が低いです。
41114133 </p>
41124134 ]]>
41134135 </Details>
41194141 <Details>
41204142 <![CDATA[
41214143 <p>
4122 インタフェースに定義された final static フィールドは、配列や Hashtable などの可変オブジェクトを参照しています。
4144 インタフェースに定義された final static フィールドが、配列や Hashtable などの可変オブジェクトを参照しています。
41234145 この可変オブジェクトは、悪質なコードや偶然別のパッケージによって変更される可能性があります。
41244146 これを解決するために、フィールドはクラスへ移動する必要があり、脆弱性を回避するためにパッケージプロテクテッドにします。
41254147 </p>
41344156 <![CDATA[
41354157 <p>
41364158 この可変 static フィールドは、悪質なコードや偶然別のパッケージによって変更される可能性があります。
4137 フィールドは、脆弱性を回避するために final またはパッケージプロテクテッドにできます。
4159 フィールドは、脆弱性を回避するために final および/またはパッケージプロテクテッドにします。
41384160 </p>
41394161 ]]>
41404162 </Details>
41474169 <![CDATA[
41484170 <p>
41494171 final でない public static フィールドは、悪質なコードや偶然別のパッケージによって変更される可能性があります。
4150 フィールドは、脆弱性を回避するために final にできます。
4172 フィールドは、脆弱性を回避するために final にします。
41514173 しかしながら、スタティックイニシャライザには複数のフィールドへの書き込みがあるので、何らかのリファクタリングを必要とするでしょう。
41524174 </p>
41534175 ]]>
41614183 <![CDATA[
41624184 <p>
41634185 final でない public static フィールドは、悪質なコードや偶然別のパッケージによって変更される可能性があります。
4164 フィールドは、脆弱性を回避するために final にできます。
4186 フィールドは、脆弱性を回避するために final にします。
41654187 </p>
41664188 ]]>
41674189 </Details>
41744196 <![CDATA[
41754197 <p>
41764198 この可変 static フィールドは、悪質なコードや偶然別のパッケージによって変更される可能性があります。
4177 フィールドは、脆弱性を回避するためにパッケージプロテクテッドにできます。
4199 フィールドは、脆弱性を回避するためにパッケージプロテクテッドにします。
41784200 </p>
41794201 ]]>
41804202 </Details>
42204242 </BugPattern>
42214243
42224244 <BugPattern type="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">
4223 <ShortDescription>継承されたメソッドなのか外部のメソッドなのかあいまいなメソッドの呼び出し</ShortDescription>
4224 <LongDescription>継承されたメソッドなのか外部のメソッドなのかあいまいなメソッド {2} を呼び出しています。{1}</LongDescription>
4245 <ShortDescription>潜在的な継承されたメソッドなのか外部のメソッドなのかあいまいなメソッドの呼び出し</ShortDescription>
4246 <LongDescription>潜在的な継承されたメソッドなのか外部のメソッドなのかあいまいなメソッド {2} を呼び出しています。{1}</LongDescription>
42254247 <Details>
42264248 <![CDATA[
42274249 <p>
42284250 内部クラスは、継承されたメソッドか外部クラスで定義されたメソッドなのかどちらとも解釈できるメソッドを呼び出しています。
4229 Java の仕様上は継承したメソッドを呼び出しますが、これは意図したことではないかもしれません。
4251 たとえば、<code>foo(17)</code> を呼び出します。それはスーパークラスと外部のメソッドの両方で定義されています。
4252 Java のセマンティックスでは、継承したメソッドを呼び出しますが、これは意図したことではないかもしれません。
4253 </p>
4254 <p>
42304255 本当に継承されたメソッドを呼び出すつもりなら super を付けて (例:super.foo(17)) 呼び出してください。
42314256 そうすれば、外部クラスのメソッドではなく継承されたメソッドを呼び出したいことがこのコードを読む人と FindBugs に明確になります。
4257 </p>
4258 <p>
4259 <code>this.foo(17)</code> を呼び出す場合は、継承されたメソッドが呼び出されます。
4260 しかしながら、FindBugs はクラスファイルを見るだけなので、<code>this.foo(17)</code> と <code>foo(17)</code> の呼び出しの違いを見分けることができません。
4261 潜在的なあいまいな呼び出しについて文句を言うでしょう。
42324262 </p>
42334263 ]]>
42344264 </Details>
42404270 <Details>
42414271 <![CDATA[
42424272 <p>
4243 このクラスにはそのスーパークラスと同一の単純名がありますが、スーパークラスは異なるパッケージです (たとえば、<code>alpha.Foo</code> が <code>beta.Foo</code> を拡張します)。
4273 このクラスは、スーパークラスが異なるパッケージであるということを除いて、スーパークラスと同一の単純名をです (たとえば、<code>alpha.Foo</code> が <code>beta.Foo</code> を拡張します)。
42444274 これは非常に紛らわしく、参照関係を解決するために import 文を見なければならなかったり、スーパークラスに存在するメソッドを誤ってオーバーライドしてしまったりする状況を作り出します。
42454275 </p>
42464276 ]]>
42534283 <Details>
42544284 <![CDATA[
42554285 <p>
4256 このクラスまたはインタフェースには実装された/拡張されたインタフェースと同一の単純名がありますが、インタフェースは異なるパッケージです (たとえば、<code>alpha.Foo</code> が <code>beta.Foo</code> を継承しているような状況です)。
4286 このクラスまたはインタフェースは、、インタフェースが異なるパッケージであるということを除いて実装された/拡張されたインタフェースと同一の単純名です (たとえば、<code>alpha.Foo</code> が <code>beta.Foo</code> を継承しているような状況です)。
42574287 これは非常に紛らわしく、参照関係を解決するために import 文を見なければならなかったり、スーパークラスに存在するメソッドを誤ってオーバーライドしてしまったりする状況を作り出します。
42584288 </p>
42594289 ]]>
43124342 </BugPattern>
43134343
43144344 <BugPattern type="NM_VERY_CONFUSING_INTENTIONAL">
4315 <ShortDescription>非常に紛らわしい名前のメソッド (たぶん意図的)</ShortDescription>
4316 <LongDescription>{1} と {3} のメソッドは、非常に紛らわしいです (たぶん意図的)。</LongDescription>
4345 <ShortDescription>非常に紛らわしい名前のメソッド (多分意図的)</ShortDescription>
4346 <LongDescription>{1} と {3} のメソッドは、非常に紛らわしいです (多分意図的)。</LongDescription>
43174347 <Details>
43184348 <![CDATA[
43194349 <p>
43334363 <![CDATA[
43344364 <p>
43354365 パラメータの型がスーパークラスで対応するパラメータの型と正確に合致していないので、サブクラスのメソッドはスーパークラスの類似したメソッドをオーバーライドしていません。<br>
4336 たとえば、以下のようなコードです。
4366 たとえば以下のようなコードです。
43374367 </p>
43384368 <blockquote><pre>
43394369 import alpha.Foo;
43554385 ]]>
43564386 </Details>
43574387 </BugPattern>
4388
43584389 <BugPattern type="NM_WRONG_PACKAGE_INTENTIONAL">
43594390 <ShortDescription>パラメータの間違ったパッケージのためにスーパークラスのメソッドをオーバーライドしていないメソッド</ShortDescription>
43604391 <LongDescription>パラメータの型 {4} がスーパークラスのパラメータの型 {5} と合致しないので、{1} はスーパークラスのメソッドをオーバーライドしていません。</LongDescription>
43614392 <Details>
43624393 <![CDATA[
43634394 <p>
4364 パラメータの型がスーパークラスで対応するパラメータの型と正確に合致していないので、サブクラスのメソッドはスーパークラスの類似したメソッドをオーバーライドしません。<br>
4365 たとえば、以下のようなコードです。
4395 パラメータの型が正確にスーパークラスで対応するパラメータの型と合致していないので、サブクラスのメソッドはスーパークラスの類似したメソッドをオーバーライドしていません。<br>
4396 たとえば以下のようなコードです。
4397 </p>
43664398 <blockquote><pre>
43674399 import alpha.Foo;
43684400
43824414 これは引数の型 <code>Foo</code> が違うパッケージだからです。
43834415 </p>
43844416 <p>
4385 この場合、サブクラスがスーパークラスのメソッドと同一のシグネチャでメソッドを定義するので、おそらく理解されます。
4417 この場合、サブクラスがスーパークラスのメソッドと同一のシグネチャでメソッドを定義しているので、おそらく理解できます。
43864418 しかしながら、そのようなメソッドは非常に紛らわしいです。
43874419 類似しているが同一ではないシグネチャのメソッドを除去するか、非推奨にすることを強く検討するべきです。
43884420 </p>
44074439 <Details>
44084440 <![CDATA[
44094441 <p>
4410 この正規のメソッドは、定義しているクラスと同じ名前です。
4442 この正規のメソッドは定義しているクラスと同じ名前です。
44114443 これはコンストラクタを意図していた可能性が高いです。もしそうなら void 戻り値の宣言を除去してください。
44124444 このメソッドを定義したことが偶然間違っているとわかり、正しいコンストラクタを定義したが、下位互換性のためにこのメソッドを取り除くことができないなら、メソッドを非推奨にしてください。
44134445 </p>
44754507 <p>
44764508 このメソッドは、複数バイトを返す可能性がある <code>java.io.InputStream.read()</code> (またはそのバリエーション) の戻り値を無視しています。
44774509 戻り値がチェックされないと呼び出し元は要求したバイト数よりも少ないバイト数を読み出した場合、正しく処理できません。
4478 これは潜在的なバグです。
4479 多くのプログラムで、入力ストリームからの読み出しは、要求した完全なデータ量を読み出しますが、散発的に失敗することがあります。
4510 これは潜在的なバグで、多くのプログラムでは、入力ストリームからの読み出しは、通常要求した完全なデータ量を読み出しますが、散発的に失敗することがあります。
44804511 </p>
44814512 ]]>
44824513 </Details>
44904521 <p>
44914522 このメソッドは、複数バイトをスキップする可能性がある <code>java.io.InputStream.skip()</code> の戻り値を無視しています。
44924523 戻り値がチェックされないと呼び出し元は要求したバイト数よりも少ないバイト数しかスキップしなかった場合、正しく処理できません。
4493 これは潜在的なバグです。
4494 多くのプログラムで、入力ストリームからのスキップは、要求した完全なデータ量をスキップをしますが、散発的に失敗することがあります。
4495 しかしながら、バッファードストリーム での <code>skip</code> メソッドはバッファのデータをスキップするので、要求されたバイト数のスキップは常に失敗します。
4524 これは潜在的なバグで、多くのプログラムでは、入力ストリームからのスキップは、通常要求した完全なデータ量をスキップをしますが、散発的に失敗することがあります。
4525 しかしながら、バッファードストリーム での <code>skip</code> メソッドはバッファのデータをスキップするので要求されたバイト数のスキップは常に失敗します。
44964526 </p>
44974527 ]]>
44984528 </Details>
45044534 <Details>
45054535 <![CDATA[
45064536 <p>
4507 <code>readResolve</code> メソッドが直列化機構で認識されるためにはstatic メソッドとして宣言してはいけません。
4508 </p>
4509 ]]>
4510 </Details>
4511 </BugPattern>
4537 <code>readResolve</code> メソッドが直列化機構で認識されるためには static メソッドとして宣言してはいけません。
4538 </p>
4539 ]]>
4540 </Details>
4541 </BugPattern>
4542
45124543 <BugPattern type="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">
45134544 <ShortDescription>サブクラスで継承できない private な readResolve メソッド</ShortDescription>
45144545 <LongDescription>サブクラスで継承できない {0} の private な readResolve メソッドです。</LongDescription>
45174548 <p>
45184549 このクラスは、private な <code>readResolve</code> メソッドを定義しています。
45194550 そのため、このメソッドはサブクラスで継承できません。
4520 これが意図したことなら間違っていないかもしれませんが、確認するためにレビューするべきです。
4551 これが意図したことなら間違っていないかもしれませんが確認するためにレビューするべきです。
45214552 </p>
45224553 ]]>
45234554 </Details>
45344565 ]]>
45354566 </Details>
45364567 </BugPattern>
4568
45374569 <BugPattern type="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">
45384570 <ShortDescription>Serializable でないクラスの transient フィールド</ShortDescription>
45394571 <LongDescription>{1.givenClass} は、transient ですが、{0} は Serializable ではありません。</LongDescription>
45414573 <![CDATA[
45424574 <p>
45434575 フィールドは、transient と宣言していますが、クラスは直列化可能ではないので、まったく効果がありません。
4544 これはクラスが transient だったときの名残かもしれません、あるいは直列化機構を誤解しているのかもしれません。
4576 クラスが transient だったときの名残かもしれません、あるいは直列化機構を誤解しているのかもしれません。
45454577 </p>
45464578 ]]>
45474579 </Details>
45544586 <![CDATA[
45554587 <p>
45564588 このクラスには複数の場所で更新されるフィールドがあります。したがって、このクラスの状態の一部であると思われます。
4557 しかしながら、フィールドは transient と宣言しているので、 readObject/readResolve で設定されません。
4589 しかしながら、フィールドは transient と宣言しているので、 readObject/readResolve で値が設定されません。
45584590 クラスの直列化復元されたインスタンスにはデフォルト値が設定されます。
45594591 </p>
45604592 ]]>
45764608
45774609 <BugPattern type="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">
45784610 <ShortDescription>Externalizable なクラスが引数なしコンストラクタを定義していない</ShortDescription>
4579 <LongDescription>{0} は、Externalizable を実装しているのに引数なしコンストラクタを定義していません。</LongDescription>
4580 <Details>
4581 <![CDATA[
4582 <p>
4583 このクラスは、<code>Externalizable</code> インタフェースを実装しているのに、引数なしコンストラクタは定義していません。
4584 Externalizable オブジェクトが直列化復元されるときは、最初に引数なしコンストラクタを呼び出すことによって構築される必要があります。
4611 <LongDescription>{0} は、Externalizable を実装していますが、引数なしコンストラクタを定義していません。</LongDescription>
4612 <Details>
4613 <![CDATA[
4614 <p>
4615 このクラスは、<code>Externalizable</code> インタフェースを実装していますが、引数なしコンストラクタを定義していません。
4616 <code>Externalizable</code> オブジェクトが直列化復元されるときは、最初に引数なしコンストラクタを呼び出すことによって構築される必要があります。
45854617 このクラスには引数なしコンストラクタがないので、直列化と直列化復元は実行時に失敗します。
45864618 </p>
45874619 ]]>
46044636
46054637 <BugPattern type="SE_NO_SERIALVERSIONID">
46064638 <ShortDescription>Serializable なクラスが serialVersionUID を定義していない</ShortDescription>
4607 <LongDescription>{0} は、Serializable を実装しているのに serialVersionUID は定義していません。</LongDescription>
4608 <Details>
4609 <![CDATA[
4610 <p>
4611 このクラスは <code>Serializable</code> インタフェースを実装しているのに <code>serialVersionUID</code> フィールドを定義していません。
4639 <LongDescription>{0} は、Serializable を実装していますが、serialVersionUID は定義していません。</LongDescription>
4640 <Details>
4641 <![CDATA[
4642 <p>
4643 このクラスは <code>Serializable</code> インタフェースを実装していますが、<code>serialVersionUID</code> フィールドを定義していません。
46124644 .class オブジェクトへの参照を追加するのと同じくらい簡単な変更でクラスに合成フィールドを追加します。
4613 それは、残念ながら暗黙の serialVersionUID を変えます (たとえば、<code>String.class</code> への参照を追加すると、<code>class$java$lang$String</code> という static フィールドを生成します)。
4614 また、バイトコードコンパイラへの異なるソースコードは、クラスオブジェクトまたは内部クラスに参照のために生成される合成変数のために、異なる命名規則を使用するかもしれません。
4645 それは、残念ながら暗黙の <code>serialVersionUID</code> を変えます (たとえば、<code>String.class</code> への参照を追加すると、<code>class$java$lang$String</code> という static フィールドを生成します)。
4646 また、バイトコードコンパイラへの異なるソースコードは、クラスオブジェクトまたは内部クラスに参照のために生成される合成変数のために異なる命名規則を使用するかもしれません。
46154647 バージョンを横断する Serializable の相互運用性を保証するために、明示的に、serialVersionUID を追加することを検討してください。
46164648 </p>
46174649 ]]>
46204652
46214653 <BugPattern type="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">
46224654 <ShortDescription>Comparator は Serializable を実装していない</ShortDescription>
4623 <LongDescription>{0} は、Comparator を実装しているのに Serializable を実装していません。</LongDescription>
4655 <LongDescription>{0} は、Comparator を実装していますが、Serializable を実装していません。</LongDescription>
46244656 <Details>
46254657 <![CDATA[
46264658 <p>
46274659 このクラスは <code>Comparator</code> インタフェースを実装しています。
46284660 <code>Serializable</code> インタフェースも実装するべきかどうか検討するべきです。
46294661 コンパレータが <code>TreeMap</code> のような順序付きコレクションを構築するために使われるなら、コンパレータが直列化可能な場合だけ、<code>TreeMap</code> は直列化可能です。
4630 大部分のコンパレータがほとんど状態を持たないとしても、直列化可能にすることは簡単で良い防衛的なプログラミングです。
4631 </p>
4632 ]]>
4633 </Details>
4634 </BugPattern>
4635
4662 大部分のコンパレータがほとんど状態を持たないとしても直列化可能にすることは簡単で良い防衛的なプログラミングです。
4663 </p>
4664 ]]>
4665 </Details>
4666 </BugPattern>
46364667
46374668 <BugPattern type="SF_SWITCH_FALLTHROUGH">
46384669 <ShortDescription>1つの case が次の case へと通り抜ける switch 文を発見した</ShortDescription>
46464677 ]]>
46474678 </Details>
46484679 </BugPattern>
4680
46494681 <BugPattern type="SF_SWITCH_NO_DEFAULT">
46504682 <ShortDescription>default がない switch 文を発見した</ShortDescription>
46514683 <LongDescription>default がない switch 文を発見しました。{1}</LongDescription>
46614693 ]]>
46624694 </Details>
46634695 </BugPattern>
4696
46644697 <BugPattern type="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">
46654698 <ShortDescription>switch 文のフォールスルーのために格納が無効になっている</ShortDescription>
46664699 <LongDescription>前の case からの値 {2.givenClass} が switch 文のフォールスルーのためにここで上書きされています。</LongDescription>
46684701 <![CDATA[
46694702 <p>
46704703 前の case で格納された値が switch 文のフォールスルーのためにここで上書きされています。
4671 前の case の終わりに break または return を置くのを忘れた可能性があります。
4704 前の case の終わりに break または return を入れるのを忘れた可能性があります。
46724705 </p>
46734706 ]]>
46744707 </Details>
46814714 <![CDATA[
46824715 <p>
46834716 前の case で格納された値が例外がスローされる場所で、switch 文のフォールスルーのためにここで失われています。
4684 前の case の終わりに break または return を置くのを忘れた可能性があります。
4717 前の case の終わりに break または return を入れるのを忘れた可能性があります。
46854718 </p>
46864719 ]]>
46874720 </Details>
47064739 <Details>
47074740 <![CDATA[
47084741 <p>
4709 この直列化可能クラスは同期化する <code>readObject</code> メソッド を定義しています。
4710 定義によって、直列化復元によって作成されるオブジェクトは1つのスレッドによってだけ到達可能です。
4742 この直列化可能クラスは同期化する <code>readObject</code> メソッド を定義していますが、
4743 直列化復元によって作成されるオブジェクトは1つのスレッドによってだけ到達可能です。
47114744 したがって、<code>readObject</code> メソッドは同期化する必要がありません。
47124745 <code>readObject</code> メソッドそのものが別のスレッドに見えるようになるオブジェクトの原因になっているなら非常に疑わしいコーディングスタイルの例です。
47134746 </p>
47624795 <p>
47634796 この直列化可能クラスは、transient、Serializable、<code>java.lang.Object</code> でもない非プリミティブ型のインスタンスフィールドを定義して、
47644797 <code>Externalizable</code> インタフェースまたは <code>readObject</code> メソッドと <code>writeObject</code> メソッドを実装するように見えません。
4765 また、<code>Externalizable</code> インタフェースも実装していないし、<code>readObject</code> メソッドも <code>writeObject</code> メソッドも定義していません。
4766 非直列化可能オブジェクトがこのフィールドに格納されるならこのクラスのオブジェクトは正しく直列化復元されません。
4798 また、<code>Externalizable</code> インタフェースも実装していなくて、<code>readObject</code> メソッドも <code>writeObject</code> メソッドも定義していません。
4799 非直列化可能オブジェクトがこのフィールドに格納されるならクラスのオブジェクトは正しく直列化復元されません。
47674800 </p>
47684801 ]]>
47694802 </Details>
47934826 <Details>
47944827 <![CDATA[
47954828 <p>
4796 この直列化可能なクラスは、内部クラスです。
4797 内部クラスを直列化しようとすると関連した外部クラスのインスタンスも直列化します。
4829 この直列化可能なクラスは内部クラスです。内部クラスを直列化しようとすると関連した外部クラスのインスタンスも直列化します。
47984830 外部クラスのインスタンスは直列化可能なので失敗しませんが、意図したことよりもっとずっと多くのデータを直列化するかもしれません。
47994831 できれば、内部クラスを static にして問題を解決するべきです。
48004832 </p>
48714903 <![CDATA[
48724904 <p>
48734905 このフィールドは決して使用されません。
4874 フィールドは、public か protected なので、たぶん、それは解析の一部として見えないクラスで使用されることを意図しています。
4906 フィールドは、public か protected なので、多分、それは解析の一部として見えないクラスで使用されることを意図しています。
48754907 そうでなければ、クラスから除去することを検討してください。
48764908 </p>
48774909 ]]>
48844916 <Details>
48854917 <![CDATA[
48864918 <p>
4887 このフィールドは決して読み出されません。
4888 フィールドは、public か protected なので、たぶん、それは解析の一部として見えないクラスで使用されることを意図しています。
4919 このフィールドは決して読み出されません。
4920 フィールドは、public か protected なので、多分、それは解析の一部として見えないクラスで使用されることを意図しています。
48894921 そうでなければ、クラスから除去することを検討してください。
48904922 </p>
48914923 ]]>
48994931 <![CDATA[
49004932 <p>
49014933 本当にこの for ループが正しい変数をインクリメントしていますか?
4902 別の変数が for ループによって初期化されて、チェックされるように見えます。
4934 別の変数が for ループによって初期化されてチェックされるように見えます。
49034935 </p>
49044936 ]]>
49054937 </Details>
49514983 <![CDATA[
49524984 <p>
49534985 このインスタンスメソッドは、static フィールドに書き込みをしています。
4954 複数のインスタンスが操作されているなら、正しくさせるのは難しいです。通常、間違ったプラクティスです。
4986 複数のインスタンスが操作されているなら、正しくさせるのは難しいです。一般的に間違ったプラクティスです。
49554987 </p>
49564988 ]]>
49574989 </Details>
49644996 <![CDATA[
49654997 <p>
49664998 ここで参照されている変数は、以前に null なのかチェックしているため null であることがわかっています。
4967 これは有効かもしれないし、間違いかもしれません (たぶん、異なる変数を参照することを意図してました、あるいは以前の null チェックで null でないのか確かめるべきでした)。
4999 これは有効かもしれないが、間違いかもしれません (多分異なる変数を参照することを意図してました、あるいは以前の null チェックで null でないのか確かめるべきでした)。
49685000 </p>
49695001 ]]>
49705002 </Details>
50165048 <![CDATA[
50175049 <p>
50185050 プログラムは、決して null 値でない値を書き込むと思われない public または protected フィールドの null 値を利用しています。
5019 フィールドが解析によって見られない機構を通して初期化されない限り、この値を利用すると NullPointerException が発生します。
5051 フィールドが解析によって見られない機構を通して初期化されないかぎり、この値を利用すると NullPointerException が発生します。
50205052 </p>
50215053 ]]>
50225054 </Details>
51295161 <p>
51305162 このメソッドは、<code>notifyAll</code> メソッドではなく <code>notify</code> メソッドを呼び出しています。
51315163 モニタが複数の条件のために多くの場合使われます。
5132 <code>notify</code> メソッドの呼び出しは1つのスレッドを起こすだけで、起こされたスレッドは呼び出し元が満たした待機条件の1つではないかもしれないことを意味しています。
5164 <code>notify</code> メソッドの呼び出しは1つのスレッドを起こすだけで起こされたスレッドは呼び出し元が満たした待機条件の1つではないかもしれないことを意味しています。
51335165 </p>
51345166 ]]>
51355167 </Details>
51425174 <![CDATA[
51435175 <p>
51445176 このメソッドは <code>String.indexOf</code> を呼び出して結果が正かどうか確かめています。
5145 結果が負かどうか確かめる方がずっと典型的です。チェックされる部分文字列が先頭以外の場所で出現するときだけ正になります。
5146
5177 結果が負かどうか確かめるほうがずっと典型的です。チェックされる部分文字列が先頭以外の場所で出現するときだけ正になります。
51475178 </p>
51485179 ]]>
51495180 </Details>
51705201 <![CDATA[
51715202 <p>
51725203 このコードは、メソッドを呼び出して、戻り値を無視しています。
5173 戻り値は、メソッドが呼び出される型と同じ型です。そして、我々の解析から戻り値が重要であるかもしれないように見えます (たとえば、<code>String.toLowerCase()</code> の戻り値を無視するような)。
5204 戻り値は、メソッドが呼び出される型と同じ型です。そして、我々の解析から戻り値が重要であるかもしれないように見えます (たとえば、<code>String.toLowerCase()</code> の戻り値を無視するような)。
51745205 </p>
51755206 <p>
51765207 我々は、戻り値を無視することがメソッド本体の単純な解析から悪い考えかもしれないと推測しています。
51915222 <p>
51925223 このメソッドの戻り値はチェックするべきです。
51935224 この警告の共通の原因は、オブジェクトが更新されると思って不変オブジェクトのメソッドを呼び出すことです。<br>
5194 たとえば、以下のようなコードです。
5225 たとえば以下のようなコードです。
51955226 </p>
51965227 <blockquote><pre>
51975228 String dateString = getHeaderField(name);
52165247 <Details>
52175248 <![CDATA[
52185249 <p>
5219 このメソッドは、チェックされていない値を返しています。
5250 このメソッドはチェックされていない値を返しています。
52205251 戻り値は異常か予想外の実行結果を示す可能性があるのでチェックするべきです。
52215252 たとえば、<code>File.delete()</code> はファイルをうまく削除できなかったなら、例外をスローするのではなく false を返します。
52225253 結果をチェックしないなら例外的戻り値を返すメソッドの呼び出しで予想外の振る舞いの合図に気づきません。
52455276 <Details>
52465277 <![CDATA[
52475278 <p>
5248 このコードは、例外 (またはエラー) オブジェクトを作成しているのに何もしていません。<br>
5249 たとえば、以下のようなコードです。
5279 このコードは、例外 (またはエラー) オブジェクトを作成していますが、何もしていません。<br>
5280 たとえば以下のようなコードです。
52505281 </p>
52515282 <blockquote><pre>
52525283 if (x &lt; 0) {
52655296 </Details>
52665297 </BugPattern>
52675298
5268
5269
52705299 <BugPattern type="NP_ALWAYS_NULL">
52715300 <ShortDescription>null 値を利用している</ShortDescription>
52725301 <LongDescription>{2.givenClass} の null 値を利用しています。{1}</LongDescription>
52985327 <ShortDescription>@NonNull でアノテートされたフィールドに null を格納している</ShortDescription>
52995328 <LongDescription>@NonNull でアノテートされたフィールド {2.givenClass} に null を格納しています。{1}</LongDescription>
53005329 <Details>
5301 <![CDATA[
5330 <![CDATA[
53025331 <p>
53035332 @NonNull でアノテートされたフィールドに null かもしれない値を格納しています。
53045333 </p>
53125341 <Details>
53135342 <![CDATA[
53145343 <p>
5315 例外経路上のここで null 値を利用しています。
5316 コードが実行されると NullPointerException が発生します。
5344 例外経路上のここで null 値を利用しています。コードが実行されると NullPointerException が発生します。
53175345 現在の FindBugs は実行不可能な例外経路を取り除いていないので、誤検出かもしれないことに注意してください。
53185346 </p>
53195347 <p>
53295357 <Details>
53305358 <![CDATA[
53315359 <p>
5332 このパラメータは、常に 非 null にすることを要求する方法で使われますが、パラメータには明示的に null 可能としてアノテートされています。
5360 このパラメータは、常に 非 null にすることを要求する方法で使われていますが、パラメータには明示的に null 可能としてアノテートされています。
53335361 パラメータかアノテーションのどちらかの使い方が間違っています。
53345362 </p>
53355363 ]]>
53595387 分岐または文が実行されるなら、null 値が利用されて NullPointerException が発生します。
53605388 もちろん、問題は分岐または文が実行不可能で、NullPointerException が決して発生する可能性がないということかもしれません。
53615389 それを決めるのは FindBugs の能力を超えています。
5362 この値がすでに null であることを検査したという事実からこれは確かな可能性です。
5390 この値がすでに null であることを検査したという事実からこれは明確な可能性です。
53635391 </p>
53645392 ]]>
53655393 </Details>
53715399 <Details>
53725400 <![CDATA[
53735401 <p>
5374 例外経路上のここで null 値が利用されています。
5375 コードが実行されると NullPointerException が発生するかもしれません。
5402 例外経路上のここで null 値が利用されています。コードが実行されると NullPointerException が発生するかもしれません。
53765403 現在の FindBugs は実行不可能な例外経路を取り除かないので、誤検出かもしれないことに注意してください。
53775404 </p>
53785405 <p>
54125439 <ShortDescription>メソッド呼び出しは非 null パラメータに対して null を渡している</ShortDescription>
54135440 <LongDescription>{2.givenClass} の 非 null パラメータに対して null を渡しています。{1}</LongDescription>
54145441 <Details>
5415 <![CDATA[
5416 <p>
5417 おそらく、すべての知られているターゲットメソッドが非 null であることを要求する呼び出し場所で null 値を渡しています。
5442 <![CDATA[
5443 <p>
5444 すべての既知のターゲットメソッドが非 null であることをパラメータに要求する呼び出し場所で、おそらく null 値を渡しています。
54185445 パラメータは、常に非 null とすべきパラメータとしてアノテートされていたか、または解析が常に null 値を利用すると示していました。
54195446 </p>
5420 ]]>
5447 ]]>
54215448 </Details>
54225449 </BugPattern>
54235450
54255452 <ShortDescription>メソッド呼び出しは非 null パラメータに対して null を渡している</ShortDescription>
54265453 <LongDescription>{2.givenClass} の 非 null パラメータに対して null を渡しています。{1}</LongDescription>
54275454 <Details>
5428 <![CDATA[
5455 <![CDATA[
54295456 <p>
54305457 このメソッド呼び出しは非 null メソッドパラメータに対して null 値を渡しています。
54315458 パラメータは、常に非 null とすべきパラメータとしてアノテートされていたか、または解析が常に null 値を利用すると示していました。
54325459 </p>
5433 ]]>
5460 ]]>
54345461 </Details>
54355462 </BugPattern>
54365463
54385465 <ShortDescription>メソッド呼び出しは非 null パラメータに対して null を渡している</ShortDescription>
54395466 <LongDescription>{2.givenClass} の 非 null パラメータに対して null を渡しています。{1}</LongDescription>
54405467 <Details>
5441 <![CDATA[
5468 <![CDATA[
54425469 <p>
54435470 このメソッドは、非 null でなければならないメソッドのパラメータとして、null 値を渡しています。
54445471 このパラメータは、@Nonnull として明示的にアノテートされていたか、または解析が常に null 値を利用すると示していました。
54455472 </p>
5446 ]]>
5473 ]]>
54475474 </Details>
54485475 </BugPattern>
54495476
54635490 <ShortDescription>null を返すかもしれない clone メソッド</ShortDescription>
54645491 <LongDescription>{1} は、null を返すかもしれません。</LongDescription>
54655492 <Details>
5466 <![CDATA[
5467 <p>
5468 この <code>clone</code> メソッドはいくつかの条件で null を返すと思われます。
5493 <![CDATA[
5494 <p>
5495 この <code>clone</code> メソッドは、いくつかの条件で null を返すと思われます。
54695496 しかし、<code>clone</code> メソッドは決して null を返すのは許されません。
5470 この経路が到達できないことを確信しているなら、その代わりに <code>AssertionError</code> をスローしてください。
5471 </p>
5472 ]]>
5473 </Details>
5474 </BugPattern>
5497 この経路が到達できないことを確信しているなら、代わりに <code>AssertionError</code> をスローしてください。
5498 </p>
5499 ]]>
5500 </Details>
5501 </BugPattern>
5502
54755503 <BugPattern type="NP_TOSTRING_COULD_RETURN_NULL">
54765504 <ShortDescription>null を返すかもしれない toString メソッド</ShortDescription>
54775505 <LongDescription>{1} は、null を返すかもしれません。</LongDescription>
54785506 <Details>
54795507 <![CDATA[
54805508 <p>
5481 この <code>toString</code> メソッドはいくつかの条件で null を返すと思われます。
5509 この <code>toString</code> メソッドは、いくつかの条件で null を返すと思われます。
54825510 仕様を寛大に読むとこれが許されると解釈できるかもしれませんが、それはおそらく間違った考えで、他のコードが壊れる原因になる可能性があります。
5483 null ではなく空の文字列またはいくつかの他の適切な文字列を返してください。
5511 null ではなく空の文字列または、いくつかの他の適切な文字列を返してください。
54845512 </p>
54855513 ]]>
54865514 </Details>
55195547 <Details>
55205548 <![CDATA[
55215549 <p>
5522 すべての static finalフィールドが初期化される前に、スタティックイニシャライザはクラスのインスタンスを作成します。
5550 すべての static final フィールドが初期化される前に、スタティックイニシャライザがクラスのインスタンスを作成します。
55235551 </p>
55245552 ]]>
55255553 </Details>
55315559 <Details>
55325560 <![CDATA[
55335561 <p>
5534 このメソッドは、入出力ストリームオブジェクトを作成しているのにどんなフィールドにも代入していないし、クローズするかもしれない別のメソッドにも渡していないし、戻り値にしてもいません。そして、メソッドからのすべての経路でクローズするように見えません。
5562 このメソッドは、入出力ストリームオブジェクトを作成していますが、どんなフィールドにも代入していないしクローズするかもしれない別のメソッドにも渡していなくて、戻り値にしてもいません。そして、メソッドからのすべての経路でクローズするように見えません。
55355563 これは、ファイルディスクリプタリークになるかもしれません。
5536 ストリームがクローズされることを確実にするために <code>finally</code> ブロックを使うことは、通常良い考えです。
5564 ストリームがクローズされることを確実にするために <code>finally</code> ブロックを使うことは、一般に良い考えです。
55375565 </p>
55385566 ]]>
55395567 </Details>
55455573 <Details>
55465574 <![CDATA[
55475575 <p>
5548 このメソッドは、入出力ストリームオブジェクトを作成しているのにどんなフィールドにも代入していないし、クローズするかもしれない別のメソッドにも渡していないし、戻り値にしてもいません。そして、メソッドからのすべての可能性がある例外経路でクローズするように見えません。
5576 このメソッドは、入出力ストリームオブジェクトを作成していますが、どんなフィールドにも代入していないしクローズするかもしれない別のメソッドにも渡していないくて、戻り値にしてもいません。そして、メソッドからのすべての可能性がある例外経路でクローズするように見えません。
55495577 これはファイルディスクリプターリークになるかもしれません。
5550 ストリームがクローズされることを確実にするために <code>finally</code> ブロックを使うことは、通常良い考えです。
5578 ストリームがクローズされることを確実にするために <code>finally</code> ブロックを使うことは、一般に良い考えです。
55515579 </p>
55525580 ]]>
55535581 </Details>
55775605 <p>
55785606 このメソッドには分岐するのかどうかに関係なく、制御フローが同じ場所へと続く、役に立たない制御フロー文があります。<br>
55795607 たとえば、これは 空の <code>if</code> 文が原因になります。
5608 </p>
55805609 <blockquote><pre>
55815610 if (argv.length == 0) {
55825611 // TODO: handle this case
56115640 <p>
56125641 ここで値が null なのかチェックしていますが、すでに値を利用していたので null である可能性はありません。
56135642 値が null なら以前の利用で NullPointerException が発生していたでしょう。
5614 基本的に、この値が null であることを許すのかどうかに関係なく、このコードと以前の値の利用は一致しません。
5643 基本的に、値が null であることを許すのかどうかに関係なく、このコードと以前の値の利用は一致しません。
56155644 チェックは冗長か、または以前の値の利用は誤りです。
56165645 </p>
56175646 ]]>
56555684 </BugPattern>
56565685
56575686 <BugPattern type="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">
5658 <ShortDescription>null でない値と null 値との冗長な比較</ShortDescription>
5659 <LongDescription>null でない値と null 値との冗長な比較があります。{1}</LongDescription>
5687 <ShortDescription>非 null 値と null 値との冗長な比較</ShortDescription>
5688 <LongDescription>非 null 値と null 値との冗長な比較があります。{1}</LongDescription>
56605689 <Details>
56615690 <![CDATA[
56625691 <p>
56935722 <Details>
56945723 <![CDATA[
56955724 <p>
5696 このメソッドは、JSR-166(<code>java.util.concurrent</code>) のロックを獲得しているのにメソッドからのすべての経路で解除していません。
5697 通常、JSR-166のロックを使用するための正しいイディオムは以下のようになります。
5725 このメソッドは、JSR-166(<code>java.util.concurrent</code>) のロックを獲得していますが、メソッドからのすべての経路で解除していません。
5726 一般に、JSR-166のロックを使用するための正しいイディオムは以下のようになります。
56985727 </p>
56995728 <blockquote><pre>
57005729 Lock l = ...;
57155744 <Details>
57165745 <![CDATA[
57175746 <p>
5718 このメソッドは、JSR-166(<code>java.util.concurrent</code>) のロックを獲得しているのにメソッドからのすべての例外経路で解除していません。
5719 通常、JSR-166のロックを使用するための正しいイディオムは以下のようになります。
5747 このメソッドは、JSR-166(<code>java.util.concurrent</code>) のロックを獲得していますが、メソッドからのすべての例外経路で解除していません。
5748 一般に、JSR-166のロックを使用するための正しいイディオムは以下のようになります。
57205749 </p>
57215750 <blockquote><pre>
57225751 Lock l = ...;
57385767 <![CDATA[
57395768 <p>
57405769 このメソッドは、 == または != 演算子を使用して2つの参照値を比較しています。
5741 この型のインスタンスを比較する正しい方法は、通常 <code>equals</code> メソッドです。
5742 等価で識別可能なインスタンスを作成する可能性がありますが、異なるオブジェクトなので == で比較しないでください。
5743 参照によって通常比較されるべきでないクラスの例は、<code>java.lang.Integer</code> 、<code>java.lang.Float</code> などです。
5770 この型のインスタンスを比較する正しい方法は、一般に <code>equals</code> メソッドです。
5771 等価で識別可能なインスタンスを作成する可能性がありますが異なるオブジェクトなので == で比較しないでください。
5772 参照によって一般に比較されるべきでないクラスの例は、<code>java.lang.Integer</code> 、<code>java.lang.Float</code> などです。
57445773 </p>
57455774 ]]>
57465775 </Details>
57525781 <Details>
57535782 <![CDATA[
57545783 <p>
5755 このメソッドは、 == または != 演算子を使用して定数と比較しています。
5756 この型のインスタンスを比較する正しい方法は、通常 <code>equals</code> メソッドです。
5757 等価で識別可能なインスタンスを作成する可能性がありますが、異なるオブジェクトなので == で比較しないでください。
5758 参照によって通常比較されるべきではないクラスの例は、<code>java.lang.Integer</code> 、<code>java.lang.Float</code> などです。
5784 このメソッドは、 参照値を == または != 演算子を使用して定数と比較しています。
5785 この型のインスタンスを比較する正しい方法は、一般に <code>equals</code> メソッドです。
5786 等価で識別可能なインスタンスを作成する可能性がありますが異なるオブジェクトなので == で比較しないでください。
5787 参照によって一般に比較されるべきではないクラスの例は、<code>java.lang.Integer</code> 、<code>java.lang.Float</code> などです。
57595788 </p>
57605789 ]]>
57615790 </Details>
57685797 <![CDATA[
57695798 <p>
57705799 このメソッドは、== または != 演算子を使用して2つの Boolean 値を比較しています。
5771 通常は2つの Boolean 値 (<code>Boolean.TRUE</code> と <code>Boolean.FALSE</code>) だけですが、
5800 一般には2つの Boolean 値 (<code>Boolean.TRUE</code> と <code>Boolean.FALSE</code>) だけですが、
57725801 <code>new Boolean(b)</code> コンストラクタを使用して他の Boolean オブジェクトを作成する可能性があります。
57735802 そのようなオブジェクトを回避することは最高です。
57745803 しかし、それらが存在するなら、Boolean オブジェクトの等価性をチェックするために <code>.equals(...)</code> ではなく == または != を使用しているなら異なる結果をもたらします。
57835812 <Details>
57845813 <![CDATA[
57855814 <p>
5786 このメソッドは、異なる型と思われる2つの参照を比較するために参照等価性を使用しています。
5815 このメソッドは異なる型と思われる2つの参照を比較するために参照等価性を使用しています。
57875816 この比較の結果は、常に false です。
57885817 </p>
57895818 ]]>
57975826 <![CDATA[
57985827 <p>
57995828 このメソッドは、共通のサブクラスがない異なるクラス型の2つのオブジェクト参照で <code>equals(Object)</code> メソッドを呼び出しています。
5800 したがって、比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5801 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に等しくないとして比較するべきです。
5829 したがって比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5830 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に不等として比較するべきです。
58025831 したがって、<code>java.lang.Object.equals(Object)</code> によって定義される規約によれば、この比較の結果は実行時に常に false になります。
58035832 </p>
58045833 ]]>
58135842 <p>
58145843 このメソッドは、どちらも他方のサブタイプでない無関係なインタフェース型の2つの参照で <code>equals(Object)</code> メソッドを呼び出しています。
58155844 そして、両方のインタフェースを実装する既知の非抽象クラスがありません。
5816 したがって、比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5817 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に等しくないとして比較するべきです。
5845 したがって比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5846 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に不等として比較するべきです。
58185847 したがって、<code>java.lang.Object.equals(Object)</code> によって定義される規約によれば、この比較の結果は実行時に常に false になります。
58195848 </p>
58205849 ]]>
58255854 <ShortDescription>equals メソッドを呼び出して無関係のクラスとインタフェースを比較している</ShortDescription>
58265855 <LongDescription>{3.simpleClass}.equals({2.simpleClass}) を呼び出しています。{1}</LongDescription>
58275856 <Details>
5828 <![CDATA[
5857 <![CDATA[
58295858 <p>
58305859 このメソッドは、一方がクラスで他方がインタフェースである2つの参照で <code>equals(Object)</code> メソッドを呼び出しています。
58315860 クラスは、そのクラスの非抽象サブクラスも含めてインタフェースを実装していません。
5832 したがって、比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5833 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に等しくないとして比較するべきです。
5861 したがって比較されている2つのオブジェクトは実行時に同じクラスのメンバである可能性が低いです (いくつかのアプリケーションクラスが解析できなかったか、動的クラスローディングが実行時に起こることができた場合を除く)。
5862 <code>equals</code> メソッドの規約によると、異なるクラスのオブジェクトは常に不等として比較するべきです。
58345863 したがって、<code>java.lang.Object.equals(Object)</code> によって定義される規約によれば、この比較の結果は実行時に常に false になります。
58355864 </p>
5836 ]]>
5865 ]]>
58375866 </Details>
58385867 </BugPattern>
58395868
58835912 <![CDATA[
58845913 <p>
58855914 このメソッドにはローカル変数の自己代入があり、ローカル変数とフィールドが同じ名前です。<br>
5886 たとえば、以下のようなコードです。
5915 たとえば以下のようなコードです。
58875916 </p>
58885917 <blockquote><pre>
58895918 int foo;
59055934 <![CDATA[
59065935 <p>
59075936 このメソッドにはローカル変数の自己代入があります。<br>
5908 たとえば、以下のようなコードです。
5937 たとえば以下のようなコードです。
59095938 </p>
59105939 <blockquote><pre>
59115940 public void foo() {
59275956 <![CDATA[
59285957 <p>
59295958 このメソッドにはフィールドの自己代入があります。<br>
5930 たとえば、以下のようなコードです。
5959 たとえば以下のようなコードです。
59315960 </p>
59325961 <blockquote><pre>
59335962 int x;
59495978 <![CDATA[
59505979 <p>
59515980 このメソッドにはフィールドの二重代入があります。<br>
5952 たとえば、以下のようなコードです。
5981 たとえば以下のようなコードです。
59535982 </p>
59545983 <blockquote><pre>
59555984 int x,y;
59716000 <![CDATA[
59726001 <p>
59736002 このメソッドにはローカル変数の二重代入があります。<br>
5974 たとえば、以下のようなコードです。
6003 たとえば以下のようなコードです。
59756004 </p>
59766005 <blockquote><pre>
59776006 public void foo() {
60086037 <p>
60096038 このメソッドは、ローカル変数と同じ変数への別の参照との無意味な計算を実行しています (たとえば、x &amp; x または x - x)。
60106039 この計算の性質のため、演算は意味をなすとは思われないので、論理エラーかタイプミスかもしれません。
6011 計算をチェックしてください。
6040 計算をダブルチェックしてください。
60126041 </p>
60136042 ]]>
60146043 </Details>
60336062 <Details>
60346063 <![CDATA[
60356064 <p>
6036 このメソッドは、ローカル変数をそれ自身と比較しています。
6037 論理エラーかタイプミスかもしれません。正しいものを比較していることを確認してください。
6065 このメソッドは、ローカル変数をそれ自身と比較しています。論理エラーかタイプミスかもしれません。
6066 正しいものを比較していることを確認してください。
60386067 </p>
60396068 ]]>
60406069 </Details>
60476076 <![CDATA[
60486077 <p>
60496078 <code>Double.longBitsToDouble()</code> の呼び出しで、32ビット int 値が引数として渡されています。
6050 これはほぼ間違いなく意図したことではありませんし、意図した結果を与えることはほとんどありません。
6079 これはほぼ間違いなく意図したことではありませんし意図した結果を与えることはほとんどありません。
60516080 </p>
60526081 ]]>
60536082 </Details>
60606089 <![CDATA[
60616090 <p>
60626091 このメソッド呼び出しへの引数は、順序が間違っているように見えます。
6063 たとえば、呼び出し <code>Preconditions.checkNotNull("message", message)</code> は、引数を予約しました。チェックされる値は、第一引数です。
6092 たとえば、呼び出し <code>Preconditions.checkNotNull("message", message)</code> は、引数を予約しました。チェックされる値は第一引数です。
60646093 </p>
60656094 ]]>
60666095 </Details>
60796108 </p>
60806109 <p>
60816110 生成された乱数が推測可能でないことが重要なら、乱数ごとに新しい <code>Random</code> オブジェクトを作成してはいけません (値はあまりに簡単に推測可能です)。
6082 その代わりに <code>java.security.SecureRandom</code> の使用を強く検討するべきです (そして、必要とされる乱数ごとに新しい <code>SecureRandom</code> のオブジェクトを作成することを回避します)。
6083 </p>
6084 ]]>
6085 </Details>
6086 </BugPattern>
6087
6111 その代わりに <code>java.security.SecureRandom</code> の使用を強く検討するべきです (そして必要とされる乱数ごとに新しい <code>SecureRandom</code> のオブジェクトを作成することを回避します)。
6112 </p>
6113 ]]>
6114 </Details>
6115 </BugPattern>
60886116
60896117 <BugPattern type="RV_ABSOLUTE_VALUE_OF_RANDOM_INT">
60906118 <ShortDescription>符号付き整数の乱数の絶対値を計算する間違った試み</ShortDescription>
61436171 計算結果が負ではないことを確認したいなら、コードを変更する必要があるかもしれません。
61446172 除数が2の累乗であることがわかっているなら、代わりにビット演算を使用できます (すなわち、<code>x.hashCode()%n</code> の代わりに <code>x.hashCode()&amp;(n-1)</code> を使用してください)。
61456173 これはおそらく、剰余を計算するより高速です。
6146 除数が2の累乗であるということをわかっていないなら、剰余演算の結果の絶対値を取得してください (すなわち、<code>Math.abs(x.hashCode()%n)</code>)。
6174 除数が2の累乗であるということをわかっていないなら、剰余演算の結果の絶対値を取得してください (すなわち <code>Math.abs(x.hashCode()%n)</code>)。
61476175 </p>
61486176 ]]>
61496177 </Details>
61936221 <Details>
61946222 <![CDATA[
61956223 <p>
6196 これはどんな有用な働きもしない整数ビット演算 (AND、OR、XOR) です (たとえば、<code>v & 0xffffffff</code>)。
6224 これはどんな有効な働きもしない整数ビット演算 (AND、OR、XOR) です (たとえば <code>v & 0xffffffff</code>)。
61976225 </p>
61986226 ]]>
61996227 </Details>
62056233 <Details>
62066234 <![CDATA[
62076235 <p>
6208 常に同じ値を返す整数の比較があります (たとえば、<code>x &lt;= Integer.MAX_VALUE</code>)。
6236 常に同じ値を返す整数の比較があります (たとえば <code>x &lt;= Integer.MAX_VALUE</code>)。
62096237 </p>
62106238 ]]>
62116239 </Details>
62456273 }
62466274 </pre></blockquote>
62476275 <p>
6248 その代わりに、以下のようなイディオムは動作します。
6276 その代わりに以下のようなイディオムは動作します。
62496277 </p>
62506278 <blockquote><pre>
62516279 int result = 0;
62776305 result = ((result &lt;&lt; 8) + b[i]);
62786306 </pre></blockquote>
62796307 <p>
6280 その代わりに、以下のようなイディオムは動作します。
6308 その代わりに以下のようなイディオムは動作します。
62816309 </p>
62826310 <blockquote><pre>
62836311 int result = 0;
62976325 このメソッドは、<i>(e &amp; C)</i> 形式の式を <i>D</i> と比較しています。
62986326 定数 <i>C</i> と <i>D</i> の特定の値と常に等しくないことを比較します。論理エラーかタイプミスかもしれません。
62996327 </p>
6300
63016328 ]]>
63026329 </Details>
63036330 </BugPattern>
64086435 <![CDATA[
64096436 <p>
64106437 このメソッドにはstatic フィールドの非同期な遅延初期化があります。
6411 フィールドが設定されたあと、その場所に格納されるオブジェクトはさらに更新されるかアクセスされます。
6412 それが設定されるとすぐに、そのフィールドの設定は他のスレッドに見えます。
6438 フィールドが設定された後で、その場所に格納されるオブジェクトはさらに更新されるかアクセスされます。
6439 それが設定されるとすぐに、フィールドの設定は他のスレッドに見えます。
64136440 フィールドを設定するさらなるアクセスがオブジェクトを初期化するのに役に立つなら、
6414 それが完全に初期化されるまでどんな他のスレッドも格納されたオブジェクトにアクセスするのを防がない限り、非常に深刻なマルチスレッドバグがあります。
6441 それが完全に初期化されるまでどんな他のスレッドも格納されたオブジェクトにアクセスするのを防がないかぎり、非常に深刻なマルチスレッドバグがあります。
64156442 </p>
64166443 <p>
64176444 たとえメソッドが複数のスレッドによって決して呼び出されないと確信していても、
6418 それは、フィールドに設定している値が完全にデータを読み込まれるか初期化されるまで、 static フィールドを設定しない方が良いかもしれません。
6445 それは、フィールドに設定している値が完全にデータを読み込まれるか初期化されるまで、 static フィールドを設定しないほうが良いかもしれません。
64196446 </p>
64206447 ]]>
64216448 </Details>
64276454 <Details>
64286455 <![CDATA[
64296456 <p>
6430 このメソッドは、java.util.concurrent.locks.Lock を実装したオブジェクトで同期化しています。
6457 このメソッドは、<code>java.util.concurrent.locks.Lock</code> を実装したオブジェクトで同期化しています。
64316458 そのようなオブジェクトは <code>synchronized (...)</code> 構文よりも <code>acquire()</code>/<code>release()</code> を使用してロックとロックの解除をします。
64326459 </p>
64336460 ]]>
64596486 たとえば、<code>AtomicBoolean</code> で同期しても、他のスレッドが <code>AtomicBoolean</code> を変更するのを防ぎません。
64606487 </p>
64616488 <p>
6462 そのようなコードは正しいかもしれないが、後日コードを維持しなければならない人々を混乱させるかもしれないので慎重にレビューし文書化するべきです、
6489 そのようなコードは正しいかもしれないが、将来コードを維持しなければならない人々を混乱させるかもしれないので慎重にレビューし文書化するべきです、
64636490 </p>
64646491 ]]>
64656492 </Details>
64846511 <Details>
64856512 <![CDATA[
64866513 <p>
6487 この無名クラスは、直接呼び出されない、スーパークラスのメソッドをオーバーライドしていないメソッドを定義しています。
6514 この無名クラスは、直接呼び出されないスーパークラスのメソッドをオーバーライドしていないメソッドを定義しています。
64886515 他のクラスのメソッドが無名クラスで宣言されたメソッドを直接呼び出せないので、このメソッドは呼び出し不可能であると思われます。
64896516 メソッドは単にデッドコードであるかもしれません。しかし、メソッドがスーパークラスで宣言されるメソッドをオーバーライドすることを意図した可能性もあります。
64906517 そして、タイプミスまたは他の誤りのために、メソッドは、実際、それが意図されるメソッドをオーバーライドしません。
64996526 <Details>
65006527 <![CDATA[
65016528 <p>
6502 このメソッドは、データベースリソース (たとえば、データベースコネクションや行セット) を作成しているのにどんなフィールドにも代入していないし、他のメソッドにも渡していないし、戻り値にもしていません。
6529 このメソッドは、データベースリソース (たとえば、データベースコネクションや行セット) を作成していますが、どんなフィールドにも代入していないか、他のメソッドにも渡していないか、戻り値にもしていません。
65036530 そして、メソッドからのすべての経路でオブジェクトをクローズするように見えません。
65046531 メソッドからのすべての経路でデータベースリソースのクローズ失敗は良くない性能になるかもしれません。
65056532 データベースとの通信で問題があるアプリケーションの原因になる可能性があります。
65146541 <Details>
65156542 <![CDATA[
65166543 <p>
6517 このメソッドは、データベースリソース (たとえば、データベースコネクションや行セット) を作成しているのにどんなフィールドにも代入していないし、他のメソッドにも渡していないし、戻り値にもしていません。
6544 このメソッドは、データベースリソース (たとえば、データベースコネクションや行セット) を作成していますが、どんなフィールドにも代入していないか、他のメソッドにも渡していないか、戻り値にもしていません。
65186545 そして、メソッドからのすべての例外経路でオブジェクトをクローズするように見えません。
65196546 メソッドからのすべての経路でデータベースリソースのクローズ失敗は良くない性能になるかもしれません。
65206547 データベースとの通信で問題があるアプリケーションの原因になる可能性があります。
65316558 <p>
65326559 このメソッドは、ループの中で + を使用して <code>String</code> を構築していると思われます。
65336560 各々の繰り返しにおいて、<code>String</code> は <code>StringBuffer</code>/<code>StringBuilder</code> に変換、追加され、<code>String</code> へ変換されます。
6534 各々の繰り返しで文字列が再コピーされ増大すると、繰り返しの数で二次コストの原因になる可能性があります。
6561 各々の繰り返しで文字列が再コピーされ、増大すると繰り返しの数で二次コストの原因になる可能性があります。
65356562 </p>
65366563 <p>
65376564 明示的に、<code>StringBuffer</code> (または J2SE 5.0の <code>StringBuilder</code>) を使うことで、より良い性能を得られるかもしれません。
65646591 <![CDATA[
65656592 <p>
65666593 このメソッドは、Collection 派生クラスの </code>toArray</code> メソッドを使用して長さが0の配列の引数を渡しています。
6567 <code>myCollection.toArray(new Foo[myCollection.size()])</code> を使用する方がより効率的です。
6594 <code>myCollection.toArray(new Foo[myCollection.size()])</code> を使用するほうがより効率的です。
65686595 渡される配列がコレクションの要素のすべてを格納できるくらいの大きさなら、データが読み込まれて、そのまま返されます。
65696596 これは、結果として返す2番目の配列 (リフレクションによって) を作成する必要を回避します。
65706597 </p>
66306657 <![CDATA[
66316658 <p>
66326659 JUnit の TestCase クラスで、<code>suite</code> メソッドを実装しています。
6633 しかしながら、<code>suite</code> メソッドは
6634 </p>
6635 <pre>public static junit.framework.Test suite()</pre>
6660 しかしながら、<code>suite</code> メソッドは、
6661 </p>
6662 <blockquote><pre>
6663 public static junit.framework.Test suite()
6664 </pre></blockquote>
66366665 <p>か</p>
6637 <pre>public static junit.framework.TestSuite suite()</pre>
6666 <blockquote><pre>
6667 public static junit.framework.TestSuite suite()
6668 </pre></blockquote>
66386669 <p>
66396670 のどちらかを宣言する必要があります。
66406671 </p>
66546685 </Details>
66556686 </BugPattern>
66566687
6657
66586688 <BugPattern type="BOA_BADLY_OVERRIDDEN_ADAPTER">
66596689 <ShortDescription>スーパークラスの Adapter で実装されるメソッドを誤ってオーバーライドしているクラス</ShortDescription>
66606690 <LongDescription>クラス {0} は、スーパークラス の Adapter で実装されるメソッド {1} を誤ってオーバーライドしています。</LongDescription>
67386768 <![CDATA[
67396769 <p>
67406770 このメソッドは、配列と配列であると思われない参照を比較するために <code>.equals(Object o)</code> を呼び出しています。
6741 比較されているものが違う型なら、等しくないことが保証されているので、比較はほぼ間違いなく誤りです。
6771 比較されているものが違う型なら不等であることが保証されているので、比較はほぼ間違いなく誤りです。
67426772 たとえそれらが両方とも配列であるとしても、配列の <code>equals</code> メソッドは2つの配列が同じオブジェクトであると決定するだけです。
67436773 配列のコンテンツを比較するためには <code>java.util.Arrays.equals(Object[], Object[])</code> を使用してください。
67446774 </p>
67816811 <![CDATA[
67826812 <p>
67836813 このメソッドは、<code>interrupted</code> メソッドを呼び出すために <code>Thread.currentThread()</code> を呼び出しています。
6784 <code>interrupted</code> メソッドは、static メソッドです。<code>Thread.interrupted()</code> を使用する方が単純明解です。
6814 <code>interrupted</code> メソッドは static メソッドなので、<code>Thread.interrupted()</code> を使用するほうが単純明解です。
67856815 </p>
67866816 ]]>
67876817 </Details>
67946824 <![CDATA[
67956825 <p>
67966826 このメソッドは、カレントスレッドでない Thread オブジェクトであるように見える Thread オブジェクトで <code>Thread.interrupted()</code> を呼び出しています。
6797 <code>interrupted</code> メソッドは static で、作成者が意図したこととは異なるオブジェクトで呼び出されます。
6827 <code>interrupted</code> メソッドは static なので、作成者が意図したこととは異なるオブジェクトで呼び出されます。
67986828 </p>
67996829 ]]>
68006830 </Details>
68196849 <Details>
68206850 <![CDATA[
68216851 <p>
6822 この命令は、ローカル変数に値を代入しているのに値は読み出されないか以降の命令でも使われません。
6852 この命令は、ローカル変数に値を代入していますが、値は読み出されないか以降の命令でも使われません。
68236853 多くの場合、計算された値が決して使われないので、これは誤りを示します。
68246854 フィールドがローカル変数と同じ名前です。そうではなく、フィールドに代入するつもりでしたか?
68256855 </p>
68336863 <Details>
68346864 <![CDATA[
68356865 <p>
6836 この命令はローカル変数に値を代入しているのに値は読み出されないか以降の命令でも使われません。
6866 この命令はローカル変数に値を代入していますが、値は読み出されないか以降の命令でも使われません。
68376867 多くの場合、計算された値が決して使われないので、これは誤りを示します。
68386868 </p>
68396869 <p>
6840 Sun のjavac コンパイラが final なローカル変数のためにしばしば無効な格納を生成することに注意してください。
6870 Sun の javac コンパイラが final なローカル変数のためにしばしば無効な格納を生成することに注意してください。
68416871 FindBugs は、バイトコードベースのツールなので誤検出をなくす簡単な方法がありません。
68426872 </p>
68436873 ]]>
68486878 <ShortDescription>return 文に役に立たない代入がある</ShortDescription>
68496879 <LongDescription>{1} からの return 文に役に立たない代入があります。</LongDescription>
68506880 <Details>
6851 <![CDATA[
6881 <![CDATA[
68526882 <p>
68536883 この文は、return 文でローカル変数に代入をしています。この代入は効果がありません。
68546884 この文が正しいことを確かめてください。
68576887 </Details>
68586888 </BugPattern>
68596889
6890 <BugPattern type="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">
6891 <ShortDescription>return 文に役に立たないインクリメントがある</ShortDescription>
6892 <LongDescription>{1} からの return に役に立たないインクリメントがあります。</LongDescription>
6893 <Details>
6894 <![CDATA[
6895 <p>
6896 <code>return x++;</code> のような return 文があります。
6897 接頭辞インクリメント/デクリメントは 式の値に影響を与えないので、インクリメント/デクリメントは効果がありません。
6898 この文が正しいのか確かめてください。
6899 </p>
6900 ]]>
6901 </Details>
6902 </BugPattern>
6903
68606904 <BugPattern type="DLS_DEAD_STORE_OF_CLASS_LITERAL">
68616905 <ShortDescription>クラスリテラルの無効な代入</ShortDescription>
68626906 <LongDescription>{3}.class の無効な代入です。{1}</LongDescription>
68636907 <Details>
68646908 <![CDATA[
68656909 <p>
6866 この命令は変数にクラスリテラルを代入しているのに決して使われません。<br>
6910 この命令は変数にクラスリテラルを代入していますが、決して使われません。<br>
68676911 <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The behavior of this differs in Java 1.4 and in Java 5</a><br>
68686912 J2SE 1.4 およびそれ以前のバージョンでは、<code>Foo.class</code> への参照は <code>Foo</code> のためのスタティックイニシャライザがすでに実行されていないなら実行することを強制します。
6869 J2SE 5.0ではそうしません。
6870 </p>
6871 <p>
6872 より多くの詳細と例と J2SE 5.0のクラスの強制的な初期化の方法の提案は Sun の<a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">article on Java SE compatibility</a> を参照してください。
6913 J2SE 5.0 ではそうしません。
6914 </p>
6915 <p>
6916 より多くの詳細と例と J2SE 5.0 のクラスの強制的な初期化の方法の提案は Sun の <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">article on Java SE compatibility</a> を参照してください。
68736917 </p>
68746918 ]]>
68756919 </Details>
68816925 <Details>
68826926 <![CDATA[
68836927 <p>
6884 このコードはローカル変数に null を代入しているのに代入された値は読み出されていません。
6885 この代入はガベージコレクタを手伝うために導入されたのかもしれませんが、Java SE 6ではもはや必要とされないか有用ではありません。
6928 このコードはローカル変数に null を代入していますが代入された値は読み出されていません。
6929 この代入はガベージコレクタを手伝うために導入されたのかもしれませんが、Java SE 6 ではもはや必要とされないか有効ではありません。
68866930 </p>
68876931 ]]>
68886932 </Details>
68956939 <![CDATA[
68966940 <p>
68976941 このメソッドは、このクラスまたはスーパークラスのフィールドと同じ名前でローカル変数を定義しています。
6898 これはフィールドから初期化されていない値を読み出したり、初期化されていないフィールドをそのままにしておくメソッドの原因になるかもしれません。
6942 これはフィールドから初期化されていない値を読み出したり初期化されていないフィールドをそのままにしておくメソッドの原因になるかもしれません。
68996943 </p>
69006944 ]]>
69016945 </Details>
69216965 <![CDATA[
69226966 <p>
69236967 このメソッドは、keySet イテレータから取り出されたキーを使用して、マップエントリの値にアクセスしています。
6924 Map の entrySet イテレータを使用した方が <code>Map.get(key)</code> ルックアップを回避するのでより効率的です。
6968 Map の entrySet イテレータを使用したほうが <code>Map.get(key)</code> ルックアップを回避するのでより効率的です。
69256969 </p>
69266970 ]]>
69276971 </Details>
69466990 <Details>
69476991 <![CDATA[
69486992 <p>
6949 このメソッドは、例外オブジェクトをキャッチする try-catch ブロックを使用しているのに例外は try ブロックの中でスローされません。また、実行時例外は明示的にキャッチされません。
6993 このメソッドは、例外オブジェクトをキャッチする try-catch ブロックを使用していますが、例外は try ブロックの中でスローされません。また、実行時例外は明示的にキャッチされません。
69506994 それぞれの catch ブロックが同一である多くの例外型をキャッチすることの短縮形として <code>try { ... } catch (Exception e) { something }</code> を使用することが共通のバグパターンです。
69516995 しかし、この構文は誤って実行時例外も同様にキャッチするので、潜在的なバグを隠します。
69526996 </p>
69737017 <Details>
69747018 <![CDATA[
69757019 <p>
6976 このコードは、浮動小数点が特別な非数値と等価であるか確かめています (たとえば、<code>if (x == Double.NaN)</code>)。
7020 このコードは、浮動小数点が特別な非数値と等価であるか確かめています (たとえば <code>if (x == Double.NaN)</code>)。
69777021 しかしながら、<code>NaN</code> の特別な意味のため、値は <code>NaN</code> と等価ではありません。
69787022 したがって、<code>x == Double.NaN</code> は常に false と評価します。
6979 <code>x</code> という値が特別な非数値であるかどうか確かめるためには <code>Double.isNaN(x)</code> を使用します (あるいは、<code>x</code> が浮動小数点精度であるなら <code>Float.isNaN(x)</code>)。
7023 <code>x</code> という値が特別な非数値であるかどうか確かめるためには <code>Double.isNaN(x)</code> を使用します (あるいは <code>x</code> が浮動小数点精度であるなら <code>Float.isNaN(x)</code>)。
69807024 </p>
69817025 ]]>
69827026 </Details>
69897033 <![CDATA[
69907034 <p>
69917035 この演算は、等価性のために2つの浮動小数点値を比較しています。
6992 浮動小数点の計算は丸めを伴うかもしれないので、計算された float と double の値は正確ではないかもしれません。
7036 浮動小数点の計算は丸めを伴うかもしれないので計算された float と double の値は正確ではないかもしれません。
69937037 通貨のような正確でなければならない値のために、<code>BigDecimal</code> のような固定精度型を使うことを検討してください。
6994 正確である必要がない値のために、いくつかの範囲の中で等価性のために比較することを検討してください。
7038 正確である必要がない値のためにいくつかの範囲の中で等価性のために比較することを検討してください。
69957039 たとえば、<code>if (Math.abs(x - y) &lt; .0000001)</code>。<br>
69967040 詳細は Java 言語仕様4.2.4を参照してください。
69977041 </p>
70057049 <Details>
70067050 <![CDATA[
70077051 <p>
7008 このメソッドは、定数値で java.lang.Math の static メソッドを呼び出しています。
7009 このメソッドの結果は、静的に確定している可能性があり、より高速で、ときには定数を使用する方がより正確です。<br>
7010 検出されるメソッドは、以下の通りです。
7052 このメソッドは、定数値で <code>java.lang.Math</code> の static メソッドを呼び出しています。
7053 このメソッドの結果は、静的に確定している可能性があり、より高速で、ときには定数を使用するほうがより正確です。<br>
7054 検出されるメソッドは、以下のとおりです。
70117055 </p>
70127056 <table>
70137057 <tr>
71227166 <![CDATA[
71237167 <p>
71247168 Struts Action クラスを拡張したクラスで、インスタンス変数を使用しています。
7125 Struts Action クラスの1つのインスタンスだけが Struts フレームワークによって作成され、マルチスレッドによって使われるので、このパラダイムは極めて問題があり推奨できません。
7169 Struts Action クラスの1つのインスタンスだけが Struts フレームワークによって作成され、マルチスレッドによって使われるので、このパラダイムは極めて問題があり、推奨できません。
71267170 ローカル変数を使うことだけを検討してください。
71277171 モニタを除いて書き込まれるインスタンスフィールドだけが報告されます。
71287172 </p>
71377181 <![CDATA[
71387182 <p>
71397183 Servletクラスを拡張したクラスで、インスタンス変数を使用しています。
7140 Servlet クラスの1つのインスタンスだけが Java EE フレームワークによって作成され、マルチスレッドによって使われるので、このパラダイムは極めて問題があり推奨できません。
7184 Servlet クラスの1つのインスタンスだけが Java EE フレームワークによって作成され、マルチスレッドによって使われるので、このパラダイムは極めて問題があり、推奨できません。
71417185 ローカル変数を使うことだけを検討してください。
71427186 </p>
71437187 ]]>
71507194 <Details>
71517195 <![CDATA[
71527196 <p>
7153 このクラスは、それ自身 (this 参照) で、 <code>wait</code> メソッド、<code>notify</code> メソッド、<code>notifyAll</code> メソッド とともに同期化しています。
7197 このクラスは、自分自身 (this 参照) で、 <code>wait</code> メソッド、<code>notify</code> メソッド、<code>notifyAll</code> メソッド とともに同期化しています。
71547198 このクラスを使用するクライアントクラスは、同期化のためのオブジェクトとしてこのクラスのインスタンスをさらに使用するかもしれません。
71557199 2つのクラスが同期化のために同じオブジェクトを使用するので、マルチスレッドの正確性は疑わしいです。
71567200 同期化するべきでもないし、公開参照でセマフォメソッドも呼び出すべきではありません。
71737217 </pre></blockquote>
71747218 <p>
71757219 long を使用して乗算をすれば、結果がオーバーフローするという可能性を回避できます。<br>
7176 たとえば、以下のように修正できます。
7220 たとえば以下のように修正できます。
71777221 </p>
71787222 <blockquote><pre>
71797223 long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
72077251 32ビット値は、64ビットに変換されて、絶対時間値を表すために使用されるとき、1969年12月と1970年1月の日付しか表せません。
72087252 </p>
72097253 <p>
7210 上記のメソッドのための正しい実装は、以下の通りです。
7254 上記のメソッドのための正しい実装は、以下のとおりです。
72117255 </p>
72127256 <blockquote><pre>
72137257 // 失敗、2037年後の日付
72147258 Date getDate(int seconds) { return new Date(seconds * 1000L); }
72157259
7216 // より良い, すべての日付で動作する
7260 // より良い、すべての日付で動作する
72177261 Date getDate(long seconds) { return new Date(seconds * 1000); }
72187262 </pre></blockquote>
72197263 ]]>
72267270 <Details>
72277271 <![CDATA[
72287272 <p>
7229 このコードは、整数値を float 精度浮動小数点に変換してからその結果を <code>Math.round()</code> に渡して引数に最も近い int/long を返します。
7273 このコードは、整数値を float 精度浮動小数点に変換してから、その結果を <code>Math.round()</code> に渡して引数に最も近い int/long を返します。
72307274 整数を float に変換すると小数部がない数値が得られるので、この演算は常にノーオペレーションになります。
72317275 <code>Math.round()</code>に渡される値を生成した演算が浮動小数点演算を使用して実行することを意図した可能性が高いです。
72327276 </p>
7233
72347277 ]]>
72357278 </Details>
72367279 </BugPattern>
72417284 <Details>
72427285 <![CDATA[
72437286 <p>
7244 このコードは、整数値 (たとえば、int や long) を倍精度浮動小数点に変換してからその結果を <code>Math.ceil()</code> に渡しています。
7287 このコードは、整数値 (たとえば、int や long) を倍精度浮動小数点に変換してから、その結果を <code>Math.ceil()</code> に渡しています。
72457288 整数を double に変換すると小数部がない数値が得られるので、この演算は常にノーオペレーションになります。
72467289 <code>Math.ceil()</code>に渡される値を生成した演算が倍精度浮動小数点演算を使用して実行することを意図した可能性が高いです。
7290 </p>
72477291 ]]>
72487292 </Details>
72497293 </BugPattern>
73877431 <![CDATA[
73887432 <p>
73897433 Java の printf 書式文字列と引数のリストを期待するメソッドが呼び出されています。
7390 しかしながら、書式文字列にはどんな書式指示子 (たとえば、%s) もなくて、メッセージフォーマットの要素 (たとえば、{0}) があります。
7434 しかしながら、書式文字列にはどんな書式指示子 (たとえば、%s) も含まないで、メッセージフォーマットの要素 (たとえば、{0}) を含んでいます。
73917435 printf スタイルの書式文字列が必要なときに、MessageFormat の文字列を与えている可能性が高いです。
73927436 実行時に、すべての引数は無視され、書式文字列は正確にフォーマットされずに返されます。
73937437 </p>
74777521 <Details>
74787522 <![CDATA[
74797523 <p>
7480 このコードは、Collection を抽象コレクションにキャストしています (たとえば、<code>List</code>、<code>Set</code>、<code>Map</code>)。
7524 このコードは、Collection を抽象コレクションにキャストしています (たとえば <code>List</code>、<code>Set</code>、<code>Map</code>)。
74817525 オブジェクトがキャストする型であると保証されることを確認してください。
74827526 必要とするコレクションの反復処理ができるなら Set または List にキャストする必要はありません。
74837527 </p>
75197563 <![CDATA[
75207564 <p>
75217565 このキャストは、常に ClassCastException をスローします。
7522 解析は、キャストしている値の正確な型がわかっていると信じています。
7566 解析はキャストしている値の正確な型がわかっていると信じています。
75237567 そして、サブタイプへダウンキャストしようとする試みは、ClassCastException のスローによって常に失敗します。
75247568 </p>
75257569 ]]>
75987642 <Details>
75997643 <![CDATA[
76007644 <p>
7601 この instanceof は常に true を返します (テストしている値が null でない限り)。
7645 この instanceof は常に true を返します (テストしている値が null でないかぎり)。
76027646 これは安全で、誤解や論理エラーを指摘していないことを確認してください。
7603 本当に null なのか値をテストしたいなら、たぶん、instanceof ではなく null テストをした方が良く、より明確になります。
7647 本当に null なのか値をテストしたいなら、多分、instanceof ではなく null テストをしたほうが良く、より明確になります。
76047648 </p>
76057649 ]]>
76067650 </Details>
76127656 <Details>
76137657 <![CDATA[
76147658 <p>
7615 このキャストはチェックされていません。
7616 すべての型のインスタンスがキャストした型にキャストできるというわけではありません。
7659 このキャストはチェックされていません。すべての型のインスタンスがキャストした型にキャストできるというわけではありません。
76177660 プログラムのロジックがこのキャストが失敗しないことを確実に確認してください。
76187661 </p>
76197662 ]]>
76417684 <![CDATA[
76427685 <p>
76437686 このコードは抽象コレクション (たとえば、Collection、List、Set) を特定の具象実装 (たとえば、ArrayList、HashSet) にキャストしています。
7644 これは正しくないかもしれません。
7645 そして、将来の時点で他の具象実装への切り替えをとても困難にするので、脆弱なコードになるかもしれません。
7646 そうするために特別な理由がない限り抽象コレクションクラスを使用してください。
7687 これは正しくないかもしれません。そして、将来の時点で他の具象実装への切り替えをとても困難にするので、脆弱なコードになるかもしれません。
7688 そうするために特別な理由がないかぎり抽象コレクションクラスを使用してください。
76477689 </p>
76487690 ]]>
76497691 </Details>
76507692 </BugPattern>
76517693
76527694 <BugPattern type="RE_POSSIBLE_UNINTENDED_PATTERN">
7653 <ShortDescription>正規表現のために使われている "."</ShortDescription>
7654 <LongDescription>正規表現で "." を使用しています。{1}</LongDescription>
7655 <Details>
7656 <![CDATA[
7657 <p>
7658 String メソッドが呼び出されていて、"." が引数として正規表現を取るパラメータに渡されています。
7695 <ShortDescription>正規表現のために使われている "." または "|"</ShortDescription>
7696 <LongDescription>正規表現で "." または "|" を使用しています。{1}</LongDescription>
7697 <Details>
7698 <![CDATA[
7699 <p>
7700 String 機能が呼び出されていて、"." または "|" が引数として正規表現を取るパラメータに渡されています。
76597701 これは、意図したことですか?
7660 たとえば、<code>s.replaceAll(".", "/")</code> はあらゆる文字が "/" 文字に置き換えられた文字列を返します。
7661 また、<code>s.split(".")</code> は常に長さが0の String の配列を返します。
7662 </p>
7702 たとえば
7703 </p>
7704 <ul>
7705 <li><code>s.replaceAll(".", "/")</code> は、すべての文字が '/' 文字に置換された String を返す</li>
7706 <li><code>s.split(".")</code> は、常に長さが0の String 配列を返す</li>
7707 <li><code>"ab|cd".replaceAll("|", "/")</code> は、<code>"/a/b/|/c/d/"</code> を返す</li>
7708 <li><code>"ab|cd".split("|")</code> は、6個の要素がある配列を返す: <code>[, a, b, |, c, d]</code></li>
7709 </ul>
76637710 ]]>
76647711 </Details>
76657712 </BugPattern>
76837730 <Details>
76847731 <![CDATA[
76857732 <p>
7686 このコードは、正規表現が必要である <code>File.separator</code> を使用しています。
7733 このコードは、正規表現が必要とされる場所で、<code>File.separator</code> を使用しています。
76877734 これは <code>File.separator</code> がバックスラッシュである Windows プラットホームでは失敗します。
76887735 バックスラッシュは正規表現ではエスケープ文字として解釈されます。
76897736 その他の選択肢としては、<code>File.separator</code> の代わりに <code>File.separatorChar=='\\' ? "\\\\" : File.separator</code> を使用できます。
77047751 ]]>
77057752 </Details>
77067753 </BugPattern>
7754
77077755 <BugPattern type="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">
77087756 <ShortDescription>符号なし右シフトを short/byte にキャストしている</ShortDescription>
77097757 <LongDescription>符号なし右シフトを short/byte にキャストしています。{1}</LongDescription>
77187766 </BugPattern>
77197767
77207768 <BugPattern type="ICAST_BAD_SHIFT_AMOUNT">
7721 <ShortDescription>32ビット int の0から31の範囲を超えた量によるシフト</ShortDescription>
7769 <ShortDescription>32ビット int の-31から31の範囲を超えた量によるシフト</ShortDescription>
77227770 <LongDescription>32ビット int を {2} ビットでシフトしました。{1}</LongDescription>
77237771 <Details>
77247772 <![CDATA[
77257773 <p>
7726 このコードは、32ビット int の0から31の範囲を超えた量でシフトを実行しています。
7774 このコードは、32ビット int の-31から31の範囲を超えた量でシフトを実行しています。
77277775 これの効果は、どのくらいシフトするのかを決めるために整数値の下位5ビット (32で割った余り) を使うことです (たとえば、40ビットでシフトすることは8ビットでシフトすることと同じで、32ビットでシフトすることは0ビットでシフトすることと同じです)。
7728 これはおそらく、期待されたことではありません、それは少なくとも紛らわしいです。
7776 これは、おそらく期待されたことではなく、少なくとも紛らわしいです。
77297777 </p>
77307778 ]]>
77317779 </Details>
77877835 </Details>
77887836 </BugPattern>
77897837
7790
77917838 <BugPattern type="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">
77927839 <ShortDescription>平均の計算はオーバーフローする可能性がある</ShortDescription>
77937840 <LongDescription>平均の計算は、オーバーフローする可能性があります。{1}</LongDescription>
77947841 <Details>
77957842 <![CDATA[
77967843 <p>
7797 このコードは、除算か符号付き右シフトを使用して2つの整数の平均を計算して、その結果を配列の添字として使用しています。
7844 このコードは、除算か符号付き右シフトを使用して2つの整数の平均を計算して、結果を配列の添字として使用しています。
77987845 平均値が非常に大きいならオーバーフローする可能性があります (結果として負の平均の計算になる)。
77997846 結果が負でないことを意図していたなら、その代わりに符号なし右シフトを使用できます。
78007847 つまり、<code>(low+high)/2</code> ではなく <code>(low+high) &gt;&gt;&gt; 1</code> を使用してください。
78017848 </p>
78027849 <p>
78037850 このバグは、二分探索とマージソートの多くの以前の実装で存在します。
7804 Martin Buchholz が <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6412541">JDK ライブラリでバグを発見し修正しています</a>。
7851 Martin Buchholz が <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6412541">JDK ライブラリでバグを発見し、修正しています</a>。
78057852 Joshua Bloch が <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">バグパターンとして公表しました</a>。
78067853 </p>
78077854 ]]>
78277874 <Details>
78287875 <![CDATA[
78297876 <p>
7830 このコードは、ハードコードされた絶対パス名を使用して File オブジェクトを構築しています (たとえば、<code>new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");</code>)。
7877 このコードは、ハードコードされた絶対パス名を使用して File オブジェクトを構築しています (たとえば <code>new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");</code>)。
78317878 </p>
78327879 ]]>
78337880 </Details>
78917938 <Details>
78927939 <![CDATA[
78937940 <p>
7894 このメソッドは、条件分岐の2つの分岐を実装するために同じコードを使用しています。
7895 これがコーディングミスではないことを確認してください。
7941 このメソッドは、条件分岐の2つの分岐を実装するために同じコードを使用しています。これがコーディングミスではないことを確認してください。
78967942 </p>
78977943 ]]>
78987944 </Details>
79057951 <![CDATA[
79067952 <p>
79077953 このメソッドは、switch 文の2つの case を実装するために同じコードを使用しています。
7908 重複コードの case かもしれないし、コーディングミスかもしれません。
7954 複製コードの case かもしれないしコーディングミスかもしれません。
79097955 </p>
79107956 ]]>
79117957 </Details>
79197965 <p>
79207966 この内部クラスのメソッドは、所有クラスの private メンバー変数への読み書きか、所有クラスの private メソッドを呼び出しています。
79217967 コンパイラはこの private メンバーにアクセスするために特別なメソッドを生成しなければなりないので、効率を悪化させる原因になります。
7922 メンバー変数またはメソッドの保護を緩和することは、コンパイラが通常のアクセスとして扱うのを許可します。
7968 メンバー変数またはメソッドの保護を緩和することは、コンパイラが一般にのアクセスとして扱うのを許可します。
79237969 </p>
79247970 ]]>
79257971 </Details>
80178063 <![CDATA[
80188064 <p>
80198065 総称型パラメータからの特定の型が予想される Object 型をコンパイルするとき、総称型コレクションメソッドへの呼び出しは引数を渡します。
8020 したがって、標準の Java 型システムも静的解析もパラメータとして渡されているオブジェクトが適切な型かどうかに関する有用な情報を提供できません。
8066 したがって、標準の Java 型システムも静的解析もパラメータとして渡されているオブジェクトが適切な型かどうかに関する有効な情報を提供できません。
80218067 </p>
80228068 ]]>
80238069 </Details>
80318077 <p>
80328078 総称型コレクションメソッドへの呼び出しにコレクションのパラメータとは互換性のないクラスの引数があります (すなわち、引数の型は総称型引数に対応するスーパタイプでもサブタイプでもありません)。
80338079 したがって、コレクションにはここで使用されたメソッド引数と等価であるどんなオブジェクトも含まれていません。
8034 たぶん、間違った値がメソッドに渡されています。
8035 通常、2つの無関係なクラスのインスタンスは等価ではありません。
8080 多分間違った値がメソッドに渡されています。
8081 一般に、2つの無関係なクラスのインスタンスは等価ではありません。
80368082 たとえば、<code>Foo</code> と <code>Bar</code> クラスがサブタイプによって関係がないなら、<code>Foo</code> のインスタンスは <code>Bar</code> のインスタンスと等価のはずがありません。
8037 その他の問題で、対称的ではない <code>equals</code> メソッドになる可能性が高いです。
8083 その他の問題で対称的ではない <code>equals</code> メソッドになる可能性が高いです。
80388084 たとえば、<code>Foo</code> が <code>String</code> と等価であるように <code>Foo</code> クラスを定義するなら、<code>String</code> は <code>String</code> だけと等価であるので、<code>equals</code> メソッドは対称的ではありません。
80398085 </p>
80408086 <p>
80418087 まれに、非対称 <code>equals</code> メソッドを定義して、まだ、何とかそれらのコードを機能させています。
8042 APIのどれも文書化していないし、保証もしていないが通常の場合は <code>Collection&lt;String&gt;</code> に <code>Foo</code> があるかどうか調べたいなら、
8088 APIのどれも文書化していないか、保証もしていないが、<code>Collection&lt;String&gt;</code> に <code>Foo</code> があるかどうか調べたいなら、
80438089 引数の <code>equals</code> メソッド (たとえば、<code>Foo</code>クラスの <code>equals</code> メソッド) を使用して等価性をチェックします。
80448090 </p>
80458091 ]]>
80708116 どんなコレクション <code>c</code> も <code>c.containsAll(c)</code> を呼び出すことは常に true であるべきです。
80718117 そして、<code>c.retainAll(c)</code> は効果があるはずがありません。
80728118 </p>
8073 ]]>
8119 ]]>
80748120 </Details>
80758121 </BugPattern>
80768122
80828128 <p>
80838129 このクラスは、Iterator と Map.Entry で基底 Map のビューを返すことを許可された両方の entrySet メソッドがあります。
80848130 この巧妙なアイデアは、Map 実装で使用されましたが、厄介なコーディング間違いの可能性を取り込みました。
8085 Map <code>m</code> が entrySet のためのそのような反復子を返すならば、<code>c.addAll(m.entrySet())</code> はひどく間違っていくでしょう。
8131 Map <code>m</code> が entrySet のためのそのような反復子を返すならば、<code>c.addAll(m.entrySet())</code> はひどく間違っているでしょう。
80868132 OpenJDK 1.7 の すべての Map 実装はこれを回避するために書き直されました。
80878133 </p>
80888134 ]]>
80988144 entrySet メソッドは、一つの Entry オブジェクトを再利用し、反復中に返される基底 Map のビューを返すことが許可されています。
80998145 Java 1.6 の時点で、IdentityHashMap と EnumMap の両方がそうしました。
81008146 そのような Map を通して繰り返すとき、エントリ値は次の繰り返しへ進むまでが有効です。
8101 たとえば、addAll メソッドにそのような entrySet を渡そうとすると、物事はひどく間違っていくでしょう。
8147 たとえば、addAll メソッドにそのような entrySet を渡そうと試みるのは、ひどく間違っているでしょう。
81028148 </p>
81038149 ]]>
81048150 </Details>
81258171 <p>
81268172 たとえ JavaDoc にそれに関する手がかりがないとしても、Calendar はマルチスレッドでの使用は本質的に安全でありません。
81278173 正しい同期化をしないでスレッド境界の向こうで1つのインスタンスを共有することは、アプリケーションの誤動作になります。
8128 JDK 5.0に比べて JDK 1.4 の方が問題が表面化するように思われ、おそらく sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate() の ArrayIndexOutOfBoundsExceptions や IndexOutOfBoundsExceptions がランダムに発生します。
8174 JDK 5.0に比べて JDK 1.4 のほうが問題が表面化するように思われ、おそらく sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate() の ArrayIndexOutOfBoundsExceptions や IndexOutOfBoundsExceptions がランダムに発生します。
81298175 直列化問題も経験するかもしれません。インスタンスフィールドを使うことを推奨します。<br>
81308176 詳細については、<a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a> や <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a> を参照してください。
81318177 </p>
81568202 <p>
81578203 JavaDoc に書かれているように、DateFormat はマルチスレッドでの使用は本質的に安全ではありません。
81588204 正しい同期化をしないでスレッド境界の向こうで1つのインスタンスを共有することは、アプリケーションの誤動作になります。
8159 JDK 5.0に比べて JDK 1.4 の方が問題が表面化するように思われ、おそらく sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate() の ArrayIndexOutOfBoundsExceptions や IndexOutOfBoundsExceptions がランダムに発生します。
8205 JDK 5.0に比べて JDK 1.4 のほうが問題が表面化するように思われ、おそらく sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate() の ArrayIndexOutOfBoundsExceptions や IndexOutOfBoundsExceptions がランダムに発生します。
81608206 直列化問題も経験するかもしれません。インスタンスフィールドを使うことを推奨します。<br>
81618207 詳細については、<a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579">Sun Bug #6231579</a> や <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug #6178997</a> を参照してください。
8208 </p>
81628209 ]]>
81638210 </Details>
81648211 </BugPattern>
81828229 <ShortDescription>互換性のない型修飾子による比較値</ShortDescription>
81838230 <LongDescription>型修飾子 {2.simpleName} でアノテートされた値がその修飾子がない値と等価性のために比較されています。</LongDescription>
81848231 <Details>
8185 <![CDATA[
8232 <![CDATA[
81868233 <p>
81878234 型修飾子アノテーションを指定した値がその修飾子のない値と比較しています。
81888235 </p>
81988245 return value1.equals(value2);
81998246 }
82008247 </pre></blockquote>
8201 ]]>
8248 ]]>
82028249 </Details>
82038250 </BugPattern>
82048251
82088255 <Details>
82098256 <![CDATA[
82108257 <p>
8211 型修飾子アノテーションを指定した値がその修飾子を付けてはならない値を必要とする場所で使われています。
8258 型修飾子であのてーとされた値がその修飾子を付けてはならない値を必要とする場所で使われています。
82128259 </p>
82138260 <p>
82148261 より正確に、when=ALWAYS を指定した型修飾子でアノテートされた値が到達することが保証されているか同じ型修飾子で when=NEVER を指定する場所で使用しています。
82268273 </Details>
82278274 </BugPattern>
82288275
8276 <BugPattern type="TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">
8277 <ShortDescription>型修飾子がない値が修飾子を必要とする場所で使われている</ShortDescription>
8278 <LongDescription>{2.simpleName} アノテーションを必要とする場所で型修飾子がない値が使われています。</LongDescription>
8279 <Details>
8280 <![CDATA[
8281 <p>
8282 値が型修飾子アノテーションを必要とする方法で使われています。型修飾子は厳密なので、ツールは適切なアノテーションを指定していない値を拒絶します。
8283 </p>
8284 <p>
8285 厳密なアノテーションを指定しているので値を型変換します。戻り値が厳密なアノテーションでアノテートされる同一性機能を定義してください。
8286 これは、厳密な型修飾子アノテーションで非アノテート値を値に変える唯一の方法です。
8287 </p>
8288 ]]>
8289 </Details>
8290 </BugPattern>
8291
82298292 <BugPattern type="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">
8230 <ShortDescription>型修飾子でアノテーションされていない値がその修飾子が付けられた値を必要とする場所で使われている</ShortDescription>
8293 <ShortDescription>型修飾子でアノテートされていない値がその修飾子が付けられた値を必要とする場所で使われている</ShortDescription>
82318294 <LongDescription>型修飾子 {2.simpleName} でアノテートされていない値がその修飾子が付けられた値を必要とする場所で使われています。</LongDescription>
82328295 <Details>
82338296 <![CDATA[
82348297 <p>
8235 型修飾子アノテーションを指定していない値がその修飾子が付けられた値を必要とする場所で使われています。
8298 型修飾子でアノテートされていない値がその修飾子が付けられた値を必要とする場所で使われています。
82368299 </p>
82378300 <p>
82388301 より正確に、when=NEVER を指定した型修飾子でアノテートされた値が同じ型修飾子で when=ALWAYS を指定する場所で使用しています。
8239 </p>
8302 </p>
82408303 ]]>
82418304 </Details>
82428305 </BugPattern>
82488311 <![CDATA[
82498312 <p>
82508313 型修飾子によって示された値のインスタンスではない可能性としてアノテートされた値です。
8251 値はその型修飾子によって示された値を必要とする方法で使われることが保証されています。
8314 値は、その型修飾子によって示された値を必要とする方法で使われることが保証されています。
82528315 </p>
82538316 ]]>
82548317 </Details>
82618324 <![CDATA[
82628325 <p>
82638326 型修飾子によって示された値のインスタンスである可能性としてアノテートされた値です。
8264 値はその型修飾子によって示された値を禁止する方法で使われることが保証されています。
8327 値は、その型修飾子によって示された値を禁止する方法で使われることが保証されています。
82658328 </p>
82668329 ]]>
82678330 </Details>
82908353 値は、常に型修飾子によって示された値であることを必要とする方法で使われています。
82918354 しかし、値はどこでその型修飾子が必要なのかわからないと述べている明示的なアノテーションがあります。
82928355 使い方かアノテーションのどちらかが間違っています。
8293 </p>
8294 ]]>
8356 </p>
8357 ]]>
82958358 </Details>
82968359 </BugPattern>
82978360
83218384 <p>
83228385 このインスタンスメソッドは、<code>this.getClass()</code> で同期化しています。
83238386 このクラスがサブクラス化されるなら、サブクラスはおそらく意図したことではないサブクラスのためにクラスオブジェクトで同期化します。
8324 たとえば、java.awt.Label の以下のコードを検討してください。
8387 たとえば、<code>java.awt.Label</code> の以下のコードを検討してください。
83258388 </p>
83268389 <blockquote><pre>
83278390 private static final String base = "label";
83358398 </pre></blockquote>
83368399 <p>
83378400 <code>Label</code> のサブクラスは同じサブクラスで同期化しません。データレースを生じさせます。
8338 その代わりに、このコードは、<code>Label.class</code> で同期化するべきです。
8401 代わりに、このコードは、<code>Label.class</code> で同期化するべきです。
83398402 </p>
83408403 <blockquote><pre>
83418404 private static final String base = "label";
83638426 このメソッドは、ストリーム、データベースオブジェクト、または明示的にクリーンアップ操作を必要としている他のリソースのクリーンアップ (クローズする、片付ける) に失敗するかもしれません。
83648427 </p>
83658428 <p>
8366 通常、メソッドがストリープや他のリソースを開いたなら、メソッドはストリームやリソースがメソッドが戻る前にクリーンアップされることを確認するために、try/finally ブロックを使用するべきです。
8429 一般に、メソッドがストリープや他のリソースを開いたなら、メソッドはストリームやリソースがメソッドが戻る前にクリーンアップされることを確認するために、try/finally ブロックを使用するべきです。
83678430 </p>
83688431 <p>
83698432 このバグパターンは、OS_OPEN_STREAM と ODR_OPEN_DATABASE_RESOURCE と基本的に同じですが異なる (そして、うまくいけばより良い) 静的解析技術に基づいています。
8370 私たちは、このバグパターンの有用性についてのフィードバックを得ることに関心があります。
8433 私たちは、このバグパターンの有効性についてのフィードバックを得ることに関心があります。
83718434 どちらかの方法でフィードバックを送ってください。
83728435 </p>
83738436 <ul>
8374 <li>send email to findbugs@cs.umd.edu</li>
8375 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
8437 <li>send email to findbugs@cs.umd.edu</li>
8438 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
83768439 </ul>
83778440 <p>
83788441 特に、このバグパターンの誤検出抑制探索法は詳細にわたって調整されていないので、誤検出についてのレポートは我々の助けになります。
83938456 このメソッドは、ストリーム、データベースオブジェクト、または明示的にクリーンアップ操作を必要としている他のリソースのクリーンアップ (クローズする、片付ける) に失敗するかもしれません。
83948457 </p>
83958458 <p>
8396 通常、メソッドがストリープや他のリソースを開いたなら、メソッドはストリームやリソースがメソッドが戻る前にクリーンアップされることを確認するために、try/finally ブロックを使用するべきです。
8459 一般に、メソッドがストリープや他のリソースを開いたなら、メソッドはストリームやリソースがメソッドが戻る前にクリーンアップされることを確認するために、try/finally ブロックを使用するべきです。
83978460 </p>
83988461 <p>
83998462 このバグパターンは、OS_OPEN_STREAM と ODR_OPEN_DATABASE_RESOURCE と基本的に同じですが異なる (そして、うまくいけばより良い) 静的解析技術に基づいています。
8400 私たちは、このバグパターンの有用性についてのフィードバックを得ることに関心があります。
8463 私たちは、このバグパターンの有効性についてのフィードバックを得ることに関心があります。
84018464 どちらかの方法でフィードバックを送ってください。
84028465 </p>
84038466 <ul>
8404 <li>send email to findbugs@cs.umd.edu</li>
8405 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
8467 <li>send email to findbugs@cs.umd.edu</li>
8468 <li>file a bug report: <a href="http://findbugs.sourceforge.net/reportingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li>
84068469 </ul>
84078470 <p>
84088471 特に、このバグパターンの誤検出抑制探索法は詳細にわたって調整されていないので、誤検出についてのレポートは我々の助けになります。
84208483 <Details>
84218484 <![CDATA[
84228485 <p>
8423 FindBugs は、@NoWarning でアノテートされたことにより、予期しない/望ましくない警告を生成しました。
8486 FindBugs は、@NoWarning でアノテートされたことにより予期しない/望ましくない警告を生成しました。
84248487 </p>
84258488 ]]>
84268489 </Details>
84328495 <Details>
84338496 <![CDATA[
84348497 <p>
8435 FindBugs は、@ExpectedWarning でアノテートされたことにより、予期した/望ましい警告が生成されませんでした。
8498 FindBugs は、@ExpectedWarning でアノテートされたことにより予期した/望ましい警告が生成されませんでした。
84368499 </p>
84378500 ]]>
84388501 </Details>
84448507 <Details>
84458508 <![CDATA[
84468509 <p>
8447 <code>putIfAbsent</code> メソッドは、通常1つの値が与えられたキー (非存在が成功するかどうかの第一の値) と関連することを確認するために使われます。
8510 <code>putIfAbsent</code> メソッドは、一般に1つの値が与えられたキー (非存在が成功するかどうかの第一の値) と関連することを確認するために使われます。
84488511 戻り値を無視して中で渡される値への参照を保持するなら、マップのキーと関連する1つではない値を保持する危険性を冒します。
84498512 どれを使用するかが重要であり、マップに格納できないものを使用すると、プログラムは誤った振る舞いをします。
84508513 </p>
84588521 <Details>
84598522 <![CDATA[
84608523 <p>
8461 OpenJDK は、潜在的非互換性を取り入れました。特に、java.util.logging.Logger は振る舞いが変更されています。
8524 OpenJDK は、潜在的非互換性を取り入れました。特に、<code>java.util.logging.Logger</code> は振る舞いが変更されています。
84628525 強参照を使用する代わりに、現在、内部的に弱参照を使用しています。
84638526 それは理にかなった変更ですが、残念ながらいくつかのコードは古い振る舞いに依存しています。
84648527 ロガーの構成を変更するとき、ロガーへの参照を捨てます。
8465 つまり、ガベージコレクタはそのメモリを回収できます。それは、ロガーの構成が失われることを意味します。
8528 つまり、ガベージコレクタはそのメモリを回収できます。それは、ロガーの構成が失われることを意味します。<br>
84668529 たとえば、以下を検討してください。
84678530 </p>
84688531 <blockquote><pre>
84758538 <p>
84768539 ロガーの参照は、メソッドの終わり (メソッドは脱出しません) で失われるので、
84778540 <code>initLogging</code> の呼び出しの後でガベージコレクションの循環があるなら、ロガー構成は失われます (なぜなら Logger は弱参照を保持するだけなので)。
8478 .</p>
8541 </p>
84798542 <blockquote><pre>
84808543 public static void main(String[] args) throws Exception {
84818544 initLogging(); // ファイルハンドラーをロガーに追加する
85098572 <Details>
85108573 <![CDATA[
85118574 <p>
8512 バイトから String (またはStringからバイト) への変換で、デフォルトプラットホームエンコーディングが適切であると仮定するメソッドの呼び出しを発見しました。
8575 byte から String (または String から byte) への変換で、デフォルトプラットホームエンコーディングが適切であると仮定するメソッドの呼び出しを発見しました。
85138576 これは、アプリケーションの振る舞いがプラットホーム間で異なる原因となります。代替 API を使用して、明示的に文字セット名または Charset オブジェクトを指定して下さい。
85148577 </p>
85158578 ]]>
85168579 </Details>
8580 </BugPattern>
8581
8582 <BugPattern type="NP_METHOD_PARAMETER_RELAXING_ANNOTATION">
8583 <ShortDescription>メソッドはパラメータで nullness アノテーションを強化する</ShortDescription>
8584 <LongDescription>メソッド {1} は、パラメータで祖先メソッドの要件を緩和している nullness アノテーションをオーバライドしています。</LongDescription>
8585 <Details>
8586 <![CDATA[
8587 <p>
8588 メソッドは、オーバライドするメソッドの規約を常に実装するべきです。
8589 したがって、メソッドが @Nullable としてマークされるパラメーターを取るならば、サブクラスでパラメーターを @Nonnull にしてメソッドをオーバーライドするべきでありません。
8590 そうするこによって、メソッドが null パラメーターを扱うべきである規約に違反します。
8591 </p>
8592 ]]>
8593 </Details>
8594 </BugPattern>
8595
8596 <BugPattern type="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">
8597 <ShortDescription>メソッドはパラメータで nullness アノテーションを強化する</ShortDescription>
8598 <LongDescription>メソッド {1} は、互換性のない方法でパラメーター {2} の nullness アノテーションをオーバーライドしています。</LongDescription>
8599 <Details>
8600 <![CDATA[
8601 <p>
8602 メソッドは、オーバライドするメソッドの規約を常に実装するべきです。
8603 したがって、メソッドが @Nullable としてマークされるパラメーターを取るならば、サブクラスでパラメーターを @Nonnull にしてメソッドをオーバーライドするべきでありません。
8604 そうするこによって、メソッドが null パラメーターを扱うべきである規約に違反します。
8605 </p>
8606 ]]>
8607 </Details>
8608 </BugPattern>
8609
8610 <BugPattern type="NP_METHOD_RETURN_RELAXING_ANNOTATION">
8611 <ShortDescription>メソッドは戻り値で nullness アノテーションを緩和させる</ShortDescription>
8612 <LongDescription>メソッド {1} は、互換性のない方法で戻り値の nullness アノテーションをオーバーライドしています。</LongDescription>
8613 <Details>
8614 <![CDATA[
8615 <p>
8616 メソッドは、オーバライドするメソッドの規約を常に実装するべきです。
8617 したがって、メソッドが @Nonnull 値を返すようにアノテートしているならば、サブクラスでメソッドが @Nullable または @CheckForNull 値を返すようにアノテートしてメソッドをオーバーライドするべきでありません。
8618 そうするこによって、メソッドが null を返すべきでない規約に違反します。
8619 </p>
8620 ]]>
8621 </Details>
85178622 </BugPattern>
85188623
85198624 <!--
(No changes)
1515 <excludeFolder url="file://$MODULE_DIR$/build/junitclasses" />
1616 <excludeFolder url="file://$MODULE_DIR$/classesEclipse" />
1717 </content>
18 <content url="file://$CODE_DIR$/findbugs/sandbox">
19 <excludeFolder url="file://$CODE_DIR$/findbugs/sandbox/localCloud" />
18 <content url="file://$MODULE_DIR$/sandbox">
19 <excludeFolder url="file://$MODULE_DIR$/sandbox/localCloud" />
2020 </content>
2121 <orderEntry type="sourceFolder" forTests="false" />
22 <orderEntry type="jdk" jdkName="J2SE-1.5" jdkType="JavaSDK" />
22 <orderEntry type="inheritedJdk" />
2323 <orderEntry type="module-library">
2424 <library name="AppleJavaExtensions.jar">
2525 <CLASSES>
6161 </library>
6262 </orderEntry>
6363 <orderEntry type="module-library" exported="">
64 <library name="commons-lang-2.4.jar">
65 <CLASSES>
66 <root url="jar://$MODULE_DIR$/lib/commons-lang-2.4.jar!/" />
64 <library name="commons-lang-2.6.jar">
65 <CLASSES>
66 <root url="jar://$MODULE_DIR$/lib/commons-lang-2.6.jar!/" />
6767 </CLASSES>
6868 <JAVADOC />
6969 <SOURCES />
7979 </library>
8080 </orderEntry>
8181 <orderEntry type="module-library" exported="">
82 <library name="jaxen-1.1.1.jar">
83 <CLASSES>
84 <root url="jar://$MODULE_DIR$/lib/jaxen-1.1.1.jar!/" />
82 <library name="jaxen-1.1.6.jar">
83 <CLASSES>
84 <root url="jar://$MODULE_DIR$/lib/jaxen-1.1.6.jar!/" />
8585 </CLASSES>
8686 <JAVADOC />
8787 <SOURCES />
1818 <jar href="asm-3.3.jar"/>
1919 <jar href="asm-tree-3.3.jar"/>
2020 <jar href="asm-commons-3.3.jar"/>
21 <jar href="jaxen-1.1.1.jar"/>
21 <jar href="jaxen-1.1.6.jar"/>
2222 <jar href="jFormatString.jar"/>
23 <jar href="commons-lang-2.4.jar"/>
23 <jar href="commons-lang-2.6.jar"/>
2424 <jar href="jsr305.jar"/>
2525 </resources>
2626 <component-desc />
2323 <jar href="asm-3.3.jar"/>
2424 <jar href="asm-tree-3.3.jar"/>
2525 <jar href="asm-commons-3.3.jar"/>
26 <jar href="jaxen-1.1.1.jar"/>
26 <jar href="jaxen-1.1.6.jar"/>
2727 <jar href="jFormatString.jar"/>
28 <jar href="commons-lang-2.4.jar"/>
28 <jar href="commons-lang-2.6.jar"/>
2929 <jar href="jsr305.jar"/>
3030 <property name="findbugs.jaws" value="true"/>
3131 <property name="findbugs.noSummary" value="true"/>
+0
-17
nbproject/ide-file-targets.xml less more
0 <?xml version="1.0" encoding="UTF-8"?>
1 <project basedir=".." name="findbugs-IDE">
2 <!-- TODO: edit the following target according to your needs -->
3 <!-- (more info: http://www.netbeans.org/kb/41/freeform-config.html#runsingle) -->
4 <target name="run-selected-file-in-java5">
5 <fail unless="run.class">Must set property 'run.class'</fail>
6 <ant antfile="build.xml" inheritall="false">
7 <target name="junittests"/>
8 <target name="jars"/>
9 </ant>
10 <java classname="${run.class}" failonerror="true" fork="true">
11 <classpath>
12 <pathelement path="build/classes:lib/annotations.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/asm-3.0.jar:lib/asm-analysis-3.0.jar:lib/asm-commons-3.0.jar:lib/asm-tree-3.0.jar:lib/asm-util-3.0.jar:lib/asm-xml-3.0.jar:lib/bcel.jar:lib/dom4j-full.jar:lib/jsr305.jar:lib/junit.jar"/>
13 </classpath>
14 </java>
15 </target>
16 </project>
+0
-137
nbproject/project.xml less more
0 <?xml version="1.0" encoding="UTF-8"?>
1 <project xmlns="http://www.netbeans.org/ns/project/1">
2 <type>org.netbeans.modules.ant.freeform</type>
3 <configuration>
4 <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
5 <!-- Do not use Project Properties customizer when editing this file manually. -->
6 <name>findbugs</name>
7 <properties/>
8 <folders>
9 <source-folder>
10 <label>src/java</label>
11 <type>java</type>
12 <location>src/java</location>
13 </source-folder>
14 <source-folder>
15 <label>src/junit</label>
16 <type>java</type>
17 <location>src/junit</location>
18 </source-folder>
19 <source-folder>
20 <label>src/antTask</label>
21 <type>java</type>
22 <location>src/antTask</location>
23 </source-folder>
24 <source-folder>
25 <label>src/gui</label>
26 <type>java</type>
27 <location>src/gui</location>
28 </source-folder>
29 <source-folder>
30 <label>src/tools</label>
31 <type>java</type>
32 <location>src/tools</location>
33 </source-folder>
34 </folders>
35 <ide-actions>
36 <action name="build">
37 <target>build</target>
38 </action>
39 <action name="clean">
40 <target>clean</target>
41 </action>
42 <action name="javadoc">
43 <target>docs</target>
44 </action>
45 <action name="run">
46 <target>runjunit</target>
47 </action>
48 <action name="test">
49 <target>junittests</target>
50 </action>
51 <action name="rebuild">
52 <target>clean</target>
53 <target>build</target>
54 </action>
55 <action name="run.single">
56 <script>nbproject/ide-file-targets.xml</script>
57 <target>run-selected-file-in-java5</target>
58 <context>
59 <property>run.class</property>
60 <folder>src/gui</folder>
61 <pattern>\.java$</pattern>
62 <format>java-name</format>
63 <arity>
64 <one-file-only/>
65 </arity>
66 </context>
67 </action>
68 </ide-actions>
69 <view>
70 <items>
71 <source-folder style="packages">
72 <label>src/java</label>
73 <location>src/java</location>
74 </source-folder>
75 <source-folder style="packages">
76 <label>src/junit</label>
77 <location>src/junit</location>
78 </source-folder>
79 <source-folder style="packages">
80 <label>src/antTask</label>
81 <location>src/antTask</location>
82 </source-folder>
83 <source-folder style="packages">
84 <label>src/gui</label>
85 <location>src/gui</location>
86 </source-folder>
87 <source-folder style="packages">
88 <label>src/tools</label>
89 <location>src/tools</location>
90 </source-folder>
91 <source-file>
92 <location>build.xml</location>
93 </source-file>
94 </items>
95 <context-menu>
96 <ide-action name="build"/>
97 <ide-action name="clean"/>
98 <ide-action name="javadoc"/>
99 <ide-action name="run"/>
100 <ide-action name="test"/>
101 <ide-action name="rebuild"/>
102 </context-menu>
103 </view>
104 <subprojects/>
105 </general-data>
106 <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
107 <!--
108 <compilation-unit>
109 <package-root>src/junit</package-root>
110 <unit-tests/>
111 <classpath mode="compile">build/classes:lib/annotations.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/asm-3.0.jar:lib/asm-analysis-3.0.jar:lib/asm-commons-3.0.jar:lib/asm-tree-3.0.jar:lib/asm-util-3.0.jar:lib/asm-xml-3.0.jar:lib/bcel.jar:lib/dom4j-full.jar:lib/jsr305.jar:lib/junit.jar</classpath>
112 <source-level>1.5</source-level>
113 </compilation-unit>
114 <compilation-unit>
115 <package-root>src/antTask</package-root>
116 <classpath mode="compile">build/classes:lib/annotations.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/asm-3.0.jar:lib/asm-analysis-3.0.jar:lib/asm-commons-3.0.jar:lib/asm-tree-3.0.jar:lib/asm-util-3.0.jar:lib/asm-xml-3.0.jar:lib/bcel.jar:lib/dom4j-full.jar:lib/jsr305.jar:lib/junit.jar</classpath>
117 <source-level>1.5</source-level>
118 </compilation-unit>
119 <compilation-unit>
120 <package-root>src/gui</package-root>
121 <classpath mode="compile">build/classes:lib/annotations.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/asm-3.0.jar:lib/asm-analysis-3.0.jar:lib/asm-commons-3.0.jar:lib/asm-tree-3.0.jar:lib/asm-util-3.0.jar:lib/asm-xml-3.0.jar:lib/bcel.jar:lib/dom4j-full.jar:lib/jsr305.jar:lib/junit.jar</classpath>
122 <source-level>1.5</source-level>
123 </compilation-unit>
124 -->
125 <compilation-unit>
126 <package-root>src/java</package-root>
127 <package-root>src/junit</package-root>
128 <package-root>src/antTask</package-root>
129 <package-root>src/gui</package-root>
130 <package-root>src/tools</package-root>
131 <classpath mode="compile">build/classes:lib/bcel.jar:lib/junit.jar:lib/ant.jar:lib/AppleJavaExtensions.jar:lib/jsr305.jar:lib/dom4j-1.6.1.jar:lib/jaxen-1.1.1.jar:lib/asm-3.3.jar:lib/asm-analysis-3.3.jar:lib/asm-commons-3.3.jar:lib/asm-tree-3.1.jar:lib/asm-util-3.1.jar:lib/asm-xml-3.1.jar</classpath>
132 <source-level>1.5</source-level>
133 </compilation-unit>
134 </java-data>
135 </configuration>
136 </project>
0 <project>
1 <modelVersion>4.0.0</modelVersion>
2 <parent>
3 <groupId>org.sonatype.oss</groupId>
4 <artifactId>oss-parent</artifactId>
5 <version>7</version>
6 </parent>
7
8 <groupId>com.google.code.findbugs</groupId>
9 <artifactId>findbugs</artifactId>
10 <version>2.0.3-SNAPSHOT</version>
11 <packaging>jar</packaging>
12
13 <url>http://findbugs.sourceforge.net/</url>
14 <name>FindBugs-Project</name>
15 <description>Findbugs: Because it's easy!</description>
16 <inceptionYear>2003</inceptionYear>
17 <licenses>
18 <license>
19 <name>GNU Lesser Public License</name>
20 <url>http://www.gnu.org/licenses/lgpl.html</url>
21 <distribution>repo</distribution>
22 </license>
23 </licenses>
24
25 <prerequisites>
26 <maven>3.0</maven>
27 </prerequisites>
28
29
30 <scm>
31 <connection>scm:svn:http://findbugs.googlecode.com/svn/trunk/</connection>
32 <developerConnection>scm:svn:https://findbugs.googlecode.com/svn/trunk/</developerConnection>
33 <url>http://findbugs.googlecode.com/svn/trunk/</url>
34 </scm>
35
36 <developers>
37 <developer>
38 <id>bp</id>
39 <name>Bill Pugh</name>
40 <email>pugh at cs.umd.edu</email>
41 <url>http://www.cs.umd.edu/~pugh/</url>
42 <roles>
43 <role>Project Lead</role>
44 <role>Primary Developer</role>
45 </roles>
46 <timezone>-5</timezone>
47 </developer>
48 <developer>
49 <id>al</id>
50 <name>Andrey Loskutov</name>
51 <email>Loskutov@gmx.de</email>
52 <url>http://andrei.gmxhome.de/privat.html</url>
53 <roles>
54 <role>Eclipse plugin</role>
55 </roles>
56 <timezone>+1</timezone>
57 </developer>
58 <developer>
59 <id>bp</id>
60 <name>Keith Lea</name>
61 <email></email>
62 <url>http://keithlea.com/</url>
63 <roles>
64 <role>web cloud</role>
65 </roles>
66 <timezone>-5</timezone>
67 </developer>
68 </developers>
69 <contributors>
70 <contributor>
71 <name>Garvin LeClaire</name>
72 <email>gleclaire@codehaus.org</email>
73 <url>http://gdleclaire.blogspot.com</url>
74 <roles>
75 <role>Maven</role>
76 </roles>
77 <timezone>-5</timezone>
78 </contributor>
79 <contributor>
80 <name>David H. Hovemeyer</name>
81 <email>dhovemey@ycp.edu</email>
82 <url>http://goose.ycp.edu/~dhovemey/</url>
83 <roles>
84 <role>project founder</role>
85 </roles>
86 <timezone>-5</timezone>
87 </contributor>
88 <contributor>
89 <name>Nay Ayewah</name>
90 <email></email>
91 <url></url>
92 <roles>
93 <role></role>
94 </roles>
95 <timezone>-5</timezone>
96 </contributor>
97 <contributor>
98 <name>Ben Langmead</name>
99 <email></email>
100 <url></url>
101 <roles>
102 <role></role>
103 </roles>
104 <timezone>-5</timezone>
105 </contributor>
106 <contributor>
107 <name>Tomas Pollak</name>
108 <email></email>
109 <url></url>
110 <roles>
111 <role>Eclipse plugin tests</role>
112 </roles>
113 <timezone>-5</timezone>
114 </contributor>
115 <contributor>
116 <name>Phil Crosby</name>
117 <email></email>
118 <url></url>
119 <roles>
120 <role></role>
121 </roles>
122 <timezone>-5</timezone>
123 </contributor>
124 <contributor>
125 <name>Peter Friese</name>
126 <email></email>
127 <url></url>
128 <roles>
129 <role>Eclipse plugin</role>
130 </roles>
131 <timezone>-5</timezone>
132 </contributor>
133 <contributor>
134 <name>Dave Brosius</name>
135 <email></email>
136 <url></url>
137 <roles>
138 <role></role>
139 </roles>
140 <timezone>-5</timezone>
141 </contributor>
142 <contributor>
143 <name>Brian Goetz</name>
144 <email></email>
145 <url></url>
146 <roles>
147 <role></role>
148 </roles>
149 <timezone>-5</timezone>
150 </contributor>
151 <contributor>
152 <name>Rohan Lloyd</name>
153 <email></email>
154 <url></url>
155 <roles>
156 <role></role>
157 </roles>
158 <timezone>-5</timezone>
159 </contributor>
160 </contributors>
161
162 <properties>
163 <asmVersion>3.3</asmVersion>
164 <junitVersion>4.11</junitVersion>
165 </properties>
166
167 <dependencies>
168 <dependency>
169 <groupId>net.jcip</groupId>
170 <artifactId>jcip-annotations</artifactId>
171 <version>1.0</version>
172 </dependency>
173 <dependency>
174 <groupId>com.google.code.findbugs</groupId>
175 <artifactId>jsr305</artifactId>
176 <version>2.0.1</version>
177 </dependency>
178 <dependency>
179 <groupId>com.google.code.findbugs</groupId>
180 <artifactId>bcel</artifactId>
181 <version>2.0.1</version>
182 </dependency>
183 <dependency>
184 <groupId>com.google.code.findbugs</groupId>
185 <artifactId>jFormatString</artifactId>
186 <version>2.0.1</version>
187 </dependency>
188 <dependency>
189 <groupId>dom4j</groupId>
190 <artifactId>dom4j</artifactId>
191 <version>1.6.1</version>
192 </dependency>
193 <dependency>
194 <groupId>org.apache.ant</groupId>
195 <artifactId>ant</artifactId>
196 <version>1.7.1</version>
197 <scope>provided</scope>
198 </dependency>
199 <dependency>
200 <groupId>asm</groupId>
201 <artifactId>asm</artifactId>
202 <version>${asmVersion}</version>
203 </dependency>
204 <dependency>
205 <groupId>asm</groupId>
206 <artifactId>asm-commons</artifactId>
207 <version>${asmVersion}</version>
208 </dependency>
209 <dependency>
210 <groupId>commons-lang</groupId>
211 <artifactId>commons-lang</artifactId>
212 <version>2.6</version>
213 </dependency>
214 <dependency>
215 <groupId>com.apple</groupId>
216 <artifactId>AppleJavaExtensions</artifactId>
217 <version>1.4</version>
218 </dependency>
219 <dependency>
220 <groupId>junit</groupId>
221 <artifactId>junit</artifactId>
222 <version>${junitVersion}</version>
223 <scope>test</scope>
224 </dependency>
225 <dependency>
226 <groupId>jaxen</groupId>
227 <artifactId>jaxen</artifactId>
228 <version>1.1.6</version>
229 <exclusions>
230 <exclusion>
231 <artifactId>icu4j</artifactId>
232 <groupId>com.ibm.icu</groupId>
233 </exclusion>
234 </exclusions>
235 </dependency>
236 </dependencies>
237 <build>
238 <sourceDirectory>${basedir}/src</sourceDirectory>
239 <testSourceDirectory>${basedir}/src/junit</testSourceDirectory>
240 <resources>
241 <resource>
242 <directory>${basedir}/etc</directory>
243 <includes>
244 <include>*.xsd</include>
245 <include>bugrank.txt</include>
246 <include>findbugs.xml</include>
247 <include>messages*.xml</include>
248 </includes>
249 </resource>
250 <resource>
251 <directory>${basedir}/src/xsl</directory>
252 <includes>
253 <include>*.xsl</include>
254 </includes>
255 </resource>
256 <resource>
257 <directory>${basedir}/src/antTask</directory>
258 <includes>
259 <include>**/*.xsl</include>
260 <include>**/*.properties</include>
261 <include>**/*.db</include>
262 <include>**/*.png</include>
263 <include>**/*.html</include>
264 </includes>
265 </resource>
266 <resource>
267 <directory>${basedir}/src/antTask</directory>
268 <includes>
269 <include>**/*.xsl</include>
270 <include>**/*.properties</include>
271 <include>**/*.db</include>
272 <include>**/*.png</include>
273 <include>**/*.html</include>
274 </includes>
275 </resource>
276 <resource>
277 <directory>${basedir}/src/gui</directory>
278 <includes>
279 <include>**/*.xsl</include>
280 <include>**/*.properties</include>
281 <include>**/*.db</include>
282 <include>**/*.png</include>
283 <include>**/*.html</include>
284 </includes>
285 </resource>
286 <resource>
287 <directory>${basedir}/src/java</directory>
288 <includes>
289 <include>**/*.xsl</include>
290 <include>**/*.properties</include>
291 <include>**/*.db</include>
292 <include>**/*.png</include>
293 <include>**/*.html</include>
294 </includes>
295 </resource>
296 </resources>
297 <plugins>
298 <plugin>
299 <groupId>org.apache.maven.plugins</groupId>
300 <artifactId>maven-compiler-plugin</artifactId>
301 <version>3.0</version>
302 <configuration>
303 <source>1.5</source>
304 <target>1.5</target>
305 <excludes>
306 <exclude>**/junit/**</exclude>
307 <exclude>**/infonodeJava/**</exclude>
308 <exclude>**/obsolete/**</exclude>
309 </excludes>
310 <testExcludes>
311 <exclude>**/architecture/**</exclude>
312 <exclude>**/cloud/**</exclude>
313 <!-- -->
314 <exclude>**/DetectorsTest.java</exclude>
315 </testExcludes>
316 </configuration>
317 </plugin>
318 <plugin>
319 <groupId>org.apache.maven.plugins</groupId>
320 <artifactId>maven-jar-plugin</artifactId>
321 <version>2.4</version>
322 <configuration>
323 <archive>
324 <manifestFile>${basedir}/etc/MANIFEST-findbugs.MF</manifestFile>
325 </archive>
326 </configuration>
327 </plugin>
328 </plugins>
329 </build>
330
331 <profiles>
332 <profile>
333 <id>deploy</id>
334 <build>
335 <plugins>
336 <plugin>
337 <groupId>org.apache.maven.plugins</groupId>
338 <artifactId>maven-gpg-plugin</artifactId>
339 <version>1.4</version>
340 <executions>
341 <execution>
342 <id>sign-artifacts</id>
343 <phase>install</phase>
344 <goals>
345 <goal>sign</goal>
346 </goals>
347 </execution>
348 </executions>
349 </plugin>
350 </plugins>
351 </build>
352 </profile>
353 </profiles>
354 </project>
360360 */
361361 private void execFindbugs() throws BuildException {
362362
363 System.out.println("Executing findbugs from ant task");
363 System.out.println("Executing findbugs " + this.getClass().getSimpleName() + " from ant task");
364364 createFindbugsEngine();
365365 configureFindbugsEngine();
366366
393393 log(be.toString());
394394 }
395395 String returnProperty = getFindbugsEngine().getProject().getProperty(execReturnCodeIdentifier);
396 int rc = returnProperty == null ? 0 : Integer.valueOf(returnProperty).intValue();
396 int rc = returnProperty == null ? 0 : Integer.parseInt(returnProperty);
397397
398398 afterExecuteJavaProcess(rc);
399399 }
110110 if (input == null) {
111111 throw new BuildException("input attribute is required", getLocation());
112112 }
113 if (output == null) {
114 throw new BuildException("output attribute is required", getLocation());
115 }
116113 if (!format.equals("text") && !(format.equals("html") || format.startsWith("html:"))) {
117114 throw new BuildException("invalid value " + format + " for format attribute", getLocation());
118115 }
138135 addArg("-applySuppression");
139136 }
140137 addArg(input);
141 addArg(output);
138 if (output != null)
139 addArg(output);
142140 }
143141
144142 /*
150148 */
151149 @Override
152150 protected void beforeExecuteJavaProcess() {
153 log("Converting " + input + " to " + output + " using format " + format);
151 if (output != null)
152 log("Converting " + input + " to " + output + " using format " + format);
153 else
154 log("Converting " + input + " using format " + format);
154155 }
155156
156157 /*
00 /*
1 * The Apache Software License, Version 1.1
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2013 University of Maryland
23 *
3 * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
4 * reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
58 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
913 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. The end-user documentation included with the redistribution, if
19 * any, must include the following acknowlegement:
20 * "This product includes software developed by the
21 * Apache Software Foundation (http://www.apache.org/)."
22 * Alternately, this acknowlegement may appear in the software itself,
23 * if and wherever such third-party acknowlegements normally appear.
24 *
25 * 4. The names "Ant" and "Apache Software
26 * Foundation" must not be used to endorse or promote products derived
27 * from this software without prior written permission. For written
28 * permission, please contact apache@apache.org.
29 *
30 * 5. Products derived from this software may not be called "Apache"
31 * nor may "Apache" appear in their names without prior written
32 * permission of the Apache Group.
33 *
34 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
38 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
41 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
44 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 * ====================================================================
47 *
48 * This software consists of voluntary contributions made by many
49 * individuals on behalf of the Apache Software Foundation. For more
50 * information on the Apache Software Foundation, please see
51 * <http://www.apache.org/>.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5217 */
5318
5419 package edu.umd.cs.findbugs.anttask;
10065 * <li>pluginList (list of plugin Jar files to load)
10166 * <li>projectFile (project filename)
10267 * <li>projectName (project name, for display in generated HTML)
68 * <li>userPrefs (user preferences filename)
10369 * <li>quietErrors (boolean - default false)
10470 * <li>relaxed (boolean - default false)
10571 * <li>reportLevel (enum experimental|low|medium|high)
159125
160126 private File projectFile;
161127
128 private File userPreferencesFile;
129
162130 private File baselineBugs;
163131
164132 private boolean applySuppression;
413381 */
414382 public void setProjectFile(File projectFile) {
415383 this.projectFile = projectFile;
384 }
385
386 /**
387 * Set the project file
388 */
389 public void setUserPreferencesFile(File userPreferencesFile) {
390 this.userPreferencesFile = userPreferencesFile;
416391 }
417392
418393 /**
697672 if (projectFile != null) {
698673 addArg("-project");
699674 addArg(projectFile.getPath());
675 }
676 if (userPreferencesFile != null) {
677 addArg("-userPrefs");
678 addArg(userPreferencesFile.getPath());
700679 }
701680 if (applySuppression) {
702681 addArg("-applySuppression");
9494 /**
9595 * Sets the file that contains the XML output of a findbugs report.
9696 *
97 * @param bugReport
97 * @param loadbugs
9898 * XML output from a findbugs session
9999 */
100100 public void setLoadbugs(File loadbugs) {
6262 /**
6363 * The File everything should get merged into
6464 *
65 * @param file
65 * @param arg
6666 */
6767 public void setTo(String arg) {
6868 this.to = arg;
1616
1717
1818 <h1>FindBugs Change Log, Version @VERSION@</h1>
19 <ul>
20 <li>New Bug patterns: <a
21 href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_BOXED_PRIMITIVE_FOR_PARSING">DM_BOXED_PRIMITIVE_FOR_PARSING</a>,
22 <a
23 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_METHOD_RETURN_RELAXING_ANNOTATION">NP_METHOD_RETURN_RELAXING_ANNOTATION</a>,
24 and
25 <a
26 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION</a>
27 </li>
28 <li>Add the ability in the GUI to save the currently viewable/filtered bugs to HTML output.
29 <li>When dataflow does't terminate, make sure we continue with
30 analysis.
31
32 <li>Fix some problems that resulting in dataflow analysis not
33 terminating
34
35 <li>Get parameter annotations from default parameters
36 annotations applied to the method.
37 <li>Add subversion change number to eclipse plugin qualifier.
38
39 <li>Disabled detector for <a
40 href="http://findbugs.sourceforge.net/bugDescriptions.html#AM_CREATES_EMPTY_JAR_FILE_ENTRY">AM_CREATES_EMPTY_JAR_FILE_ENTRY</a>;
41 it complaints inappropriately about code that creates directory
42 entries.
43
44 <li>Add warnings about incompatible types passed to
45 org.testng.Assert.assertEquals</li>
46 <li>Add logic that understands more of the Google Guava APIs.
47 <li>Disable type qualifier validator execution within Eclipse plugin;
48 too many problems with class loading and security manager (see #1154 Random obscure Eclipse failures)
49 <li>Consistently check both access flags and attributes to see if something is synthetic. Compiler is
50 inconsistent about where synthetic elements are marked.
51
52 <li>Fixed false positives for the following bug patterns (17
53 occurrences in findbugsTestCases):
54 <ul>
55 <li><a
56 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC">BC</a>
57 <li><a
58 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_INSTANCEOF">BC_IMPOSSIBLE_INSTANCEOF</a>
59 <li><a
60 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST">BC_UNCONFIRMED_CAST</a>
61 <li><a
62 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_UNRELATED_TYPES">EC_UNRELATED_TYPES</a>
63 <li><a
64 href="http://findbugs.sourceforge.net/bugDescriptions.html#INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE</a>
65 <li><a
66 href="http://findbugs.sourceforge.net/bugDescriptions.html#IS2_INCONSISTENT_SYNC">IS2_INCONSISTENT_SYNC</a>
67 <li><a
68 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS</a>
69 <li><a
70 href="http://findbugs.sourceforge.net/bugDescriptions.html#OBL_UNSATISFIED_OBLIGATION">OBL_UNSATISFIED_OBLIGATION</a>
71 <li><a
72 href="http://findbugs.sourceforge.net/bugDescriptions.html#RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE</a>
73 <li><a
74 href="http://findbugs.sourceforge.net/bugDescriptions.html#SA_FIELD_SELF_COMPARISON">SA_FIELD_SELF_COMPARISON</a>
75 <li><a
76 href="http://findbugs.sourceforge.net/bugDescriptions.html#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED</a>
77 </li>
78 </ul>
79 <li>Fixed false negatives for the following bug patterns (45
80 occurrences in findbugsTestCases):
81 <ul>
82 <li><a
83 href="http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST">BC_UNCONFIRMED_CAST</a>
84 <li><a
85 href="http://findbugs.sourceforge.net/bugDescriptions.html#DM_NUMBER_CTOR">DM_NUMBER_CTOR</a>
86 <li><a
87 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_ARRAY_AND_NONARRAY">EC_ARRAY_AND_NONARRAY</a>
88 <li><a
89 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_INCOMPATIBLE_ARRAY_COMPARE">EC_INCOMPATIBLE_ARRAY_COMPARE</a>
90 <li><a
91 href="http://findbugs.sourceforge.net/bugDescriptions.html#EC_UNRELATED_TYPES">EC_UNRELATED_TYPES</a>
92 <li><a
93 href="http://findbugs.sourceforge.net/bugDescriptions.html#GC_UNRELATED_TYPES">GC_UNRELATED_TYPES</a>
94 <li><a
95 href="http://findbugs.sourceforge.net/bugDescriptions.html#IS_FIELD_NOT_GUARDED">IS_FIELD_NOT_GUARDED</a>
96 <li><a
97 href="http://findbugs.sourceforge.net/bugDescriptions.html#IT_NO_SUCH_ELEMENT">IT_NO_SUCH_ELEMENT</a>
98 <li><a
99 href="http://findbugs.sourceforge.net/bugDescriptions.html#JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS</a>
100 <li><a
101 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_ON_SOME_PATH">NP_NULL_ON_SOME_PATH</a>
102 <li><a
103 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NONNULL_PARAM_VIOLATION">NP_NONNULL_PARAM_VIOLATION</a>
104 <li><a
105 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE</a>
106 <li><a
107 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE</a>
108 <li><a
109 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_STORE_INTO_NONNULL_FIELD">NP_STORE_INTO_NONNULL_FIELD</a>
110 <li><a
111 href="http://findbugs.sourceforge.net/bugDescriptions.html#RE_POSSIBLE_UNINTENDED_PATTERN">RE_POSSIBLE_UNINTENDED_PATTERN</a>
112 <li><a
113 href="http://findbugs.sourceforge.net/bugDescriptions.html#SA_FIELD_SELF_COMPARISON">SA_FIELD_SELF_COMPARISON</a>
114 </ul>
115 </ul>
116 <h1>FindBugs Change Log, Version 2.0.2</h1>
117
19118 <ul>
20119 <li>Fix false positions for <a
21120 href="http://findbugs.sourceforge.net/bugDescriptions.html#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR</a>
4242 </li>
4343 <li>Eclipse plugin for FindBugs version @ECLIPSE_UI_VERSION@ (requires Eclipse 3.6 or later)
4444 <ul>
45 <li><a href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_@ECLIPSE_UI_VERSION@.zip?download">edu.umd.cs.findbugs.plugin.eclipse_@ECLIPSE_UI_VERSION@.zip</a>
46 <li><a href="http://prdownloads.sourceforge.net/findbugs/eclipsePlugin-@ECLIPSE_UI_VERSION@-source.zip?download">eclipsePlugin-@ECLIPSE_UI_VERSION@-source.zip</a>
45 <li><a href="http://sourceforge.net/projects/findbugs/files/findbugs%20eclipse%20plugin/@VERSION_BASE@/edu.umd.cs.findbugs.plugin.eclipse_@ECLIPSE_UI_VERSION@-@FINDBUGS_SVN_REVISION@.zip/download">edu.umd.cs.findbugs.plugin.eclipse_@ECLIPSE_UI_VERSION@-@FINDBUGS_SVN_REVISION@.zip</a>
46 <li><a href="http://sourceforge.net/projects/findbugs/files/findbugs%20eclipse%20plugin/@VERSION_BASE@/eclipsePlugin-@ECLIPSE_UI_VERSION@-@FINDBUGS_SVN_REVISION@-source.zip/download">
47 eclipsePlugin-@ECLIPSE_UI_VERSION@-@FINDBUGS_SVN_REVISION@-source.zip/download</a>
4748 </ul>
4849 </li>
4950 </ul>
3838
3939 <p>
4040 FindBugs requires JRE (or JDK) 1.5.0 or later to run.&nbsp; However, it can analyze programs
41 compiled for any version of Java, from 1.0 to 1.8. The current version of FindBugs is @VERSION@,
41 compiled for any version of Java, from 1.0 to 1.7. Some classfiles compiled for Java 1.8 give
42 FindBugs problems, the next major release of FindBugs will handle Java 1.8 classfiles.
43
44 <p> The current version of FindBugs is @VERSION@,
45
4246 released on @RELEASE_DATE@. <a href="reportingBugs.html">We are very interested in getting
4347 feedback on how to improve FindBugs</a>. File bug reports on <a
4448 href="http://sourceforge.net/tracker/?func=browse&amp;group_id=96405&amp;atid=614693"> our
4549 sourceforge bug tracker</a>
4650 </p>
51 <p>The current version of FindBugs may encounter errors when analyzing
52 Java 1.8 bytecode, due to changes in the classfile format. After FindBugs 2.0.3
53 is released, work will start on the next major release of FindBugs, which will
54 be able to analyze Java 1.8 (and will require Java 1.7 to compile and run).
55
4756
4857 <p>
4958 <a href="#changes">Changes</a> | <a href="#talks">Talks</a> | <a href="#papers">Papers </a> | <a
5059 href="#sponsors">Sponsors</a> | <a href="#support">Support</a>
5160 </p>
52 <h1>FindBugs 2.0 Release</h1>
53 <p>After many delays, we have released FindBugs 2.0. We are pretty happy and confident about the
54 functionality, although we know the documentation of the changes in 2.0 is lacking. We decided that
55 releasing 2.0 took precedence over fixing the documentation. Anyone currently using FindBugs 1.3.9
56 should find FindBugs 2.0 to largely be a drop-in replacement that offers better accuracy and
57 performance.</p>
61
62 <h1>FindBugs 2.0.3 Release</h1>
63 <p>FindBugs 2.0.3 is intended to be a minor bug fix release over
64 FindBugs 2.0.2. Although than some improvements to existing bug detectors
65 and analysis engines, and a few new bug patterns, and some
66 important bug fixes to the Eclipse plugin, no significant changes
67 should be observed. Consult the <a href="Changes.html">Change log</a>
68 for more details.</p>
5869
5970 <p>
6071 Also check out <a href="http://code.google.com/p/findbugs/w/list">http://code.google.com/p/findbugs/w/list</a>
6374
6475
6576 <h3>
66 <a href="findbugs2.html">Major changes in FindBugs 2.0</a>
77 <a href="findbugs2.html">Major changes in FindBugs 2.0 (from FindBugs 1.3.x)</a>
6778 </h3>
6879 <ul>
6980 <li><a href="findbugs2.html#cloud">FindBugs Communal cloud</a></li>
103114 <dd>
104115 <a href="http://kenai.com/projects/sqe/pages/Home">SQE: Software Quality Environment</a>
105116 </dd>
117 <dt><a href="https://wiki.jenkins-ci.org/display/JENKINS">Jenkins</a></dt>
118 <dd> <a href="https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin">Jenkins FindBugs Plugin</a>
119
106120 <dt>
107121 <a href="http://wiki.hudson-ci.org/display/HUDSON/Home">Hudson</a>
108122 </dt>
109123 <dd>
110 <a href="http://wiki.hudson-ci.org/display/HUDSON/FindBugs+Plugin">http://wiki.hudson-ci.org/display/HUDSON/FindBugs+Plugin</a>
124 <a href="http://wiki.hudson-ci.org/display/HUDSON/FindBugs+Plugin"> HUDSON FindBugs Plugin</a>
111125 </dd>
112126 <dt>
113127 <a href="http://www.jetbrains.com/idea/">IntelliJ</a>
114128 </dt>
115129 <dd>
116130 Several plugins, see <a href="http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins">http://code.google.com/p/findbugs/wiki/IntellijFindBugsPlugins</a>
117 for a descrption.
131 for a description.
118132
119133 </dd>
120134 </dl>
122136
123137 <h1>New</h1>
124138 <ul>
125 <li>We've released FindBugs 2.0.2.
139
140 <li>jFormatString library republished at
141 <a href="http://code.google.com/p/j-format-string">http://code.google.com/p/j-format-string</a>.
142 This is the library we use for compile time checking of format strings. It is separately published to
143
144 <li>We're releasing FindBugs 2.0.3.
145
126146 Mostly small changes to address false positives, with one important fix to the Eclipse plugin
127 to fix a problem that had prevented the plugin from running in some versions of Eclipse.
147 to fix a problem that had prevented the plugin from running in some versions of Eclipse.
128148 Check the <a href="Changes.html">change log</a> for more details.
129
149
130150 <li>We've released <a href="findbugs2.html">FindBugs 2.0</a>
131151 </li>
132152 <li>FindBugs communal cloud and Java web start links:. We have analyzed several large open
153173 the systems at Google. A fixit might work to improve web accessibility, internal testing, removing
154174 TODO's from internal software, etc.
155175
156 <p>On May 13-14, Google held a global fixit for UMD's FindBugs tool a static analysis tool for
176 <p>In 2009, Google held a global fixit for UMD's FindBugs tool a static analysis tool for
157177 finding coding mistakes in Java software. The focus of the fixit was to get feedback on the
158178 4,000 highest confidence issues found by FindBugs at Google, and let Google engineers decide
159179 which issues, if any, needed fixing.</p>
184204 <a name="talks">Talks about FindBugs</a>
185205 </h2>
186206 <ul>
187 <p>
207 <li>
188208 <a href="http://www.cs.umd.edu/~pugh/MistakesThatMatter.pdf">Mistakes That Matter</a>, JavaOne,
189209 2009
190 </p>
191 <li><a href="http://youtu.be/1AJjwsuESno?hd=1">Youtube video</a> showing of demo
192 of our 2.0 Eclipse plugin (16 minutes)</li>
210 </li>
211 <li><a href="http://youtu.be/jflQSFhYTEo?hd=1">Youtube video</a> showing of demo
212 of our 2.0 Eclipse plugin (5 minutes)</li>
193213 <li><a href="http://findbugs.cs.umd.edu/talks/findbugs.mov">Quicktime movie</a> showing of demo
194214 of our new GUI to view some of the null pointer bugs in Eclipse (Big file warning: 23 Megabytes)</li>
195215 <li><a href="http://findbugs.cs.umd.edu/talks/JavaOne2007-TS2007.pdf">JavaOne 2007 talk on
231251 href="http://www.cs.umd.edu/~pugh">Bill Pugh</a> and <a
232252 href="http://andrei.gmxhome.de/privat.html">Andrey Loskutov</a>.
233253 </p>
234 <p>Current funding for FindBugs comes from a Google Faculty Research Awards. We'd be interested in
235 any offers of support or sponsorship.</p>
254 <p>The most recent funding for FindBugs comes from a Google Faculty Research Awards.</p>
236255 <h2>
237256 <a name="support">Additional Support</a>
238257 </h2>
259278 </p>
260279 <p>Any opinions, findings and conclusions or recommendations expressed in this material are those of
261280 the author(s) and do not necessarily reflect the views of the National Science Foundation (NSF).
262 @HTML_FOOTER@</p>
281 </p>
282 @HTML_FOOTER@
263283 </td>
264284 </tr>
265285 </table>
937937 </listitem>
938938 </varlistentry>
939939
940 <varlistentry>
941 <term><command>-userPrefs</command> <replaceable>edu.umd.cs.findbugs.core.prefs</replaceable></term>
942 <listitem>
943 <para>
944 Set the path of the user preferences file to use, which might override some of the options abobe.
945 Specifying <literal>userPrefs</literal> as first argument would mean some later
946 options will override them, as last argument would mean they will override some previous options).
947 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
948 line execution.
949 </para>
950 </listitem>
951 </varlistentry>
952
940953 <!--
941954 <varlistentry>
942955 <term><command></command> <replaceable></replaceable></term>
12311244 elements may be specified as children of a single <literal>findbugs</literal> element.
12321245 </para>
12331246 <para>In addition to or instead of specifying a <literal>class</literal> element,
1234 the &FindBugs; task can contain one or more <literal>fileset</literal> element(s) that
1235 specify files to be analyzed.
1247 the &FindBugs; task can contain one or more <literal>fileset</literal> element(s) that
1248 specify files to be analyzed.
12361249 For example, you might use a fileset to specify that all of the jar files in a directory
12371250 should be analyzed.
12381251 </para>
12911304 <para>
12921305 An optional attribute. It specifies
12931306 the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs.
1294 If set to "medium" (the default), low confidence issues are supressed.
1307 If set to "medium" (the default), low confidence issues are supressed.
12951308 If set to "high", only high confidence bugs are reported.
12961309 </para>
12971310 </listitem>
15091522 that will be set to "true" if any warnings are reported by
15101523 &FindBugs; on the analyzed program.
15111524 </para>
1525 </listitem>
1526 </varlistentry>
1527
1528 <varlistentry>
1529 <term><literal>userPreferencesFile</literal></term>
1530 <listitem>
1531 <para>
1532 Optional attribute. Set the path of the user preferences file to use, which might override some of the options abobe.
1533 Specifying <literal>userPreferencesFile</literal> as first argument would mean some later
1534 options will override them, as last argument would mean they will override some previous options).
1535 This rationale behind this option is to reuse FindBugs Eclipse project settings for command
1536 line execution.
1537 </para>
15121538 </listitem>
15131539 </varlistentry>
15141540
7676 * Process an HTML page to replace certain substitution patterns. Right now,
7777 * we just expand @VERSION@.
7878 */
79 @edu.umd.cs.findbugs.annotations.SuppressWarnings("OS_OPEN_STREAM")
79 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("OS_OPEN_STREAM")
8080 private void processPage(javax.swing.JEditorPane pane, String fileName) throws IOException {
8181 InputStream in = null;
8282 BufferedReader reader = null;
6565
6666 private JButton cancelButton;
6767
68 public AnalyzingDialog(@Nonnull final Project project) {
69 this(project, new AnalysisCallback() {
68 public static void show(@Nonnull final Project project) {
69 AnalysisCallback callback = new AnalysisCallback() {
7070 public void analysisFinished(BugCollection results) {
7171 MainFrame instance = MainFrame.getInstance();
7272 assert results.getProject() == project;
8484 instance.updateProjectAndBugCollection(null);
8585 instance.releaseDisplayWait();
8686 }
87 }, false);
88 }
89
87 };
88 show(project, callback, false);
89
90 }
91
9092 /**
9193 *
9294 * @param project
99101 * analysis is complete. If true, the constructor does not return
100102 * until the analysis is either finished or interrupted.
101103 */
102 public AnalyzingDialog(@Nonnull Project project, AnalysisCallback callback, boolean joinThread) {
104
105 public static void show(@Nonnull
106 Project project, AnalysisCallback callback, boolean joinThread) {
107 AnalyzingDialog dialog = new AnalyzingDialog(project, callback, joinThread);
108 MainFrame.getInstance().acquireDisplayWait();
109 try {
110 dialog.analysisThread.start();
111 if (joinThread)
112 try {
113 dialog.analysisThread.join();
114 } catch (InterruptedException e) {
115 }
116 } finally {
117 if (joinThread)
118 MainFrame.getInstance().releaseDisplayWait();
119 }
120 }
121
122
123
124 /**
125 *
126 * @param project
127 * The Project to analyze
128 * @param callback
129 * contains what to do if the analysis is interrupted and what to
130 * do if it finishes normally
131 * @param joinThread
132 * Whether or not this constructor should return before the
133 * analysis is complete. If true, the constructor does not return
134 * until the analysis is either finished or interrupted.
135 */
136 private AnalyzingDialog(@Nonnull Project project, AnalysisCallback callback, boolean joinThread) {
103137 if (project == null)
104138 throw new NullPointerException("null project");
105139 this.project = project;
106140 this.callback = callback;
107 initComponents();
108 MainFrame.getInstance().acquireDisplayWait();
109 try {
110 analysisThread.start();
111 if (joinThread)
112 try {
113 analysisThread.join();
114 } catch (InterruptedException e) {
115 }
116 } finally {
117 if (joinThread)
118 MainFrame.getInstance().releaseDisplayWait();
119
120 }
121 }
122
123 private void initComponents() {
124141 statusLabel = new JLabel(" ");
125142 progressBar = new JProgressBar();
126143 progressBar.setStringPainted(true);
137154 cancel();
138155 }
139156 });
140
157
141158 SwingUtilities.invokeLater(new Runnable() {
142159 public void run() {
143160 setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
155172 try {
156173 setVisible(true);
157174 } catch (Throwable e) {
158 project.getGuiCallback().showMessageDialog("ERROR DURING ANALYSIS:\n\n"
175 AnalyzingDialog.this.project.getGuiCallback().showMessageDialog("ERROR DURING ANALYSIS:\n\n"
159176 + e.getClass().getSimpleName() + ": " + e.getMessage());
160177 }
161178 }
162179 });
180
163181 }
164182
165183 private void cancel() {
3737
3838 import edu.umd.cs.findbugs.BugCollection;
3939 import edu.umd.cs.findbugs.BugCollectionBugReporter;
40 import edu.umd.cs.findbugs.BugInstance;
4140 import edu.umd.cs.findbugs.BugReporter;
4241 import edu.umd.cs.findbugs.DetectorFactoryCollection;
4342 import edu.umd.cs.findbugs.FindBugs2;
187186 String msg = SystemProperties.getOSDependentProperty("findbugs.unableToLoadViaURL");
188187 if (msg == null)
189188 msg = e.getMessage();
190 else
191 msg = String.format(msg);
189 else try {
190 msg = String.format(msg, url);
191 } catch (Exception e2) {
192 msg = e.getMessage();
193 }
192194 JOptionPane.showMessageDialog(mainFrame, "Could not read " + url + "\n" + msg);
193195 if (SystemProperties.getBoolean("findbugs.failIfUnableToLoadViaURL"))
194196 System.exit(1);
289291
290292 RedoAnalysisCallback ac = new RedoAnalysisCallback();
291293
292 new AnalyzingDialog(p, ac, true);
294 AnalyzingDialog.show(p, ac, true);
293295
294296 if (ac.finished)
295297 return ac.getBugCollection();
316318
317319 RedoAnalysisCallback ac = new RedoAnalysisCallback();
318320
319 new AnalyzingDialog(p, ac, true);
321 AnalyzingDialog.show(p, ac, true);
320322
321323 if (!ac.finished)
322324 return null;
323325 if (current == null)
324 current = ac.getBugCollection();
326 current = ac.getBugCollection();
325327 else {
326328 current = update.mergeCollections(current, ac.getBugCollection(), true, false);
327329 if (current.hasDeadBugs()) {
164164
165165 public Object getChild(Object o, int index) {
166166 int childCount = getChildCount(o);
167 if (index < 0 || index >= childCount)
167 if (index < 0 || index >= childCount) {
168 if (SystemProperties.ASSERTIONS_ENABLED) {
169 System.out.printf("Unable to get child %d of %d from %s:%s%n" , index, childCount, o.getClass().getSimpleName(), o);
170 }
168171 return null;
172 }
169173 Object result = getChild((BugAspects) o, index);
170174 assert result != null;
171175 return result;
172176 }
173
177
174178 private @Nonnull Object getChild(BugAspects a, int index) {
175
179
176180 int treeLevels = st.getOrderBeforeDivider().size();
177181 int queryDepth = a.size();
178182 assert queryDepth <= treeLevels;
315319
316320 /**
317321 * Swaps in a new BugTreeModel and a new JTree
318 *
322 *
319323 */
320324 public void rebuild() {
321325 if (TRACE)
361365 }
362366 }
363367 }, "Rebuilding thread");
364
368
365369 }
366370
367371 public void crawl(final ArrayList<BugAspects> path, final int depth) {
619623
620624 enum TreeModification {
621625 REMOVE, INSERT, REMOVERESTRUCTURE, INSERTRESTRUCTURE
622 };
626 }
623627
624628 private TreeModelEvent branchOperations(ArrayList<String> stringsToBranch, TreeModification whatToDo)
625629 throws BranchOperationException {
00 /*
1 * Copyright 2010 Keith Lea
1 * FindBugs - Find bugs in Java programs
2 * Copyright (C) 2010-2013 University of Maryland
23 *
3 * This file is part of FindBugs-IDEA.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
48 *
5 * FindBugs-IDEA is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
913 *
10 * FindBugs-IDEA is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with FindBugs-IDEA. If not, see <http://www.gnu.org/licenses/>.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717 */
1818
1919 package edu.umd.cs.findbugs.gui2;
8080 import edu.umd.cs.findbugs.cloud.CloudPlugin;
8181 import edu.umd.cs.findbugs.util.Util;
8282
83 @edu.umd.cs.findbugs.annotations.SuppressWarnings({"SE_TRANSIENT_FIELD_NOT_RESTORED", "SE_BAD_FIELD", "SE_BAD_FIELD_STORE"})
83 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"SE_TRANSIENT_FIELD_NOT_RESTORED", "SE_BAD_FIELD", "SE_BAD_FIELD_STORE"})
8484 public abstract class CloudCommentsPane extends JPanel {
8585
8686 private static final String MSG_REVIEW = L10N.getLocalString("dlg.cloud.add_review", "Click to add review...");
377377 }
378378 });
379379 refresh();
380
380
381381 }
382382 }
383383 }
411411 // boolean b1 = text.trim().equals("");
412412 boolean b3 = text.equals(lastCommentText);
413413 return b && !b3;
414 }
415
416 public boolean canSetDesignations() {
417 List<BugInstance> bugs = getSelectedBugs();
418 if (bugs.isEmpty())
419 return true;
420 Cloud plugin = _bugCollection != null ? _bugCollection.getCloud() : null;
421 if (plugin == null)
422 return false;
423 for(BugInstance b : bugs)
424 if (plugin.canStoreUserAnnotation(b))
425 return true;
426 return false;
414427 }
415428
416429 public void setDesignation(final String designationKey) {
171171 return null;
172172 return bugCollection.getCloud();
173173 }
174
174
175175 public void updateBugCollection() {
176176 commentsPane.setBugCollection(getBugCollection());
177177 }
180180 commentsPane.refresh();
181181 }
182182
183
184 public boolean canSetDesignations() {
185 return commentsPane.canSetDesignations();
186 }
183187 public void setDesignation(String designationKey) {
184188 commentsPane.setDesignation(designationKey);
185189 }
140140 for (String pid : plugins) {
141141 Plugin plugin = Plugin.getByPluginId(pid);
142142 if (plugin != null) {
143 if (plugin.cannotDisable())
143 if (!enabled && plugin.cannotDisable())
144144 JOptionPane.showMessageDialog(null,
145145 "Cannot disable plugin: " + plugin.getPluginId() + "\n" + plugin.getShortDescription(),
146146 "Cannot disable plugin", JOptionPane.ERROR_MESSAGE);
2626 public interface FilterListener {
2727 enum Action {
2828 FILTERING, UNFILTERING
29 };
29 }
3030
3131 public void clearCache();
3232
3535 public class FilterMatcher implements Matcher, Serializable, Comparable<FilterMatcher> {
3636 enum FilterWhere {
3737 FILTER_EXACTLY, FILTER_AT_OR_AFTER, FILTER_AT_OR_BEFORE, FILTER_ALL_BUT
38 };
38 }
3939
4040 private static final long serialVersionUID = -4859486064351510016L;
4141
42 private Sortables filterBy;
42 private final Sortables filterBy;
4343
44 private String value;
44 private final String value;
4545
46 private FilterWhere mode;
46 private final FilterWhere mode;
4747
4848 protected boolean active;
4949
2525 public static final FindBugsFBAFileFilter INSTANCE = new FindBugsFBAFileFilter();
2626
2727 private FindBugsFBAFileFilter() {
28 };
28 }
2929
3030 @Override
3131 public boolean accept(File arg0) {
2525 public static final FindBugsFBPFileFilter INSTANCE = new FindBugsFBPFileFilter();
2626
2727 private FindBugsFBPFileFilter() {
28 };
28 }
2929
3030 @Override
3131 public boolean accept(File arg0) {
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2006, University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
17 */
18
19 package edu.umd.cs.findbugs.gui2;
20
21 import java.io.File;
22
23 public final class FindBugsHtmlFileFilter extends FindBugsFileFilter {
24
25 public static final FindBugsHtmlFileFilter INSTANCE = new FindBugsHtmlFileFilter();
26
27 @Override
28 public boolean accept(File arg0) {
29 return arg0.getName().endsWith(".html") || arg0.getName().endsWith(".htm") || arg0.isDirectory();
30 }
31
32 @Override
33 public String getDescription() {
34 return "FindBugs html output (.html)";
35 }
36
37 @Override
38 SaveType getSaveType() {
39 return SaveType.HTML_OUTPUT;
40 }
41 }
6666 import edu.umd.cs.findbugs.cloud.Cloud;
6767 import edu.umd.cs.findbugs.cloud.Cloud.CloudListener;
6868 import edu.umd.cs.findbugs.cloud.Cloud.SigninState;
69 import edu.umd.cs.findbugs.cloud.DoNothingCloud;
6970 import edu.umd.cs.findbugs.filter.Filter;
7071 import edu.umd.cs.findbugs.log.ConsoleLogger;
7172 import edu.umd.cs.findbugs.log.LogSync;
109110
110111 private final ProjectPackagePrefixes projectPackagePrefixes = new ProjectPackagePrefixes();
111112
112 private Logger logger = new ConsoleLogger(this);
113 private final Logger logger = new ConsoleLogger(this);
113114
114115 @CheckForNull
115116 private File saveFile = null;
116117
117 private CloudListener userAnnotationListener = new MyCloudListener();
118
119 private Cloud.CloudStatusListener cloudStatusListener = new MyCloudStatusListener();
120
121 private ExecutorService backgroundExecutor = Executors.newCachedThreadPool();
118 private final CloudListener userAnnotationListener = new MyCloudListener();
119
120 private final Cloud.CloudStatusListener cloudStatusListener = new MyCloudStatusListener();
121
122 private final ExecutorService backgroundExecutor = Executors.newCachedThreadPool();
122123
123124 private final CountDownLatch mainFrameInitialized = new CountDownLatch(1);
124125
141142
142143 private final CommentsArea comments;
143144
144 private JLabel statusBarLabel = new JLabel();
145
146 private JTextField sourceSearchTextField = new JTextField(SEARCH_TEXT_FIELD_SIZE);
147
148 private JButton findButton = MainFrameHelper.newButton("button.find", "First");
149
150 private JButton findNextButton = MainFrameHelper.newButton("button.findNext", "Next");
151
152 private JButton findPreviousButton = MainFrameHelper.newButton("button.findPrev", "Previous");
153
154 private NavigableTextPane sourceCodeTextPane = new NavigableTextPane();
145 private final JLabel statusBarLabel = new JLabel();
146
147 private final JTextField sourceSearchTextField = new JTextField(SEARCH_TEXT_FIELD_SIZE);
148
149 private final JButton findButton = MainFrameHelper.newButton("button.find", "First");
150
151 private final JButton findNextButton = MainFrameHelper.newButton("button.findNext", "Next");
152
153 private final JButton findPreviousButton = MainFrameHelper.newButton("button.findPrev", "Previous");
154
155 private final NavigableTextPane sourceCodeTextPane = new NavigableTextPane();
155156
156157 private JPanel summaryTopPanel;
157158
158159 JEditorPane summaryHtmlArea = new JEditorPane();
159160
160 private JScrollPane summaryHtmlScrollPane = new JScrollPane(summaryHtmlArea);
161
162 private SourceCodeDisplay displayer = new SourceCodeDisplay(this);
163
164 private ViewFilter viewFilter = new ViewFilter(this);
161 private final JScrollPane summaryHtmlScrollPane = new JScrollPane(summaryHtmlArea);
162
163 private final SourceCodeDisplay displayer = new SourceCodeDisplay(this);
164
165 private final ViewFilter viewFilter = new ViewFilter(this);
165166
166167 private SaveType saveType = SaveType.NOT_KNOWN;
167168
168 private MainFrameLoadSaveHelper mainFrameLoadSaveHelper = new MainFrameLoadSaveHelper(this);
169 private final MainFrameLoadSaveHelper mainFrameLoadSaveHelper = new MainFrameLoadSaveHelper(this);
169170
170171 final MainFrameTree mainFrameTree = new MainFrameTree(this);
171172
414415 * Opens the analysis. Also clears the source and summary panes. Makes
415416 * comments enabled false. Sets the saveType and adds the file to the recent
416417 * menu.
417 *
418 *
418419 * @param f
419420 * @return whether the operation was successful
420421 */
448449 setSaveFile(null);
449450 setProjectAndBugCollection(null, null);
450451 }
451
452
452453 @SwingThread
453454 void setBugCollection(BugCollection bugCollection) {
454455 setProjectAndBugCollection(bugCollection.getProject(), bugCollection);
474475 }
475476 acquireDisplayWait();
476477 try {
477
478
478479 if (this.bugCollection != bugCollection && this.bugCollection != null) {
479480 Cloud plugin = this.bugCollection.getCloud();
480481 if (plugin != null) {
803804 BugPattern bugPattern = bug.getBugPattern();
804805 String detailText =
805806 bugPattern.getDetailText()
806 +"<br><p> <b>Bug kind and pattern: " +
807 +"<br><p> <b>Bug kind and pattern: " +
807808 bugPattern.getAbbrev() + " - " + bugPattern.getType();
808809 String txt = bugPattern.getDetailHTML(detailText);
809810 summaryHtmlArea.setText(txt);
10221023
10231024 toggleItem.addActionListener(new ActionListener() {
10241025 public void actionPerformed(ActionEvent arg0) {
1025 comments.setDesignation(key);
1026 Cloud cloud = getBugCollection().getCloud();
1027 if (cloud instanceof DoNothingCloud) {
1028 JOptionPane.showMessageDialog(MainFrame.this, "No cloud selected; enable and select optional Bug Collection XML Pseudo-Cloud plugin to store designations in XML");
1029 } else if (comments.canSetDesignations())
1030 comments.setDesignation(key);
1031 else {
1032 JOptionPane.showMessageDialog(MainFrame.this, "The currently selected cloud cannot store these designations");
1033 }
10261034 }
10271035 });
10281036 MainFrameHelper.attachAcceleratorKey(toggleItem, keyEvent);
1414 import javax.swing.filechooser.FileFilter;
1515
1616 import edu.umd.cs.findbugs.BugCollection;
17 import edu.umd.cs.findbugs.BugInstance;
18 import edu.umd.cs.findbugs.HTMLBugReporter;
1719 import edu.umd.cs.findbugs.L10N;
1820 import edu.umd.cs.findbugs.Project;
1921 import edu.umd.cs.findbugs.ba.AnalysisContext;
22 import edu.umd.cs.findbugs.charsets.UTF8;
2023 import edu.umd.cs.findbugs.filter.Filter;
2124 import edu.umd.cs.findbugs.filter.Matcher;
2225
3942 saveOpenFileChooser.addChoosableFileFilter(FindBugsFBPFileFilter.INSTANCE);
4043 saveOpenFileChooser.addChoosableFileFilter(FindBugsFBAFileFilter.INSTANCE);
4144 saveOpenFileChooser.setFileFilter(FindBugsAnalysisFileFilter.INSTANCE);
45 saveOpenFileChooser.addChoosableFileFilter(FindBugsHtmlFileFilter.INSTANCE);
4246 filterOpenFileChooser = new FBFileChooser();
4347 filterOpenFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
4448 filterOpenFileChooser.setFileFilter(FindBugsFilterFileFilter.INSTANCE);
281285 int response = -1;
282286
283287 switch (fileType) {
284 case XML_ANALYSIS:
288 case HTML_OUTPUT:
289 response = JOptionPane.showConfirmDialog(saveOpenFileChooser,
290 L10N.getLocalString("dlg.analysis_exists_lbl", "This html output already exists.\nReplace it?"),
291 L10N.getLocalString("dlg.warning_ttl", "Warning!"), JOptionPane.OK_CANCEL_OPTION,
292 JOptionPane.WARNING_MESSAGE);
293 break;case XML_ANALYSIS:
285294 response = JOptionPane.showConfirmDialog(saveOpenFileChooser,
286295 L10N.getLocalString("dlg.analysis_exists_lbl", "This analysis already exists.\nReplace it?"),
287296 L10N.getLocalString("dlg.warning_ttl", "Warning!"), JOptionPane.OK_CANCEL_OPTION,
316325
317326 switch (fileType) {
318327
328 case HTML_OUTPUT:
329 successful = printHtml(f);
330 break;
319331 case XML_ANALYSIS:
320332 successful = saveAnalysis(f);
321333 break;
419431 return SaveReturn.SAVE_SUCCESSFUL;
420432 }
421433
434 SaveReturn printHtml(final File f) {
435
436 Future<Object> waiter = mainFrame.getBackgroundExecutor().submit(new Callable<Object>() {
437 public Object call() throws Exception {
438 HTMLBugReporter reporter = new HTMLBugReporter( mainFrame.getProject(), "default.xsl");
439 reporter.setIsRelaxed(true);
440 reporter.setOutputStream(UTF8.printStream(new FileOutputStream(f)));
441 for(BugInstance bug : mainFrame.getBugCollection().getCollection()) {
442 try {
443 if (mainFrame.getViewFilter().show(bug)) {
444 reporter.reportBug(bug);
445 }
446 } catch (Exception e) {
447 e.printStackTrace();
448 }
449 }
450 reporter.finish();
451 return null;
452 }
453 });
454 try {
455 waiter.get();
456 } catch (InterruptedException e) {
457 return SaveReturn.SAVE_ERROR;
458 } catch (ExecutionException e) {
459 return SaveReturn.SAVE_ERROR;
460 }
461
462 return SaveReturn.SAVE_SUCCESSFUL;
463 }
464
422465 /**
423466 * Save current analysis as file passed in. Return SAVE_SUCCESSFUL if save
424467 * successful. Method doesn't do much. This method is more if need to do
204204 for (CloudPlugin c : DetectorFactoryCollection.instance().getRegisteredClouds().values()) {
205205 String fbid = c.getFindbugsPluginId();
206206 Plugin plugin = Plugin.getByPluginId(fbid);
207 if (plugin == null)
207 if (plugin == null)
208208 continue;
209209 Boolean fbPluginStatus = project.getPluginStatus(plugin);
210210 if ((!c.isHidden() || c.getId().equals(cloudId)) && !Boolean.FALSE.equals(fbPluginStatus))
275275 if (keepGoing) {
276276 mainFrame.setProject(p);
277277 }
278 if (projectChanged && (isNewProject
278 if (projectChanged && (isNewProject
279279 || JOptionPane.showConfirmDialog(NewProjectWizard.this, edu.umd.cs.findbugs.L10N
280280 .getLocalString("dlg.project_settings_changed_lbl",
281281 "Project settings have been changed. Perform a new analysis with the changed files?"),
282282 edu.umd.cs.findbugs.L10N.getLocalString("dlg.redo_analysis_question_lbl", "Redo analysis?"),
283283 JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
284 new AnalyzingDialog(p);
284 AnalyzingDialog.show(p);
285285 } else if (!Util.nullSafeEquals(newCloudId, oldCloudId)) {
286286 BugCollection bugs = mainFrame.getBugCollection();
287287 try {
2323 import edu.umd.cs.findbugs.util.Util;
2424
2525 enum SaveType {
26 NOT_KNOWN, XML_ANALYSIS, FBP_FILE, FBA_FILE;
26 NOT_KNOWN, HTML_OUTPUT, XML_ANALYSIS, FBP_FILE, FBA_FILE;
2727 public FindBugsFileFilter getFilter() {
2828 switch (this) {
2929 case XML_ANALYSIS:
3030 return FindBugsAnalysisFileFilter.INSTANCE;
31 case FBP_FILE:
31 case HTML_OUTPUT:
32 return FindBugsHtmlFileFilter.INSTANCE;
33 case FBP_FILE:
3234 return FindBugsFBPFileFilter.INSTANCE;
3335 case FBA_FILE:
3436 return FindBugsFBAFileFilter.INSTANCE;
4850 public String getFileExtension() {
4951 switch (this) {
5052
53 case HTML_OUTPUT:
54 return ".html";
5155 case XML_ANALYSIS:
5256 return ".xml";
5357 case FBP_FILE:
6266 public static SaveType forFile(File f) {
6367 String extension = Util.getFileExtension(f);
6468
69 if (extension.equals("html") || extension.equals("htm"))
70 return HTML_OUTPUT;
71 if (extension.equals("fba"))
72 return FBA_FILE;
6573 if (extension.equals("fbp"))
6674 return FBP_FILE;
67 if (extension.equals("fba"))
68 return FBA_FILE;
6975 if (extension.equals("xml"))
76 return XML_ANALYSIS;
77 if (extension.equals("html"))
7078 return XML_ANALYSIS;
7179 if (f.getName().toLowerCase().endsWith("xml.gz"))
7280 return XML_ANALYSIS;
101101 if (appVersion != null) {
102102 String timestamp = new Timestamp(appVersion.getTimestamp()).toString();
103103 return appVersion.getReleaseName() + " (" + timestamp.substring(0, timestamp.indexOf(' ')) + ")";
104 } else
104 } else
105105 return "#" + seqNum;
106106 }
107107
152152 return 0;
153153
154154 // Numerical (except that -1 is last)
155 int first = Integer.valueOf(one);
156 int second = Integer.valueOf(two);
155 int first = Integer.parseInt(one);
156 int second = Integer.parseInt(two);
157157 if (first == second)
158158 return 0;
159159 if (first < 0)
2121 import java.text.CharacterIterator;
2222 import java.util.HashSet;
2323
24 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
25
2426 public class JavaScanner {
2527 public final static int NORMAL_TEXT = 0;
2628
3436
3537 public final static int EOF = -1;
3638
39 @StaticConstant
3740 private final static HashSet<String> KEYWORDS = new HashSet<String>();
3841
3942 private final static int MAX_KEYWORD_LENGTH;
7575 super(title, true);
7676 addItemListener(this);
7777 this.view = view;
78 // view.addListener(new Listener());
78 // view.addListener(new Listener());
7979 }
8080
8181 // Menu item has been checked or unchecked
8787 view.close();
8888 }
8989
90 // private class Listener extends DockingWindowAdapter
91 // {
92 // @Override
93 // public void windowAdded(DockingWindow addedToWindow, DockingWindow addedWindow)
94 // {
95 // if (addedWindow.equals(view))
96 // ViewMenuItem.this.setSelected(true);
97 // }
90 // private class Listener extends DockingWindowAdapter
91 // {
92 // @Override
93 // public void windowAdded(DockingWindow addedToWindow, DockingWindow addedWindow)
94 // {
95 // if (addedWindow.equals(view))
96 // ViewMenuItem.this.setSelected(true);
97 // }
9898 //
99 // @Override
100 // public void windowRemoved(DockingWindow removedFromWindow, DockingWindow removedWindow)
101 // {
102 // if (removedWindow.equals(view))
103 // ViewMenuItem.this.setSelected(false);
104 // }
105 // }
99 // @Override
100 // public void windowRemoved(DockingWindow removedFromWindow, DockingWindow removedWindow)
101 // {
102 // if (removedWindow.equals(view))
103 // ViewMenuItem.this.setSelected(false);
104 // }
105 // }
106106 }
107107 private View commentsView = null;
108108 final MainFrame frame;
157157 tabs = new TabWindow(new DockingWindow[]{summaryView, commentsView, sourceView});
158158 tabs.addListener(new DockParentListener());
159159 tabs.setSelectedTab(0);
160 // tabs.getWindowProperties().setCloseEnabled(false);
160 // tabs.getWindowProperties().setCloseEnabled(false);
161161
162162 rootWindow.setWindow(new SplitWindow(false, 0.4f, topView, tabs));
163163
114114
115115 private int rankThreshold;
116116
117 private boolean analysisUnderway, relaxed;
117 private boolean relaxedSet, relaxed;
118118
119119 private int errorCount;
120120
134134 observerList = new LinkedList<BugReporterObserver>();
135135 projectStats = new ProjectStats();
136136 // bug 2815983: no bugs are reported anymore
137 // there is no info which value should be default, so using the
138 // "any one"
139 rankThreshold = 42;
137 // there is no info which value should be default, so using the max
138 rankThreshold = BugRanker.VISIBLE_RANK_MAX;
140139 }
141140
142141 public void setErrorVerbosity(int level) {
150149 public void setRankThreshold(int threshold) {
151150 this.rankThreshold = threshold;
152151 }
153
152
153 public void setIsRelaxed(boolean relaxed) {
154 this.relaxed = relaxed;
155 this.relaxedSet = true;
156 }
157
158 protected boolean isRelaxed() {
159 if (!relaxedSet) {
160 if (FindBugsAnalysisFeatures.isRelaxedMode()) {
161 relaxed = true;
162 }
163
164 relaxedSet = true;
165 }
166 return relaxed;
167 }
154168 // Subclasses must override doReportBug(), not this method.
155169 public final void reportBug(@Nonnull BugInstance bugInstance) {
170 if (isRelaxed()) {
171 doReportBug(bugInstance);
172 return;
173 }
156174 if (priorityThreshold == 0) {
157175 throw new IllegalStateException("Priority threshold not set");
158176 }
159 if (!analysisUnderway) {
160 if (FindBugsAnalysisFeatures.isRelaxedMode()) {
161 relaxed = true;
162 }
163
164 analysisUnderway = true;
165 }
177
166178 ClassAnnotation primaryClass = bugInstance.getPrimaryClass();
167179 if (primaryClass != null && !AnalysisContext.currentAnalysisContext().isApplicationClass(primaryClass.getClassName())) {
168180 if (DEBUG) {
172184 }
173185 int priority = bugInstance.getPriority();
174186 int bugRank = bugInstance.getBugRank();
175 if (priority <= priorityThreshold && bugRank <= rankThreshold || relaxed) {
187 if (priority <= priorityThreshold && bugRank <= rankThreshold) {
176188 doReportBug(bugInstance);
177189 } else {
178190 if (DEBUG) {
2323
2424 import org.dom4j.DocumentException;
2525
26 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2727
2828 /**
2929 * Add an annotation string to every BugInstance in a BugCollection.
7070 }
7171 }
7272
73 @SuppressWarnings("DM_EXIT")
73 @SuppressFBWarnings("DM_EXIT")
7474 public static void main(String[] argv) throws Exception {
7575 if (argv.length != 2) {
7676 System.err.println("Usage: " + AddAnnotation.class.getName() + " <results file> <annotation>");
2929 import org.dom4j.io.OutputFormat;
3030 import org.dom4j.io.XMLWriter;
3131
32 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3333 import edu.umd.cs.findbugs.xml.XMLUtil;
3434
3535 /**
164164 }
165165 }
166166
167 @SuppressWarnings("DM_EXIT")
167 @SuppressFBWarnings("DM_EXIT")
168168 public static void main(String[] args) throws Exception {
169169 if (args.length != 2) {
170170 System.err.println("Usage: " + AddMessages.class.getName() + " <input collection> <output collection>");
2323 import java.util.LinkedHashSet;
2424 import java.util.Map;
2525
26 import javax.annotation.CheckForNull;
27
2628 import org.apache.bcel.classfile.Method;
2729 import org.apache.bcel.generic.MethodGen;
2830
4850
4951 private final HashMap<String, BugInstance> hashes = new HashMap<String, BugInstance>();
5052
53 private BugInstance lastBug;
54 private SourceLineAnnotation lastSourceLine;
5155 static class Data {
5256 public Data(int priority, SourceLineAnnotation primarySource) {
5357 this.priority = priority;
7377 performAccumulation = AnalysisContext.currentAnalysisContext().getBoolProperty(AnalysisFeatures.MERGE_SIMILAR_WARNINGS);
7478 }
7579
80 public @CheckForNull
81 SourceLineAnnotation getLastBugLocation() {
82 return lastSourceLine;
83 }
84
85 public void forgetLastBug() {
86 Data d = map.get(lastBug);
87 if (d != null) {
88
89 d.allSource.remove(lastSourceLine);
90 if (d.allSource.isEmpty()) {
91 map.remove(lastBug);
92 hashes.remove(lastBug.getInstanceHash());
93 }
94 }
95 lastBug = null;
96 lastSourceLine = null;
97 }
7698 /**
7799 * Accumulate a warning at given source location.
78100 *
84106 public void accumulateBug(BugInstance bug, SourceLineAnnotation sourceLine) {
85107 if (sourceLine == null)
86108 throw new NullPointerException("Missing source line");
87 if (!performAccumulation) {
88 reporter.reportBug(bug.addSourceLine(sourceLine));
89 return;
90 }
91
92109 int priority = bug.getPriority();
93 bug.setPriority(Priorities.NORMAL_PRIORITY);
110 if (!performAccumulation)
111 bug.addSourceLine(sourceLine);
112 else
113 bug.setPriority(Priorities.NORMAL_PRIORITY);
114
115 lastBug = bug;
116 lastSourceLine = sourceLine;
94117 Data d = map.get(bug);
95118 if (d == null) {
96119 String hash = bug.getInstanceHash();
129152
130153 public Iterable<? extends BugInstance> uniqueBugs() {
131154 return map.keySet();
155
132156 }
133157
134158 public Iterable<? extends SourceLineAnnotation> locations(BugInstance bug) {
165189 public void clearBugs() {
166190 map.clear();
167191 hashes.clear();
168 }
169
170 /**
171 * @param bug
172 * @param classContext
173 * @param method
174 * @param location
175 */
192 lastBug = null;
193 lastSourceLine = null;
194 }
195
176196 public void accumulateBug(BugInstance bug, ClassContext classContext, Method method, Location location) {
177197 accumulateBug(bug, SourceLineAnnotation.fromVisitedInstruction(classContext, method, location));
178198
179199 }
180200
181 /**
182 * @param bug
183 * @param classContext
184 * @param methodGen
185 * @param sourceFile
186 * @param location
187 */
188201 public void accumulateBug(BugInstance bug, ClassContext classContext, MethodGen methodGen, String sourceFile,
189202 Location location) {
190203 accumulateBug(bug, SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, location.getHandle()));
6868 import edu.umd.cs.findbugs.ba.XMethod;
6969 import edu.umd.cs.findbugs.ba.bcp.FieldVariable;
7070 import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
71 import edu.umd.cs.findbugs.bcel.BCELUtil;
7172 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
7273 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
7374 import edu.umd.cs.findbugs.classfile.FieldDescriptor;
134135
135136 private int instanceOccurrenceMax;
136137
138 @CheckForNull
137139 private DetectorFactory detectorFactory;
138140
139141 private final AtomicReference<XmlProps> xmlProps = new AtomicReference<XmlProps>();
258260 * @param detectorName
259261 */
260262 public void adjustForDetector(String detectorName) {
261 detectorFactory = DetectorFactoryCollection.instance().getFactoryByClassName(detectorName);
262 if (detectorFactory != null) {
263 this.priority += detectorFactory.getPriorityAdjustment();
263 DetectorFactory factory = DetectorFactoryCollection.instance().getFactoryByClassName(detectorName);
264 detectorFactory = factory;
265 if (factory != null) {
266 this.priority += factory.getPriorityAdjustment();
264267 boundPriority();
265268 BugPattern bugPattern = getBugPattern();
266269 if (SystemProperties.ASSERTIONS_ENABLED && !bugPattern.getCategory().equals("EXPERIMENTAL")
267 && !detectorFactory.getReportedBugPatterns().contains(bugPattern))
268 AnalysisContext.logError(detectorFactory.getShortName() + " doesn't note that it reports "
270 && !factory.getReportedBugPatterns().contains(bugPattern)) {
271 AnalysisContext.logError(factory.getShortName() + " doesn't note that it reports "
269272 + bugPattern + " in category " + bugPattern.getCategory());
273 }
270274 }
271275 }
272276
425429 */
426430 public boolean isExperimental() {
427431 BugPattern pattern = getBugPattern();
428 return (pattern != null) && pattern.isExperimental();
432 return pattern.isExperimental();
429433 }
430434
431435 /**
432436 * Get the primary class annotation, which indicates where the bug occurs.
433437 */
434438 public ClassAnnotation getPrimaryClass() {
435 ClassAnnotation result = findPrimaryAnnotationOfType(ClassAnnotation.class);
436 if (result == null) {
437 System.out.println("huh");
438 result = findPrimaryAnnotationOfType(ClassAnnotation.class);
439 }
440 return result;
439 return findPrimaryAnnotationOfType(ClassAnnotation.class);
441440 }
442441
443442 /**
10941093 public BugInstance addClassAndMethod(MethodGen methodGen, String sourceFile) {
10951094 addClass(methodGen.getClassName());
10961095 addMethod(methodGen, sourceFile);
1097 if (methodGen.isSynthetic())
1096 if (BCELUtil.isSynthetic(methodGen))
10981097 foundInSyntheticMethod();
10991098 return this;
11001099 }
11121111 public BugInstance addClassAndMethod(JavaClass javaClass, Method method) {
11131112 addClass(javaClass.getClassName());
11141113 addMethod(javaClass, method);
1115 if (method.isSynthetic())
1114
1115 if (BCELUtil.isSynthetic(method))
11161116 foundInSyntheticMethod();
11171117 return this;
11181118 }
21472147 writeXML(xmlOutput, null, false);
21482148 }
21492149
2150 public int getCWEid() {
2151 BugPattern pattern = getBugPattern();
2152
2153 int cweid = pattern.getCWEid();
2154 if (cweid != 0)
2155 return cweid;
2156 BugCode bugCode = pattern.getBugCode();
2157 return bugCode.getCWEid();
2158 }
21502159 public void writeXML(XMLOutput xmlOutput, BugCollection bugCollection, boolean addMessages) throws IOException {
21512160 XMLAttributeList attributeList = new XMLAttributeList().addAttribute("type", type).addAttribute("priority",
21522161 String.valueOf(priority));
21532162
21542163 BugPattern pattern = getBugPattern();
2155 if (pattern != null) {
2156 // The bug abbreviation and pattern category are
2157 // emitted into the XML for informational purposes only.
2158 // (The information is redundant, but might be useful
2159 // for processing tools that want to make sense of
2160 // bug instances without looking at the plugin descriptor.)
2161 attributeList.addAttribute("abbrev", pattern.getAbbrev());
2162 attributeList.addAttribute("category", pattern.getCategory());
2163 }
2164
2165 // The bug abbreviation and pattern category are
2166 // emitted into the XML for informational purposes only.
2167 // (The information is redundant, but might be useful
2168 // for processing tools that want to make sense of
2169 // bug instances without looking at the plugin descriptor.)
2170 attributeList.addAttribute("abbrev", pattern.getAbbrev());
2171 attributeList.addAttribute("category", pattern.getCategory());
21642172
21652173 if (addMessages) {
21662174 // Add a uid attribute, if we have a unique id.
21692177 attributeList.addAttribute("instanceOccurrenceNum", Integer.toString(getInstanceOccurrenceNum()));
21702178 attributeList.addAttribute("instanceOccurrenceMax", Integer.toString(getInstanceOccurrenceMax()));
21712179 attributeList.addAttribute("rank", Integer.toString(getBugRank()));
2180
2181 int cweid = getCWEid();
2182 if (cweid != 0)
2183 attributeList.addAttribute("cweid", Integer.toString(cweid));
2184
21722185
21732186 } else if (oldInstanceHash != null && !isInstanceHashConsistent()) {
21742187 attributeList.addAttribute("oldInstanceHash", oldInstanceHash);
23442357
23452358 public BugInstance addSomeSourceForTopTwoStackValues(ClassContext classContext, Method method, Location location) {
23462359 int pc = location.getHandle().getPosition();
2347 OpcodeStack stack = OpcodeStackScanner.getStackAt(classContext.getJavaClass(), method, pc);
2348 BugAnnotation a1 = getSomeSource(classContext, method, location, stack, 1);
2349 BugAnnotation a0 = getSomeSource(classContext, method, location, stack, 0);
2350 addOptionalUniqueAnnotations(a0, a1);
2351
2360 try {
2361 OpcodeStack stack = OpcodeStackScanner.getStackAt(classContext.getJavaClass(), method, pc);
2362 BugAnnotation a1 = getSomeSource(classContext, method, location, stack, 1);
2363 BugAnnotation a0 = getSomeSource(classContext, method, location, stack, 0);
2364 addOptionalUniqueAnnotations(a0, a1);
2365 } catch (UnreachableCodeException e) {
2366 if (SystemProperties.ASSERTIONS_ENABLED) {
2367 AnalysisContext.logError(e.getMessage(), e);
2368 }
2369 assert true;
2370 }
23522371 return this;
23532372
23542373 }
24452464 add(a);
24462465 return this;
24472466 }
2467
2468 public boolean tryAddingOptionalUniqueAnnotations(BugAnnotation... annotations) {
2469 HashSet<BugAnnotation> added = new HashSet<BugAnnotation>();
2470 for (BugAnnotation a : annotations)
2471 if (a != null && added.add(a))
2472 add(a);
2473 return !added.isEmpty();
2474 }
2475
24482476
24492477 public BugInstance addOptionalUniqueAnnotationsWithFallback(BugAnnotation fallback, BugAnnotation... annotations) {
24502478 HashSet<BugAnnotation> added = new HashSet<BugAnnotation>();
27182746 return instanceOccurrenceMax;
27192747 }
27202748
2749 @CheckForNull
27212750 public DetectorFactory getDetectorFactory() {
27222751 return detectorFactory;
27232752 }
1717 */
1818
1919 package edu.umd.cs.findbugs;
20
21 import javax.annotation.Nonnull;
2022
2123 import edu.umd.cs.findbugs.util.HTML;
2224
128130 }
129131
130132 /**
133 * Get the BugCode
134 */
135 public @Nonnull BugCode getBugCode() {
136 return DetectorFactoryCollection.instance().getBugCode(abbrev);
137
138 }
139 /**
131140 * Get the BugCategory
132141 */
133142 public String getCategory() {
216225
217226
218227 public String wrapInDescriptionLink(String text) {
219 return
228 if (isExperimental())
229 return
230 "<a href=\"http://findbugs.sourceforge.net/allBugDescriptions.html#"
231 + type +"\">"
232 + text + "</a>";
233 return
220234 "<a href=\"http://findbugs.sourceforge.net/bugDescriptions.html#"
221235 + type +"\">"
222236 + text + "</a>";
1818
1919 package edu.umd.cs.findbugs;
2020
21 import javax.annotation.Nonnull;
22
23 /**
24 * Smaller value is scarier
25 *
26 * @see BugRanker
27 * @see edu.umd.cs.findbugs.annotations.Confidence
28 */
2129 public enum BugRankCategory {
30
2231 SCARIEST(4), SCARY(9), TROUBLING(14), OF_CONCERN(BugRanker.VISIBLE_RANK_MAX);
32
2333 public final int maxRank;
34
35 @Nonnull
2436 static public BugRankCategory getRank(int rank) {
2537 for(BugRankCategory c : values()) {
2638 if (rank <= c.maxRank) {
7777 * categories are defined by the core bug ranker, we should always find an
7878 * absolute bug rank.
7979 *
80 *
80 * @see BugRankCategory
81 * @see Priorities
82 * @see edu.umd.cs.findbugs.annotations.Confidence
8183 *
8284 * @author Bill Pugh
8385 */
8486 public class BugRanker {
85 /** Maximum value for user visible ranks */
87 /** Maximum value for user visible ranks (least relevant) */
8688 public static final int VISIBLE_RANK_MAX = 20;
87 /** Minimum value for user visible ranks */
89 /** Minimum value for user visible ranks (most relevant) */
8890 public static final int VISIBLE_RANK_MIN = 1;
8991
9092 static final boolean PLUGIN_DEBUG = Boolean.getBoolean("bugranker.plugin.debug");
226226 */
227227 public boolean isReportingDetector() {
228228 return !isDetectorClassSubtypeOf(TrainingDetector.class) && !isDetectorClassSubtypeOf(FirstPassDetector.class);
229
230 }
231
229 }
230
231
232232 /**
233233 * Check to see if we are running on a recent-enough JRE for this detector
234234 * to be enabled.
555555 * the short bug type code
556556 * @return the description of that short bug type code means
557557 */
558 public BugCode getBugCode(String shortBugType) {
558 public @Nonnull BugCode getBugCode(String shortBugType) {
559559 BugCode bugCode = lookupBugCode(shortBugType);
560560 if (bugCode == null)
561561 throw new IllegalArgumentException("Error: missing bug code for key" + shortBugType);
566566 * @param shortBugType the short bug type code
567567 * @return the description of that short bug type code means
568568 */
569 public BugCode lookupBugCode(String shortBugType) {
569 public @CheckForNull BugCode lookupBugCode(String shortBugType) {
570570 return bugCodeMap.get(shortBugType);
571571 }
572572
4949 * and a "root" source directory (under which some number of "real" source
5050 * directories may be located), scan to find the source directories containing
5151 * the application's source files.
52 *
52 *
5353 * @author David Hovemeyer
5454 */
5555 public class DiscoverSourceDirectories {
9191
9292 public void reportSkippedAnalysis(MethodDescriptor method) {
9393 }
94 };
94 }
9595
9696 private static class NoOpProgress implements Progress {
9797 public void startScanningArchives(int numArchivesToScan) {
133133
134134 private Progress progress;
135135
136 private List<String> discoveredSourceDirectoryList;
136 private final List<String> discoveredSourceDirectoryList;
137137
138138 /**
139139 * Constructor.
146146
147147 /**
148148 * Set the Project for which we want to find source directories.
149 *
149 *
150150 * @param project
151151 * Project for which we want to find source directories
152152 */
157157 /**
158158 * Set the "root" source directory: we expect all of the actual source
159159 * directories to be underneath it.
160 *
160 *
161161 * @param rootSourceDirectory
162162 * the root source directory
163163 */
169169 * Set whether or not to scan the project for nested archives (i.e., if
170170 * there is a WAR or EAR file that contains jar files inside it.) Default is
171171 * false.
172 *
172 *
173173 * @param scanForNestedArchives
174174 * true if nested archives should be scanned, false otherwise
175175 */
180180 /**
181181 * Set the error logger to use to report errors during scanning. By default,
182182 * a no-op error logger is used.
183 *
183 *
184184 * @param errorLogger
185185 * error logger to use to report errors during scanning
186186 */
190190
191191 /**
192192 * Set the progress callback to which scanning progress should be reported.
193 *
193 *
194194 * @param progress
195195 * the progress callback
196196 */
201201 /**
202202 * Get the list of discovered source directories. These can be added to a
203203 * Project.
204 *
204 *
205205 * @return list of discovered source directories.
206206 */
207207 public List<String> getDiscoveredSourceDirectoryList() {
210210
211211 /**
212212 * Execute the search for source directories.
213 *
213 *
214214 * @throws edu.umd.cs.findbugs.classfile.CheckedAnalysisException
215215 * @throws java.io.IOException
216216 * @throws java.lang.InterruptedException
3636 import edu.umd.cs.findbugs.ba.SourceInfoMap;
3737 import edu.umd.cs.findbugs.ba.XFactory;
3838 import edu.umd.cs.findbugs.ba.XField;
39 import edu.umd.cs.findbugs.ba.XMethod;
4039 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
4140 import edu.umd.cs.findbugs.classfile.FieldDescriptor;
4241 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
43 import edu.umd.cs.findbugs.util.ClassName;
4442 import edu.umd.cs.findbugs.visitclass.DismantleBytecode;
4543 import edu.umd.cs.findbugs.visitclass.PreorderVisitor;
4644 import edu.umd.cs.findbugs.xml.XMLAttributeList;
3030
3131 import org.dom4j.DocumentException;
3232
33 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
33 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3434 import edu.umd.cs.findbugs.ba.AnalysisContext;
3535 import edu.umd.cs.findbugs.ba.AnalysisFeatures;
3636 import edu.umd.cs.findbugs.config.AnalysisFeatureSetting;
3737 import edu.umd.cs.findbugs.config.CommandLine.HelpRequestedException;
3838 import edu.umd.cs.findbugs.filter.Filter;
3939 import edu.umd.cs.findbugs.filter.FilterException;
40 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
4041 import edu.umd.cs.findbugs.updates.UpdateChecker;
4142 import edu.umd.cs.findbugs.updates.UpdateChecker.PluginUpdate;
4243 import edu.umd.cs.findbugs.util.FutureValue;
167168 public static boolean isNoMains() {
168169 return noMains;
169170 }
170
171
171172 public static final Logger LOGGER = Logger.getLogger(FindBugs.class.getPackage().getName());
172173
173174 static {
178179 * Known URL protocols. Filename URLs that do not have an explicit protocol
179180 * are assumed to be files.
180181 */
182 @StaticConstant
181183 static public final Set<String> knownURLProtocolSet = new HashSet<String>();
182184 static {
183185 knownURLProtocolSet.add("file");
361363 *
362364 * @param commandLine
363365 */
364 @SuppressWarnings("DM_EXIT")
366 @SuppressFBWarnings("DM_EXIT")
365367 public static void showHelp(TextUICommandLine commandLine) {
366368 showSynopsis();
367369 ShowHelp.showGeneralOptions();
378380 * @param commandLine
379381 * the TextUICommandLine used to configure the IFindBugsEngine
380382 */
381 @SuppressWarnings("DM_EXIT")
383 @SuppressFBWarnings("DM_EXIT")
382384 public static void runMain(IFindBugsEngine findBugs, TextUICommandLine commandLine) throws IOException {
383385 boolean verbose = !commandLine.quiet() || commandLine.setExitCode();
384
385 FutureValue<Collection<UpdateChecker.PluginUpdate>>
386
387 FutureValue<Collection<UpdateChecker.PluginUpdate>>
386388 updateHolder = null;
387389 if (verbose)
388390 updateHolder = DetectorFactoryCollection.instance().getUpdates();
421423 } catch (InterruptedException e) {
422424 assert true;
423425 }
424
426
425427 }
426428 }
427429
2828 import java.util.LinkedHashSet;
2929 import java.util.LinkedList;
3030 import java.util.List;
31 import java.util.Map;
3132 import java.util.Map.Entry;
3233 import java.util.Set;
3334
3839 import org.dom4j.DocumentException;
3940
4041 import edu.umd.cs.findbugs.asm.FBClassReader;
41 import edu.umd.cs.findbugs.ba.AnalysisCacheToAnalysisContextAdapter;
4242 import edu.umd.cs.findbugs.ba.AnalysisContext;
4343 import edu.umd.cs.findbugs.ba.AnalysisFeatures;
4444 import edu.umd.cs.findbugs.ba.ObjectTypeFactory;
6161 import edu.umd.cs.findbugs.classfile.IClassPath;
6262 import edu.umd.cs.findbugs.classfile.IClassPathBuilder;
6363 import edu.umd.cs.findbugs.classfile.ICodeBase;
64 import edu.umd.cs.findbugs.classfile.ICodeBaseEntry;
6465 import edu.umd.cs.findbugs.classfile.MissingClassException;
65 import edu.umd.cs.findbugs.classfile.analysis.MethodInfo;
6666 import edu.umd.cs.findbugs.classfile.impl.ClassFactory;
6767 import edu.umd.cs.findbugs.config.AnalysisFeatureSetting;
6868 import edu.umd.cs.findbugs.config.UserPreferences;
196196 Profiler profiler = bugReporter.getProjectStats().getProfiler();
197197
198198 try {
199 try {
199200 // Get the class factory for creating classpath/codebase/etc.
200201 classFactory = ClassFactory.instance();
201202
266267 }
267268
268269 if (appClassList.size() == 0) {
270 Map<String, ICodeBaseEntry> codebase = classPath.getApplicationCodebaseEntries();
269271 if (analysisOptions.noClassOk) {
270272 System.err.println("No classfiles specified; output will have no warnings");
273 } else if (codebase.isEmpty()) {
274 throw new IOException("No files to analyze could be opened");
271275 } else {
272276 throw new NoClassesFoundToAnalyzeException(classPath);
273277 }
296300 profiler.end(this.getClass());
297301 profiler.report();
298302 }
303 } catch (IOException e) {
304 bugReporter.reportQueuedErrors();
305 throw e;
306 }
299307 }
300308
301309 /**
310318 // Make sure the codebases on the classpath are closed
311319 AnalysisContext.removeCurrentAnalysisContext();
312320 Global.removeAnalysisCacheForCurrentThread();
313 MethodInfo.clearCaches();
314321 if (classPath != null) {
315322 classPath.close();
316323 }
559566 }
560567
561568 protected void configureFilters(UserPreferences userPreferences) {
569 IllegalArgumentException deferredError = null;
562570 Set<Entry<String, Boolean>> excludeBugFiles = userPreferences.getExcludeBugsFiles().entrySet();
563571 for (Entry<String, Boolean> entry : excludeBugFiles) {
564572 if (entry.getValue() == null || !entry.getValue()) {
570578 String message = "Unable to read filter: " + entry.getKey() + " : " + e.getMessage();
571579 if (getBugReporter() != null) {
572580 getBugReporter().logError(message, e);
573 } else {
574 throw new IllegalArgumentException(message, e);
581 } else if (deferredError == null){
582 deferredError = new IllegalArgumentException(message, e);
575583 }
576584 }
577585 }
586594 String message = "Unable to read filter: " + entry.getKey() + " : " + e.getMessage();
587595 if (getBugReporter() != null) {
588596 getBugReporter().logError(message, e);
589 } else {
590 throw new IllegalArgumentException(message, e);
597 } else if (deferredError == null){
598 deferredError = new IllegalArgumentException(message, e);
591599 }
592600 }
593601 }
594602 Set<Entry<String, Boolean>> excludeFilterFiles = userPreferences.getExcludeFilterFiles().entrySet();
603
595604 for (Entry<String, Boolean> entry : excludeFilterFiles) {
596605 Boolean value = entry.getValue();
597606 if (value == null || !value) {
604613 String message = "Unable to read filter: " + excludeFilterFile + " : " + e.getMessage();
605614 if (getBugReporter() != null) {
606615 getBugReporter().logError(message, e);
607 } else {
608 throw new IllegalArgumentException(message, e);
609 }
610 }
611 }
616 } else if (deferredError == null){
617 deferredError = new IllegalArgumentException(message, e);
618 }
619 }
620 }
621 if (deferredError != null)
622 throw deferredError;
612623 }
613624
614625 /*
766777 private void buildClassPath() throws InterruptedException, IOException, CheckedAnalysisException {
767778 IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter);
768779
780 {
781 HashSet<String> seen = new HashSet<String>();
769782 for (String path : project.getFileArray()) {
783 if (seen.add(path))
770784 builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), true);
771785 }
772786 for (String path : project.getAuxClasspathEntryList()) {
787 if (seen.add(path))
773788 builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), false);
789 }
774790 }
775791
776792 builder.scanNestedArchives(analysisOptions.scanNestedArchives);
956972 @SuppressWarnings({"UnusedDeclaration"})
957973 public static void createAnalysisContext(Project project, List<ClassDescriptor> appClassList,
958974 @CheckForNull String sourceInfoFileName) throws IOException {
959 AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter();
975 AnalysisContext analysisContext = new AnalysisContext();
960976
961977 // Make this the current analysis context
962978 AnalysisContext.setCurrentAnalysisContext(analysisContext);
974990 }
975991
976992 public static void setAppClassList(List<ClassDescriptor> appClassList) {
977 AnalysisCacheToAnalysisContextAdapter analysisContext = (AnalysisCacheToAnalysisContextAdapter) AnalysisContext
993 AnalysisContext analysisContext = AnalysisContext
978994 .currentAnalysisContext();
979995
980996 analysisContext.setAppClassList(appClassList);
11491165 classCollection.size(), classDescriptor);
11501166 }
11511167 count++;
1168 if (!isNonReportingFirstPass && count % 1000 == 0)
1169 yourkitController.advanceGeneration(String.format("Pass %d.%02d", passCount, count/1000));
1170
11521171
11531172 // Check to see if class is excluded by the class screener.
11541173 // In general, we do not want to screen classes from the
174174 }
175175
176176 /**
177 * Wrapper so that possbile NoClassDefFoundError can be caught.
177 * Wrapper so that possible NoClassDefFoundError can be caught.
178178 * Instantiating this class will throw a NoClassDefFoundError on JDK 1.4 and
179179 * earlier, or will throw a ClassCastException on a 1.5-compliant non-sun
180180 * JRE where the osBean is not a sunBean. (If compiled by Eclipse,
2323 import java.util.Iterator;
2424 import java.util.NoSuchElementException;
2525
26 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
2627 import edu.umd.cs.findbugs.model.ClassNameRewriter;
2728
2829 /**
3536 * changes (e.g., "definitely null" to "null on simple path" for a null pointer
3637 * dereference). Also, we often change bug types between different versions of
3738 * FindBugs.
38 *
39 *
3940 * @see edu.umd.cs.findbugs.BugInstance
4041 * @see edu.umd.cs.findbugs.VersionInsensitiveBugComparator
4142 * @author David Hovemeyer
7576
7677 /*
7778 * (non-Javadoc)
78 *
79 *
7980 * @see java.util.Iterator#hasNext()
8081 */
8182 public boolean hasNext() {
8586
8687 /*
8788 * (non-Javadoc)
88 *
89 *
8990 * @see java.util.Iterator#next()
9091 */
9192 public BugAnnotation next() {
99100
100101 /*
101102 * (non-Javadoc)
102 *
103 *
103104 * @see java.util.Iterator#remove()
104105 */
105106 public void remove() {
111112 * Keep track of which BugCollections the various BugInstances have come
112113 * from.
113114 */
114 private IdentityHashMap<BugInstance, BugCollection> bugCollectionMap;
115 private final IdentityHashMap<BugInstance, BugCollection> bugCollectionMap;
115116
116117 private ClassNameRewriter classNameRewriter;
117118
132133 /**
133134 * Register a BugCollection. This allows us to find the class and method
134135 * hashes for BugInstances to be compared.
135 *
136 *
136137 * @param bugCollection
137138 * a BugCollection
138139 */
142143
143144 /*
144145 * (non-Javadoc)
145 *
146 *
146147 * @see
147148 * edu.umd.cs.findbugs.WarningComparator#setClassNameRewriter(edu.umd.cs
148149 * .findbugs.model.MovedClassMap)
301302
302303 /**
303304 * Compare source line annotations.
304 *
305 *
305306 * @param rhsCollection
306307 * lhs BugCollection
307308 * @param lhsCollection
327328 }
328329
329330 // See "FindBugsAnnotationDescriptions.properties"
331 @StaticConstant
330332 private static final HashSet<String> significantDescriptionSet = new HashSet<String>();
331333 static {
332334 // Classes, methods, and fields are significant.
3434 private final String rest;
3535
3636 /**
37 * Constant for the Java version we're currently running on.
37 * StaticConstant for the Java version we're currently running on.
3838 */
3939 private static JavaVersion runtimeVersion;
4040
5050 }
5151
5252 /**
53 * Constant for Java 1.5 (Tiger).
53 * StaticConstant for Java 1.5 (Tiger).
5454 */
5555 public static final JavaVersion JAVA_1_5 = new JavaVersion(1, 5);
5656
2323 import java.util.HashMap;
2424 import java.util.Map;
2525
26 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
27
2628 /**
2729 * Class to launch the appropriate textUI or GUI. This class is the Main-Class
2830 * in the findbugs.jar manifest, and is responsible for running an appropriate
2931 * main() method.
30 *
32 *
3133 * @author Bill Pugh
3234 * @author David Hovemeyer
3335 */
6062 /**
6163 * Map of UI name strings to integer UI codes.
6264 */
65 @StaticConstant
6366 public static final Map<String, Integer> uiNameToCodeMap;
6467 static {
6568 uiNameToCodeMap = new HashMap<String, Integer>();
7780
7881 /**
7982 * Constructor.
80 *
83 *
8184 * @param args
8285 * command line arguments
8386 */
8790
8891 /**
8992 * Launch the appropriate UI.
90 *
93 *
9194 * @throws java.lang.Exception
9295 */
9396 public void launch() throws Exception {
114117
115118 /**
116119 * Find out what UI should be launched.
117 *
120 *
118121 * <p>
119122 * First, we check the command line arguments to see if the first argument
120123 * specifies the UI (e.g., "-textui", "-gui", etc.)
121 *
124 *
122125 * <p>
123126 * If the first command line argument does not specify the UI, then we check
124127 * the <code>findbugs.launchUI</code> system property to one of the
125128 * following values:
126 *
129 *
127130 * <ul>
128131 * <li>-Dfindbugs.launchUI=textui for textui,</li>
129132 * <li>-Dfindbugs.launchUI=gui1 for the original swing gui,</li>
131134 * <li>-Dfindbugs.launchUI=version for the ShowVersion main() method, or</li>
132135 * <li>-Dfindbugs.launchUI=help for the ShowHelp main() method.</li>
133136 * </ul>
134 *
137 *
135138 * Any other value (or the absence of any value) will not change the default
136139 * behavior, which is to launch the newer "gui2" on systems that support it.
137 *
138 * @param args
139 * the command line arguments
140 *
140141 * @return an integer UI code: TEXTUI, GUI1, GUI2, SHOW_VERSION, SHOW_HELP,
141142 * or possibly another user-set int value
142143 */
184185
185186 /**
186187 * main() method. This is where execution of FindBugs (any UI) starts.
187 *
188 *
188189 * @param args
189190 * command line arguments
190191 * @throws java.lang.Exception
180180 */
181181 public static LocalVariableAnnotation getParameterLocalVariableAnnotation(Method method, int local) {
182182 LocalVariableAnnotation lva = getLocalVariableAnnotation(method, local, 0, 0);
183 if (lva.isNamed())
184 lva.setDescription(LocalVariableAnnotation.PARAMETER_NAMED_ROLE);
185 else
186 lva.setDescription(LocalVariableAnnotation.PARAMETER_ROLE);
183187 return lva;
184188 }
185189
8484 public static final String METHOD_COMPUTED_IN = "METHOD_COMPUTED_IN";
8585
8686 public static final String METHOD_ALTERNATIVE_TARGET = "METHOD_ALTERNATIVE_TARGET";
87
87
88 public static final String SHOULD_CALL = "SHOULD_CALL";
89
8890 /**
8991 * Constructor.
9092 *
9799 * @param isStatic
98100 * true if the method is static, false if not
99101 */
100 public MethodAnnotation(String className, String methodName, String methodSig, boolean isStatic) {
102 public MethodAnnotation(@DottedClassName String className, String methodName, String methodSig, boolean isStatic) {
101103 super(className, DEFAULT_ROLE);
102104 this.methodName = methodName;
103105 if (methodSig.indexOf(".") >= 0) {
2626 import java.lang.annotation.Target;
2727 import java.util.ArrayList;
2828 import java.util.BitSet;
29 import java.util.Collection;
2930 import java.util.HashMap;
3031 import java.util.List;
3132 import java.util.Map;
5253 import org.apache.bcel.generic.Type;
5354
5455 import edu.umd.cs.findbugs.OpcodeStack.Item.SpecialKind;
56 import edu.umd.cs.findbugs.StackMapAnalyzer.JumpInfoFromStackMap;
5557 import edu.umd.cs.findbugs.ba.AnalysisContext;
5658 import edu.umd.cs.findbugs.ba.AnalysisFeatures;
5759 import edu.umd.cs.findbugs.ba.ClassMember;
6769 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
6870 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
6971 import edu.umd.cs.findbugs.classfile.analysis.MethodInfo;
70 import edu.umd.cs.findbugs.classfile.engine.bcel.AnalysisFactory;
7172 import edu.umd.cs.findbugs.internalAnnotations.SlashedClassName;
7273 import edu.umd.cs.findbugs.util.ClassName;
7374 import edu.umd.cs.findbugs.util.Util;
104105 * will not use iterative opcode stack evaluation.
105106 *
106107 * This is primarily for detectors that need to be backwards compatible with
107 * versions of FindBugs that do not support {@link OpcodeStackDetector.WithCustomJumpInfo }}
108 * versions of FindBugs that do not support {@link edu.umd.cs.findbugs.bcel.OpcodeStackDetector.WithCustomJumpInfo }}
108109 */
109110 @Documented
110111 @Target({ElementType.TYPE, ElementType.PACKAGE})
228229
229230 public static final @SpecialKind
230231 int SERVLET_OUTPUT = 23;
231
232
233 public static final @SpecialKind
234 int TYPE_ONLY = 24;
235
236 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
232237 public static final HashMap<Integer, String> specialKindNames = new HashMap<Integer, String>();
233238
234 private static @SpecialKind int nextSpecialKind = asSpecialKind(SERVLET_OUTPUT + 1);
239 private static @SpecialKind int nextSpecialKind = asSpecialKind(TYPE_ONLY + 1);
235240
236241 public static @SpecialKind
237242 int defineNewSpecialKind(String name) {
314319
315320 }
316321
322 public boolean usesTwoSlots() {
323 return getSize() == 2;
324 }
317325 @Override
318326 public boolean equals(Object o) {
319327 if (!(o instanceof Item))
396404 case SERVLET_OUTPUT:
397405 buf.append(", servlet_output");
398406 break;
399
407 case TYPE_ONLY:
408 buf.append(", type_only");
409 break;
400410 case NOT_SPECIAL:
401411 break;
402412 default:
436446 buf.append(", r");
437447 buf.append(registerNumber);
438448 }
439 if (isCouldBeZero())
449 if (isCouldBeZero() && !isZero())
440450 buf.append(", cbz");
441451 if (userValue != null) {
442452 buf.append(", uv: ");
455465 if (i1.equals(i2))
456466 return i1;
457467 Item m = new Item();
468 if (i1.getSpecialKind() == TYPE_ONLY && i2.getSpecialKind() != TYPE_ONLY)
469 return i2;
470 else if (i2.getSpecialKind() == TYPE_ONLY && i1.getSpecialKind() != TYPE_ONLY)
471 return i1;
458472 m.flags = i1.flags & i2.flags;
459473 m.setCouldBeZero(i1.isCouldBeZero() || i2.isCouldBeZero());
460474 if (i1.pc == i2.pc)
503517 this(signature, Integer.valueOf(constValue));
504518 }
505519
520
521 public static Item initialArgument(String signature, int reg) {
522 Item it = new Item(signature);
523 it.setInitialParameter(true);
524 it.registerNumber = reg;
525 return it;
526
527 }
506528 public Item(String signature) {
507529 this(signature, UNKNOWN);
508530 }
509
531 public static Item typeOnly(String signature) {
532 Item it = new Item(signature, UNKNOWN);
533 it.setSpecialKind(TYPE_ONLY);
534 return it;
535 }
510536 public Item(Item it) {
511537 this.signature = it.signature;
512538 this.constValue = it.constValue;
513539 this.source = it.source;
540 this.fieldLoadedFromRegister = it.fieldLoadedFromRegister;
514541 this.registerNumber = it.registerNumber;
515542 this.userValue = it.userValue;
516543 this.injection = it.injection;
519546 this.pc = it.pc;
520547 }
521548
549
550
522551 public Item(Item it, String signature) {
523552 this(it);
524553 this.signature = DescriptorFactory.canonicalizeString(signature);
532561 this.constValue = (char) constantNumericValue.intValue();
533562 else if (signature.equals("I"))
534563 this.constValue = constantNumericValue.intValue();
535
536 }
564 else if (signature.equals("D"))
565 this.constValue = constantNumericValue.doubleValue();
566 else if (signature.equals("F"))
567 this.constValue = constantNumericValue.floatValue();
568
569 }
570 char s = signature.charAt(0);
571 if (s != 'L' && s != '[')
572 this.source = null;
573
537574 setSpecialKindFromSignature();
538575 }
539576
623660 specialKind = NON_NEGATIVE;
624661 }
625662
663 public void setCouldBeNegative() {
664 if (specialKind == NON_NEGATIVE)
665 specialKind = NOT_SPECIAL;
666 }
667
626668 public Item() {
627669 signature = "Ljava/lang/Object;";
628670 constValue = null;
877919 * @return Returns the couldBeZero.
878920 */
879921 private boolean isCouldBeZero() {
880 return (flags & COULD_BE_ZERO_FLAG) != 0;
922 return (flags & COULD_BE_ZERO_FLAG) != 0
923 || isZero();
924 }
925
926 /**
927 * @return
928 */
929 private boolean isZero() {
930 return constValue != null && constValue.equals(0);
881931 }
882932
883933 /**
10011051 List<Item> jumpEntry = null;
10021052 if (jumpEntryLocations.get(dbc.getPC()))
10031053 jumpEntry = jumpEntries.get(Integer.valueOf(dbc.getPC()));
1054 boolean wasReachOnlyByBranch = isReachOnlyByBranch();
10041055 if (jumpEntry != null) {
10051056 setReachOnlyByBranch(false);
10061057 List<Item> jumpStackEntry = jumpStackEntries.get(Integer.valueOf(dbc.getPC()));
10071058
10081059 if (DEBUG2) {
1009 System.out.println("XXXXXXX " + isReachOnlyByBranch());
1010 System.out.println("merging lvValues at jump target " + dbc.getPC() + " -> " + jumpEntry);
1011 System.out.println(" current lvValues " + lvValues);
1012 System.out.println(" merging stack entry " + jumpStackEntry);
1013 System.out.println(" current stack values " + stack);
1060 if (wasReachOnlyByBranch) {
1061 System.out.println("Reached by branch at " + dbc.getPC() + " with " + jumpEntry);
1062 if (jumpStackEntry != null)
1063 System.out.println(" and stack " + jumpStackEntry);
1064 } else if (!jumpEntry.equals(lvValues)
1065 || jumpStackEntry != null && !jumpStackEntry.equals(stack)) {
1066
1067 System.out.println("Merging at " + dbc.getPC() + " with " + jumpEntry);
1068 if (jumpStackEntry != null)
1069 System.out.println(" and stack " + jumpStackEntry);
1070
1071 }
10141072
10151073 }
10161074 if (isTop()) {
10531111 }
10541112 }
10551113 setTop(true);
1114
1115
10561116 }
10571117
10581118 }
12331293 if (item != null) {
12341294 Item itm = new Item(item);
12351295 itm.setLoadedFromField(fieldOperand, Integer.MAX_VALUE);
1296 itm.setPC(dbc.getPC());
12361297 push(itm);
12371298 break;
12381299 }
12421303 if (field.getFieldName().equals("separator") && field.getClassName().equals("java.io.File")) {
12431304 i.setSpecialKind(Item.FILE_SEPARATOR_STRING);
12441305 }
1245
1306 i.setPC(dbc.getPC());
12461307 push(i);
12471308 break;
12481309 }
13301391 case MONITORENTER:
13311392 case MONITOREXIT:
13321393 case POP:
1394 pop();
1395 break;
1396
13331397 case PUTSTATIC:
13341398 pop();
1399 eraseKnowledgeOf(dbc.getXFieldOperand());
1400 break;
1401 case PUTFIELD:
1402 pop(2);
1403 eraseKnowledgeOf(dbc.getXFieldOperand());
13351404 break;
13361405
13371406 case IF_ACMPEQ:
14201489 if (it.getSize() == 1)
14211490 pop();
14221491 break;
1423 case PUTFIELD:
1424 pop(2);
1425 break;
1492
14261493
14271494 case IALOAD:
14281495 case SALOAD:
15881655 Item addr = pop();
15891656 Item itm = new Item(item);
15901657 itm.setLoadedFromField(fieldOperand, addr.getRegisterNumber());
1658 itm.setPC(dbc.getPC());
15911659 push(itm);
15921660 break;
15931661 }
15941662 }
15951663 Item item = pop();
15961664 int reg = item.getRegisterNumber();
1597 push(new Item(dbc.getSigConstantOperand(), FieldAnnotation.fromReferencedField(dbc), reg));
1665 Item valueLoaded = new Item(dbc.getSigConstantOperand(), FieldAnnotation.fromReferencedField(dbc), reg);
1666 valueLoaded.setPC(dbc.getPC());
1667 push(valueLoaded);
15981668
15991669 }
16001670 break;
17541824 case I2B: {
17551825 it = pop();
17561826 Item newValue = new Item(it, "B");
1827 newValue.setCouldBeNegative();
17571828
17581829 push(newValue);
17591830 }
17851856 break;
17861857
17871858 case I2S:
1788 changeSignatureOfTopElement("S");
1859 {
1860 Item item1 = pop();
1861 Item newValue = new Item(item1, "S");
1862 newValue.setCouldBeNegative();
1863 push(newValue);
1864 }
17891865 break;
17901866
17911867 case L2I:
19151991 clear();
19161992 } finally {
19171993 if (DEBUG) {
1918 System.out.println(dbc.getNextPC() + "pc : " + OPCODE_NAMES[seen] + " stack depth: " + getStackDepth());
1919 System.out.println(this);
1994 System.out.printf("%4d: %14s %s%n", dbc.getPC(), OPCODE_NAMES[seen] , this);
19201995 }
19211996 }
19221997 }
19231998
19241999 /**
1925 *
2000 * @param fieldOperand
19262001 */
1927 private void changeSignatureOfTopElement(String newSignature) {
1928 {
1929 Item item = pop();
1930 Item newValue = new Item(item, newSignature);
1931
1932 push(newValue);
1933 }
1934 }
2002 private void eraseKnowledgeOf(XField fieldOperand) {
2003 if (fieldOperand == null) return;
2004 for (Item item : stack)
2005 if (item != null && fieldOperand.equals(item.getXField()))
2006 item.setLoadedFromField(null, -1);
2007 for (Item item : lvValues)
2008 if (item != null && fieldOperand.equals(item.getXField()))
2009 item.setLoadedFromField(null, -1);
2010 }
2011
2012
19352013
19362014 public void precomputation(DismantleBytecode dbc) {
19372015 if (registerTestedFoundToBeNonnegative >= 0) {
22042282 }
22052283 }
22062284
2285 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
22072286 static final HashMap<String, String> boxedTypes = new HashMap<String, String>();
22082287
22092288 static private void addBoxedType(Class<?>... clss) {
24292508 (methodName.equals("nextInt") && signature.equals("()I")
24302509 || methodName.equals("nextLong") && signature.equals("()J"))
24312510 ) {
2432 Item i = pop();
2511 Item i = new Item(pop());
24332512 i.setSpecialKind(Item.RANDOM_INT);
24342513 push(i);
24352514 } else if (methodName.equals("size") && signature.equals("()I")
24362515 && Subtypes2.instanceOf(ClassName.toDottedClassName(clsName), "java.util.Collection")) {
2437 Item i = pop();
2516 Item i = new Item(pop());
24382517 if (i.getSpecialKind() == Item.NOT_SPECIAL)
24392518 i.setSpecialKind(Item.NON_NEGATIVE);
24402519 push(i);
24412520 } else if (ClassName.isMathClass(clsName) && methodName.equals("abs")) {
2442 Item i = pop();
2521 Item i = new Item(pop());
24432522 if (i.getSpecialKind() == Item.HASHCODE_INT)
24442523 i.setSpecialKind(Item.MATH_ABS_OF_HASHCODE);
24452524 else if (i.getSpecialKind() == Item.RANDOM_INT)
24502529 } else if (seen == INVOKEVIRTUAL && methodName.equals("hashCode") && signature.equals("()I") || seen == INVOKESTATIC
24512530 && clsName.equals("java/lang/System") && methodName.equals("identityHashCode")
24522531 && signature.equals("(Ljava/lang/Object;)I")) {
2453 Item i = pop();
2532 Item i = new Item(pop());
24542533 i.setSpecialKind(Item.HASHCODE_INT);
24552534 push(i);
24562535 } else if (topIsTainted
24572536 && (methodName.startsWith("encode") && clsName.equals("javax/servlet/http/HttpServletResponse") || methodName
24582537 .equals("trim") && clsName.equals("java/lang/String"))) {
2459 Item i = pop();
2538 Item i = new Item(pop());
24602539 i.setSpecialKind(Item.SERVLET_REQUEST_TAINTED);
24612540 i.injection = injection;
24622541 push(i);
24632542 }
24642543
24652544 if (!signature.endsWith(")V")) {
2466 Item i = pop();
2545 Item i = new Item(pop());
24672546 i.source = XFactory.createReferencedXMethod(dbc);
24682547 push(i);
24692548 }
24702549
24712550 }
24722551
2473 private void mergeLists(List<Item> mergeInto, List<Item> mergeFrom, boolean errorIfSizesDoNotMatch) {
2552 boolean foobar = false;
2553 private boolean mergeLists(List<Item> mergeInto, List<Item> mergeFrom, boolean errorIfSizesDoNotMatch) {
24742554 // merge stacks
24752555 int intoSize = mergeInto.size();
24762556 int fromSize = mergeFrom.size();
2557 boolean changed = false;
24772558 if (errorIfSizesDoNotMatch && intoSize != fromSize) {
24782559 if (DEBUG2) {
24792560 System.out.println("Bad merging items");
24822563 }
24832564 } else {
24842565 if (DEBUG2) {
2485 if (intoSize == fromSize)
2486 System.out.println("Merging items");
2487 else
2488 System.out.println("Bad merging items");
2489 System.out.println("current items: " + mergeInto);
2490 System.out.println("jump items: " + mergeFrom);
2491 }
2492
2493 for (int i = 0; i < Math.min(intoSize, fromSize); i++)
2494 mergeInto.set(i, Item.merge(mergeInto.get(i), mergeFrom.get(i)));
2495 if (DEBUG2) {
2496 System.out.println("merged items: " + mergeInto);
2497 }
2498 }
2566 if (intoSize != fromSize) {
2567 System.out.printf("Bad merging %d items from %d items%n", intoSize, fromSize);
2568 System.out.println("current items: " + mergeInto);
2569 System.out.println("jump items: " + mergeFrom);
2570 }
2571
2572 }
2573
2574 List<Item> mergeIntoCopy = null;
2575 if (DEBUG2)
2576 mergeIntoCopy = new ArrayList<Item>(mergeInto);
2577 int common = Math.min(intoSize, fromSize);
2578 for (int i = 0; i < common; i++) {
2579 Item oldValue = mergeInto.get(i);
2580 Item newValue = mergeFrom.get(i);
2581 Item merged = Item.merge(oldValue, newValue);
2582 if (merged != null && !merged.equals(oldValue)) {
2583 if (foobar)
2584 System.out.println("foobar");
2585 mergeInto.set(i, merged);
2586 changed = true;
2587 }
2588 }
2589 if (false) for (int i = common; i < fromSize; i++) {
2590 Item newValue = mergeFrom.get(i);
2591 if (foobar)
2592 System.out.println("foobar");
2593 mergeInto.add(newValue);
2594 changed = true;
2595
2596 }
2597 if (DEBUG2 && changed) {
2598 System.out.println("Merge results:");
2599 System.out.println("updating: " + mergeIntoCopy);
2600 System.out.println(" with: " + mergeFrom);
2601 System.out.println(" gives: " + mergeInto);
2602 }
2603 }
2604 return changed;
24992605 }
25002606
25012607 public void clear() {
25092615
25102616 BitSet exceptionHandlers = new BitSet();
25112617
2618 private boolean jumpInfoChangedByBackwardsBranch = false;
2619
25122620 private Map<Integer, List<Item>> jumpEntries = new HashMap<Integer, List<Item>>();
25132621
25142622 private Map<Integer, List<Item>> jumpStackEntries = new HashMap<Integer, List<Item>>();
25152623
25162624 private BitSet jumpEntryLocations = new BitSet();
2625
2626 public void printJumpEntries() {
2627 for(int i=jumpEntryLocations.nextSetBit(0); i>=0; i=jumpEntryLocations.nextSetBit(i+1)) {
2628 List<Item> stack = jumpStackEntries.get(i);
2629 List<Item> locals = jumpEntries.get(i);
2630 if (stack != null)
2631 System.out.printf("%4d: %s::%s%n", i, stack, locals);
2632 else
2633 System.out.printf("%4d: ::%s%n", i, locals);
2634 }
2635 }
25172636
25182637 public static class JumpInfo {
25192638 final Map<Integer, List<Item>> jumpEntries;
25332652 }
25342653 }
25352654
2536 public static class JumpInfoFactory extends AnalysisFactory<JumpInfo> {
2655
2656 public static class JumpInfoFactory extends edu.umd.cs.findbugs.classfile.engine.bcel.AnalysisFactory<JumpInfo> {
25372657
25382658 public JumpInfoFactory() {
25392659 super("Jump info for opcode stack", JumpInfo.class);
25402660 }
25412661
2542 public JumpInfo analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
2662 public @CheckForNull JumpInfo analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
25432663 Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
25442664 JavaClass jclass = getJavaClass(analysisCache, descriptor.getClassDescriptor());
2545
25462665 Code code = method.getCode();
25472666 if (code == null) {
25482667 return null;
25492668 }
2550 final OpcodeStack stack = new OpcodeStack();
2551
2552 DismantleBytecode branchAnalysis = new DismantleBytecode() {
2553 @Override
2554 public void sawOpcode(int seen) {
2555 stack.sawOpcode(this, seen);
2556 }
2557 };
2558 return computeJumpInfo(jclass, method, stack, branchAnalysis);
2559 }
2669
2670 JumpStackComputation branchAnalysis = new JumpStackComputation(descriptor);
2671
2672 return computeJumpInfo(jclass, method, branchAnalysis);
2673 }
2674
2675 static class JumpStackComputation extends BytecodeScanningDetector {
2676
2677 static final boolean DEBUG = false;
2678 final MethodDescriptor descriptor;
2679 private JumpStackComputation(MethodDescriptor descriptor) {
2680 this.descriptor = descriptor;
2681 }
2682
2683 protected OpcodeStack stack = new OpcodeStack();
2684
2685 public OpcodeStack getStack() {
2686 return stack;
2687 }
2688
2689 @Override
2690 public final void visitCode(Code obj) {
2691 if (!getMethodDescriptor().equals(descriptor))
2692 throw new IllegalStateException();
2693 if (DEBUG) System.out.println(descriptor);
2694 stack.resetForMethodEntry0(this);
2695 super.visitCode(obj);
2696 if (DEBUG) System.out.println();
2697 }
2698
2699 @Override
2700 public void sawOpcode(int seen) {
2701 stack.precomputation(this);
2702
2703 if (DEBUG) System.out.printf("%4d %-15s %s%n", getPC(), OPCODE_NAMES[seen], stack);
2704 try {
2705 stack.sawOpcode(this, seen);
2706 } catch (RuntimeException e) {
2707 throw e;
2708 }
2709 }
2710 }
25602711
25612712 /**
25622713 * @param jclass
25652716 * @param branchAnalysis
25662717 * @return
25672718 */
2568 public static JumpInfo computeJumpInfo(JavaClass jclass, Method method, final OpcodeStack stack,
2569 DismantleBytecode branchAnalysis) {
2719 public static @CheckForNull JumpInfo computeJumpInfo(JavaClass jclass, Method method,
2720 JumpStackComputation branchAnalysis) {
25702721 branchAnalysis.setupVisitorForClass(jclass);
2571 MethodInfo xMethod = (MethodInfo) XFactory.createXMethod(jclass, method);
2572 int oldCount = 0;
2573 while (true) {
2574 stack.resetForMethodEntry0(ClassName.toSlashedClassName(jclass.getClassName()), method);
2722 XMethod createXMethod = XFactory.createXMethod(jclass, method);
2723 if (!(createXMethod instanceof MethodInfo))
2724 return null;
2725 MethodInfo xMethod = (MethodInfo) createXMethod;
2726
2727 int iteration = 1;
2728 OpcodeStack myStack = branchAnalysis.stack;
2729 if (false)
2730 myStack.learnFrom(myStack.getJumpInfoFromStackMap());
2731 do {
2732 if (DEBUG && iteration > 1 ) {
2733 System.out.println("Iterative jump info for " + xMethod +", iteration " + iteration);
2734 myStack.printJumpEntries();
2735 System.out.println();
2736 }
2737 // myStack.resetForMethodEntry0(ClassName.toSlashedClassName(jclass.getClassName()), method);
25752738 branchAnalysis.doVisitMethod(method);
2576 int newCount = stack.jumpEntries.size();
2577 if (xMethod.hasBackBranch() != stack.backwardsBranch && !stack.encountedTop) {
2739 if (xMethod.hasBackBranch() != myStack.backwardsBranch && !myStack.encountedTop) {
25782740 AnalysisContext.logError(
25792741 String.format("For %s, mismatch on existence of backedge: %s for precomputation, %s for bytecode analysis",
2580 xMethod, xMethod.hasBackBranch(), stack.backwardsBranch));
2581 }
2582 if (newCount == oldCount || !stack.encountedTop || !stack.backwardsBranch)
2742 xMethod, xMethod.hasBackBranch(), myStack.backwardsBranch));
2743 }
2744 if (iteration++ > 40) {
2745 AnalysisContext.logError("Iterative jump info didn't converge after " + iteration + " iterations in " + xMethod
2746 + ", size " + method.getCode().getLength());
25832747 break;
2584 oldCount = newCount;
2585 }
2586
2587 return new JumpInfo(stack.jumpEntries, stack.jumpStackEntries, stack.jumpEntryLocations);
2748 }
2749 } while (myStack.isJumpInfoChangedByBackwardsBranch() && myStack.backwardsBranch);
2750 if (iteration > 20&& iteration <= 40) {
2751 AnalysisContext.logError("Iterative jump info converged after " + iteration + " iterations in " + xMethod + ", size " + method.getCode().getLength());
2752
2753 }
2754 return new JumpInfo(myStack.jumpEntries, myStack.jumpStackEntries, myStack.jumpEntryLocations);
25882755 }
25892756 }
25902757
25942761
25952762 private void addJumpValue(int from, int target) {
25962763 if (DEBUG)
2597 System.out.println("Set jump entry at " + methodName + ":" + target + "pc to " + stack + " : " + lvValues);
2764 System.out.println("Set jump entry at " + methodName + ":" + target + " pc to " + stack + " : " + lvValues);
25982765
25992766 if (from >= target)
26002767 backwardsBranch = true;
26012768 List<Item> atTarget = jumpEntries.get(Integer.valueOf(target));
26022769 if (atTarget == null) {
2603 if (DEBUG)
2604 System.out.println("Was null");
2605
2770 setJumpInfoChangedByBackwardBranch("new target", from, target);
26062771 jumpEntries.put(Integer.valueOf(target), new ArrayList<Item>(lvValues));
26072772 jumpEntryLocations.set(target);
26082773 if (stack.size() > 0) {
26092774 jumpStackEntries.put(Integer.valueOf(target), new ArrayList<Item>(stack));
26102775 }
2611 return;
2612 }
2613 mergeLists(atTarget, lvValues, false);
2776 } else {
2777 if (mergeLists(atTarget, lvValues, false))
2778 setJumpInfoChangedByBackwardBranch("locals", from, target);
26142779 List<Item> stackAtTarget = jumpStackEntries.get(Integer.valueOf(target));
26152780 if (stack.size() > 0 && stackAtTarget != null)
2616 mergeLists(stackAtTarget, stack, false);
2781 if (mergeLists(stackAtTarget, stack, false))
2782 setJumpInfoChangedByBackwardBranch("stack", from, target);
2783 }
26172784 if (DEBUG)
2618 System.out.println("merge target for " + methodName + ":" + target + "pc is " + atTarget);
2785 System.out.println("merge target for " + methodName + ":" + target + " pc is " + atTarget);
26192786 }
26202787
26212788 private String methodName;
26232790 DismantleBytecode v;
26242791
26252792 public void learnFrom(JumpInfo info) {
2793 if (info == null)
2794 return;
26262795 jumpEntries = new HashMap<Integer, List<Item>>(info.jumpEntries);
26272796 jumpStackEntries = new HashMap<Integer, List<Item>>(info.jumpStackEntries);
26282797 jumpEntryLocations = (BitSet) info.jumpEntryLocations.clone();
26502819 Code code = v.getMethod().getCode();
26512820 if (code == null)
26522821 return result;
2653
2822 JumpInfo jump = null;
26542823 if (useIterativeAnalysis) {
2655 JumpInfo jump = null;
26562824 if (visitor instanceof OpcodeStackDetector.WithCustomJumpInfo) {
26572825 jump = ((OpcodeStackDetector.WithCustomJumpInfo) visitor).customJumpInfo();
26582826 } else if ((visitor instanceof OpcodeStackDetector) && !((OpcodeStackDetector)visitor).isUsingCustomUserValue()) {
26592827 jump = getJumpInfo();
2660 }
2661 if (jump != null) {
2662 learnFrom(jump);
2663 }
2664
2665 }
2666
2828 } else {
2829 jump = getJumpInfoFromStackMap();
2830 }
2831 } else {
2832 jump = getJumpInfoFromStackMap();
2833 }
2834 learnFrom(jump);
26672835 return result;
26682836
26692837 }
26702838
2839 int nullSafeSize(@CheckForNull Collection<?> c) {
2840 if (c == null)
2841 return 0;
2842 return c.size();
2843 }
2844
26712845 private JumpInfo getJumpInfo() {
26722846 IAnalysisCache analysisCache = Global.getAnalysisCache();
26732847 XMethod xMethod = XFactory.createXMethod(v.getThisClass(), v.getMethod());
26832857 return null;
26842858 }
26852859 }
2860 private JumpInfoFromStackMap getJumpInfoFromStackMap() {
2861 IAnalysisCache analysisCache = Global.getAnalysisCache();
2862 XMethod xMethod = XFactory.createXMethod(v.getThisClass(), v.getMethod());
2863 if (xMethod instanceof MethodInfo) {
2864 MethodInfo mi = (MethodInfo) xMethod;
2865 if (!mi.hasBackBranch())
2866 return null;
2867 }
2868
2869 try {
2870 return analysisCache.getMethodAnalysis(JumpInfoFromStackMap.class, xMethod.getMethodDescriptor());
2871
2872 } catch (CheckedAnalysisException e) {
2873 AnalysisContext.logError("Error getting jump information from StackMap", e);
2874 return null;
2875 }
2876 }
2877
2878 public void setJumpInfoChangedByBackwardBranch(String kind, int from, int to) {
2879 if (from < to)
2880 return ;
2881
2882
2883 if (DEBUG && !this.isJumpInfoChangedByBackwardsBranch())
2884 System.out.printf("%s jump info at %d changed by jump from %d%n", kind, to, from);
2885 this.setJumpInfoChangedByBackwardsBranch(from,to);
2886 return ;
2887 }
26862888
26872889 private int resetForMethodEntry0(PreorderVisitor visitor) {
26882890 return resetForMethodEntry0(visitor.getClassName(), visitor.getMethod());
26892891 }
26902892
2691 private int resetForMethodEntry0(@SlashedClassName String className, Method m) {
2893 int resetForMethodEntry0(@SlashedClassName String className, Method m) {
26922894 methodName = m.getName();
26932895
26942896 if (DEBUG)
26992901 top = false;
27002902 encountedTop = false;
27012903 backwardsBranch = false;
2904 clearJumpInfoChangedByBackwardsBranch();
27022905
27032906 setReachOnlyByBranch(false);
27042907 seenTransferOfControl = false;
27152918 Type[] argTypes = Type.getArgumentTypes(signature);
27162919 int reg = 0;
27172920 if (!m.isStatic()) {
2718 Item it = new Item("L" + className + ";");
2719 it.setInitialParameter(true);
2720 it.registerNumber = reg;
2921 Item it = Item.initialArgument("L" + className + ";", reg);
27212922 setLVValue(reg, it);
27222923 reg += it.getSize();
27232924 }
27242925 for (Type argType : argTypes) {
2725 Item it = new Item(argType.getSignature());
2726 it.registerNumber = reg;
2727 it.setInitialParameter(true);
2926 Item it = Item.initialArgument(argType.getSignature(), reg);
27282927 setLVValue(reg, it);
27292928 reg += it.getSize();
27302929 }
27562955 private Item pop() {
27572956 return stack.remove(stack.size() - 1);
27582957 }
2958
2959 public void replace(int stackOffset, Item value) {
2960 if (stackOffset < 0 || stackOffset >= stack.size()) {
2961 AnalysisContext.logError("Can't get replace stack offset " + stackOffset + " from " + stack.toString() + " @ " + v.getPC()
2962 + " in " + v.getFullyQualifiedMethodName(), new IllegalArgumentException(stackOffset
2963 + " is not a value stack offset"));
2964
2965 }
2966 int tos = stack.size() - 1;
2967 int pos = tos - stackOffset;
2968
2969 stack.set(pos, value);
2970
2971 }
27592972
27602973 public void replaceTop(Item newTop) {
27612974 pop();
27873000 else if (c instanceof ConstantLong)
27883001 push(new Item("J", Long.valueOf(((ConstantLong) c).getBytes())));
27893002 else
2790 throw new UnsupportedOperationException("Constant type not expected");
3003 throw new UnsupportedOperationException("StaticConstant type not expected");
27913004 }
27923005
27933006 private void pushByLocalObjectLoad(DismantleBytecode dbc, int register) {
30493262 if (getStackDepth() > 0) {
30503263 Item next = getStackItem(0);
30513264 if (constructed.equals(next)) {
3265 next = new Item(next);
30523266 next.source = XFactory.createReferencedXMethod(dbc);
30533267 next.pc = dbc.getPC();
3268 replace(0, next);
30543269 }
30553270 }
30563271 return;
30923307 }
30933308
30943309 private void pushByLocalStore(int register) {
3095 Item it = pop();
3310 Item it = new Item(pop());
30963311 if (it.getRegisterNumber() != register) {
30973312 for (Item i : lvValues)
30983313 if (i != null) {
31093324 i.fieldLoadedFromRegister = -1;
31103325 }
31113326 }
3327 if (it.registerNumber == -1)
3328 it.registerNumber = register;
31123329 setLVValue(register, it);
31133330 }
31143331
31153332 private void pushByLocalLoad(String signature, int register) {
3116 Item oldItem = getLVValue(register);
3333 Item oldItem = new Item(getLVValue(register));
31173334
31183335 Item newItem = oldItem;
31193336 if (newItem.signature.equals("Ljava/lang/Object;") && !signature.equals("Ljava/lang/Object;")) {
31913408 boolean isReachOnlyByBranch() {
31923409 return reachOnlyByBranch;
31933410 }
3411
3412 /**
3413 * @return Returns the jumpInfoChangedByBackwardsBranch.
3414 */
3415 boolean isJumpInfoChangedByBackwardsBranch() {
3416 return jumpInfoChangedByBackwardsBranch;
3417 }
3418
3419
3420 void clearJumpInfoChangedByBackwardsBranch() {
3421 this.jumpInfoChangedByBackwardsBranch = false;
3422 }
3423 /**
3424 * @param jumpInfoChangedByBackwardsBranch The jumpInfoChangedByBackwardsBranch to set.
3425 */
3426 void setJumpInfoChangedByBackwardsBranch(int from, int to) {
3427 this.jumpInfoChangedByBackwardsBranch = true;
3428 }
31943429 }
31953430
31963431 // vim:ts=4
2828 import java.util.regex.Pattern;
2929
3030 import javax.annotation.CheckForNull;
31 import javax.annotation.Nonnull;
32 import javax.annotation.OverridingMethodsMustInvokeSuper;
3133
3234 import edu.umd.cs.findbugs.xml.XMLOutput;
3335 import edu.umd.cs.findbugs.xml.XMLWriteable;
3840 * @author Mike Fagan
3941 * @author Jay Dunning
4042 */
41 public class PackageStats implements XMLWriteable {
42
43 public static class ClassStats implements XMLWriteable, Cloneable {
44 private final String name;
45
46 private final String sourceFile;
47
48 private boolean isInterface;
49
50 // nBugs[0] is total; nBugs[n] is total for bug priority n
51 private final int[] nBugs = new int[] { 0, 0, 0, 0, 0 };
52
53 private int size;
54
55 public ClassStats(String name, String sourceFile) {
56 this.name = name;
57 this.sourceFile = sourceFile;
58 }
59
60 @Override
61 public Object clone() {
62 try {
63 return super.clone();
64 } catch (CloneNotSupportedException e) {
65 // can't happen
66 throw new AssertionError(e);
67 }
68 }
69
70 public void setInterface(boolean isInterface) {
71 this.isInterface = isInterface;
72 }
73
74 public void setSize(int size) {
75 this.size = size;
76 }
77
78 public void addError(BugInstance bug) {
79 ++nBugs[bug.getPriority()];
80 ++nBugs[0];
81 }
82
83 public int getTotalBugs() {
84 return nBugs[0];
85 }
86
87 public int getBugsAtPriority(int p) {
88 return nBugs[p];
89 }
90
91 public int size() {
92 return size;
93 }
94
95 public String getName() {
96 return name;
97 }
98
99 public @CheckForNull
100 String getSourceFile() {
101 return sourceFile;
102 }
103
104 public void writeXML(XMLOutput xmlOutput) throws IOException {
105 if (size == 0)
106 return;
107 xmlOutput.startTag("ClassStats");
108
109 xmlOutput.addAttribute("class", name);
110 if (sourceFile != null)
111 xmlOutput.addAttribute("sourceFile", sourceFile);
112 xmlOutput.addAttribute("interface", String.valueOf(isInterface));
113 xmlOutput.addAttribute("size", String.valueOf(size));
114 xmlOutput.addAttribute("bugs", String.valueOf(nBugs[0]));
115 writeBugPriorities(xmlOutput, nBugs);
116
117 xmlOutput.stopTag(true);
118 }
119
120 /**
121 *
122 */
123 public void clearBugCounts() {
124 for (int i = 0; i < nBugs.length; i++)
125 nBugs[i] = 0;
126
127 }
128 }
129
130 public static final String ELEMENT_NAME = "PackageStats";
131
132 public static final int ALL_ERRORS = 0;
133
134 private final String packageName;
135
136 // nBugs[0] is total; nBugs[n] is total for bug priority n
137 private int[] nBugs = new int[] { 0, 0, 0, 0, 0 };
138
139 private int size;
140
141 private int numClasses;
142
143 @Override
144 public String toString() {
145 return String.format("%s, %d classes, %d ncss", packageName, numClasses, size);
146 }
147
148 // list of errors for this package
149 // private LinkedList<BugInstance> packageErrors = new
150 // LinkedList<BugInstance>();
151
152 // all classes and interfaces in this package
153 private Map<String, ClassStats> packageMembers = new HashMap<String, ClassStats>(5);
154
155 public PackageStats(String packageName) {
156 this.packageName = packageName;
157 }
158
159 public PackageStats(String packageName, int numClasses, int size) {
160 this(packageName);
161 this.numClasses = numClasses;
162 this.size = size;
163 }
164
165 public Collection<ClassStats> getClassStats() {
166 return packageMembers.values();
167 }
168
169 public int getTotalBugs() {
170 return nBugs[0];
171 }
172
173 public int size() {
174 return size;
175 }
176
177 public void setSize(int size) {
178 this.size = size;
179 }
180
181 public int getBugsAtPriority(int p) {
182 return nBugs[p];
183 }
184
185 private ClassStats getClassStats(String name, String sourceFile) {
186 ClassStats result = packageMembers.get(name);
187 if (result == null) {
188 result = new ClassStats(name, sourceFile);
189 packageMembers.put(name, result);
190 numClasses = packageMembers.size();
191 }
192
193 return result;
194 }
195
196 public @CheckForNull ClassStats getClassStatsOrNull(String name) {
197 ClassStats result = packageMembers.get(name);
198 return result;
199 }
200
43
44 class BugCounts {
45 protected int[] nBugs;
46
47 @OverridingMethodsMustInvokeSuper
20148 public void addError(BugInstance bug) {
202 SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation();
203 if (bug.getPriority() >= nBugs.length)
204 return;
49 ensureNonnullBugCounts();
20550 ++nBugs[bug.getPriority()];
20651 ++nBugs[0];
207
208 // see bug https://sourceforge.net/tracker/index.php?func=detail&aid=3322583&group_id=96405&atid=614693
209 // always add class stats to see useful details in package stats fancy.xsl output
210 getClassStats(source.getClassName(), source.getSourceFile()).addError(bug);
211 }
212
213 public void addClass(String name, String sourceFile, boolean isInterface, int size) {
214 addClass(name, sourceFile, isInterface, size, true);
215 }
216
217 public void addClass(String name, String sourceFile, boolean isInterface, int size, boolean updatePackageStats) {
218 ClassStats classStats = getClassStats(name, sourceFile);
219 classStats.setInterface(isInterface);
220 classStats.setSize(size);
221 addClass(classStats, updatePackageStats);
222 }
223
224 public void addClass(ClassStats classStats) {
225 addClass(classStats, true);
226 }
227
228 public void addClass(ClassStats classStats, boolean updatePackageStats) {
229 if (packageMembers.isEmpty()) {
230 this.size = 0;
231 this.numClasses = 0;
232 }
233 packageMembers.put(classStats.getName(), classStats);
234 if (updatePackageStats)
235 size += classStats.size();
236 }
237
238 public String getPackageName() {
239 return packageName;
240 }
241
242 public int getNumClasses() {
243 return numClasses;
244 }
245
246 public void setNumClasses(int numClasses) {
247 this.numClasses = numClasses;
248 }
249
250 public void writeXML(XMLOutput xmlOutput) throws IOException {
251 if (size == 0)
252 return;
253
254 xmlOutput.startTag(ELEMENT_NAME);
255
256 xmlOutput.addAttribute("package", packageName);
257 xmlOutput.addAttribute("total_bugs", String.valueOf(nBugs[0]));
258 int numClasses = packageMembers.size();
259 if (numClasses == 0)
260 numClasses = this.numClasses;
261 xmlOutput.addAttribute("total_types", String.valueOf(numClasses));
262 xmlOutput.addAttribute("total_size", String.valueOf(size));
263 writeBugPriorities(xmlOutput, nBugs);
264
265 xmlOutput.stopTag(false);
266
267 for (ClassStats classStats : getSortedClassStats()) {
268 classStats.writeXML(xmlOutput);
269 }
270
271 xmlOutput.closeTag(ELEMENT_NAME);
272 }
273
274 public Collection<ClassStats> getSortedClassStats() {
275 SortedMap<String, ClassStats> sorted = new TreeMap<String, ClassStats>(packageMembers);
276 return sorted.values();
277
278 }
279
52 }
53
54 protected void ensureNonnullBugCounts() {
55 if (nBugs == null)
56 nBugs = new int[] { 0, 0, 0, 0, 0 };
57
58 }
59 public final int getTotalBugs() {
60 if (nBugs == null)
61 return 0;
62 return nBugs[0];
63 }
64
65 public final int getBugsAtPriority(int p) {
66 if (nBugs == null)
67 return 0;
68 return nBugs[p];
69 }
70
71 public void clearBugCounts() {
72 nBugs = null;
73
74 }
75
28076 /**
28177 * Add priority attributes to a started tag. Each priority at offset n,
28278 * where n &gt; 0, is output using attribute priority_n if the value at
28985 * an array for which the element at offset n is the number of
29086 * bugs for priority n.
29187 */
292 public static void writeBugPriorities(XMLOutput xmlOutput, int[] bugs) throws IOException {
293 int i = bugs.length;
88 public void writeBugPriorities(XMLOutput xmlOutput) throws IOException {
89 if (nBugs == null)
90 return;
91 writeBugPriorities(xmlOutput, nBugs);
92 }
93 public static void writeBugPriorities(XMLOutput xmlOutput, @Nonnull int nBugs[]) throws IOException {
94 int i = nBugs.length;
29495 while (--i > 0) {
295 if (bugs[i] > 0) {
296 xmlOutput.addAttribute("priority_" + i, String.valueOf(bugs[i]));
96 if (nBugs[i] > 0) {
97 xmlOutput.addAttribute("priority_" + i, String.valueOf(nBugs[i]));
29798 }
29899 }
299100 }
101 }
102
103 public class PackageStats extends BugCounts implements XMLWriteable {
104
105
106 public static class ClassStats extends BugCounts implements XMLWriteable, Cloneable {
107 private final String name;
108
109 private final String sourceFile;
110
111 private boolean isInterface;
112
113 private int size;
114
115 public ClassStats(String name, String sourceFile) {
116 this.name = name;
117 this.sourceFile = sourceFile;
118 }
119
120 @Override
121 public Object clone() {
122 try {
123 return super.clone();
124 } catch (CloneNotSupportedException e) {
125 // can't happen
126 throw new AssertionError(e);
127 }
128 }
129
130 public void setInterface(boolean isInterface) {
131 this.isInterface = isInterface;
132 }
133
134 public void setSize(int size) {
135 this.size = size;
136 }
137
138 public int size() {
139 return size;
140 }
141
142 public String getName() {
143 return name;
144 }
145
146 public @CheckForNull
147 String getSourceFile() {
148 return sourceFile;
149 }
150
151 public void writeXML(XMLOutput xmlOutput) throws IOException {
152 if (size == 0)
153 return;
154 xmlOutput.startTag("ClassStats");
155
156 xmlOutput.addAttribute("class", name);
157 if (sourceFile != null)
158 xmlOutput.addAttribute("sourceFile", sourceFile);
159 xmlOutput.addAttribute("interface", String.valueOf(isInterface));
160 xmlOutput.addAttribute("size", String.valueOf(size));
161 xmlOutput.addAttribute("bugs", String.valueOf(getTotalBugs()));
162 writeBugPriorities(xmlOutput);
163
164 xmlOutput.stopTag(true);
165 }
166
167 /**
168 *
169 */
170
171 }
172
173 public static final String ELEMENT_NAME = "PackageStats";
174
175 public static final int ALL_ERRORS = 0;
176
177 private final String packageName;
178 private int size;
179
180 private int numClasses;
181
182 @Override
183 public String toString() {
184 return String.format("%s, %d classes, %d ncss", packageName, numClasses, size);
185 }
186
187 // list of errors for this package
188 // private LinkedList<BugInstance> packageErrors = new
189 // LinkedList<BugInstance>();
190
191 // all classes and interfaces in this package
192 private Map<String, ClassStats> packageMembers = new HashMap<String, ClassStats>(5);
193
194 public PackageStats(String packageName) {
195 this.packageName = packageName;
196 }
197
198 public PackageStats(String packageName, int numClasses, int size) {
199 this(packageName);
200 this.numClasses = numClasses;
201 this.size = size;
202 }
203
204 public Collection<ClassStats> getClassStats() {
205 return packageMembers.values();
206 }
207
208 public int size() {
209 return size;
210 }
211
212 public void setSize(int size) {
213 this.size = size;
214 }
215
216
217 private ClassStats getClassStats(String name, String sourceFile) {
218 ClassStats result = packageMembers.get(name);
219 if (result == null) {
220 result = new ClassStats(name, sourceFile);
221 packageMembers.put(name, result);
222 numClasses = packageMembers.size();
223 }
224
225 return result;
226 }
227
228 public @CheckForNull ClassStats getClassStatsOrNull(String name) {
229 ClassStats result = packageMembers.get(name);
230 return result;
231 }
232
233 @Override
234 public void addError(BugInstance bug) {
235 super.addError(bug);
236 SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation();
237 // see bug https://sourceforge.net/tracker/index.php?func=detail&aid=3322583&group_id=96405&atid=614693
238 // always add class stats to see useful details in package stats fancy.xsl output
239 getClassStats(source.getClassName(), source.getSourceFile()).addError(bug);
240 }
241
242 public void addClass(String name, String sourceFile, boolean isInterface, int size) {
243 addClass(name, sourceFile, isInterface, size, true);
244 }
245
246 public void addClass(String name, String sourceFile, boolean isInterface, int size, boolean updatePackageStats) {
247 ClassStats classStats = getClassStats(name, sourceFile);
248 classStats.setInterface(isInterface);
249 classStats.setSize(size);
250 addClass(classStats, updatePackageStats);
251 }
252
253 public void addClass(ClassStats classStats) {
254 addClass(classStats, true);
255 }
256
257 public void addClass(ClassStats classStats, boolean updatePackageStats) {
258 if (packageMembers.isEmpty()) {
259 this.size = 0;
260 this.numClasses = 0;
261 }
262 packageMembers.put(classStats.getName(), classStats);
263 if (updatePackageStats)
264 size += classStats.size();
265 }
266
267 public String getPackageName() {
268 return packageName;
269 }
270
271 public int getNumClasses() {
272 return numClasses;
273 }
274
275 public void setNumClasses(int numClasses) {
276 this.numClasses = numClasses;
277 }
278
279 public void writeXML(XMLOutput xmlOutput) throws IOException {
280 if (size == 0)
281 return;
282
283 xmlOutput.startTag(ELEMENT_NAME);
284
285 xmlOutput.addAttribute("package", packageName);
286 xmlOutput.addAttribute("total_bugs", String.valueOf(getTotalBugs()));
287 int numClasses = packageMembers.size();
288 if (numClasses == 0)
289 numClasses = this.numClasses;
290 xmlOutput.addAttribute("total_types", String.valueOf(numClasses));
291 xmlOutput.addAttribute("total_size", String.valueOf(size));
292 writeBugPriorities(xmlOutput);
293
294 xmlOutput.stopTag(false);
295
296 for (ClassStats classStats : getSortedClassStats()) {
297 classStats.writeXML(xmlOutput);
298 }
299
300 xmlOutput.closeTag(ELEMENT_NAME);
301 }
302
303 public Collection<ClassStats> getSortedClassStats() {
304 SortedMap<String, ClassStats> sorted = new TreeMap<String, ClassStats>(packageMembers);
305 return sorted.values();
306
307 }
308
309
300310
301311 public void recomputeFromClassStats() {
302 for (int i = 0; i < nBugs.length; i++)
303 nBugs[i] = 0;
312 super.clearBugCounts();
304313 size = 0;
305314 numClasses = packageMembers.size();
315 ensureNonnullBugCounts();
306316 for (ClassStats classStats : packageMembers.values()) {
307317 for (int i = 0; i < nBugs.length; i++)
308318 nBugs[i] += classStats.getBugsAtPriority(i);
313323 /**
314324 *
315325 */
326 @Override
316327 public void clearBugCounts() {
317 for (int i = 0; i < nBugs.length; i++)
318 nBugs[i] = 0;
328 super.clearBugCounts();
319329
320330 for (ClassStats classStats : packageMembers.values()) {
321331 classStats.clearBugCounts();
6060 private final String pluginId;
6161
6262 private final String version;
63 private Date releaseDate;
63 private final Date releaseDate;
6464
6565 private String provider;
6666
103103
104104 static Map<URI, Plugin> allPlugins = new LinkedHashMap<URI, Plugin>();
105105
106 enum EnabledState { PLUGIN_DEFAULT, ENABLED, DISABLED};
106 enum EnabledState { PLUGIN_DEFAULT, ENABLED, DISABLED}
107107
108108 private EnabledState enabled;
109109
277277 /**
278278 * Add a BugCategory reported by the Plugin.
279279 *
280 * @param bugCode
280 * @param bugCategory
281281 */
282282 public void addBugCategory(BugCategory bugCategory) {
283283 BugCategory old = bugCategories.get(bugCategory.getCategory());
470470 return bugRanker;
471471 }
472472
473 <T> void addFindBugsMain(Class<?> mainClass, String cmd, String description, String kind, boolean analysis)
473 <T> void addFindBugsMain(Class<?> mainClass, String cmd, String description, String kind, boolean analysis)
474474 throws SecurityException, NoSuchMethodException {
475475 FindBugsMain main = new FindBugsMain(mainClass, cmd, description, kind, analysis);
476476 mainPlugins.put(cmd, main);
516516 }
517517 return null;
518518 }
519
519
520520 public static synchronized void removePlugin(URI uri) {
521521 allPlugins.remove(uri);
522522 }
598598 }
599599 }
600600
601 /**
602 * @return
603 */
604601 public void setGloballyEnabled(boolean enabled) {
605602 if (isCorePlugin()) {
606603 if (!enabled)
640637 public ClassLoader getClassLoader() {
641638 return getPluginLoader().getClassLoader();
642639 }
643
640
644641 public @CheckForNull Plugin getParentPlugin() {
645 if (getPluginLoader().hasParent())
642 if (getPluginLoader().hasParent())
646643 return Plugin.getByPluginId(getPluginLoader().parentId);
647644 return null;
648645 }
174174 * the URL of the plugin Jar file
175175 * @param parent
176176 * the parent classloader
177 * @deprecated Use {@link #PluginLoader(URL,ClassLoader,boolean,boolean)} instead
177 * @deprecated Use {@link #PluginLoader(URL,URI,ClassLoader,boolean,boolean)} instead
178178 */
179179 @Deprecated
180180 public PluginLoader(URL url, ClassLoader parent) throws PluginException {
11221122 String name = "findbugs.xml";
11231123 URL findbugsXML_URL = getResource(name);
11241124 if (findbugsXML_URL == null) {
1125 throw new PluginException("Couldn't find \"" + name + "\" in plugin");
1125 throw new PluginException("Couldn't find \"" + name + "\" in plugin " + this);
11261126 }
11271127 if (DEBUG)
11281128 System.out.println("PluginLoader found " + name + " at: " + findbugsXML_URL);
1919 package edu.umd.cs.findbugs;
2020
2121 /**
22 * @see edu.umd.cs.findbugs.BugRankCategory
23 * @see edu.umd.cs.findbugs.BugRanker
24 * @see edu.umd.cs.findbugs.annotations.Confidence
2225 * @author pugh
2326 */
2427 public interface Priorities {
188188 }
189189
190190 /**
191 * Constant used to name anonymous projects.
191 * StaticConstant used to name anonymous projects.
192192 */
193193 public static final String UNNAMED_PROJECT = "<<unnamed project>>";
194194
194194
195195 }
196196
197 /**
198 * @param name
199 * property name
200 * @return string value (or null if the property does not exist)
201 */
202197 public void setProperty(String name, String value) {
203198 properties.setProperty(name, value);
204199 }
342342 BugCollection bugCollection = this.bugCollection;
343343 assert bugCollection != null;
344344 String packageName = getRequiredAttribute(attributes, "package", qName);
345 int numClasses = Integer.valueOf(getRequiredAttribute(attributes, "total_types", qName));
346 int size = Integer.valueOf(getRequiredAttribute(attributes, "total_size", qName));
345 int numClasses = Integer.parseInt(getRequiredAttribute(attributes, "total_types", qName));
346 int size = Integer.parseInt(getRequiredAttribute(attributes, "total_size", qName));
347347 bugCollection.getProjectStats().putPackageStats(packageName, numClasses, size);
348348
349349 } else if (outerElement.equals("PackageStats")) {
352352 if (qName.equals("ClassStats")) {
353353 String className = getRequiredAttribute(attributes, "class", qName);
354354 Boolean isInterface = Boolean.valueOf(getRequiredAttribute(attributes, "interface", qName));
355 int size = Integer.valueOf(getRequiredAttribute(attributes, "size", qName));
355 int size = Integer.parseInt(getRequiredAttribute(attributes, "size", qName));
356356 String sourceFile = getOptionalAttribute(attributes, "sourceFile");
357357 bugCollection.getProjectStats().addClass(className, sourceFile, isInterface, size, false);
358358 }
381381 String releaseName = getOptionalAttribute(attributes, "release");
382382 String codeSize = getOptionalAttribute(attributes, "codeSize");
383383 String numClasses = getOptionalAttribute(attributes, "numClasses");
384 AppVersion appVersion = new AppVersion(Long.valueOf(sequence));
384 AppVersion appVersion = new AppVersion(Long.parseLong(sequence));
385385 if (timestamp != null)
386 appVersion.setTimestamp(Long.valueOf(timestamp));
386 appVersion.setTimestamp(Long.parseLong(timestamp));
387387 if (releaseName != null)
388388 appVersion.setReleaseName(releaseName);
389389 if (codeSize != null)
465465 }
466466
467467 boolean nextMatchedIsDisabled;
468 private final Set<String> outerElementTags = unmodifiableSet(new HashSet<String>(asList("And", "Match", "Or", "Not")));;
468 private final Set<String> outerElementTags = unmodifiableSet(new HashSet<String>(asList("And", "Match", "Or", "Not")));
469469
470470 private void parseMatcher(String qName, Attributes attributes) throws SAXException {
471471 if (DEBUG)
604604 s = getOptionalAttribute(attributes, "timestamp"); // optional
605605 if (s != null)
606606 try {
607 long timestamp = Long.valueOf(s);
607 long timestamp = Long.parseLong(s);
608608 bugInstance.setUserAnnotationTimestamp(timestamp);
609609 } catch (NumberFormatException nfe) {
610610 // ok to contine -- just won't set a timestamp for the user
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs;
20
21 import java.lang.reflect.Field;
22 import java.security.AccessController;
23 import java.security.PrivilegedAction;
24 import java.util.ArrayList;
25 import java.util.BitSet;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import javax.annotation.CheckForNull;
31
32 import org.apache.bcel.Constants;
33 import org.apache.bcel.classfile.Attribute;
34 import org.apache.bcel.classfile.ClassFormatException;
35 import org.apache.bcel.classfile.Code;
36 import org.apache.bcel.classfile.ConstantClass;
37 import org.apache.bcel.classfile.Method;
38 import org.apache.bcel.classfile.StackMapTable;
39 import org.apache.bcel.classfile.StackMapTableEntry;
40 import org.apache.bcel.classfile.StackMapType;
41 import org.apache.bcel.generic.Type;
42
43 import edu.umd.cs.findbugs.OpcodeStack.Item;
44 import edu.umd.cs.findbugs.OpcodeStack.JumpInfo;
45 import edu.umd.cs.findbugs.ba.AnalysisContext;
46 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
47 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
48 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
49
50 /**
51 * @author pugh
52 */
53 public class StackMapAnalyzer {
54
55
56
57
58 public static class StackMapAnalysisFactory extends edu.umd.cs.findbugs.classfile.engine.bcel.AnalysisFactory<JumpInfoFromStackMap> {
59 public StackMapAnalysisFactory() {
60 super("Jump info for opcode stack from stack map analysis", JumpInfoFromStackMap.class);
61 }
62
63 public JumpInfoFromStackMap analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) {
64
65 return getFromStackMap( analysisCache, descriptor);
66
67
68 }
69 }
70
71 static class JumpInfoFromStackMap extends JumpInfo {
72
73
74 JumpInfoFromStackMap(Map<Integer, List<Item>> jumpEntries, Map<Integer, List<Item>> jumpStackEntries, BitSet jumpEntryLocations) {
75 super(jumpEntries, jumpStackEntries, jumpEntryLocations);
76 }
77
78 }
79 static final boolean DEBUG = false;
80
81 enum StackFrameType {
82 SAME_FRAME, SAME_LOCALS_1_STACK_ITEM_FRAME, CHOP_FRAME, APPEND_FRAME, FULL_FRAME;
83
84 static StackFrameType get(int frame_type) {
85 if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
86 return SAME_FRAME;
87 } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME
88 && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
89 return SAME_LOCALS_1_STACK_ITEM_FRAME;
90 } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
91 return SAME_LOCALS_1_STACK_ITEM_FRAME;
92 } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) {
93 return CHOP_FRAME;
94 } else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
95 return SAME_FRAME;
96 } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) {
97 return APPEND_FRAME;
98 } else if (frame_type == Constants.FULL_FRAME) {
99 return FULL_FRAME;
100 } else {
101 /* Can't happen */
102 throw new ClassFormatException("Invalid frame type : " + frame_type);
103 }
104 }
105 }
106
107 static @CheckForNull StackMapTable getStackMapTable(Code code) {
108 for(Attribute a : code.getAttributes())
109 if (a instanceof StackMapTable)
110 return (StackMapTable) a;
111 return null;
112 }
113
114 static List<Item> getInitialLocals(MethodDescriptor descriptor) {
115 List<Item> locals = new ArrayList<Item>();
116 Type[] argTypes = Type.getArgumentTypes(descriptor.getSignature());
117 int reg = 0;
118 if (!descriptor.isStatic()) {
119 Item it = Item.typeOnly("L" + descriptor.getSlashedClassName() + ";");
120 locals.add(it);
121 reg += it.getSize();
122 }
123 for (Type argType : argTypes) {
124 Item it = Item.typeOnly(argType.getSignature());
125 locals.add(it);
126 reg += it.getSize();
127 if (it.usesTwoSlots())
128 locals.add(null);
129 }
130 return locals;
131 }
132
133 static final @CheckForNull Field frame_type_field;
134 static {
135 Field f;
136 try {
137 f = AccessController.doPrivileged(new PrivilegedAction<Field>() {
138
139 public Field run() {
140 Class<StackMapTableEntry> c = StackMapTableEntry.class;
141 Field result;
142 try {
143 result = c.getDeclaredField("frame_type");
144 result.setAccessible(true);
145 return result;
146 } catch (NoSuchFieldException e) {
147 throw new AssertionError("frame_type field doesn't exist");
148 } catch (SecurityException e) {
149 return null;
150 }
151
152 }
153
154 });
155 } catch (Exception e) {
156 AnalysisContext.logError("Unable to create frame_type accessor",e );
157 f = null;
158 }
159 System.out.println("Frame type field is null:" + (f == null));
160 frame_type_field = f;
161 }
162
163 static int getFrameType(StackMapTableEntry e) {
164 if (frame_type_field == null)
165 return -1;
166 try {
167 return (Integer) frame_type_field.get(e);
168 } catch (IllegalArgumentException e1) {
169 return -1;
170 } catch (IllegalAccessException e1) {
171 return -1;
172 }
173 }
174 static private @CheckForNull JumpInfoFromStackMap getFromStackMap(IAnalysisCache analysisCache, MethodDescriptor descriptor) {
175 if (frame_type_field == null)
176 return null;
177
178 Method method;
179 try {
180 method = analysisCache.getMethodAnalysis(Method.class, descriptor);
181 } catch (CheckedAnalysisException e1) {
182 analysisCache.getErrorLogger().logError("Unable to get method for " + descriptor, e1);
183 return null;
184 }
185
186 Code code = method.getCode();
187 if (code == null) {
188 return null;
189 }
190 StackMapTable stackMapTable = getStackMapTable(code);
191 if (stackMapTable == null)
192 return null;
193 Map<Integer, List<Item>> jumpEntries = new HashMap<Integer, List<Item>>();
194
195 Map<Integer, List<Item>> jumpStackEntries = new HashMap<Integer, List<Item>>();
196
197 List<Item> locals = getInitialLocals(descriptor);
198 List<Item> stack = new ArrayList<Item>();
199 BitSet jumpEntryLocations = new BitSet();
200 if (DEBUG) {
201 System.out.println(descriptor);
202 System.out.println(locals);
203 }
204 int pc = 0;
205 for(StackMapTableEntry e : stackMapTable.getStackMapTable()) {
206 pc += e.getByteCodeOffsetDelta();
207 StackFrameType stackFrameType = StackFrameType.get(getFrameType(e));
208 switch (stackFrameType) {
209 case SAME_FRAME:
210 stack.clear();
211 break;
212 case SAME_LOCALS_1_STACK_ITEM_FRAME:
213 stack.clear();
214 addStack(stack, e.getTypesOfStackItems());
215 break;
216 case CHOP_FRAME :
217 stack.clear();
218 for(int i = 0; i < e.getNumberOfLocals(); i++) {
219 Item it = locals.remove(locals.size()-1);
220 if (it == null) {
221 it = locals.remove(locals.size()-1);
222 assert it.usesTwoSlots();
223 }
224 }
225 break;
226
227 case APPEND_FRAME:
228
229 stack.clear();
230 addLocals(locals, e.getTypesOfLocals());
231
232 break;
233 case FULL_FRAME:
234 stack.clear();
235 locals.clear();
236 addLocals(locals, e.getTypesOfLocals());
237 addStack(stack, e.getTypesOfStackItems());
238 break;
239
240 }
241 if (DEBUG) {
242 System.out.printf("%4d %2d %2d %12s %s%n",
243
244 pc, e.getNumberOfLocals(), e.getNumberOfStackItems(), stackFrameType, e);
245 System.out.printf(" %s :: %s%n", stack, locals);
246 }
247 if (pc > 0) {
248 jumpEntries.put(pc, new ArrayList<Item>(locals));
249 if (!stack.isEmpty())
250 jumpStackEntries.put(pc, new ArrayList<Item>(stack));
251 jumpEntryLocations.set(pc);
252 }
253 pc++;
254 }
255 if (DEBUG)
256 System.out.println("\n");
257 return new JumpInfoFromStackMap(jumpEntries, jumpStackEntries, jumpEntryLocations);
258
259 }
260
261 static private Item getItem(StackMapType t) {
262
263 switch (t.getType()) {
264
265 case Constants.ITEM_Double:
266 return Item.typeOnly("D");
267 case Constants.ITEM_Float:
268 return Item.typeOnly("F");
269 case Constants.ITEM_Integer:
270 return Item.typeOnly("I");
271 case Constants.ITEM_Long:
272 return Item.typeOnly("J");
273 case Constants.ITEM_Bogus:
274 case Constants.ITEM_NewObject:
275 return Item.typeOnly("Ljava/lang/Object;");
276 case Constants.ITEM_Null:
277 Item it = new Item();
278 it.setSpecialKind(Item.TYPE_ONLY);
279 return it;
280 case Constants.ITEM_InitObject:
281 return Item.typeOnly("Ljava/lang/Object;");
282 case Constants.ITEM_Object:
283 int index = t.getIndex();
284 ConstantClass c = (ConstantClass) t.getConstantPool().getConstant(index);
285 String name = c.getBytes(t.getConstantPool());
286 if (name.charAt(0) != '[') name = "L" + name + ";";
287 return Item.typeOnly(name);
288 default:
289 throw new IllegalArgumentException("Bad item type: " + t.getType());
290
291 }
292 }
293 static private void addLocals(List<Item> lst, StackMapType[] typesOfStackItems) {
294 for(StackMapType t : typesOfStackItems) {
295 Item item = getItem(t);
296 lst.add(item);
297 if (item.usesTwoSlots())
298 lst.add(null);
299 }
300
301 }
302 static private void addStack(List<Item> lst, StackMapType[] typesOfStackItems) {
303 for(StackMapType t : typesOfStackItems) {
304 Item item = getItem(t);
305 lst.add(item);
306 }
307
308 }
309
310 }
2626
2727 /**
2828 * Bug annotation class for string values.
29 *
29 *
3030 * @author William Pugh
3131 * @see BugAnnotation
3232 */
3434 private static final long serialVersionUID = 1L;
3535
3636 public static final String DEFAULT_ROLE = "STRING_DEFAULT";
37
37
3838 public static final String STRING_CONSTANT_ROLE = "STRING_CONSTANT";
39
39
4040 /** Used for non-string constants (e.g., null) */
4141 public static final String STRING_NONSTRING_CONSTANT_ROLE = "STRING_NONSTRING_CONSTANT";
42
42
4343 public static final String REGEX_ROLE = "STRING_REGEX";
4444
4545 public static final String ERROR_MSG_ROLE = "STRING_ERROR_MSG";
6161 private String description;
6262
6363 static class QuotedStringMarker {
64 };
64 }
6565
6666 /**
6767 * Constructor.
68 *
68 *
6969 * @param value
7070 * the String value
7171 */
9595
9696 /**
9797 * Get the String value.
98 *
98 *
9999 * @return the String value
100100 */
101101 public String getValue() {
2323 import java.io.InputStream;
2424 import java.net.MalformedURLException;
2525 import java.net.URL;
26 import java.util.IllegalFormatException;
2627 import java.util.Properties;
2728 import java.util.regex.Matcher;
2829 import java.util.regex.Pattern;
30 import java.util.regex.PatternSyntaxException;
2931
3032 import edu.umd.cs.findbugs.ba.AnalysisContext;
3133 import edu.umd.cs.findbugs.io.IO;
3941
4042 public final static boolean ASSERTIONS_ENABLED;
4143
44 public static boolean RUNNING_IN_ECLIPSE = SystemProperties.class.getClassLoader().getClass().getCanonicalName()
45 .startsWith("org.eclipse.osgi");
46
4247 final static String OS_NAME;
4348 static {
4449 boolean tmp = false;
208213
209214 }
210215
211 /**
212 * @param name
213 * property name
214 * @return string value (or null if the property does not exist)
215 */
216216 public static void setProperty(String name, String value) {
217217 properties.setProperty(name, value);
218218 }
240240 private static final String URL_REWRITE_FORMAT = getOSDependentProperty("findbugs.urlRewriteFormat");
241241
242242 private static final Pattern URL_REWRITE_PATTERN;
243
243244 static {
244245 Pattern p = null;
245 if (URL_REWRITE_PATTERN_STRING != null && URL_REWRITE_FORMAT != null)
246 if (URL_REWRITE_PATTERN_STRING != null && URL_REWRITE_FORMAT != null) {
246247 try {
247248 p = Pattern.compile(URL_REWRITE_PATTERN_STRING);
248 } catch (Exception e) {
249 assert true;
249 String ignored = String.format(URL_REWRITE_FORMAT, "");
250 } catch (PatternSyntaxException e) {
251 throw new IllegalArgumentException("Bad findbugs.urlRewritePattern '" + URL_REWRITE_PATTERN_STRING + "' - "
252 + e.getClass().getSimpleName() + ": "+ e.getMessage());
253 } catch (IllegalFormatException e) {
254 throw new IllegalArgumentException("Bad findbugs.urlRewriteFormat '" + URL_REWRITE_FORMAT + "' - "
255 + e.getClass().getSimpleName() + ": " + e.getMessage());
250256 }
257 } else if (URL_REWRITE_PATTERN_STRING != null) {
258 throw new IllegalArgumentException("findbugs.urlRewritePattern is set but not findbugs.urlRewriteFormat");
259 } else if (URL_REWRITE_FORMAT != null) {
260 throw new IllegalArgumentException("findbugs.urlRewriteFormat is set but not findbugs.urlRewritePattern");
261 }
251262 URL_REWRITE_PATTERN = p;
252263 }
253264
255266 if (URL_REWRITE_PATTERN == null || URL_REWRITE_FORMAT == null)
256267 return u;
257268 Matcher m = URL_REWRITE_PATTERN.matcher(u);
258 if (!m.matches())
269 if (!m.matches() || m.groupCount() == 0)
259270 return u;
260271 String result = String.format(URL_REWRITE_FORMAT, m.group(1));
261272 return result;
2121 import java.io.PrintStream;
2222 import java.io.PrintWriter;
2323 import java.util.Iterator;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
2624
2725 import edu.umd.cs.findbugs.charsets.UTF8;
2826
3836 * @author David Hovemeyer
3937 */
4038 public abstract class TextUIBugReporter extends AbstractBugReporter {
41 private static final Logger LOGGER = Logger.getLogger(TextUIBugReporter.class.getName());
42
4339 private boolean reportStackTrace;
4440
4541 private boolean useLongBugCodes = false;
151147
152148 @Override
153149 public void reportQueuedErrors() {
150 boolean errors = analysisErrors || missingClasses || getQueuedErrors().size() > 0;
154151 analysisErrors = missingClasses = false;
155152 super.reportQueuedErrors();
153 if (errors)
154 emitLine("");
156155 }
157156
158157 @Override
161160 emitLine("The following errors occurred during analysis:");
162161 analysisErrors = true;
163162 }
164 LOGGER.log(Level.SEVERE, error.getMessage(), error.getException());
165163 emitLine("\t" + error.getMessage());
166164 if (error.getExceptionMessage() != null) {
167165 emitLine("\t\t" + error.getExceptionMessage());
2121 import java.io.BufferedOutputStream;
2222 import java.io.BufferedReader;
2323 import java.io.File;
24 import java.io.FileInputStream;
2425 import java.io.FileOutputStream;
2526 import java.io.IOException;
2627 import java.io.OutputStream;
3839
3940 import org.dom4j.DocumentException;
4041
41 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
42 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4243 import edu.umd.cs.findbugs.charsets.UTF8;
4344 import edu.umd.cs.findbugs.config.UserPreferences;
4445 import edu.umd.cs.findbugs.filter.FilterException;
128129
129130 private String redoAnalysisFile = null;
130131
132 private boolean mergeSimilarWarnings = true;
133
131134 private boolean xargs = false;
132135
133136 private boolean scanNestedArchives = true;
144147 public TextUICommandLine() {
145148 addSwitch("-showPlugins", "show list of available detector plugins");
146149
150 addOption("-userPrefs", "filename", "user preferences file, e.g /path/to/project/.settings/edu.umd.cs.findbugs.core.prefs for Eclipse projects");
151
147152 startOptionGroup("Output options:");
148153 addSwitch("-justListOptions", "throw an exception that lists the provided options");
149154 makeOptionUnlisted("-justListOptions");
155
150156
151157 addSwitch("-timestampNow", "set timestamp of results to be current time");
152158 addSwitch("-quiet", "suppress error messages");
158164 addSwitch("-medium", "report only medium and high confidence warnings [default]");
159165 addSwitch("-high", "report only high confidence warnings");
160166 addOption("-maxRank", "rank", "only report issues with a bug rank at least as scary as that provided");
167 addSwitch("-dontCombineWarnings", "Don't combine warnings that differ only in line number");
168
161169 addSwitch("-sortByClass", "sort warnings by class");
162170 addSwitchWithOptionalExtraPart("-xml", "withMessages", "XML output (optionally with messages)");
163171 addSwitch("-xdocs", "xdoc XML output to use with Apache Maven");
169177 addOption("-redoAnalysis", "filename", "Redo analysis using configureation from previous analysis");
170178 addOption("-sourceInfo", "filename", "Specify source info file (line numbers for fields/classes)");
171179 addOption("-projectName", "project name", "Descriptive name of project");
180
172181 addOption("-reanalyze", "filename", "redo analysis in provided file");
173182
174183 addOption("-outputFile", "filename", "Save output in named file");
231240 public boolean applySuppression() {
232241 return applySuppression;
233242 }
243
234244 public boolean justPrintConfiguration() {
235245 return printConfiguration;
236246 }
241251
242252 Map<String, String> parsedOptions = new LinkedHashMap<String, String>();
243253
244 @SuppressWarnings("DM_EXIT")
254 @SuppressFBWarnings("DM_EXIT")
245255 @Override
246256 protected void handleOption(String option, String optionExtraPart) {
247257 parsedOptions.put(option, optionExtraPart);
284294 priorityThreshold = Detector.NORMAL_PRIORITY;
285295 else if (option.equals("-high"))
286296 priorityThreshold = Detector.HIGH_PRIORITY;
297 else if (option.equals("-dontCombineWarnings"))
298 mergeSimilarWarnings = false;
287299 else if (option.equals("-sortByClass"))
288300 bugReporterType = SORTING_REPORTER;
289301 else if (option.equals("-xml")) {
357369 }
358370
359371 protected @CheckForNull File outputFile;
360 @SuppressWarnings("DM_EXIT")
372 @SuppressFBWarnings("DM_EXIT")
361373 @Override
362374 protected void handleOptionWithArgument(String option, String argument) throws IOException {
363375 parsedOptions.put(option, argument);
525537 StringTokenizer tok = new StringTokenizer(argument, File.pathSeparator);
526538 while (tok.hasMoreTokens())
527539 project.addSourceDir(new File(tok.nextToken()).getAbsolutePath());
540 } else if(option.equals("-userPrefs")){
541 UserPreferences prefs = UserPreferences.createDefaultUserPreferences();
542 prefs.read(new FileInputStream(argument));
543 project.setConfiguration(prefs);
528544 } else {
529545 super.handleOptionWithArgument(option, argument);
530546 }
653669
654670 findBugs.setAnalysisFeatureSettings(settingList);
655671
672 findBugs.setMergeSimilarWarnings(mergeSimilarWarnings);
656673 findBugs.setReleaseName(releaseName);
657674 findBugs.setProjectName(projectName);
658675
5353 /**
5454 * Patch level.
5555 */
56 public static final int PATCHLEVEL = 2;
56 public static final int PATCHLEVEL = 3;
5757
5858 /**
5959 * Development version or release candidate?
1818
1919 package edu.umd.cs.findbugs.annotations;
2020
21 import javax.annotation.Nonnull;
22
2123 import edu.umd.cs.findbugs.Priorities;
2224
2325 /**
24 * @author pugh
26 * Describes the confidence with which FindBugs reports a bug instance.
2527 */
2628 public enum Confidence {
2729 HIGH(Priorities.HIGH_PRIORITY), MEDIUM(Priorities.NORMAL_PRIORITY), LOW(Priorities.LOW_PRIORITY), IGNORE(
2830 Priorities.IGNORE_PRIORITY);
2931
3032 private final int confidenceValue;
33
34 /** Given a numeric confidence value, report the corresponding confidence enum value */
35 @Nonnull
36 static public Confidence getConfidence(int prio) {
37 for(Confidence c : values()) {
38 if (prio <= c.confidenceValue) {
39 return c;
40 }
41 }
42 return Confidence.IGNORE;
43 }
3144
3245 public int getConfidenceValue() {
3346 return confidenceValue;
2525 import java.lang.annotation.RetentionPolicy;
2626 import java.lang.annotation.Target;
2727
28 import javax.annotation.ParametersAreNonnullByDefault;
28 import javax.annotation.Nonnegative;
2929 import javax.annotation.meta.TypeQualifierDefault;
30 import javax.swing.JApplet;
30
3131
3232 /**
3333 * Indicates that all members of the class or package should be annotated with
4040 * package, and then use @Nullable only on those parameters, methods or fields
4141 * that you want to allow to be null.
4242 *
43 * @deprecated - use the JSR305 annotations instead,
44 * For example, you can use {@link javax.annotations.ParametersAreNonnullByDefault} instead
45 * of @DefaultAnnotation(NonNull.class), and {@link javax.annotations.meta.TypeQualifierDefault}
46 * in general to define a type qualifier default. The JSR305 {@link javax.annotation.CheckReturnValue}
43 * @deprecated - Use the JSR305 annotations instead.
44 * For example, you can use {@link javax.annotation.ParametersAreNonnullByDefault} instead
45 * of @DefaultAnnotation(NonNull.class) so that method parameters are nonnull by default in the annotated
46 * element. You can also use {@link javax.annotation.meta.TypeQualifierDefault}
47 * in general to define your own annotation that specifies a default type qualifier. For example,
48 * <p><pre><code>
49 * {@link Nonnegative}
50 * {@link TypeQualifierDefault}({@link ElementType#PARAMETER})
51 * public @interface ParametersAreNonnegativeByDefault {}
52 * </code></pre>
53 *
54 * <p>The JSR305 {@link javax.annotation.CheckReturnValue}
4755 * annotation can be applied to a type or package, and it will act as a default for all methods
4856 * in that class or package unless otherwise overridden.
4957 *
3737 * that you want to allow to be null.
3838 *
3939 * @deprecated - use the JSR305 annotations instead,
40 * For example, you can use {@link javax.annotations.ParametersAreNonnullByDefault} instead
41 * of @DefaultAnnotation(NonNull.class), and {@link javax.annotations.meta.TypeQualifierDefault}
40 * For example, you can use {@link javax.annotation.ParametersAreNonnullByDefault} instead
41 * of @DefaultAnnotation(NonNull.class), and {@link javax.annotation.meta.TypeQualifierDefault}
4242 * in general to define a type qualifier default. The JSR305 {@link javax.annotation.CheckReturnValue}
4343 * annotation can be applied to a type or package, and it will act as a default for all methods
4444 * in that class or package unless otherwise overridden.
3434 * overriding method.
3535 *
3636 * @see edu.umd.cs.findbugs.annotations.When
37 *
38 * @deprecated - Use {@link javax.annotation.OverridingMethodsMustInvokeSuper} instead
3739 **/
3840 @Documented
41 @Deprecated
3942 @Target({ ElementType.METHOD })
4043 @Retention(RetentionPolicy.CLASS)
41 @Deprecated
4244 public @interface OverrideMustInvoke {
4345 When value() default When.ANYTIME;
4446
2222
2323 /**
2424 * @author pugh
25 * @deprecated use {@link Confidence} instead
2526 */
2627 @Deprecated
2728 public enum Priority {
2020 import java.lang.annotation.Retention;
2121 import java.lang.annotation.RetentionPolicy;
2222
23 @Retention(RetentionPolicy.CLASS)
23
2424 /**
25 * This annotation is used to suppress FindBugs warnings. It can be used instead of
25 * Used to suppress FindBugs warnings.
26 *
27 * It should be used instead of
2628 * {@link edu.umd.cs.findbugs.annotations.SuppressWarnings} to avoid conflicts with
27 * {@link java.lang.SuppressWarnings}.
29 * {@link java.lang.SuppressWarnings}.
2830 *
2931 */
32 @Retention(RetentionPolicy.CLASS)
3033 public @interface SuppressFBWarnings {
3134 /**
3235 * The set of FindBugs warnings that are to be suppressed in
3336 * annotated element. The value can be a bug category, kind or pattern.
3437 *
35 */
38 */
3639 String[] value() default {};
3740
41 /**
42 * Optional documentation of the reason why the warning is suppressed
43 */
3844 String justification() default "";
3945 }
2222 import java.lang.annotation.RetentionPolicy;
2323 import java.lang.annotation.Target;
2424
25
26 /**
27 * Was used to suppress FindBugs warnings but generates name conflicts with {@link java.lang.SuppressWarnings}.
28 *
29 *
30 * @deprecated - Use {@link SuppressFBWarnings} instead
31 * @author pugh
32 */
2533 @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR,
26 ElementType.LOCAL_VARIABLE, ElementType.PACKAGE })
34 ElementType.LOCAL_VARIABLE, ElementType.PACKAGE })
2735 @Retention(RetentionPolicy.CLASS)
36 @Deprecated
2837 public @interface SuppressWarnings {
2938 /**
30 * The set of warnings that are to be suppressed by the compiler in the
39 * The set of FindBugs warnings that are to be suppressed by the compiler in the
3140 * annotated element.
3241 *
33 * Duplicate names are permitted. The second and successive occurrences of a
34 * name are ignored. The presence of unrecognized warning names is
35 * <i>not</i> an error: Compilers must ignore any warning names they do not
36 * recognize. They are, however, free to emit a warning if an annotation
37 * contains an unrecognized warning name.
38 *
39 * <p>
40 * Compiler vendors should document the warning names they support in
41 * conjunction with this annotation type. They are encouraged to cooperate
42 * to ensure that the same names work across multiple compilers.
4342 */
4443 String[] value() default {};
4544
0 /**
1 * Annotations for FindBugs (mostly deprecated except for {@link edu.umd.cs.findbugs.annotations.SuppressFBWarnings}).
2 *
3 * This annotations are mostly deprecated and replaced by JSR 305 annotations
4 * defined in javax.annotation. The annotations still actively supported are:
5 * <ul>
6 * <li> {@link edu.umd.cs.findbugs.annotations.SuppressFBWarnings} for suppressing FindBugs warnings
7 * <li> Annotations about expected/unexpected warnings in FindBugs regression tests
8 * <ul>
9 * <li> {@link edu.umd.cs.findbugs.annotations.ExpectWarning} Warnings expected to be generated
10 * <li> {@link edu.umd.cs.findbugs.annotations.NoWarning} Warnings that should not be generated
11 * <li> {@link edu.umd.cs.findbugs.annotations.DesireWarning} Warnings we wish to generated
12 * <li> {@link edu.umd.cs.findbugs.annotations.DesireNoWarning} Warnings we wish to not generate generated
13 * </ul></ul>
14 *
15 * There are another set of annotations used by an experimental detector for unclosed resources:
16 * <ul>
17 * <li>{@link edu.umd.cs.findbugs.annotations.CleanupObligation}
18 * <li>{@link edu.umd.cs.findbugs.annotations.CreatesObligation}
19 * <li>{@link edu.umd.cs.findbugs.annotations.DischargesObligation}
20 * </ul>
21
22 */
23 package edu.umd.cs.findbugs.annotations;
24
1717 */
1818
1919 package edu.umd.cs.findbugs.asm;
20
21 import java.util.ArrayList;
2022
2123 import org.objectweb.asm.tree.ClassNode;
2224
5153 return this.getClass().getName();
5254 }
5355
56 @SuppressWarnings("rawtypes")
5457 public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
5558
5659 FBClassReader cr = Global.getAnalysisCache().getClassAnalysis(FBClassReader.class, classDescriptor);
60 this.interfaces = new ArrayList();
61 this.innerClasses = new ArrayList();
62 this.fields = new ArrayList();
63 this.methods = new ArrayList();
5764 cr.accept(this, 0);
5865 }
5966
4444 * allows a checked DataflowAnalysisException to be thrown when invalid bytecode
4545 * is detected. E.g., stack underflows.
4646 * </p>
47 *
47 *
4848 * @author David Hovemeyer
4949 * @see Frame
5050 * @see DataflowAnalysis
5858
5959 /**
6060 * Constructor.
61 *
61 *
6262 * @param cpg
6363 * the ConstantPoolGen of the method to be analyzed
6464 */
6969
7070 /**
7171 * Analyze the given Instruction.
72 *
72 *
7373 * @param ins
7474 * the Instruction
7575 * @throws DataflowAnalysisException
8282 try {
8383 ins.accept(this);
8484 } catch (InvalidBytecodeException e) {
85 System.out.println("Could not analyze " + ins + " frame is " + frame);
86 e.printStackTrace(System.out);
87 throw new DataflowAnalysisException("Invalid bytecode", e);
85 String message = "Invalid bytecode: could not analyze instr. " + ins + " at frame " + frame;
86 throw new DataflowAnalysisException(message, e);
8887 }
8988 }
9089
9796
9897 /**
9998 * Set the frame and Location for the instruction about to be modeled.
100 *
99 *
101100 * @param frame
102101 * the Frame
103102 * @param location
110109
111110 /**
112111 * Get the frame.
113 *
112 *
114113 * @return the Frame object
115114 */
116115 public FrameType getFrame() {
119118
120119 /**
121120 * Get the Location.
122 *
121 *
123122 * @return the Location
124123 */
125124 public Location getLocation() {
156155
157156 /**
158157 * This is called for illegal bytecodes.
159 *
158 *
160159 * @throws InvalidBytecodeException
161160 */
162161 private void illegalBytecode(Instruction ins) {
187186 public void visitIfInstruction(IfInstruction obj) {
188187 }
189188
190 /** To allow for calls to visitNULL2Z and visitNONNULL2Z, this method is made final.
189 /** To allow for calls to visitNULL2Z and visitNONNULL2Z, this method is made final.
191190 * If you want to override it, override visitConversionInstruction2 instead.
192191 */
193192 public final void visitConversionInstruction(ConversionInstruction obj) {
328327 /**
329328 * Model the stack for instructions handled by handleNormalInstruction().
330329 * Subclasses may override to provide analysis-specific behavior.
331 *
330 *
332331 * @param ins
333332 * the Instruction to model
334333 * @param numWordsConsumed
343342 /**
344343 * Primitive to model the stack effect of a single instruction, explicitly
345344 * specifying the value to be pushed on the stack.
346 *
345 *
347346 * @param ins
348347 * the Instruction to model
349348 * @param numWordsConsumed
784783 handleNormalInstruction(obj);
785784 }
786785
787
786
788787 public void visitNULL2Z(NULL2Z obj) {
789788 handleNormalInstruction(obj);
790789 }
791
790
792791 public void visitNONNULL2Z(NONNULL2Z obj) {
793792 handleNormalInstruction(obj);
794793 }
795
794
796795 public void visitI2S(I2S obj) {
797796 handleNormalInstruction(obj);
798797 }
+0
-482
src/java/edu/umd/cs/findbugs/ba/AnalysisCacheToAnalysisContextAdapter.java less more
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2006, University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.ba;
20
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.IdentityHashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import javax.annotation.CheckForNull;
30 import javax.annotation.Nonnull;
31
32 import org.apache.bcel.Repository;
33 import org.apache.bcel.classfile.JavaClass;
34
35 import edu.umd.cs.findbugs.AnalysisCacheToRepositoryAdapter;
36 import edu.umd.cs.findbugs.ba.ch.Subtypes2;
37 import edu.umd.cs.findbugs.ba.jsr305.DirectlyRelevantTypeQualifiersDatabase;
38 import edu.umd.cs.findbugs.ba.npe.IsNullValueAnalysisFeatures;
39 import edu.umd.cs.findbugs.ba.npe.ParameterNullnessPropertyDatabase;
40 import edu.umd.cs.findbugs.ba.npe.ReturnValueNullnessPropertyDatabase;
41 import edu.umd.cs.findbugs.ba.npe.TypeQualifierNullnessAnnotationDatabase;
42 import edu.umd.cs.findbugs.ba.type.FieldStoreTypeDatabase;
43 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
44 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
45 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
46 import edu.umd.cs.findbugs.classfile.Global;
47 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
48 import edu.umd.cs.findbugs.classfile.analysis.ClassInfo;
49 import edu.umd.cs.findbugs.classfile.analysis.MethodInfo;
50 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
51 import edu.umd.cs.findbugs.util.ClassName;
52
53 /**
54 * An AnalysisContext implementation that uses the IAnalysisCache. This class
55 * must only be used by FindBugs2, not the original FindBugs driver.
56 *
57 * @author David Hovemeyer
58 */
59 public class AnalysisCacheToAnalysisContextAdapter extends AnalysisContext {
60
61 static class DelegatingRepositoryLookupFailureCallback implements RepositoryLookupFailureCallback {
62
63 /*
64 * (non-Javadoc)
65 *
66 * @see
67 * edu.umd.cs.findbugs.classfile.IErrorLogger#logError(java.lang.String)
68 */
69 public void logError(String message) {
70 Global.getAnalysisCache().getErrorLogger().logError(message);
71 }
72
73 /*
74 * (non-Javadoc)
75 *
76 * @see
77 * edu.umd.cs.findbugs.classfile.IErrorLogger#logError(java.lang.String,
78 * java.lang.Throwable)
79 */
80 public void logError(String message, Throwable e) {
81 Global.getAnalysisCache().getErrorLogger().logError(message, e);
82 }
83
84 /*
85 * (non-Javadoc)
86 *
87 * @see
88 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(java
89 * .lang.ClassNotFoundException)
90 */
91 public void reportMissingClass(ClassNotFoundException ex) {
92 Global.getAnalysisCache().getErrorLogger().reportMissingClass(ex);
93 }
94
95 /*
96 * (non-Javadoc)
97 *
98 * @see
99 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(edu
100 * .umd.cs.findbugs.classfile.ClassDescriptor)
101 */
102 public void reportMissingClass(ClassDescriptor classDescriptor) {
103 Global.getAnalysisCache().getErrorLogger().reportMissingClass(classDescriptor);
104 }
105
106 /*
107 * (non-Javadoc)
108 *
109 * @see
110 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportSkippedAnalysis(
111 * edu.umd.cs.findbugs.classfile.MethodDescriptor)
112 */
113 public void reportSkippedAnalysis(MethodDescriptor method) {
114 Global.getAnalysisCache().getErrorLogger().reportSkippedAnalysis(method);
115 }
116
117 }
118
119 private RepositoryLookupFailureCallback lookupFailureCallback;
120
121 /**
122 * Constructor.
123 */
124 public AnalysisCacheToAnalysisContextAdapter() {
125 this.lookupFailureCallback = new DelegatingRepositoryLookupFailureCallback();
126 }
127
128 // /* (non-Javadoc)
129 // * @see
130 // edu.umd.cs.findbugs.ba.AnalysisContext#addApplicationClassToRepository(org.apache.bcel.classfile.JavaClass)
131 // */
132 // @Override
133 // public void addApplicationClassToRepository(JavaClass appClass) {
134 // throw new UnsupportedOperationException();
135 // }
136
137 /*
138 * (non-Javadoc)
139 *
140 * @see
141 * edu.umd.cs.findbugs.ba.AnalysisContext#addClasspathEntry(java.lang.String
142 * )
143 */
144 @Override
145 public void addClasspathEntry(String url) throws IOException {
146 throw new UnsupportedOperationException();
147 }
148
149 /*
150 * (non-Javadoc)
151 *
152 * @see edu.umd.cs.findbugs.ba.AnalysisContext#clearClassContextCache()
153 */
154 @Override
155 public void clearClassContextCache() {
156 throw new UnsupportedOperationException();
157 }
158
159 /*
160 * (non-Javadoc)
161 *
162 * @see edu.umd.cs.findbugs.ba.AnalysisContext#clearRepository()
163 */
164 @Override
165 public void clearRepository() {
166 // Set the backing store for the BCEL Repository to
167 // be the AnalysisCache.
168 Repository.setRepository(new AnalysisCacheToRepositoryAdapter());
169 }
170
171 /*
172 * (non-Javadoc)
173 *
174 * @see
175 * edu.umd.cs.findbugs.ba.AnalysisContext#getAnnotationRetentionDatabase()
176 */
177 @Override
178 public AnnotationRetentionDatabase getAnnotationRetentionDatabase() {
179 return getDatabase(AnnotationRetentionDatabase.class);
180 }
181
182 /*
183 * (non-Javadoc)
184 *
185 * @see
186 * edu.umd.cs.findbugs.ba.AnalysisContext#getCheckReturnAnnotationDatabase()
187 */
188 @Override
189 public CheckReturnAnnotationDatabase getCheckReturnAnnotationDatabase() {
190 return getDatabase(CheckReturnAnnotationDatabase.class);
191 }
192
193 /*
194 * (non-Javadoc)
195 *
196 * @see
197 * edu.umd.cs.findbugs.ba.AnalysisContext#getClassContext(org.apache.bcel
198 * .classfile.JavaClass)
199 */
200 @Override
201 public ClassContext getClassContext(JavaClass javaClass) {
202 // This is a bit silly since we're doing an unnecessary
203 // ClassDescriptor->JavaClass lookup.
204 // However, we can be assured that it will succeed.
205
206 ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(
207 ClassName.toSlashedClassName(javaClass.getClassName()));
208
209 try {
210 return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor);
211 } catch (CheckedAnalysisException e) {
212 IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass");
213 ise.initCause(e);
214 throw ise;
215 }
216 }
217
218 /*
219 * (non-Javadoc)
220 *
221 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getClassContextStats()
222 */
223 @Override
224 public String getClassContextStats() {
225 return "<unknown ClassContext stats>";
226 }
227
228 /*
229 * (non-Javadoc)
230 *
231 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getFieldStoreTypeDatabase()
232 */
233 @Override
234 public FieldStoreTypeDatabase getFieldStoreTypeDatabase() {
235 return getDatabase(FieldStoreTypeDatabase.class);
236 }
237
238 /*
239 * (non-Javadoc)
240 *
241 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getJCIPAnnotationDatabase()
242 */
243 @Override
244 public JCIPAnnotationDatabase getJCIPAnnotationDatabase() {
245 return getDatabase(JCIPAnnotationDatabase.class);
246 }
247
248 /*
249 * (non-Javadoc)
250 *
251 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getLookupFailureCallback()
252 */
253 @Override
254 public RepositoryLookupFailureCallback getLookupFailureCallback() {
255 return lookupFailureCallback;
256 }
257
258 private TypeQualifierNullnessAnnotationDatabase tqNullnessDatabase;
259
260 /*
261 * (non-Javadoc)
262 *
263 * @see
264 * edu.umd.cs.findbugs.ba.AnalysisContext#getNullnessAnnotationDatabase()
265 */
266 @Override
267 public INullnessAnnotationDatabase getNullnessAnnotationDatabase() {
268 if (IsNullValueAnalysisFeatures.USE_TYPE_QUALIFIERS) {
269 if (tqNullnessDatabase == null) {
270 tqNullnessDatabase = new TypeQualifierNullnessAnnotationDatabase();
271 }
272 return tqNullnessDatabase;
273 } else {
274 return getDatabase(NullnessAnnotationDatabase.class);
275 }
276 }
277
278 /*
279 * (non-Javadoc)
280 *
281 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getSourceFinder()
282 */
283 @Override
284 public SourceFinder getSourceFinder() {
285 return project.getSourceFinder();
286 }
287
288 /*
289 * (non-Javadoc)
290 *
291 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getSourceInfoMap()
292 */
293 @Override
294 public SourceInfoMap getSourceInfoMap() {
295 return getDatabase(SourceInfoMap.class);
296 }
297
298 // /* (non-Javadoc)
299 // * @see edu.umd.cs.findbugs.ba.AnalysisContext#getSubtypes()
300 // */
301 // @Override
302 // public Subtypes getSubtypes() {
303 // if (Subtypes.DO_NOT_USE) {
304 // throw new IllegalArgumentException();
305 // }
306 // return getDatabase(Subtypes.class);
307 // }
308
309 /*
310 * (non-Javadoc)
311 *
312 * @see
313 * edu.umd.cs.findbugs.ba.AnalysisContext#getUnconditionalDerefParamDatabase
314 * ()
315 */
316 @Override
317 public ParameterNullnessPropertyDatabase getUnconditionalDerefParamDatabase() {
318 return getDatabase(ParameterNullnessPropertyDatabase.class);
319 }
320
321 /*
322 * (non-Javadoc)
323 *
324 * @see edu.umd.cs.findbugs.ba.AnalysisContext#initDatabases()
325 */
326 @Override
327 public void initDatabases() {
328 // Databases are created on-demand - don't need to explicitly create
329 // them
330 }
331
332 /*
333 * (non-Javadoc)
334 *
335 * @see edu.umd.cs.findbugs.ba.AnalysisContext#lookupClass(java.lang.String)
336 */
337 @Override
338 public JavaClass lookupClass(@Nonnull @DottedClassName String className) throws ClassNotFoundException {
339 try {
340 if (className.length() == 0)
341 throw new IllegalArgumentException("Class name is empty");
342 if (!ClassName.isValidClassName(className)) {
343 throw new ClassNotFoundException("Invalid class name: " + className);
344 }
345 return Global.getAnalysisCache().getClassAnalysis(JavaClass.class,
346 DescriptorFactory.instance().getClassDescriptor(ClassName.toSlashedClassName(className)));
347 } catch (CheckedAnalysisException e) {
348 throw new ClassNotFoundException("Class not found: " + className, e);
349 }
350 }
351
352 /*
353 * (non-Javadoc)
354 *
355 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getInnerClassAccessMap()
356 */
357 @Override
358 public InnerClassAccessMap getInnerClassAccessMap() {
359 return getDatabase(InnerClassAccessMap.class);
360 }
361
362 /**
363 * Helper method to get a database without having to worry about a
364 * CheckedAnalysisException.
365 *
366 * @param cls
367 * Class of the database to get
368 * @return the database
369 */
370 private <E> E getDatabase(Class<E> cls) {
371 return Global.getAnalysisCache().getDatabase(cls);
372 }
373
374 /**
375 * Set the collection of class descriptors identifying all application
376 * classes.
377 *
378 * @param appClassCollection
379 * List of ClassDescriptors identifying application classes
380 */
381 public void setAppClassList(List<ClassDescriptor> appClassCollection) {
382
383 // FIXME: we really should drive the progress callback here
384 HashSet<ClassDescriptor> appSet = new HashSet<ClassDescriptor>(appClassCollection);
385
386 Collection<ClassDescriptor> allClassDescriptors = new ArrayList<ClassDescriptor>(DescriptorFactory.instance()
387 .getAllClassDescriptors());
388 for (ClassDescriptor appClass : allClassDescriptors)
389 try {
390 XClass xclass = currentXFactory().getXClass(appClass);
391
392 if (xclass == null)
393 continue;
394
395 // Add the application class to the database
396 if (appSet.contains(appClass))
397 getSubtypes2().addApplicationClass(xclass);
398 else if (xclass instanceof ClassInfo)
399 getSubtypes2().addClass(xclass);
400
401 } catch (Exception e) {
402 AnalysisContext.logError("Unable to get XClass for " + appClass, e);
403 }
404
405 if (true && Subtypes2.DEBUG) {
406 System.out.println(getSubtypes2().getGraph().getNumVertices() + " vertices in inheritance graph");
407 }
408 }
409
410 /*
411 * (non-Javadoc)
412 *
413 * @see edu.umd.cs.findbugs.ba.AnalysisContext#updateDatabases(int)
414 */
415 @Override
416 public void updateDatabases(int pass) {
417 if (pass == 0) {
418 getCheckReturnAnnotationDatabase().loadAuxiliaryAnnotations();
419 getNullnessAnnotationDatabase().loadAuxiliaryAnnotations();
420 }
421
422 }
423
424 /*
425 * (non-Javadoc)
426 *
427 * @see
428 * edu.umd.cs.findbugs.ba.AnalysisContext#getReturnValueNullnessPropertyDatabase
429 * ()
430 */
431 @Override
432 public ReturnValueNullnessPropertyDatabase getReturnValueNullnessPropertyDatabase() {
433 return getDatabase(ReturnValueNullnessPropertyDatabase.class);
434 }
435
436 // private Subtypes2 subtypes2;
437
438 /*
439 * (non-Javadoc)
440 *
441 * @see edu.umd.cs.findbugs.ba.AnalysisContext#getSubtypes2()
442 */
443 @Override
444 public Subtypes2 getSubtypes2() {
445 return Global.getAnalysisCache().getDatabase(Subtypes2.class);
446 }
447
448 /*
449 * (non-Javadoc)
450 *
451 * @see edu.umd.cs.findbugs.ba.AnalysisContext#
452 * getDirectlyRelevantTypeQualifiersDatabase()
453 */
454 @Override
455 public DirectlyRelevantTypeQualifiersDatabase getDirectlyRelevantTypeQualifiersDatabase() {
456 return Global.getAnalysisCache().getDatabase(DirectlyRelevantTypeQualifiersDatabase.class);
457 }
458
459 @Override
460 public @CheckForNull
461 XMethod getBridgeTo(MethodInfo m) {
462 return bridgeTo.get(m);
463 }
464
465 @Override
466 public @CheckForNull
467 XMethod getBridgeFrom(MethodInfo m) {
468 return bridgeFrom.get(m);
469 }
470
471 @Override
472 public void setBridgeMethod(MethodInfo from, MethodInfo to) {
473 bridgeTo.put(from, to);
474 bridgeFrom.put(to, from);
475 }
476
477 final Map<MethodInfo, MethodInfo> bridgeTo = new IdentityHashMap<MethodInfo, MethodInfo>();
478
479 final Map<MethodInfo, MethodInfo> bridgeFrom = new IdentityHashMap<MethodInfo, MethodInfo>();
480
481 }
2121 import java.io.File;
2222 import java.io.IOException;
2323 import java.io.InputStream;
24 import java.util.ArrayList;
2425 import java.util.BitSet;
2526 import java.util.Collection;
27 import java.util.HashSet;
28 import java.util.IdentityHashMap;
29 import java.util.List;
30 import java.util.Map;
2631
2732 import javax.annotation.CheckForNull;
2833 import javax.annotation.Nonnull;
3338 import org.apache.bcel.classfile.JavaClass;
3439
3540 import edu.umd.cs.findbugs.AbstractBugReporter;
41 import edu.umd.cs.findbugs.AnalysisCacheToRepositoryAdapter;
3642 import edu.umd.cs.findbugs.AnalysisLocal;
3743 import edu.umd.cs.findbugs.BugInstance.NoSuchBugPattern;
3844 import edu.umd.cs.findbugs.Project;
4652 import edu.umd.cs.findbugs.ba.jsr305.DirectlyRelevantTypeQualifiersDatabase;
4753 import edu.umd.cs.findbugs.ba.npe.ParameterNullnessPropertyDatabase;
4854 import edu.umd.cs.findbugs.ba.npe.ReturnValueNullnessPropertyDatabase;
55 import edu.umd.cs.findbugs.ba.npe.TypeQualifierNullnessAnnotationDatabase;
4956 import edu.umd.cs.findbugs.ba.type.FieldStoreTypeDatabase;
5057 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
5158 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
5360 import edu.umd.cs.findbugs.classfile.FieldOrMethodDescriptor;
5461 import edu.umd.cs.findbugs.classfile.Global;
5562 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
63 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
5664 import edu.umd.cs.findbugs.classfile.analysis.ClassData;
65 import edu.umd.cs.findbugs.classfile.analysis.ClassInfo;
5766 import edu.umd.cs.findbugs.classfile.analysis.MethodInfo;
5867 import edu.umd.cs.findbugs.detect.UnreadFields;
5968 import edu.umd.cs.findbugs.detect.UnreadFieldsData;
6069 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
70 import edu.umd.cs.findbugs.util.ClassName;
6171
6272 /**
6373 * A context for analysis of a complete project. This serves as the repository
7484 * @see edu.umd.cs.findbugs.classfile.Global
7585 */
7686 @NotThreadSafe
77 public abstract class AnalysisContext {
87 public class AnalysisContext {
7888 public static final boolean DEBUG = SystemProperties.getBoolean("findbugs.analysiscontext.debug");
7989
8090 public static final boolean IGNORE_BUILTIN_MODELS = SystemProperties.getBoolean("findbugs.ignoreBuiltinModels");
111121 }
112122 };
113123
114 public abstract INullnessAnnotationDatabase getNullnessAnnotationDatabase();
115
116 public abstract CheckReturnAnnotationDatabase getCheckReturnAnnotationDatabase();
117
118 public abstract AnnotationRetentionDatabase getAnnotationRetentionDatabase();
119
120 public abstract JCIPAnnotationDatabase getJCIPAnnotationDatabase();
124
121125
122126 /**
123127 * save the original SyntheticRepository so we may obtain JavaClass objects
140144
141145 private String databaseOutputDir;
142146
143 protected AnalysisContext() {
147 public AnalysisContext() {
144148 this.boolPropertySet = new BitSet();
149 this.lookupFailureCallback = new DelegatingRepositoryLookupFailureCallback();
150
145151 }
146152
147153 private void clear() {
152158
153159
154160 /**
155 * Instantiate the CheckReturnAnnotationDatabase. Do this after the
156 * repository has been set up.
157 */
158 public abstract void initDatabases();
159
160 /**
161 * After a pass has been completed, allow the analysis context to update
162 * information.
163 *
164 * @param pass
165 * -- the first pass is pass 0
166 */
167 public abstract void updateDatabases(int pass);
168
169 /**
170161 * Get the AnalysisContext associated with this thread
171162 */
172163 static public AnalysisContext currentAnalysisContext() {
249240 this.unreadFields = unreadFields;
250241 }
251242
252 public abstract DirectlyRelevantTypeQualifiersDatabase getDirectlyRelevantTypeQualifiersDatabase();
253
254 private static boolean skipReportingMissingClass(@CheckForNull @DottedClassName String missing) {
243 private static boolean skipReportingMissingClass(@CheckForNull @DottedClassName String missing) {
255244 return missing == null || missing.length() == 0 || missing.charAt(0) == '[' || missing.endsWith("package-info");
256245 }
257246
373362 return oldValue;
374363 }
375364
376 /**
377 * Get the lookup failure callback.
378 */
379 public abstract RepositoryLookupFailureCallback getLookupFailureCallback();
380365
381366 /**
382367 * Set the source path.
384369 public final void setProject(Project project) {
385370 this.project = project;
386371 }
387
388 /**
389 * Get the SourceFinder, for finding source files.
390 */
391 public abstract SourceFinder getSourceFinder();
392
393 // /**
394 // * Get the Subtypes database.
395 // *
396 // * @return the Subtypes database
397 // */
398 // @Deprecated // use Subtypes2 instead
399 // public abstract Subtypes getSubtypes();
400
401 /**
402 * Clear the BCEL Repository in preparation for analysis.
403 */
404 public abstract void clearRepository();
405
406 /**
407 * Clear the ClassContext cache. This should be done between analysis
408 * passes.
409 */
410 public abstract void clearClassContextCache();
411
412 /**
413 * Add an entry to the Repository's classpath.
414 *
415 * @param url
416 * the classpath entry URL
417 * @throws IOException
418 */
419 public abstract void addClasspathEntry(String url) throws IOException;
420372
421373 // /**
422374 // * Add an application class to the repository.
513465 * Lookup a class.
514466 * <em>Use this method instead of Repository.lookupClass().</em>
515467 *
516 * @param className
517 * the name of the class
518 * @return the JavaClass representing the class
519 * @throws ClassNotFoundException
520 * (but not really)
521 */
522 public abstract JavaClass lookupClass(@Nonnull @DottedClassName String className) throws ClassNotFoundException;
523
524 /**
525 * Lookup a class.
526 * <em>Use this method instead of Repository.lookupClass().</em>
527 *
528468 * @param classDescriptor
529469 * descriptor specifying the class to look up
530470 * @return the class
586526 }
587527
588528 /**
589 * Get the ClassContext for a class.
590 *
591 * @param javaClass
592 * the class
593 * @return the ClassContext for that class
594 */
595 public abstract ClassContext getClassContext(JavaClass javaClass);
596
597 /**
598 * Get stats about hit rate for ClassContext cache.
599 *
600 * @return stats about hit rate for ClassContext cache
601 */
602 public abstract String getClassContextStats();
603
604 /**
605529 * If possible, load interprocedural property databases.
606530 */
607531 public final void loadInterproceduralDatabases() {
650574 }
651575
652576 /**
653 * Get the SourceInfoMap.
654 */
655 public abstract SourceInfoMap getSourceInfoMap();
656
657 /**
658577 * Set the interprocedural database input directory.
659578 *
660579 * @param databaseInputDir
696615 return databaseOutputDir;
697616 }
698617
699 /**
700 * Get the property database recording the types of values stored into
701 * fields.
702 *
703 * @return the database, or null if there is no database available
704 */
705 public abstract FieldStoreTypeDatabase getFieldStoreTypeDatabase();
706
707 /**
708 * Get the property database recording which methods unconditionally
709 * dereference parameters.
710 *
711 * @return the database, or null if there is no database available
712 */
713 public abstract ParameterNullnessPropertyDatabase getUnconditionalDerefParamDatabase();
714
715 /**
716 * Get the property database recording which methods always return nonnull
717 * values
718 *
719 * @return the database, or null if there is no database available
720 */
721 public abstract ReturnValueNullnessPropertyDatabase getReturnValueNullnessPropertyDatabase();
618
722619
723620 /**
724621 * Load an interprocedural property database.
824721 }
825722 }
826723
827 public abstract InnerClassAccessMap getInnerClassAccessMap();
828
829724 /**
830725 * Set the current analysis context for this thread.
831726 *
845740 currentAnalysisContext.remove();
846741 }
847742
848 /**
849 * Get the Subtypes2 inheritance hierarchy database.
850 */
851 public abstract Subtypes2 getSubtypes2();
852743
853744 /**
854745 * Get Collection of all XClass objects seen so far.
859750 return getSubtypes2().getXClassCollection();
860751 }
861752
862 public abstract @CheckForNull
863 XMethod getBridgeTo(MethodInfo m);
864
865 public abstract @CheckForNull
866 XMethod getBridgeFrom(MethodInfo m);
867
868 public abstract void setBridgeMethod(MethodInfo from, MethodInfo to);
869
870753 private final SuppressionMatcher suppressionMatcher = new SuppressionMatcher();
754
755 private TypeQualifierNullnessAnnotationDatabase tqNullnessDatabase;
756
757 protected final RepositoryLookupFailureCallback lookupFailureCallback;
758
759 final Map<MethodInfo, MethodInfo> bridgeTo = new IdentityHashMap<MethodInfo, MethodInfo>();
760
761 final Map<MethodInfo, MethodInfo> bridgeFrom = new IdentityHashMap<MethodInfo, MethodInfo>();
871762
872763 public SuppressionMatcher getSuppressionMatcher() {
873764 return suppressionMatcher;
874765 }
766
767 /**
768 * Add an entry to the Repository's classpath.
769 *
770 * @param url
771 * the classpath entry URL
772 * @throws IOException
773 */
774 public void addClasspathEntry(String url) throws IOException {
775 throw new UnsupportedOperationException();
776 }
777
778 /**
779 * Clear the ClassContext cache. This should be done between analysis
780 * passes.
781 */
782 public void clearClassContextCache() {
783 throw new UnsupportedOperationException();
784 }
785
786 /**
787 * Clear the BCEL Repository in preparation for analysis.
788 */
789 public void clearRepository() {
790 // Set the backing store for the BCEL Repository to
791 // be the AnalysisCache.
792 Repository.setRepository(new AnalysisCacheToRepositoryAdapter());
793 }
794
795
796 public AnnotationRetentionDatabase getAnnotationRetentionDatabase() {
797 return getDatabase(AnnotationRetentionDatabase.class);
798 }
799
800
801 public CheckReturnAnnotationDatabase getCheckReturnAnnotationDatabase() {
802 return getDatabase(CheckReturnAnnotationDatabase.class);
803 }
804
805 /**
806 * Get the ClassContext for a class.
807 *
808 * @param javaClass
809 * the class
810 * @return the ClassContext for that class
811 */
812 public ClassContext getClassContext(JavaClass javaClass) {
813 // This is a bit silly since we're doing an unnecessary
814 // ClassDescriptor->JavaClass lookup.
815 // However, we can be assured that it will succeed.
816
817 ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(
818 ClassName.toSlashedClassName(javaClass.getClassName()));
819
820 try {
821 return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor);
822 } catch (CheckedAnalysisException e) {
823 IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass");
824 ise.initCause(e);
825 throw ise;
826 }
827 }
828
829 /**
830 * Get stats about hit rate for ClassContext cache.
831 *
832 * @return stats about hit rate for ClassContext cache
833 */
834 public String getClassContextStats() {
835 return "<unknown ClassContext stats>";
836 }
837
838 /**
839 * Get the property database recording the types of values stored into
840 * fields.
841 *
842 * @return the database, or null if there is no database available
843 */
844 public FieldStoreTypeDatabase getFieldStoreTypeDatabase() {
845 return getDatabase(FieldStoreTypeDatabase.class);
846 }
847
848
849 public JCIPAnnotationDatabase getJCIPAnnotationDatabase() {
850 return getDatabase(JCIPAnnotationDatabase.class);
851 }
852
853 /**
854 * Get the lookup failure callback.
855 */
856 public RepositoryLookupFailureCallback getLookupFailureCallback() {
857 return lookupFailureCallback;
858 }
859
860 /**
861 * Get the SourceFinder, for finding source files.
862 */
863 public SourceFinder getSourceFinder() {
864 return project.getSourceFinder();
865 }
866
867 /**
868 * Get the SourceInfoMap.
869 */
870 public SourceInfoMap getSourceInfoMap() {
871 return getDatabase(SourceInfoMap.class);
872 }
873
874 /**
875 * Get the property database recording which methods unconditionally
876 * dereference parameters.
877 *
878 * @return the database, or null if there is no database available
879 */
880 public ParameterNullnessPropertyDatabase getUnconditionalDerefParamDatabase() {
881 return getDatabase(ParameterNullnessPropertyDatabase.class);
882 }
883
884 /**
885 * Instantiate the CheckReturnAnnotationDatabase. Do this after the
886 * repository has been set up.
887 */
888
889 public void initDatabases() {
890 // Databases are created on-demand - don't need to explicitly create
891 // them
892 }
893
894 /**
895 * Lookup a class.
896 * <em>Use this method instead of Repository.lookupClass().</em>
897 *
898 * @param className
899 * the name of the class
900 * @return the JavaClass representing the class
901 * @throws ClassNotFoundException
902 * (but not really)
903 */
904 public JavaClass lookupClass(@Nonnull @DottedClassName String className) throws ClassNotFoundException {
905 try {
906 if (className.length() == 0)
907 throw new IllegalArgumentException("Class name is empty");
908 if (!ClassName.isValidClassName(className)) {
909 throw new ClassNotFoundException("Invalid class name: " + className);
910 }
911 return Global.getAnalysisCache().getClassAnalysis(JavaClass.class,
912 DescriptorFactory.instance().getClassDescriptor(ClassName.toSlashedClassName(className)));
913 } catch (CheckedAnalysisException e) {
914 throw new ClassNotFoundException("Class not found: " + className, e);
915 }
916 }
917
918 public InnerClassAccessMap getInnerClassAccessMap() {
919 return getDatabase(InnerClassAccessMap.class);
920 }
921
922 public void setAppClassList(List<ClassDescriptor> appClassCollection) {
923
924 // FIXME: we really should drive the progress callback here
925 HashSet<ClassDescriptor> appSet = new HashSet<ClassDescriptor>(appClassCollection);
926
927 Collection<ClassDescriptor> allClassDescriptors = new ArrayList<ClassDescriptor>(DescriptorFactory.instance()
928 .getAllClassDescriptors());
929 for (ClassDescriptor appClass : allClassDescriptors)
930 try {
931 XClass xclass = currentXFactory().getXClass(appClass);
932
933 if (xclass == null)
934 continue;
935
936 // Add the application class to the database
937 if (appSet.contains(appClass))
938 getSubtypes2().addApplicationClass(xclass);
939 else if (xclass instanceof ClassInfo)
940 getSubtypes2().addClass(xclass);
941
942 } catch (Exception e) {
943 AnalysisContext.logError("Unable to get XClass for " + appClass, e);
944 }
945
946 if (true && Subtypes2.DEBUG) {
947 System.out.println(getSubtypes2().getGraph().getNumVertices() + " vertices in inheritance graph");
948 }
949 }
950
951 /**
952 * After a pass has been completed, allow the analysis context to update
953 * information.
954 *
955 * @param pass
956 * -- the first pass is pass 0
957 */
958 public void updateDatabases(int pass) {
959 if (pass == 0) {
960 getCheckReturnAnnotationDatabase().loadAuxiliaryAnnotations();
961 getNullnessAnnotationDatabase().loadAuxiliaryAnnotations();
962 }
963
964 }
965
966 /**
967 * Get the property database recording which methods always return nonnull
968 * values
969 *
970 * @return the database, or null if there is no database available
971 */
972 public ReturnValueNullnessPropertyDatabase getReturnValueNullnessPropertyDatabase() {
973 return getDatabase(ReturnValueNullnessPropertyDatabase.class);
974 }
975
976 /**
977 * Get the Subtypes2 inheritance hierarchy database.
978 */
979 public Subtypes2 getSubtypes2() {
980 return Global.getAnalysisCache().getDatabase(Subtypes2.class);
981 }
982
983
984 public DirectlyRelevantTypeQualifiersDatabase getDirectlyRelevantTypeQualifiersDatabase() {
985 return Global.getAnalysisCache().getDatabase(DirectlyRelevantTypeQualifiersDatabase.class);
986 }
987
988
989 @CheckForNull
990 public XMethod getBridgeTo(MethodInfo m) {
991 return bridgeTo.get(m);
992 }
993
994
995 @CheckForNull
996 public XMethod getBridgeFrom(MethodInfo m) {
997 return bridgeFrom.get(m);
998 }
999
1000
1001 public void setBridgeMethod(MethodInfo from, MethodInfo to) {
1002 bridgeTo.put(from, to);
1003 bridgeFrom.put(to, from);
1004 }
1005
1006 public TypeQualifierNullnessAnnotationDatabase getNullnessAnnotationDatabase() {
1007 if (tqNullnessDatabase == null) {
1008 tqNullnessDatabase = new TypeQualifierNullnessAnnotationDatabase();
1009 }
1010 return tqNullnessDatabase;
1011
1012 }
1013
1014 protected <E> E getDatabase(Class<E> cls) {
1015 return Global.getAnalysisCache().getDatabase(cls);
1016 }
1017
1018 static class DelegatingRepositoryLookupFailureCallback implements RepositoryLookupFailureCallback {
1019
1020 /*
1021 * (non-Javadoc)
1022 *
1023 * @see
1024 * edu.umd.cs.findbugs.classfile.IErrorLogger#logError(java.lang.String)
1025 */
1026 public void logError(String message) {
1027 Global.getAnalysisCache().getErrorLogger().logError(message);
1028 }
1029
1030 /*
1031 * (non-Javadoc)
1032 *
1033 * @see
1034 * edu.umd.cs.findbugs.classfile.IErrorLogger#logError(java.lang.String,
1035 * java.lang.Throwable)
1036 */
1037 public void logError(String message, Throwable e) {
1038 Global.getAnalysisCache().getErrorLogger().logError(message, e);
1039 }
1040
1041 /*
1042 * (non-Javadoc)
1043 *
1044 * @see
1045 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(java
1046 * .lang.ClassNotFoundException)
1047 */
1048 public void reportMissingClass(ClassNotFoundException ex) {
1049 Global.getAnalysisCache().getErrorLogger().reportMissingClass(ex);
1050 }
1051
1052 /*
1053 * (non-Javadoc)
1054 *
1055 * @see
1056 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(edu
1057 * .umd.cs.findbugs.classfile.ClassDescriptor)
1058 */
1059 public void reportMissingClass(ClassDescriptor classDescriptor) {
1060 Global.getAnalysisCache().getErrorLogger().reportMissingClass(classDescriptor);
1061 }
1062
1063 /*
1064 * (non-Javadoc)
1065 *
1066 * @see
1067 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportSkippedAnalysis(
1068 * edu.umd.cs.findbugs.classfile.MethodDescriptor)
1069 */
1070 public void reportSkippedAnalysis(MethodDescriptor method) {
1071 Global.getAnalysisCache().getErrorLogger().reportSkippedAnalysis(method);
1072 }
1073
1074 }
1075
8751076 }
8761077
8771078 // vim:ts=4
4444 /**
4545 * Mark methodref constant pool entries of methods that are likely to implement
4646 * assertions. This is useful for pruning likely false paths.
47 *
47 *
4848 * @author David Hovemeyer
4949 */
5050 public class AssertionMethods implements Constants {
5555 * Bitset of methodref constant pool indexes referring to likely assertion
5656 * methods.
5757 */
58 private BitSet assertionMethodRefSet;
58 private final BitSet assertionMethodRefSet;
5959
6060 private static class UserAssertionMethod {
61 private String className;
62
63 private String methodName;
61 private final String className;
62
63 private final String methodName;
6464
6565 public UserAssertionMethod(String className, String methodName) {
6666 this.className = className;
7676 }
7777 }
7878
79 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
7980 private static final List<UserAssertionMethod> userAssertionMethodList = new ArrayList<UserAssertionMethod>();
8081
8182 static {
9697
9798 /**
9899 * Constructor.
99 *
100 *
100101 * @param jclass
101102 * the JavaClass containing the methodrefs
102103 */
121122
122123 String classNameLC = className.toLowerCase();
123124 String methodNameLC = methodName.toLowerCase();
124
125
125126 boolean voidReturnType = methodSig.endsWith(")V");
126127 boolean boolReturnType = methodSig.endsWith(")Z");
127
128
128
129
129130
130131 if (DEBUG) {
131132 System.out.print("Is " + className + "." + methodName + " assertion method: " + voidReturnType);
142143 || methodNameLC.equals("exit") || methodNameLC.startsWith("fail")
143144 || methodNameLC.startsWith("fatal") || methodNameLC.indexOf("assert") >= 0
144145 || methodNameLC.indexOf("legal") >= 0 || methodNameLC.indexOf("error") >= 0
145 || methodNameLC.indexOf("abort") >= 0
146 // || methodNameLC.indexOf("check") >= 0
146 || methodNameLC.indexOf("abort") >= 0
147 // || methodNameLC.indexOf("check") >= 0
147148 || methodNameLC.indexOf("failed") >= 0) || methodName.equals("addOrThrowException")) {
148149 assertionMethodRefSet.set(i);
149150 if (DEBUG) {
193194
194195 /**
195196 * Does the given instruction refer to a likely assertion method?
196 *
197 *
197198 * @param ins
198199 * the instruction
199200 * @return true if the instruction likely refers to an assertion, false if
2828 import org.apache.bcel.generic.CodeExceptionGen;
2929 import org.apache.bcel.generic.InstructionHandle;
3030
31 import edu.umd.cs.findbugs.ba.type.TypeMerger;
3132 import edu.umd.cs.findbugs.graph.AbstractVertex;
3233
3334 /**
396397 * @param exceptionGen
397398 * the CodeExceptionGen object for the block
398399 */
399 public void setExceptionGen(CodeExceptionGen exceptionGen) {
400 this.exceptionGen = exceptionGen;
401 }
402
403 /**
400 public void setExceptionGen(TypeMerger m, CodeExceptionGen exceptionGen) {
401 if (this.exceptionGen != null) {
402 AnalysisContext.logError("Multiple exception handlers");
403 }
404
405 this.exceptionGen = exceptionGen;
406 }
407
408 /**
404409 * Return whether or not the basic block contains the given instruction.
405410 *
406411 * @param handle
1919 package edu.umd.cs.findbugs.ba;
2020
2121 import java.util.BitSet;
22 import java.util.Collections;
2223 import java.util.HashMap;
2324 import java.util.IdentityHashMap;
2425 import java.util.Iterator;
6869 import org.apache.bcel.generic.ReturnInstruction;
6970
7071 import edu.umd.cs.findbugs.SystemProperties;
72 import edu.umd.cs.findbugs.ba.type.ExceptionSetFactory;
73 import edu.umd.cs.findbugs.ba.type.StandardTypeMerger;
7174 import edu.umd.cs.findbugs.bcel.generic.NONNULL2Z;
7275 import edu.umd.cs.findbugs.bcel.generic.NULL2Z;
76 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
77 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
7378 import edu.umd.cs.findbugs.classfile.FieldDescriptor;
79 import edu.umd.cs.findbugs.classfile.Global;
80 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
81 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
7482
7583 /**
7684 * A CFGBuilder that really tries to construct accurate control flow graphs. The
166174 return edgeType;
167175 }
168176 }
169
170 private static final LinkedList<EscapeTarget> emptyEscapeTargetList = new LinkedList<EscapeTarget>();
171177
172178 /**
173179 * JSR subroutine. The top level subroutine is where execution starts. Each
318324 // Block is an exception handler?
319325 CodeExceptionGen exceptionGen = exceptionHandlerMap.getHandlerForStartInstruction(start);
320326 if (exceptionGen != null)
321 block.setExceptionGen(exceptionGen);
327 block.setExceptionGen(null, exceptionGen);
322328
323329 addItem(new WorkListItem(start, block));
324330 }
436442 public Iterator<EscapeTarget> escapeTargetIterator(BasicBlock sourceBlock) {
437443 List<EscapeTarget> escapeTargetList = escapeTargetListMap.get(sourceBlock);
438444 if (escapeTargetList == null)
439 escapeTargetList = emptyEscapeTargetList;
445 escapeTargetList = Collections.emptyList();
440446 return escapeTargetList.iterator();
441447 }
442448 }
597603 * @param methodGen
598604 * the method to build a CFG for
599605 */
600 public BetterCFGBuilder2(@Nonnull MethodGen methodGen) {
606 public BetterCFGBuilder2(@Nonnull MethodDescriptor descriptor, @Nonnull MethodGen methodGen) {
601607 this.methodGen = methodGen;
602608 this.cpg = methodGen.getConstantPool();
603 this.exceptionHandlerMap = new ExceptionHandlerMap(methodGen);
609 IAnalysisCache analysisCache = Global.getAnalysisCache();
610 StandardTypeMerger merger = null;
611 ExceptionSetFactory exceptionSetFactory;
612 try {
613 exceptionSetFactory = analysisCache.getMethodAnalysis(ExceptionSetFactory.class, descriptor);
614 merger = new StandardTypeMerger( AnalysisContext.currentAnalysisContext()
615 .getLookupFailureCallback(), exceptionSetFactory);
616 } catch (CheckedAnalysisException e) {
617 AnalysisContext.logError("Unable to generate exceptionSetFactory for " + descriptor, e);
618 }
619
620
621 this.exceptionHandlerMap = new ExceptionHandlerMap(methodGen, merger);
604622 this.usedInstructionSet = new BitSet();
605623 this.jsrSubroutineMap = new IdentityHashMap<InstructionHandle, Subroutine>();
606624 this.subroutineWorkList = new LinkedList<Subroutine>();
10401058
10411059 // Set exception handler status
10421060 if (subBlock.isExceptionHandler())
1043 resultBlock.setExceptionGen(subBlock.getExceptionGen());
1061 resultBlock.setExceptionGen(null, subBlock.getExceptionGen());
10441062
10451063 // Add control edges (including inlining JSR subroutines)
10461064 Iterator<Edge> edgeIter = subCFG.outgoingEdgeIterator(subBlock);
11761194 if (methodName != null && !method.getName().equals(methodName))
11771195 continue;
11781196
1197 MethodDescriptor descriptor = DescriptorFactory.instance().getMethodDescriptor(jclass, method);
11791198 MethodGen methodGen = new MethodGen(method, jclass.getClassName(), classGen.getConstantPool());
11801199
1181 CFGBuilder cfgBuilder = new BetterCFGBuilder2(methodGen);
1200 CFGBuilder cfgBuilder = new BetterCFGBuilder2(descriptor, methodGen);
11821201 cfgBuilder.build();
11831202
11841203 CFG cfg = cfgBuilder.getCFG();
2222
2323 import org.apache.bcel.generic.MethodGen;
2424
25 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
26
2527
2628 /**
2729 * Factory object to create CFGBuilders for methods. Using a CFGBuilderFactory
3436 * @see CFGBuilder
3537 */
3638 public class CFGBuilderFactory {
39
3740 /**
3841 * Create a CFGBuilder to build a CFG for given method.
3942 *
4144 * the method
4245 * @return a CFGBuilder for the method
4346 */
44 public static CFGBuilder create(@Nonnull MethodGen methodGen) {
45 return new BetterCFGBuilder2(methodGen);
47 public static CFGBuilder create(@Nonnull MethodDescriptor descriptor, @Nonnull MethodGen methodGen) {
48 return new BetterCFGBuilder2(descriptor, methodGen);
4649 }
4750 }
4851
141141 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_LOW);
142142 addMethodAnnotation("java.lang.String", "<init>", "()V", false, CheckReturnValueAnnotation.CHECK_RETURN_VALUE_LOW);
143143 addDefaultMethodAnnotation("java.math.BigDecimal", CheckReturnValueAnnotation.CHECK_RETURN_VALUE_HIGH);
144 addMethodAnnotation("java.math.BigDecimal", "inflate", "()Ljava/math/BigDecimal;", false,
145 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE);
144 addMethodAnnotation("java.math.BigDecimal", "inflate", "()Ljava/math/BigInteger;", false,
145 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE);
146 addMethodAnnotation("java.math.BigDecimal", "precision", "()I", false,
147 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
148
146149 addMethodAnnotation("java.math.BigDecimal", "toBigIntegerExact", "()Ljava/math/BigInteger;", false,
147150 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE);
148151 addMethodAnnotation("java.math.BigDecimal", "longValueExact", "()J", false,
161164 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE);
162165
163166 addDefaultMethodAnnotation("java.math.BigInteger", CheckReturnValueAnnotation.CHECK_RETURN_VALUE_HIGH);
164 addMethodAnnotation("java.math.BigInteger", "precision", "()I", true,
165 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
166167 addMethodAnnotation("java.math.BigInteger", "addOne", "([IIII)I", true,
167168 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE);
168169 addMethodAnnotation("java.math.BigInteger", "subN", "([I[II)I", true,
188189 addDefaultMethodAnnotation("jsr166z.forkjoin.ParallelDoubleArray", CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
189190
190191
191 addMethodAnnotation(java.sql.Statement.class, "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;", false,
192 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
193 addMethodAnnotation(java.sql.PreparedStatement.class, "executeQuery", "()Ljava/sql/ResultSet;", false,
192 addMethodAnnotation(java.sql.Statement.class, "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;", false,
193 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
194 addMethodAnnotation(java.sql.PreparedStatement.class, "executeQuery", "()Ljava/sql/ResultSet;", false,
194195 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM);
195196 AnalysisContext.currentAnalysisContext().setMissingClassWarningsSuppressed(missingClassWarningsSuppressed);
196197
211212 */
212213 private void addWarningAboutSubmit(Class<? extends ExecutorService> c) {
213214 addMethodAnnotation(c.getName(), "submit",
214 "(Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;", false,
215 "(Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;", false,
215216 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM_BAD_PRACTICE);
216217 addMethodAnnotation(c.getName(), "submit",
217 "(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;", false,
218 "(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;", false,
218219 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_LOW_BAD_PRACTICE);
219220 addMethodAnnotation(c.getName(), "submit",
220 "(Ljava/lang/Runnable;Ljava/lang/Object;)Ljava/util/concurrent/Future;", false,
221 "(Ljava/lang/Runnable;Ljava/lang/Object;)Ljava/util/concurrent/Future;", false,
221222 CheckReturnValueAnnotation.CHECK_RETURN_VALUE_MEDIUM_BAD_PRACTICE);
222223 }
223224
7575 * A ClassContext caches all of the auxiliary objects used to analyze the
7676 * methods of a class. That way, these objects don't need to be created over and
7777 * over again.
78 *
78 *
7979 * @author David Hovemeyer
8080 */
8181 public class ClassContext {
106106
107107 /**
108108 * Constructor.
109 *
109 *
110110 * @param jclass
111111 * the JavaClass
112112 */
139139 /**
140140 * Store a method analysis object. Note that the cached analysis object
141141 * could be a special value (indicating null or an exception).
142 *
142 *
143143 * @param analysisClass
144144 * class the method analysis object belongs to
145145 * @param methodDescriptor
157157
158158 /**
159159 * Retrieve a method analysis object.
160 *
160 *
161161 * @param analysisClass
162162 * class the method analysis object should belong to
163163 * @param methodDescriptor
164164 * method descriptor identifying the analyzed method
165165 * @return the analysis object
166 * @throws CheckedAnalysisException
167166 */
168167 public Object getMethodAnalysis(Class<?> analysisClass, MethodDescriptor methodDescriptor) {
169168 Map<MethodDescriptor, Object> objectMap = getObjectMap(analysisClass);
176175
177176 /**
178177 * Purge all CFG-based method analyses for given method.
179 *
178 *
180179 * @param methodDescriptor
181180 * method descriptor identifying method to purge
182181 */
217216
218217 /**
219218 * Look up the Method represented by given MethodGen.
220 *
219 *
221220 * @param methodGen
222221 * a MethodGen
223222 * @return the Method represented by the MethodGen
263262
264263 /**
265264 * Get the RepositoryLookupFailureCallback.
266 *
265 *
267266 * @return the RepositoryLookupFailureCallback
268267 */
269268 public RepositoryLookupFailureCallback getLookupFailureCallback() {
272271
273272 /**
274273 * Get a MethodGen object for given method.
275 *
274 *
276275 * @param method
277276 * the method
278277 * @return the MethodGen object for the method, or null if the method has no
289288 * will be done. Because the CFG pruning can involve interprocedural
290289 * analysis, it is done on a best-effort basis, so the CFG returned might
291290 * not actually be pruned.
292 *
291 *
293292 * @param method
294293 * the method
295294 * @return the CFG
302301
303302 /**
304303 * Get the ConstantPoolGen used to create the MethodGens for this class.
305 *
304 *
306305 * @return the ConstantPoolGen
307306 */
308307 public @Nonnull
312311
313312 /**
314313 * Get a UsagesRequiringNonNullValues for given method.
315 *
314 *
316315 * @param method
317316 * the method
318317 * @return the UsagesRequiringNonNullValues
324323
325324 /**
326325 * Get a ValueNumberDataflow for given method.
327 *
326 *
328327 * @param method
329328 * the method
330329 * @return the ValueNumberDataflow
335334
336335 /**
337336 * Get an IsNullValueDataflow for given method.
338 *
337 *
339338 * @param method
340339 * the method
341340 * @return the IsNullValueDataflow
346345
347346 /**
348347 * Get a TypeDataflow for given method.
349 *
348 *
350349 * @param method
351350 * the method
352351 * @return the TypeDataflow
357356
358357 /**
359358 * Get a DepthFirstSearch for given method.
360 *
359 *
361360 * @param method
362361 * the method
363362 * @return the DepthFirstSearch
368367
369368 /**
370369 * Get a ReverseDepthFirstSearch for given method.
371 *
370 *
372371 * @param method
373372 * the method
374373 * @return the ReverseDepthFirstSearch
377376 return getMethodAnalysisNoDataflowAnalysisException(ReverseDepthFirstSearch.class, method);
378377 }
379378
380 static final AnalysisLocal<MapCache<XMethod, BitSet>> cachedBitsets_AL
379 static final AnalysisLocal<MapCache<XMethod, BitSet>> cachedBitsets_AL
381380 = new AnalysisLocal<MapCache<XMethod, BitSet>>() {
382381 @Override
383382 protected MapCache<XMethod, BitSet> initialValue() {
385384 }
386385 };
387386
388 static final AnalysisLocal<MapCache<XMethod, Set<Integer>>> cachedLoopExits_AL =
387 static final AnalysisLocal<MapCache<XMethod, Set<Integer>>> cachedLoopExits_AL =
389388 new AnalysisLocal<MapCache<XMethod, Set<Integer>>>() {
390389 @Override
391390 protected MapCache<XMethod, Set<Integer>> initialValue() {
392391 return new MapCache<XMethod, Set<Integer>>(13);
393392 }
394393 };
395
394
396395
397396 /**
398397 * Get a BitSet representing the bytecodes that are used in the given
400399 * particular instructions. Because this step doesn't require building a
401400 * MethodGen, it is very fast and memory-efficient. It may allow a Detector
402401 * to avoid some very expensive analysis, which is a Big Win for the user.
403 *
402 *
404403 * @param method
405404 * the method
406405 * @return the BitSet containing the opcodes which appear in the method, or
417416 * particular instructions. Because this step doesn't require building a
418417 * MethodGen, it is very fast and memory-efficient. It may allow a Detector
419418 * to avoid some very expensive analysis, which is a Big Win for the user.
420 *
419 *
421420 * @param method
422421 * the method
423422 * @return the BitSet containing the opcodes which appear in the method, or
537536 * elements containing zero are either not valid instruction offsets, or
538537 * contain a NOP instruction. (It is convenient not to distinguish these
539538 * cases.)
540 *
539 *
541540 * @param method
542541 * the method
543542 * @return map of bytecode offsets to opcodes, or null if the method has no
550549
551550 /**
552551 * Get dataflow for LockAnalysis for given method.
553 *
552 *
554553 * @param method
555554 * the method
556555 * @return the LockDataflow
563562 * Get LockChecker for method. This is like LockDataflow, but may be able to
564563 * avoid performing the actual dataflow analyses if the method doesn't
565564 * contain explicit monitorenter/monitorexit instructions.
566 *
565 *
567566 * @param method
568567 * the method
569568 * @return the LockChecker
576575
577576 /**
578577 * Get ReturnPathDataflow for method.
579 *
578 *
580579 * @param method
581580 * the method
582581 * @return the ReturnPathDataflow
588587 /**
589588 * Get DominatorsAnalysis for given method, where exception edges are
590589 * ignored.
591 *
590 *
592591 * @param method
593592 * the method
594593 * @return the DominatorsAnalysis
601600 /**
602601 * Get DominatorsAnalysis for given method, where implicit exception edges
603602 * are ignored.
604 *
603 *
605604 * @param method
606605 * the method
607606 * @return the DominatorsAnalysis
614613 /**
615614 * Get PostDominatorsAnalysis for given method, where exception edges are
616615 * ignored.
617 *
616 *
618617 * @param method
619618 * the method
620619 * @return the PostDominatorsAnalysis
626625
627626 /**
628627 * Get ExceptionSetFactory for given method.
629 *
628 *
630629 * @param method
631630 * the method
632631 * @return the ExceptionSetFactory
637636
638637 /**
639638 * Get array of type signatures of parameters for given method.
640 *
639 *
641640 * @param method
642641 * the method
643642 * @return an array of type signatures indicating the types of the method's
649648
650649 /**
651650 * Get the set of fields loaded by given method.
652 *
651 *
653652 * @param method
654653 * the method
655654 * @return the set of fields loaded by the method
660659
661660 /**
662661 * Get LiveLocalStoreAnalysis dataflow for given method.
663 *
662 *
664663 * @param method
665664 * the method
666665 * @return the Dataflow object for LiveLocalStoreAnalysis on the method
671670
672671 /**
673672 * Get BlockType dataflow for given method.
674 *
673 *
675674 * @param method
676675 * the method
677676 * @return the Dataflow object for BlockTypeAnalysis on the method
696695
697696 /**
698697 * Get AssertionMethods for class.
699 *
698 *
700699 * @return the AssertionMethods
701700 */
702701 public AssertionMethods getAssertionMethods() {
705704
706705 /**
707706 * Get ConstantDataflow for method.
708 *
707 *
709708 * @param method
710709 * the method
711710 * @return the ConstantDataflow
718717
719718 /**
720719 * Get load dataflow.
721 *
720 *
722721 * @param method
723722 * the method
724723 * @return the LoadDataflow
731730
732731 /**
733732 * Get store dataflow.
734 *
733 *
735734 * @param method
736735 * the method
737736 * @return the StoreDataflow
744743
745744 /**
746745 * Get CallListDataflow for method.
747 *
746 *
748747 * @param method
749748 * the method
750749 * @return the CallListDataflow
816815
817816 /**
818817 * Get the UnconditionalValueDerefDataflow for a method.
819 *
818 *
820819 * @param method
821820 * the method
822821 * @return the UnconditionalValueDerefDataflow
830829
831830 /**
832831 * Get a CompactLocationNumbering for a method.
833 *
832 *
834833 * @param method
835834 * a method
836835 * @return the CompactLocationNumbering for the method
843842
844843 /**
845844 * Get ReturnPathTypeDataflow for a method.
846 *
845 *
847846 * @param method
848847 * the method
849848 * @return the ReturnPathTypeDataflow for the method
10111010 if (cause instanceof CFGBuilderException) {
10121011 throw (CFGBuilderException) cause;
10131012 }
1014 System.out.println("Bad CAE: " + e.getClass().getName() + " for " + analysisClass.getName() + " of " + method);
1015 e.printStackTrace(System.out);
1016 IllegalStateException ise = new IllegalStateException("should not happen");
1013 String message = "Should not happen: bad CAE: " + e.getClass().getName() + " for " + analysisClass.getName() + " of " + method;
1014 IllegalStateException ise = new IllegalStateException(message);
10171015 ise.initCause(e);
10181016 throw ise;
10191017 }
182182 }
183183
184184 if (numIterations >= MAX_ITERS + 9) {
185 throw new AssertionError("Too many iterations (" + numIterations + ") in dataflow when analyzing "
185 throw new DataflowAnalysisException("Too many iterations (" + numIterations + ") in dataflow when analyzing "
186186 + getFullyQualifiedMethodName());
187187 }
188188
267267
268268 int direction = blockOrder.compare(block, logicalPred);
269269
270 if (DEBUG)
270 if (DEBUG)
271271 debug(block, "direction " + direction + " for " + blockId(logicalPred) + "\n");
272272 if (direction < 0)
273273 sawBackEdge = true;
1919 package edu.umd.cs.findbugs.ba;
2020
2121 import edu.umd.cs.findbugs.AbstractBugReporter;
22 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2323 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
2424 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
2525
3838 * edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#reportMissingClass
3939 * (java.lang.ClassNotFoundException)
4040 */
41 @SuppressWarnings("DM_EXIT")
41 @SuppressFBWarnings("DM_EXIT")
4242 public void reportMissingClass(ClassNotFoundException ex) {
4343 String missing = AbstractBugReporter.getMissingClassName(ex);
4444 if (missing == null || missing.charAt(0) == '[')
5656 * edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(edu.umd
5757 * .cs.findbugs.classfile.ClassDescriptor)
5858 */
59 @SuppressWarnings("DM_EXIT")
59 @SuppressFBWarnings("DM_EXIT")
6060 public void reportMissingClass(ClassDescriptor classDescriptor) {
6161 System.out.println("Missing class: " + classDescriptor);
6262 System.exit(1);
6969 * edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#logError(java.
7070 * lang.String)
7171 */
72 @SuppressWarnings("DM_EXIT")
72 @SuppressFBWarnings("DM_EXIT")
7373 public void logError(String message) {
7474 System.err.println("Error: " + message);
7575 System.exit(1);
8282 * edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback#logError(java.
8383 * lang.String, java.lang.Throwable)
8484 */
85 @SuppressWarnings("DM_EXIT")
85 @SuppressFBWarnings("DM_EXIT")
8686 public void logError(String message, Throwable e) {
8787 if (e instanceof MissingClassException) {
8888 MissingClassException missingClassEx = (MissingClassException) e;
277277 0, NullnessAnnotation.CHECK_FOR_NULL);
278278 database.addMethodParameterAnnotation("java.util.concurrent.Phaser", "<init>", "(Ljava/util/concurrent/Phaser;I)V",
279279 false, 0, NullnessAnnotation.CHECK_FOR_NULL);
280
281 if (ICSE10_NULLNESS_PAPER) {
282 database.addMethodAnnotation("java.util.HashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false,
283 NullnessAnnotation.CHECK_FOR_NULL);
284 database.addMethodAnnotation("java.util.Hashtable", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false,
285 NullnessAnnotation.CHECK_FOR_NULL);
286 database.addMethodAnnotation("java.util.Map", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false,
287 NullnessAnnotation.CHECK_FOR_NULL);
288 database.addMethodAnnotation("java.util.SortedMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false,
289 NullnessAnnotation.CHECK_FOR_NULL);
290 database.addMethodAnnotation("java.util.TreeMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false,
291 NullnessAnnotation.CHECK_FOR_NULL);
292 }
293
294 if (false) {
295 database.addMethodAnnotation("java.util.concurrent.ConcurrentMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;",
296 false, NullnessAnnotation.CHECK_FOR_NULL);
297 database.addMethodAnnotation("java.util.concurrent.ConcurrentMap", "remove",
298 "(Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
299 database.addMethodAnnotation("java.util.concurrent.ConcurrentMap", "putIfAbsent",
300 "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
301 database.addMethodAnnotation("java.util.concurrent.ConcurrentMap", "replace",
302 "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
303 database.addMethodAnnotation("java.util.concurrent.ConcurrentHashMap", "get",
304 "(Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
305 database.addMethodAnnotation("java.util.concurrent.ConcurrentHashMap", "remove",
306 "(Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
307 database.addMethodAnnotation("java.util.concurrent.ConcurrentHashMap", "putIfAbsent",
308 "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false, NullnessAnnotation.CHECK_FOR_NULL);
309 }
310
280
311281 database.addMethodAnnotation("java.util.concurrent.locks.ReadWriteLock", "readLock",
312282 "()Ljava/util/concurrent/locks/Lock;", false, NullnessAnnotation.NONNULL);
313283 database.addMethodAnnotation("java.util.concurrent.locks.ReadWriteLock", "writeLock",
402372 NullnessAnnotation.CHECK_FOR_NULL);
403373
404374 database.addMethodParameterAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;)Ljava/lang/Object;",
405 false, 0, NullnessAnnotation.NONNULL);
375 true, 0, NullnessAnnotation.NONNULL);
406376 database.addMethodParameterAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
407 false, 0, NullnessAnnotation.NONNULL);
377 true, 0, NullnessAnnotation.NONNULL);
408378 database.addMethodParameterAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;",
409 false, 0, NullnessAnnotation.NONNULL);
379 true, 0, NullnessAnnotation.NONNULL);
410380 database.addMethodAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;)Ljava/lang/Object;",
381 true, NullnessAnnotation.NONNULL);
382 database.addMethodAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
383 true, NullnessAnnotation.NONNULL);
384 database.addMethodAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;",
385 true, NullnessAnnotation.NONNULL);
386
387 database.addMethodParameterAnnotation("java.util.Objects","requireNonNull", "(Ljava/lang/Object;)Ljava/lang/Object;",
388 true, 0, NullnessAnnotation.NONNULL);
389 database.addMethodParameterAnnotation("java.util.Objects","requireNonNull", "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;",
390 true, 0, NullnessAnnotation.NONNULL);
391 database.addMethodAnnotation("java.util.Objects","requireNonNull", "(Ljava/lang/Object;)Ljava/lang/Object;",
392 true, NullnessAnnotation.NONNULL);
393 database.addMethodAnnotation("java.util.Objects","requireNonNull", "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;",
394 true, NullnessAnnotation.NONNULL);
395
396
397 database.addMethodAnnotation("org.w3c.dom.Element","getAttribute", "(Ljava/lang/String;)Ljava/lang/String;",
411398 false, NullnessAnnotation.NONNULL);
412 database.addMethodAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
399 database.addMethodAnnotation("org.w3c.dom.Element","getAttributeNS", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
413400 false, NullnessAnnotation.NONNULL);
414 database.addMethodAnnotation("com.google.common.base.Preconditions","checkNotNull","(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;",
415 false, NullnessAnnotation.NONNULL);
416
401
402
417403 addEclipseSpecificAnnotations(database);
418404
419405 AnalysisContext.currentAnalysisContext().setMissingClassWarningsSuppressed(missingClassWarningsSuppressed);
2222 import java.util.LinkedList;
2323 import java.util.List;
2424
25 import javax.annotation.CheckForNull;
26
2527 import org.apache.bcel.generic.CodeExceptionGen;
2628 import org.apache.bcel.generic.InstructionHandle;
2729 import org.apache.bcel.generic.MethodGen;
30 import org.apache.bcel.generic.ObjectType;
31 import org.apache.bcel.generic.Type;
32
33 import edu.umd.cs.findbugs.ba.type.TypeMerger;
2834
2935 /**
3036 * This class provides a convenient way of determining the exception handlers
4046
4147 private IdentityHashMap<InstructionHandle, CodeExceptionGen> startInstructionToHandlerMap;
4248
49 private TypeMerger merger;
4350 /**
4451 * Constructor.
4552 *
4653 * @param methodGen
4754 * the method to build the map for
4855 */
49 public ExceptionHandlerMap(MethodGen methodGen) {
56 public ExceptionHandlerMap( MethodGen methodGen, TypeMerger merger) {
5057 codeToHandlerMap = new IdentityHashMap<InstructionHandle, List<CodeExceptionGen>>();
5158 startInstructionToHandlerMap = new IdentityHashMap<InstructionHandle, CodeExceptionGen>();
59 this.merger = merger;
5260 build(methodGen);
5361 }
5462
8694
8795 // Map handler start instructions to the actual exception handlers
8896 for (CodeExceptionGen exceptionHandler : handlerList) {
89 startInstructionToHandlerMap.put(exceptionHandler.getHandlerPC(), exceptionHandler);
97 addExceptionHandler(exceptionHandler);
9098 }
9199
92100 // For each instruction, determine which handlers it can reach
115123 }
116124 }
117125
126 public static CodeExceptionGen merge(@CheckForNull TypeMerger m, CodeExceptionGen e1, CodeExceptionGen e2) {
127 if (e1 == null) return e2;
128 if (e2 == null) return e1;
129 if (m == null)
130 return e1;
131 if ( ! e1.getHandlerPC().equals( e2.getHandlerPC() ) ){
132 // log error
133 return e1;
134 }
135 try {
136 Type t = m.mergeTypes(e1.getCatchType(), e2.getCatchType());
137 return new CodeExceptionGen(e1.getStartPC(), e1.getEndPC(), e1.getHandlerPC(), (ObjectType) t);
138 } catch (DataflowAnalysisException e) {
139 // TODO Auto-generated catch block
140 e.printStackTrace();
141 return e1;
142 }
143 }
144
145
146 private void addExceptionHandler(CodeExceptionGen exceptionHandler) {
147 InstructionHandle handlerPC = exceptionHandler.getHandlerPC();
148 CodeExceptionGen existing = startInstructionToHandlerMap.get(handlerPC);
149 if (existing != null) {
150 exceptionHandler = merge (this.merger, existing, exceptionHandler);
151 }
152 startInstructionToHandlerMap.put(handlerPC, exceptionHandler);
153 }
154
118155 private void addHandler(InstructionHandle handle, CodeExceptionGen exceptionHandler) {
119156 List<CodeExceptionGen> handlerList = codeToHandlerMap.get(handle);
120157 if (handlerList == null) {
328328 * the ConstantPoolGen for the class containing the method
329329 * @return number of arguments; note that this excludes the object instance
330330 * for instance methods
331 * @throws DataflowAnalysisException
332331 */
333332 public int getNumArguments(InvokeInstruction ins, ConstantPoolGen cpg) {
334333 SignatureParser parser = new SignatureParser(ins.getSignature(cpg));
1919 package edu.umd.cs.findbugs.ba;
2020
2121 import java.util.Collections;
22 import java.util.HashMap;
2322 import java.util.HashSet;
24 import java.util.Map;
2523 import java.util.Set;
2624
2725 import javax.annotation.CheckForNull;
5755 * hierarchy using the {@link org.apache.bcel.Repository} class. Callers should
5856 * generally expect to handle ClassNotFoundException for when referenced classes
5957 * can't be found.
60 *
58 *
6159 * @author David Hovemeyer
6260 */
6361 public class Hierarchy {
6664 public static ClassDescriptor RUNTIME_EXCEPTION = DescriptorFactory.createClassDescriptor(RuntimeException.class);
6765 public static ClassDescriptor EXCEPTION = DescriptorFactory.createClassDescriptor(Exception.class);
6866 public static ClassDescriptor ERROR = DescriptorFactory.createClassDescriptor(Error.class);
69
67
7068 /**
7169 * Type of java.lang.Exception.
7270 */
8482
8583 /**
8684 * Determine whether one class (or reference type) is a subtype of another.
87 *
85 *
8886 * @param clsName
8987 * the name of the class or reference type
9088 * @param possibleSupertypeClassName
9997
10098 /**
10199 * Determine if one reference type is a subtype of another.
102 *
100 *
103101 * @param t
104102 * a reference type
105103 * @param possibleSupertype
107105 * @return true if t is a subtype of possibleSupertype, false if not
108106 */
109107 public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException {
110 if (true) {
111 return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype);
112 } else {
113 Map<ReferenceType, Boolean> subtypes = subtypeCache.get(possibleSupertype);
114 if (subtypes == null) {
115 subtypes = new HashMap<ReferenceType, Boolean>();
116 subtypeCache.put(possibleSupertype, subtypes);
117 }
118 Boolean result = subtypes.get(t);
119 if (result == null) {
120 result = Boolean.valueOf(t.isAssignmentCompatibleWith(possibleSupertype));
121 subtypes.put(t, result);
122 }
123 return result;
124 }
125 }
126
127 static Map<ReferenceType, Map<ReferenceType, Boolean>> subtypeCache = new HashMap<ReferenceType, Map<ReferenceType, Boolean>>();
108 return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype);
109 }
110
128111
129112 /**
130113 * Determine if the given ObjectType reference represents a
131114 * <em>universal</em> exception handler. That is, one that will catch any
132115 * kind of exception.
133 *
116 *
134117 * @param catchType
135118 * the ObjectType of the exception handler
136119 * @return true if catchType is null, or if catchType is java.lang.Throwable
149132 ClassDescriptor c = DescriptorFactory.getClassDescriptor(type);
150133 Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class);
151134 return subtypes2.isSubtype(c, RUNTIME_EXCEPTION, ERROR);
152
135
153136 }
154137
155138 /**
156139 * Determine if method whose name and signature is specified is a monitor
157140 * wait operation.
158 *
141 *
159142 * @param methodName
160143 * name of the method
161144 * @param methodSig
168151
169152 /**
170153 * Determine if given Instruction is a monitor wait.
171 *
154 *
172155 * @param ins
173156 * the Instruction
174157 * @param cpg
175158 * the ConstantPoolGen for the Instruction
176 *
159 *
177160 * @return true if the instruction is a monitor wait, false if not
178161 */
179162 public static boolean isMonitorWait(Instruction ins, ConstantPoolGen cpg) {
192175 /**
193176 * Determine if method whose name and signature is specified is a monitor
194177 * notify operation.
195 *
178 *
196179 * @param methodName
197180 * name of the method
198181 * @param methodSig
205188
206189 /**
207190 * Determine if given Instruction is a monitor wait.
208 *
191 *
209192 * @param ins
210193 * the Instruction
211194 * @param cpg
212195 * the ConstantPoolGen for the Instruction
213 *
196 *
214197 * @return true if the instruction is a monitor wait, false if not
215198 */
216199 public static boolean isMonitorNotify(Instruction ins, ConstantPoolGen cpg) {
230213 * Look up the method referenced by given InvokeInstruction. This method
231214 * does <em>not</em> look for implementations in super or subclasses
232215 * according to the virtual dispatch rules.
233 *
216 *
234217 * @param inv
235218 * the InvokeInstruction
236219 * @param cpg
247230 * Look up the method referenced by given InvokeInstruction. This method
248231 * does <em>not</em> look for implementations in super or subclasses
249232 * according to the virtual dispatch rules.
250 *
233 *
251234 * @param inv
252235 * the InvokeInstruction
253236 * @param cpg
271254
272255 /**
273256 * Visit all superclass methods which the given method overrides.
274 *
257 *
275258 * @param method
276259 * the method
277260 * @param chooser
287270
288271 /**
289272 * Visit all superinterface methods which the given method implements.
290 *
273 *
291274 * @param method
292275 * the method
293276 * @param chooser
306289 * called by the given InvokeInstruction. One reason this method is useful
307290 * is that it indicates which declared exceptions are thrown by the called
308291 * methods.
309 *
292 *
310293 * <p/>
311294 * <ul>
312295 * <li>For invokespecial, this is simply an exact lookup.
320303 * desired is given, so the extended lookup will not be required. Should
321304 * check.)
322305 * </ul>
323 *
306 *
324307 * @param inv
325308 * the InvokeInstruction
326309 * @param cpg
401384
402385 /**
403386 * Find the declared exceptions for the method called by given instruction.
404 *
387 *
405388 * @param inv
406389 * the InvokeInstruction
407390 * @param cpg
420403
421404 /**
422405 * Find a method in given class.
423 *
406 *
424407 * @param javaClass
425408 * the class
426409 * @param methodName
459442
460443 /**
461444 * Find a method in given class.
462 *
445 *
463446 * @param classDesc
464447 * the class descriptor
465448 * @param methodName
489472
490473 /**
491474 * Find a method in given class.
492 *
475 *
493476 * @param javaClass
494477 * the class
495478 * @param methodName
523506
524507 /**
525508 * Find a method in given class.
526 *
509 *
527510 * @param javaClass
528511 * the class
529512 * @param methodName
605588
606589 /**
607590 * Find a method in given list of classes, searching the classes in order.
608 *
591 *
609592 * @param classList
610593 * list of classes in which to search
611594 * @param methodName
622605
623606 /**
624607 * Find a method in given list of classes, searching the classes in order.
625 *
608 *
626609 * @param classList
627610 * list of classes in which to search
628611 * @param methodName
650633 /**
651634 * Find XMethod for method in given list of classes, searching the classes
652635 * in order.
653 *
636 *
654637 * @param classList
655638 * list of classes in which to search
656639 * @param methodName
667650 /**
668651 * Find XMethod for method in given list of classes, searching the classes
669652 * in order.
670 *
653 *
671654 * @param classList
672655 * list of classes in which to search
673656 * @param methodName
694677 /**
695678 * Resolve possible method call targets. This works for both static and
696679 * instance method calls.
697 *
680 *
698681 * @param invokeInstruction
699682 * the InvokeInstruction
700683 * @param typeFrame
753736 /**
754737 * Resolve possible instance method call targets. Assumes that invokevirtual
755738 * and invokeinterface methods may call any subtype of the receiver class.
756 *
739 *
757740 * @param receiverType
758741 * type of the receiver object
759742 * @param invokeInstruction
770753
771754 /**
772755 * Resolve possible instance method call targets.
773 *
756 *
774757 * @param receiverType
775758 * type of the receiver object
776759 * @param invokeInstruction
856839
857840 /**
858841 * Return whether or not the given method is concrete.
859 *
842 *
860843 * @param xmethod
861844 * the method
862845 * @return true if the method is concrete, false otherwise
869852
870853 /**
871854 * Find a field with given name defined in given class.
872 *
855 *
873856 * @param className
874857 * the name of the class
875858 * @param fieldName
897880 * Look up a field with given name and signature in given class, returning
898881 * it as an {@link XField XField} object. If a field can't be found in the
899882 * immediate class, its superclass is search, and so forth.
900 *
883 *
901884 * @param className
902885 * name of the class through which the field is referenced
903886 * @param fieldName
918901 /**
919902 * Look up the field referenced by given FieldInstruction, returning it as
920903 * an {@link XField XField} object.
921 *
904 *
922905 * @param fins
923906 * the FieldInstruction
924907 * @param cpg
947930 /**
948931 * Determine whether the given INVOKESTATIC instruction is an inner-class
949932 * field accessor method.
950 *
933 *
951934 * @param inv
952935 * the INVOKESTATIC instruction
953936 * @param cpg
962945
963946 /**
964947 * Get the InnerClassAccess for access method called by given INVOKESTATIC.
965 *
948 *
966949 * @param inv
967950 * the INVOKESTATIC instruction
968951 * @param cpg
210210
211211 }
212212
213
214 public static @CheckForNull XMethod findFirstSuperMethod(XMethod m) {
215
216 try {
217 @CheckForNull ClassDescriptor c = m.getClassDescriptor();
218 XClass xc = getXClass(c);
219 c = xc.getSuperclassDescriptor();
220 while (c != null) {
221 xc = getXClass(c);
222 XMethod xm = xc.findMatchingMethod(m.getMethodDescriptor());
223 if (xm != null)
224 return xm;
225 c = xc.getSuperclassDescriptor();
226 }
227 } catch (CheckedAnalysisException e) {
228 AnalysisContext.logError("Error finding super methods for " + m, e);
229 }
230 return null;
231 }
232
213233 private static void findSuperMethods(@CheckForNull ClassDescriptor c, XMethod m, Set<XMethod> accumulator) {
214234 if (c == null)
215235 return;
102102
103103 public static final IncompatibleTypes UNRELATED_INTERFACES = new IncompatibleTypes("Unrelated interfaces",
104104 Priorities.NORMAL_PRIORITY);
105 public static final IncompatibleTypes UNRELATED_INTERFACES_WITHOUT_IMPLEMENTATIONS = new IncompatibleTypes("Unrelated interfaces without implementations",
106 Priorities.LOW_PRIORITY);
105107
106108 public static final IncompatibleTypes UNRELATED_UTIL_INTERFACE = new IncompatibleTypes("Unrelated java.util interface",
107109 Priorities.HIGH_PRIORITY);
127129
128130 static public @Nonnull
129131 IncompatibleTypes getPriorityForAssumingCompatible(Type expectedType, Type actualType, boolean pointerEquality) {
132 if (expectedType.equals(actualType))
133 return SEEMS_OK;
134
130135 if (!(expectedType instanceof ReferenceType))
131136 return SEEMS_OK;
132137 if (!(actualType instanceof ReferenceType))
291296 Set<ClassDescriptor> commonSubtypes = subtypes2.getTransitiveCommonSubtypes(lhsDescriptor, rhsDescriptor);
292297
293298 if (commonSubtypes.isEmpty()) {
299 if (lhs.isInterface() && rhs.isInterface()) {
300 if (!subtypes2.hasKnownSubclasses(lhsDescriptor) || !subtypes2.hasKnownSubclasses(rhsDescriptor))
301 return UNRELATED_INTERFACES_WITHOUT_IMPLEMENTATIONS;
302 return UNRELATED_INTERFACES;
303 }
294304 if (lhs.isFinal() || rhs.isFinal())
295305 return UNRELATED_FINAL_CLASS_AND_INTERFACE;
296306 if (lhsDescriptor.getClassName().startsWith("java/util/")
297307 || rhsDescriptor.getClassName().startsWith("java/util/"))
298308 return UNRELATED_UTIL_INTERFACE;
299 if (lhs.isInterface() && rhs.isInterface())
300 return UNRELATED_INTERFACES;
301309 return UNRELATED_CLASS_AND_INTERFACE;
302310 }
303311
305313 return SEEMS_OK;
306314 }
307315
308 private static boolean containsAtLeastOneInstantiableClass(Set<ClassDescriptor> commonSubtypes)
309 throws CheckedAnalysisException {
310 IAnalysisCache cache = Global.getAnalysisCache();
311 for (ClassDescriptor classDescriptor : commonSubtypes) {
312
313 XClass xclass = cache.getClassAnalysis(XClass.class, classDescriptor);
314
315 if (!xclass.isInterface() && !xclass.isAbstract())
316 return true;
317 }
318 return false;
319 }
316
317
320318
321319 }
1818
1919 package edu.umd.cs.findbugs.ba;
2020
21 import java.util.Collections;
2122 import java.util.HashMap;
2223 import java.util.Map;
2324
6162 * Map of class names to maps of method names to InnerClassAccess objects
6263 * representing access methods.
6364 */
64 private Map<String, Map<String, InnerClassAccess>> classToAccessMap;
65 private final Map<String, Map<String, InnerClassAccess>> classToAccessMap;
6566
6667 /*
6768 * ----------------------------------------------------------------------
173174 * and whether the field is loaded or stored.
174175 */
175176 private static class InstructionCallback implements BytecodeScanner.Callback {
176 private JavaClass javaClass;
177
178 private String methodName;
179
180 private String methodSig;
181
182 private byte[] instructionList;
177 private final JavaClass javaClass;
178
179 private final String methodName;
180
181 private final String methodSig;
182
183 private final byte[] instructionList;
183184
184185 private InnerClassAccess access;
185186
262263 if (xfield != null && xfield.isStatic() == isStatic && isValidAccessMethod(methodSig, xfield, isLoad)) {
263264 access = new InnerClassAccess(methodName, methodSig, xfield, isLoad);
264265 }
265
266
266267 }
267268
268269 /**
321322 return true;
322323 }
323324 }
324
325 private static final Map<String, InnerClassAccess> emptyMap = new HashMap<String, InnerClassAccess>();
326325
327326 /**
328327 * Return a map of inner-class member access method names to the fields that
372371 }
373372
374373 if (map.size() == 0)
375 map = emptyMap;
374 map = Collections.emptyMap();
376375 else
377376 map = new HashMap<String, InnerClassAccess>(map);
378377
2121 import java.util.HashMap;
2222 import java.util.Map;
2323
24 import javax.annotation.CheckForNull;
25
2426 import org.apache.bcel.classfile.ElementValue;
27
28 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
2529
2630 public class JCIPAnnotationDatabase {
2731 Map<ClassMember, Map<String, ElementValue>> memberAnnotations = new HashMap<ClassMember, Map<String, ElementValue>>();
2832
2933 Map<String, Map<String, ElementValue>> classAnnotations = new HashMap<String, Map<String, ElementValue>>();
3034
31 public Object getClassAnnotation(String dottedClassName, String annotationClass) {
32 assert dottedClassName.indexOf('/') == -1;
33 return getEntryForClass(dottedClassName).get(annotationClass);
35 @CheckForNull
36 public ElementValue getClassAnnotation(@DottedClassName String dottedClassName, String annotationClass) {
37 Map<String, ElementValue> map = getEntryForClass(dottedClassName);
38 return map == null? null : map.get(annotationClass);
3439 }
3540
36 public boolean hasClassAnnotation(String dottedClassName, String annotationClass) {
41 public boolean hasClassAnnotation(@DottedClassName String dottedClassName, String annotationClass) {
3742 assert dottedClassName.indexOf('/') == -1;
38 return getEntryForClass(dottedClassName).containsKey(annotationClass);
43 Map<String, ElementValue> map = getEntryForClass(dottedClassName);
44 return map != null && map.containsKey(annotationClass);
3945 }
4046
41 public Object getFieldAnnotation(XField field, String annotationClass) {
42 return getEntryForClassMember(field).get(annotationClass);
47 @CheckForNull
48 public ElementValue getFieldAnnotation(XField field, String annotationClass) {
49 Map<String, ElementValue> map = getEntryForClassMember(field);
50 return map == null? null : map.get(annotationClass);
4351 }
4452
4553 public boolean hasFieldAnnotation(XField field, String annotationClass) {
46 return getEntryForClassMember(field).containsKey(annotationClass);
54 Map<String, ElementValue> map = getEntryForClassMember(field);
55 return map != null && map.containsKey(annotationClass);
4756 }
4857
49 public Object getMethodAnnotation(XMethod method, String annotationClass) {
50 return getEntryForClassMember(method).get(annotationClass);
58 @CheckForNull
59 public ElementValue getMethodAnnotation(XMethod method, String annotationClass) {
60 Map<String, ElementValue> map = getEntryForClassMember(method);
61 return map == null? null : map.get(annotationClass);
5162 }
5263
5364 public boolean hasMethodAnnotation(XMethod method, String annotationClass) {
54 return getEntryForClassMember(method).containsKey(annotationClass);
65 Map<String, ElementValue> map = getEntryForClassMember(method);
66 return map != null && map.containsKey(annotationClass);
5567 }
5668
57 public Map<String, ElementValue> getEntryForClassMember(ClassMember member) {
69 @CheckForNull
70 private Map<String, ElementValue> getEntryForClassMember(ClassMember member) {
71 return memberAnnotations.get(member);
72 }
73
74 public void addEntryForClassMember(ClassMember member,
75 String annotationClass, ElementValue value) {
5876 Map<String, ElementValue> map = memberAnnotations.get(member);
5977 if (map == null) {
6078 map = new HashMap<String, ElementValue>();
6179 memberAnnotations.put(member, map);
6280 }
63 return map;
81 map.put(annotationClass, value);
6482 }
6583
66 public Map<String, ElementValue> getEntryForClass(String dottedClassName) {
84 @CheckForNull
85 private Map<String, ElementValue> getEntryForClass(@DottedClassName String dottedClassName) {
6786 assert dottedClassName.indexOf('/') == -1;
68 Map<String, ElementValue> map = classAnnotations.get(dottedClassName);
87 return classAnnotations.get(dottedClassName);
88 }
89
90 public void addEntryForClass(@DottedClassName String dottedClassName,
91 String annotationClass, ElementValue value) {
92 Map<String, ElementValue> map = getEntryForClass(dottedClassName);
6993 if (map == null) {
7094 map = new HashMap<String, ElementValue>(3);
7195 classAnnotations.put(dottedClassName, map);
7296 }
73 return map;
97 map.put(annotationClass, value);
7498 }
7599
76100 }
2020
2121 import javax.annotation.CheckForNull;
2222
23 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
24 import edu.umd.cs.findbugs.util.ClassName;
25
2326 /**
2427 * @author pugh
2528 */
3639
3740 public static class Parser {
3841 @CheckForNull
39 public static NullnessAnnotation parse(String s) {
40 if (s.equals("com.google.common.base.Nullable") || s.equals("org.jetbrains.annotations.Nullable"))
42 public static NullnessAnnotation parse(@DottedClassName String className) {
43 className = ClassName.toDottedClassName(className);
44 if (className.equals("com.google.common.base.Nullable")
45 || className.equals("org.eclipse.jdt.annotation.Nullable")
46 || className.equals("org.jetbrains.annotations.Nullable")) {
4147 return CHECK_FOR_NULL;
42 for (NullnessAnnotation v : myValues)
43 if (s.endsWith(v.name))
48 }
49 // Unfortunately there are mixed case Nonnull and NonNull annotations (JSR305, FB and JDT)
50 if (className.endsWith("Nonnull")) {
51 return NONNULL;
52 }
53 for (NullnessAnnotation v : myValues) {
54 if (className.endsWith(v.name)) {
4455 return v;
45 if (s.endsWith("PossiblyNull"))
56 }
57 }
58 if (className.endsWith("PossiblyNull")) {
4659 return CHECK_FOR_NULL;
60 }
4761 return null;
4862 }
4963 }
5468
5569 private NullnessAnnotation(String s, int i) {
5670 super(s, i);
57
5871 }
5972
6073 }
2020
2121 import javax.annotation.CheckForNull;
2222
23 import edu.umd.cs.findbugs.ba.npe.TypeQualifierNullnessAnnotationDatabase;
2324 import edu.umd.cs.findbugs.classfile.Global;
2425 import edu.umd.cs.findbugs.log.Profiler;
2526
2627 /**
2728 * @author pugh
2829 */
30 @Deprecated
2931 public class NullnessAnnotationDatabase extends AnnotationDatabase<NullnessAnnotation> implements INullnessAnnotationDatabase {
3032
3133 public NullnessAnnotationDatabase() {
3941 DefaultNullnessAnnotations.addDefaultNullnessAnnotations(this);
4042 }
4143
42 /*
43 * (non-Javadoc)
44 *
45 * @see
46 * edu.umd.cs.findbugs.ba.INullnessAnnotationDatabase#parameterMustBeNonNull
47 * (edu.umd.cs.findbugs.ba.XMethod, int)
48 */
4944 public boolean parameterMustBeNonNull(XMethod m, int param) {
5045 if (param == 0) {
5146 if (m.getName().equals("equals") && m.getSignature().equals("(Ljava/lang/Object;)Z") && !m.isStatic())
5348 else if (m.getName().equals("main") && m.getSignature().equals("([Ljava/lang/String;)V") && m.isStatic()
5449 && m.isPublic())
5550 return true;
56 else if (assertsFirstParameterIsNonnull(m))
51 else if (TypeQualifierNullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
5752 return true;
5853 else if (m.getName().equals("compareTo") && m.getSignature().endsWith(";)Z") && !m.isStatic())
5954 return true;
6257 return false;
6358 XMethodParameter xmp = new XMethodParameter(m, param);
6459 NullnessAnnotation resolvedAnnotation = getResolvedAnnotation(xmp, true);
65
60
6661
6762 return resolvedAnnotation == NullnessAnnotation.NONNULL;
6863 }
6964
70 /*
71 * (non-Javadoc)
72 *
73 * @see
74 * edu.umd.cs.findbugs.ba.INullnessAnnotationDatabase#getResolvedAnnotation
75 * (java.lang.Object, boolean)
76 */
7765 @CheckForNull
7866 @Override
7967 public NullnessAnnotation getResolvedAnnotation(final Object o, boolean getMinimal) {
9381 else if (m.getName().equals("main") && m.getSignature().equals("([Ljava/lang/String;)V") && m.isStatic()
9482 && m.isPublic())
9583 return NullnessAnnotation.NONNULL;
96 else if (assertsFirstParameterIsNonnull(m))
84 else if (TypeQualifierNullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
9785 return NullnessAnnotation.NONNULL;
9886 else if (m.getName().equals("compareTo") && m.getSignature().endsWith(";)Z") && !m.isStatic())
9987 return NullnessAnnotation.NONNULL;
124112 }
125113 }
126114
127 /**
128 * @param m
129 * @return
130 */
131 public static boolean assertsFirstParameterIsNonnull(XMethod m) {
132 return (m.getName().equalsIgnoreCase("checkNonNull") || m.getName().equalsIgnoreCase("checkNotNull") || m.getName()
133 .equalsIgnoreCase("assertNotNull")) && m.getSignature().startsWith("(Ljava/lang/Object;");
134 }
115
135116
136 /*
137 * (non-Javadoc)
138 *
139 * @see
140 * edu.umd.cs.findbugs.ba.AnnotationDatabase#addDefaultMethodAnnotation(
141 * java.lang.String, edu.umd.cs.findbugs.ba.AnnotationEnumeration)
142 */
143117 @Override
144118 public void addDefaultMethodAnnotation(String name, NullnessAnnotation annotation) {
145119 super.addDefaultMethodAnnotation(name, annotation);
146120 }
147121
148 /*
149 * (non-Javadoc)
150 *
151 * @see
152 * edu.umd.cs.findbugs.ba.AnnotationDatabase#addDefaultAnnotation(java.lang
153 * .String, java.lang.String, edu.umd.cs.findbugs.ba.AnnotationEnumeration)
154 */
155122 @Override
156123 public void addDefaultAnnotation(AnnotationDatabase.Target target, String c, NullnessAnnotation n) {
157124 super.addDefaultAnnotation(target, c, n);
158125 }
159126
160 /*
161 * (non-Javadoc)
162 *
163 * @see
164 * edu.umd.cs.findbugs.ba.AnnotationDatabase#addFieldAnnotation(java.lang
165 * .String, java.lang.String, java.lang.String, boolean,
166 * edu.umd.cs.findbugs.ba.AnnotationEnumeration)
167 */
168127 @Override
169128 public void addFieldAnnotation(String name, String name2, String sig, boolean isStatic, NullnessAnnotation annotation) {
170129 super.addFieldAnnotation(name, name2, sig, isStatic, annotation);
171130 }
172131
173 /*
174 * (non-Javadoc)
175 *
176 * @see
177 * edu.umd.cs.findbugs.ba.AnnotationDatabase#addMethodAnnotation(java.lang
178 * .String, java.lang.String, java.lang.String, boolean,
179 * edu.umd.cs.findbugs.ba.AnnotationEnumeration)
180 */
181132 @Override
182133 public void addMethodAnnotation(String name, String name2, String sig, boolean isStatic, NullnessAnnotation annotation) {
183134 super.addMethodAnnotation(name, name2, sig, isStatic, annotation);
184135 }
185136
186 /*
187 * (non-Javadoc)
188 *
189 * @see
190 * edu.umd.cs.findbugs.ba.AnnotationDatabase#addMethodParameterAnnotation
191 * (java.lang.String, java.lang.String, java.lang.String, boolean, int,
192 * edu.umd.cs.findbugs.ba.AnnotationEnumeration)
193 */
194137 @Override
195138 public void addMethodParameterAnnotation(String name, String name2, String sig, boolean isStatic, int param,
196139 NullnessAnnotation annotation) {
5050 *
5151 * @param fileName
5252 * name of the class file
53 * @throws IOException
54 * if the file cannot be read
5553 */
5654 public RepositoryClassParser(String fileName) {
5755 classParser = new ClassParser(fileName);
6462 * name of a zip file containing the class
6563 * @param fileName
6664 * name of the zip entry within the class
67 * @throws IOException
68 * if the zip entry cannot be read
6965 */
7066 public RepositoryClassParser(String zipFile, String fileName) {
7167 classParser = new ClassParser(zipFile, fileName);
168168 return new ParameterSignatureIterator();
169169 }
170170
171 public Iterable<String> parameterSignatures() {
172 return new Iterable<String>() {
173
174 public Iterator<String> iterator() {
175 return new ParameterSignatureIterator();
176 }};
177
178 }
179
171180 /**
172181 * Get the method return type signature.
173182 *
186186 return map.keySet();
187187 }
188188
189 public boolean hasParameterAnnotations() {
190 return !methodParameterAnnotations.isEmpty();
191 }
192
189193 public @Nullable
190194 AnnotationValue getParameterAnnotation(int param, ClassDescriptor desc) {
191195 Map<ClassDescriptor, AnnotationValue> map = methodParameterAnnotations.get(param);
157157 * parameter
158158 */
159159 public Collection<AnnotationValue> getParameterAnnotations(int param);
160
160
161 public boolean hasParameterAnnotations();
161162 /**
162163 * Get ClassDescriptors (annotation classes) of annotations applied directly
163164 * to this method.
2121 import org.apache.bcel.generic.ConstantPoolGen;
2222 import org.apache.bcel.generic.InstructionHandle;
2323
24 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2525 import edu.umd.cs.findbugs.ba.DataflowAnalysisException;
2626 import edu.umd.cs.findbugs.ba.Edge;
2727 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
4848 * @param childList
4949 * list of child PatternElements
5050 */
51 @SuppressWarnings("EI2")
51 @SuppressFBWarnings("EI2")
5252 public MatchAny(PatternElement[] childList) {
5353 this.childList = childList;
5454 }
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.bcp;
23
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.ca;
23
133133 final static ObjectType COLLECTION_TYPE = ObjectTypeFactory.getInstance(Collection.class);
134134 final static ObjectType MAP_TYPE = ObjectTypeFactory.getInstance(Map.class);
135135
136 static public boolean isCollection(ReferenceType target) throws ClassNotFoundException {
136 static public boolean isCollection(ReferenceType target) throws ClassNotFoundException {
137137 Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
138138 return subtypes2.isSubtype(target, COLLECTION_TYPE);
139139 }
140140 /** A collection, a map, or some other container */
141 static public boolean isContainer(ReferenceType target) throws ClassNotFoundException {
141 static public boolean isContainer(ReferenceType target) throws ClassNotFoundException {
142142 Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
143143 return subtypes2.isSubtype(target, COLLECTION_TYPE)
144144 || subtypes2.isSubtype(target, MAP_TYPE);
449449 }
450450 }
451451 if (false) {
452 if (subName.equals("java/lang/Error") && superName.equals("java/lang/RuntimeException"))
452 if (subName.equals("java/lang/Error") && superName.equals("java/lang/RuntimeException"))
453453 System.out.println("huh");
454454 System.out.println("sub: " + subDesc);
455455 System.out.println("SUP: " + superDesc);
850850 return result;
851851 }
852852
853
853854 /**
854855 * Get Collection of all XClass objects (resolved classes) seen so far.
855856 *
10291030 return new HashSet<ClassDescriptor>(result);
10301031 }
10311032
1033
1034 public boolean hasKnownSubclasses(ClassDescriptor classDescriptor) throws ClassNotFoundException {
1035
1036 ClassVertex startVertex = resolveClassVertex(classDescriptor);
1037 if (!startVertex.isInterface())
1038 return true;
1039
1040 LinkedList<ClassVertex> workList = new LinkedList<ClassVertex>();
1041
1042 workList.addLast(startVertex);
1043
1044 Set<ClassDescriptor> result = new HashSet<ClassDescriptor>();
1045
1046 while (!workList.isEmpty()) {
1047 ClassVertex current = workList.removeFirst();
1048
1049 if (!result.add(current.getClassDescriptor())) {
1050 // Already added this class
1051 continue;
1052 }
1053
1054 // Add class to the result
1055 if (current.isResolved() && !current.isInterface())
1056 return true;
1057
1058 // Add all known subtype vertices to the work list
1059 Iterator<InheritanceEdge> i = graph.incomingEdgeIterator(current);
1060 while (i.hasNext()) {
1061 InheritanceEdge edge = i.next();
1062 workList.addLast(edge.getSource());
1063 }
1064 }
1065
1066 return false;
1067 }
10321068 private Set<ClassDescriptor> computeKnownSupertypes(ClassDescriptor classDescriptor) throws ClassNotFoundException {
10331069 LinkedList<ClassVertex> workList = new LinkedList<ClassVertex>();
10341070
10661102 * @param classDescriptor
10671103 * a ClassDescriptor
10681104 * @return SupertypeQueryResults for the class named by the ClassDescriptor
1069 * @throws ClassNotFoundException
10701105 */
10711106 public SupertypeQueryResults getSupertypeQueryResults(ClassDescriptor classDescriptor) {
10721107 SupertypeQueryResults supertypeQueryResults = supertypeSetMap.get(classDescriptor);
10831118 * @param classDescriptor
10841119 * a ClassDescriptor
10851120 * @return SupertypeQueryResults containing known supertypes of the class
1086 * @throws ClassNotFoundException
1087 * if the class can't be found
10881121 */
10891122 private SupertypeQueryResults computeSupertypes(ClassDescriptor classDescriptor) // throws
10901123 // ClassNotFoundException
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.ch;
23
4444 this.value = value;
4545 }
4646
47 public Object getConstantValue() {
48 return value;
49 }
4750 /**
4851 * Return whether or not this value is a constant.
4952 *
9396 * Merge two Constants.
9497 *
9598 * @param a
96 * a Constant
99 * a StaticConstant
97100 * @param b
98 * another Constant
101 * another StaticConstant
99102 * @return the merge (dataflow meet) of the two Constants
100103 */
101104 public static Constant merge(Constant a, Constant b) {
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.constant;
23
451451 private void checkNonNullReturnValue(XMethod thisMethod, Location location, ValueNumberFrame vnaFrame,
452452 UnconditionalValueDerefSet fact) throws DataflowAnalysisException {
453453 INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
454 if (database == null) {
455 return;
456 }
454
457455 if (database.getResolvedAnnotation(thisMethod, true) != NullnessAnnotation.NONNULL)
458456 return;
459457 if (reportPotentialDereference(location, invDataflow.getFactAtLocation(location))) {
477475 private void checkNonNullPutField(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact)
478476 throws DataflowAnalysisException {
479477 INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
480 if (database == null) {
481 return;
482 }
483478
484479 FieldInstruction fieldIns = (FieldInstruction) location.getHandle().getInstruction();
485480
546541 if (invFrame != null && !invFrame.isValid())
547542 return Collections.emptySet();
548543 INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
549 if (database == null) {
550 return Collections.emptySet();
551 }
552544
553545 InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
554546 XMethod called = XFactory.createXMethod(inv, constantPool);
0 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
2 package edu.umd.cs.findbugs.ba.deref;
3
3838 * Extension to ObjectType that includes additional information about the
3939 * generic signature.
4040 * <p>
41 *
41 *
4242 * A GenericObjectType is either a parameterized type e.g.
4343 * <code>List&lt;String&gt;</code>, or a type variable e.g. <code>T</code>.
4444 * <p>
45 *
45 *
4646 * This class cannot be initialized directly. Instead, create a
4747 * GenericObjectType by calling GenericUtilities.getType(String) and passing in
4848 * the bytecode signature for the type.
49 *
49 *
5050 * @author Nat Ayewah
5151 */
5252 public class GenericObjectType extends ObjectType {
102102
103103 /**
104104 * Get the TypeCategory that represents this Object
105 *
105 *
106106 * @see GenericUtilities.TypeCategory
107107 */
108108 public GenericUtilities.TypeCategory getTypeCategory() {
167167 /**
168168 * Create a GenericObjectType that represents a Simple Type Variable or a
169169 * simple wildcard with no extensions
170 *
170 *
171171 * @param variable
172172 * the type variable e.g. <code>T</code>
173173 */
177177
178178 /**
179179 * Create a GenericObjectType that represents a Wildcard with extensions
180 *
180 *
181181 * @param variable
182182 * the type variable e.g. <code>T</code>
183183 */
184 GenericObjectType(@Nonnull String wildcard, ReferenceType extension) {
184 GenericObjectType(@Nonnull String wildcard, @CheckForNull ReferenceType extension) {
185185 super(DescriptorFactory.canonicalizeString(Type.OBJECT.getClassName()));
186186 this.variable = DescriptorFactory.canonicalizeString(wildcard);
187187 this.extension = extension;
190190
191191 /**
192192 * Create a GenericObjectType that represents a parameterized class
193 *
193 *
194194 * @param class_name
195195 * the class that is parameterized. e.g.
196196 * <code>java.util.List</code>
224224 * <code>toString()</code> in case any existing code assumes that this
225225 * object is an ObjectType and expects similar string representation. i.e.
226226 * <code>toString()</code> is equivalent to <code>toString(false)</code>)
227 *
227 *
228228 * @param includeGenerics
229229 * if true then the string includes generic information in this
230230 * object. Otherwise this returns the same value as
3636 /**
3737 * Utilities for adding support for generics. Most of these methods can be
3838 * applied to generic and non generic type information.
39 *
39 *
4040 * @author Nat Ayewah
4141 */
4242 public class GenericUtilities {
179179
180180 /**
181181 * Get the TypeCategory that represents this Object
182 *
182 *
183183 * @see GenericUtilities.TypeCategory
184184 */
185185 public static final TypeCategory getTypeCategory(Type type) {
243243 * that it also accepts signatures with generic information. e.g.
244244 * <code>Ljava/util/ArrayList&lt;TT;&gt;;</code>
245245 * <p>
246 *
246 *
247247 * The signature should only contain one type. Use GenericSignatureParser to
248248 * break up a signature with many types or call createTypes(String) to
249249 * return a list of types
299299 }
300300 }
301301
302 public static ObjectType merge(Type t1, ObjectType t2) {
302 public static ObjectType merge(@CheckForNull Type t1, ObjectType t2) {
303303 if (t1 instanceof GenericObjectType)
304304 return merge((GenericObjectType) t1, t2);
305305 return t2;
306306 }
307307
308 public static Type merge(GenericObjectType t1, Type t2) {
308 public static Type merge(@CheckForNull GenericObjectType t1, Type t2) {
309309 if (t1 == null)
310310 return t2;
311311 if (t2 instanceof ObjectType)
315315 return t2;
316316 }
317317
318 public static ObjectType merge(GenericObjectType t1, ObjectType t2) {
319 if (t2 instanceof GenericObjectType)
318 public static ObjectType merge(@CheckForNull GenericObjectType t1, ObjectType t2) {
319 if (t1 == null || t2 instanceof GenericObjectType)
320320 return t2;
321321 List<? extends ReferenceType> parameters = t1.getParameters();
322322 if (parameters == null)
385385 /**
386386 * Parse a bytecode signature that has 1 or more (possibly generic) types
387387 * and return a list of the Types.
388 *
388 *
389389 * @param signature
390390 * bytecode signature e.g. e.g.
391391 * <code>Ljava/util/ArrayList&lt;Ljava/lang/String;&gt;;Ljava/util/ArrayList&lt;TT;&gt;;Ljava/util/ArrayList&lt;*&gt;;</code>
0 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
2 package edu.umd.cs.findbugs.ba.generic;
3
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.heap;
23
120120 * @param fileName
121121 * name of the database file
122122 * @throws IOException
123 * @throws MethodPropertyDatabaseFormatException
123 * @throws PropertyDatabaseFormatException
124124 */
125125 public void readFromFile(String fileName) throws IOException, PropertyDatabaseFormatException {
126126 read(new FileInputStream(fileName));
133133 * @param in
134134 * the InputStream
135135 * @throws IOException
136 * @throws MethodPropertyDatabaseFormatException
136 * @throws PropertyDatabaseFormatException
137137 */
138138 public void read(@WillClose InputStream in) throws IOException, PropertyDatabaseFormatException {
139139 BufferedReader reader = null;
256256 * @param propStr
257257 * String containing the encoded property
258258 * @return the property
259 * @throws MethodPropertyDatabaseFormatException
259 * @throws PropertyDatabaseFormatException
260260 */
261261 protected abstract ValueType decodeProperty(String propStr) throws PropertyDatabaseFormatException;
262262
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.interproc;
23
2424 /**
2525 * Accumulate type qualifier annotations on method, taking supertype methods
2626 * into account.
27 *
27 *
2828 * @author David Hovemeyer
2929 */
3030 public abstract class AbstractMethodAnnotationAccumulator extends OverriddenMethodsVisitor {
31 private final TypeQualifierValue typeQualifierValue;
31 private final TypeQualifierValue<?> typeQualifierValue;
3232
33 protected AbstractMethodAnnotationAccumulator(TypeQualifierValue typeQualifierValue, XMethod xmethod) {
33 protected AbstractMethodAnnotationAccumulator(TypeQualifierValue<?> typeQualifierValue, XMethod xmethod) {
3434 super(xmethod);
3535 this.typeQualifierValue = typeQualifierValue;
3636 }
3838 /**
3939 * @return Returns the typeQualifierValue.
4040 */
41 public TypeQualifierValue getTypeQualifierValue() {
41 public TypeQualifierValue<?> getTypeQualifierValue() {
4242 return typeQualifierValue;
4343 }
4444
45 /*
46 * (non-Javadoc)
47 *
48 * @see
49 * edu.umd.cs.findbugs.ba.ch.OverriddenMethodsVisitor#visitOverriddenMethod
50 * (edu.umd.cs.findbugs.ba.XMethod)
51 */
5245 @Override
5346 protected boolean visitOverriddenMethod(XMethod xmethod) {
5447
207207 * @param result
208208 * @param m
209209 */
210 public static void addKnownTypeQualifiersForParameters(HashSet<TypeQualifierValue<?>> result, XMethod m) {
210 public static void addKnownTypeQualifiersForParameters(HashSet<? super TypeQualifierValue<?>> result, XMethod m) {
211211 int numParameters = new SignatureParser(m.getSignature()).getNumParameters();
212212 for (int p = 0; p < numParameters; p++) {
213213 addKnownTypeQualifiers(result, TypeQualifierApplications.getApplicableApplications(m, p));
218218 * @param result
219219 * @param applicableApplications
220220 */
221 public static void addKnownTypeQualifiers(HashSet<TypeQualifierValue<?>> result,
221 public static void addKnownTypeQualifiers(HashSet<? super TypeQualifierValue<?>> result,
222222 Collection<TypeQualifierAnnotation> applicableApplications) {
223223 for (TypeQualifierAnnotation t : applicableApplications) {
224224 if (t.when != When.UNKNOWN) {
8484 * should check
8585 */
8686 public BackwardTypeQualifierDataflowAnalysis(DepthFirstSearch dfs, ReverseDepthFirstSearch rdfs, XMethod xmethod, CFG cfg,
87 ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, TypeQualifierValue typeQualifierValue) {
87 ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, TypeQualifierValue<?> typeQualifierValue) {
8888 super(xmethod, cfg, vnaDataflow, cpg, typeQualifierValue);
8989 this.dfs = dfs;
9090 this.rdfs = rdfs;
9898 this.forwardTypeQualifierDataflow = forwardTypeQualifierDataflow;
9999 }
100100
101 /*
102 * (non-Javadoc)
103 *
104 * @see
105 * edu.umd.cs.findbugs.ba.jsr305.TypeQualifierDataflowAnalysis#edgeTransfer
106 * (edu.umd.cs.findbugs.ba.Edge,
107 * edu.umd.cs.findbugs.ba.jsr305.TypeQualifierValueSet)
108 */
109101 @Override
110102 public void edgeTransfer(Edge edge, TypeQualifierValueSet fact) throws DataflowAnalysisException {
111103 if (PRUNE_CONFLICTING_VALUES && forwardTypeQualifierDataflow != null) {
115107 super.edgeTransfer(edge, fact);
116108 }
117109
118 /*
119 * (non-Javadoc)
120 *
121 * @see
122 * edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis#transferInstruction(org
123 * .apache.bcel.generic.InstructionHandle,
124 * edu.umd.cs.findbugs.ba.BasicBlock, java.lang.Object)
125 */
126110 @Override
127111 public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, TypeQualifierValueSet fact)
128112 throws DataflowAnalysisException {
146130 valueNumbers.retainAll(forwardFact.getValueNumbers());
147131
148132 for (ValueNumber vn : valueNumbers) {
149 if (FlowValue.valuesConflict(typeQualifierValue.isStrictQualifier() && !xmethod.isIdentity(),
133 if (FlowValue.valuesConflict(typeQualifierValue.isStrictQualifier() && !xmethod.isIdentity(),
150134 forwardFact.getValue(vn), fact.getValue(vn))) {
151135 fact.pruneValue(vn);
152136 }
154138 }
155139 }
156140
157 /*
158 * (non-Javadoc)
159 *
160 * @see
161 * edu.umd.cs.findbugs.ba.DataflowAnalysis#getBlockOrder(edu.umd.cs.findbugs
162 * .ba.CFG)
163 */
164 public BlockOrder getBlockOrder(CFG cfg) {
165 return new ReverseDFSOrder(cfg, rdfs, dfs);
166 }
167
168 /*
169 * (non-Javadoc)
170 *
171 * @see edu.umd.cs.findbugs.ba.DataflowAnalysis#isForwards()
172 */
141 public BlockOrder getBlockOrder(CFG cfg1) {
142 return new ReverseDFSOrder(cfg1, rdfs, dfs);
143 }
144
173145 public boolean isForwards() {
174146 return false;
175147 }
176148
177 /*
178 * (non-Javadoc)
179 *
180 * @see edu.umd.cs.findbugs.ba.jsr305.TypeQualifierDataflowAnalysis#
181 * registerSourceSinkLocations()
182 */
183149 @Override
184150 public void registerSourceSinkLocations() throws DataflowAnalysisException {
185151 registerInstructionSinks();
259225
260226 if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod))
261227 return;
262
228
263229 for (int param = 0; param < calledMethod.getNumParams(); param++) {
264230 TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
265231 typeQualifierValue);
7171 @Override
7272 protected BackwardTypeQualifierDataflow getDataflow(DepthFirstSearch dfs, XMethod xmethod, CFG cfg,
7373 ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, IAnalysisCache analysisCache,
74 MethodDescriptor methodDescriptor, TypeQualifierValue typeQualifierValue) throws CheckedAnalysisException {
74 MethodDescriptor methodDescriptor, TypeQualifierValue<?> typeQualifierValue) throws CheckedAnalysisException {
7575 ReverseDepthFirstSearch rdfs = analysisCache.getMethodAnalysis(ReverseDepthFirstSearch.class, methodDescriptor);
7676
7777 BackwardTypeQualifierDataflowAnalysis analysis = new BackwardTypeQualifierDataflowAnalysis(dfs, rdfs, xmethod, cfg,
9797
9898 @Override
9999 protected void populateDatabase(BackwardTypeQualifierDataflow dataflow, ValueNumberDataflow vnaDataflow, XMethod xmethod,
100 TypeQualifierValue tqv) throws CheckedAnalysisException {
100 TypeQualifierValue<?> tqv) throws CheckedAnalysisException {
101101 assert TypeQualifierDatabase.USE_DATABASE;
102102
103103 // Get the dataflow fact that propagated
2929 * FindBugs-specific default-annotation annotations. I.e.:
3030 *
3131 * <pre>
32 * {@literal @DefaultAnnotationForParameters({Nonnull.class})}
32 * {@literal @DefaultAnnotationForParameters(Nonnull.class)}
3333 * public class MyClass {
3434 * ...
3535 * }
2020
2121 import java.util.Iterator;
2222
23 import javax.annotation.CheckForNull;
2324 import javax.annotation.meta.When;
2425
2526 import org.apache.bcel.Constants;
7576 * should check
7677 */
7778 public ForwardTypeQualifierDataflowAnalysis(DepthFirstSearch dfs, XMethod xmethod, CFG cfg, ValueNumberDataflow vnaDataflow,
78 ConstantPoolGen cpg, TypeQualifierValue typeQualifierValue) {
79 ConstantPoolGen cpg, TypeQualifierValue<?> typeQualifierValue) {
7980 super(xmethod, cfg, vnaDataflow, cpg, typeQualifierValue);
8081 this.dfs = dfs;
8182 }
8283
83 /*
84 * (non-Javadoc)
85 *
86 * @see
87 * edu.umd.cs.findbugs.ba.DataflowAnalysis#getBlockOrder(edu.umd.cs.findbugs
88 * .ba.CFG)
89 */
90 public BlockOrder getBlockOrder(CFG cfg) {
91 return new ReversePostOrder(cfg, dfs);
92 }
93
94 /*
95 * (non-Javadoc)
96 *
97 * @see edu.umd.cs.findbugs.ba.DataflowAnalysis#isForwards()
98 */
84 public BlockOrder getBlockOrder(CFG cfg1) {
85 return new ReversePostOrder(cfg1, dfs);
86 }
87
9988 public boolean isForwards() {
10089 return true;
10190 }
10291
103 /*
104 * (non-Javadoc)
105 *
106 * @see edu.umd.cs.findbugs.ba.jsr305.TypeQualifierDataflowAnalysis#
107 * registerSourceSinkLocations()
108 */
10992 @Override
11093 public void registerSourceSinkLocations() throws DataflowAnalysisException {
11194 registerParameterSources();
159142 private void registerPushNullSource(Location location) throws DataflowAnalysisException {
160143 registerConstantSource(location, null);
161144 }
162 private void registerConstantSource(Location location, Object constantValue) throws DataflowAnalysisException {
145 private void registerConstantSource(Location location, @CheckForNull Object constantValue) throws DataflowAnalysisException {
163146
164147 When w;
165148 if (typeQualifierValue.canValidate(constantValue)) {
226209 }
227210
228211 private void registerTopOfStackSource(SourceSinkType sourceSinkType, Location location, When when, boolean interproc,
229 Object constantValue) throws DataflowAnalysisException {
212 @CheckForNull Object constantValue) throws DataflowAnalysisException {
230213 if (when == When.UNKNOWN && !typeQualifierValue.isStrictQualifier())
231214 return;
232215 ValueNumberFrame vnaFrameAfterInstruction = vnaDataflow.getFactAfterLocation(location);
248231 int param = 0;
249232 int slotOffset = 0;
250233
251 for (Iterator<String> i = sigParser.parameterSignatureIterator(); i.hasNext();) {
252 String paramSig = i.next();
234 for ( String paramSig : sigParser.parameterSignatures()) {
253235
254236 // Get the TypeQualifierAnnotation for this parameter
255237 SourceSinkInfo info;
6161 super(methodDescriptor);
6262 }
6363
64 /*
65 * (non-Javadoc)
66 *
67 * @see
68 * edu.umd.cs.findbugs.ba.jsr305.TypeQualifierDataflowFactory#getDataflow
69 * (edu.umd.cs.findbugs.ba.DepthFirstSearch, edu.umd.cs.findbugs.ba.XMethod,
70 * edu.umd.cs.findbugs.ba.CFG,
71 * edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow,
72 * org.apache.bcel.generic.ConstantPoolGen,
73 * edu.umd.cs.findbugs.classfile.IAnalysisCache,
74 * edu.umd.cs.findbugs.classfile.MethodDescriptor)
75 */
64
7665 @Override
7766 protected ForwardTypeQualifierDataflow getDataflow(DepthFirstSearch dfs, XMethod xmethod, CFG cfg,
7867 ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, IAnalysisCache analysisCache,
79 MethodDescriptor methodDescriptor, TypeQualifierValue typeQualifierValue) throws DataflowAnalysisException {
68 MethodDescriptor methodDescriptor, TypeQualifierValue<?> typeQualifierValue) throws DataflowAnalysisException {
8069 ForwardTypeQualifierDataflowAnalysis analysis = new ForwardTypeQualifierDataflowAnalysis(dfs, xmethod, cfg, vnaDataflow,
8170 cpg, typeQualifierValue);
8271 analysis.registerSourceSinkLocations();
9180
9281 @Override
9382 protected void populateDatabase(ForwardTypeQualifierDataflow dataflow, ValueNumberDataflow vnaDataflow, XMethod xmethod,
94 TypeQualifierValue tqv) throws CheckedAnalysisException {
83 TypeQualifierValue<?> tqv) throws CheckedAnalysisException {
9584 assert TypeQualifierDatabase.USE_DATABASE;
9685
9786 if (xmethod.getSignature().endsWith(")V")) {
2222
2323 /**
2424 * Accumulate type qualifier annotations for a method parameter.
25 *
25 *
2626 * @author David Hovemeyer
2727 */
2828 public class ParameterAnnotationAccumulator extends AbstractMethodAnnotationAccumulator {
29 private int parameter;
29 private final int parameter;
3030
31 private ParameterAnnotationLookupResult result;
31 private final ParameterAnnotationLookupResult result;
3232
3333 private boolean overrides = false;
3434
3535 /**
3636 * Constructor.
37 *
37 *
3838 * @param typeQualifierValue
3939 * TypeQualifierValue specifying kind of application to lookup
4040 * @param xmethod
4242 * @param parameter
4343 * the parameter (0 == first parameter)
4444 */
45 protected ParameterAnnotationAccumulator(TypeQualifierValue typeQualifierValue, XMethod xmethod, int parameter) {
45 protected ParameterAnnotationAccumulator(TypeQualifierValue<?> typeQualifierValue, XMethod xmethod, int parameter) {
4646 super(typeQualifierValue, xmethod);
4747 this.parameter = parameter;
4848 this.result = new ParameterAnnotationLookupResult();
4949 }
5050
51 /*
52 * (non-Javadoc)
53 *
54 * @see
55 * edu.umd.cs.findbugs.ba.jsr305.AbstractMethodAnnotationAccumulator#getResult
56 * ()
57 */
5851 @Override
5952 public TypeQualifierAnnotationLookupResult getResult() {
6053 return result;
6962 return overrides;
7063 }
7164
72 /*
73 * (non-Javadoc)
74 *
75 * @see edu.umd.cs.findbugs.ba.jsr305.AbstractMethodAnnotationAccumulator#
76 * lookupAnnotation(edu.umd.cs.findbugs.ba.XMethod)
77 */
7865 @Override
7966 protected TypeQualifierAnnotation lookupAnnotation(XMethod xm) {
8067 overrides = true;
81 TypeQualifierAnnotation result = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xm, parameter,
68 TypeQualifierAnnotation result1 = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xm, parameter,
8269 getTypeQualifierValue());
83 if (TypeQualifierApplications.DEBUG && result != null) {
84 System.out.println("Inherit " + result.when + " from " + xm);
70 if (TypeQualifierApplications.DEBUG && result1 != null) {
71 System.out.println("Inherit " + result1.when + " from " + xm);
8572 }
86 return result;
73 return result1;
8774
8875 }
8976
3030
3131 /**
3232 * A type qualifier applied to a field, method, parameter, or return value.
33 *
33 *
3434 * @author Bill Pugh
3535 * @author David Hovemeyer
3636 */
3737 public class TypeQualifierAnnotation {
3838
39 public final TypeQualifierValue typeQualifier;
39 public final TypeQualifierValue<?> typeQualifier;
4040
4141 public final When when;
4242
43 private TypeQualifierAnnotation(TypeQualifierValue typeQualifier, When when) {
43 private TypeQualifierAnnotation(TypeQualifierValue<?> typeQualifier, When when) {
4444 this.typeQualifier = typeQualifier;
4545 this.when = when;
4646 }
5656 // TypeQualifierAnnotation> map = new DualKeyHashMap <TypeQualifierValue,
5757 // When, TypeQualifierAnnotation> ();
5858
59 private static ThreadLocal<DualKeyHashMap<TypeQualifierValue, When, TypeQualifierAnnotation>> instance = new ThreadLocal<DualKeyHashMap<TypeQualifierValue, When, TypeQualifierAnnotation>>() {
59 private static ThreadLocal<DualKeyHashMap<TypeQualifierValue<?>, When, TypeQualifierAnnotation>> instance = new ThreadLocal<DualKeyHashMap<TypeQualifierValue<?>, When, TypeQualifierAnnotation>>() {
6060 @Override
61 protected DualKeyHashMap<TypeQualifierValue, When, TypeQualifierAnnotation> initialValue() {
62 return new DualKeyHashMap<TypeQualifierValue, When, TypeQualifierAnnotation>();
61 protected DualKeyHashMap<TypeQualifierValue<?>, When, TypeQualifierAnnotation> initialValue() {
62 return new DualKeyHashMap<TypeQualifierValue<?>, When, TypeQualifierAnnotation>();
6363 }
6464 };
6565
107107
108108 /**
109109 * Combine return type annotations.
110 *
110 *
111111 * @param a
112112 * a TypeQualifierAnnotation used on a return value
113113 * @param b
122122 }
123123
124124 /**
125 *
125 *
126126 * @param a
127127 * a TypeQualifierAnnotation used on a method parameter
128128 * @param b
156156 }
157157
158158 public static @Nonnull
159 Collection<TypeQualifierAnnotation> getValues(Map<TypeQualifierValue, When> map) {
159 Collection<TypeQualifierAnnotation> getValues(Map<TypeQualifierValue<?>, When> map) {
160160 Collection<TypeQualifierAnnotation> result = new LinkedList<TypeQualifierAnnotation>();
161 for (Map.Entry<TypeQualifierValue, When> e : map.entrySet()) {
161 for (Map.Entry<TypeQualifierValue<?>, When> e : map.entrySet()) {
162162 result.add(getValue(e.getKey(), e.getValue()));
163163 }
164164 return result;
165165 }
166166
167167 public static @Nonnull
168 TypeQualifierAnnotation getValue(TypeQualifierValue desc, When when) {
169 DualKeyHashMap<TypeQualifierValue, When, TypeQualifierAnnotation> map = instance.get();
168 TypeQualifierAnnotation getValue(TypeQualifierValue<?> desc, When when) {
169 DualKeyHashMap<TypeQualifierValue<?>, When, TypeQualifierAnnotation> map = instance.get();
170170 TypeQualifierAnnotation result = map.get(desc, when);
171171 if (result != null)
172172 return result;
2727 import java.util.Set;
2828
2929 import javax.annotation.CheckForNull;
30 import javax.annotation.CheckReturnValue;
3031 import javax.annotation.meta.When;
3132
3233 import org.objectweb.asm.Type;
8283 * AnnotatedObject, the effective TypeQualifierAnnotation (if any) for
8384 * that AnnotatedObject.
8485 */
85 private final Map<TypeQualifierValue, Map<AnnotatedObject, TypeQualifierAnnotation>> effectiveObjectAnnotations = new HashMap<TypeQualifierValue, Map<AnnotatedObject, TypeQualifierAnnotation>>();
86 private final Map<TypeQualifierValue<?>, Map<AnnotatedObject, TypeQualifierAnnotation>> effectiveObjectAnnotations = new HashMap<TypeQualifierValue<?>, Map<AnnotatedObject, TypeQualifierAnnotation>>();
8687
8788 /**
8889 * Map of TypeQualifierValues to maps containing, for each
8990 * XMethod/parameter, the effective TypeQualifierAnnotation (if any) for
9091 * that XMethod/parameter.
9192 */
92 private final Map<TypeQualifierValue, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> effectiveParameterAnnotations = new HashMap<TypeQualifierValue, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>>();
93 private final Map<TypeQualifierValue<?>, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> effectiveParameterAnnotations = new HashMap<TypeQualifierValue<?>, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>>();
9394 }
9495
9596 private static ThreadLocal<Data> instance = new ThreadLocal<Data>() {
106107 instance.remove();
107108 }
108109
109 private static Map<TypeQualifierValue, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> getEffectiveParameterAnnotations() {
110 private static Map<TypeQualifierValue<?>, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> getEffectiveParameterAnnotations() {
110111 return instance.get().effectiveParameterAnnotations;
111112 }
112113
113 private static Map<TypeQualifierValue, Map<AnnotatedObject, TypeQualifierAnnotation>> getEffectiveObjectAnnotations() {
114 private static Map<TypeQualifierValue<?>, Map<AnnotatedObject, TypeQualifierAnnotation>> getEffectiveObjectAnnotations() {
114115 return instance.get().effectiveObjectAnnotations;
115116 }
116117
132133 * AnnotatedObject or method parameter.
133134 */
134135 private interface ComputeEffectiveTypeQualifierAnnotation {
135 public TypeQualifierAnnotation compute(TypeQualifierValue tqv);
136 public TypeQualifierAnnotation compute(TypeQualifierValue<?> tqv);
136137 }
137138
138139 /**
240241 EnumValue whenValue = (EnumValue) v.getValue("when");
241242 When when = whenValue == null ? When.ALWAYS : When.valueOf(whenValue.value);
242243 ClassDescriptor annotationClass = v.getAnnotationClass();
243 TypeQualifierValue tqv = TypeQualifierValue.getValue(annotationClass, v.getValue("value"));
244 TypeQualifierValue<?> tqv = TypeQualifierValue.getValue(annotationClass, v.getValue("value"));
244245 TypeQualifierAnnotation tqa = TypeQualifierAnnotation.getValue(tqv, when);
245246 return tqa;
246247 }
372373 */
373374 private static @CheckForNull
374375 TypeQualifierAnnotation findMatchingTypeQualifierAnnotation(Collection<TypeQualifierAnnotation> typeQualifierAnnotations,
375 TypeQualifierValue typeQualifierValue) {
376 TypeQualifierValue<?> typeQualifierValue) {
376377 for (TypeQualifierAnnotation typeQualifierAnnotation : typeQualifierAnnotations) {
377378 if (typeQualifierAnnotation.typeQualifier.equals(typeQualifierValue)) {
378379 return typeQualifierAnnotation;
394395 * @return default TypeQualifierAnnotation, or null if none
395396 */
396397 private static @CheckForNull
397 TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue typeQualifierValue, ElementType elementType) {
398 TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue<?> typeQualifierValue, ElementType elementType) {
398399 //
399400 // Try to find a default annotation using the standard JSR-305
400401 // default annotation mechanism.
434435 // ignore
435436 }
436437
438 // Try out default JDT (Eclipse) annotations
439 if(result == null){
440 AnnotationValue annotationValue = o.getAnnotation(TypeQualifierResolver.eclipseNonNullByDefault);
441 if(annotationValue != null){
442 Collection<AnnotationValue> resolvedTypeQualifiers = TypeQualifierResolver.resolveTypeQualifiers(annotationValue);
443 tqa = extractAnnotation(resolvedTypeQualifiers, typeQualifierValue);
444 if(tqa != null){
445 return tqa;
446 }
447 }
448 }
437449 return result;
438450 }
439451
440452 private static @CheckForNull
441453 TypeQualifierAnnotation checkFindBugsDefaultAnnotation(ClassDescriptor defaultAnnotation, AnnotatedObject o,
442 TypeQualifierValue typeQualifierValue) {
454 TypeQualifierValue<?> typeQualifierValue) {
443455
444456 if (DEBUG_DEFAULT_ANNOTATION) {
445457 System.out.println("Checking for " + defaultAnnotation + " containing " + typeQualifierValue + " on " + o);
503515 }
504516
505517 private static TypeQualifierAnnotation extractAnnotation(Collection<AnnotationValue> resolvedTypeQualifiers,
506 TypeQualifierValue typeQualifierValue) {
518 TypeQualifierValue<?> typeQualifierValue) {
507519 for (AnnotationValue typeQualifier : resolvedTypeQualifiers) {
508520 TypeQualifierAnnotation tqa = constructTypeQualifierAnnotation(typeQualifier);
509521 if (tqa.typeQualifier.equals(typeQualifierValue)) {
530542 * effective TypeQualifierAnnotation on this AnnotatedObject
531543 */
532544 public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
533 TypeQualifierValue typeQualifierValue) {
545 TypeQualifierValue<?> typeQualifierValue) {
534546 if (o instanceof XMethod) {
535547 XMethod m = (XMethod) o;
536548 if (m.getName().startsWith("access$")) {
551563 final AnnotatedObject o2 = o;
552564 if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
553565 tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
554 public TypeQualifierAnnotation compute(TypeQualifierValue tqv) {
566 public TypeQualifierAnnotation compute(TypeQualifierValue<?> tqv) {
555567 return computeEffectiveTypeQualifierAnnotation(tqv, o2);
556568 }
557569
565577 return tqa;
566578 }
567579
568 private static TypeQualifierAnnotation computeEffectiveTypeQualifierAnnotation(TypeQualifierValue typeQualifierValue,
580 private static TypeQualifierAnnotation computeEffectiveTypeQualifierAnnotation(TypeQualifierValue<?> typeQualifierValue,
569581 AnnotatedObject o) {
570582
571583 Map<AnnotatedObject, TypeQualifierAnnotation> map = getEffectiveObjectAnnotations().get(typeQualifierValue);
630642 * such annotation on the AnnotatedObject
631643 */
632644 private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o,
633 TypeQualifierValue typeQualifierValue) {
645 TypeQualifierValue<?> typeQualifierValue) {
634646 TypeQualifierAnnotation result;
635647
636648 Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
653665 * supertype methods, or null if there is no inherited
654666 * TypeQualifierAnnotation
655667 */
656 private static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue typeQualifierValue) {
668 public static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue<?> typeQualifierValue) {
657669 assert !o.isStatic();
658670
659671 ReturnTypeAnnotationAccumulator accumulator = new ReturnTypeAnnotationAccumulator(typeQualifierValue, o);
681693 * is no default TypeQualifierAnnotation
682694 */
683695 private static TypeQualifierAnnotation getDefaultTypeQualifierAnnotation(AnnotatedObject o,
684 TypeQualifierValue typeQualifierValue, boolean stopAtClassScope) {
696 TypeQualifierValue<?> typeQualifierValue, boolean stopAtClassScope) {
685697
686698 if (o.isSynthetic())
687699 return null; // synthetic objects don't get default annotations
729741 */
730742 public static @CheckForNull
731743 TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(final XMethod xmethod, final int parameter,
732 TypeQualifierValue typeQualifierValue) {
744 TypeQualifierValue<?> typeQualifierValue) {
733745
734746 TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, xmethod, parameter);
735747
736748 if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
737749 tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
738 public TypeQualifierAnnotation compute(TypeQualifierValue tqv) {
750 public TypeQualifierAnnotation compute(TypeQualifierValue<?> tqv) {
739751 return computeEffectiveTypeQualifierAnnotation(tqv, xmethod, parameter);
740752 }
741753
751763
752764 // static Map<String, Throwable> checked = new HashMap<String, Throwable>();
753765
754 private static TypeQualifierAnnotation computeEffectiveTypeQualifierAnnotation(TypeQualifierValue typeQualifierValue,
766 private static TypeQualifierAnnotation computeEffectiveTypeQualifierAnnotation(TypeQualifierValue<?> typeQualifierValue,
755767 XMethod xmethod, int parameter) {
756768 if (DEBUG) {
757769 // System.out.println("XX: "
761773 + typeQualifierValue.value.getClass().toString() + ")");
762774 }
763775 }
764 Map<TypeQualifierValue, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> effectiveParameterAnnotations = getEffectiveParameterAnnotations();
776 Map<TypeQualifierValue<?>, DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation>> effectiveParameterAnnotations = getEffectiveParameterAnnotations();
765777 DualKeyHashMap<XMethod, Integer, TypeQualifierAnnotation> map = effectiveParameterAnnotations.get(typeQualifierValue);
766778 if (map == null) {
767779 if (DEBUG) {
885897 * @return TypeQualifierAnnotation directly applied to the parameter, or
886898 * null if there is no directly applied TypeQualifierAnnotation
887899 */
888 public static @CheckForNull
889 TypeQualifierAnnotation getDirectTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue typeQualifierValue) {
900 public static @CheckForNull @CheckReturnValue
901 TypeQualifierAnnotation getDirectTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) {
890902 XMethod bridge = xmethod.bridgeTo();
891903 if (bridge != null)
892904 xmethod = bridge;
912924 * @return effective inherited TypeQualifierAnnotation on the parameter, or
913925 * null if there is not effective TypeQualifierAnnotation
914926 */
915 private static @CheckForNull
927 public static @CheckForNull
916928 TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod xmethod, int parameter,
917 TypeQualifierValue typeQualifierValue) {
929 TypeQualifierValue<?> typeQualifierValue) {
918930 assert !xmethod.isStatic();
919931
920932 ParameterAnnotationAccumulator accumulator = new ParameterAnnotationAccumulator(typeQualifierValue, xmethod, parameter);
945957 */
946958 private static @CheckForNull
947959 TypeQualifierAnnotation getDefaultTypeQualifierAnnotationForParameters(XMethod xmethod,
948 TypeQualifierValue typeQualifierValue, boolean stopAtMethodScope) {
960 TypeQualifierValue<?> typeQualifierValue, boolean stopAtMethodScope) {
949961
950962 if (xmethod.isSynthetic())
951963 return null; // synthetic methods don't get default annotations
972984
973985 AnnotatedObject o = xmethod;
974986 while (true) {
975 o = o.getContainingScope();
976987 if (o == null)
977988 return null;
978989
9961007 }
9971008 if (stopAtClassScope && o instanceof XClass)
9981009 return null;
999 }
1000
1001 }
1002
1003 private static TypeQualifierAnnotation computeExclusiveQualifier(TypeQualifierValue typeQualifierValue,
1010
1011 o = o.getContainingScope();
1012
1013 }
1014
1015 }
1016
1017 private static TypeQualifierAnnotation computeExclusiveQualifier(TypeQualifierValue<?> typeQualifierValue,
10041018 ComputeEffectiveTypeQualifierAnnotation c) {
10051019 assert typeQualifierValue.isExclusiveQualifier();
10061020
10211035
10221036 boolean allComplementaryValuesAreWhenEqualsNever = true;
10231037
1024 Collection<TypeQualifierValue> complementaryTypeQualifierValues = TypeQualifierValue
1038 Collection<TypeQualifierValue<?>> complementaryTypeQualifierValues = TypeQualifierValue
10251039 .getComplementaryExclusiveTypeQualifierValue(typeQualifierValue);
10261040
1027 for (TypeQualifierValue complementaryTypeQualifierValue : complementaryTypeQualifierValues) {
1041 for (TypeQualifierValue<?> complementaryTypeQualifierValue : complementaryTypeQualifierValues) {
10281042 TypeQualifierAnnotation complementaryTqa = c.compute(complementaryTypeQualifierValue);
10291043 if (complementaryTqa != null) {
10301044 if (complementaryTqa.when == When.ALWAYS) {
2828 /**
2929 * Store computed type qualifiers for method parameters and return values. This
3030 * allows interprocedural checking of type qualifiers.
31 *
31 *
3232 * @author David Hovemeyer
3333 */
3434 public class TypeQualifierDatabase {
3939
4040 public static final boolean DEBUG = SystemProperties.getBoolean("ctq.db.debug");
4141
42 private Map<MethodDescriptor, Map<TypeQualifierValue, TypeQualifierAnnotation>> returnValueMap;
42 private final Map<MethodDescriptor, Map<TypeQualifierValue<?>, TypeQualifierAnnotation>> returnValueMap;
4343
44 private DualKeyHashMap<MethodDescriptor, Integer, Map<TypeQualifierValue, TypeQualifierAnnotation>> parameterMap;
44 private final DualKeyHashMap<MethodDescriptor, Integer, Map<TypeQualifierValue<?>, TypeQualifierAnnotation>> parameterMap;
4545
4646 /**
4747 * Constructor.
4848 */
4949 public TypeQualifierDatabase() {
50 this.returnValueMap = new HashMap<MethodDescriptor, Map<TypeQualifierValue, TypeQualifierAnnotation>>();
51 this.parameterMap = new DualKeyHashMap<MethodDescriptor, Integer, Map<TypeQualifierValue, TypeQualifierAnnotation>>();
50 this.returnValueMap = new HashMap<MethodDescriptor, Map<TypeQualifierValue<?>, TypeQualifierAnnotation>>();
51 this.parameterMap = new DualKeyHashMap<MethodDescriptor, Integer, Map<TypeQualifierValue<?>, TypeQualifierAnnotation>>();
5252 }
5353
5454 /**
5555 * Set a TypeQualifierAnnotation on a method return value.
56 *
56 *
5757 * @param methodDesc
5858 * the method
5959 * @param tqv
6161 * @param tqa
6262 * the type qualifier annotation
6363 */
64 public void setReturnValue(MethodDescriptor methodDesc, TypeQualifierValue tqv, TypeQualifierAnnotation tqa) {
65 Map<TypeQualifierValue, TypeQualifierAnnotation> map = returnValueMap.get(methodDesc);
64 public void setReturnValue(MethodDescriptor methodDesc, TypeQualifierValue<?> tqv, TypeQualifierAnnotation tqa) {
65 Map<TypeQualifierValue<?>, TypeQualifierAnnotation> map = returnValueMap.get(methodDesc);
6666 if (map == null) {
67 map = new HashMap<TypeQualifierValue, TypeQualifierAnnotation>();
67 map = new HashMap<TypeQualifierValue<?>, TypeQualifierAnnotation>();
6868 returnValueMap.put(methodDesc, map);
6969 }
7070 map.put(tqv, tqa);
7676
7777 /**
7878 * Get the TypeQualifierAnnotation on a method return value.
79 *
79 *
8080 * @param methodDesc
8181 * the method
8282 * @param tqv
8585 * if no (interesting) type qualifier annotation was computed for
8686 * this method
8787 */
88 public TypeQualifierAnnotation getReturnValue(MethodDescriptor methodDesc, TypeQualifierValue tqv) {
88 public TypeQualifierAnnotation getReturnValue(MethodDescriptor methodDesc, TypeQualifierValue<?> tqv) {
8989 //
9090 // TODO: handling of overridden methods?
9191 //
92 Map<TypeQualifierValue, TypeQualifierAnnotation> map = returnValueMap.get(methodDesc);
92 Map<TypeQualifierValue<?>, TypeQualifierAnnotation> map = returnValueMap.get(methodDesc);
9393 if (map == null) {
9494 return null;
9595 }
9898
9999 /**
100100 * Set a TypeQualifierAnnotation on a method parameter.
101 *
101 *
102102 * @param methodDesc
103103 * the method
104104 * @param param
108108 * @param tqa
109109 * the type qualifier annotation
110110 */
111 public void setParameter(MethodDescriptor methodDesc, int param, TypeQualifierValue tqv, TypeQualifierAnnotation tqa) {
112 Map<TypeQualifierValue, TypeQualifierAnnotation> map = parameterMap.get(methodDesc, param);
111 public void setParameter(MethodDescriptor methodDesc, int param, TypeQualifierValue<?> tqv, TypeQualifierAnnotation tqa) {
112 Map<TypeQualifierValue<?>, TypeQualifierAnnotation> map = parameterMap.get(methodDesc, param);
113113 if (map == null) {
114 map = new HashMap<TypeQualifierValue, TypeQualifierAnnotation>();
114 map = new HashMap<TypeQualifierValue<?>, TypeQualifierAnnotation>();
115115 parameterMap.put(methodDesc, param, map);
116116 }
117117 map.put(tqv, tqa);
123123
124124 /**
125125 * Get the TypeQualifierAnnotation on a parameter.
126 *
126 *
127127 * @param methodDesc
128128 * the method
129129 * @param param
134134 * if no (interesting) type qualifier annotation was computed for
135135 * this method
136136 */
137 public TypeQualifierAnnotation getParameter(MethodDescriptor methodDesc, int param, TypeQualifierValue tqv) {
137 public TypeQualifierAnnotation getParameter(MethodDescriptor methodDesc, int param, TypeQualifierValue<?> tqv) {
138138 //
139139 // TODO: handling of overridden methods?
140140 //
141 Map<TypeQualifierValue, TypeQualifierAnnotation> map = parameterMap.get(methodDesc, param);
141 Map<TypeQualifierValue<?>, TypeQualifierAnnotation> map = parameterMap.get(methodDesc, param);
142142 if (map == null) {
143143 return null;
144144 }
3636 /**
3737 * Factory to create and cache TypeQualifierDataflow objects for a particular
3838 * method.
39 *
39 *
4040 * @author David Hovemeyer
4141 */
4242 public abstract class TypeQualifierDataflowFactory<AnalysisType extends TypeQualifierDataflowAnalysis, DataflowType extends TypeQualifierDataflow<AnalysisType>> {
5959 }
6060 }
6161
62 private HashMap<TypeQualifierValue, DataflowResult<DataflowType>> dataflowMap;
62 private final HashMap<TypeQualifierValue<?>, DataflowResult<DataflowType>> dataflowMap;
6363
64 private MethodDescriptor methodDescriptor;
64 private final MethodDescriptor methodDescriptor;
6565
6666 public TypeQualifierDataflowFactory(MethodDescriptor methodDescriptor) {
6767 this.methodDescriptor = methodDescriptor;
68 this.dataflowMap = new HashMap<TypeQualifierValue, DataflowResult<DataflowType>>();
68 this.dataflowMap = new HashMap<TypeQualifierValue<?>, DataflowResult<DataflowType>>();
6969 }
7070
71 public DataflowType getDataflow(TypeQualifierValue typeQualifierValue) throws CheckedAnalysisException {
71 public DataflowType getDataflow(TypeQualifierValue<?> typeQualifierValue) throws CheckedAnalysisException {
7272 DataflowResult<DataflowType> result = dataflowMap.get(typeQualifierValue);
7373 if (result == null) {
7474 result = compute(typeQualifierValue);
7777 return result.get();
7878 }
7979
80 private DataflowResult<DataflowType> compute(TypeQualifierValue typeQualifierValue) {
80 private DataflowResult<DataflowType> compute(TypeQualifierValue<?> typeQualifierValue) {
8181 DataflowResult<DataflowType> result = new DataflowResult<DataflowType>();
8282
8383 try {
111111 }
112112
113113 protected abstract DataflowType getDataflow(DepthFirstSearch dfs, XMethod xmethod, CFG cfg, ValueNumberDataflow vnaDataflow,
114 ConstantPoolGen cpg, IAnalysisCache analysisCache, MethodDescriptor methodDescriptor,
115 TypeQualifierValue typeQualifierValue) throws CheckedAnalysisException;
114 ConstantPoolGen cpg, IAnalysisCache analysisCache, MethodDescriptor methodDescriptor1,
115 TypeQualifierValue<?> typeQualifierValue) throws CheckedAnalysisException;
116116
117117 protected abstract void populateDatabase(DataflowType dataflow, ValueNumberDataflow vnaDataflow, XMethod xmethod,
118 TypeQualifierValue tqv) throws CheckedAnalysisException;
118 TypeQualifierValue<?> tqv) throws CheckedAnalysisException;
119119
120120 }
2020
2121 import java.lang.annotation.ElementType;
2222 import java.util.Collection;
23 import java.util.Collections;
2324 import java.util.LinkedList;
2425
2526 import edu.umd.cs.findbugs.ba.AnalysisContext;
169170 * @return Collection of resolved type qualifier AnnotationValues
170171 */
171172 public static Collection<AnnotationValue> resolveTypeQualifiers(Collection<AnnotationValue> values) {
173 if (values.isEmpty())
174 return Collections.emptyList();
172175 LinkedList<AnnotationValue> result = new LinkedList<AnnotationValue>();
173176 LinkedList<ClassDescriptor> onStack = new LinkedList<ClassDescriptor>();
174177 for (AnnotationValue value : values)
2222 import java.lang.reflect.InvocationHandler;
2323 import java.lang.reflect.Method;
2424 import java.lang.reflect.Proxy;
25 import java.security.Permission;
2625 import java.util.Collection;
2726 import java.util.Collections;
2827 import java.util.HashSet;
2928 import java.util.LinkedList;
3029 import java.util.Set;
31 import java.util.concurrent.atomic.AtomicBoolean;
3230
3331 import javax.annotation.CheckForNull;
3432 import javax.annotation.Nonnull;
4644 import edu.umd.cs.findbugs.classfile.Global;
4745 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
4846 import edu.umd.cs.findbugs.classfile.analysis.ClassData;
47 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
4948 import edu.umd.cs.findbugs.log.Profiler;
5049 import edu.umd.cs.findbugs.util.DualKeyHashMap;
5150 import edu.umd.cs.findbugs.util.Util;
6160 */
6261 public class TypeQualifierValue<A extends Annotation> {
6362 public static final boolean DEBUG = SystemProperties.getBoolean("tqv.debug");
63 public static final boolean DEBUG_CLASSLOADING = SystemProperties.getBoolean("tqv.debug.classloading");
6464
6565 private static final ClassDescriptor EXCLUSIVE_ANNOTATION = DescriptorFactory.instance().getClassDescriptor(
6666 javax.annotation.meta.Exclusive.class);
8484 private final @CheckForNull
8585 TypeQualifierValidator<A> validator;
8686
87 private final static ClassLoader validatorLoader = new ValidatorClassLoader();
8887
8988
9089 private TypeQualifierValue(ClassDescriptor typeQualifier, @CheckForNull Object value) {
9190 this.typeQualifier = typeQualifier;
9291 this.value = value;
93 boolean isStrict = false; // will be set to true if this is a strict
94 // type qualifier value
95 boolean isExclusive = false; // will be set to true if this is an
96 // exclusive type qualifier value
97 boolean isExhaustive = false; // will be set to true if this is an
98 // exhaustive type qualifier value
99
100 TypeQualifierValidator<A> validator = null;
92 /** will be set to true if this is a strict type qualifier value */
93 boolean isStrict1 = false;
94 /** will be set to true if this is an exclusive type qualifier value */
95 boolean isExclusive1 = false;
96 /** will be set to true if this is an exhaustive type qualifier value */
97 boolean isExhaustive1 = false;
98 TypeQualifierValidator<A> validator1 = null;
10199 Class<A> qualifierClass = null;
102 A proxy = null;
100 XClass xclass = null;
101 A proxy1 = null;
103102 try {
104 XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, typeQualifier);
103 xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, typeQualifier);
105104
106105 // Annotation elements appear as abstract methods in the annotation
107106 // class (interface).
110109 // it will appear as an abstract method called "when".
111110 XMethod whenMethod = xclass.findMethod("when", "()Ljavax/annotation/meta/When;", false);
112111 if (whenMethod == null) {
113 isStrict = true;
112 isStrict1 = true;
114113 }
115114 for (XMethod xmethod : xclass.getXMethods()) {
116115 if (xmethod.getName().equals("value") && xmethod.getSignature().startsWith("()")) {
117 isExhaustive = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null;
118 if (isExhaustive) {
116 isExhaustive1 = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null;
117 if (isExhaustive1) {
119118 // exhaustive qualifiers are automatically exclusive
120 isExclusive = true;
119 isExclusive1 = true;
121120 } else {
122121 // see if there is an explicit @Exclusive annotation
123 isExclusive = xmethod.getAnnotation(EXCLUSIVE_ANNOTATION) != null;
122 isExclusive1 = xmethod.getAnnotation(EXCLUSIVE_ANNOTATION) != null;
124123 }
125124
126125 break;
131130 } catch (CheckedAnalysisException e) {
132131 AnalysisContext.logError("Error looking up annotation class " + typeQualifier.toDottedClassName(), e);
133132 }
134 this.isStrict = isStrict;
135 this.isExclusive = isExclusive;
136 this.isExhaustive = isExhaustive;
137 ClassDescriptor checkerName = DescriptorFactory.createClassDescriptor(typeQualifier.getClassName() + "$Checker");
138 try {
139 Global.getAnalysisCache().getClassAnalysis(ClassData.class, checkerName);
140 // found it.
141 // System.out.println(checkerName);
142 SecurityManager m = System.getSecurityManager();
143 if (m == null)
144 System.setSecurityManager(new ValidationSecurityManager());
145 Class<?> c = validatorLoader.loadClass(checkerName.getDottedClassName());
146 if (TypeQualifierValidator.class.isAssignableFrom(c)) {
147 Class<? extends TypeQualifierValidator> checkerClass = c.asSubclass(TypeQualifierValidator.class);
148 validator = getValidator(checkerClass);
149 qualifierClass = getQualifierClass(typeQualifier);
150
151 InvocationHandler handler = new InvocationHandler() {
152
153 public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
154 if (arg1.getName() == "value")
155 return TypeQualifierValue.this.value;
156 throw new UnsupportedOperationException("Can't handle " + arg1);
157 }};
158
159 proxy = qualifierClass.cast(Proxy.newProxyInstance(validatorLoader, new Class[] {qualifierClass}, handler));
160 }
161 } catch (ClassNotFoundException e) {
162 assert true; // ignore
163 } catch (CheckedAnalysisException e) {
164 assert true; // ignore
165 } catch (Exception e) {
166 AnalysisContext.logError("Unable to construct type qualifier checker " + checkerName, e);
167 } catch (Throwable e) {
168 AnalysisContext.logError("Unable to construct type qualifier checker " + checkerName + " due to " + e.getClass().getSimpleName() + ":" + e.getMessage());
169 }
170 this.validator = validator;
133 this.isStrict = isStrict1;
134 this.isExclusive = isExclusive1;
135 this.isExhaustive = isExhaustive1;
136
137
138 if (xclass != null) {
139 ClassDescriptor checkerName = DescriptorFactory.createClassDescriptor(typeQualifier.getClassName() + "$Checker");
140
141 if (!SystemProperties.RUNNING_IN_ECLIPSE) {
142 /** don't do this if running in Eclipse; check below is the quick
143 fix for bug 3599258 (Random obscure Eclipse failures during
144 analysis) */
145
146 try {
147 Global.getAnalysisCache().getClassAnalysis(ClassData.class, checkerName);
148
149 // found it.
150 SecurityManager m = System.getSecurityManager();
151 if (m == null) {
152 if (DEBUG_CLASSLOADING) System.out.println("Setting ValidationSecurityManager");
153 System.setSecurityManager(ValidationSecurityManager.INSTANCE);
154 }
155
156 Class<?> c = ValidatorClassLoader.INSTANCE.loadClass(checkerName.getDottedClassName());
157 if (TypeQualifierValidator.class.isAssignableFrom(c)) {
158
159 @SuppressWarnings("unchecked")
160 Class<? extends TypeQualifierValidator<A>> validatorClass = (Class<? extends TypeQualifierValidator<A>>) c
161 .asSubclass(TypeQualifierValidator.class);
162 validator1 = getValidator(validatorClass);
163 qualifierClass = getQualifierClass(typeQualifier);
164
165 InvocationHandler handler = new InvocationHandler() {
166
167 public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
168 if (arg1.getName() == "value")
169 return TypeQualifierValue.this.value;
170 throw new UnsupportedOperationException("Can't handle " + arg1);
171 }
172 };
173
174 proxy1 = qualifierClass.cast(Proxy.newProxyInstance(ValidatorClassLoader.INSTANCE,
175 new Class[] { qualifierClass }, handler));
176 }
177
178 } catch (ClassNotFoundException e) {
179 assert true; // ignore
180 } catch (CheckedAnalysisException e) {
181 assert true; // ignore
182 } catch (Exception e) {
183 AnalysisContext.logError("Unable to construct type qualifier checker " + checkerName, e);
184 } catch (Throwable e) {
185 AnalysisContext.logError("Unable to construct type qualifier checker " + checkerName + " due to "
186 + e.getClass().getSimpleName() + ":" + e.getMessage());
187 }
188 }
189 else if (DEBUG_CLASSLOADING) {
190 SecurityManager m = System.getSecurityManager();
191 if (m == null) {
192 if (DEBUG_CLASSLOADING) System.out.println("Setting ValidationSecurityManager");
193 System.setSecurityManager(ValidationSecurityManager.INSTANCE);
194 }
195 }
196 }
197 this.validator = validator1;
171198 this.typeQualifierClass = qualifierClass;
172 this.proxy = proxy;
173 }
174
175 /**
176 * @param checkerClass
177 * @return
178 * @throws InstantiationException
179 * @throws IllegalAccessException
180 */
181 @SuppressWarnings("unchecked")
182 private TypeQualifierValidator<A> getValidator(Class<? extends TypeQualifierValidator> checkerClass)
199 this.proxy = proxy1;
200 }
201
202 private static <A extends Annotation> TypeQualifierValidator<A> getValidator(
203 Class<? extends TypeQualifierValidator<A>> checkerClass)
183204 throws InstantiationException, IllegalAccessException {
184205 return checkerClass.newInstance();
185206 }
186207
187 /**
188 * @param typeQualifier
189 * @return
190 * @throws ClassNotFoundException
191 */
192208 @SuppressWarnings("unchecked")
193 private Class<A> getQualifierClass(ClassDescriptor typeQualifier) throws ClassNotFoundException {
209 private static <A> Class<A> getQualifierClass(ClassDescriptor typeQualifier) throws ClassNotFoundException {
210 @DottedClassName String className = typeQualifier.getDottedClassName();
211 if (DEBUG_CLASSLOADING)
212 System.out.println("Getting qualifier class for " + className);
213 if (className.startsWith("javax.annotation"))
214 return (Class<A>) Class.forName(className);
215 try {
216 Global.getAnalysisCache().getClassAnalysis(ClassData.class, typeQualifier);
217 } catch (CheckedAnalysisException e) {
218 throw new ClassNotFoundException("No class data found for " + className);
219 }
220
221 ValidatorClassLoader validatorLoader = ValidatorClassLoader.INSTANCE;
194222 return (Class<A>) validatorLoader.loadClass(typeQualifier.getDottedClassName());
195223 }
196224
225 static byte[] loadClassData(String name) throws CheckedAnalysisException {
226 ClassDescriptor d = DescriptorFactory.createClassDescriptorFromDottedClassName(name);
227 ClassData data = Global.getAnalysisCache().getClassAnalysis(ClassData.class, d);
228 return data.getData();
229 }
197230 static class Data {
198231 /**
199232 * Cache in which constructed TypeQualifierValues are interned.
217250 instance.remove();
218251 }
219252
220 public boolean canValidate(Object constantValue) {
253 public boolean canValidate(@CheckForNull Object constantValue) {
221254 if (validator == null)
222255 return false;
223256 return true;
224257 }
225258
226 private static final InheritableThreadLocal<AtomicBoolean> performingValidation
227 = new InheritableThreadLocal<AtomicBoolean>() {
228 @Override protected AtomicBoolean initialValue() {
229 return new AtomicBoolean();
230 }
231
232 };
233
234 static final class ValidationSecurityManager extends SecurityManager {
235 @Override
236 public void checkPermission(Permission perm) {
237 // System.out.println("Checking " + perm);
238 if (performingValidation.get().get())
239 throw new SecurityException("not permissions granted while performing JSR-305 validation");
240 }
241 @Override
242 public void checkPermission(Permission perm, Object context) {
243 if (performingValidation.get().get())
244 throw new SecurityException("not permissions granted while performing JSR-305 validation");
245 }
246 }
247
248
249 public When validate(Object constantValue) {
259 public When validate(@CheckForNull Object constantValue) {
250260 if (validator == null)
251261 throw new IllegalStateException("No validator");
252262 IAnalysisCache analysisCache = Global.getAnalysisCache();
253263 Profiler profiler = analysisCache.getProfiler();
254264 profiler.start(validator.getClass());
255 AtomicBoolean performing = performingValidation.get();
256265 try {
257 if (!performing.compareAndSet(false, true)) {
258 throw new IllegalStateException("recursive validation");
259 }
260
261 return validator.forConstantValue(proxy, constantValue);
266 return ValidationSecurityManager.sandboxedValidation(proxy, validator, constantValue);
262267 } catch (Exception e) {
263268 AnalysisContext.logError("Error executing custom validator for " + typeQualifier + " " + constantValue, e);
264269 return When.UNKNOWN;
265270 } finally {
266 if (!performing.compareAndSet(true, false)) {
267 throw new IllegalStateException("performingValidation not set when validation completes");
268 }
269271 profiler.end(validator.getClass());
270
271272 }
272273 }
273274
281282 * a value
282283 * @return an interned TypeQualifierValue object
283284 */
285 @SuppressWarnings("rawtypes")
284286 public static @Nonnull
285 TypeQualifierValue<?> getValue(ClassDescriptor desc, Object value) {
287 TypeQualifierValue<?> getValue(ClassDescriptor desc, @CheckForNull Object value) {
286288 DualKeyHashMap<ClassDescriptor, Object, TypeQualifierValue<?>> map = instance.get().typeQualifierMap;
287289 TypeQualifierValue<?> result = map.get(desc, value);
288290 if (result != null)
294296 }
295297 @SuppressWarnings("unchecked")
296298 public static @Nonnull <A extends Annotation>
297 TypeQualifierValue<A> getValue(Class <A> clazz, Object value) {
299 TypeQualifierValue<A> getValue(Class <A> clazz, @CheckForNull Object value) {
298300 return (TypeQualifierValue<A>) getValue(DescriptorFactory.createClassDescriptor(clazz), value);
299301 }
300302
315317 * a type qualifier (which must be exclusive)
316318 * @return Collection of complementary exclusive type qualifiers
317319 */
318 public static Collection<TypeQualifierValue> getComplementaryExclusiveTypeQualifierValue(TypeQualifierValue tqv) {
320 public static Collection<TypeQualifierValue<?>> getComplementaryExclusiveTypeQualifierValue(TypeQualifierValue<?> tqv) {
319321 assert tqv.isExclusiveQualifier();
320322
321 LinkedList<TypeQualifierValue> result = new LinkedList<TypeQualifierValue>();
322
323 for (TypeQualifierValue t : instance.get().allKnownTypeQualifiers) {
323 LinkedList<TypeQualifierValue<?>> result = new LinkedList<TypeQualifierValue<?>>();
324
325 for (TypeQualifierValue<?> t : instance.get().allKnownTypeQualifiers) {
324326 //
325327 // Any TypeQualifierValue with the same
326328 // annotation class but a different value is a complementary
344346 * @return true if there are multiple variants of this type qualifier, false
345347 * otherwise
346348 */
347 public static boolean hasMultipleVariants(TypeQualifierValue tqv) {
349 public static boolean hasMultipleVariants(TypeQualifierValue<?> tqv) {
348350 int count = 0;
349 for (TypeQualifierValue t : instance.get().allKnownTypeQualifiers) {
351 for (TypeQualifierValue<?> t : instance.get().allKnownTypeQualifiers) {
350352 if (t.typeQualifier.equals(tqv.typeQualifier)) {
351353 count++;
352354 }
404406 public boolean equals(Object o) {
405407 if (!(o instanceof TypeQualifierValue))
406408 return false;
407 TypeQualifierValue other = (TypeQualifierValue) o;
409 TypeQualifierValue<?> other = (TypeQualifierValue<?>) o;
408410 return typeQualifier.equals(other.typeQualifier) && Util.nullSafeEquals(value, other.value);
409411 }
410412
411 /*
412 * (non-Javadoc)
413 *
414 * @see java.lang.Object#toString()
415 */
416413 @Override
417414 public String toString() {
418415 StringBuilder buf = new StringBuilder();
324324
325325 for (ValueNumber vn : interesting) {
326326 FlowValue value = getValue(vn);
327 if (value == FlowValue.TOP || !isStrict && value == FlowValue.UNKNOWN) continue;
327 if (value == FlowValue.TOP || /* !isStrict && */ value == FlowValue.UNKNOWN) continue;
328328 if (buf.length() > 1) {
329329 buf.append(", ");
330330 }
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.ba.jsr305;
20
21 import java.lang.annotation.Annotation;
22 import java.security.Permission;
23
24 import javax.annotation.CheckForNull;
25 import javax.annotation.meta.TypeQualifierValidator;
26 import javax.annotation.meta.When;
27
28 final class ValidationSecurityManager extends SecurityManager {
29
30
31 static final ValidationSecurityManager INSTANCE = new ValidationSecurityManager();
32
33
34
35 static {
36 if (TypeQualifierValue.DEBUG_CLASSLOADING)
37 new RuntimeException("Creating ValidationSecurityManager #").printStackTrace();
38
39 }
40 public static <A extends Annotation> When sandboxedValidation(A proxy, TypeQualifierValidator<A> v, @CheckForNull
41 Object constantValue) {
42 if (performingValidation.get())
43 throw new IllegalStateException("recursive validation");
44
45 try {
46 performingValidation.set(Boolean.TRUE);
47 if (TypeQualifierValue.DEBUG_CLASSLOADING)
48 System.out.println("Performing validation in thread " + Thread.currentThread().getName());
49 try {
50 When result = v.forConstantValue(proxy, constantValue);
51 if (!performingValidation.get())
52 throw new IllegalStateException("performingValidation not set when validation completes");
53 return result;
54 } catch (ClassCastException e) {
55 Class<? extends Annotation> c = proxy.getClass();
56 System.out.println(c.getName() + " extends " + c.getSuperclass().getName());
57 for(Class<?> i : c.getInterfaces())
58 System.out.println(" " + i.getName());
59 throw e;
60 }
61
62 } finally {
63 performingValidation.set(Boolean.FALSE);
64 if (TypeQualifierValue.DEBUG_CLASSLOADING)
65 System.out.println("Validation finished in thread " + Thread.currentThread().getName());
66
67 }
68 }
69
70
71 @Override
72 public void checkPermission(Permission perm) {
73 if (TypeQualifierValue.DEBUG_CLASSLOADING)
74 System.out.println("Checking for " + perm + " permission in thread " + Thread.currentThread().getName());
75 if (performingValidation.get() && inValidation()) {
76 SecurityException e = new SecurityException("No permissions granted while performing JSR-305 validation");
77 if (TypeQualifierValue.DEBUG_CLASSLOADING)
78 e.printStackTrace(System.out);
79 throw e;
80 }
81
82 }
83
84 @Override
85 public void checkPermission(Permission perm, Object context) {
86 if (TypeQualifierValue.DEBUG_CLASSLOADING)
87 System.out.println("Checking for " + perm + " permission with content in thread " + Thread.currentThread().getName());
88
89 if (performingValidation.get() && inValidation()) {
90 SecurityException e = new SecurityException("No permissions granted while performing JSR-305 validation");
91 if (TypeQualifierValue.DEBUG_CLASSLOADING)
92 e.printStackTrace(System.out);
93 throw e;
94 }
95 }
96
97 private ValidationSecurityManager() { }
98
99 private boolean inValidation() {
100 for (Class<?> c : getClassContext()) {
101 if (TypeQualifierValidator.class.isAssignableFrom(c)
102 || c.getClassLoader() == ValidatorClassLoader.INSTANCE)
103 return true;
104 }
105 return false;
106 }
107
108 private static final ThreadLocal<Boolean> performingValidation = new ThreadLocal<Boolean>() {
109 @Override
110 protected Boolean initialValue() {
111 return Boolean.FALSE;
112 }
113
114 };
115
116
117 }
1919 package edu.umd.cs.findbugs.ba.jsr305;
2020
2121 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
22 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
23 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
24 import edu.umd.cs.findbugs.classfile.Global;
25 import edu.umd.cs.findbugs.classfile.analysis.ClassData;
22 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
2623
2724 /**
2825 * @author pugh
2926 */
30 public class ValidatorClassLoader extends ClassLoader {
27 class ValidatorClassLoader extends ClassLoader {
28
29 static {
30 if (TypeQualifierValue.DEBUG_CLASSLOADING)
31 new RuntimeException("Initialising ValidatorClassLoader").printStackTrace();
32
33 }
34 final static ValidatorClassLoader INSTANCE = new ValidatorClassLoader();
3135
3236 ValidatorClassLoader() {
3337 super(ClassLoader.getSystemClassLoader().getParent());
38 if (TypeQualifierValue.DEBUG_CLASSLOADING)
39 new RuntimeException("Creating ValidatorClassLoader #").printStackTrace();
40 }
41
42 @Override
43 protected Class<?> loadClass(String name, boolean resolve)
44 throws ClassNotFoundException {
45
46 if (TypeQualifierValue.DEBUG_CLASSLOADING) {
47 if (resolve)
48 System.out.println("Loading and resolving class for " + name);
49 else System.out.println("Loading class for " + name);
50 }
51
52 return super.loadClass(name, resolve);
3453 }
3554 @Override
36 public Class<?> findClass(String name) throws ClassNotFoundException {
55 public Class<?> findClass(@DottedClassName String name) throws ClassNotFoundException {
56 if (TypeQualifierValue.DEBUG_CLASSLOADING)
57 System.out.println("Looking for class data for " + name);
58
3759 if (name.startsWith("javax.annotation"))
3860 return Class.forName(name);
39 byte[] b;
61
4062 try {
41 b = loadClassData(name);
42 return defineClass(name, b, 0, b.length);
63 byte[] b = TypeQualifierValue.loadClassData(name);
64 return findClass(name, b);
4365 } catch (CheckedAnalysisException e) {
44 // e.printStackTrace();
66 if (TypeQualifierValue.DEBUG_CLASSLOADING)
67 e.printStackTrace();
4568 return super.findClass(name);
4669 } catch (RuntimeException e) {
47 // e.printStackTrace();
70 if (TypeQualifierValue.DEBUG_CLASSLOADING)
71 e.printStackTrace();
72 throw e;
73 }
74 }
75
76
77 private Class<?> findClass(@DottedClassName String name, byte [] b) {
78 try {
79 if (TypeQualifierValue.DEBUG_CLASSLOADING)
80 System.out.println("Loading " + b.length + " bytes for class " + name);
81 Class<?> result = defineClass(name, b, 0, b.length);
82 super.resolveClass(result);
83 if (TypeQualifierValue.DEBUG_CLASSLOADING)
84 System.out.println("defined class " + name);
85 return result;
86 } catch (RuntimeException e) {
87 e.printStackTrace();
4888 throw e;
4989 }
5090
5191
5292 }
53
54 private byte[] loadClassData(String name) throws CheckedAnalysisException {
55 ClassDescriptor d = DescriptorFactory.createClassDescriptorFromDottedClassName(name);
56 ClassData data = Global.getAnalysisCache().getClassAnalysis(ClassData.class, d);
57 return data.getData();
58 }
93
94
5995
6096 }
0 /**
1 * Support for analyzing code containing JSR-305 type qualifier annotations.
2 *
3 * See the JSR-305 home page at <a href="http://code.google.com/p/jsr-305/">http://code.google.com/p/jsr-305/</a>.
4 */
5
6 @javax.annotation.ParametersAreNonnullByDefault
7 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
8 package edu.umd.cs.findbugs.ba.jsr305;
9
+0
-17
src/java/edu/umd/cs/findbugs/ba/jsr305/package.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <html>
2 <head>
3 </head>
4
5 <body bgcolor="white">
6 <p>
7 Support for analyzing code containing JSR-305 type qualifier annotations.
8 </p>
9
10 <p>
11 See the JSR-305 home page at
12 <a href="http://code.google.com/p/jsr-305/">http://code.google.com/p/jsr-305/</a>.
13 </p>
14 </body>
15
16 </html>
7171
7272 private IsNullConditionDecision decision;
7373
74 private boolean trackValueNumbers;
75
74 private final boolean trackValueNumbers;
75
7676 public boolean isTrackValueNumbers() {
7777 return trackValueNumbers;
7878 }
217217
218218 /*
219219 * (non-Javadoc)
220 *
220 *
221221 * @see edu.umd.cs.findbugs.ba.Frame#copyFrom(edu.umd.cs.findbugs.ba.Frame)
222222 */
223223 @Override
226226 decision = ((IsNullValueFrame) other).decision;
227227 if (trackValueNumbers) {
228228 knownValueMap = Util.makeSmallHashMap(((IsNullValueFrame) other).knownValueMap);
229 ;
230
231229 }
232230 }
233231
184184 IsNullValueFrame frame = getFrame();
185185 for (ValueNumber vn : nonnullParameters) {
186186 IsNullValue knownValue = frame.getKnownValue(vn);
187 if (knownValue != null && knownValue.mightBeNull()) {
187 if (knownValue != null && !knownValue.isDefinitelyNotNull()) {
188188 if (knownValue.isDefinitelyNull()) {
189189 frame.setTop();
190190 return;
193193 }
194194 for (int i = 0; i < vnaFrame.getNumSlots(); i++) {
195195 IsNullValue value = frame.getValue(i);
196 if (vnaFrame.getValue(i).equals(vn) && value.mightBeNull()) {
196 if (vnaFrame.getValue(i).equals(vn) && !value.isDefinitelyNotNull()) {
197197 frame.setValue(i, kaboom);
198198 if (value.isDefinitelyNull()) {
199199 frame.setTop();
3131 import edu.umd.cs.findbugs.ba.DefaultNullnessAnnotations;
3232 import edu.umd.cs.findbugs.ba.INullnessAnnotationDatabase;
3333 import edu.umd.cs.findbugs.ba.NullnessAnnotation;
34 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
3534 import edu.umd.cs.findbugs.ba.SignatureParser;
3635 import edu.umd.cs.findbugs.ba.XClass;
3736 import edu.umd.cs.findbugs.ba.XFactory;
111110 }
112111 }
113112
113 public @CheckForNull NullnessAnnotation getInheritedAnnotation(XMethod m, int parameter) {
114 Profiler profiler = Global.getAnalysisCache().getProfiler();
115 profiler.start(this.getClass());
116 try {
117 TypeQualifierAnnotation tqa
118 = TypeQualifierApplications.getInheritedTypeQualifierAnnotation(m,
119 parameter, nonnullTypeQualifierValue);
120 NullnessAnnotation result = toNullnessAnnotation(tqa);
121 return result;
122 } finally {
123 profiler.end(this.getClass());
124 }
125 }
126 public @CheckForNull NullnessAnnotation getInheritedAnnotation(XMethod m) {
127 Profiler profiler = Global.getAnalysisCache().getProfiler();
128 profiler.start(this.getClass());
129 try {
130 TypeQualifierAnnotation tqa
131 = TypeQualifierApplications.getInheritedTypeQualifierAnnotation(m, nonnullTypeQualifierValue);
132 NullnessAnnotation result = toNullnessAnnotation(tqa);
133 return result;
134 } finally {
135 profiler.end(this.getClass());
136 }
137 }
138 public @CheckForNull NullnessAnnotation getDirectAnnotation(Object o) {
139 Profiler profiler = Global.getAnalysisCache().getProfiler();
140 profiler.start(this.getClass());
141 try {
142
143 if (DEBUG) {
144 System.out.println("getDirectAnnotation: o=" + o + "...");
145 }
146
147 TypeQualifierAnnotation tqa = null;
148
149 if (o instanceof XMethodParameter) {
150 XMethodParameter param = (XMethodParameter) o;
151 tqa = TypeQualifierApplications.getDirectTypeQualifierAnnotation(param.getMethod(),
152 param.getParameterNumber(), nonnullTypeQualifierValue);
153 } else if (o instanceof XMethod || o instanceof XField) {
154 tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
155 nonnullTypeQualifierValue);
156 }
157
158 NullnessAnnotation result = toNullnessAnnotation(tqa);
159 if (DEBUG) {
160 if (result == null)
161 System.out.println(" ===> not found");
162 else
163 System.out.println(" ===> " + tqa + "/" + result.toString() );
164 }
165 return result;
166 } finally {
167 profiler.end(this.getClass());
168 }
169 }
170
171 public static boolean assertsFirstParameterIsNonnull(XMethod m) {
172 return (m.getName().equalsIgnoreCase("checkNonNull")
173 || m.getName().equalsIgnoreCase("checkNotNull")
174 // JDK 7 java.util.Objects.requireNonNull(Object)
175 || m.getName().equals("requireNonNull")
176 // org.eclipse.core.runtime.Assert(Object)
177 || m.getName().equalsIgnoreCase("isNotNull")
178 || m.getName().equalsIgnoreCase("assertNotNull"))
179 && m.getSignature().startsWith("(Ljava/lang/Object;");
180 }
181
114182 /*
115183 * (non-Javadoc)
116184 *
130198 String signature = m.getSignature();
131199 if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
132200 return true;
133 else if (NullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
201 else if (assertsFirstParameterIsNonnull(m))
134202 return true;
135203 else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
136204 return true;
399467 * Nonnull-based TypeQualifierAnnotation
400468 * @return corresponding NullnessAnnotation
401469 */
402 private NullnessAnnotation toNullnessAnnotation(@CheckForNull TypeQualifierAnnotation tqa) {
403 if (tqa == null) {
470 private @CheckForNull NullnessAnnotation toNullnessAnnotation(@CheckForNull TypeQualifierAnnotation tqa) {
471 if (tqa == null || tqa == TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION)
404472 return null;
405 }
406
473 if (tqa.when == null) {
474 new NullPointerException("TGA value with null when field").printStackTrace();
475 return null;
476 }
477
478
479
407480 switch (tqa.when) {
408481 case ALWAYS:
409482 return NullnessAnnotation.NONNULL;
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.npe;
23
2222 import java.util.Collection;
2323 import java.util.Collections;
2424 import java.util.HashMap;
25 import java.util.Iterator;
2526 import java.util.LinkedList;
2627 import java.util.Map;
28
29 import javax.annotation.WillClose;
2730
2831 import org.apache.bcel.Constants;
2932 import org.apache.bcel.generic.ARETURN;
4245 import edu.umd.cs.findbugs.ba.BasicBlock;
4346 import edu.umd.cs.findbugs.ba.Location;
4447 import edu.umd.cs.findbugs.ba.ObjectTypeFactory;
48 import edu.umd.cs.findbugs.ba.SignatureParser;
49 import edu.umd.cs.findbugs.ba.XFactory;
4550 import edu.umd.cs.findbugs.ba.XMethod;
4651 import edu.umd.cs.findbugs.ba.type.TypeDataflow;
4752 import edu.umd.cs.findbugs.ba.type.TypeFrame;
53 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
54 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
55 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
4856
4957 /**
5058 * A cache for looking up the collection of ObligationPolicyDatabaseActions
5159 * associated with a given InstructionHandle. Avoids the need for repeated
5260 * (slow) lookups.
53 *
61 *
5462 * @author David Hovemeyer
5563 */
5664 public class InstructionActionCache {
5967 private final ObligationPolicyDatabase database;
6068
6169 private final Map<InstructionHandle, Collection<ObligationPolicyDatabaseAction>> actionCache;
62
70
6371 private final XMethod xmethod;
6472 private final TypeDataflow typeDataflow;
6573 private final ConstantPoolGen cpg;
66
74
6775
6876
6977 public InstructionActionCache(ObligationPolicyDatabase database, XMethod xmethod, ConstantPoolGen cpg, TypeDataflow typeDataflow) {
7482 this.typeDataflow = typeDataflow;
7583 }
7684
85 static final ClassDescriptor WILL_CLOSE = DescriptorFactory.createClassDescriptor(WillClose.class);
7786 public Collection<ObligationPolicyDatabaseAction> getActions(BasicBlock block, InstructionHandle handle) {
7887 Collection<ObligationPolicyDatabaseAction> actionList = actionCache.get(handle);
7988 if (actionList == null) {
8291 if (ins instanceof InvokeInstruction) {
8392
8493 InvokeInstruction inv = (InvokeInstruction) ins;
85 String signature = inv.getSignature(cpg);
86 String methodName = inv.getName(cpg);
94 XMethod invokedMethod = XFactory.createXMethod(inv, cpg);
95 String signature = invokedMethod.getSignature();
96 String methodName = invokedMethod.getName();
97
8798 if (DEBUG_LOOKUP) {
88 System.out.println("Looking up actions for call to " + methodName +signature);
99 System.out.println("Looking up actions for call to " + invokedMethod);
89100 }
90
91 if (signature.indexOf(';') >= -1) {
101
102
103 if (invokedMethod.getAnnotationDescriptors().contains(WILL_CLOSE) && methodName.startsWith("close") && signature.endsWith(")V")) {
104 actionList = Collections.singletonList(ObligationPolicyDatabaseAction.CLEAR);
105 } else if (signature.indexOf(';') >= -1) {
106 ReferenceType receiverType = inv.getReferenceType(cpg);
107
108 boolean isStatic = inv.getOpcode() == Constants.INVOKESTATIC;
92109 actionList = new LinkedList<ObligationPolicyDatabaseAction>();
93110
94 if (signature.substring(0, signature.indexOf(')')).indexOf("Ljava/io/Closeable;") >= 0 || false && methodName.startsWith("close")) {
95 actionList.add(ObligationPolicyDatabaseAction.CLEAR);
96 } else {
97
98 ReferenceType receiverType = inv.getReferenceType(cpg);
99
100 boolean isStatic = inv.getOpcode() == Constants.INVOKESTATIC;
101
102 database.getActions(receiverType, methodName, signature, isStatic, actionList);
103 if (actionList.isEmpty()) {
104 actionList = Collections.emptyList();
111 database.getActions(receiverType, methodName, signature, isStatic, actionList);
112
113 if (actionList.isEmpty()) {
114
115 try {
116 TypeFrame factAtLocation = null;
117 SignatureParser sigParser = new SignatureParser(signature);
118 // int startIndex = 0;
119 // if (!xmethod.isStatic())
120 // startIndex = 1;
121 Iterator<String> signatureIterator = sigParser.parameterSignatureIterator();
122 int parameters = sigParser.getNumParameters();
123 for (int i = 0; i < parameters; i++) {
124 String sig = signatureIterator.next();
125 Collection<ClassDescriptor> annotations = invokedMethod.getParameterAnnotationDescriptors(i);
126 if (annotations.contains(WILL_CLOSE) || sig.equals("Ljava/io/Closeable;") || methodName.startsWith("close")) {
127 // closing this value
128 if (factAtLocation == null)
129 factAtLocation = typeDataflow.getFactAtLocation( new Location(handle, block));
130
131 Type argumentType = factAtLocation.getArgument(inv, cpg, i, sigParser);
132 if (argumentType instanceof ObjectType) {
133 Obligation obligation = database.getFactory().getObligationByType((ObjectType) argumentType);
134 if (obligation != null)
135 actionList.add(new ObligationPolicyDatabaseAction(ObligationPolicyDatabaseActionType.DEL, obligation));
136
137 }
138
139 }
105140 }
141
142 } catch (CheckedAnalysisException e) {
143 AnalysisContext.logError("Error checking " + invokedMethod, e);
144 } catch (ClassNotFoundException e) {
145 AnalysisContext.reportMissingClass(e);
146 } finally { }
147
148
106149 }
107
108150 if (DEBUG_LOOKUP && !actionList.isEmpty()) {
109151 System.out.println(" At " + handle + ": " + actionList);
110152 }
124166 Obligation sObligation = factory.getObligationByType(sType);
125167 actionList = Arrays.asList(
126168 new ObligationPolicyDatabaseAction(ObligationPolicyDatabaseActionType.DEL, obligation),
127 new ObligationPolicyDatabaseAction(ObligationPolicyDatabaseActionType.DEL, sObligation));
128 } else
169 new ObligationPolicyDatabaseAction(ObligationPolicyDatabaseActionType.DEL, sObligation));
170 } else
129171 actionList = Collections.singleton(new ObligationPolicyDatabaseAction(ObligationPolicyDatabaseActionType.DEL,
130172 obligation));
131
173
132174 }
133175 }
134176 }
139181 }
140182
141183 }
142
184
143185 actionCache.put(handle, actionList);
144186 }
145187
2929 import org.apache.bcel.generic.ObjectType;
3030 import org.apache.bcel.generic.Type;
3131
32 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3333 import edu.umd.cs.findbugs.ba.Hierarchy;
3434 import edu.umd.cs.findbugs.ba.XMethod;
3535 import edu.umd.cs.findbugs.bcel.BCELUtil;
4949 // // XXX: this is just for debugging.
5050 // static ObligationFactory lastInstance;
5151
52 @SuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
52 @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
5353 public ObligationFactory() {
5454 this.classNameToObligationMap = new HashMap<String, Obligation>();
5555 // lastInstance = this;
122122 * a ClassDescriptor naming a class type
123123 * @return an Obligation that is a supertype of the given type, or null if
124124 * there is no such Obligation
125 * @throws ClassNotFoundException
126125 */
127126 public @CheckForNull
128127 Obligation getObligationByType(ClassDescriptor classDescriptor) {
190190 if (stateMap.isEmpty()) {
191191 State s = new State(factory);
192192 s.getObligationSet().add(obligation);
193 updatedStateMap.put(s.getObligationSet(), s);
193 updatedStateMap.put(s.getObligationSet(), s);
194194 } else for (State state : stateMap.values()) {
195195 checkCircularity(state, obligation, basicBlockId);
196196 state.getObligationSet().add(obligation);
208208 * @param basicBlockId
209209 * the id of the basic block (path component) removing the
210210 * obligation
211 * @throws NonexistentObligationException
211 * @throws ObligationAcquiredOrReleasedInLoopException
212212 */
213213 public void deleteObligation(final Obligation obligation, int basicBlockId)
214214 throws ObligationAcquiredOrReleasedInLoopException {
275275 if (o == null || o.getClass() != this.getClass())
276276 return false;
277277 StateSet other = (StateSet) o;
278 return this.isTop == other.isTop && this.isBottom == other.isBottom
278 return this.isTop == other.isTop && this.isBottom == other.isBottom
279279 && this.onExceptionPath == other.onExceptionPath && this.stateMap.equals(other.stateMap);
280280 }
281281
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.obl;
23
00 @javax.annotation.ParametersAreNonnullByDefault
1 package edu.umd.cs.findbugs.ba;
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
2 package edu.umd.cs.findbugs.ba;
3
3737 * exceptions are explicitly declared, thrown, or caught. Implicit exceptions
3838 * are runtime faults (NPE, array out of bounds) not explicitly handled by the
3939 * user code.
40 *
40 *
4141 * @author David Hovemeyer
4242 * @see TypeAnalysis
4343 */
4444 public class ExceptionSet implements Serializable {
4545 private static final long serialVersionUID = 1;
4646
47 private ExceptionSetFactory factory;
48
49 private BitSet exceptionSet;
50
51 private BitSet explicitSet;
47 private final ExceptionSetFactory factory;
48
49 private final BitSet exceptionSet;
50
51 private final BitSet explicitSet;
5252
5353 private int size;
5454
198198 /**
199199 * Checks to see if the exception set is a singleton set containing just the
200200 * named exception
201 *
201 *
202202 * @param exceptionName
203203 * (in dotted format)
204204 * @return true if it is
213213
214214 /**
215215 * Add an explicit exception.
216 *
216 *
217217 * @param type
218218 * type of the exception
219219 */
223223
224224 /**
225225 * Add an implicit exception.
226 *
226 *
227227 * @param type
228228 * type of the exception
229229 */
233233
234234 /**
235235 * Add an exception.
236 *
236 *
237237 * @param type
238238 * the exception type
239239 * @param explicit
253253
254254 /**
255255 * Add all exceptions in the given set.
256 *
256 *
257257 * @param other
258258 * the set
259259 */
3838 * A TypeMerger which applies standard Java semantics when merging Types.
3939 * Subclasses may override mergeReferenceTypes() in order to implement special
4040 * typing rules for reference types.
41 *
41 *
4242 * @author David Hovemeyer
4343 * @see TypeMerger
4444 */
4545 public class StandardTypeMerger implements TypeMerger, Constants, ExtendedTypes {
46 private RepositoryLookupFailureCallback lookupFailureCallback;
47
48 private ExceptionSetFactory exceptionSetFactory;
46 private final RepositoryLookupFailureCallback lookupFailureCallback;
47
48 private final ExceptionSetFactory exceptionSetFactory;
4949
5050 private static final ObjectType OBJECT_TYPE = ObjectTypeFactory.getInstance("java.lang.Object");
5151
5252 /**
5353 * Constructor.
54 *
54 *
5555 * @param lookupFailureCallback
5656 * object used to report Repository lookup failures
5757 * @param exceptionSetFactory
6363 }
6464
6565 public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
66 if (a == null) return b;
67 if (b == null) return a;
6668 byte aType = a.getType(), bType = b.getType();
6769
6870 if (aType == T_TOP) // Top is the identity element
141143 * Default implementation of merging reference types. This just returns the
142144 * first common superclass, which is compliant with the JVM Spec. Subclasses
143145 * may override this method in order to implement extended type rules.
144 *
146 *
145147 * @param aRef
146148 * a ReferenceType
147149 * @param bRef
158160 // We want to preserve the ExceptionSets associated,
159161 // in order to track the exact set of exceptions
160162 if (isObjectType(aType) && isObjectType(bType)
161 && (aType == T_EXCEPTION || bType == T_EXCEPTION || isThrowable(aRef) && isThrowable(bRef))) {
163 && ((aType == T_EXCEPTION || isThrowable(aRef)) && (bType == T_EXCEPTION || isThrowable(bRef)))) {
162164 ExceptionSet union = exceptionSetFactory.createExceptionSet();
163165 if (aType == T_OBJECT && aRef.getSignature().equals("Ljava/lang/Throwable;"))
164166 return aRef;
219221 * ClassNotFoundException
220222 */{
221223 try {
222
224
223225 Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
224226 return subtypes2.isSubtype(ref, Type.THROWABLE);
225
227
226228 } catch (ClassNotFoundException e) {
227229 // We'll just assume that it's not an exception type.
228230 lookupFailureCallback.reportMissingClass(e);
210210 if (code == null)
211211 throw new IllegalArgumentException(method.getName() + " has no code");
212212 for (Attribute a : code.getAttributes()) {
213 if (a instanceof LocalVariableTypeTable)
213 if (a instanceof LocalVariableTypeTable)
214214 visitor.setLocalTypeTable((LocalVariableTypeTable) a);
215215 }
216216 this.methodGen = methodGen;
810810 * the basic block
811811 * @return the set of exceptions that can be thrown by the block
812812 */
813 private ExceptionSet computeThrownExceptionTypes(BasicBlock basicBlock) throws
813 private ExceptionSet computeThrownExceptionTypes(BasicBlock basicBlock) throws
814814 DataflowAnalysisException {
815815
816816 ExceptionSet exceptionTypeSet = exceptionSetFactory.createExceptionSet();
2424 import java.util.List;
2525 import java.util.Map;
2626 import java.util.Set;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
2729
2830 import javax.annotation.CheckForNull;
2931
701703 pushValue(result);
702704 }
703705
706 public static final Pattern mapSignaturePattern = Pattern.compile("<(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*):L[^;]*;(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*):L[^;]*;>.*Ljava/util/(\\p{javaJavaIdentifierStart}(\\p{javaJavaIdentifierPart}|/)*)?Map<T\\1;T\\2;>;.*");
704707 public static boolean isStraightGenericMap(ClassDescriptor c) {
705708 if (c.matches(Map.class))
706709 return true;
713716 String sourceSignature = xc.getSourceSignature();
714717 if (sourceSignature == null)
715718 return false;
716 if (sourceSignature.startsWith("<") && !sourceSignature.contains("Map<TK;TV;>")) {
717 if (SystemProperties.ASSERTIONS_ENABLED)
718 AnalysisContext.logError("QQQ: " + c + " has signature " + sourceSignature);
719 return false;
720 }
719 if (sourceSignature.startsWith("<")) {
720 Matcher matcher = mapSignaturePattern.matcher(sourceSignature);
721 if (!matcher.matches()) {
722 if (DEBUG) {
723 System.out.println(c + " has a complex generic signature: " + sourceSignature);
724 }
725 // See Bug3470297 and Bug3470297a examples
726 return false;
727 }
728 }
729
721730 return true;
722731 }
723732
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.type;
23
3737 import edu.umd.cs.findbugs.ba.FrameDataflowAnalysis;
3838 import edu.umd.cs.findbugs.ba.Location;
3939 import edu.umd.cs.findbugs.ba.RepositoryLookupFailureCallback;
40 import edu.umd.cs.findbugs.ba.SignatureParser;
4041 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
4142
4243 /**
153154 * @return the ValueNumber assigned to that parameter
154155 */
155156 public ValueNumber getEntryValueForParameter(int param) {
156 return getEntryValue(methodGen.isStatic() ? param : param + 1);
157
158 SignatureParser sigParser = new SignatureParser(methodGen.getSignature());
159 int p = 0;
160 int slotOffset = methodGen.isStatic() ? 0 : 1;
161
162 for ( String paramSig : sigParser.parameterSignatures()) {
163 if (p == param)
164 return getEntryValue(slotOffset);
165 param++;
166 slotOffset += SignatureParser.getNumSlotsForType(paramSig);
167 }
168
169 throw new IllegalStateException();
157170 }
158171
159172 public ValueNumberFrame createFact() {
2424 import org.apache.bcel.generic.InstructionHandle;
2525
2626 import edu.umd.cs.findbugs.SystemProperties;
27 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2828
2929 /**
3030 * A cache mapping instructions and input values to the output values they
4848
4949 private int cachedHashCode;
5050
51 @SuppressWarnings("EI2")
51 @SuppressFBWarnings("EI2")
5252 public Entry(InstructionHandle handle, ValueNumber[] inputValueList) {
5353 this.handle = handle;
5454 this.inputValueList = inputValueList;
00 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
12 package edu.umd.cs.findbugs.ba.vna;
23
1919 package edu.umd.cs.findbugs.bcel;
2020
2121 import org.apache.bcel.Constants;
22 import org.apache.bcel.classfile.Attribute;
23 import org.apache.bcel.classfile.FieldOrMethod;
2224 import org.apache.bcel.classfile.JavaClass;
2325 import org.apache.bcel.classfile.Method;
26 import org.apache.bcel.classfile.Synthetic;
2427 import org.apache.bcel.generic.ConstantPoolGen;
28 import org.apache.bcel.generic.FieldGenOrMethodGen;
2529 import org.apache.bcel.generic.FieldInstruction;
2630 import org.apache.bcel.generic.InvokeInstruction;
2731 import org.apache.bcel.generic.ObjectType;
153157 public static ObjectType getObjectTypeInstance(Class<?> clazz) {
154158 return getObjectTypeInstance(clazz.getName());
155159 }
160
161 public static boolean isSynthetic(FieldOrMethod m) {
162 if (m.isSynthetic())
163 return true;
164
165 for(Attribute a : m.getAttributes())
166 if (a instanceof Synthetic)
167 return true;
168 return false;
169 }
170 public static boolean isSynthetic(JavaClass j) {
171 if (j.isSynthetic())
172 return true;
173
174 for(Attribute a : j.getAttributes())
175 if (a instanceof Synthetic)
176 return true;
177 return false;
178 }
179 public static boolean isSynthetic(FieldGenOrMethodGen m) {
180 if (m.isSynthetic())
181 return true;
182 for(Attribute a : m.getAttributes())
183 if (a instanceof Synthetic)
184 return true;
185 return false;
186 }
156187 }
3535 private final boolean isUsingCustomUserValue;
3636
3737 public OpcodeStackDetector() {
38 super();
38 super();
3939 isUsingCustomUserValue = getClass().isAnnotationPresent(OpcodeStack.CustomUserValue.class);
4040 }
4141
6565 @Override
6666 public boolean beforeOpcode(int seen) {
6767 stack.precomputation(this);
68 stack.mergeJumps(this);
6968 return !stack.isTop();
7069 }
7170
7877 abstract public void sawOpcode(int seen);
7978
8079 /**
81 * @return true if this detector is annotated with {@link OpcodeStack.CustomUserValue}
80 * @return true if this detector is annotated with {@link edu.umd.cs.findbugs.OpcodeStack.CustomUserValue}
8281 * and thus should not reuse generic OpcodeStack information
8382 * from an iterative evaluation of the opcode stack. Such detectors
8483 * will not use iterative opcode stack evaluation.
0 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
2 package edu.umd.cs.findbugs.bcel.generic;
3
0 @javax.annotation.ParametersAreNonnullByDefault
1 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
2 package edu.umd.cs.findbugs.bcel;
3
1919 package edu.umd.cs.findbugs.classfile;
2020
2121 import java.util.Collection;
22 import java.util.Collections;
2322 import java.util.HashMap;
2423 import java.util.Map;
2524
2525 * @author David Hovemeyer
2626 */
2727 public interface ICodeBase {
28 /** Codebase was explicitly specified. */
29 public static final int SPECIFIED = 0;
28
29 enum Discovered {
3030
31 /** Codebase was discovered as a nested archive in another codebase. */
32 public static final int NESTED = 1;
31 /** Codebase was explicitly specified. */
32 SPECIFIED,
3333
34 /**
35 * Codebase was referenced in the Class-Path attribute of a Jar manifest of
36 * another codebase.
37 */
38 public static final int IN_JAR_MANIFEST = 2;
34 /** Codebase was discovered as a nested archive in another codebase. */
35 NESTED,
3936
40 /** Codebase was discovered in the system classpath. */
41 public static final int IN_SYSTEM_CLASSPATH = 3;
37 /**
38 * Codebase was referenced in the Class-Path attribute of a Jar manifest
39 * of another codebase.
40 */
41 IN_JAR_MANIFEST,
4242
43 /** Codebase was discovered in the system classpath. */
44 IN_SYSTEM_CLASSPATH,
45 }
4346 /**
4447 * Get the codebase locator describing the location of this codebase.
4548 *
7982 * one of the constants SPECIFIED, NESTED, IN_JAR_MANIFEST, or
8083 * IN_SYSTEM_CLASSPATH
8184 */
82 public void setHowDiscovered(int howDiscovered);
85 public void setHowDiscovered(ICodeBase.Discovered howDiscovered);
8386
8487 /**
8588 * Return how this codebase was discovered.
8790 * @return one of the constants SPECIFIED, NESTED, IN_JAR_MANIFEST, or
8891 * IN_SYSTEM_CLASSPATH
8992 */
90 public int getHowDiscovered();
93 public ICodeBase.Discovered getHowDiscovered();
9194
9295 /**
9396 * Return whether or not this code base contains any source files.
6565 * the class data to be loaded in order to determine the class.
6666 *
6767 * @return ClassDescriptor of this entry
68 * @throws CheckedAnalysisException
68 * @throws ResourceNotFoundException, InvalidClassFileFormatException
6969 * if the codebase entry does not reference a valid classfile
7070 * @throws IllegalArgumentException
7171 * if the codebase entry's filename is definitely not a
108108 MethodInfo method = e.getKey();
109109 String signature = e.getValue();
110110 for (MethodInfo m : methodInfoList)
111 if (m.getName().equals(m.getName()) && m.getSignature().equals(signature)) {
111 if (m.getName().equals(method.getName()) && m.getSignature().equals(signature)) {
112112 context.setBridgeMethod(method, m);
113113
114114 }
136136 }
137137 }
138138
139 /**
140 * Constructor.
141 *
142 * @param classDescriptor
143 * ClassDescriptor representing the class name
144 * @param superclassDescriptor
145 * ClassDescriptor representing the superclass name
146 * @param interfaceDescriptorList
147 * ClassDescriptors representing implemented interface names
148 * @param codeBaseEntry
149 * codebase entry class was loaded from
150 * @param accessFlags
151 * class's access flags
152 * @param usesConcurrency
153 * TODO
154 */
139
155140 ClassNameAndSuperclassInfo(ClassDescriptor classDescriptor, ClassDescriptor superclassDescriptor,
156141 ClassDescriptor[] interfaceDescriptorList, ICodeBaseEntry codeBaseEntry, int accessFlags,
157142 /* TODO: We aren't doing anything with this */
9191
9292 final boolean isResolved;
9393
94 /**
95 * @param className
96 * @param fieldName
97 * @param fieldSignature
98 * @param isStatic
99 * @param accessFlags
100 * @param fieldAnnotations
101 * @param isResolved
102 */
94
10395 private FieldInfo(@SlashedClassName String className, String fieldName, String fieldSignature,
10496 @CheckForNull String fieldSourceSignature, int accessFlags, Map<ClassDescriptor, AnnotationValue> fieldAnnotations,
10597 boolean isResolved) {
224224
225225 Map<Integer, Map<ClassDescriptor, AnnotationValue>> methodParameterAnnotations;
226226
227 static IdentityHashMap<MethodInfo, Void> unconditionalThrowers = new IdentityHashMap<MethodInfo, Void>();
228
229 static IdentityHashMap<MethodInfo, Void> unsupportedMethods = new IdentityHashMap<MethodInfo, Void>();
230
231 static IdentityHashMap<MethodInfo, MethodDescriptor> accessMethodForMethod = new IdentityHashMap<MethodInfo, MethodDescriptor>();
232 static IdentityHashMap<MethodInfo, FieldDescriptor> accessMethodForField = new IdentityHashMap<MethodInfo, FieldDescriptor>();
233 static IdentityHashMap<MethodInfo, Void> identifyMethods = new IdentityHashMap<MethodInfo, Void>();
234
235 public static void clearCaches() {
236 unsupportedMethods = new IdentityHashMap<MethodInfo, Void>();
237 unconditionalThrowers = new IdentityHashMap<MethodInfo, Void>();
238 accessMethodForMethod = new IdentityHashMap<MethodInfo, MethodDescriptor>();
239 accessMethodForField = new IdentityHashMap<MethodInfo, FieldDescriptor>();
240 identifyMethods = new IdentityHashMap<MethodInfo, Void>();
241 }
242
227 public static class MethodInfoDatabase {
228 final IdentityHashMap<MethodInfo, Void> unconditionalThrowers = new IdentityHashMap<MethodInfo, Void>();
229 final IdentityHashMap<MethodInfo, Void> unsupportedMethods = new IdentityHashMap<MethodInfo, Void>();
230 final IdentityHashMap<MethodInfo, MethodDescriptor> accessMethodForMethod = new IdentityHashMap<MethodInfo, MethodDescriptor>();
231 final IdentityHashMap<MethodInfo, FieldDescriptor> accessMethodForField = new IdentityHashMap<MethodInfo, FieldDescriptor>();
232 final IdentityHashMap<MethodInfo, Void> identityMethods = new IdentityHashMap<MethodInfo, Void>();
233
234 }
235
236 /**
237 * @return Returns the database.
238 */
239 static MethodInfoDatabase getDatabase() {
240 return Global.getAnalysisCache().getDatabase(MethodInfoDatabase.class);
241 }
242 static IdentityHashMap<MethodInfo, Void> getUnconditionalthrowers() {
243 return getDatabase().unconditionalThrowers;
244 }
245
246 static IdentityHashMap<MethodInfo, Void> getUnsupportedmethods() {
247 return getDatabase().unsupportedMethods;
248 }
249
250 static IdentityHashMap<MethodInfo, MethodDescriptor> getAccessmethodformethod() {
251 return getDatabase().accessMethodForMethod;
252 }
253
254 static IdentityHashMap<MethodInfo, FieldDescriptor> getAccessmethodforfield() {
255 return getDatabase().accessMethodForField;
256 }
257
258 static IdentityHashMap<MethodInfo, Void> getIdentitymethods() {
259 return getDatabase().identityMethods;
260 }
243261
244262 MethodInfo(@SlashedClassName String className, String methodName, String methodSignature, String methodSourceSignature,
245263 int accessFlags, boolean isUnconditionalThrower, boolean isUnsupported, boolean usesConcurrency,
258276 this.methodAnnotations = Util.immutableMap(methodAnnotations);
259277 this.methodParameterAnnotations = Util.immutableMap(methodParameterAnnotations);
260278 if (isUnconditionalThrower)
261 unconditionalThrowers.put(this, null);
279 getUnconditionalthrowers().put(this, null);
262280 if (isUnsupported)
263 unsupportedMethods.put(this, null);
281 getUnconditionalthrowers().put(this, null);
264282 if (accessMethodForMethod != null)
265 MethodInfo.accessMethodForMethod.put(this, accessMethodForMethod);
283 getAccessmethodformethod().put(this, accessMethodForMethod);
266284 if (accessMethodForField!= null)
267 MethodInfo.accessMethodForField.put(this, accessMethodForField);
285 getAccessmethodforfield().put(this, accessMethodForField);
268286 if (isIdentity) {
269 MethodInfo.identifyMethods.put(this, null);
287 getIdentitymethods().put(this, null);
270288 }
271289
272290 this.usesConcurrency = usesConcurrency;
281299 return exceptions;
282300 }
283301
302
303
284304 public boolean isUnconditionalThrower() {
285 return unconditionalThrowers.containsKey(this);
305 return getUnconditionalthrowers().containsKey(this);
286306 }
287307
288308 public boolean isIdentity() {
289 return MethodInfo.identifyMethods.containsKey(this);
309 return getIdentitymethods().containsKey(this);
290310 }
291311
292312 public boolean isUnsupported() {
293 return unsupportedMethods.containsKey(this);
313 return getUnsupportedmethods().containsKey(this);
294314 }
295315
296316 public int getNumParams() {
434454 return map.keySet();
435455 }
436456
457 public boolean hasParameterAnnotations() {
458 return !methodParameterAnnotations.isEmpty();
459 }
460
437461 public @Nullable
438462 AnnotationValue getParameterAnnotation(int param, ClassDescriptor desc) {
439463 Map<ClassDescriptor, AnnotationValue> map = methodParameterAnnotations.get(param);
552576
553577 public @CheckForNull
554578 MethodDescriptor getAccessMethodForMethod() {
555 return accessMethodForMethod.get(this);
579 return getAccessmethodformethod().get(this);
556580 }
557581 public @CheckForNull
558582 FieldDescriptor getAccessMethodForField() {
559 return accessMethodForField.get(this);
583 return getAccessmethodforfield().get(this);
560584 }
561585
562586 /*
66 * which represents symbolic information parsed from the class data.
77 */
88 @javax.annotation.ParametersAreNonnullByDefault
9 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
910 package edu.umd.cs.findbugs.classfile.analysis;
4545 * /docs/books/vmspec/2nd-edition/html/ClassFile.doc.html">
4646 * http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html
4747 * </a>
48 *
48 *
4949 * @author David Hovemeyer
5050 */
5151 public class ClassParser implements ClassParserInterface {
6161 }
6262 }
6363
64 private DataInputStream in;
65
66 private ClassDescriptor expectedClassDescriptor;
67
68 private ICodeBaseEntry codeBaseEntry;
64 private final DataInputStream in;
65
66 private final ClassDescriptor expectedClassDescriptor;
67
68 private final ICodeBaseEntry codeBaseEntry;
6969
7070 private Constant[] constantPool;
7171
7373
7474 /**
7575 * Constructor.
76 *
76 *
7777 * @param in
7878 * the DataInputStream to read class data from
7979 * @param expectedClassDescriptor
8989
9090 /*
9191 * (non-Javadoc)
92 *
92 *
9393 * @see
9494 * edu.umd.cs.findbugs.classfile.engine.ClassParserInterface#parse(edu.umd
9595 * .cs.findbugs.classfile.analysis.ClassNameAndSuperclassInfo.Builder)
154154
155155 /*
156156 * (non-Javadoc)
157 *
157 *
158158 * @see
159159 * edu.umd.cs.findbugs.classfile.engine.ClassParserInterface#parse(edu.umd
160160 * .cs.findbugs.classfile.analysis.ClassInfo.Builder)
165165
166166 /**
167167 * Extract references to other classes.
168 *
168 *
169169 * @return array of ClassDescriptors of referenced classes
170170 * @throws InvalidClassFileFormatException
171171 */
226226 // L: long
227227 // D: double
228228 // i: 2-byte constant pool index
229 private static final String[] CONSTANT_FORMAT_MAP = { null, "8", // 1:
230 // CONSTANT_Utf8
231 null, "I", // 3: CONSTANT_Integer
229 private static final String[] CONSTANT_FORMAT_MAP = { null,
230 "8", // 1:CONSTANT_Utf8
231 null, // 2:
232 "I", // 3: CONSTANT_Integer
232233 "F", // 4: CONSTANT_Float
233234 "L", // 5: CONSTANT_Long
234235 "D", // 6: CONSTANT_Double
238239 "ii", // 10: CONSTANT_Methodref
239240 "ii", // 11: CONSTANT_InterfaceMethodref
240241 "ii", // 12: CONSTANT_NameAndType
242 null, // 13:
243 null, // 14:
244 "bi", // 15: CONSTANT_MethodHandle
245 "i", // 16: CONSTANT_MethodType
246 null, // 17:
247 "ii", // 18: CONSTANT_InvokeDynamic
248
241249 };
242250
243251 /**
244 * Read a constant from the constant pool.
245 *
246 * @return a Constant
252 * Read a constant from the constant pool. Return null for
253 *
254 * @return a StaticConstant
247255 * @throws InvalidClassFileFormatException
248256 * @throws IOException
249257 */
250258 private Constant readConstant() throws InvalidClassFileFormatException, IOException {
251259 int tag = in.readUnsignedByte();
252 if (tag < 0 || tag >= CONSTANT_FORMAT_MAP.length || CONSTANT_FORMAT_MAP[tag] == null) {
260 if (tag < 0 || tag >= CONSTANT_FORMAT_MAP.length) {
253261 throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry);
254262 }
255263 String format = CONSTANT_FORMAT_MAP[tag];
264 if (format == null) {
265 throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry);
266 }
267
256268 Object[] data = new Object[format.length()];
257269 for (int i = 0; i < format.length(); i++) {
258270 char spec = format.charAt(i);
275287 case 'i':
276288 data[i] = in.readUnsignedShort();
277289 break;
290 case 'b':
291 data[i] = in.readUnsignedByte();
292 break;
278293 default:
279294 throw new IllegalStateException();
280295 }
286301 /**
287302 * Get a class name from a CONSTANT_Class. Note that this may be an array
288303 * (e.g., "[Ljava/lang/String;").
289 *
304 *
290305 * @param index
291306 * index of the constant
292307 * @return the class name
310325
311326 /**
312327 * Get the ClassDescriptor of a class referenced in the constant pool.
313 *
328 *
314329 * @param index
315330 * index of the referenced class in the constant pool
316331 * @return the ClassDescriptor of the referenced class
324339
325340 /**
326341 * Get the UTF-8 string constant at given constant pool index.
327 *
342 *
328343 * @param refIndex
329344 * the constant pool index
330345 * @return the String at that index
339354
340355 /**
341356 * Check that a constant pool index is valid.
342 *
357 *
343358 * @param expectedClassDescriptor
344359 * class descriptor
345360 * @param constantPool
357372
358373 /**
359374 * Check that a constant has the expected tag.
360 *
375 *
361376 * @param constant
362377 * the constant to check
363378 * @param expectedTag
377392
378393 /**
379394 * Read field_info, return FieldDescriptor.
380 *
395 *
381396 * @param thisClassDescriptor
382397 * the ClassDescriptor of this class (being parsed)
383398 * @return the FieldDescriptor
388403 return readFieldOrMethod(thisClassDescriptor, new FieldOrMethodDescriptorCreator<FieldDescriptor>() {
389404 /*
390405 * (non-Javadoc)
391 *
406 *
392407 * @see edu.umd.cs.findbugs.classfile.engine.ClassParser.
393408 * FieldOrMethodDescriptorCreator#create(java.lang.String,
394409 * java.lang.String, java.lang.String, int)
402417
403418 /**
404419 * Read method_info, read method descriptor.
405 *
420 *
406421 * @param thisClassDescriptor
407422 * @return
408423 * @throws IOException
412427 return readFieldOrMethod(thisClassDescriptor, new FieldOrMethodDescriptorCreator<MethodDescriptor>() {
413428 /*
414429 * (non-Javadoc)
415 *
430 *
416431 * @see edu.umd.cs.findbugs.classfile.engine.ClassParser.
417432 * FieldOrMethodDescriptorCreator#create(java.lang.String,
418433 * java.lang.String, java.lang.String, int)
426441
427442 /**
428443 * Read field_info or method_info. They have the same format.
429 *
444 *
430445 * @param <E>
431446 * descriptor type to return
432447 * @param thisClassDescriptor
458473
459474 /**
460475 * Read an attribute.
461 *
476 *
462477 * @throws IOException
463478 * @throws InvalidClassFileFormatException
464479 */
480495
481496 /**
482497 * Read an InnerClasses attribute.
483 *
498 *
484499 * @param attribute_length
485500 * length of attribute (excluding first 6 bytes)
486501 * @throws InvalidClassFileFormatException
507522
508523 /**
509524 * Get the signature from a CONSTANT_NameAndType.
510 *
525 *
511526 * @param index
512527 * the index of the CONSTANT_NameAndType
513528 * @return the signature
310310 boolean match = false;
311311 if (parameterLoadState == ParameterLoadState.OTHER && !isStatic() && var == 0) {
312312 parameterLoadState = ParameterLoadState.LOADED_THIS;
313 ;
313
314314 match = true;
315315 }
316316 else if (parameterLoadState == ParameterLoadState.LOADED_THIS && var > 0){
411411
412412 }
413413
414 @Override
415 public void visitJumpInsn(int opcode, Label label) {
414 private void sawBranchTo(Label label) {
416415 sawBranch = true;
417416 if (labelsSeen.contains(label))
418417 sawBackBranch = true;
418 }
419
420 @Override
421 public void visitJumpInsn(int opcode, Label label) {
422 sawBranchTo(label);
419423 identityState = IdentityMethodState.NOT;
420424 super.visitJumpInsn(opcode, label);
421
422 }
425 }
426
427 @Override
428 public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
429 sawBranchTo(dflt);
430 for (Label lbl : labels)
431 sawBranchTo(lbl);
432 identityState = IdentityMethodState.NOT;
433 super.visitLookupSwitchInsn(dflt, keys, labels);
434 }
435
436 @Override
437 public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
438 sawBranchTo(dflt);
439 for (Label lbl : labels)
440 sawBranchTo(lbl);
441 identityState = IdentityMethodState.NOT;
442 super.visitTableSwitchInsn(min, max, dflt, labels);
443 }
444
423445 @Override
424446 public void visitLabel(Label label) {
425447 labelsSeen.add(label);
8888 AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportSkippedAnalysis(descriptor);
8989 throw new MethodUnprofitableException(javaClassAndMethod);
9090 }
91 CFGBuilder cfgBuilder = CFGBuilderFactory.create(methodGen);
91 CFGBuilder cfgBuilder = CFGBuilderFactory.create(descriptor, methodGen);
9292 cfgBuilder.build();
9393 CFG cfg = cfgBuilder.getCFG();
9494
1919 package edu.umd.cs.findbugs.classfile.engine.bcel;
2020
2121 import edu.umd.cs.findbugs.OpcodeStack;
22 import edu.umd.cs.findbugs.StackMapAnalyzer.StackMapAnalysisFactory;
2223 import edu.umd.cs.findbugs.ba.AnnotationRetentionDatabase;
2324 import edu.umd.cs.findbugs.ba.CheckReturnAnnotationDatabase;
2425 import edu.umd.cs.findbugs.ba.InnerClassAccessMap;
2526 import edu.umd.cs.findbugs.ba.JCIPAnnotationDatabase;
26 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
2727 import edu.umd.cs.findbugs.ba.SourceInfoMap;
2828 import edu.umd.cs.findbugs.ba.ch.Subtypes2;
2929 import edu.umd.cs.findbugs.ba.jsr305.DirectlyRelevantTypeQualifiersDatabase;
3737 import edu.umd.cs.findbugs.classfile.IDatabaseFactory;
3838 import edu.umd.cs.findbugs.classfile.IMethodAnalysisEngine;
3939 import edu.umd.cs.findbugs.classfile.ReflectionDatabaseFactory;
40 import edu.umd.cs.findbugs.classfile.analysis.MethodInfo.MethodInfoDatabase;
4041
4142 /**
4243 * Register BCEL-framework analysis engines.
43 *
44 *
4445 * <p>
4546 * <b>NOTE</b>: the database factories will only work with
4647 * AnalysisCacheToAnalysisContextAdapter, not with LegacyAnalysisContext.
4748 * However, that's ok since the databases for BCEL-based analyses are only ever
4849 * accessed through the AnalysisContext.
4950 * </p>
50 *
51 *
5152 * @author David Hovemeyer
5253 */
5354 public class EngineRegistrar implements IAnalysisEngineRegistrar {
6768 new BlockTypeAnalysisFactory(), new CallListDataflowFactory(), new UnconditionalValueDerefDataflowFactory(),
6869 new CompactLocationNumberingFactory(), new ReturnPathTypeDataflowFactory(),
6970 new ForwardTypeQualifierDataflowFactoryFactory(), new BackwardTypeQualifierDataflowFactoryFactory(),
70 new OpcodeStack.JumpInfoFactory(), new ObligationDataflowFactory(), };
71 new OpcodeStack.JumpInfoFactory(), new StackMapAnalysisFactory(), new ObligationDataflowFactory(), };
7172
7273 private static final IDatabaseFactory<?>[] databaseFactoryList = {
7374 // new ReflectionDatabaseFactory<Subtypes>(Subtypes.class),
7677 new ReflectionDatabaseFactory<CheckReturnAnnotationDatabase>(CheckReturnAnnotationDatabase.class),
7778 new ReflectionDatabaseFactory<AnnotationRetentionDatabase>(AnnotationRetentionDatabase.class),
7879 new ReflectionDatabaseFactory<JCIPAnnotationDatabase>(JCIPAnnotationDatabase.class),
79 new ReflectionDatabaseFactory<NullnessAnnotationDatabase>(NullnessAnnotationDatabase.class),
8080 new ReflectionDatabaseFactory<SourceInfoMap>(SourceInfoMap.class),
8181 new ReflectionDatabaseFactory<FieldStoreTypeDatabase>(FieldStoreTypeDatabase.class),
8282 new ReflectionDatabaseFactory<ParameterNullnessPropertyDatabase>(ParameterNullnessPropertyDatabase.class),
8383 new ReflectionDatabaseFactory<ReturnValueNullnessPropertyDatabase>(ReturnValueNullnessPropertyDatabase.class),
8484 new ReflectionDatabaseFactory<DirectlyRelevantTypeQualifiersDatabase>(DirectlyRelevantTypeQualifiersDatabase.class),
85 new ReflectionDatabaseFactory<TypeQualifierDatabase>(TypeQualifierDatabase.class), };
85 new ReflectionDatabaseFactory<TypeQualifierDatabase>(TypeQualifierDatabase.class),
86 new ReflectionDatabaseFactory<MethodInfoDatabase>(MethodInfoDatabase.class),
87 };
8688
8789 /*
8890 * (non-Javadoc)
89 *
91 *
9092 * @see edu.umd.cs.findbugs.classfile.IAnalysisEngineRegistrar#
9193 * registerAnalysisEngines(edu.umd.cs.findbugs.classfile.IAnalysisCache)
9294 */
2222 import java.util.Map;
2323
2424 import edu.umd.cs.findbugs.FindBugs;
25 import edu.umd.cs.findbugs.classfile.ICodeBase;
2526 import edu.umd.cs.findbugs.classfile.ICodeBaseLocator;
2627 import edu.umd.cs.findbugs.classfile.IScannableCodeBase;
2728
3738
3839 private boolean isAppCodeBase;
3940
40 private int howDiscovered;
41 private ICodeBase.Discovered howDiscovered;
4142
4243 private long lastModifiedTime;
4344
9394 *
9495 * @see edu.umd.cs.findbugs.classfile.ICodeBase#setHowDiscovered(int)
9596 */
96 public void setHowDiscovered(int howDiscovered) {
97 public void setHowDiscovered(ICodeBase.Discovered howDiscovered) {
9798 this.howDiscovered = howDiscovered;
9899 }
99100
102103 *
103104 * @see edu.umd.cs.findbugs.classfile.ICodeBase#getHowDiscovered()
104105 */
105 public int getHowDiscovered() {
106 public ICodeBase.Discovered getHowDiscovered() {
106107 return howDiscovered;
107108 }
108109
3131
3232 import edu.umd.cs.findbugs.BugReporter;
3333 import edu.umd.cs.findbugs.SystemProperties;
34 import edu.umd.cs.findbugs.asm.FBClassReader;
3435 import edu.umd.cs.findbugs.ba.AnalysisContext;
3536 import edu.umd.cs.findbugs.ba.ClassContext;
3637 import edu.umd.cs.findbugs.ba.Debug;
5859 /**
5960 *
6061 */
61 private static final int MAX_JAVACLASS_RESULTS_TO_CACHE = 5000;
62 private static final int MAX_JAVACLASS_RESULTS_TO_CACHE = 3000;
63 private static final int MAX_FBCLASSREADER_RESULTS_TO_CACHE = 3000;
6264
6365 private static final int MAX_CONSTANT_POOL_GEN_RESULTS_TO_CACHE = 500;
6466
184186
185187 @SuppressWarnings("unchecked")
186188 private <E> Map<ClassDescriptor, E> getAllClassAnalysis(Class<E> analysisClass) {
187 Map<ClassDescriptor, Object> descriptorMap
189 Map<ClassDescriptor, Object> descriptorMap
188190 = findOrCreateDescriptorMap(classAnalysisMap, classAnalysisEngineMap,
189191 analysisClass);
190192 return (Map<ClassDescriptor, E>) descriptorMap;
244246 }
245247 // Get the descriptor->result map for this analysis class,
246248 // creating if necessary
247 Map<ClassDescriptor, Object> descriptorMap = findOrCreateDescriptorMap(classAnalysisMap,
249 Map<ClassDescriptor, Object> descriptorMap = findOrCreateDescriptorMap(classAnalysisMap,
248250 classAnalysisEngineMap,
249251 analysisClass);
250252
435437 * @param <DescriptorType>
436438 * type of descriptor used as the map's key type (ClassDescriptor
437439 * or MethodDescriptor)
438 * @param <E>
439 * type of analysis class
440440 * @param analysisClassToDescriptorMapMap
441441 * analysis class to descriptor map map
442442 * @param engineMap
447447 */
448448 private static <DescriptorType> Map<DescriptorType, Object> findOrCreateDescriptorMap(
449449 final Map<Class<?>, Map<DescriptorType, Object>> analysisClassToDescriptorMapMap,
450 final Map<Class<?>, ? extends IAnalysisEngine<DescriptorType, ?>> engineMap,
450 final Map<Class<?>, ? extends IAnalysisEngine<DescriptorType, ?>> engineMap,
451451 final Class<?> analysisClass) {
452452 Map<DescriptorType, Object> descriptorMap = analysisClassToDescriptorMapMap.get(analysisClass);
453453 if (descriptorMap == null) {
466466 IAnalysisEngine<DescriptorType, ?> engine = engineMap.get(analysisClass);
467467 if (analysisClass.equals(JavaClass.class)) {
468468 descriptorMap = new MapCache<DescriptorType, Object>(MAX_JAVACLASS_RESULTS_TO_CACHE);
469 } else if (analysisClass.equals(FBClassReader.class)) {
470 descriptorMap = new MapCache<DescriptorType, Object>(MAX_FBCLASSREADER_RESULTS_TO_CACHE);
469471 } else if (analysisClass.equals(ConstantPoolGen.class)) {
470472 descriptorMap = new MapCache<DescriptorType, Object>(MAX_CONSTANT_POOL_GEN_RESULTS_TO_CACHE);
471473 } else if (analysisClass.equals(ClassContext.class)) {
2121 import java.io.DataInputStream;
2222 import java.io.File;
2323 import java.io.FileFilter;
24 import java.io.FileNotFoundException;
2425 import java.io.IOException;
2526 import java.io.InputStream;
2627 import java.util.HashMap;
6162
6263 /**
6364 * Implementation of IClassPathBuilder.
64 *
65 *
6566 * @author David Hovemeyer
6667 */
6768 public class ClassPathBuilder implements IClassPathBuilder {
7677 * classpath construction algorithm.
7778 */
7879 static class WorkListItem {
79 private ICodeBaseLocator codeBaseLocator;
80
81 private boolean isAppCodeBase;
82
83 private int howDiscovered;
80 private final ICodeBaseLocator codeBaseLocator;
81
82 private final boolean isAppCodeBase;
83
84 private final ICodeBase.Discovered howDiscovered;
8485
8586 @Override
8687 public String toString() {
8788 return "WorkListItem(" + codeBaseLocator + ", " + isAppCodeBase + ", " + howDiscovered + ")";
8889 }
8990
90 public WorkListItem(ICodeBaseLocator codeBaseLocator, boolean isApplication, int howDiscovered) {
91 public WorkListItem(ICodeBaseLocator codeBaseLocator, boolean isApplication, ICodeBase.Discovered howDiscovered) {
9192 this.codeBaseLocator = codeBaseLocator;
9293 this.isAppCodeBase = isApplication;
9394 this.howDiscovered = howDiscovered;
104105 /**
105106 * @return Returns the howDiscovered.
106107 */
107 public int getHowDiscovered() {
108 public ICodeBase.Discovered getHowDiscovered() {
108109 return howDiscovered;
109110 }
110111 }
152153 }
153154
154155 // Fields
155 private IClassFactory classFactory;
156
157 private IErrorLogger errorLogger;
158
159 private LinkedList<WorkListItem> projectWorkList;
160
161 private LinkedList<DiscoveredCodeBase> discoveredCodeBaseList;
162
163 private Map<String, DiscoveredCodeBase> discoveredCodeBaseMap;
164
165 private LinkedList<ClassDescriptor> appClassList;
156 private final IClassFactory classFactory;
157
158 private final IErrorLogger errorLogger;
159
160 private final LinkedList<WorkListItem> projectWorkList;
161
162 private final LinkedList<DiscoveredCodeBase> discoveredCodeBaseList;
163
164 private final Map<String, DiscoveredCodeBase> discoveredCodeBaseMap;
165
166 private final LinkedList<ClassDescriptor> appClassList;
166167
167168 private boolean scanNestedArchives;
168169
169170 /**
170171 * Constructor.
171 *
172 *
172173 * @param classFactory
173174 * the class factory
174175 * @param errorLogger
185186
186187 /*
187188 * (non-Javadoc)
188 *
189 *
189190 * @see
190191 * edu.umd.cs.findbugs.classfile.IClassPathBuilder#addCodeBase(edu.umd.cs
191192 * .findbugs.classfile.ICodeBaseLocator, boolean)
192193 */
193194 public void addCodeBase(ICodeBaseLocator locator, boolean isApplication) {
194 addToWorkList(projectWorkList, new WorkListItem(locator, isApplication, ICodeBase.SPECIFIED));
195 addToWorkList(projectWorkList, new WorkListItem(locator, isApplication, ICodeBase.Discovered.SPECIFIED));
195196 }
196197
197198 /*
198199 * (non-Javadoc)
199 *
200 *
200201 * @see
201202 * edu.umd.cs.findbugs.classfile.IClassPathBuilder#scanNestedArchives(boolean
202203 * )
207208
208209 /*
209210 * (non-Javadoc)
210 *
211 *
211212 * @see
212213 * edu.umd.cs.findbugs.classfile.IClassPathBuilder#build(edu.umd.cs.findbugs
213214 * .classfile.IClassPath,
220221
221222 // If not already located, try to locate any additional codebases
222223 // containing classes required for analysis.
223 locateCodebasesRequiredForAnalysis(classPath, progress);
224 if (!discoveredCodeBaseList.isEmpty()) {
225 locateCodebasesRequiredForAnalysis(classPath, progress);
226 }
224227
225228 // Add all discovered codebases to the classpath
226229 for (DiscoveredCodeBase discoveredCodeBase : discoveredCodeBaseList) {
332335 // of its classes.)
333336 //
334337 ICodeBaseLocator loc = new FilesystemCodeBaseLocator(findbugsFullJar);
335 workList.addLast(new WorkListItem(loc, false, ICodeBase.IN_SYSTEM_CLASSPATH));
338 workList.addLast(new WorkListItem(loc, false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
336339 }
337340 return workList;
338341 }
339342
340343 /**
341344 * Probe a codebase to see if a given source exists in that code base.
342 *
345 *
343346 * @param resourceName
344347 * name of a resource
345348 * @return true if the resource exists in the codebase, false if not
424427 if (loc != null) {
425428 found = true;
426429 ICodeBaseLocator codeBaseLocator = classFactory.createFilesystemCodeBaseLocator(loc.getPath());
427 workList.add(new WorkListItem(codeBaseLocator, false, ICodeBase.IN_SYSTEM_CLASSPATH));
430 workList.add(new WorkListItem(codeBaseLocator, false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
428431 }
429432 }
430433
464467 }
465468 if (found) {
466469 ICodeBaseLocator codeBaseLocator = classFactory.createFilesystemCodeBaseLocator(entry);
467 workList.add(new WorkListItem(codeBaseLocator, false, ICodeBase.IN_SYSTEM_CLASSPATH));
470 workList.add(new WorkListItem(codeBaseLocator, false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
468471 break;
469472 }
470473
480483
481484 /**
482485 * Add worklist items from given system classpath.
483 *
486 *
484487 * @param workList
485488 * the worklist
486489 * @param path
498501 System.out.println("System classpath entry: " + entry);
499502 }
500503 addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(entry), false,
501 ICodeBase.IN_SYSTEM_CLASSPATH));
504 ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
502505 }
503506 }
504507
505508 /**
506509 * Add worklist items from given extensions directory.
507 *
510 *
508511 * @param workList
509512 * the worklist
510513 * @param extDir
515518 File[] fileList = dir.listFiles(new FileFilter() {
516519 /*
517520 * (non-Javadoc)
518 *
521 *
519522 * @see java.io.FileFilter#accept(java.io.File)
520523 */
521524 public boolean accept(File pathname) {
530533
531534 for (File archive : fileList) {
532535 addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(archive.getPath()), false,
533 ICodeBase.IN_SYSTEM_CLASSPATH));
536 ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
534537 }
535538 }
536539
539542 * archives and Class-Path entries specified in Jar manifests. This should
540543 * give us as good an idea as possible of all of the classes available (and
541544 * which are part of the application).
542 *
545 *
543546 * @param workList
544547 * the worklist to process
545548 * @param progress
554557 // and referenced codebases.
555558 while (!workList.isEmpty()) {
556559 WorkListItem item = workList.removeFirst();
557 if (item.getHowDiscovered() == ICodeBase.SPECIFIED) {
560 if (item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED) {
558561 progress.startArchive(item.toString());
559562 }
560563 if (DEBUG) {
580583 if (item.getCodeBaseLocator() instanceof FilesystemCodeBaseLocator) {
581584 FilesystemCodeBaseLocator l = (FilesystemCodeBaseLocator) item.getCodeBaseLocator();
582585 if (l.getPathName().endsWith(".java")) {
583 System.err.println("Ignoring .java file \"" + l.getPathName() + "\" specified in classpath or auxclasspath");
586 if (DEBUG){
587 System.err.println("Ignoring .java file \"" + l.getPathName() + "\" specified in classpath or auxclasspath");
588 }
584589 continue;
585590 }
586591 }
604609 // In addition, if it is an application codebase then
605610 // make a list of application classes.
606611 if (discoveredCodeBase.getCodeBase() instanceof IScannableCodeBase
607 && discoveredCodeBase.codeBase.isApplicationCodeBase()) {
612 && ( discoveredCodeBase.codeBase.isApplicationCodeBase()
613 || item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED)
614 ) {
608615 scanCodebase(classPath, workList, discoveredCodeBase);
609616 }
610617
612619 // entries.
613620 scanJarManifestForClassPathEntries(workList, discoveredCodeBase.getCodeBase());
614621 } catch (IOException e) {
615 if (item.isAppCodeBase() || item.getHowDiscovered() == ICodeBase.SPECIFIED) {
622 if (item.isAppCodeBase() || item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED) {
623 if (e instanceof FileNotFoundException)
624 errorLogger.logError("File not found: " + item.getCodeBaseLocator());
625 else errorLogger.logError("Cannot open codebase " + item.getCodeBaseLocator(), e);
626 }
627 } catch (ResourceNotFoundException e) {
628 if (item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED) {
616629 errorLogger.logError("Cannot open codebase " + item.getCodeBaseLocator(), e);
617630 }
618 } catch (ResourceNotFoundException e) {
619 if (item.getHowDiscovered() == ICodeBase.SPECIFIED) {
620 errorLogger.logError("Cannot open codebase " + item.getCodeBaseLocator(), e);
621 }
622 }
623
624 if (item.getHowDiscovered() == ICodeBase.SPECIFIED) {
631 }
632
633 if (item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED) {
625634 progress.finishArchive();
626635 }
627636 }
634643 * worklist)
635644 * <li>build a list of class resources found in the codebase
636645 * </ul>
637 *
646 *
638647 * @param workList
639648 * the worklist
640649 * @param discoveredCodeBase
665674 discoveredCodeBase.addCodeBaseEntry(entry);
666675
667676 // If resource is a nested archive, add it to the worklist
668 if (scanNestedArchives && codeBase.isApplicationCodeBase() && Archive.isArchiveFileName(entry.getResourceName())) {
677 if (scanNestedArchives && (codeBase.isApplicationCodeBase() || codeBase instanceof DirectoryCodeBase)
678 && Archive.isLibraryFileName(entry.getResourceName())) {
669679 if (VERBOSE) {
670 System.out.println("Entry is an archive!");
680 System.out.println("Entry is an library!");
671681 }
672682 ICodeBaseLocator nestedArchiveLocator = classFactory.createNestedArchiveCodeBaseLocator(codeBase,
673683 entry.getResourceName());
674684 addToWorkList(workList,
675 new WorkListItem(nestedArchiveLocator, codeBase.isApplicationCodeBase(), ICodeBase.NESTED));
685 new WorkListItem(nestedArchiveLocator, codeBase.isApplicationCodeBase(), ICodeBase.Discovered.NESTED));
676686 }
677687 }
678688 }
680690 /**
681691 * Attempt to parse data of given resource in order to divine the real name
682692 * of the class contained in the resource.
683 *
693 *
684694 * @param entry
685695 * the resource
686696 */
711721
712722 /**
713723 * Check a codebase for a Jar manifest to examine for Class-Path entries.
714 *
724 *
715725 * @param workList
716726 * the worklist
717727 * @param codeBase
745755
746756 // Codebases found in Class-Path entries are always
747757 // added to the aux classpath, not the application.
748 addToWorkList(workList, new WorkListItem(relativeCodeBaseLocator, false, ICodeBase.IN_JAR_MANIFEST));
758 addToWorkList(workList, new WorkListItem(relativeCodeBaseLocator, false, ICodeBase.Discovered.IN_JAR_MANIFEST));
749759 }
750760 }
751761 } finally {
760770 * that all of the worklist items representing application codebases appear
761771 * <em>before</em> all of the worklist items representing auxiliary
762772 * codebases.
763 *
773 *
764774 * @param projectWorkList
765775 * the worklist
766776 * @param itemToAdd
794804
795805 /*
796806 * (non-Javadoc)
797 *
807 *
798808 * @see edu.umd.cs.findbugs.classfile.IClassPathBuilder#getAppClassList()
799809 */
800810 public List<ClassDescriptor> getAppClassList() {
2828
2929 import edu.umd.cs.findbugs.FindBugs;
3030 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
31 import edu.umd.cs.findbugs.classfile.ICodeBase;
3132 import edu.umd.cs.findbugs.classfile.ICodeBaseEntry;
3233 import edu.umd.cs.findbugs.classfile.ICodeBaseIterator;
3334 import edu.umd.cs.findbugs.classfile.ICodeBaseLocator;
5253
5354 private boolean isAppCodeBase;
5455
55 private int howDiscovered;
56 private ICodeBase.Discovered howDiscovered;
5657
5758 private long lastModifiedTime;
5859
161162 *
162163 * @see edu.umd.cs.findbugs.classfile.ICodeBase#setHowDiscovered(int)
163164 */
164 public void setHowDiscovered(int howDiscovered) {
165 public void setHowDiscovered(ICodeBase.Discovered howDiscovered) {
165166 this.howDiscovered = howDiscovered;
166167 }
167168
170171 *
171172 * @see edu.umd.cs.findbugs.classfile.ICodeBase#getHowDiscovered()
172173 */
173 public int getHowDiscovered() {
174 public ICodeBase.Discovered getHowDiscovered() {
174175 return howDiscovered;
175176 }
176177
1818
1919 package edu.umd.cs.findbugs.classfile.impl;
2020
21 import java.io.BufferedInputStream;
2221 import java.io.File;
23 import java.io.FileInputStream;
24 import java.io.FileNotFoundException;
2522 import java.io.IOException;
26 import java.util.Enumeration;
27 import java.util.zip.ZipEntry;
2823 import java.util.zip.ZipException;
29 import java.util.zip.ZipFile;
30 import java.util.zip.ZipInputStream;
3124
3225 import edu.umd.cs.findbugs.classfile.Global;
3326 import edu.umd.cs.findbugs.classfile.ICodeBaseLocator;
4235 Profiler profiler = Global.getAnalysisCache().getProfiler();
4336 profiler.start(ZipCodeBaseFactory.class);
4437 try {
45 return countUsingZipFile(codeBaseLocator, file);
38 return new ZipFileCodeBase(codeBaseLocator, file);
39 } catch (ZipException e) {
40 // May be too many zip entries
41 return new ZipInputStreamCodeBase(codeBaseLocator, file);
4642 } finally {
4743 profiler.end(ZipCodeBaseFactory.class);
4844 }
4945 }
5046
51 /**
52 * @param codeBaseLocator
53 * @param file
54 * @return
55 * @throws IOException
56 * @throws FileNotFoundException
57 */
58 private static AbstractScannableCodeBase countUsingZipInputStream(ICodeBaseLocator codeBaseLocator, File file)
59 throws IOException, FileNotFoundException {
60 long size = file.length();
61 long estimatedEntries = size / 2000;
62 if (estimatedEntries < 20000)
63 return new ZipFileCodeBase(codeBaseLocator, file);
64 int zipEntries = 0;
65 ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
66 try {
67 for (ZipEntry e; (e = in.getNextEntry()) != null && zipEntries < 30010;)
68 zipEntries++;
69 } finally {
70 in.close();
71 }
72 if (zipEntries < 30010)
73 return new ZipFileCodeBase(codeBaseLocator, file);
74 return new ZipInputStreamCodeBase(codeBaseLocator, file);
75 }
7647
77 /**
78 * @param codeBaseLocator
79 * @param file
80 * @return
81 * @throws IOException
82 * @throws ZipException
83 */
84 private static AbstractScannableCodeBase countUsingZipFile(ICodeBaseLocator codeBaseLocator, File file) throws IOException,
85 ZipException {
86 long size = file.length();
87 long estimatedEntries = size / 2000;
88 if (estimatedEntries < 20000)
89 return new ZipFileCodeBase(codeBaseLocator, file);
90 int zipEntries = 0;
91 ZipFile in = new ZipFile(file);
92 try {
93 for (Enumeration<?> e = in.entries(); e.hasMoreElements() && zipEntries < 30010;) {
94 e.nextElement();
95 zipEntries++;
96 }
97 } finally {
98 in.close();
99 }
100 if (zipEntries < 30010)
101 return new ZipFileCodeBase(codeBaseLocator, file);
102 return new ZipInputStreamCodeBase(codeBaseLocator, file);
103 }
48
10449
10550 }
5454 try {
5555 this.zipFile = new ZipFile(file);
5656 setLastModifiedTime(file.lastModified());
57 } catch (ZipException e) {
57 } catch (IOException e) {
5858 if (!file.exists()) {
5959 File parent = file.getParentFile();
6060 if (!(parent.exists() && parent.isDirectory() && parent.canRead()))
61 throw new ZipException("Can't read directory containing zip file: " + file);
62 throw new ZipException("Zip file doesn't exist: " + file);
61 throw new IOException("Can't read directory containing zip file: " + file);
62 throw new IOException("Zip file doesn't exist: " + file);
6363 }
6464 if (!file.canRead())
65 throw new ZipException("Can't read file zip file: " + file);
65 throw new IOException("Can't read file zip file: " + file);
6666 if (!file.isFile())
67 throw new ZipException("Zip file isn't a normal file: " + file);
67 throw new IOException("Zip file isn't a normal file: " + file);
6868 if (file.length() == 0)
69 throw new ZipException("Zip file is empty: " + file);
69 throw new IOException("Zip file is empty: " + file);
70 if (!(e instanceof ZipException)) {
71 IOException ioException = new IOException("Error opening zip file " + file + " of " + file.length() + " bytes");
72 ioException.initCause(e);
73 throw ioException;
74 }
7075 DataInputStream in = new DataInputStream(new FileInputStream(file));
71 ZipException e2 = new ZipException("Error opening zip file " + file + " of " + file.length() + " bytes");
7276 int magicBytes;
7377 try {
7478 magicBytes = in.readInt();
79 in.close();
7580 } catch (IOException e3) {
76 throw new ZipException(String.format("Unable read first 4 bytes of zip file %s of %d bytes", file, file.length()));
81 throw new IOException(String.format("Unable read first 4 bytes of zip file %s of %d bytes", file, file.length()));
7782 }
7883 if (magicBytes != 0x504b0304)
79 throw new ZipException(String.format("Wrong magic bytes of %x for zip file %s of %d bytes", magicBytes, file,
84 throw new IOException(String.format("Wrong magic bytes of %x for zip file %s of %d bytes", magicBytes, file,
8085 file.length()));
86 ZipException e2 = new ZipException("Error opening zip file " + file + " of " + file.length() + " bytes");
8187 e2.initCause(e);
8288 throw e2;
8389 }
88 * using the ClassFactory singleton in that package.
99 */
1010 @javax.annotation.ParametersAreNonnullByDefault
11 @edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained
1112 package edu.umd.cs.findbugs.classfile;
1213
2323 import java.util.Collections;
2424 import java.util.Date;
2525 import java.util.Properties;
26 import java.util.concurrent.TimeUnit;
2627
2728 import edu.umd.cs.findbugs.BugCollection;
2829 import edu.umd.cs.findbugs.BugDesignation;
6162 public void initiateCommunication() {
6263 }
6364
65 public boolean waitUntilNewIssuesUploaded(long timeout, TimeUnit unit) throws InterruptedException {
66 return true;
67 }
68
69 public boolean waitUntilIssueDataDownloaded(long timeout, TimeUnit unit) throws InterruptedException {
70 return true;
71 }
72
6473 @Override
6574 public Mode getMode() {
6675 return Mode.COMMUNAL;
101110 public void setMode(Mode m) {
102111 }
103112
113 @Override
104114 public void bugsPopulated() {
105115 assert true;
106116
2727 import java.util.MissingResourceException;
2828 import java.util.ResourceBundle;
2929 import java.util.Set;
30 import java.util.concurrent.TimeUnit;
3031
3132 import javax.annotation.CheckForNull;
3233
9394 * Waits until all new issues have been uploaded
9495 */
9596 public void waitUntilNewIssuesUploaded();
97
98 public boolean waitUntilNewIssuesUploaded(long timeout, TimeUnit unit)
99 throws InterruptedException;
96100
97101 /**
98102 * Waits until all data about this bug collection has been received from the
100104 */
101105 public void waitUntilIssueDataDownloaded();
102106
107 public boolean waitUntilIssueDataDownloaded(long timeout, TimeUnit unit)
108 throws InterruptedException;
109
103110 /**
104111 * Returns true if communication has already been initiated (and perhaps completed).
105 *
112 *
106113 */
107114 public boolean communicationInitiated();
108115 /**
338345
339346 enum SigninState {
340347 NO_SIGNIN_REQUIRED, UNAUTHENTICATED, SIGNING_IN, SIGNED_IN, SIGNIN_FAILED, SIGNIN_DECLINED, SIGNED_OUT, DISCONNECTED;
341
342
348
349
343350 /** Can download issues without asking to sign in */
344351 public boolean canDownload() {
345352 switch (this) {
351358 default:
352359 return false;
353360 }
354
355 }
356
361
362 }
363
357364 /** Can upload issues without asking to sign in */
358365 public boolean canUpload() {
359366 switch (this) {
364371 default:
365372 return false;
366373 }
367
374
368375 }
369376 /** Should ask to sign in if new issues to upload found */
370377 public boolean shouldAskToSignIn() {
391398 return false;
392399 }
393400 }
401 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
394402 static final ResourceBundle names = ResourceBundle.getBundle(Cloud.class.getName(), Locale.getDefault());
395403
396
404
397405 @Override
398406 public String toString() {
399407 try {
434442 return this == UserDesignation.OBSOLETE_CODE || this == UserDesignation.NEEDS_STUDY
435443 || this == UserDesignation.UNCLASSIFIED;
436444 }
437
445
438446 public boolean notAProblem() {
439 return this.score() < 0;
447 return this.score() < 0;
440448 }
441449 public boolean shouldFix() {
442 return this.score() > 0;
450 return this.score() > 0;
443451 }
444452 }
445453
77 import java.util.Date;
88 import java.util.Properties;
99 import java.util.Set;
10 import java.util.concurrent.TimeUnit;
1011
1112 import javax.annotation.CheckForNull;
1213
9798 public void waitUntilIssueDataDownloaded() {
9899 }
99100
101 public boolean waitUntilNewIssuesUploaded(long timeout, TimeUnit unit) throws InterruptedException {
102 return true;
103 }
104
105 public boolean waitUntilIssueDataDownloaded(long timeout, TimeUnit unit) throws InterruptedException {
106 return true;
107 }
100108 public void bugsPopulated() {
101109 }
102110
337345 public boolean isInitialized() {
338346 return true;
339347 }
348
349
340350 }
130130 try {
131131 String host = new URL(url).getHost();
132132 InetAddress.getByName(host);
133 } catch (MalformedURLException e) {
133 } catch (MalformedURLException e) {
134134 assert true;
135135 /* this will come out later */
136136 }
177177
178178 // ======================= end of public methods =======================
179179
180 private static SecureRandom secureRandom = new SecureRandom();
181
180182 private long loadOrCreateSessionId() {
181183 long id = loadSessionId();
182184 if (id != 0) {
183185 LOGGER.info("Using saved session ID: " + id);
184186 return id;
185187 }
186 SecureRandom r = new SecureRandom();
187 while (id == 0)
188 id = r.nextLong();
189 // if (id == 0) { // 0 is reserved for no session id
190 // id = 42;
191 // }
188 while (id == 0)
189 id = secureRandom.nextLong();
190
192191 if (isSavingSessionInfoEnabled())
193192 saveSessionInformation(id);
194193
3333 import java.util.Set;
3434
3535 import edu.umd.cs.findbugs.DetectorFactoryCollection;
36 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
36 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3737 import edu.umd.cs.findbugs.ba.AnalysisContext;
3838 import edu.umd.cs.findbugs.charsets.UTF8;
3939 import edu.umd.cs.findbugs.util.Util;
256256 * usage synopsis
257257 * @return number of arguments parsed
258258 */
259 @SuppressWarnings("DM_EXIT")
259 @SuppressFBWarnings("DM_EXIT")
260260 public int parse(String argv[], int minArgs, int maxArgs, String usage) {
261261 try {
262262 int count = parse(argv);
304304
305305 while (arg < argv.length) {
306306 String option = argv[arg];
307 if (option.equals("-help"))
307 if (option.equals("-help") || option.equals("-h"))
308308 throw new HelpRequestedException();
309309 if (!option.startsWith("-"))
310310 break;
3131 import edu.umd.cs.findbugs.BugProperty;
3232 import edu.umd.cs.findbugs.DetectorFactoryCollection;
3333 import edu.umd.cs.findbugs.Priorities;
34 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
3435
3536 /**
3637 * Settings for user filtering of warnings for a project. This includes
5960 public static final String DEFAULT_PRIORITY = MEDIUM_PRIORITY;
6061
6162 /** Map of priority level names to their numeric values. */
63 @StaticConstant
6264 private static Map<String, Integer> priorityNameToValueMap = new HashMap<String, Integer>();
6365 static {
6466 priorityNameToValueMap.put(HIGH_PRIORITY, (Priorities.HIGH_PRIORITY));
7575
7676 public static final String EFFORT_MAX = "max";
7777
78 /**
79 * Key prefix for custom plugins, full key consists of a prefix + plugin index starting with 0
80 */
81 public static final String KEY_PLUGIN = "plugin";
82
7883 // Private constants
7984
8085 private static final String PREF_FILE_NAME = ".Findbugs_prefs";
8287 private static final int MAX_RECENT_FILES = 9;
8388
8489 private static final String CLOUD_ID_KEY = "cloud_id";
85
90
8691 private static final String DETECTOR_THRESHOLD_KEY = "detector_threshold";
8792
8893 private static final String FILTER_SETTINGS_KEY = "filter_settings";
99104
100105 private static final String KEY_EXCLUDE_BUGS = "excludebugs";
101106
102 private static final String KEY_PLUGIN = "plugin";
103
104107 // Fields
105108
106109 private LinkedList<String> recentProjectsList;
112115 private boolean runAtFullBuild;
113116
114117 private String effort;
115
118
116119 private String cloudId;
117120
118121 private Map<String, Boolean> includeFilterFiles;
496499 @Override
497500 public int hashCode() {
498501 return recentProjectsList.hashCode() + detectorEnablementMap.hashCode() + filterSettings.hashCode() + effort.hashCode()
499 + includeFilterFiles.hashCode() + excludeFilterFiles.hashCode() + (runAtFullBuild ? 1 : 0)
502 + includeFilterFiles.hashCode() + excludeFilterFiles.hashCode() + (runAtFullBuild ? 1 : 0)
500503 + Util.nullSafeHashcode(cloudId);
501504 }
502505
2626 import edu.umd.cs.findbugs.BugReporter;
2727 import edu.umd.cs.findbugs.OpcodeStack;
2828 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
29 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
2930 import edu.umd.cs.findbugs.visitclass.PreorderVisitor;
3031
3132 public class BadResultSetAccess extends OpcodeStackDetector {
3233
34 @StaticConstant
3335 private static final Set<String> dbFieldTypesSet = new HashSet<String>() {
3436 static final long serialVersionUID = -3510636899394546735L;
3537 {
6062 }
6163 };
6264
63 private BugReporter bugReporter;
65 final private BugReporter bugReporter;
6466
6567 public BadResultSetAccess(BugReporter bugReporter) {
6668 this.bugReporter = bugReporter;
4646 if (value == null || !(value instanceof String))
4747 return;
4848 String regex = (String) value;
49 if (!regex.equals("."))
49 boolean dotIsUsed = regex.equals(".");
50 if (!dotIsUsed && !regex.equals("|"))
5051 return;
5152 int priority = HIGH_PRIORITY;
52 if (ignorePasswordMasking) {
53 if (ignorePasswordMasking && dotIsUsed) {
5354 priority = NORMAL_PRIORITY;
5455 OpcodeStack.Item top = stack.getStackItem(0);
5556 Object topValue = top.getConstant();
3232 import edu.umd.cs.findbugs.ba.CheckReturnValueAnnotation;
3333 import edu.umd.cs.findbugs.ba.XFactory;
3434 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
35 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
3536 import edu.umd.cs.findbugs.visitclass.AnnotationVisitor;
3637
3738 /**
3839 * Scan application classes for CheckReturnValue annotations.
39 *
40 *
4041 * @author David Hovemeyer
4142 * @author William Pugh
4243 */
4546
4647 private static final String DEFAULT_ANNOTATION_ANNOTATION_CLASS = "DefaultAnnotation";
4748
49 @StaticConstant
4850 private static final Map<String, AnnotationDatabase.Target> defaultKind = new HashMap<String, AnnotationDatabase.Target>();
4951 static {
5052 defaultKind.put("", AnnotationDatabase.Target.ANY);
7072
7173 String annotationClassSimpleName = simpleClassName(annotationClassName);
7274
73 if (annotationClassSimpleName.startsWith("DefaultAnnotation")) {
74 annotationClassSimpleName = annotationClassSimpleName.substring("DefaultAnnotation".length());
75 if (annotationClassSimpleName.startsWith(DEFAULT_ANNOTATION_ANNOTATION_CLASS)) {
76 annotationClassSimpleName = annotationClassSimpleName.substring(DEFAULT_ANNOTATION_ANNOTATION_CLASS.length());
7577
7678 Target annotationTarget = defaultKind.get(annotationClassSimpleName);
7779 if (annotationTarget != Target.METHOD)
3535 import edu.umd.cs.findbugs.ba.XFactory;
3636 import edu.umd.cs.findbugs.ba.XMethod;
3737 import edu.umd.cs.findbugs.ba.XMethodParameter;
38 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
3839 import edu.umd.cs.findbugs.visitclass.AnnotationVisitor;
3940
4041 /**
4142 * Scan application classes for NonNull annotations.
42 *
43 *
4344 * @author David Hovemeyer
4445 * @author William Pugh
46 *
47 * @deprecated AnnotationDatabases are being phased out, since annotations are
48 * now stored directly in the XClass/XMethod/XField objects.
49 * Resolving nullness annotations will be handled through the
50 * JSR-305 type qualifier code.
4551 */
52 @Deprecated
4653 public class BuildNonNullAnnotationDatabase extends AnnotationVisitor {
4754 private static final boolean DEBUG = SystemProperties.getBoolean("fnd.debug.annotation");
4855
4956 private static final String DEFAULT_ANNOTATION_ANNOTATION_CLASS = "DefaultAnnotation";
5057
58 @StaticConstant
5159 private static final Map<String, AnnotationDatabase.Target> defaultKind = new HashMap<String, AnnotationDatabase.Target>();
5260 static {
5361 defaultKind.put("", AnnotationDatabase.Target.ANY);
5765
5866 }
5967
60 private NullnessAnnotationDatabase database;
68 private final NullnessAnnotationDatabase database;
6169
6270 public BuildNonNullAnnotationDatabase(@CheckForNull NullnessAnnotationDatabase database) {
6371 this.database = database;
7280
7381 /*
7482 * * @param value
75 *
83 *
7684 * @param map
77 *
85 *
7886 * @param annotationTarget
7987 */
8088 private void handleClassElementValue(ClassElementValue value, Target annotationTarget) {
6666 * database with some known resources types needing to be released, and augment
6767 * the database with additional entries discovered through scanning referenced
6868 * classes for annotations.
69 *
69 *
7070 * @author David Hovemeyer
7171 */
7272 public class BuildObligationPolicyDatabase implements Detector2, NonReportingDetector {
7575
7676 /*
7777 * (non-Javadoc)
78 *
78 *
7979 * @see
8080 * edu.umd.cs.findbugs.ba.interproc.PropertyDatabase#decodeProperty(
8181 * java.lang.String)
8787
8888 /*
8989 * (non-Javadoc)
90 *
90 *
9191 * @see
9292 * edu.umd.cs.findbugs.ba.interproc.PropertyDatabase#encodeProperty(
9393 * java.lang.Object)
208208 methodHasCloseInName = splitter.split().contains("close");
209209 }
210210
211 for (int i = 0; i < xmethod.getNumParams(); i++)
212 if (paramObligationTypes[i] != null) {
211 for (int i = 0; i < xmethod.getNumParams(); i++) {
212 Obligation obligationType = paramObligationTypes[i];
213 if (obligationType != null) {
213214 if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
214215 //
215216 // Calling this method deletes a parameter obligation
217218 // creates a new obligation for the object returned by
218219 // the method.
219220 //
220 handleWillCloseWhenClosed(xmethod, paramObligationTypes[i]);
221 handleWillCloseWhenClosed(xmethod, obligationType);
221222 } else if (xmethod.getParameterAnnotation(i, willClose) != null) {
222 if (paramObligationTypes[i] == null) {
223 // Hmm...
224 if (DEBUG_ANNOTATIONS) {
225 System.out.println("Method " + xmethod.toString() + " has param " + i + " annotated @WillClose, "
226 + "but its type is not an obligation type");
227 }
228 } else {
229 addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
230 ObligationPolicyDatabaseEntryType.STRONG);
231 }
223 addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
224 ObligationPolicyDatabaseEntryType.STRONG);
232225 sawAnnotationsInApplicationCode = true;
233226 } else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
234227 // No database entry needs to be added
236229 } else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
237230 // Method has "close" in its name.
238231 // Assume that it deletes the obligation.
239 addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
232 addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
240233 ObligationPolicyDatabaseEntryType.STRONG);
241234 } else {
242235 /*
250243 if (xmethod.getName().equals("<init>") || xmethod.isStatic()
251244 || xmethod.getName().toLowerCase().indexOf("close") >= 0
252245 || xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
253 addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
246 addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
254247 ObligationPolicyDatabaseEntryType.WEAK);
255248 }
256249 }
257
258
250 }
251
252
259253 }
260254
261255 public void finishPass() {
281275 }
282276
283277 private void addBuiltInPolicies() {
278
284279 // Add the database entries describing methods that add and delete
285280 // file stream/reader obligations.
286281 addFileStreamEntries("InputStream");
298293 .getObjectTypeInstance("java.util.logging.StreamHandler")), new ExactStringMatcher("setOutputStream"),
299294 new ExactStringMatcher("(Ljava/io/OutputStream;)V"), false, ObligationPolicyDatabaseActionType.DEL,
300295 ObligationPolicyDatabaseEntryType.STRONG, javaIoOutputStreamObligation));
301
296
302297 database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
303298 .getObjectTypeInstance("java.io.FileOutputStream")), new ExactStringMatcher("getChannel"),
304299 new ExactStringMatcher("()Ljava/nio/channels/FileChannel;"), false, ObligationPolicyDatabaseActionType.DEL,
357352 /**
358353 * Add an appropriate policy database entry for parameters marked with the
359354 * WillClose annotation.
360 *
355 *
361356 * @param xmethod
362357 * a method
363358 * @param obligation
4747 import edu.umd.cs.findbugs.ba.XMethod;
4848 import edu.umd.cs.findbugs.ba.type.TypeDataflow;
4949 import edu.umd.cs.findbugs.ba.type.TypeFrame;
50 import edu.umd.cs.findbugs.bcel.BCELUtil;
5051 import edu.umd.cs.findbugs.visitclass.PreorderVisitor;
5152
5253 public class CallToUnconditionalThrower extends PreorderVisitor implements Detector {
7273 }
7374
7475 private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
75 if (method.isSynthetic() || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
76 if (BCELUtil.isSynthetic(method) || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
7677 return;
7778 CFG cfg = classContext.getCFG(method);
7879
4848 import edu.umd.cs.findbugs.ba.XMethod;
4949 import edu.umd.cs.findbugs.ba.type.TypeDataflow;
5050 import edu.umd.cs.findbugs.ba.type.TypeFrame;
51 import edu.umd.cs.findbugs.bcel.BCELUtil;
5152
5253 public class CallToUnsupportedMethod implements Detector {
5354
8788 */
8889 private void analyzeMethod(ClassContext classContext, Method method) throws MethodUnprofitableException, CFGBuilderException,
8990 DataflowAnalysisException {
90 if (method.isSynthetic() || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
91 if (BCELUtil.isSynthetic(method)|| (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
9192 return;
9293 CFG cfg = classContext.getCFG(method);
9394 TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
0 /*
1 * FindBugs - Find bugs in Java programs
2 * Copyright (C) 2004-2006 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.detect;
20
21 import org.apache.bcel.Constants;
22 import org.apache.bcel.classfile.Code;
23 import org.apache.bcel.classfile.Field;
24
25 import edu.umd.cs.findbugs.BugAccumulator;
26 import edu.umd.cs.findbugs.BugInstance;
27 import edu.umd.cs.findbugs.BugReporter;
28 import edu.umd.cs.findbugs.OpcodeStack;
29 import edu.umd.cs.findbugs.OpcodeStack.Item;
30 import edu.umd.cs.findbugs.OpcodeStack.JumpInfo;
31 import edu.umd.cs.findbugs.ba.XClass;
32 import edu.umd.cs.findbugs.ba.XMethod;
33 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
34 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
35 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
36 import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject;
37 import edu.umd.cs.findbugs.internalAnnotations.AnalysisContextContained;
38 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
39
40 public class CheckAnalysisContextContainedAnnotation extends OpcodeStackDetector.WithCustomJumpInfo {
41
42 final BugReporter bugReporter;
43
44 final BugAccumulator accumulator;
45
46 public CheckAnalysisContextContainedAnnotation(BugReporter bugReporter) {
47 this.bugReporter = bugReporter;
48 this.accumulator = new BugAccumulator(bugReporter);
49 }
50
51 final static ClassDescriptor ConstantAnnotation = DescriptorFactory.createClassDescriptor(StaticConstant.class);
52 final static ClassDescriptor AnalysisContextContainedAnnotation = DescriptorFactory.createClassDescriptor(AnalysisContextContained.class);
53
54
55 private boolean analysisContextContained(XClass xclass) {
56 AnnotatedObject ao = xclass;
57 do {
58 if (ao.getAnnotation(AnalysisContextContainedAnnotation) != null)
59 return true;
60 ao = ao.getContainingScope();
61
62 } while (ao != null);
63 return false;
64
65 }
66 @Override
67 public void visit(Field field) {
68 if (!field.isStatic())
69 return;
70 String signature = field.getSignature();
71 if (signature.startsWith("Ljava/util/") && !signature.equals("Ljava/util/regex/Pattern;")
72 && !signature.equals("Ljava/util/logging/Logger;") && !signature.equals("Ljava/util/BitSet;")
73 && !signature.equals("Ljava/util/ResourceBundle;")
74 && !signature.equals("Ljava/util/Comparator;")
75 && getXField().getAnnotation(ConstantAnnotation) == null) {
76 boolean flagged = analysisContextContained(getXClass());
77
78 bugReporter.reportBug(new BugInstance(this, "TESTING", flagged ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addField(this).addType(signature));
79
80 }
81 }
82 @Override
83 public void visit(Code code) {
84 boolean interesting = false;
85 if (interesting) {
86 // initialize any variables we want to initialize for the method
87 super.visit(code); // make callbacks to sawOpcode for all opcodes
88 }
89 accumulator.reportAccumulatedBugs();
90 }
91
92 @Override
93 public void sawOpcode(int seen) {
94 switch (seen) {
95 default:
96 break;
97 case Constants.IF_ICMPEQ:
98 case Constants.IF_ICMPNE:
99 OpcodeStack.Item left = stack.getStackItem(1);
100 OpcodeStack.Item right = stack.getStackItem(0);
101 if (bad(left, right) || bad(right, left))
102 accumulator.accumulateBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this)
103 .addValueSource(left, this).addValueSource(right, this)
104 .addString("Just check the sign of the result of compare or compareTo, not specific values such as 1 or -1"), this);
105 break;
106 }
107
108 }
109
110 private boolean bad(Item left, Item right) {
111 XMethod m = left.getReturnValueOf();
112
113 if (m == null)
114 return false;
115 Object value = right.getConstant();
116 if (!(value instanceof Integer) || ((Integer) value).intValue() == 0)
117 return false;
118 if (m.isStatic() || !m.isPublic())
119 return false;
120
121 if (m.getName().equals("compareTo") && m.getSignature().equals("(Ljava/lang/Object;)I"))
122 return true;
123 if (m.getName().equals("compare") && m.getSignature().equals("(Ljava/lang/Object;Ljava/lang/Object;)I"))
124 return true;
125
126 return false;
127
128 }
129
130 @Override
131 public JumpInfo customJumpInfo() {
132 // TODO Auto-generated method stub
133 return null;
134 }
135
136 }
3535 import edu.umd.cs.findbugs.BugPattern;
3636 import edu.umd.cs.findbugs.BugRanker;
3737 import edu.umd.cs.findbugs.BugReporter;
38 import edu.umd.cs.findbugs.ClassAnnotation;
3839 import edu.umd.cs.findbugs.Detector2;
3940 import edu.umd.cs.findbugs.DetectorFactory;
4041 import edu.umd.cs.findbugs.DetectorFactoryCollection;
8182 private Set<String> possibleBugCodes;
8283
8384 private boolean initialized = false;
85 private Map<ClassDescriptor, Collection<BugInstance>> warningsByClass;
8486 private Map<MethodDescriptor, Collection<BugInstance>> warningsByMethod;
8587 private Map<FieldDescriptor, Collection<BugInstance>> warningsByField;
8688
125127 // produced by this point.
126128 //
127129
130 warningsByClass = new HashMap<ClassDescriptor, Collection<BugInstance>>();
128131 warningsByMethod = new HashMap<MethodDescriptor, Collection<BugInstance>>();
129132 warningsByField = new HashMap<FieldDescriptor, Collection<BugInstance>>();
130133
153156 }
154157 warnings.add(warning);
155158 }
159 if(field == null && method == null){
160 ClassAnnotation clazz = warning.getPrimaryClass();
161 if (clazz != null) {
162 ClassDescriptor classDesc = clazz.getClassDescriptor();
163 Collection<BugInstance> warnings = warningsByClass.get(classDesc);
164 if (warnings == null) {
165 warnings = new LinkedList<BugInstance>();
166 warningsByClass.put(classDesc, warnings);
167 }
168 warnings.add(warning);
169 }
170 }
156171 }
157172
158173 //
185200
186201 XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor);
187202 List<? extends XMethod> methods = xclass.getXMethods();
203 if (DEBUG) {
204 System.out.println("CEW: checking " + xclass.toString());
205 }
206 check(xclass, expectWarning, true, HIGH_PRIORITY);
207 check(xclass, desireWarning, true, NORMAL_PRIORITY);
208 check(xclass, noWarning, false, HIGH_PRIORITY);
209 check(xclass, desireNoWarning, false, NORMAL_PRIORITY);
210
188211 for (XMethod xmethod : methods) {
189212 if (DEBUG) {
190213 System.out.println("CEW: checking " + xmethod.toString());
204227 check(xfield, desireNoWarning, false, NORMAL_PRIORITY);
205228 }
206229
230 }
231
232 private void check(XClass xclass, ClassDescriptor annotation, boolean expectWarnings, int priority) {
233 AnnotationValue expect = xclass.getAnnotation(annotation);
234 if (expect == null)
235 return;
236 if (DEBUG) {
237 System.out.println("*** Found " + annotation + " annotation on " + xclass);
238 }
239 ClassDescriptor descriptor = xclass.getClassDescriptor();
240 Collection<BugInstance> warnings = warningsByClass.get(descriptor);
241 check(expect, descriptor, warnings, expectWarnings, priority, descriptor);
207242 }
208243
209244 private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) {
215250 }
216251 FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor();
217252 Collection<BugInstance> warnings = warningsByMethod.get(descriptor);
218 check(expect, descriptor, warnings, expectWarnings, priority);
219 }
253 check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor());
254 }
255
220256 private void check(XField xfield, ClassDescriptor annotation, boolean expectWarnings, int priority) {
221257 AnnotationValue expect = xfield.getAnnotation(annotation);
222258 if (expect == null)
227263 }
228264 FieldOrMethodDescriptor descriptor = xfield.getFieldDescriptor();
229265 Collection<BugInstance> warnings = warningsByField.get(descriptor);
230 check(expect, descriptor, warnings, expectWarnings, priority);
231 }
232
233 private void check(AnnotationValue expect, FieldOrMethodDescriptor descriptor,
234 Collection<BugInstance> warnings, boolean expectWarnings, int priority) {
266 check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor());
267 }
268
269 private void check(AnnotationValue expect, Object descriptor,
270 Collection<BugInstance> warnings, boolean expectWarnings, int priority, ClassDescriptor cd) {
235271
236272 if (expect != null) {
237273
262298 }
263299 }
264300 if (expectedBugCodes == null || expectedBugCodes.trim().length() == 0) {
265 checkAnnotation(null, warnings, expectWarnings, priority, rank, num, descriptor, minPriority);
301 checkAnnotation(null, warnings, expectWarnings, priority, rank, num, descriptor, minPriority, cd);
266302 } else {
267303 StringTokenizer tok = new StringTokenizer(expectedBugCodes, ",");
268304 while (tok.hasMoreTokens()) {
269305 String bugCode = tok.nextToken().trim();
270306 if (!possibleBugCodes.contains(bugCode))
271307 continue;
272 checkAnnotation(bugCode, warnings, expectWarnings, priority, rank, num, descriptor, minPriority);
308 checkAnnotation(bugCode, warnings, expectWarnings, priority, rank, num, descriptor, minPriority, cd);
273309 }
274310 }
275311 }
276312 }
277313
278314 public void checkAnnotation(@CheckForNull String bugCode, Collection<BugInstance> warnings, boolean expectWarnings, int priority,
279 Integer rank, Integer num, FieldOrMethodDescriptor methodDescriptor, int minPriority) {
315 Integer rank, Integer num, Object methodDescriptor, int minPriority, ClassDescriptor cd) {
280316
281317 String bugCodeMessage = bugCode != null ? bugCode : "any bug";
282318 Collection<SourceLineAnnotation> bugs = countWarnings(warnings, bugCode, minPriority,
283319 rank);
284320 if (expectWarnings && bugs.size() < num) {
285 BugInstance bug = makeWarning("FB_MISSING_EXPECTED_WARNING", methodDescriptor, priority).addString(bugCodeMessage);
321 BugInstance bug = makeWarning("FB_MISSING_EXPECTED_WARNING", methodDescriptor, priority, cd).addString(bugCodeMessage);
286322 if (!bugs.isEmpty()) {
287323 bug.addString(String.format("Expected %d bugs, saw %d", num, bugs.size()));
288324 }
289325 reporter.reportBug(bug);
290326 } else if (bugs.size() > num) {
291 BugInstance bug = makeWarning("FB_UNEXPECTED_WARNING", methodDescriptor, priority).addString(bugCodeMessage);
327 BugInstance bug = makeWarning("FB_UNEXPECTED_WARNING", methodDescriptor, priority, cd).addString(bugCodeMessage);
292328 if (!expectWarnings) {
293329 for (SourceLineAnnotation s : bugs) {
294330 reporter.reportBug(bug.add(s));
308344 * @param priority
309345 * @return
310346 */
311 public BugInstance makeWarning(String bugPattern, FieldOrMethodDescriptor descriptor, int priority) {
312 BugInstance bug = new BugInstance(this, bugPattern, priority).addClass(descriptor.getClassDescriptor());
347 public BugInstance makeWarning(String bugPattern, Object descriptor, int priority, ClassDescriptor cd) {
348 BugInstance bug = new BugInstance(this, bugPattern, priority).addClass(cd);
313349 if (descriptor instanceof FieldDescriptor)
314350 bug.addField((FieldDescriptor)descriptor);
315351 else if (descriptor instanceof MethodDescriptor)
316352 bug.addMethod((MethodDescriptor)descriptor);
353 else if (descriptor instanceof ClassDescriptor)
354 bug.addClass((ClassDescriptor)descriptor);
317355 if (DEBUG)
318356 System.out.println("Reporting " + bug);
319357 return bug;
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2007 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.detect;
20
21 import static edu.umd.cs.findbugs.ba.NullnessAnnotation.CHECK_FOR_NULL;
22 import static edu.umd.cs.findbugs.ba.NullnessAnnotation.NONNULL;
23 import static org.objectweb.asm.Opcodes.ACC_STATIC;
24
25 import java.util.Arrays;
26 import java.util.Collection;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.Iterator;
30 import java.util.LinkedList;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.Queue;
34 import java.util.Set;
35
36 import javax.annotation.CheckForNull;
37 import javax.annotation.Nonnull;
38
39 import org.objectweb.asm.MethodVisitor;
40 import org.objectweb.asm.tree.AnnotationNode;
41 import org.objectweb.asm.tree.LocalVariableNode;
42 import org.objectweb.asm.tree.MethodNode;
43
44 import edu.umd.cs.findbugs.BugInstance;
45 import edu.umd.cs.findbugs.BugReporter;
46 import edu.umd.cs.findbugs.LocalVariableAnnotation;
47 import edu.umd.cs.findbugs.asm.ClassNodeDetector;
48 import edu.umd.cs.findbugs.ba.AnalysisContext;
49 import edu.umd.cs.findbugs.ba.Hierarchy;
50 import edu.umd.cs.findbugs.ba.NullnessAnnotation;
51 import edu.umd.cs.findbugs.ba.NullnessAnnotation.Parser;
52 import edu.umd.cs.findbugs.ba.SignatureParser;
53 import edu.umd.cs.findbugs.ba.XClass;
54 import edu.umd.cs.findbugs.ba.XMethod;
55 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
56 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
57 import edu.umd.cs.findbugs.classfile.Global;
58 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
59 import edu.umd.cs.findbugs.classfile.analysis.AnnotationValue;
60 import edu.umd.cs.findbugs.internalAnnotations.SlashedClassName;
61 import edu.umd.cs.findbugs.util.ClassName;
62
63 /**
64 * Checks that overriding methods do not relax {@link Nonnull} (made
65 * {@link CheckForNull}) on return values or {@link CheckForNull} (made
66 * {@link Nonnull}) on parameters.
67 *
68 * The code accepts also old (deprecated) nullness annotations from
69 * {@link edu.umd.cs.findbugs.annotations} package.
70 *
71 * @author alienisty (Alessandro Nistico)
72 * @author Andrey Loskutov
73 */
74 public class CheckRelaxingNullnessAnnotation extends ClassNodeDetector {
75
76 XClass xclass;
77
78 public CheckRelaxingNullnessAnnotation(BugReporter bugReporter) {
79 super(bugReporter);
80 }
81
82 @Override
83 public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
84 xclass = getClassInfo(classDescriptor);
85 if(xclass != null){
86 super.visitClass(classDescriptor);
87 }
88 }
89
90 @CheckForNull
91 XClass getClassInfo(ClassDescriptor classDescr){
92 if(classDescr == null){
93 return null;
94 }
95 try {
96 return Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescr);
97 } catch (CheckedAnalysisException e) {
98 bugReporter.reportMissingClass(classDescr);
99 return null;
100 }
101 }
102
103 @Override
104 public MethodVisitor visitMethod(int methodAccess, String methodName, String desc, String methodSignature, String[] exceptions) {
105 if ((methodAccess & ACC_STATIC) != 0) {
106 // skip static methods
107 return null;
108 }
109 final XMethod xmethod = xclass.findMethod(methodName, desc, false);
110 if (xmethod == null) {
111 // unable to continue the analysis
112 bugReporter.reportSkippedAnalysis(new MethodDescriptor(xclass.getClassDescriptor().getClassName(), methodName, desc,
113 false));
114 return null;
115 }
116 return new DetectorNode(methodAccess, methodName, desc, methodSignature, exceptions, xmethod);
117 }
118
119 private final class DetectorNode extends MethodNode {
120
121 private final XMethod xmethod;
122
123 private Map<Integer, NullnessAnnotation> nonNullParameter;
124
125 private boolean checkForNullReturn;
126
127 DetectorNode(int access, String name, String desc, String signature, String[] exceptions, XMethod xmethod) {
128 super(access, name, desc, signature, exceptions);
129 this.xmethod = xmethod;
130 }
131
132 @SuppressWarnings("unchecked")
133 @Override
134 public void visitEnd() {
135 super.visitEnd();
136 // 1 test if we have suspicious annotations on method or parameters
137 checkForNullReturn = containsCheckForNull(visibleAnnotations);
138 if(!checkForNullReturn){
139 checkForNullReturn = containsCheckForNull(invisibleAnnotations);
140 }
141 boolean needsCheck = checkForNullReturn;
142 if (invisibleParameterAnnotations != null || visibleParameterAnnotations != null) {
143 nonNullParameter = getNonnullOrNullableParams(visibleParameterAnnotations);
144 Map<Integer, NullnessAnnotation> nnp = getNonnullOrNullableParams(invisibleParameterAnnotations);
145 if (nnp != null) {
146 if (nonNullParameter == null) {
147 nonNullParameter = nnp;
148 } else {
149 nonNullParameter.putAll(nnp);
150 }
151 }
152 needsCheck |= !nonNullParameter.isEmpty();
153 }
154
155 if (!needsCheck) {
156 // we can stop, there is no direct violations due annotations applied on the method.
157 // However it would be nice to flag Bug2672946B violation too (where the entire class
158 // relaxes the parent contract by applying default annotations)
159 return;
160 // If we continue here, we will flag Bug2672946B violation too on method level,
161 // but it would be nice to do it on class or even package level (if package-info.java
162 // has default annotations applied which conflicts with parent class contract)
163 }
164
165 // 2 look in the hierarchy if we have relaxed contract
166 HierarchyIterator hierarchy = new HierarchyIterator(xclass);
167 XClass superClass;
168 boolean done = false;
169 while (!done && (superClass = hierarchy.next()) != null) {
170 XMethod method = superClass.findMethod(name, desc, false);
171 if (method != null) {
172 done = checkMethod(method);
173 } else {
174 for (XMethod superMethod : superClass.getXMethods()) {
175 if (name.equals(superMethod.getName()) && compatibleParameters(desc, superMethod.getSignature())) {
176 if (checkMethod(superMethod)) {
177 done = true;
178 break;
179 }
180 }
181 }
182 }
183 }
184 }
185
186 private final boolean checkMethod(@Nonnull XMethod method) {
187 boolean foundAny = false;
188 if (checkForNullReturn && containsNullness(method.getAnnotations(), NONNULL)) {
189 BugInstance bug = new BugInstance(CheckRelaxingNullnessAnnotation.this, "NP_METHOD_RETURN_RELAXING_ANNOTATION",
190 HIGH_PRIORITY);
191 bug.addClassAndMethod(xmethod);
192 bugReporter.reportBug(bug);
193 foundAny = true;
194 }
195 if (nonNullParameter != null) {
196 for(Map.Entry<Integer, NullnessAnnotation> e : nonNullParameter.entrySet()) {
197 int i = e.getKey();
198 if (containsNullness(method.getParameterAnnotations(i), CHECK_FOR_NULL)) {
199 NullnessAnnotation a = e.getValue();
200 BugInstance bug = new BugInstance(CheckRelaxingNullnessAnnotation.this,
201 "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", a.equals(NONNULL) ? HIGH_PRIORITY : NORMAL_PRIORITY);
202 bug.addClassAndMethod(xmethod);
203 LocalVariableAnnotation lva = null;
204 if (localVariables != null) {
205 for(LocalVariableNode lvn : (List<LocalVariableNode>)localVariables) {
206 if (lvn.index == i+1) {
207 lva = new LocalVariableAnnotation(lvn.name, i+1, 0);
208 lva.setDescription(LocalVariableAnnotation.PARAMETER_NAMED_ROLE);
209 break;
210 }
211 }
212 }
213 if (lva==null) {
214 lva = new LocalVariableAnnotation("?", i+1, 0);
215 lva.setDescription(LocalVariableAnnotation.PARAMETER_ROLE);
216 }
217 bug.add(lva);
218 bugReporter.reportBug(bug);
219 foundAny = true;
220 }
221 }
222
223 }
224 return foundAny;
225 }
226 }
227
228 private class HierarchyIterator {
229 private XClass superclass;
230 private Queue<ClassDescriptor> interfacesToVisit;
231 private final Set<ClassDescriptor> visited;
232
233 public HierarchyIterator(@Nonnull XClass xclass) {
234 interfacesToVisit = new LinkedList<ClassDescriptor>(Arrays.asList(xclass.getInterfaceDescriptorList()));
235 visited = new HashSet<ClassDescriptor>();
236 superclass = getClassInfo(xclass.getSuperclassDescriptor());
237 }
238
239 public XClass next() {
240 while (!interfacesToVisit.isEmpty()) {
241 ClassDescriptor interfaceDescr = interfacesToVisit.poll();
242 if (visited.add(interfaceDescr)) {
243 XClass xinterface = getClassInfo(interfaceDescr);
244 if(xinterface != null){
245 interfacesToVisit.addAll(Arrays.asList(xinterface.getInterfaceDescriptorList()));
246 return xinterface;
247 }
248 }
249 }
250 // no interfaces => check super classes
251 if (superclass == null) {
252 return null;
253 }
254 XClass currentSuperclass = superclass;
255 // compute next one
256 superclass = getClassInfo(superclass.getSuperclassDescriptor());
257 if(superclass != null){
258 interfacesToVisit = new LinkedList<ClassDescriptor>(Arrays.asList(superclass.getInterfaceDescriptorList()));
259 }
260 return currentSuperclass;
261 }
262 }
263
264 static boolean containsCheckForNull(@CheckForNull List<AnnotationNode> methodAnnotations) {
265 if (methodAnnotations == null) {
266 return false;
267 }
268 for (AnnotationNode annotation : methodAnnotations) {
269 NullnessAnnotation nullness = getNullness(annotation.desc);
270 if (nullness == CHECK_FOR_NULL) {
271 return true;
272 }
273 }
274 return false;
275 }
276
277 @CheckForNull
278 static Map<Integer, NullnessAnnotation> getNonnullOrNullableParams(@CheckForNull List<AnnotationNode>[] parameterAnnotations) {
279 if (parameterAnnotations == null) {
280 return null;
281 }
282 Map<Integer, NullnessAnnotation> nonNullParameter = new HashMap<Integer, NullnessAnnotation>();
283 for (int i = 0; i < parameterAnnotations.length; i++) {
284 List<AnnotationNode> annotations = parameterAnnotations[i];
285 if (annotations == null) {
286 continue;
287 }
288 for (AnnotationNode annotation : annotations) {
289 NullnessAnnotation nullness = getNullness(annotation.desc);
290 if (nullness == null || nullness == CHECK_FOR_NULL) {
291 continue;
292 }
293 nonNullParameter.put(i, nullness);
294 }
295 }
296 return nonNullParameter;
297 }
298
299 @CheckForNull
300 static NullnessAnnotation getNullness(@SlashedClassName String annotationDesc) {
301 if (annotationDesc.length() < 2) {
302 return null;
303 }
304 // remove L; from signature
305 String substring = annotationDesc.substring(1, annotationDesc.length() - 1);
306 return Parser.parse(ClassName.toDottedClassName(substring));
307 }
308
309 static boolean containsNullness(Collection<AnnotationValue> annotations, NullnessAnnotation nullness) {
310 for (AnnotationValue annotation : annotations) {
311 NullnessAnnotation check = Parser.parse(annotation.getAnnotationClass().getDottedClassName());
312 if (check == nullness) {
313 return true;
314 }
315 }
316 return false;
317 }
318
319 static boolean compatibleParameters(String signature, String superSignature) {
320 SignatureParser sig = new SignatureParser(signature);
321 SignatureParser superSig = new SignatureParser(superSignature);
322 if (sig.getNumParameters() == superSig.getNumParameters()) {
323 Iterator<String> params = sig.parameterSignatureIterator();
324 Iterator<String> superParams = superSig.parameterSignatureIterator();
325 while (params.hasNext()) {
326 String param = params.next();
327 String superParam = superParams.next();
328 if (areRelated(param, superParam)) {
329 continue;
330 }
331 return false;
332 }
333 String retSig = sig.getReturnTypeSignature();
334 String superRetSig = superSig.getReturnTypeSignature();
335 if (areRelated(retSig, superRetSig)) {
336 // it is compatible
337 return true;
338 }
339 }
340 return false;
341 }
342
343 static boolean areRelated(String sig, String superSig) {
344 try {
345 if (sig.equals(superSig)) {
346 return true;
347 }
348 if (sig.charAt(0) == 'L' && superSig.charAt(0) == 'L') {
349 sig = sig.substring(1, sig.length() - 1);
350 superSig = superSig.substring(1, superSig.length() - 1);
351 return Hierarchy.isSubtype(sig, superSig);
352 }
353 } catch (ClassNotFoundException e) {
354 AnalysisContext.reportMissingClass(e);
355 }
356 return false;
357 }
358 }
6868 import edu.umd.cs.findbugs.ba.jsr305.TypeQualifierValue;
6969 import edu.umd.cs.findbugs.ba.jsr305.TypeQualifierValueSet;
7070 import edu.umd.cs.findbugs.ba.vna.ValueNumber;
71 import edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis;
7172 import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow;
7273 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
7374 import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
220221 System.out.println("----------------------------------------------------------------------");
221222 }
222223
224 if (DEBUG_DATAFLOW) {
225 System.out.println("********* Valuenumber analysis *********");
226 DataflowCFGPrinter<ValueNumberFrame, ValueNumberAnalysis> p = new DataflowCFGPrinter<ValueNumberFrame, ValueNumberAnalysis>(vnaDataflow);
227 p.print(System.out);
228 }
229
223230 ForwardTypeQualifierDataflow forwardDataflow = forwardDataflowFactory.getDataflow(typeQualifierValue);
224231
225232 if (DEBUG_DATAFLOW && (DEBUG_DATAFLOW_MODE.startsWith("forward") || DEBUG_DATAFLOW_MODE.equals("both"))) {
302309 }
303310 }
304311
305 /**
306 * @param methodDescriptor2
307 * @param cfg2
308 * @param typeQualifierValue
309 * @param forwardsFact
310 * @param loc
311 * @param factAtLocation
312 * @throws DataflowAnalysisException
313 */
312
314313 private void checkForEqualityTest(XMethod xmethod, CFG cfg, TypeQualifierValue typeQualifierValue,
315314 TypeQualifierValueSet forwardsFact, Location loc, ValueNumberFrame factAtLocation) throws DataflowAnalysisException {
316315 InstructionHandle handle = loc.getHandle();
592591 Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
593592 LocalVariableAnnotation lva = LocalVariableAnnotation.getParameterLocalVariableAnnotation(method,
594593 sourceSinkInfo.getLocal());
595 lva.setDescription(lva.isSignificant() ? "LOCAL_VARIABLE_PARAMETER_VALUE_SOURCE_NAMED"
596 : "LOCAL_VARIABLE_PARAMETER_VALUE_SOURCE");
594 lva.setDescription(lva.isSignificant() ? LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_NAMED_ROLE
595 : LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_ROLE);
596
597597 warning.add(lva);
598598 } catch (CheckedAnalysisException e) {
599599 warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
3737 import edu.umd.cs.findbugs.ba.PruneUnconditionalExceptionThrowerEdges;
3838 import edu.umd.cs.findbugs.ba.XFactory;
3939 import edu.umd.cs.findbugs.ba.ch.Subtypes2;
40 import edu.umd.cs.findbugs.bcel.BCELUtil;
4041 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
4142 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
4243 import edu.umd.cs.findbugs.visitclass.DismantleBytecode;
184185
185186 @Override
186187 public void visit(Method obj) {
187 if (obj.isAbstract() || obj.isSynthetic())
188 if (obj.isAbstract() || BCELUtil.isSynthetic(obj))
188189 return;
189190 if (!obj.isPublic())
190191 return;
2828 import edu.umd.cs.findbugs.BytecodeScanningDetector;
2929 import edu.umd.cs.findbugs.ba.XFactory;
3030 import edu.umd.cs.findbugs.ba.XMethod;
31 import edu.umd.cs.findbugs.bcel.BCELUtil;
3132
3233 public class ConfusionBetweenInheritedAndOuterMethod extends BytecodeScanningDetector {
3334
3940
4041 @Override
4142 public void visitJavaClass(JavaClass obj) {
42 hasThisDollarZero = false;
43 isInnerClass = false;
4344 // totally skip methods not defined in inner classes
4445 if (obj.getClassName().indexOf('$') >= 0) {
4546 super.visitJavaClass(obj);
4849
4950 }
5051
51 boolean hasThisDollarZero;
52 boolean isInnerClass;
5253
5354 @Override
5455 public void visit(Field f) {
55 if (f.getName().equals("this$0")) {
56 hasThisDollarZero = true;
56 if (f.getName().startsWith("this$")) {
57 isInnerClass = true;
5758 }
5859 }
5960
6061 @Override
6162 public void visit(Code obj) {
62 if (hasThisDollarZero) {
63 if (isInnerClass && !BCELUtil.isSynthetic(getMethod())) {
64 // System.out.println(getFullyQualifiedMethodName());
6365 super.visit(obj);
6466 }
6567 }
6668
6769 @Override
6870 public void sawOpcode(int seen) {
71 // System.out.printf("%3d : %s%n", getPC(), OPCODE_NAMES[seen]);
6972 if (seen != INVOKEVIRTUAL) {
7073 return;
7174 }
7477 }
7578 XMethod invokedMethod = XFactory.createXMethod(getDottedClassConstantOperand(), getNameConstantOperand(),
7679 getSigConstantOperand(), false);
77 if (invokedMethod.isResolved() && invokedMethod.getClassName().equals(getDottedClassConstantOperand())) {
78 // method is not inherited
80 if (invokedMethod.isResolved() && invokedMethod.getClassName().equals(getDottedClassConstantOperand())
81 || invokedMethod.isSynthetic()) {
7982 return;
8083 }
8184 // method is inherited
106109 priority++;
107110 }
108111
112 // System.out.println("Found it");
109113 bugAccumulator.accumulateBug(
110114 new BugInstance(this, "IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD", priority)
111115 .addClassAndMethod(this).addMethod(invokedMethod).describe("METHOD_INHERITED")
4545 /** The dead store is an increment. */
4646 public static final DeadLocalStoreProperty DEAD_INCREMENT = new DeadLocalStoreProperty("DEAD_INCREMENT",
4747 PriorityAdjustment.LOWER_PRIORITY);
48 public static final DeadLocalStoreProperty DEAD_INCREMENT_IN_RETURN = new DeadLocalStoreProperty("DEAD_INCREMENT_IN_RETURN",
49 PriorityAdjustment.NO_ADJUSTMENT);
4850
4951 public static final DeadLocalStoreProperty DEAD_INCREMENT_IN_MAIN = new DeadLocalStoreProperty("DEAD_INCREMENT",
5052 PriorityAdjustment.AT_MOST_LOW);
6767 import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow;
6868 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
6969 import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
70 import edu.umd.cs.findbugs.bcel.BCELUtil;
7071 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
7172 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
7273 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
132133
133134 final static boolean DEBUG = false;
134135
136 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
135137 static HashSet<String> immutableClassNames = new HashSet<String>();
136138 static {
137139 immutableClassNames.add("java/lang/Integer");
191193 }
192194
193195 private void analyzeMethod(ClassContext classContext, Method method) throws DataflowAnalysisException, CFGBuilderException {
194 if (method.isSynthetic() || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
196 if (BCELUtil.isSynthetic(method) || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
195197 return;
196198
197199 if (DEBUG) {
6464 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
6565 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
6666 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
67 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
6768 import edu.umd.cs.findbugs.util.ClassName;
6869 import edu.umd.cs.findbugs.util.Util;
6970 import edu.umd.cs.findbugs.visitclass.PreorderVisitor;
190191 sinceBufferedInputStreamReady = 100000;
191192 sawCheckForNonNegativeSignedByte = -1000;
192193 sawLoadOfMinValue = false;
194 previousMethodCall = null;
193195
194196 }
195197
205207
206208 boolean sawLoadOfMinValue = false;
207209
210 MethodDescriptor previousMethodCall = null;
208211
209212 @Override
210213 public void sawOpcode(int seen) {
211 // System.out.printf("%3d %12s %s%n", getPC(), OPCODE_NAMES[seen],
212 // stack);
214
215 if (isMethodCall()) {
216 MethodDescriptor called = getMethodDescriptorOperand();
217
218 if (previousMethodCall != null && !stack.isJumpTarget(getPC())) {
219 if (called.getName().equals("toString")
220 && called.getClassDescriptor().getClassName().equals("java/lang/Integer")
221 && previousMethodCall.getName().equals("valueOf")
222 && previousMethodCall.getSignature().equals("(I)Ljava/lang/Integer;")
223 ) {
224 MethodAnnotation preferred = new MethodAnnotation("java.lang.Integer", "toString", "(I)Ljava/lang/String;", true);
225 BugInstance bug = new BugInstance(this, "DM_BOXED_PRIMITIVE_TOSTRING", HIGH_PRIORITY).addClassAndMethod(this)
226 .addCalledMethod(this).addMethod(preferred).describe(MethodAnnotation.SHOULD_CALL);
227 accumulator.accumulateBug(bug, this);
228
229 } else if (called.getName().equals("intValue")
230 && called.getClassDescriptor().getClassName().equals("java/lang/Integer")
231 && previousMethodCall.getSlashedClassName().equals("java/lang/Integer")
232 && (previousMethodCall.getName().equals("<init>")
233 && previousMethodCall.getSignature().equals("(Ljava/lang/String;)V")
234 || previousMethodCall.getName().equals("valueOf")
235 && previousMethodCall.getSignature().equals("(Ljava/lang/String;)Ljava/lang/Integer;")
236 )) {
237
238 MethodAnnotation preferred = new MethodAnnotation("java.lang.Integer", "parseInt", "(Ljava/lang/String;)I", true);
239
240 BugInstance bug = new BugInstance(this, "DM_BOXED_PRIMITIVE_FOR_PARSING", HIGH_PRIORITY).addClassAndMethod(this)
241 .addCalledMethod(this).addMethod(preferred).describe(MethodAnnotation.SHOULD_CALL);
242 accumulator.accumulateBug(bug, this);
243 } else if (called.getName().equals("longValue")
244 && called.getClassDescriptor().getClassName().equals("java/lang/Long")
245 && previousMethodCall.getSlashedClassName().equals("java/lang/Long")
246 && ( previousMethodCall.getName().equals("<init>")
247 && previousMethodCall.getSignature().equals("(Ljava/lang/String;)V")
248 || previousMethodCall.getName().equals("valueOf")
249 && previousMethodCall.getSignature().equals("(Ljava/lang/String;)Ljava/lang/Long;"))
250 ) {
251 MethodAnnotation preferred = new MethodAnnotation("java.lang.Long", "parseLong", "(Ljava/lang/String;)J", true);
252
253 BugInstance bug = new BugInstance(this, "DM_BOXED_PRIMITIVE_FOR_PARSING", HIGH_PRIORITY).addClassAndMethod(this)
254 .addCalledMethod(this).addMethod(preferred).describe(MethodAnnotation.SHOULD_CALL);
255 accumulator.accumulateBug(bug, this);
256 }
257 }
258 previousMethodCall = called;
259 } else
260 previousMethodCall = null;
261
213262
214263 if (seen == LDC || seen == LDC_W || seen == LDC2_W) {
215264 Constant c = getConstantRefOperand();
310359
311360 if (seen == INVOKESTATIC && (getClassConstantOperand().equals("com/google/common/base/Preconditions")
312361 && getNameConstantOperand().equals("checkNotNull")
313 || getClassConstantOperand().equals("com/google/common/base/Strings")
362 || getClassConstantOperand().equals("com/google/common/base/Strings")
314363 && (getNameConstantOperand().equals("nullToEmpty") ||
315 getNameConstantOperand().equals("emptyToNull") ||
364 getNameConstantOperand().equals("emptyToNull") ||
316365 getNameConstantOperand().equals("isNullOrEmpty")))
317366 ) {
318367 int args = PreorderVisitor.getNumberArguments(getSigConstantOperand());
509558
510559 }
511560
512 if (!sawLoadOfMinValue && seen == INVOKESTATIC &&
561 if (!sawLoadOfMinValue && seen == INVOKESTATIC &&
513562 ClassName.isMathClass(getClassConstantOperand()) && getNameConstantOperand().equals("abs")
514563 ) {
515564 OpcodeStack.Item item0 = stack.getStackItem(0);
923972 if ((seen == INVOKESPECIAL) && getNameConstantOperand().equals("<init>")) {
924973 String cls = getClassConstantOperand();
925974 String sig = getSigConstantOperand();
926 if ((cls.equals("java/lang/Integer") && sig.equals("(I)V"))
927 || (cls.equals("java/lang/Float") && sig.equals("(F)V"))
928 || (cls.equals("java/lang/Double") && sig.equals("(D)V"))
929 || (cls.equals("java/lang/Long") && sig.equals("(J)V"))
930 || (cls.equals("java/lang/Byte") && sig.equals("(B)V"))
931 || (cls.equals("java/lang/Character") && sig.equals("(C)V"))
932 || (cls.equals("java/lang/Short") && sig.equals("(S)V"))
933 || (cls.equals("java/lang/Boolean") && sig.equals("(Z)V"))) {
975 String primitiveType = ClassName.getPrimitiveType(cls);
976 if (primitiveType != null && sig.charAt(1) == primitiveType.charAt(0)) {
934977 primitiveObjCtorSeen = cls;
935978 } else {
936979 primitiveObjCtorSeen = null;
938981 } else if ((primitiveObjCtorSeen != null) && (seen == INVOKEVIRTUAL) && getNameConstantOperand().equals("toString")
939982 && getClassConstantOperand().equals(primitiveObjCtorSeen)
940983 && getSigConstantOperand().equals("()Ljava/lang/String;")) {
984 BugInstance bug = new BugInstance(this, "DM_BOXED_PRIMITIVE_TOSTRING", NORMAL_PRIORITY).addClassAndMethod(this).addCalledMethod(this);
985 MethodAnnotation preferred = new MethodAnnotation(ClassName.toDottedClassName(primitiveObjCtorSeen),
986 "toString", "("+ClassName.getPrimitiveType(primitiveObjCtorSeen)+")Ljava/lang/String;", true);
987 bug.addMethod(preferred).describe(MethodAnnotation.SHOULD_CALL);
941988 accumulator.accumulateBug(
942 new BugInstance(this, "DM_BOXED_PRIMITIVE_TOSTRING", LOW_PRIORITY).addClassAndMethod(this), this);
989 bug, this);
943990
944991 primitiveObjCtorSeen = null;
945992 } else {
950997 ctorSeen = true;
951998 } else if (ctorSeen && (seen == INVOKEVIRTUAL) && getClassConstantOperand().equals("java/lang/Object")
952999 && getNameConstantOperand().equals("getClass") && getSigConstantOperand().equals("()Ljava/lang/Class;")) {
953 accumulator.accumulateBug(new BugInstance(this, "DM_NEW_FOR_GETCLASS", LOW_PRIORITY).addClassAndMethod(this),
1000 accumulator.accumulateBug(new BugInstance(this, "DM_NEW_FOR_GETCLASS", NORMAL_PRIORITY).addClassAndMethod(this),
9541001 this);
9551002 ctorSeen = false;
9561003 } else {
2626 import edu.umd.cs.findbugs.BytecodeScanningDetector;
2727 import edu.umd.cs.findbugs.StatelessDetector;
2828
29 /**
30 * This detector is currently disabled by default.
31 * It generates false positives when creating directory entries.
32 *
33 */
2934 public class EmptyZipFileEntry extends BytecodeScanningDetector implements StatelessDetector {
3035
31 private BugReporter bugReporter;
36 private final BugReporter bugReporter;
3237
3338 private int sawPutEntry;
3439
1010
1111 import org.apache.bcel.Constants;
1212 import org.apache.bcel.Repository;
13 import org.apache.bcel.classfile.Attribute;
1413 import org.apache.bcel.classfile.ConstantClass;
1514 import org.apache.bcel.classfile.JavaClass;
1615 import org.apache.bcel.classfile.LineNumberTable;
1716 import org.apache.bcel.classfile.Method;
18 import org.apache.bcel.classfile.Synthetic;
1917 import org.apache.bcel.generic.CHECKCAST;
2018 import org.apache.bcel.generic.ConstantPoolGen;
2119 import org.apache.bcel.generic.INSTANCEOF;
5856 import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow;
5957 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
6058 import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
59 import edu.umd.cs.findbugs.bcel.BCELUtil;
6160 import edu.umd.cs.findbugs.util.ClassName;
61 import edu.umd.cs.findbugs.visitclass.Util;
6262
6363 public class FindBadCast2 implements Detector {
6464
124124 return bytecodeSet != null && (bytecodeSet.get(Constants.CHECKCAST) || bytecodeSet.get(Constants.INSTANCEOF));
125125 }
126126
127 private boolean isSynthetic(Method m) {
128 if (m.isSynthetic())
129 return true;
130 Attribute[] attrs = m.getAttributes();
131 for (Attribute attr : attrs) {
132 if (attr instanceof Synthetic)
133 return true;
134 }
135 return false;
136 }
137
138127 private Set<ValueNumber> getParameterValueNumbers(ClassContext classContext, Method method, CFG cfg)
139128 throws DataflowAnalysisException, CFGBuilderException {
140129 ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
148137 }
149138
150139 private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
151 if (isSynthetic(method) || !prescreen(classContext, method))
140 if (BCELUtil.isSynthetic(method) || !prescreen(classContext, method))
152141 return;
153142 BugAccumulator accumulator = new BugAccumulator(bugReporter);
154143
177166 Location location = i.next();
178167 InstructionHandle handle = location.getHandle();
179168 Instruction ins = handle.getInstruction();
180
169
181170 if (!(ins instanceof CHECKCAST) && !(ins instanceof INSTANCEOF))
182171 continue;
183172
202191 Map<BugAnnotation, String> instanceOfChecks = new HashMap<BugAnnotation, String>();
203192 String constantClass = null;
204193 boolean methodInvocationWasGeneric = false;
205
194
206195 int pcForConstantClass = -1;
207196 for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
208197 Location location = i.next();
224213 System.out.println(m + " has source signature " + sourceSignature);
225214 }
226215 }
227
216
228217 }
229218 if (ins instanceof LDC) {
230219 LDC ldc = (LDC) ins;
232221 if (value instanceof ConstantClass) {
233222 ConstantClass cc = (ConstantClass) value;
234223 constantClass = cc.getBytes(classContext.getJavaClass().getConstantPool());
235 pcForConstantClass = pc;
224 pcForConstantClass = pc;
236225 }
237226 }
238227
240229 continue;
241230
242231 boolean isCast = ins instanceof CHECKCAST;
243 String kind = isCast ? "checkedCast" : "instanceof";
244232 int occurrences = cfg.getLocationsContainingInstructionWithOffset(pc).size();
245233 boolean split = occurrences > 1;
246234 if (lineNumberTable != null) {
254242 continue;
255243 IsNullValue operandNullness = nullFrame.getTopValue();
256244 if (DEBUG) {
245 String kind = isCast ? "checkedCast" : "instanceof";
257246 System.out.println(kind + " at pc: " + pc + " in " + methodName);
258247 System.out.println(" occurrences: " + occurrences);
259248 System.out.println("XXX: " + operandNullness);
260
261 }
262
263
249 }
250
264251 if (split && !isCast) {
265252 // don't report this case; it might be infeasible due to
266253 // inlining
279266 continue;
280267 }
281268 boolean operandTypeIsExact = frame.isExact(frame.getStackLocation(0));
282 Type castType = ((TypedInstruction) ins).getType(cpg);
269 final Type castType = ((TypedInstruction) ins).getType(cpg);
283270
284271 if (!(castType instanceof ReferenceType)) {
285272 // This shouldn't happen either
301288 // Shouldn't happen - illegal bytecode
302289 continue;
303290 }
304 ReferenceType refType = (ReferenceType) operandType;
291 final ReferenceType refType = (ReferenceType) operandType;
305292 boolean impliesByGenerics = typeDataflow.getAnalysis().isImpliedByGenericTypes(refType);
306293
307294 if (impliesByGenerics && !isCast)
308295 continue;
309296
310 if (isCast && refType.equals(castType)) {
297 final boolean typesAreEqual = refType.equals(castType);
298 if (isCast && typesAreEqual) {
311299 // System.out.println("self-cast to " +
312300 // castType.getSignature());
313301 continue;
336324 int priority = HIGH_PRIORITY;
337325 if (split && (castSig2.endsWith("Error;") || castSig2.endsWith("Exception;")))
338326 priority = LOW_PRIORITY;
339
340 bugReporter.reportBug(new BugInstance(this, isCast ? "BC_IMPOSSIBLE_CAST" : "BC_IMPOSSIBLE_INSTANCEOF", priority)
327 // report bug only if types are not equal, see bug 3598482
328 if(!typesAreEqual){
329 bugReporter.reportBug(new BugInstance(this, isCast ? "BC_IMPOSSIBLE_CAST" : "BC_IMPOSSIBLE_INSTANCEOF", priority)
341330 .addClassAndMethod(methodGen, sourceFile).addFoundAndExpectedType(refType, castType)
342331 .addSourceLine(sourceLineAnnotation));
332 }
343333 continue;
344334 }
345335
364354 "VALUE_OF");
365355 BugAnnotation source = BugInstance.getSourceForTopStackValue(classContext, method, location);
366356 boolean isParameter = paramValueNumberSet.contains(valueNumber) && source instanceof LocalVariableAnnotation;
367
357
368358 try {
369359 JavaClass castJavaClass = Repository.lookupClass(castName);
370360 JavaClass refJavaClass = Repository.lookupClass(refName);
371361
372362 boolean upcast = Repository.instanceOf(refJavaClass, castJavaClass);
373 if (upcast || refType.equals(castType)) {
363 if (upcast || typesAreEqual) {
374364 if (!isCast)
375365 accumulator.accumulateBug(new BugInstance(this, "BC_VACUOUS_INSTANCEOF", NORMAL_PRIORITY)
376366 .addClassAndMethod(methodGen, sourceFile).addFoundAndExpectedType(refType, castType),
386376 && abstractCollectionClasses.contains(refName);
387377 boolean castToAbstractCollection = abstractCollectionClasses.contains(castName)
388378 && veryAbstractCollectionClasses.contains(refName);
379 int position = location.getHandle().getPosition();
380 int catchSize = Util.getSizeOfSurroundingTryBlock(classContext.getJavaClass().getConstantPool(), method.getCode(),
381 "java/lang/ClassCastException", position);
382
383
389384
390385 if (!operandTypeIsExact) {
391386 rank = Analyze.deepInstanceOf(refJavaClass, castJavaClass);
411406 System.out.println(" isParameter: " + valueNumber);
412407 System.out.println(" score: " + rank);
413408 System.out.println(" source is: " + valueSource);
409 if (catchSize < Integer.MAX_VALUE)
410 System.out.println(" catch block size is: " + catchSize);
414411 if (constantClass != null)
415412 System.out.println(" constant class " + constantClass + " at " + pcForConstantClass);
416413 if (handle.getPrev() == null)
444441 .addClassAndMethod(methodGen, sourceFile)
445442 .addFoundAndExpectedType(refType, castType).addOptionalUniqueAnnotations(valueSource, source)
446443 .addSourceLine(sourceLineAnnotation));
447 } else if (isCast && rank < 0.9
444 } else if (isCast && rank < 0.9
448445 && !valueNumber.hasFlag(ValueNumber.ARRAY_VALUE)) {
449446
450447 int priority = NORMAL_PRIORITY;
454451 System.out.println("Old check: " + oldCheck);
455452 }
456453 if (castName.equals(oldCheck)) {
457 priority += 1;
454 priority += 1;
458455 } else if ("".equals(oldCheck)) {
459456 priority += 1;
460457 if (!(source instanceof LocalVariableAnnotation)) continue;
461458 }
462
459
463460 if (rank > 0.75)
464461 priority += 2;
465462 else if (rank > 0.5)
468465 priority += 0;
469466 else
470467 priority--;
468
469
471470
472471 if (DEBUG)
473472 System.out.println(" priority a: " + priority);
507506 if (xm != null && (xm.isPrivate() || xm.isStatic()) && priority == Priorities.LOW_PRIORITY)
508507 continue;
509508 }
510
509
511510 if (valueNumber.hasFlag(ValueNumber.RETURN_VALUE) && priority < Priorities.LOW_PRIORITY)
512511 priority = Priorities.LOW_PRIORITY;
513512 if (DEBUG)
514513 System.out.println(" priority g: " + priority);
515
514
516515 if (DEBUG)
517516 System.out.println(" priority h: " + priority);
517
518 if (catchSize < 15)
519 return;
520 if (catchSize < 25)
521 priority++;
522 if (DEBUG)
523 System.out.println(" priority i: " + priority);
524
525
518526 if (priority < HIGH_PRIORITY)
519527 priority = HIGH_PRIORITY;
520528 if (priority <= LOW_PRIORITY) {
6262 if (clsName.startsWith(refClsName) && (refClsName.indexOf("$") >= 0))
6363 return;
6464
65 if (refClsName.startsWith(refClsName) && (clsName.indexOf("$") >= 0))
65 if (refClsName.startsWith(clsName) && (clsName.indexOf("$") >= 0))
6666 return;
6767
6868 Set<String> dependencies = dependencyGraph.get(clsName);
4343 import org.apache.bcel.generic.GETSTATIC;
4444 import org.apache.bcel.generic.IINC;
4545 import org.apache.bcel.generic.INVOKESPECIAL;
46 import org.apache.bcel.generic.IRETURN;
4647 import org.apache.bcel.generic.IndexedInstruction;
4748 import org.apache.bcel.generic.Instruction;
4849 import org.apache.bcel.generic.InstructionHandle;
7778 import edu.umd.cs.findbugs.ba.ch.Subtypes2;
7879 import edu.umd.cs.findbugs.ba.type.TypeDataflow;
7980 import edu.umd.cs.findbugs.ba.type.TypeFrame;
80 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
81 import edu.umd.cs.findbugs.bcel.BCELUtil;
82 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
8183 import edu.umd.cs.findbugs.props.WarningProperty;
8284 import edu.umd.cs.findbugs.props.WarningPropertySet;
8385 import edu.umd.cs.findbugs.props.WarningPropertyUtil;
8688
8789 /**
8890 * Find dead stores to local variables.
89 *
91 *
9092 * @author David Hovemeyer
9193 * @author Bill Pugh
9294 */
100102 private static final String FINDBUGS_EXCLUDED_LOCALS_PROP_NAME = "findbugs.dls.exclusions";
101103
102104 // Define a collection of excluded local variables...
105 @StaticConstant
103106 private static final Set<String> EXCLUDED_LOCALS = new HashSet<String>();
104107
105108 private static final boolean DO_EXCLUDE_LOCALS = SystemProperties.getProperty(FINDBUGS_EXCLUDED_LOCALS_PROP_NAME) != null;
155158 defensiveConstantValueOpcodes.set(Constants.LDC2_W);
156159 }
157160
158 private BugReporter bugReporter;
161 private final BugReporter bugReporter;
159162
160163 public FindDeadLocalStores(BugReporter bugReporter) {
161164 this.bugReporter = bugReporter;
191194 }
192195
193196 private void analyzeMethod(ClassContext classContext, Method method) throws DataflowAnalysisException, CFGBuilderException {
194 if (method.isSynthetic() || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
197 if (BCELUtil.isSynthetic(method) || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
195198 return;
196199
197200 if (DEBUG) {
448451 && method.getSignature().equals("([Ljava/lang/String;)V"))
449452 propertySet.addProperty(DeadLocalStoreProperty.DEAD_INCREMENT_IN_MAIN);
450453
451 propertySet.addProperty(DeadLocalStoreProperty.DEAD_INCREMENT);
454 InstructionHandle next = location.getHandle().getNext();
455 if (next != null && next.getInstruction() instanceof IRETURN)
456 propertySet.addProperty(DeadLocalStoreProperty.DEAD_INCREMENT_IN_RETURN);
457 else
458 propertySet.addProperty(DeadLocalStoreProperty.DEAD_INCREMENT);
452459 if (localIncrementCount[local] == 1) {
453460 propertySet.addProperty(DeadLocalStoreProperty.SINGLE_DEAD_INCREMENT);
454461 } else
507514 String sourceFile = javaClass.getSourceFileName();
508515 if (Subtypes2.isJSP(javaClass))
509516 propertySet.addProperty(DeadLocalStoreProperty.IN_JSP_PAGE);
510 else if (javaClass.isSynthetic() || sourceFile != null && !sourceFile.endsWith(".java")) {
511 if (sourceFile.endsWith(".gxp") && (lvName.startsWith("gxp$") || lvName.startsWith("gxp_")))
517 else if (BCELUtil.isSynthetic(javaClass) || sourceFile != null && !sourceFile.endsWith(".java")) {
518 if (sourceFile != null && sourceFile.endsWith(".gxp") && (lvName.startsWith("gxp$") || lvName.startsWith("gxp_")))
512519 continue;
513520 propertySet.addProperty(DeadLocalStoreProperty.NOT_JAVA);
514521 }
519526 bugPattern = "DLS_DEAD_LOCAL_STORE_OF_NULL";
520527 else if (shadowedField != null)
521528 bugPattern = "DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD";
529 else if (propertySet.containsProperty(DeadLocalStoreProperty.DEAD_INCREMENT_IN_RETURN))
530 bugPattern = "DLS_DEAD_LOCAL_INCREMENT_IN_RETURN";
522531 else
523532 bugPattern = "DLS_DEAD_LOCAL_STORE";
524533 BugInstance bugInstance = new BugInstance(this, bugPattern, NORMAL_PRIORITY).addClassAndMethod(methodGen,
558567 /**
559568 * If feature is enabled, suppress warnings where there is at least one live
560569 * store on the line where the warning would be reported.
561 *
570 *
562571 * @param accumulator
563572 * BugAccumulator containing warnings for method
564573 * @param liveStoreSourceLineSet
587596 /**
588597 * Count stores, loads, and increments of local variables in method whose
589598 * CFG is given.
590 *
599 *
591600 * @param localStoreCount
592601 * counts of local stores (indexed by local)
593602 * @param localLoadCount
626635 /**
627636 * Get the name of given local variable (if possible) and store it in the
628637 * HeuristicPropertySet.
629 *
638 *
630639 * @param lvt
631640 * the LocalVariableTable
632641 * @param local
648657
649658 /**
650659 * Is instruction at given location a store?
651 *
660 *
652661 * @param location
653662 * the location
654663 * @return true if instruction at given location is a store, false if not
660669
661670 /**
662671 * Is instruction at given location a load?
663 *
672 *
664673 * @param location
665674 * the location
666675 * @return true if instruction at given location is a load, false if not
2828 import edu.umd.cs.findbugs.LocalVariableAnnotation;
2929 import edu.umd.cs.findbugs.OpcodeStack;
3030 import edu.umd.cs.findbugs.OpcodeStack.Item;
31 import edu.umd.cs.findbugs.Priorities;
3132 import edu.umd.cs.findbugs.StatelessDetector;
33 import edu.umd.cs.findbugs.SystemProperties;
3234 import edu.umd.cs.findbugs.ba.XField;
3335 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
3436
3537 public class FindFieldSelfAssignment extends OpcodeStackDetector implements StatelessDetector {
3638 private final BugReporter bugReporter;
3739
40 private static final boolean DEBUG = SystemProperties.getBoolean("fsa.debug");
3841 int state;
3942
4043 public FindFieldSelfAssignment(BugReporter bugReporter) {
4346
4447 @Override
4548 public void visit(Code obj) {
46 // System.out.println(getFullyQualifiedMethodName());
4749 state = 0;
50 lastMethodCall = -1;
51
52 if (DEBUG)
53 System.out.println(getXMethod());
4854 super.visit(obj);
55 possibleOverwrite = null;
56 if (DEBUG)
57 System.out.println();
4958 initializedFields.clear();
5059 }
5160
5261 int register;
5362
63 int lastMethodCall;
5464 Set<String> initializedFields = new HashSet<String>();
5565
66 XField possibleOverwrite;
5667 @Override
5768 public void sawOpcode(int seen) {
58 // System.out.printf("%5d %12s %s%n", getPC(), OPCODE_NAMES[seen],stack);
69
70 if (DEBUG)
71 System.out.printf("%5d %12s %s%n", getPC(), OPCODE_NAMES[seen],stack);
5972 if (seen == PUTFIELD) {
6073 OpcodeStack.Item top = stack.getStackItem(0);
6174 OpcodeStack.Item next = stack.getStackItem(1);
6275
76 if (possibleOverwrite != null && possibleOverwrite.equals(getXFieldOperand())) {
77 bugReporter.reportBug(new BugInstance(this, "SA_FIELD_SELF_ASSIGNMENT", Priorities.HIGH_PRIORITY).addClassAndMethod(this)
78 .addReferencedField(this).addSourceLine(this));
79
80 }
81 possibleOverwrite = null;
82
83 if (stack.getStackDepth() >= 4 && getNextOpcode() == PUTFIELD) {
84 OpcodeStack.Item third = stack.getStackItem(2);
85 OpcodeStack.Item fourth = stack.getStackItem(3);
86 XField f2 = third.getXField();
87 int registerNumber2 = fourth.getRegisterNumber();
88 if (f2 != null && f2.equals(getXFieldOperand()) && registerNumber2 >= 0
89 && registerNumber2 == third.getFieldLoadedFromRegister()
90 && !third.equals(top) && (third.getPC() == -1 || third.getPC() > lastMethodCall)) {
91 possibleOverwrite = f2;
92 }
93 }
94
6395 XField f = top.getXField();
6496 int registerNumber = next.getRegisterNumber();
6597 if (f != null && f.equals(getXFieldOperand()) && registerNumber >= 0
66 && registerNumber == top.getFieldLoadedFromRegister()) {
98 && registerNumber == top.getFieldLoadedFromRegister() && (top.getPC() == -1 || top.getPC() > lastMethodCall)) {
6799 int priority = NORMAL_PRIORITY;
68100
69101 LocalVariableAnnotation possibleMatch = LocalVariableAnnotation.findMatchingIgnoredParameter(getClassContext(),
70102 getMethod(), getNameConstantOperand(), getSigConstantOperand());
71103 if (possibleMatch != null)
72104 priority--;
73 else
105 else
74106 possibleMatch = LocalVariableAnnotation.findUniqueBestMatchingParameter(getClassContext(), getMethod(),
75107 getNameConstantOperand(), getSigConstantOperand());
76108 if (possibleMatch == null) {
89121 .addReferencedField(this).addOptionalAnnotation(possibleMatch).addSourceLine(this));
90122
91123 }
92 }
124 } else
125 possibleOverwrite = null;
126 if (isMethodCall())
127 lastMethodCall = getPC();
93128 switch (state) {
94129 case 0:
95130 if (seen == DUP)
4747 import edu.umd.cs.findbugs.ba.XClass;
4848 import edu.umd.cs.findbugs.ba.XMethod;
4949 import edu.umd.cs.findbugs.ba.ch.Subtypes2;
50 import edu.umd.cs.findbugs.bcel.BCELUtil;
5051 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
5152 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
5253 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
342343 int accessFlags = obj.getAccessFlags();
343344 if ((accessFlags & ACC_STATIC) != 0)
344345 return;
345 if (!obj.getName().startsWith("this$") && !obj.isSynthetic() && !obj.isTransient())
346 if (!obj.getName().startsWith("this$") && !BCELUtil.isSynthetic(obj) && !obj.isTransient())
346347 hasFields = true;
347348 }
348349
432433 }
433434 } else if (name.equals("compareTo") && sig.endsWith(")I") && !obj.isStatic()) {
434435 MethodAnnotation tmp = MethodAnnotation.fromVisitedMethod(this);
435 if (obj.isSynthetic())
436 if (BCELUtil.isSynthetic(obj))
436437 hasCompareToBridgeMethod = true;
437438 if (sig.equals("(Ljava/lang/Object;)I")) {
438439 hasCompareToObject = true;
3030 import java.util.Set;
3131
3232 import org.apache.bcel.Constants;
33 import org.apache.bcel.classfile.ElementValue;
3334 import org.apache.bcel.classfile.Field;
3435 import org.apache.bcel.classfile.JavaClass;
3536 import org.apache.bcel.classfile.Method;
221222 * lock held.
222223 */
223224 private static class FieldStats {
224 private final XField field;
225225
226226 private final int[] countList = new int[6];
227227
238238 final boolean servletField;
239239
240240 FieldStats(XField field) {
241 this.field = field;
242241 servletField = FindInconsistentSync2.isServletField(field);
243242 }
244243
366365 bugReporter.logError("Error finding locked call sites", e);
367366 return;
368367 }
369
370
368
369
371370 for (Method method : allMethods) {
372371 if (DEBUG)
373372 System.out.println("******** considering method " + method.getName());
412411 }
413412
414413 public void report() {
414 if(statMap.isEmpty()){
415 return;
416 }
417 JCIPAnnotationDatabase jcipAnotationDatabase = AnalysisContext.currentAnalysisContext().getJCIPAnnotationDatabase();
415418 for (XField xfield : statMap.keySet()) {
416419 FieldStats stats = statMap.get(xfield);
417 if (!stats.interesting)
420 if (!stats.isInteresting())
418421 continue;
419 JCIPAnnotationDatabase jcipAnotationDatabase = AnalysisContext.currentAnalysisContext().getJCIPAnnotationDatabase();
420 boolean guardedByThis = "this".equals(jcipAnotationDatabase.getFieldAnnotation(xfield, "GuardedBy"));
421422 boolean notThreadSafe = jcipAnotationDatabase.hasClassAnnotation(xfield.getClassName(), "NotThreadSafe");
422 boolean threadSafe = jcipAnotationDatabase.hasClassAnnotation(xfield.getClassName().replace('/', '.'), "ThreadSafe");
423423 if (notThreadSafe)
424424 continue;
425 ElementValue guardedByValue = jcipAnotationDatabase.getFieldAnnotation(xfield, "GuardedBy");
426 boolean guardedByThis;
427 if(guardedByValue != null){
428 guardedByThis = guardedByValue.stringifyValue().equals("this");
429 } else {
430 guardedByThis = false;
431 }
432 boolean threadSafe = jcipAnotationDatabase.hasClassAnnotation(xfield.getClassName(), "ThreadSafe");
425433
426434 WarningPropertySet<InconsistentSyncWarningProperty> propertySet = new WarningPropertySet<InconsistentSyncWarningProperty>();
427435
754762 * @param method
755763 * the method
756764 */
757 @SuppressWarnings("unchecked")
758765 public static boolean isGetterMethod(ClassContext classContext, Method method) {
759766 MethodGen methodGen = classContext.getMethodGen(method);
760767 if (methodGen == null)
823830 * assume that nonpublic methods will only be called from within the class,
824831 * which is not really a valid assumption.
825832 */
826 private Set<Method> findNotUnlockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites)
833 private static Set<Method> findNotUnlockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites)
827834 {
828835
829836 JavaClass javaClass = classContext.getJavaClass();
887894 * assume that nonpublic methods will only be called from within the class,
888895 * which is not really a valid assumption.
889896 */
890 private Set<Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites)
897 private static Set<Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites)
891898 {
892899
893900 JavaClass javaClass = classContext.getJavaClass();
983990 /**
984991 * Find all self-call sites that are obviously locked.
985992 */
986 private Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls)
993 private static Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls)
987994 throws CFGBuilderException, DataflowAnalysisException {
988995 ConstantPoolGen cpg = classContext.getConstantPoolGen();
989996
8181 import edu.umd.cs.findbugs.ba.Location;
8282 import edu.umd.cs.findbugs.ba.MissingClassException;
8383 import edu.umd.cs.findbugs.ba.NullnessAnnotation;
84 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
8584 import edu.umd.cs.findbugs.ba.OpcodeStackScanner;
8685 import edu.umd.cs.findbugs.ba.SignatureConverter;
8786 import edu.umd.cs.findbugs.ba.SignatureParser;
105104 import edu.umd.cs.findbugs.ba.npe.RedundantBranch;
106105 import edu.umd.cs.findbugs.ba.npe.ReturnPathType;
107106 import edu.umd.cs.findbugs.ba.npe.ReturnPathTypeDataflow;
107 import edu.umd.cs.findbugs.ba.npe.TypeQualifierNullnessAnnotationDatabase;
108108 import edu.umd.cs.findbugs.ba.npe.UsagesRequiringNonNullValues;
109109 import edu.umd.cs.findbugs.ba.type.TypeDataflow;
110110 import edu.umd.cs.findbugs.ba.type.TypeFrame;
118118 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
119119 import edu.umd.cs.findbugs.classfile.Global;
120120 import edu.umd.cs.findbugs.classfile.analysis.AnnotationValue;
121 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
121122 import edu.umd.cs.findbugs.log.Profiler;
122123 import edu.umd.cs.findbugs.props.GeneralWarningProperty;
123124 import edu.umd.cs.findbugs.props.WarningProperty;
564565 }
565566 }
566567
568 @StaticConstant
567569 public static final Set<String> catchTypesForNull = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
568570 "java/lang/NullPointerException", "java/lang/RuntimeException", "java/lang/Exception")));
569571
814816 * @param invokeInstruction
815817 * @param nullArgSet
816818 * @param definitelyNullArgSet
817 * @throws ClassNotFoundException
818819 */
819820 private void checkNonNullParam(Location location, ConstantPoolGen cpg, TypeDataflow typeDataflow,
820821 InvokeInstruction invokeInstruction, BitSet nullArgSet, BitSet definitelyNullArgSet) {
11571158 priority += 1;
11581159 }
11591160
1161
11601162 if (DEBUG) {
11611163 System.out.println("RCN" + priority + " " + redundantBranch.firstValue + " =? " + redundantBranch.secondValue + " : "
11621164 + warning);
11821184 return;
11831185 variableAnnotation = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame,
11841186 "VALUE_OF");
1187 if (variableAnnotation instanceof LocalVariableAnnotation) {
1188 LocalVariableAnnotation local = (LocalVariableAnnotation) variableAnnotation;
1189 if (!local.isNamed()) {
1190 if (warning.equals("RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"))
1191 return;
1192 priority++;
1193 }
1194 }
11851195
11861196 }
11871197 } catch (DataflowAnalysisException e) {
11921202
11931203 BugInstance bugInstance = new BugInstance(this, warning, priority).addClassAndMethod(classContext.getJavaClass(), method);
11941204 LocalVariableAnnotation fallback = new LocalVariableAnnotation("?", -1, -1);
1195 bugInstance.addOptionalUniqueAnnotationsWithFallback(fallback, variableAnnotation,
1205 boolean foundSource = bugInstance.tryAddingOptionalUniqueAnnotations(variableAnnotation,
11961206 BugInstance.getFieldOrMethodValueSource(item1), BugInstance.getFieldOrMethodValueSource(item2));
11971207
1208 if (!foundSource) {
1209 if (warning.equals("RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"))
1210 return;
1211 bugInstance.setPriority(priority+1);
1212 bugInstance.add(fallback);
1213 }
11981214 if (wouldHaveBeenAKaboom)
11991215 bugInstance.addSourceLine(classContext, method, locationOfKaBoom);
12001216
14411457 return;
14421458 invokedMethod = MethodAnnotation.fromXMethod(mp.getMethod());
14431459 if (mp.getParameterNumber() == 0
1444 && NullnessAnnotationDatabase.assertsFirstParameterIsNonnull(invokedXMethod))
1460 && TypeQualifierNullnessAnnotationDatabase.assertsFirstParameterIsNonnull(invokedXMethod))
14451461 return;
14461462 parameterNumber = mp.getParameterNumber();
14471463 bugType = "NP_NULL_PARAM_DEREF";
101101 import edu.umd.cs.findbugs.classfile.Global;
102102 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
103103 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
104 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
104105 import edu.umd.cs.findbugs.log.Profiler;
105106 import edu.umd.cs.findbugs.props.WarningProperty;
106107 import edu.umd.cs.findbugs.props.WarningPropertySet;
128129 /**
129130 * Classes that are suspicious if compared by reference.
130131 */
132 @StaticConstant
131133 private static final HashSet<String> DEFAULT_SUSPICIOUS_SET = new HashSet<String>();
132134
133135 static {
346348 return "<empty string>";
347349 }
348350 }
349
351
350352 private static final Type emptyStringTypeInstance = new EmptyStringType();
351353
352
354
353355 /**
354356 * Type representing a String passed as a parameter.
355357 */
692694 // bugReporter.logError("Error analyzing " + method.toString(),
693695 // e);
694696 }
695 }
696 bugAccumulator.reportAccumulatedBugs();
697 bugAccumulator.reportAccumulatedBugs();
698 }
699
697700 }
698701
699702 /**
739742 LinkedList<WarningWithProperties> refComparisonList = new LinkedList<WarningWithProperties>();
740743 LinkedList<WarningWithProperties> stringComparisonList = new LinkedList<WarningWithProperties>();
741744
742
745
743746 comparedForEqualityInThisMethod = new HashMap<String,Integer>();
744747 CFG cfg = classContext.getCFG(method);
745748 DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
839842 if ( methodName.equals("assertSame") && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)V")) {
840843 checkRefComparison(location, jclass, method, methodGen, visitor, typeDataflow, stringComparisonList,
841844 refComparisonList);
842 }
845 } else if ( methodName.equals("assertFalse") && methodSig.equals("(Z)V")) {
846 SourceLineAnnotation lastLocation = bugAccumulator.getLastBugLocation();
847 InstructionHandle prevHandle = location.getHandle().getPrev();
848 if (lastLocation != null && prevHandle != null && lastLocation.getEndBytecode() == prevHandle.getPosition()){
849 bugAccumulator.forgetLastBug();
850 if (DEBUG)
851 System.out.println("Forgetting last bug due to call to " + className +"." + methodName);
852 }
853
854 } else {
843855 boolean equalsMethod = !isStatic && methodName.equals("equals") && methodSig.equals("(Ljava/lang/Object;)Z")
844 || isStatic && methodName.equals("assertEquals") && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)V")
845 && !className.equals("org.testng.Assert")
856 || isStatic && methodName.equals("assertEquals")
857 && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)V")
846858 || isStatic && methodName.equals("equal") && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)Z")
847 && className.equals("com.google.common.base.Objects");
848
859 && className.equals("com.google.common.base.Objects")
860 || isStatic && methodName.equals("equals") && methodSig.equals("(Ljava/lang/Object;Ljava/lang/Object;)Z")
861 && className.equals("java.util.Objects");
862
849863 if (equalsMethod) {
850864 checkEqualsComparison(location, jclass, method, methodGen, cpg, typeDataflow);
865 }
851866 }
852867 }
853868
10381053 }
10391054
10401055 private Map<String, Integer> comparedForEqualityInThisMethod;
1041
1056
10421057 void addEqualsCheck(String type, int pc) {
10431058 Integer oldPC = comparedForEqualityInThisMethod.get(type);
10441059 if (oldPC == null || pc < oldPC)
10561071 return;
10571072 }
10581073 }
1059 String sourceFile = jclass.getSourceFileName();
1074 String sourceFile = jclass.getSourceFileName();
10601075
10611076 TypeFrame frame = typeDataflow.getFactAtLocation(location);
10621077 if (frame.getStackDepth() < 2) {
10911106 int priority = NORMAL_PRIORITY;
10921107 if (a instanceof FieldAnnotation && ((FieldAnnotation) a).isStatic())
10931108 priority = LOW_PRIORITY;
1094 if (isNullFrame.isValid() && isNullFrame.getTopValue().isDefinitelyNull())
1109 if (isNullFrame.isValid() && isNullFrame.getTopValue().isDefinitelyNull()) {
1110 String type = "EC_NULL_ARG";
1111 if (calledMethodAnnotation != null && calledMethodAnnotation.isStatic()){
1112 type = "DMI_DOH";
1113 priority = LOW_PRIORITY;
1114 }
1115 BugInstance bug = new BugInstance(this, type, priority + priorityModifier).addClassAndMethod(methodGen, sourceFile)
1116 .addOptionalAnnotation(calledMethodAnnotation);
1117 if (type.equals("DMI_DOH"))
1118 bug.addString("Use \"== null\" to check for a value being null");
10951119 bugAccumulator.accumulateBug(
1096 new BugInstance(this, "EC_NULL_ARG", priority).addClassAndMethod(methodGen, sourceFile),
1120 bug,
10971121 SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile,
10981122 location.getHandle()));
1123 }
10991124 } catch (CFGBuilderException e) {
11001125 AnalysisContext.logError("Error getting null value analysis", e);
11011126 }
11191144 IncompatibleTypes result2 = IncompatibleTypes.getPriorityForAssumingCompatible(lhsType_, rhsType_, true);
11201145 if (result2.getPriority() <= Priorities.NORMAL_PRIORITY)
11211146 pattern = "EC_INCOMPATIBLE_ARRAY_COMPARE";
1147 else if (calledMethodAnnotation != null && calledMethodAnnotation.getClassName().equals("org.testng.Assert"))
1148 return;
11221149 bugAccumulator.accumulateBug(new BugInstance(this, pattern, NORMAL_PRIORITY).addClassAndMethod(methodGen, sourceFile)
11231150 .addFoundAndExpectedType(rhsType_, lhsType_)
11241151 .addSomeSourceForTopTwoStackValues(classContext, method, location)
11251152 .addOptionalAnnotation(calledMethodAnnotation, MethodAnnotation.METHOD_CALLED),
11261153 SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile, location.getHandle()));
1154 return;
11271155 }
11281156
11291157 if (result.getPriority() >= Priorities.LOW_PRIORITY) {
11301158 addEqualsCheck(lhsType_.getSignature(), handle.getPosition());
11311159 addEqualsCheck(rhsType_.getSignature(), handle.getPosition());
11321160 }
1133
1161
11341162 if (result == IncompatibleTypes.SEEMS_OK) return;
11351163
1136
1164
11371165 if (result.getPriority() > Priorities.LOW_PRIORITY)
11381166 return;
11391167
12181246 String invoked = inv.getClassName(cpg);
12191247 String methodName = inv.getMethodName(cpg);
12201248 String methodSig = inv.getSignature(cpg);
1221 MethodDescriptor invokedMethod =
1249 MethodDescriptor invokedMethod =
12221250 DescriptorFactory.instance().getMethodDescriptor(ClassName.toSlashedClassName(invoked), methodName, methodSig, inv instanceof INVOKESTATIC);
12231251 return invokedMethod;
12241252 }
1818
1919 package edu.umd.cs.findbugs.detect;
2020
21 import java.util.BitSet;
22
2123 import org.apache.bcel.classfile.Code;
2224 import org.apache.bcel.classfile.LineNumberTable;
2325
2729 import edu.umd.cs.findbugs.FieldAnnotation;
2830 import edu.umd.cs.findbugs.LocalVariableAnnotation;
2931 import edu.umd.cs.findbugs.OpcodeStack;
32 import edu.umd.cs.findbugs.SourceLineAnnotation;
33 import edu.umd.cs.findbugs.SystemProperties;
3034 import edu.umd.cs.findbugs.ba.SignatureParser;
3135 import edu.umd.cs.findbugs.ba.XClass;
3236 import edu.umd.cs.findbugs.ba.XField;
5054
5155 XField putFieldXField;
5256
57 int lastMethodCall;
58
59 static final boolean DEBUG = SystemProperties.getBoolean("fsc.debug");
5360 @Override
5461 public void visit(Code obj) {
55 // System.out.println(getFullyQualifiedMethodName());
62 if (DEBUG)
63 System.out.println(getFullyQualifiedMethodName());
5664 whichRegister = -1;
5765 registerLoadCount = 0;
66 lastMethodCall = -1;
5867 resetDoubleAssignmentState();
5968 super.visit(obj);
6069 resetDoubleAssignmentState();
6170 bugAccumulator.reportAccumulatedBugs();
71 if (DEBUG)
72 System.out.println();
6273 }
6374
6475 private void resetDoubleAssignmentState() {
7586
7687 @Override
7788 public void sawOpcode(int seen) {
78 // System.out.println(getPC() + " " + OPCODE_NAMES[seen] + " " +
79 // whichRegister + " " + registerLoadCount);
80
89 if (DEBUG)
90 System.out.printf("%3d %-15s %s%n", getPC(), OPCODE_NAMES[seen], stack);
91
92
8193 if (stack.hasIncomingBranches(getPC()))
8294 resetDoubleAssignmentState();
8395
150162 switch (seen) {
151163 case INVOKEVIRTUAL:
152164 case INVOKEINTERFACE:
165 // case INVOKESTATIC:
153166 if (getClassName().toLowerCase().indexOf("test") >= 0)
154167 break;
155168 if (getMethodName().toLowerCase().indexOf("test") >= 0)
160173 break;
161174 String name = getNameConstantOperand();
162175
163 if (name.equals("equals") || name.equals("compareTo")) {
176 boolean booleanComparisonMethod = FindSelfComparison2.booleanComparisonMethod(name);
177 if (booleanComparisonMethod || FindSelfComparison2.comparatorMethod(name)) {
164178 String sig = getSigConstantOperand();
165179 SignatureParser parser = new SignatureParser(sig);
166 if (parser.getNumParameters() == 1
167 && (name.equals("equals") && sig.endsWith(";)Z") || name.equals("compareTo") && sig.endsWith(";)I")))
180 int numParameters = parser.getNumParameters();
181 if ((numParameters == 1 || seen == INVOKESTATIC && numParameters == 2)
182 && (booleanComparisonMethod && sig.endsWith(";)Z")
183 || FindSelfComparison2.comparatorMethod(name) && sig.endsWith(";)I")))
168184 checkForSelfOperation(seen, "COMPARISON");
169185 }
170186 break;
206222 whichRegister = -1;
207223 registerLoadCount = 0;
208224 }
225
226 if (isMethodCall())
227 lastMethodCall = getPC();
228
209229 }
210230
211231 int whichRegister;
215235 private void checkForSelfOperation(int opCode, String op) {
216236 {
217237
238
218239 OpcodeStack.Item item0 = stack.getStackItem(0);
219240 OpcodeStack.Item item1 = stack.getStackItem(1);
220241
223244 if (item1.getSignature().equals("D") || item1.getSignature().equals("F"))
224245 return;
225246
247 BitSet linesMentionedMultipleTimes = getClassContext().linesMentionedMultipleTimes(getMethod());
248 SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(this);
249 boolean possibleClone = source.getStartLine() > 0 && linesMentionedMultipleTimes.get(source.getStartLine());
250 LineNumberTable lineNumberTable = getCode().getLineNumberTable();
251 int linesDifference = 0;
252 if (item0.getPC() != -1 && item1.getPC() != -1) {
253 if (lineNumberTable != null) {
254 int line0 = lineNumberTable.getSourceLine(item0.getPC());
255 int line1 = lineNumberTable.getSourceLine(item1.getPC());
256 int firstPos = Math.min(item0.getPC(), item1.getPC());
257 if (firstPos < lastMethodCall && line0 != line1)
258 return;
259
260 linesDifference = Math.abs(line0 - line1);
261 } else {
262 int firstPos = Math.min(item0.getPC(), item1.getPC());
263 int lastPos = Math.max(item0.getPC(), item1.getPC());
264
265 if (firstPos < lastMethodCall && lastPos - firstPos > 4)
266 return;
267 linesDifference = (lastPos - firstPos)/10;
268 }
269 }
226270 XField field0 = item0.getXField();
227271 XField field1 = item1.getXField();
228272 int fr0 = item0.getFieldLoadedFromRegister();
229273 int fr1 = item1.getFieldLoadedFromRegister();
230 if (field0 != null && field0.equals(field1) && fr0 != -1 && fr0 == fr1)
231 bugAccumulator.accumulateBug(new BugInstance(this, "SA_FIELD_SELF_" + op, NORMAL_PRIORITY)
232 .addClassAndMethod(this).addField(field0), this);
274 if (field0 != null && field0.equals(field1) && (field0.isStatic() || fr0 != -1 && fr0 == fr1)) {
275 int priority = NORMAL_PRIORITY;
276 if (field0.isVolatile())
277 priority++;
278 if (linesDifference > 1) {
279 if (possibleClone)
280 return;
281 priority++;
282 }
283
284 BugInstance bug = new BugInstance(this, "SA_FIELD_SELF_" + op, priority)
285 .addClassAndMethod(this).addField(field0);
286
287 if (this.isMethodCall())
288 bug.addCalledMethod(this);
289 bugAccumulator.accumulateBug(bug, this);
290 }
233291
234292 else if (opCode == IXOR && item0.equals(item1)) {
235293 LocalVariableAnnotation localVariableAnnotation = LocalVariableAnnotation.getLocalVariableAnnotation(this, item0);
236294 if (localVariableAnnotation != null)
237295 bugAccumulator.accumulateBug(
238 new BugInstance(this, "SA_LOCAL_SELF_" + op, HIGH_PRIORITY).addClassAndMethod(this).add(
296 new BugInstance(this, "SA_LOCAL_SELF_" + op, linesDifference > 1 ? NORMAL_PRIORITY : HIGH_PRIORITY).addClassAndMethod(this).add(
239297 localVariableAnnotation), this);
240 } else if (opCode == ISUB && registerLoadCount >= 2) { // let
241 // FindSelfComparison2
242 // report
243 // this; more
244 // accurate
245 bugAccumulator.accumulateBug(
246 new BugInstance(this, "SA_LOCAL_SELF_" + op, (opCode == ISUB || opCode == LSUB
247 || opCode == INVOKEINTERFACE || opCode == INVOKEVIRTUAL) ? NORMAL_PRIORITY : HIGH_PRIORITY)
248 .addClassAndMethod(this).add(
249 LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), whichRegister, getPC(),
250 getPC() - 1)), this);
251298 }
252299 }
253300 }
5555
5656 public class FindSelfComparison2 implements Detector {
5757
58 private BugReporter bugReporter;
58 private final BugReporter bugReporter;
5959
6060 public FindSelfComparison2(BugReporter bugReporter) {
6161 this.bugReporter = bugReporter;
8383 }
8484 }
8585
86 static boolean booleanComparisonMethod(String methodName) {
87 return methodName.equals("equals") ||methodName.equals("endsWith") || methodName.equals("startsWith")
88 || methodName.equals("contains") || methodName.equals("equalsIgnoreCase");
89 }
90
91 static boolean comparatorMethod(String methodName) {
92 return methodName.equals("compareTo") || methodName.equals("compareToIgnoreCase");
93 }
8694 private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
8795 CFG cfg = classContext.getCFG(method);
8896 ValueNumberDataflow valueNumberDataflow = classContext.getValueNumberDataflow(method);
99107 case INVOKEINTERFACE:
100108 InvokeInstruction iins = (InvokeInstruction) ins;
101109 String invoking = iins.getName(cpg);
102 if (invoking.equals("equals") || invoking.equals("compareTo")) {
110 if ( comparatorMethod(invoking) || booleanComparisonMethod(invoking) ) {
103111 if (methodGen.getName().toLowerCase().indexOf("test") >= 0)
104112 break;
105113 if (methodGen.getClassName().toLowerCase().indexOf("test") >= 0)
112120
113121 SignatureParser parser = new SignatureParser(sig);
114122 if (parser.getNumParameters() == 1
115 && (invoking.equals("equals") && sig.endsWith(";)Z") || invoking.equals("compareTo")
116 && sig.endsWith(";)I")))
123 && ( booleanComparisonMethod(invoking) && sig.endsWith(";)Z") || comparatorMethod(invoking) && sig.endsWith(";)I")))
117124 checkForSelfOperation(classContext, location, valueNumberDataflow, "COMPARISON", method, methodGen,
118125 sourceFile);
119126
208215 BitSet occursMultipleTimes = classContext.linesMentionedMultipleTimes(method);
209216 if (line > 0 && occursMultipleTimes.get(line))
210217 return;
211 BugInstance bug = new BugInstance(this, prefix + op, priority).addClassAndMethod(methodGen, sourceFile).add(annotation)
218 BugInstance bug = new BugInstance(this, prefix + op, priority).addClassAndMethod(methodGen, sourceFile);
219 if (ins instanceof InvokeInstruction)
220 bug.addCalledMethod(classContext.getConstantPoolGen(), (InvokeInstruction) ins);
221
222 bug.add(annotation)
212223 .addSourceLine(classContext, methodGen, sourceFile, location.getHandle());
213224 bugReporter.reportBug(bug);
214225 }
9292 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
9393 import edu.umd.cs.findbugs.classfile.Global;
9494 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
95 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
9596 import edu.umd.cs.findbugs.props.GeneralWarningProperty;
9697 import edu.umd.cs.findbugs.props.WarningProperty;
9798 import edu.umd.cs.findbugs.props.WarningPropertySet;
293294 return false;
294295 }
295296
296 final static LinkedHashSet<String> baseGenericTypes = new LinkedHashSet<String>();
297 @StaticConstant
298 final static Set<String> baseGenericTypes = new LinkedHashSet<String>();
297299 static {
298300 baseGenericTypes.addAll(Arrays.asList(new String[] { "java.util.Map", "java.util.Collection", "java.lang.Iterable",
299301 "java.util.Iterator", "com.google.common.collect.Multimap", "com.google.common.collect.Multiset",
9696 }
9797 }
9898
99 enum Use { STORE_INTO_HTTP_SESSION, PASSED_TO_WRITE_OBJECT, STORED_IN_SERIALZIED_FIELD };
99 enum Use { STORE_INTO_HTTP_SESSION, PASSED_TO_WRITE_OBJECT, STORED_IN_SERIALZIED_FIELD }
100100
101101 @CheckForNull Use getUse(ConstantPoolGen cpg, Instruction ins) {
102102 if (ins instanceof InvokeInstruction) {
4949
5050 enum FormatState {
5151 NONE, READY_FOR_FORMAT, EXPECTING_ASSIGNMENT
52 };
52 }
5353
5454 FormatState state;
5555
6868
6969 /*
7070 * (non-Javadoc)
71 *
71 *
7272 * @see edu.umd.cs.findbugs.bcel.OpcodeStackDetector#sawOpcode(int)
7373 */
7474 @Override
162162 } catch (ClassNotFoundException e1) {
163163 AnalysisContext.reportMissingClass(e1);
164164 }
165
165
166166 }
167167 bugReporter.reportBug(new BugInstance(this, "VA_FORMAT_STRING_BAD_CONVERSION", HIGH_PRIORITY)
168168 .addClassAndMethod(this).addCalledMethod(this).addType(aSig)
2929
3030 import edu.umd.cs.findbugs.BugInstance;
3131 import edu.umd.cs.findbugs.BugReporter;
32 import edu.umd.cs.findbugs.NonReportingDetector;
32 import edu.umd.cs.findbugs.FirstPassDetector;
3333 import edu.umd.cs.findbugs.OpcodeStack;
3434 import edu.umd.cs.findbugs.OpcodeStack.Item;
3535 import edu.umd.cs.findbugs.SystemProperties;
3636 import edu.umd.cs.findbugs.ba.AnalysisContext;
3737 import edu.umd.cs.findbugs.ba.SignatureParser;
38 import edu.umd.cs.findbugs.ba.XClass;
3938 import edu.umd.cs.findbugs.ba.XFactory;
4039 import edu.umd.cs.findbugs.ba.XMethod;
4140 import edu.umd.cs.findbugs.ba.generic.GenericObjectType;
4241 import edu.umd.cs.findbugs.ba.generic.GenericSignatureParser;
4342 import edu.umd.cs.findbugs.ba.generic.GenericUtilities;
43 import edu.umd.cs.findbugs.bcel.BCELUtil;
4444 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
4545 import edu.umd.cs.findbugs.internalAnnotations.SlashedClassName;
4646 import edu.umd.cs.findbugs.util.ClassName;
4747
48 public class FunctionsThatMightBeMistakenForProcedures extends OpcodeStackDetector implements NonReportingDetector {
48 public class FunctionsThatMightBeMistakenForProcedures extends OpcodeStackDetector implements FirstPassDetector {
4949
5050 final BugReporter bugReporter;
5151
5555 this.bugReporter = bugReporter;
5656 setVisitMethodsInCallOrder(true);
5757 }
58
58
5959 boolean isInnerClass, hasNonFinalFields;
6060
6161 @Override
6464 hasNonFinalFields = false;
6565
6666 }
67
67
6868 @Override
6969 public void visit(Field obj) {
7070 if (obj.getName().equals("this$0"))
7171 isInnerClass = true;
72 if (!obj.isFinal() && !obj.isStatic() && !obj.isSynthetic())
72 if (!obj.isFinal() && !obj.isStatic() && !BCELUtil.isSynthetic(obj))
7373 hasNonFinalFields = true;
7474 }
7575
128128 funky = true;
129129 }
130130
131 if (false) {
132 XClass c = getXClass();
133 String classSourceSig = c.getSourceSignature();
134 if (!genericReturnValue.equals(classSourceSig))
135 return;
136 }
131 // if (false) {
132 // XClass c = getXClass();
133 // String classSourceSig = c.getSourceSignature();
134 // if (!genericReturnValue.equals(classSourceSig))
135 // return;
136 // }
137137 }
138138
139139 // System.out.println("Investigating " + getFullyQualifiedMethodName());
140140 returnSelf = returnOther = updates = returnNew = returnUnknown = 0;
141
142 if (REPORT_INFERRED_METHODS
141
142 if (REPORT_INFERRED_METHODS
143143 && AnalysisContext.currentAnalysisContext().isApplicationClass(getThisClass()))
144144 inferredMethod = new BugInstance("TESTING", NORMAL_PRIORITY).addClassAndMethod(this);
145 else
145 else
146146 inferredMethod = null;
147147 super.visit(code); // make callbacks to sawOpcode for all opcodes
148148 // System.out.printf(" %3d %3d %3d %3d%n", returnSelf, updates, returnOther, returnNew);
179179 }
180180 }
181181
182
182
183183 inferredMethod = null;
184184
185185 }
243243 returnNew++;
244244 }
245245 break;
246
247 }
248
249
246
247 }
248
249
250250 if (xMethod.isAbstract() && !xMethod.getClassDescriptor().equals(getClassDescriptor())) {
251251 returnUnknown++;
252252 break;
193193
194194 @Override
195195 public void visit(Code obj) {
196 if (DEBUG)
197 System.out.println(getFullyQualifiedMethodName());
196198 clearRegModified();
197199 backwardBranches.clear();
198200 forwardConditionalBranches.clear();
254256 }
255257
256258 }
259 if (DEBUG)
260 System.out.println();
261
257262 }
258263
259264 /**
276281 addForwardJump(getPC(), target);
277282 }
278283
284 static final boolean DEBUG = false;
279285 @Override
280286 public void sawOpcode(int seen) {
281 if (false)
282 System.out.println(getPC() + " " + OPCODE_NAMES[seen] + " " + stack);
287 if (DEBUG)
288 System.out.printf("%3d %-15s %s%n", getPC(), OPCODE_NAMES[seen], stack);
283289 if (isRegisterStore())
284290 regModifiedAt(getRegisterOperand(), getPC());
285291 switch (seen) {
1919 package edu.umd.cs.findbugs.detect;
2020
2121 import org.apache.bcel.classfile.Code;
22 import org.apache.bcel.classfile.Method;
2223
2324 import edu.umd.cs.findbugs.BugInstance;
2425 import edu.umd.cs.findbugs.BugReporter;
3233
3334 public class IteratorIdioms extends BytecodeScanningDetector implements StatelessDetector {
3435
35 private ClassDescriptor iteratorDescriptor = DescriptorFactory.createClassDescriptor(java.util.Iterator.class);
36 private final ClassDescriptor iteratorDescriptor = DescriptorFactory.createClassDescriptor(java.util.Iterator.class);
3637
37 private BugReporter bugReporter;
38 private final BugReporter bugReporter;
39
40 private boolean sawNoSuchElement;
41
42 private boolean sawCall;
43
44 private boolean shouldVisitCode;
3845
3946 public IteratorIdioms(BugReporter bugReporter) {
4047 this.bugReporter = bugReporter;
4350 @Override
4451 public void visitClassContext(ClassContext classContext) {
4552 Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
46
4753 try {
48 if (subtypes2.isSubtype(classContext.getClassDescriptor(), iteratorDescriptor))
54 if (subtypes2.isSubtype(classContext.getClassDescriptor(), iteratorDescriptor)) {
4955 super.visitClassContext(classContext);
56 }
5057 } catch (ClassNotFoundException e) {
5158 bugReporter.reportMissingClass(e);
5259 }
5360 }
5461
55 boolean sawNoSuchElement;
5662
57 boolean sawCall;
63 @Override
64 public void visit(Method method) {
65 if(method.isPublic() && method.getName().equals("next") && method.getArgumentTypes().length == 0){
66 shouldVisitCode = true;
67 super.visit(method);
68 } else {
69 shouldVisitCode = false;
70 }
71 }
5872
5973 @Override
6074 public void visit(Code obj) {
61 if (getMethodName().equals("next") && getMethodSig().equals("()Ljava/lang/Object;")) {
62 sawNoSuchElement = false;
63 sawCall = false;
64 super.visit(obj);
65 if (!sawNoSuchElement)
66
67 bugReporter.reportBug(new BugInstance(this, "IT_NO_SUCH_ELEMENT", sawCall ? LOW_PRIORITY : NORMAL_PRIORITY)
68 .addClassAndMethod(this));
75 if(!shouldVisitCode){
76 return;
77 }
78 sawNoSuchElement = false;
79 sawCall = false;
80 super.visit(obj);
81 if (!sawNoSuchElement) {
82 BugInstance bug = new BugInstance(this, "IT_NO_SUCH_ELEMENT", sawCall ? LOW_PRIORITY : NORMAL_PRIORITY);
83 bug.addClassAndMethod(this);
84 bugReporter.reportBug(bug);
6985 }
7086 }
7187
7288 @Override
7389 public void sawOpcode(int seen) {
74 if (seen == NEW && getClassConstantOperand().equals("java/util/NoSuchElementException"))
90 if (seen == NEW && getClassConstantOperand().equals("java/util/NoSuchElementException")) {
7591 sawNoSuchElement = true;
76 else if (seen == INVOKESPECIAL || seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) {
92 } else if (seen == INVOKESPECIAL || seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) {
7793 sawCall = true;
78 if (getNameConstantOperand().toLowerCase().indexOf("next") >= 0
79 || getNameConstantOperand().toLowerCase().indexOf("previous") >= 0)
94 String name = getNameConstantOperand().toLowerCase();
95 if (name.indexOf("next") >= 0
96 || name.indexOf("previous") >= 0) {
8097 sawNoSuchElement = true;
98 }
8199 }
82100 }
83101 }
1414 import org.apache.bcel.generic.MethodGen;
1515
1616 import edu.umd.cs.findbugs.BugAccumulator;
17 import edu.umd.cs.findbugs.BugAnnotation;
1718 import edu.umd.cs.findbugs.BugInstance;
1819 import edu.umd.cs.findbugs.BugReporter;
1920 import edu.umd.cs.findbugs.Detector;
21 import edu.umd.cs.findbugs.LocalVariableAnnotation;
2022 import edu.umd.cs.findbugs.SourceLineAnnotation;
2123 import edu.umd.cs.findbugs.SystemProperties;
2224 import edu.umd.cs.findbugs.ba.CFG;
2830 import edu.umd.cs.findbugs.ba.npe.IsNullValue;
2931 import edu.umd.cs.findbugs.ba.npe.IsNullValueDataflow;
3032 import edu.umd.cs.findbugs.ba.npe.IsNullValueFrame;
33 import edu.umd.cs.findbugs.ba.vna.ValueNumber;
34 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
35 import edu.umd.cs.findbugs.ba.vna.ValueNumberSourceInfo;
3136
3237 public class LoadOfKnownNullValue implements Detector {
3338
185190 continue;
186191 }
187192 int priority = NORMAL_PRIORITY;
188
189193 if (!v.isChecked())
190194 priority++;
195
196 BugAnnotation variableAnnotation = null;
197 try {
198 // Get the value number
199 ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getFactAfterLocation(location);
200 if (vnaFrame.isValid()) {
201
202 ValueNumber valueNumber = vnaFrame.getTopValue();
203 if (valueNumber.hasFlag(ValueNumber.CONSTANT_CLASS_OBJECT))
204 return;
205 variableAnnotation = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame,
206 "VALUE_OF");
207 if (variableAnnotation instanceof LocalVariableAnnotation) {
208 LocalVariableAnnotation local = (LocalVariableAnnotation) variableAnnotation;
209 if (!local.isNamed()) {
210 priority++;
211 }
212 }
213
214 }
215 } catch (DataflowAnalysisException e) {
216 // ignore
217 } catch (CFGBuilderException e) {
218 // ignore
219 }
220
191221 // System.out.println("lineMentionedMultipleTimes: " +
192222 // lineMentionedMultipleTimes);
193223 // System.out.println("linesWithLoadsOfNonNullValues: " +
194224 // linesWithLoadsOfNotDefinitelyNullValues);
195225
196226 bugAccumulator.accumulateBug(
197 new BugInstance(this, "NP_LOAD_OF_KNOWN_NULL_VALUE", priority).addClassAndMethod(methodGen, sourceFile),
227 new BugInstance(this, "NP_LOAD_OF_KNOWN_NULL_VALUE", priority).addClassAndMethod(methodGen, sourceFile)
228 .addOptionalAnnotation(variableAnnotation),
198229 sourceLineAnnotation);
199230 }
200231
6464 if (false) {
6565 System.out.println(getFullyQualifiedMethodName());
6666 System.out.printf("%d %s %s\n", sawGetLogger, loggerEscaped, loggerImported);
67
6867 }
69 if (sawGetLogger >= 0 && !loggerEscaped && !loggerImported)
68 if (sawGetLogger >= 0 && !loggerEscaped && !loggerImported) {
7069 bugAccumulator.reportAccumulatedBugs();
71 else
70 } else
7271 bugAccumulator.clearBugs();
7372 }
7473 }
8180
8281 @Override
8382 public void sawOpcode(int seen) {
83 if (loggerEscaped || loggerImported)
84 return;
8485 switch (seen) {
8586 case INVOKESTATIC:
8687 if (getClassConstantOperand().equals("java/util/logging/Logger") && getNameConstantOperand().equals("getLogger")) {
9798 int priority = HIGH_PRIORITY;
9899 if (getMethod().isStatic() && getMethodName().equals("main") && getMethodSig().equals("([Ljava/lang/String;)V"))
99100 priority = NORMAL_PRIORITY;
100 ;
101 bugAccumulator.accumulateBug(
102 new BugInstance(this, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE", priority).addClassAndMethod(this), this);
101
102 OpcodeStack.Item item = stack.getItemMethodInvokedOn(this);
103 BugInstance bug = new BugInstance(this, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE", priority)
104 .addClassAndMethod(this).addValueSource(item, this);
105 bugAccumulator.accumulateBug(bug, this);
103106 break;
104107 }
105108 checkForImport();
158161
159162 }
160163
161 private void emitWarning() {
162 System.out.println("Warn about " + getMethodName()); // TODO
163 }
164
165164 }
131131 case Constants.IF_ICMPNE:
132132 OpcodeStack.Item left = stack.getStackItem(1);
133133 OpcodeStack.Item right = stack.getStackItem(0);
134 if (badUseOfCompareResult(left, right))
135
134 if (badUseOfCompareResult(left, right)) {
135 XMethod returnValueOf = left.getReturnValueOf();
136 assert returnValueOf != null;
136137 bugAccumulator.accumulateBug(new BugInstance(this, "RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", NORMAL_PRIORITY)
137 .addClassAndMethod(this).addMethod(left.getReturnValueOf()).describe(MethodAnnotation.METHOD_CALLED).addValueSource(right, this), this);
138 else if (badUseOfCompareResult(right, left))
138 .addClassAndMethod(this).addMethod(returnValueOf).describe(MethodAnnotation.METHOD_CALLED).addValueSource(right, this), this);
139 } else if (badUseOfCompareResult(right, left)) {
140 XMethod returnValueOf = right.getReturnValueOf();
141 assert returnValueOf != null;
139142 bugAccumulator.accumulateBug(new BugInstance(this, "RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", NORMAL_PRIORITY)
140 .addClassAndMethod(this).addMethod(right.getReturnValueOf()).describe(MethodAnnotation.METHOD_CALLED).addValueSource(left, this), this);
143 .addClassAndMethod(this).addMethod(returnValueOf).describe(MethodAnnotation.METHOD_CALLED).addValueSource(left, this), this);
144 }
141145 }
142146
143147 checkForInitWithoutCopyOnStack: if (seen == INVOKESPECIAL && getNameConstantOperand().equals("<init>")) {
4949 import edu.umd.cs.findbugs.ba.XClass;
5050 import edu.umd.cs.findbugs.ba.XFactory;
5151 import edu.umd.cs.findbugs.ba.XMethod;
52 import edu.umd.cs.findbugs.bcel.BCELUtil;
5253 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
5354 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
5455 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
288289
289290 @Override
290291 public void visitJavaClass(JavaClass obj) {
291 if (obj.isSynthetic())
292 if (BCELUtil.isSynthetic(obj))
292293 return;
293294 String name = obj.getClassName();
294295 if (!visited.add(name))
9595 // we'll use at a later point to find relevant qualifiers
9696 // stemming from called methods.
9797
98 if (!Analysis.FIND_EFFECTIVE_RELEVANT_QUALIFIERS) {
9899 XMethod m = getXMethodOperand();
99100 if (m != null)
100101 updateApplicableAnnotations(m);
101
102 }
102103 break;
103104
104105 case GETSTATIC:
2929 import edu.umd.cs.findbugs.ba.AnalysisContext;
3030 import edu.umd.cs.findbugs.ba.ClassContext;
3131 import edu.umd.cs.findbugs.ba.ClassMember;
32 import edu.umd.cs.findbugs.ba.JCIPAnnotationDatabase;
3233 import edu.umd.cs.findbugs.ba.XFactory;
3334 import edu.umd.cs.findbugs.bcel.BCELUtil;
3435 import edu.umd.cs.findbugs.visitclass.AnnotationVisitor;
3637 public class NoteJCIPAnnotation extends AnnotationVisitor implements Detector, NonReportingDetector {
3738
3839 private static final String NET_JCIP_ANNOTATIONS = "net.jcip.annotations.";
40 private static final String JSR305_CONCURRENT_ANNOTATIONS = "javax.annotation.concurrent.";
3941
4042 public NoteJCIPAnnotation(BugReporter bugReporter) {
43 super();
4144 }
4245
4346 @Override
4447 public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) {
45
46 if (!annotationClass.startsWith(NET_JCIP_ANNOTATIONS))
48 if (annotationClass.startsWith(NET_JCIP_ANNOTATIONS)) {
49 annotationClass = annotationClass.substring(NET_JCIP_ANNOTATIONS.length());
50 } else if (annotationClass.startsWith(JSR305_CONCURRENT_ANNOTATIONS)) {
51 annotationClass = annotationClass.substring(JSR305_CONCURRENT_ANNOTATIONS.length());
52 } else {
4753 return;
48 annotationClass = annotationClass.substring(NET_JCIP_ANNOTATIONS.length());
54 }
55 JCIPAnnotationDatabase annotationDatabase = AnalysisContext.currentAnalysisContext()
56 .getJCIPAnnotationDatabase();
4957 ElementValue value = map.get("value");
5058 ClassMember member;
51 if (visitingField())
59 if (visitingField()) {
5260 member = XFactory.createXField(this);
53 else if (visitingMethod())
61 } else if (visitingMethod()) {
5462 member = XFactory.createXMethod(this);
55 else {
56 Map<String, ElementValue> annotationsOfThisClass = AnalysisContext.currentAnalysisContext()
57 .getJCIPAnnotationDatabase().getEntryForClass(getDottedClassName());
58 annotationsOfThisClass.put(annotationClass, value);
63 } else {
64 annotationDatabase.addEntryForClass(getDottedClassName(), annotationClass, value);
5965 return;
6066 }
61 Map<String, ElementValue> annotationsOfThisMember = AnalysisContext.currentAnalysisContext().getJCIPAnnotationDatabase()
62 .getEntryForClassMember(member);
63 annotationsOfThisMember.put(annotationClass, value);
67 annotationDatabase.addEntryForClassMember(member, annotationClass, value);
6468 }
6569
6670 public void visitClassContext(ClassContext classContext) {
6771 JavaClass javaClass = classContext.getJavaClass();
68 if (!BCELUtil.preTiger(javaClass))
72 if (!BCELUtil.preTiger(javaClass)) {
6973 javaClass.accept(this);
74 }
7075
7176 }
7277
7378 public void report() {
74
79 // noop
7580 }
7681
7782 }
2323 import edu.umd.cs.findbugs.BugReporter;
2424 import edu.umd.cs.findbugs.Detector;
2525 import edu.umd.cs.findbugs.NonReportingDetector;
26 import edu.umd.cs.findbugs.ba.AnalysisContext;
2726 import edu.umd.cs.findbugs.ba.ClassContext;
2827 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
2928 import edu.umd.cs.findbugs.bcel.BCELUtil;
4140 public class NoteNonNullAnnotations extends BuildNonNullAnnotationDatabase implements Detector, NonReportingDetector {
4241
4342 public NoteNonNullAnnotations(BugReporter bugReporter) {
44 super(
45 AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase() instanceof NullnessAnnotationDatabase ? (NullnessAnnotationDatabase) AnalysisContext
46 .currentAnalysisContext().getNullnessAnnotationDatabase() : null);
43 super(getDatabase());
4744 }
45
46 /**
47 * @return
48 */
49 private static NullnessAnnotationDatabase getDatabase() {
50 return null;
51 }
4852
4953 public void visitClassContext(ClassContext classContext) {
5054
2020
2121 import java.util.HashMap;
2222 import java.util.Map;
23
24 import javax.annotation.CheckForNull;
2325
2426 import org.apache.bcel.classfile.Code;
2527
5254 */
5355 public class NumberConstructor extends OpcodeStackDetector {
5456
55 private final Map<String, XMethod> boxClasses = new HashMap<String, XMethod>();
57 static class Pair {
58 final XMethod boxingMethod;
59 public Pair(XMethod boxingMethod, XMethod parsingMethod) {
60 this.boxingMethod = boxingMethod;
61 this.parsingMethod = parsingMethod;
62 }
63 final XMethod parsingMethod;
64 }
65 private final Map<String, Pair> boxClasses = new HashMap<String, Pair>();
5666
5767 private final BugAccumulator bugAccumulator;
5868
6474 */
6575 public NumberConstructor(BugReporter bugReporter) {
6676 this.bugAccumulator = new BugAccumulator(bugReporter);
67 handle("java/lang/Byte", false, "(B)V");
68 handle("java/lang/Character", false, "(C)V");
69 handle("java/lang/Short", false, "(S)V");
70 handle("java/lang/Integer", false, "(I)V");
71 handle("java/lang/Long", false, "(J)V");
72 handle("java/lang/Float", true, "(F)V");
73 handle("java/lang/Double", true, "(D)V");
77 handle("java/lang/Byte", false, "(B)");
78 handle("java/lang/Character", false, "(C)");
79 handle("java/lang/Short", false, "(S)");
80 handle("java/lang/Integer", false, "(I)");
81 handle("java/lang/Long", false, "(J)");
82 handle("java/lang/Float", true, "(F)");
83 handle("java/lang/Double", true, "(D)");
7484
7585 }
7686
7787 private void handle(@SlashedClassName String className, boolean isFloatingPoint, String sig) {
78 XMethod m = XFactory.createXMethod(ClassName.toDottedClassName(className), "valueOf", sig, true);
79 boxClasses.put(className, m);
88 XMethod boxingMethod = XFactory.createXMethod(ClassName.toDottedClassName(className), "valueOf", sig + "L" + className +";", true);
89 XMethod parsingMethod = XFactory.createXMethod(ClassName.toDottedClassName(className), "valueOf", "(Ljava/lang/String;)" + "L" + className +";", true);
90 boxClasses.put(className, new Pair(boxingMethod, parsingMethod));
8091 }
8192
8293 /**
99110 bugAccumulator.reportAccumulatedBugs();
100111 }
101112
113 private boolean matchArguments(String sig1, String sig2) {
114 int lastParen = sig1.indexOf(')');
115 String args = sig1.substring(0, lastParen+1);
116 return sig2.startsWith(args);
117 }
118
119 private @CheckForNull XMethod getShouldCall() {
120 String cls = getClassConstantOperand();
121 Pair pair = boxClasses.get(cls);
122 if (pair == null)
123 return null;
124 XMethod shouldCall ;
125 if (getSigConstantOperand().startsWith("(Ljava/lang/String;)"))
126 shouldCall = pair.parsingMethod;
127 else
128 shouldCall = pair.boxingMethod;
129
130 if (shouldCall == null) {
131 return null;
132 }
133
134 if (matchArguments(getSigConstantOperand(), shouldCall.getSignature()))
135 return shouldCall;
136
137 return null;
138 }
102139 @Override
103140 public void sawOpcode(int seen) {
104141 // only acts on constructor invoke
109146 if (!"<init>".equals(getNameConstantOperand())) {
110147 return;
111148 }
112 String cls = getClassConstantOperand();
113 XMethod shouldCall = boxClasses.get(cls);
114 if (shouldCall == null) {
149 @SlashedClassName String cls = getClassConstantOperand();
150 XMethod shouldCall = getShouldCall();
151 if (shouldCall == null)
115152 return;
116 }
117
118 if (!shouldCall.getSignature().substring(0, 3).equals(getSigConstantOperand().substring(0, 3))) {
119 return;
120 }
121153
122154 int prio;
123155 String type;
132164 if (value < -128 || value > 127)
133165 prio = LOW_PRIORITY;
134166 }
135
136167 type = "DM_NUMBER_CTOR";
137168 }
138169
5959 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
6060 import edu.umd.cs.findbugs.util.ClassName;
6161
62 ;
63
6462 /**
6563 * RuntimeExceptionCapture
6664 *
338338 }
339339
340340 /**
341 * @param isLocked
342341 * @return
343342 */
344343 private boolean isLocked() {
359358 return false;
360359 }
361360
361 @Override
362 public void report() {
363 // Report any fields that were not accessed, but are potentially
364 // accessible
365 for (BugInstance bug : pendingBugs.values()) {
366 reporter.reportBug(bug);
367 }
368 }
369
362370 }
202202 }
203203
204204 if (seen == ATHROW) {
205 int sz = edu.umd.cs.findbugs.visitclass.Util.getSizeOfSurroundingTryBlock(getMethod(), null, getPC());
205 int sz = edu.umd.cs.findbugs.visitclass.Util.getSizeOfSurroundingTryBlock(getMethod(), (String) null, getPC());
206206 if (sz == Integer.MAX_VALUE) {
207207
208208 BitSet dead = new BitSet();
1818
1919 package edu.umd.cs.findbugs.detect;
2020
21 import org.apache.bcel.Constants;
2221 import org.apache.bcel.classfile.Code;
2322
2423 import edu.umd.cs.findbugs.BugAccumulator;
25 import edu.umd.cs.findbugs.BugInstance;
2624 import edu.umd.cs.findbugs.BugReporter;
27 import edu.umd.cs.findbugs.OpcodeStack;
28 import edu.umd.cs.findbugs.OpcodeStack.Item;
29 import edu.umd.cs.findbugs.ba.XMethod;
3025 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
3126
3227 public class TestingGround extends OpcodeStackDetector {
4237
4338 @Override
4439 public void visit(Code code) {
45 boolean interesting = true;
46 if (interesting) {
47 // initialize any variables we want to initialize for the method
48 super.visit(code); // make callbacks to sawOpcode for all opcodes
49 }
50 accumulator.reportAccumulatedBugs();
51 }
40 System.out.println(getFullyQualifiedMethodName());
41 super.visit(code);
42 System.out.println();
43 }
5244
5345 @Override
5446 public void sawOpcode(int seen) {
55 switch (seen) {
56 case Constants.IF_ICMPEQ:
57 case Constants.IF_ICMPNE:
58 OpcodeStack.Item left = stack.getStackItem(1);
59 OpcodeStack.Item right = stack.getStackItem(0);
60 if (bad(left, right) || bad(right, left))
61
62 accumulator.accumulateBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this)
63 .addValueSource(left, this).addValueSource(right, this), this);
64 }
65
66 }
67
68 private boolean bad(Item left, Item right) {
69 XMethod m = left.getReturnValueOf();
70
71 if (m == null)
72 return false;
73 Object value = right.getConstant();
74 if (!(value instanceof Integer) || ((Integer) value).intValue() == 0)
75 return false;
76 if (m.isStatic() || !m.isPublic())
77 return false;
78
79 if (m.getName().equals("compareTo") && m.getSignature().equals("(Ljava/lang/Object;)I"))
80 return true;
81 if (m.getName().equals("compare") && m.getSignature().equals("(Ljava/lang/Object;Ljava/lang/Object;)I"))
82 return true;
83
84 return false;
47 System.out.printf("%3d %-15s %s%n", getPC(), OPCODE_NAMES[seen], stack);
8548
8649 }
8750
1818
1919 package edu.umd.cs.findbugs.detect;
2020
21 import java.math.BigDecimal;
22
2321 import org.apache.bcel.classfile.Code;
2422
25 import edu.umd.cs.findbugs.BugInstance;
2623 import edu.umd.cs.findbugs.BugReporter;
27 import edu.umd.cs.findbugs.OpcodeStack;
2824 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
2925
3026 public class TestingGround2 extends OpcodeStackDetector {
4642
4743 @Override
4844 public void sawOpcode(int seen) {
49 if (seen == INVOKESPECIAL && getClassConstantOperand().equals("java/math/BigDecimal")
50 && getNameConstantOperand().equals("<init>") && getSigConstantOperand().equals("(D)V")) {
51 OpcodeStack.Item top = stack.getStackItem(0);
52 Object value = top.getConstant();
53 if (value instanceof Double) {
54 double arg = ((Double) value).doubleValue();
55 String dblString = Double.toString(arg);
56 String bigDecimalString = new BigDecimal(arg).toString();
57 boolean ok = dblString.equals(bigDecimalString) || dblString.equals(bigDecimalString + ".0");
58
59 if (!ok) {
60 boolean scary = dblString.length() <= 8 && dblString.toUpperCase().indexOf("E") == -1;
61 bugReporter.reportBug(new BugInstance(this, "TESTING", scary ? NORMAL_PRIORITY : LOW_PRIORITY)
62 .addClassAndMethod(this).addString(dblString).addSourceLine(this));
63 }
64 }
65
66 }
67
45
6846 }
6947
7048 }
2121 import edu.umd.cs.findbugs.BugReporter;
2222 import edu.umd.cs.findbugs.Detector;
2323 import edu.umd.cs.findbugs.TrainingDetector;
24 import edu.umd.cs.findbugs.ba.AnalysisContext;
2524 import edu.umd.cs.findbugs.ba.ClassContext;
26 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
2725
2826 /**
2927 * Training detector to store NonNull, PossiblyNull and CheckForNull annotations
4038 public class TrainNonNullAnnotations extends BuildNonNullAnnotationDatabase implements Detector, TrainingDetector {
4139
4240 public TrainNonNullAnnotations(BugReporter bugReporter) {
43 super(
44 AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase() instanceof NullnessAnnotationDatabase ? (NullnessAnnotationDatabase) AnalysisContext
45 .currentAnalysisContext().getNullnessAnnotationDatabase() : null);
41 super(null);
4642 }
4743
4844 /*
3535 import edu.umd.cs.findbugs.ba.XClass;
3636 import edu.umd.cs.findbugs.ba.XFactory;
3737 import edu.umd.cs.findbugs.ba.XMethod;
38 import edu.umd.cs.findbugs.bcel.BCELUtil;
3839 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
3940 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
4041 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
102103 if (clazz == null)
103104 return false;
104105 JavaClass superClass = clazz.getSuperClass();
106 if (superClass == null)
107 return false;
108 try {
109 XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class,
110 DescriptorFactory.createClassDescriptorFromDottedClassName(superClass.getClassName()));
111 if (xClass.hasStubs())
112 return true;
113 } catch (CheckedAnalysisException e) {
114 return true;
115 }
116
105117 if (definedInThisClassOrSuper(superClass, method))
106118 return true;
107119 for (JavaClass i : clazz.getInterfaces())
120132 }
121133
122134 private boolean skip(Method obj) {
123 if (obj.isSynthetic())
135 if (BCELUtil.isSynthetic(obj))
124136 return true;
125137 if (obj.isPrivate())
126138 return true;
170182 }
171183 pendingBug.addClass(superclassName).describe(role);
172184 try {
173 XClass from = Global.getAnalysisCache().getClassAnalysis(XClass.class,
185 XClass from = Global.getAnalysisCache().getClassAnalysis(XClass.class,
174186 DescriptorFactory.createClassDescriptorFromDottedClassName(superclassName));
175187 XMethod potentialMatch = null;
176 for(XMethod m : from.getXMethods())
188 for(XMethod m : from.getXMethods())
177189 if (!m.isStatic() && !m.isPrivate() && m.getName().toLowerCase().equals(obj.getName().toLowerCase())) {
178190 if (potentialMatch == null)
179191 potentialMatch = m;
186198 if (potentialMatch != null)
187199 pendingBug.addMethod(potentialMatch)
188200 .describe(MethodAnnotation.METHOD_DID_YOU_MEAN_TO_OVERRIDE);
189
201
190202 } catch (CheckedAnalysisException e) {
191 // TODO Auto-generated catch block
192 e.printStackTrace();
203 AnalysisContext.logError("Error: ", e);
193204 }
194205 } else {
195206 pendingBug.setPriority(pendingBug.getPriority() - 1);
3737 * Find occurrences of Math using constants, where the result of the calculation
3838 * can be determined statically. Replacing the math formula with the constant
3939 * performs better, and sometimes is more accurate.
40 *
40 *
4141 * @author Dave Brosius
4242 */
4343 public class UnnecessaryMath extends BytecodeScanningDetector implements StatelessDetector {
4545
4646 static final int SEEN_DCONST = 1;
4747
48 private BugReporter bugReporter;
48 private final BugReporter bugReporter;
4949
5050 private int state = SEEN_NOTHING;
5151
5252 private double constValue;
5353
54 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
5455 private static final Set<String> zeroMethods = new HashSet<String>() {
5556 {
5657 add("acos");
7576 }
7677 };
7778
79 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
7880 private static final Set<String> oneMethods = new HashSet<String>() {
7981 {
8082 add("acos");
9092 }
9193 };
9294
95 @edu.umd.cs.findbugs.internalAnnotations.StaticConstant
9396 private static final Set<String> anyMethods = new HashSet<String>() {
9497 {
9598 add("abs");
6565 import edu.umd.cs.findbugs.ba.vna.ValueNumber;
6666 import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow;
6767 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
68 import edu.umd.cs.findbugs.bcel.BCELUtil;
6869 import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
6970 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
7071 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
499500 priority--;
500501 if (getThisClass().isPrivate() || getMethod().isPrivate())
501502 priority++;
502 if (getClassName().indexOf('$') != -1 || getMethod().isSynthetic() || f.isSynthetic()
503 if (getClassName().indexOf('$') != -1 || BCELUtil.isSynthetic(getMethod()) || f.isSynthetic()
503504 || f.getName().indexOf('$') >= 0)
504505 priority++;
505506
2525 import org.apache.bcel.Repository;
2626 import org.apache.bcel.classfile.Attribute;
2727 import org.apache.bcel.classfile.Code;
28 import org.apache.bcel.classfile.ExceptionTable;
2829 import org.apache.bcel.classfile.JavaClass;
2930 import org.apache.bcel.classfile.Method;
3031 import org.apache.bcel.classfile.Synthetic;
3536 import edu.umd.cs.findbugs.BytecodeScanningDetector;
3637 import edu.umd.cs.findbugs.StatelessDetector;
3738 import edu.umd.cs.findbugs.ba.ClassContext;
39 import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
3840
3941 public class UselessSubclassMethod extends BytecodeScanningDetector implements StatelessDetector {
4042
4143 enum State {
4244 SEEN_NOTHING, SEEN_PARM, SEEN_LAST_PARM, SEEN_INVOKE, SEEN_RETURN, SEEN_INVALID
43 };
44
45 private BugReporter bugReporter;
46
47 private String superclassName;
45 }
46
47 private final BugReporter bugReporter;
48
49 private @DottedClassName String superclassName;
4850
4951 private State state;
5052
131133 if ((state == State.SEEN_RETURN) && (invokePC != 0)) {
132134 // Do this check late, as it is potentially expensive
133135 Method superMethod = findSuperclassMethod(superclassName, getMethod());
134 if ((superMethod == null) || accessModifiersAreDifferent(getMethod(), superMethod))
136 if ((superMethod == null) || differentAttributes(getMethod(), superMethod)
137 || getMethod().isProtected()
138 && !samePackage(getDottedClassName(), superclassName))
135139 return;
136140
137141 bugReporter.reportBug(new BugInstance(this, "USM_USELESS_SUBCLASS_METHOD", LOW_PRIORITY).addClassAndMethod(
143147 }
144148 }
145149
150 public String getPackage(@DottedClassName String classname) {
151 int i = classname.lastIndexOf('.');
152 if (i < 0)
153 return "";
154 return classname.substring(0,i);
155 }
156 public boolean samePackage(@DottedClassName String classname1, @DottedClassName String classname2) {
157 return getPackage(classname1).equals(getPackage(classname2));
158
159 }
146160 @Override
147161 public void sawOpcode(int seen) {
148162 switch (state) {
233247 state = State.SEEN_INVALID;
234248 }
235249
236 private Method findSuperclassMethod(String superclassName, Method subclassMethod) throws ClassNotFoundException {
250 private Method findSuperclassMethod(@DottedClassName String superclassName, Method subclassMethod) throws ClassNotFoundException {
237251
238252 String methodName = subclassMethod.getName();
239253 Type[] subArgs = null;
255269 }
256270
257271 if (!superclassName.equals("Object")) {
258 String superSuperClassName = superClass.getSuperclassName();
272 @DottedClassName String superSuperClassName = superClass.getSuperclassName();
259273 if (superSuperClassName.equals(superclassName)) {
260274 throw new ClassNotFoundException("superclass of " + superclassName + " is itself");
261275 }
262 return findSuperclassMethod(superClass.getSuperclassName(), subclassMethod);
276 return findSuperclassMethod(superSuperClassName, subclassMethod);
263277 }
264278
265279 return null;
266280 }
267281
268 private boolean accessModifiersAreDifferent(Method m1, Method m2) {
282 HashSet<String> thrownExceptions(Method m) {
283 HashSet<String> result = new HashSet<String>();
284 ExceptionTable exceptionTable = m.getExceptionTable();
285 if (exceptionTable != null)
286 for (String e : exceptionTable.getExceptionNames())
287 result.add(e);
288 return result;
289 }
290 private boolean differentAttributes(Method m1, Method m2) {
291 if (m1.getAnnotationEntries().length > 0 || m2.getAnnotationEntries().length > 0)
292 return true;
269293 int access1 = m1.getAccessFlags()
270294 & (Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_PUBLIC | Constants.ACC_FINAL);
271295 int access2 = m2.getAccessFlags()
272296 & (Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_PUBLIC | Constants.ACC_FINAL);
273297
274 return access1 != access2;
298
299 m1.getAnnotationEntries();
300 if (access1 != access2)
301 return true;
302 if (!thrownExceptions(m1).equals(thrownExceptions(m2)))
303 return false;
304 m1.getExceptionTable();
305 return false;
275306 }
276307 }
3535 public class VolatileUsage extends BytecodeScanningDetector {
3636 enum IncrementState {
3737 START, GETFIELD, LOADCONSTANT, ADD
38 };
38 }
3939
40 private BugReporter bugReporter;
40 private final BugReporter bugReporter;
4141
4242 public VolatileUsage(BugReporter bugReporter) {
4343 this.bugReporter = bugReporter;
2828 import edu.umd.cs.findbugs.BugReporter;
2929 import edu.umd.cs.findbugs.BytecodeScanningDetector;
3030 import edu.umd.cs.findbugs.ba.ClassContext;
31 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
3132
3233 public class XMLFactoryBypass extends BytecodeScanningDetector {
33 private BugReporter bugReporter;
34 private final BugReporter bugReporter;
3435
36 @StaticConstant
3537 private static final Set<String> xmlInterfaces = new HashSet<String>() {
3638 static final long serialVersionUID = -9117982073509840017L;
3739 {
125125 * @param fileName
126126 * name of the filter file
127127 * @throws IOException
128 * @throws SAXException
129 * @throws FilterException
130128 */
131129 public Filter(String fileName) throws IOException {
132130 try {
2222 import java.util.HashMap;
2323 import java.util.Map;
2424
25 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
26
2527 /**
2628 * @author pugh
2729 */
3335
3436 final String name;
3537
38 @StaticConstant
3639 private static final Map<String, RelationalOp> map = new HashMap<String, RelationalOp>();
3740
3841 public static RelationalOp byName(String s) {
2323 import java.util.Iterator;
2424 import java.util.LinkedList;
2525
26 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2727
2828 /**
2929 * Perform a depth first search on a graph. Algorithm based on Cormen, et. al,
243243 *
244244 * @return the array of finish times
245245 */
246 @SuppressWarnings("EI")
246 @SuppressFBWarnings("EI")
247247 public int[] getFinishTimeList() {
248248 return finishTimeList;
249249 }
2323 import java.io.Serializable;
2424 import java.util.Comparator;
2525
26 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2727
2828 /**
2929 * Comparator to compare GraphVertex objects by their visitation times in a
5555 * @param direction
5656 * either ASCENDING or DESCENDING
5757 */
58 @SuppressWarnings("EI2")
58 @SuppressFBWarnings("EI2")
5959 public VisitationTimeComparator(int[] visitationTimeList, int direction) {
6060 m_visitationTimeList = visitationTimeList;
6161 m_direction = direction;
00 package edu.umd.cs.findbugs.gui2;
11
2 import java.awt.Dimension;
23 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
45 import java.util.List;
1213 import edu.umd.cs.findbugs.cloud.CloudPlugin;
1314
1415 public class CloudCommentsPaneSwing extends CloudCommentsPane {
16
17
18 @Override
19 public Dimension getPreferredSize() {
20 return super.getMinimumSize();
21
22 }
1523
1624 @Override
1725 protected void setupLinksOrButtons() {
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.internalAnnotations;
20
21 import java.lang.annotation.Documented;
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24
25 /**
26 * Any class or package annotation with this annotation must avoid using mutable static data,
27 * and instead use the AnalysisContext for any cross-instance data.
28 */
29
30 @Documented
31 @Retention(RetentionPolicy.RUNTIME)
32 public @interface AnalysisContextContained {
33
34 }
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.internalAnnotations;
20
21 import java.lang.annotation.Documented;
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24
25 /**
26 * Denotes a static field that is initialized to a constant value and then never changes.
27 * OK to share between analysis runs.
28 *
29 */
30
31 @Documented
32 @Retention(RetentionPolicy.RUNTIME)
33 public @interface StaticConstant {
34
35 }
4444 import java.io.Writer;
4545 import java.net.URL;
4646 import java.net.URLConnection;
47 import java.util.Arrays;
4847
4948 import javax.annotation.CheckForNull;
5049 import javax.annotation.WillClose;
7675 close(in);
7776 }
7877 }
78
79 static byte[] copyOf(byte[] original, int newLength) {
80 byte[] copy = new byte[newLength];
81 System.arraycopy(original, 0, copy, 0,
82 Math.min(original.length, newLength));
83 return copy;
84 }
85
7986
8087 public static byte[] readAll(@WillClose InputStream in, int size) throws IOException {
8188 try {
9097 }
9198
9299 if (pos < size)
93 return Arrays.copyOf(result, pos);
100 return copyOf(result, pos);
94101 int nextByte = in.read();
95102 if (nextByte == -1)
96103 return result;
97104 size = size * 2 + 500;
98 result = Arrays.copyOf(result, size);
105 result = copyOf(result, size);
99106 result[pos++] = (byte) nextByte;
100107 }
101108 } finally {
2222 * One lexical token of an external annotations file.
2323 *
2424 * @author David Hovemeyer
25 * @see http://pag.csail.mit.edu/jsr308/annotation-file-utilities/
25 * @see <a href="http://pag.csail.mit.edu/jsr308/annotation-file-utilities/">
26 * http://pag.csail.mit.edu/jsr308/annotation-file-utilities/</a>
2627 */
2728 class JAIFToken {
2829 JAIFTokenKind kind;
7373 if (controller == null)
7474 return;
7575 try {
76 captureMemorySnapshot.invoke(controller);
76 System.gc();
77 captureMemorySnapshot.invoke(controller);
7778 } catch (RuntimeException e) {
7879 throw e;
7980 } catch (Exception e) {
3333 import edu.umd.cs.findbugs.ba.Hierarchy;
3434 import edu.umd.cs.findbugs.ba.JavaClassAndMethod;
3535 import edu.umd.cs.findbugs.ba.SignatureParser;
36 import edu.umd.cs.findbugs.bcel.BCELUtil;
3637 import edu.umd.cs.findbugs.xml.XMLAttributeList;
3738 import edu.umd.cs.findbugs.xml.XMLOutput;
3839 import edu.umd.cs.findbugs.xml.XMLWriteable;
118119 * the method
119120 * @return true if the method overrides a superclass/superinterface method,
120121 * false if not
121 * @throws ClassNotFoundException
122122 */
123123 private boolean overridesSuperclassMethod(JavaClass javaClass, Method method) {
124124 if (method.isStatic())
155155 * @return true if the member is synthetic
156156 */
157157 private boolean isSynthetic(FieldOrMethod member) {
158 if (member.isSynthetic()) // this never works, but worth a try
158 if (BCELUtil.isSynthetic(member)) // this never works, but worth a try
159159 return true;
160160
161161 String name = member.getName();
342342
343343 private void buildPassList(ConstraintGraph constraintGraph) throws OrderingConstraintException {
344344
345 int passCount = 0;
345346 while (constraintGraph.getNumVertices() > 0) {
346347 List<DetectorNode> inDegreeZeroList = new LinkedList<DetectorNode>();
347348 // Get all of the detectors nodes with in-degree 0.
351352 DetectorNode node = i.next();
352353 if (constraintGraph.getNumIncomingEdges(node) == 0) {
353354 inDegreeZeroList.add(node);
355 } else if (DEBUG ) {
356 System.out.println("Can't schedule " + node.getFactory().getShortName());
357 Iterator<ConstraintEdge> incomingEdgeIterator = constraintGraph.incomingEdgeIterator(node);
358 while (incomingEdgeIterator.hasNext()) {
359 ConstraintEdge edge = incomingEdgeIterator.next();
360 System.out.println(" requires " + edge.getSource().getFactory().getShortName());
361
362 }
354363 }
355364
356365 }
369378 // it doesn't assign them a position in the pass.
370379 AnalysisPass pass = new AnalysisPass();
371380 addPass(pass);
381 passCount++;
372382 for (DetectorNode node : inDegreeZeroList) {
373383 assignToPass(node.getFactory(), pass);
374384 }
22 import java.io.IOException;
33 import java.io.InputStream;
44 import java.io.OutputStream;
5 import java.io.OutputStreamWriter;
65 import java.io.StringWriter;
76 import java.net.HttpURLConnection;
87 import java.net.URI;
2928 import javax.annotation.Nonnull;
3029 import javax.annotation.WillClose;
3130
31 import org.dom4j.Document;
32 import org.dom4j.Element;
33 import org.dom4j.io.SAXReader;
34 import org.dom4j.io.XMLWriter;
35
3236 import edu.umd.cs.findbugs.DetectorFactoryCollection;
3337 import edu.umd.cs.findbugs.FindBugs;
3438 import edu.umd.cs.findbugs.Plugin;
3842 import edu.umd.cs.findbugs.util.Util;
3943 import edu.umd.cs.findbugs.xml.OutputStreamXMLOutput;
4044 import edu.umd.cs.findbugs.xml.XMLUtil;
41
42 import org.dom4j.Document;
43 import org.dom4j.Element;
44 import org.dom4j.io.SAXReader;
45 import org.dom4j.io.XMLWriter;
4645
4746 public class UpdateChecker {
4847
128127 return Long.parseLong(oldSeen) + DONT_REMIND_WINDOW;
129128 } catch (Exception e) {
130129 return 0;
131 }
130 }
132131 }
133132 static final long DONT_REMIND_WINDOW = 3L*24*60*60*1000;
134133 public boolean updatesHaveBeenSeenBefore(Collection<UpdateChecker.PluginUpdate> updates) {
157156 private void waitForCompletion(final CountDownLatch latch, final boolean force) {
158157 Util.runInDameonThread(new Runnable() {
159158 public void run() {
159 if (DEBUG)
160 System.out.println("Checking for version updates");
160161 try {
161162 if (! latch.await(15, TimeUnit.SECONDS)) {
162163 logError(Level.INFO, "Update check timed out");
197198 return;
198199 }
199200 final String entryPoint = getEntryPoint();
200 if ((entryPoint.contains("edu.umd.cs.findbugs.FindBugsTestCase")
201 if ((entryPoint.contains("edu.umd.cs.findbugs.FindBugsTestCase")
201202 || entryPoint.contains("edu.umd.cs.findbugs.cloud.appEngine.AbstractWebCloudTest"))
202203 && (url.getScheme().equals("http") || url.getScheme().equals("https"))) {
203204 LOGGER.fine("Skipping update check because we're running in FindBugsTestCase and using "
204205 + url.getScheme());
205206 return;
206207 }
207 Util.runInDameonThread(new Runnable() {
208 Runnable r = new Runnable() {
208209 public void run() {
209210 try {
210211 actuallyCheckforUpdates(url, plugins, entryPoint);
216217 latch.countDown();
217218 }
218219 }
219 }, "Check for updates");
220 }
221
220 };
221 if (DEBUG)
222 r.run();
223 else
224 Util.runInDameonThread(r, "Check for updates");
225 }
226
227 static final boolean DEBUG = SystemProperties.getBoolean("findbugs.updatecheck.debug");
222228 /** protected for testing */
223229 protected void actuallyCheckforUpdates(URI url, Collection<Plugin> plugins, String entryPoint) throws IOException {
224230 LOGGER.fine("Checking for updates at " + url + " for " + getPluginNames(plugins));
231 if (DEBUG)
232 System.out.println(url);
225233 HttpURLConnection conn = (HttpURLConnection) url.toURL().openConnection();
226234 conn.setDoInput(true);
227235 conn.setDoOutput(true);
228236 conn.setRequestMethod("POST");
229237 conn.connect();
230238 OutputStream out = conn.getOutputStream();
231 writeXml(out, plugins, entryPoint);
239 writeXml(out, plugins, entryPoint, true);
232240 // for debugging:
233 // writeXml(System.out, plugins, entryPoint);
241 if (DEBUG) {
242 System.out.println("Sending");
243 writeXml(System.out, plugins, entryPoint, false);
244 }
234245 int responseCode = conn.getResponseCode();
235246 if (responseCode != 200) {
236247 logError(SystemProperties.ASSERTIONS_ENABLED ? Level.WARNING : Level.FINE,
243254 }
244255
245256 /** protected for testing */
246 protected final void writeXml(OutputStream out, Collection<Plugin> plugins, String entryPoint) throws IOException {
257 protected final void writeXml(OutputStream out, Collection<Plugin> plugins, String entryPoint,
258 boolean finish) throws IOException {
247259 OutputStreamXMLOutput xmlOutput = new OutputStreamXMLOutput(out);
248260 try {
249261 xmlOutput.beginDocument();
285297 xmlOutput.closeTag("findbugs-invocation");
286298 xmlOutput.flush();
287299 } finally {
288 xmlOutput.finish();
300 if (finish)
301 xmlOutput.finish();
289302 }
290303 }
291304
295308 InputStream inputStream) {
296309 try {
297310 Document doc = new SAXReader().read(inputStream);
298 // StringWriter stringWriter = new StringWriter();
299 // XMLWriter xmlWriter = new XMLWriter(stringWriter);
300 // xmlWriter.write(doc);
301 // xmlWriter.close();
302 // System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
311 if (DEBUG) {
312 StringWriter stringWriter = new StringWriter();
313 XMLWriter xmlWriter = new XMLWriter(stringWriter);
314 xmlWriter.write(doc);
315 xmlWriter.close();
316 System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
317 }
303318 List<Element> pluginEls = XMLUtil.selectNodes(doc, "fb-plugin-updates/plugin");
304319 Map<String, Plugin> map = new HashMap<String, Plugin>();
305320 for (Plugin p : plugins)
392407 Preferences prefs = Preferences.userNodeForPackage(UpdateChecker.class);
393408 long uuid = prefs.getLong("uuid", 0);
394409 if (uuid == 0) {
395 uuid = random.nextLong();
410 uuid = random.nextLong();
396411 prefs.putLong("uuid", uuid);
397412 }
398413 return Long.toString(uuid, 16);
477492 URI redirect = checker.getRedirectURL(false);
478493 if (redirect != null)
479494 System.out.println("All update checks redirected to " + redirect);
480 checker.writeXml(System.out, dfc.plugins(), "UpdateChecker");
495 checker.writeXml(System.out, dfc.plugins(), "UpdateChecker", true);
481496
482497
483498 }
2222 import java.util.Locale;
2323 import java.util.Set;
2424
25 import edu.umd.cs.findbugs.internalAnnotations.StaticConstant;
26
2527 /**
2628 * Utility methods for working with zip/jar archives.
27 *
29 *
2830 * @author David Hovemeyer
2931 */
3032 public class Archive {
3234 /**
3335 * File extensions that indicate an archive (zip, jar, or similar).
3436 */
37 @StaticConstant
3538 static public final Set<String> ARCHIVE_EXTENSION_SET = new HashSet<String>();
3639 static {
3740 ARCHIVE_EXTENSION_SET.add(".jar");
4447 /**
4548 * Determine whether or not the given filename appears to identify a zip/jar
4649 * archive.
47 *
50 *
4851 * @param fileName
4952 * the filename
5053 * @return true if the filename appears to identify an archive, false
5154 * otherwise
5255 */
5356 public static boolean isArchiveFileName(String fileName) {
57 String extension = getExtension(fileName);
58 return ARCHIVE_EXTENSION_SET.contains(extension);
59 }
60
61 /**
62 * @param fileName
63 * @return
64 */
65 private static String getExtension(String fileName) {
5466 int lastDot = fileName.lastIndexOf('.');
5567 if (lastDot < 0) {
56 return false;
68 return fileName;
5769 }
5870 String extension = fileName.substring(lastDot).toLowerCase(Locale.ENGLISH);
59 return ARCHIVE_EXTENSION_SET.contains(extension);
71 return extension;
72 }
73
74 public static boolean isLibraryFileName(String fileName) {
75 String extension = getExtension(fileName);
76 return extension.equals(".jar");
6077 }
6178 }
1818
1919 package edu.umd.cs.findbugs.util;
2020
21 import javax.annotation.CheckForNull;
2122 import javax.annotation.meta.When;
2223
2324 import edu.umd.cs.findbugs.classfile.DescriptorFactory;
5152 return "L" + className + ";";
5253 }
5354
55 public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) {
56 if (!cls.startsWith("java/lang/")) return null;
57 cls = cls.substring(10);
58 if (cls.equals("Integer")) return "I";
59 if (cls.equals("Float")) return "F";
60 if (cls.equals("Double")) return "D";
61 if (cls.equals("Long")) return "J";
62 if (cls.equals("Byte")) return "B";
63 if (cls.equals("Character")) return "C";
64 if (cls.equals("Short")) return "S";
65 if (cls.equals("Boolean")) return "Z";
66 return null;
67 }
68
5469 /**
5570 * Converts from signature to slashed class name
5671 * (e.g., from Ljava/lang/String; to java/lang/String).
5772 * Returns null if it is the signature for an array or
58 * primitive type.
59 */
60 public static @javax.annotation.CheckForNull
73 * primitive type.
74 */
75 public static @CheckForNull
6176 @SlashedClassName
6277 String fromFieldSignature(String signature) {
6378 if (signature.charAt(0) != 'L') {
6565 } else if (name.equals("p")) {
6666
6767 }
68 };
68 }
6969
7070 @Override
7171 protected void writeEmbeddedTags(AttributeSet attr) throws IOException {
9393
9494 @Override
9595 protected void incrIndent() {
96 };
96 }
9797
9898 @Override
9999 protected void decrIndent() {
100 };
100 }
101101
102102 @Override
103103 protected void emptyTag(Element elem) throws IOException, BadLocationException {
104104 if (elem.getName().equals("content"))
105105 super.emptyTag(elem);
106 };
106 }
107107
108108 @Override
109109 protected void text(Element elem) throws IOException, BadLocationException {
127127 }
128128
129129 private HTML() {
130 };
130 }
131131
132132 public static void convertHtmlToText(Reader reader, Writer writer) throws IOException, BadLocationException {
133133
111111 * escape sequences. This method will be invoked automatically the first
112112 * time a string is escaped/unescaped.
113113 *
114 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets>Extensible Markup
114 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets">Extensible Markup
115115 * Language (XML) 1.0 (Fifth Edition)</a>
116116 */
117117 public static void initializeEscapeMap() {
150150 * a string
151151 * @return the same string with characters not permitted by the XML
152152 * specification escaped
153 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets>Extensible Markup
153 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets">Extensible Markup
154154 * Language (XML) 1.0 (Fifth Edition)</a>
155155 * @see <a
156156 * href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String)">org.apache.commons.lang.StringEscapeUtils
227227 * @param s
228228 * a string
229229 * @return the same string with XML entities/escape sequences unescaped
230 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets>Extensible Markup
230 * @see <a href="http://www.w3.org/TR/REC-xml/#charsets">Extensible Markup
231231 * Language (XML) 1.0 (Fifth Edition)</a>
232232 * @see <a
233233 * href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#unescapeXml(java.lang.String)">org.apache.commons.lang.StringEscapeUtils
545545 return s;
546546 }
547547
548 /**
549 * @return
550 * @throws NoSuchAlgorithmException
551 */
552548 static public @Nonnull MessageDigest getMD5Digest() {
553549 try {
554550 MessageDigest digest = MessageDigest.getInstance("MD5");
99
1010 static class PropertyReadAt extends Exception {
1111 private static final long serialVersionUID = 1L;
12 };
12 }
1313
14 private Map<String, PropertyReadAt> propertReadAt = new HashMap<String, PropertyReadAt>();
14 private final Map<String, PropertyReadAt> propertReadAt = new HashMap<String, PropertyReadAt>();
1515
1616 private WriteOnceProperties(Properties initialValue) {
1717 super.putAll(initialValue);
4141 import org.apache.bcel.classfile.ConstantString;
4242 import org.apache.bcel.classfile.LineNumberTable;
4343
44 import edu.umd.cs.findbugs.annotations.SuppressWarnings;
44 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4545 import edu.umd.cs.findbugs.ba.AnalysisContext;
4646 import edu.umd.cs.findbugs.ba.Hierarchy2;
4747 import edu.umd.cs.findbugs.ba.XClass;
195195 return getReferencedXClass();
196196 }
197197
198 public boolean isMethodCall() {
199 switch(opcode) {
200 default: return false;
201 case INVOKEDYNAMIC:
202 case INVOKEINTERFACE:
203 case INVOKESPECIAL:
204 case INVOKEVIRTUAL:
205 case INVOKESTATIC:
206 return true;
207
208 }
209 }
198210 public MethodDescriptor getMethodDescriptorOperand() {
199211 if (nameConstantOperand == NOT_AVAILABLE)
200212 throw new IllegalStateException("getMethodDescriptorOperand called but value not available");
409421 return opcode == LOOKUPSWITCH || opcode == TABLESWITCH;
410422 }
411423
412 @SuppressWarnings("EI")
424 @SuppressFBWarnings("EI")
413425 public int[] getSwitchOffsets() {
414426 if (switchOffsets == null)
415427 throw new IllegalStateException("getSwitchOffsets called but value not available");
416428 return switchOffsets;
417429 }
418430
419 @SuppressWarnings("EI")
431 @SuppressFBWarnings("EI")
420432 public int[] getSwitchLabels() {
421433 if (switchLabels == null)
422434 throw new IllegalStateException("getSwitchLabels called but value not available");
3434 import org.apache.bcel.classfile.LineNumberTable;
3535 import org.apache.bcel.classfile.Method;
3636
37 import edu.umd.cs.findbugs.internalAnnotations.SlashedClassName;
38 import edu.umd.cs.findbugs.util.ClassName;
39
3740
3841 /**
3942 * @author pugh
4144 public class Util {
4245 /**
4346 * Determine the outer class of obj.
44 *
47 *
4548 * @param obj
4649 * @return JavaClass for outer class, or null if obj is not an outer class
4750 * @throws ClassNotFoundException
6467 return null;
6568 }
6669
70 public static int getSizeOfSurroundingTryBlock(@CheckForNull Method method, Class<? extends Throwable> exceptionClass, int pc) {
71 if (method == null)
72 return Integer.MAX_VALUE;
73
74 return getSizeOfSurroundingTryBlock(method, ClassName.toSlashedClassName(exceptionClass), pc);
75 }
6776 public static int getSizeOfSurroundingTryBlock(@CheckForNull Method method, String vmNameOfExceptionClass, int pc) {
6877 if (method == null)
6978 return Integer.MAX_VALUE;
97106 }
98107
99108 public static int getSizeOfSurroundingTryBlock(ConstantPool constantPool, Code code,
100 @CheckForNull String vmNameOfExceptionClass, int pc) {
109 @CheckForNull @SlashedClassName String vmNameOfExceptionClass, int pc) {
101110 int size = Integer.MAX_VALUE;
102111 int tightStartPC = 0;
103112 int tightEndPC = Integer.MAX_VALUE;
106115 for (CodeException catchBlock : code.getExceptionTable()) {
107116 if (vmNameOfExceptionClass != null) {
108117 Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
109 if (catchType == null || catchType instanceof ConstantClass
110 && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass))
111 continue;
118 if (catchType == null) continue;
119 if (catchType instanceof ConstantClass) {
120 String name = ((ConstantClass) catchType).getBytes(constantPool);
121 if (!name.equals(vmNameOfExceptionClass))
122 continue;
123 }
112124 }
113125 int startPC = catchBlock.getStartPC();
114126 int endPC = catchBlock.getEndPC();
3232 import java.util.SortedSet;
3333 import java.util.TreeMap;
3434 import java.util.TreeSet;
35 import java.util.concurrent.TimeUnit;
3536 import java.util.regex.Pattern;
3637
3738 import org.dom4j.DocumentException;
5758 import edu.umd.cs.findbugs.SourceLineAnnotation;
5859 import edu.umd.cs.findbugs.charsets.UTF8;
5960 import edu.umd.cs.findbugs.cloud.Cloud;
61 import edu.umd.cs.findbugs.cloud.Cloud.SigninState;
6062 import edu.umd.cs.findbugs.config.CommandLine;
6163 import edu.umd.cs.findbugs.filter.FilterException;
6264 import edu.umd.cs.findbugs.filter.Matcher;
434436 return false;
435437 if (callsPattern != null) {
436438 MethodAnnotation m = bug.getAnnotationWithRole(MethodAnnotation.class, MethodAnnotation.METHOD_CALLED);
437 if (m == null)
439 if (m == null)
438440 return false;
439441 if (!callsPattern.matcher(m.getClassName()).find() && !callsPattern.matcher(m.getMethodName()).find())
440442 return false;
482484
483485 if (sloppyUniqueSpecified) {
484486 boolean unique = uniqueSloppy.add(bug);
485 if (unique != sloppyUnique)
487 if (unique != sloppyUnique)
486488 return false;
487489 }
488490
692694
693695 static SourceSearcher sourceSearcher;
694696
697
695698 public static void main(String[] args) throws Exception {
696699 FindBugs.setNoAnalysis();
697700 DetectorFactoryCollection.instance();
749752
750753 }
751754
752 if (commandLine.maxAgeSpecified || commandLine.notAProblemSpecified || commandLine.shouldFixSpecified)
753 origCollection.getCloud().waitUntilIssueDataDownloaded();
755 if (commandLine.maxAgeSpecified || commandLine.notAProblemSpecified || commandLine.shouldFixSpecified) {
756
757 Cloud cloud = origCollection.getCloud();
758 SigninState signinState = cloud.getSigninState();
759 if (!signinState.canDownload()) {
760 disconnect(verbose, commandLine, resultCollection, cloud.getCloudName() + " state is " + signinState
761 + "; ignoring filtering options that require cloud access");
762
763 } else if (!cloud.waitUntilIssueDataDownloaded(20, TimeUnit.SECONDS)) {
764 if (verbose)
765 System.out.println("Waiting for cloud information required for filtering");
766 if (!cloud.waitUntilIssueDataDownloaded(60, TimeUnit.SECONDS))
767 disconnect(verbose, commandLine, resultCollection,
768 "Unable to connect to cloud; ignoring filtering options that require cloud access");
769 }
770 }
754771
755772 commandLine.getReady(origCollection);
756773
804821
805822 }
806823
824
825
826 private static void disconnect(boolean verbose, final FilterCommandLine commandLine, SortedBugCollection resultCollection,
827 String msg) {
828 if (verbose)
829 System.out.println(msg);
830 resultCollection.addError(msg);
831 commandLine.maxAgeSpecified = commandLine.notAProblemSpecified = commandLine.shouldFixSpecified = false;
832 }
833
807834 }
808835
809836 // vim:ts=4
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2005, University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.workflow;
20
21 import edu.umd.cs.findbugs.AnalysisError;
22 import edu.umd.cs.findbugs.FindBugs;
23 import edu.umd.cs.findbugs.SortedBugCollection;
24
25 /**
26 * List the analysis errors in a bug collection
27 *
28 * @author Bill Pugh
29 */
30 public class ListErrors {
31 public static void main(String[] args) throws Exception {
32 if (args.length != 1) {
33 System.out.println("Usage: " + ListErrors.class.getName() + " <bug collection>");
34 System.exit(1);
35 }
36 FindBugs.setNoAnalysis();
37 SortedBugCollection bugCollection = new SortedBugCollection();
38 bugCollection.readXML(args[0]);
39 for (AnalysisError e : bugCollection.getErrors()) {
40 String msg = e.getExceptionMessage();
41 if (msg != null && msg.trim().length() > 0)
42 System.out.println(e.getMessage() + " : " + msg);
43
44 else
45 System.out.println(e.getMessage());
46
47 }
48
49 }
50 }
203203
204204 final MSVOptions options;
205205
206 /**
207 * @param options
208 * @throws NoSuchMethodException
209 * @throws ClassNotFoundException
210 * @throws InterruptedException
211 */
212
213206 public MergeSummarizeAndView(MSVOptions options) {
214207 this.options = options;
215208 }
2222 import java.util.Map;
2323 import java.util.TreeMap;
2424
25 import edu.umd.cs.findbugs.BugCollection;
2526 import edu.umd.cs.findbugs.DetectorFactoryCollection;
2627 import edu.umd.cs.findbugs.FindBugs;
2728 import edu.umd.cs.findbugs.PackageStats;
3132
3233 public class TreemapVisualization {
3334
34 static HashSet<String> buggyPackages = new HashSet<String>();
35 HashSet<String> buggyPackages = new HashSet<String>();
3536
36 static HashSet<String> interiorPackages = new HashSet<String>();
37 HashSet<String> interiorPackages = new HashSet<String>();
3738
38 static Bag<String> goodCodeSize = new Bag<String>(new TreeMap<String, Integer>());
39 Bag<String> goodCodeSize = new Bag<String>(new TreeMap<String, Integer>());
3940
40 static Bag<String> goodCodeCount = new Bag<String>(new TreeMap<String, Integer>());
41 Bag<String> goodCodeCount = new Bag<String>(new TreeMap<String, Integer>());
4142
42 public static void addInteriorPackages(String packageName) {
43 public void addInteriorPackages(String packageName) {
4344 String p = superpackage(packageName);
4445 if (p.length() > 0) {
4546 interiorPackages.add(p);
5960 return p;
6061 }
6162
62 public static boolean isInteriorPackage(String packageName) {
63 public boolean isInteriorPackage(String packageName) {
6364 return interiorPackages.contains(packageName);
6465 }
6566
66 public static void cleanCode(String packageName, int loc, int classes) {
67 public void cleanCode(String packageName, int loc, int classes) {
6768 String superpackage = superpackage(packageName);
6869 if (buggyPackages.contains(superpackage) || interiorPackages.contains(superpackage) || superpackage.length() == 0) {
6970 goodCodeCount.add(packageName, classes);
7576 cleanCode(superpackage, loc, classes);
7677 }
7778
78 public static void main(String[] args) throws Exception {
79 FindBugs.setNoAnalysis();
80 DetectorFactoryCollection.instance(); // load plugins
81
82 SortedBugCollection bugCollection = new SortedBugCollection();
83 int argCount = 0;
84 if (argCount < args.length)
85 bugCollection.readXML(args[argCount++]);
86 else
87 bugCollection.readXML(System.in);
88
79 public void generateTreeMap(BugCollection bugCollection) {
8980 for (PackageStats p : bugCollection.getProjectStats().getPackageStats())
9081 if (p.getTotalBugs() > 0) {
9182 buggyPackages.add(p.getPackageName());
116107 }
117108
118109 }
110
111 public static void main(String[] args) throws Exception {
112 FindBugs.setNoAnalysis();
113 DetectorFactoryCollection.instance(); // load plugins
114
115 SortedBugCollection bugCollection = new SortedBugCollection();
116 int argCount = 0;
117 if (argCount < args.length)
118 bugCollection.readXML(args[argCount++]);
119 else
120 bugCollection.readXML(System.in);
121
122 new TreemapVisualization().generateTreeMap(bugCollection);
123
124 }
119125 }
405405
406406 if (commandLine.outputFilename == null)
407407 verbose = false;
408 if (mostRecent > 0) {
409 argCount = Math.max(argCount, args.length - mostRecent);
410 }
411
408412 String[] firstPathParts = getFilePathParts(args[argCount]);
409413 int commonPrefix = firstPathParts.length;
410414 for (int i = argCount + 1; i <= (args.length - 1); i++) {
412416 commonPrefix = Math.min(commonPrefix, lengthCommonPrefix(firstPathParts, getFilePathParts(args[i])));
413417 }
414418
415 if (mostRecent > 0) {
416 argCount = Math.max(argCount, args.length - mostRecent);
417 }
418 String origFilename = args[argCount++];
419 String origFilename = args[argCount++];
419420 BugCollection origCollection;
420421 origCollection = new SortedBugCollection();
421422 if (verbose)
548549 }
549550 throw new IllegalStateException();
550551 }
551 };
552 }
552553
553554 private void matchBugs(Comparator<BugInstance> bugInstanceComparator, BugCollection origCollection,
554555 BugCollection newCollection) {
2929 import org.junit.Before;
3030 import org.junit.Test;
3131
32 import edu.umd.cs.findbugs.annotations.ExpectWarning;
33 import edu.umd.cs.findbugs.annotations.NoWarning;
3234 import edu.umd.cs.findbugs.config.UserPreferences;
3335
3436 /**
6567 }
6668 throw new IOException("FindBugs test cases not available at " + f.getCanonicalPath());
6769 }
70
6871 public File getFindbugsTestCasesFile(String path) throws IOException {
6972 File f = new File(getFindbugsTestCases(), path);
7073 if (f.exists() && f.canRead())
7174 return f;
7275 throw new IOException("FindBugs test cases file " + path + " not available at " + f.getCanonicalPath());
7376 }
77
7478 @Before
7579 public void setUp() throws Exception {
7680 loadFindbugsPlugin();
7781 }
7882
83 /**
84 * Test for expected warnings on javac compiler generated classes
85 */
7986 @Test
80 public void testAllRegressionFiles() throws IOException, InterruptedException {
87 public void testAllRegressionFilesJavac() throws IOException, InterruptedException {
8188 setUpEngine("build/classes/");
8289
8390 engine.execute();
8794 .getCollection().isEmpty());
8895 }
8996
97 /**
98 * Test for expected warnings on ecj compiler (Eclipse) generated classes
99 * Right now this test does nothing if Eclipse UI were not used to compile project.
100 * The main purpose is for developers hacking in Eclipse to see if there are any unexpected
101 * failures with Eclipse generated bytecode. It would be nice to make the test explicit by using
102 * ecj command line compiler and *always* validate both bytecode kinds.
103 */
90104 @Test
91 public void testBug3053867() throws IOException, InterruptedException {
92 setUpEngine("build/classes/sfBugs/Bug3053867.class",
93 "build/classes/sfBugs/Bug3053867$Foo.class");
105 public void testAllRegressionFilesEcj() throws IOException, InterruptedException {
106 setUpEngine("classesEclipse/");
94107
95108 engine.execute();
96109
97110 // If there are zero bugs, then something's wrong
98 assertFalse("No bugs were reported. Something is wrong with the configuration", bugReporter.getBugCollection()
99 .getCollection().isEmpty());
100 }
101
102 @Test
103 public void testBug3506402() throws IOException, InterruptedException {
104 setUpEngine("../findbugsTestCases/build/classes/nullnessAnnotations/CheckForNullVarArgs.class",
105 "../findbugsTestCases/build/classes/nullnessAnnotations/CheckForNullArrayArgs.class");
106
107 engine.execute();
108
109 // If there are zero bugs, then something's wrong
110 assertFalse("No bugs were reported. Something is wrong with the configuration", bugReporter.getBugCollection()
111 .getCollection().isEmpty());
111 if (bugReporter.getBugCollection().getCollection().isEmpty()) {
112 // TODO better to add ecj compiler and to compile classes with it on build, not with UI.
113 System.err.println("No bugs were reported. Probably Eclipse was not used to compile the project");
114 }
112115 }
113116
114117 @After
129132 /**
130133 * Returns a printable String concatenating bug locations.
131134 */
132 private String getBugsLocations(List<BugInstance> unexpectedBugs) {
135 private static String getBugsLocations(List<BugInstance> unexpectedBugs) {
133136 StringBuilder message = new StringBuilder();
134137 for (BugInstance bugInstance : unexpectedBugs) {
135138 message.append("\n");
136 if (bugInstance.getBugPattern().getType().equals(FB_MISSING_EXPECTED_WARNING))
139 if (bugInstance.getBugPattern().getType().equals(FB_MISSING_EXPECTED_WARNING)) {
137140 message.append("missing ");
138 else
141 } else {
139142 message.append("unexpected ");
143 }
140144 StringAnnotation pattern = (StringAnnotation) bugInstance.getAnnotations().get(2);
141145 message.append(pattern.getValue());
142146 message.append(" ");
148152 /**
149153 * Returns if a bug instance is unexpected for this test.
150154 */
151 private boolean isUnexpectedBug(BugInstance bug) {
155 private static boolean isUnexpectedBug(BugInstance bug) {
152156 return FB_MISSING_EXPECTED_WARNING.equals(bug.getType()) || FB_UNEXPECTED_WARNING.equals(bug.getType());
153157 }
154158
156160 * Loads the default detectors from findbugs.jar, to isolate the test from
157161 * others that use fake plugins.
158162 */
159 private void loadFindbugsPlugin() {
163 private static void loadFindbugsPlugin() {
160164 DetectorFactoryCollection dfc = new DetectorFactoryCollection();
161165 DetectorFactoryCollection.resetInstance(dfc);
162166 }
164168 /**
165169 * Sets up a FB engine to run on the 'findbugsTestCases' project. It enables
166170 * all the available detectors and reports all the bug categories. Uses a
167 * normal priority threshold.
171 * low priority threshold.
168172 */
169173 private void setUpEngine(String... analyzeMe) throws IOException {
170174 this.engine = new FindBugs2();
177181
178182 bugReporter = new BugCollectionBugReporter(project);
179183 bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY);
184 bugReporter.setRankThreshold(BugRanker.VISIBLE_RANK_MAX);
180185
181186 engine.setBugReporter(this.bugReporter);
182187 UserPreferences preferences = UserPreferences.createDefaultUserPreferences();
185190 preferences.getFilterSettings().clearAllCategories();
186191 this.engine.setUserPreferences(preferences);
187192
188 for (String s : analyzeMe)
193 for (String s : analyzeMe) {
189194 project.addFile(getFindbugsTestCasesFile(s).getPath());
195 if(s.indexOf("Eclipse") >= 0){
196 // TODO see testAllRegressionFilesEcj() comments
197 engine.setNoClassOk(true);
198 }
199 }
190200
191201 project.addAuxClasspathEntry("lib/junit.jar");
192202 File lib = getFindbugsTestCasesFile("lib");
193203 for(File f : lib.listFiles()) {
194204 String path = f.getPath();
195 if (f.canRead() && path.endsWith(".jar"))
196 project.addAuxClasspathEntry(path);
205 if (f.canRead() && path.endsWith(".jar")) {
206 project.addAuxClasspathEntry(path);
207 }
197208 }
198209
199210 }
187187 * @param runnable
188188 * a RunnableWithExceptions object whose run() method has some
189189 * JUnit test code
190 * @throws Throwable
190 * @throws Exception
191191 */
192192 protected void executeFindBugsTest(final RunnableWithExceptions runnable) throws Exception {
193193 TestRunnerThread thread = new TestRunnerThread(runnable);
2929 OpcodeStack.Item m2 = OpcodeStack.Item.merge(zeroItem, intItem);
3030 assertNull(m2.getConstant());
3131 }
32
33 public void testMergeTypeOnly() {
34 OpcodeStack.Item intOnly = OpcodeStack.Item.typeOnly("I");
35 OpcodeStack.Item zeroItem = new OpcodeStack.Item("I", 0);
36
37 OpcodeStack.Item m1 = OpcodeStack.Item.merge(intOnly, zeroItem);
38 assertEquals(0,m1.getConstant());
39 OpcodeStack.Item m2 = OpcodeStack.Item.merge(zeroItem, intOnly);
40 assertEquals(0,m2.getConstant());
41 }
3242
3343 }
1717 */
1818 package edu.umd.cs.findbugs.architecture;
1919
20 import java.io.File;
21
2022 import jdepend.framework.JDepend;
2123 import jdepend.framework.JavaPackage;
2224 import junit.framework.TestCase;
2325
2426 /**
2527 * Verifies the package dependencies.
26 *
28 *
2729 * @author Tom\u00e1s Pollak
2830 * @author Andrei Loskutov
2931 */
5658 super.setUp();
5759
5860 // Get the classes root directory
59 String rootDirectory = getClass().getResource("/").getFile();
61 String rootDirectory = new File(getClass().getResource("/").toURI()).getCanonicalPath();
6062
6163 // Setup the JDepend analysis
6264 engine = new JDepend();
2121 import java.util.Arrays;
2222 import java.util.List;
2323
24 import javax.annotation.Nullable;
25
2426 import junit.framework.TestCase;
2527
2628 import org.apache.bcel.generic.ReferenceType;
4143
4244 GenericUtilities.TypeCategory typeCategory;
4345
44 String variable;
46 @Nullable String variable;
4547
46 Type extension;
48 @Nullable Type extension;
4749
4850 List<ReferenceType> parameters;
4951
5052 public void initTest(String bytecodeSignature, String javaSignature, String underlyingClass,
51 GenericUtilities.TypeCategory typeCategory, String variable, Type extension, List<ReferenceType> parameters) {
53 GenericUtilities.TypeCategory typeCategory,
54 @Nullable String variable, @Nullable Type extension, @Nullable List<ReferenceType> parameters) {
5255 this.obj = (GenericObjectType) GenericUtilities.getType(bytecodeSignature);
5356 this.javaSignature = javaSignature;
5457 this.underlyingClass = underlyingClass;
8992 }
9093 }
9194
92 private void compareTypes(Type a, Type b) {
95 private static void compareTypes(Type a, Type b) {
9396 assertEquals(a, b);
9497 if (a instanceof GenericObjectType || b instanceof GenericObjectType) {
9598 assertTrue(a instanceof GenericObjectType && b instanceof GenericObjectType);
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.ba.jsr305;
20
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.fail;
23
24 import java.io.File;
25 import java.util.concurrent.atomic.AtomicBoolean;
26
27 import javax.annotation.Nonnull;
28 import javax.annotation.meta.TypeQualifierValidator;
29 import javax.annotation.meta.When;
30
31 import org.junit.Test;
32
33 import edu.umd.cs.findbugs.internalAnnotations.SlashedClassName;
34
35 /**
36 * @author pugh
37 */
38 public class ValidationSecurityManagerTest {
39
40
41 private static final SlashedClassName ANNOTATION = AnnotationTemplate.class.getAnnotation(SlashedClassName.class);
42 static class BadValidator implements TypeQualifierValidator<SlashedClassName> {
43
44 public @Nonnull
45 When forConstantValue(@Nonnull
46 SlashedClassName annotation, Object value) {
47 Thread t = new Thread() {
48 @Override
49 public void run() {
50 System.out.println("bang");
51 }
52 };
53 t.start();
54 return When.NEVER;
55 }
56
57 }
58
59 public When test(TypeQualifierValidator<SlashedClassName> validator) {
60 return ValidationSecurityManager.sandboxedValidation(ANNOTATION, validator, "java/lang/String");
61
62 }
63
64 public void havePermissions() throws InterruptedException {
65 final AtomicBoolean b = new AtomicBoolean(false);
66 Thread t = new Thread() {
67 @Override
68 public void run() {
69 b.set(true);
70 }
71 };
72 t.start();
73 t.join();
74 assertEquals(true, b.get());
75 for (File f : File.listRoots())
76 f.listFiles();
77 }
78
79 @SlashedClassName static class AnnotationTemplate {}
80 @Test
81 public void test() throws InterruptedException {
82 ValidationSecurityManager sm = ValidationSecurityManager.INSTANCE;
83 SecurityManager old = System.getSecurityManager();
84 System.setSecurityManager(sm);
85 TypeQualifierValidator<SlashedClassName> goodValidator = new SlashedClassName.Checker();
86 havePermissions();
87 assertEquals(When.ALWAYS, test(goodValidator));
88 try {
89 test(new BadValidator());
90 fail("Should have thrown SecurityException");
91 } catch (SecurityException e) {
92 assert true;
93 }
94 havePermissions();
95 System.setSecurityManager(old);
96 havePermissions();
97
98
99 }
100
101 }
0 /*
1 * FindBugs - Find Bugs in Java programs
2 * Copyright (C) 2003-2008 University of Maryland
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package edu.umd.cs.findbugs.ba.type;
20
21 import org.junit.Test;
22
23 /**
24 * @author pugh
25 */
26 public class TypeFrameModelingVisitorTest {
27
28 @Test
29 public void testMapSignaturePattern() {
30 // assertTrue(TypeFrameModelingVisitor.mapSignaturePattern.matcher("<") && !sourceSignature.contains("Map<TK;TV;>"))
31 }
32
33 }
1212 import java.util.Map;
1313 import java.util.Properties;
1414 import java.util.Set;
15 import java.util.concurrent.TimeUnit;
1516
1617 import junit.framework.TestCase;
1718 import edu.umd.cs.findbugs.BugCollection;
2223 import edu.umd.cs.findbugs.PropertyBundle;
2324 import edu.umd.cs.findbugs.SortedBugCollection;
2425 import edu.umd.cs.findbugs.SourceLineAnnotation;
25 import edu.umd.cs.findbugs.ba.AnalysisContext;
2626 import edu.umd.cs.findbugs.cloud.Cloud.Mode;
2727 import edu.umd.cs.findbugs.cloud.Cloud.UserDesignation;
2828 import edu.umd.cs.findbugs.cloud.username.NoNameLookup;
348348 return "user";
349349 }
350350
351 @Override
351352 public SigninState getSigninState() {
352353 return SigninState.NO_SIGNIN_REQUIRED;
353354 }
369370 throw new UnsupportedOperationException();
370371 }
371372
373 @Override
372374 public void bugsPopulated() {
373375 throw new UnsupportedOperationException();
374376 }
386388 }
387389
388390 public void waitUntilIssueDataDownloaded() {
391 }
392 public boolean waitUntilNewIssuesUploaded(long timeout, TimeUnit unit) throws InterruptedException {
393 return true;
394 }
395
396 public void waitUntilNewIssuesUploaded() {
397
398 }
399 public boolean waitUntilIssueDataDownloaded(long timeout, TimeUnit unit) throws InterruptedException {
400 return true;
389401 }
390402
391403 public Collection<String> getProjects(String className) {
400412 return false;
401413 }
402414
415 @Override
403416 public String getCloudName() {
404417 return "test";
405418 }
427440 * edu.umd.cs.findbugs.cloud.Cloud#getBugIsUnassigned(edu.umd.cs.findbugs
428441 * .BugInstance)
429442 */
443 @Override
430444 public boolean getBugIsUnassigned(BugInstance b) {
431445 throw new UnsupportedOperationException();
432446 }
438452 * edu.umd.cs.findbugs.cloud.Cloud#getReviewers(edu.umd.cs.findbugs.
439453 * BugInstance)
440454 */
455 @Override
441456 public Set<String> getReviewers(BugInstance b) {
442457 throw new UnsupportedOperationException();
443458 }
449464 * edu.umd.cs.findbugs.cloud.Cloud#getWillNotBeFixed(edu.umd.cs.findbugs
450465 * .BugInstance)
451466 */
467 @Override
452468 public boolean getWillNotBeFixed(BugInstance b) {
453469 throw new UnsupportedOperationException();
454470 }
474490 return map.values();
475491 }
476492
477 /*
478 * (non-Javadoc)
479 *
480 * @see edu.umd.cs.findbugs.cloud.Cloud#waitUntilNewIssuesUploaded()
481 */
482 public void waitUntilNewIssuesUploaded() {
483
484 }
493
494
485495 }
486496 }
1111 }
1212
1313 public void testClone() {
14 UserPreferences clone = (UserPreferences) prefs.clone();
14 UserPreferences clone = prefs.clone();
1515
1616 Assert.assertEquals(prefs, clone);
1717 Assert.assertEquals(prefs.getClass(), clone.getClass());
3232 }
3333
3434 public void testSaveTypes() {
35 check(SaveType.HTML_OUTPUT, "/home/pugh/bugs.html");
36 check(SaveType.HTML_OUTPUT, "/home/pugh/bugs.htm");
37 check(SaveType.HTML_OUTPUT, "/home/pugh/bugs.HTML");
3538 check(SaveType.XML_ANALYSIS, "/home/pugh/bugs.xml");
3639 check(SaveType.XML_ANALYSIS, "/home/pugh/bugs.XML");
3740 check(SaveType.XML_ANALYSIS, "/home/pugh/bugs.xml.gz");
4646 private Map<String, String> globalOptions;
4747 private String uploadedXml;
4848
49 @Override
4950 protected void setUp() throws Exception {
5051 updateCollector = new ArrayList<UpdateChecker.PluginUpdate>();
5152 errors = new StringBuilder();
6263 checked.put(urlStr, plugins);
6364 ByteArrayInputStream stream = new ByteArrayInputStream(responseXml.getBytes("UTF-8"));
6465 ByteArrayOutputStream out = new ByteArrayOutputStream();
65 writeXml(out, plugins, "x.y.z");
66 writeXml(out, plugins, "x.y.z", true);
6667 uploadedXml = new String(out.toByteArray(), "UTF-8");
6768 parseUpdateXml(url, plugins, stream);
6869 }
4040 assertEquals("java/lang/Integer", ClassName.extractClassName("[[[Ljava/lang/Integer;"));
4141 assertEquals("java/lang/Integer", ClassName.extractClassName("java/lang/Integer"));
4242 }
43
44 public void testGetPrimitiveType() {
45 assertEquals("I", ClassName.getPrimitiveType("java/lang/Integer"));
46 assertEquals("F", ClassName.getPrimitiveType("java/lang/Float"));
47 assertEquals("D", ClassName.getPrimitiveType("java/lang/Double"));
48 assertEquals("J", ClassName.getPrimitiveType("java/lang/Long"));
49 assertEquals("B", ClassName.getPrimitiveType("java/lang/Byte"));
50 assertEquals("C", ClassName.getPrimitiveType("java/lang/Character"));
51 assertEquals("S", ClassName.getPrimitiveType("java/lang/Short"));
52 assertEquals("Z", ClassName.getPrimitiveType("java/lang/Boolean"));
53 assertNull(ClassName.getPrimitiveType("java/lang/String"));
54 assertNull(ClassName.getPrimitiveType("java/util/HashMap"));
55 }
4356
4457 public void testExtractClassNameBad() {
4558 try {
99 *
1010 * This library is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313 * Lesser General Public License for more details.
1414 *
1515 * You should have received a copy of the GNU Lesser General Public
1616 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818 */
1919 package edu.umd.cs.findbugs.gui;
2020
99 *
1010 * This library is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313 * Lesser General Public License for more details.
1414 *
1515 * You should have received a copy of the GNU Lesser General Public
1616 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818 */
1919
2020
99 *
1010 * This library is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313 * Lesser General Public License for more details.
1414 *
1515 * You should have received a copy of the GNU Lesser General Public
1616 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818 */
1919
2020 /*
21002100
21012101 private void bugTreeBugDetailsSplitterPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_bugTreeBugDetailsSplitterPropertyChange
21022102 // Here we want to
2103 // (1) Keep the View:Bug details checkbox item up to date, and
2104 // (2) keep the details window synchronized with the current bug instance
2103 // (1) Keep the View:Bug details checkbox item up to date, and
2104 // (2) keep the details window synchronized with the current bug instance
21052105 String propertyName = evt.getPropertyName();
21062106 if (propertyName.equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
21072107 boolean isMaximized = isSplitterMaximized(bugTreeBugDetailsSplitter, evt);
24182418 /**
24192419 * Localise the given AbstractButton, setting the text and optionally mnemonic
24202420 * Note that AbstractButton includes menus and menu items.
2421 * @param button The button to localise
2422 * @param key The key to look up in resource bundle
2421 * @param button The button to localise
2422 * @param key The key to look up in resource bundle
24232423 * @param defaultString default String to use if key not found
2424 * @param setMnemonic whether or not to set the mnemonic. According to Sun's
2425 * guidelines, default/cancel buttons should not have mnemonics
2426 * but instead should use Return/Escape
2424 * @param setMnemonic whether or not to set the mnemonic. According to Sun's
2425 * guidelines, default/cancel buttons should not have mnemonics
2426 * but instead should use Return/Escape
24272427 */
24282428 private void localiseButton(AbstractButton button, String key, String defaultString,
24292429 boolean setMnemonic) {
26242624 * whose class is the same as the given class.
26252625 *
26262626 * @param tree the tree
2627 * @param c the class
2627 * @param c the class
26282628 * @return an instance of the given kind of object which is in the
2629 * current selection, or null if there is no matching object
2629 * current selection, or null if there is no matching object
26302630 */
26312631 private static <E> E getTreeSelectionOf(JTree tree, Class<E> c) {
26322632 TreePath selPath = tree.getSelectionPath();
26792679 * that we have top and bottom components).
26802680 *
26812681 * @param splitter the JSplitPane
2682 * @param evt the event that is changing the splitter value
2682 * @param evt the event that is changing the splitter value
26832683 */
26842684 private boolean isSplitterMaximized(JSplitPane splitter, java.beans.PropertyChangeEvent evt) {
26852685 Integer location = (Integer) evt.getNewValue();
26872687 int height = splitter.getHeight();
26882688 int hopefullyMaxDivider = height - (splitter.getDividerSize() + DIVIDER_FUDGE);
26892689 //System.out.println("Splitter: "+(splitter==consoleSplitter?"consoleSplitter":"bugTreeBugDetailsSplitter")+
2690 // ": height="+height+",location="+location+
2691 // ",hopefullyMax="+hopefullyMaxDivider);
2690 // ": height="+height+",location="+location+
2691 // ",hopefullyMax="+hopefullyMaxDivider);
26922692 boolean isMaximized = location.intValue() >= hopefullyMaxDivider;
26932693 return isMaximized;
26942694 }
27462746 copyItem.setEnabled(hasSelection);
27472747 selectAllItem.setEnabled(true);
27482748 }
2749 // } else if (view.equals("BugTree")) {
2750 // } else if (view.equals("ReportPanel")) {
2749 // } else if (view.equals("BugTree")) {
2750 // } else if (view.equals("ReportPanel")) {
27512751
27522752 } else {
27532753 cutItem.setEnabled(false);
27912791 * If the project already has a valid filename, use that filename.
27922792 * Otherwise, prompt for one.
27932793 *
2794 * @param project the Project to save
2794 * @param project the Project to save
27952795 * @param dialogTitle the title for the save dialog (if needed)
27962796 */
27972797 private boolean saveProject(Project project, String dialogTitle) {
28012801 /**
28022802 * Offer to save the current Project to a file.
28032803 *
2804 * @param project the Project to save
2805 * @param dialogTitle the title for the save dialog (if needed)
2804 * @param project the Project to save
2805 * @param dialogTitle the title for the save dialog (if needed)
28062806 * @param chooseFilename if true, force a dialog to prompt the user
2807 * for a filename
2807 * for a filename
28082808 * @return true if the project is saved successfully, false if the user
2809 * cancels or an error occurs
2809 * cancels or an error occurs
28102810 */
28112811 private boolean saveProject(Project project, String dialogTitle, boolean chooseFilename) {
28122812 boolean useRelativePaths;
28572857 /**
28582858 * Hook to call before closing a project.
28592859 *
2860 * @param project the project being closed
2860 * @param project the project being closed
28612861 * @param savePromptTitle title to use for the "Save project?" dialog
28622862 * @return true if user has confirmed that the project should be closed,
2863 * false if the close is cancelled
2863 * false if the close is cancelled
28642864 */
28652865 private boolean closeProjectHook(Project project, String savePromptTitle) {
28662866 if (project == null || !project.isModified())
29472947 // An immediate inline call to set the scroll position does nothing.
29482948 // So, use invokeLater(), even though this results in flashing.
29492949 // [What we really need is a way to set the text WITHOUT changing
2950 // the caret position. Need to investigate.]
2950 // the caret position. Need to investigate.]
29512951 SwingUtilities.invokeLater(new Runnable() {
29522952 public void run() {
29532953 bySummary.getViewport().setViewPosition(new Point(0, 0));
32973297 /**
32983298 * Update the source view window.
32993299 *
3300 * @param project the project (containing the source directories to search)
3300 * @param project the project (containing the source directories to search)
33013301 * @param analysisRun the analysis run (containing the mapping of classes to source files)
3302 * @param srcLine the source line annotation (specifying source file to load and
3303 * which lines to highlight)
3302 * @param srcLine the source line annotation (specifying source file to load and
3303 * which lines to highlight)
33043304 * @return true if the source was shown successfully, false otherwise
33053305 */
33063306 private boolean viewSource(Project project, AnalysisRun analysisRun, final SourceLineAnnotation srcLine)
34203420 // An immediate inline call to set the scroll position does nothing.
34213421 // So, use invokeLater(), even though this results in flashing.
34223422 // [What we really need is a way to set the text WITHOUT changing
3423 // the caret position. Need to investigate.]
3423 // the caret position. Need to investigate.]
34243424 SwingUtilities.invokeLater(new Runnable() {
34253425 public void run() {
34263426 bugDescriptionScrollPane.getViewport().setViewPosition(new Point(0, 0));
35273527 @SuppressWarnings("DM_EXIT")
35283528 void exitFindBugs() {
35293529 // TODO: offer to save work, etc.
3530 // UserPreferences.getUserPreferences().storeUserDetectorPreferences();
3530 // UserPreferences.getUserPreferences().storeUserDetectorPreferences();
35313531 UserPreferences.getUserPreferences().write();
35323532 System.exit(0);
35333533 }
35683568 * Run a file chooser dialog.
35693569 * If a file is chosen, then the current directory is updated.
35703570 *
3571 * @param dialog the file chooser dialog
3571 * @param dialog the file chooser dialog
35723572 * @param dialogTitle the dialog title
35733573 * @return the outcome
35743574 */
36173617 * @param message the message to write
36183618 */
36193619 public void writeToLog(String message) {
3620 // consoleMessageArea.append(message);
3621 // consoleMessageArea.append("\n");
3620 // consoleMessageArea.append(message);
3621 // consoleMessageArea.append("\n");
36223622 }
36233623
36243624 /**
37053705 String theme = null;
37063706 if (arg.equals("plastic")) {
37073707 // You can get the Plastic look and feel from jgoodies.com:
3708 // http://www.jgoodies.com/downloads/libraries.html
3708 // http://www.jgoodies.com/downloads/libraries.html
37093709 // Just put "plastic.jar" in the lib directory, right next
37103710 // to the other jar files.
37113711 theme = "com.jgoodies.plaf.plastic.PlasticXPLookAndFeel";
37783778 project = commandLine.getProject();
37793779 }
37803780
3781 // Uncomment one of these to test I18N
3782 // Locale.setDefault( Locale.FRENCH );
3783 // Locale.setDefault( Locale.GERMAN );
3784 // Locale.setDefault( Locale.JAPANESE );
3785 // Locale.setDefault( new Locale( "et" ));
3786 // Locale.setDefault( new Locale( "fi" ));
3787 // Locale.setDefault( new Locale( "es" ));
3788 // Locale.setDefault( new Locale( "pl" ));
3781 // Uncomment one of these to test I18N
3782 // Locale.setDefault( Locale.FRENCH );
3783 // Locale.setDefault( Locale.GERMAN );
3784 // Locale.setDefault( Locale.JAPANESE );
3785 // Locale.setDefault( new Locale( "et" ));
3786 // Locale.setDefault( new Locale( "fi" ));
3787 // Locale.setDefault( new Locale( "es" ));
3788 // Locale.setDefault( new Locale( "pl" ));
37893789
37903790 // Load plugins!
37913791 DetectorFactoryCollection.instance();
99 *
1010 * This library is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313 * Lesser General Public License for more details.
1414 *
1515 * You should have received a copy of the GNU Lesser General Public
1616 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818 */
1919 package edu.umd.cs.findbugs.gui;
2020
5050 @Override
5151 public void handlePreferences(ApplicationEvent ae) {
5252 if (mainApp != null) {
53 // mainApp.preferences();
53 // mainApp.preferences();
5454 ae.setHandled(true);
5555 } else {
5656 throw new IllegalStateException("handlePreferences: MyApp instance " +
1212 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/asm-3.3.jar</AuxClasspathEntry>
1313 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/asm-commons-3.3.jar</AuxClasspathEntry>
1414 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/asm-tree-3.3.jar</AuxClasspathEntry>
15 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/jaxen-1.1.1.jar</AuxClasspathEntry>
15 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/jaxen-1.1.6.jar</AuxClasspathEntry>
1616 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/jsr305.jar</AuxClasspathEntry>
1717 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/jFormatString.jar</AuxClasspathEntry>
18 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/commons-lang-2.4.jar</AuxClasspathEntry>
18 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/commons-lang-2.6.jar</AuxClasspathEntry>
1919 <AuxClasspathEntry>/Users/pugh/Documents/fb-trunk/findbugs/lib/jcip-annotations.jar</AuxClasspathEntry>
2020 <SrcDir>/Users/pugh/Documents/fb-trunk/findbugs/src/java</SrcDir>
2121 <SrcDir>/Users/pugh/Documents/fb-trunk/findbugs/src/gui</SrcDir>
6767
6868 enum Status {
6969 NOT_FOUND, EXPOSED, UNEXPOSED
70 };
70 }
7171
7272 static Map<String, Status> classStatus = new HashMap<String, Status>();
7373
7474 static Status getStatus(@DottedClassName String name) {
75 if (name.startsWith("com.sun") || name.startsWith("com.oracle")
75 if (name.startsWith("com.sun") || name.startsWith("com.oracle")
7676 || name.startsWith("sun") || name.startsWith("netscape"))
7777 return Status.UNEXPOSED;
7878 Status result = classStatus.get(name);