📄 faq.html
字号:
<html><head><title>FindBugs FAQ</title><link rel="stylesheet" type="text/css" href="findbugs.css"></head><body><table width="100%"><tr><td bgcolor="#b9b9fe" valign="top" align="left" width="20%"> <table width="100%" cellspacing="0" border="0"> <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="FindBugs"></a></td></tr> <tr><td> </td></tr><tr><td><b>Docs and Info</b></td></tr> <tr><td><font size="-1"><a class="sidebar" href="demo.html">Demo and data</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="users.html">Users and supporters</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="http://findbugs.blogspot.com/">FindBugs blog</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="factSheet.html">Fact sheet</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="manual/index.html">Manual</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="ja/manual/index.html">Manual(ja/日本語)</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="FAQ.html">FAQ</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="bugDescriptions.html">Bug descriptions</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="mailingLists.html">Mailing lists</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="publications.html">Documents and Publications</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="links.html">Links</a></font></td></tr> <tr><td> </td></tr><tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr> <tr><td> </td></tr><tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs Swag</b></a></td></tr><tr><td> </td></tr><tr><td><b>Development</b></td></tr> <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/tracker/?group_id=96405">Open bugs</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="reportingBugs.html">Reporting bugs</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="contributing.html">Contributing</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="team.html">Dev team</a></font></td></tr> <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> <tr><td><font size="-1"><a class="sidebar" href="Changes.html">Change log</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="http://sourceforge.net/projects/findbugs">SF project page</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/browse/">Browse source</a></font></td></tr> <tr><td><font size="-1"><a class="sidebar" href="http://code.google.com/p/findbugs/source/list">Latest code changes</a></font></td></tr> </table> </td><td><h1>FindBugs FAQ</h1><p> This document contains answers to frequently asked questions about<a href="index.html">FindBugs</a>. If you just want generalinformation about FindBugs, have a look at the<a href="factSheet.html">fact sheet</a> and the<a href="manual/index.html">manual</a>.<h2>Contents</h2><ol><li> <a href="#q1">I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a><li> <a href="#q2">When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a><li> <a href="#q3">FindBugs is running out of memory, or is taking a long time to finish</a><li> <a href="#q4">What is the "auxiliary classpath"? Why should I specify it?</a><li> <a href="#q5">The Eclipse plugin doesn't load</a><li> <a href="#q6">I'm getting a lot of false "OS" and "ODR" warnings</a><li> <a href="#q7">The Eclipse plugin loads, but doesn't work correctly</a><li> <a href="#q8">Where is the Maven plugin for FindBugs?</a><li> <a href="#q9">Where is the NetBeans plugin for FindBugs?</a></ol><h2><a name="q1">Q1: I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a></h2><p> FindBugs requires JRE 1.5.0 or later to run. If you use an earlier version,you will see an exception error message similar to the following:<pre>Exception in thread "main" java.lang.UnsupportedClassVersionError:edu/umd/cs/findbugs/gui/FindBugsFrame (Unsupported major.minor version 48.0)</pre>The solution is to upgrade to JRE 1.5.0 or later.<h2><a name="q2">Q2: When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a></h2><p> The symptom of this bug is that when you start the FindBugs analysis,you see an exception similar to the following:<pre>java.lang.NoSuchMethodError: org.apache.bcel.Repository.setRepository(Lorg/apache/bcel/util/Repository;)V at edu.umd.cs.findbugs.FindBugs.clearRepository(FindBugs.java:483) ...</pre>or<pre>java.lang.VerifyError: Cannot inherit from final class at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) ...</pre><p> The problem here is that the wrong version of the<a href="http://jakarta.apache.org/bcel/">Apache BCEL</a>library is being found. FindBugs requires its ownversion of BCEL, which normally will be used automaticallywhen you invoke the <code>findbugs</code> or <code>findbugs.bat</code>scripts used to launch FindBugs. If an old version of BCEL is installedin a location, such as "lib/endorsed" in the JRE installation,where it overrides classes on the application classpath,FindBugs will not execute properly. We know of several reasons this could happen<ul><li> If you install the<a href="http://java.sun.com/webservices/downloads/webservicespack.html">Java(TM) Web ServicesDeveloper Pack 1.2</a>in the <code>lib/endorsed</code> directory of your Java Runtime Environment (JRE). The file <code>xsltc.jar</code> contains an old version of BCEL that is incompatible withFindBugs. <li> Another possibility is that you are using the IBM JDK. Some versions include a version of BCEL which conflicts with theone required by FindBugs. This problem is fixed in version 1.4.1 SP1,so upgrading your JDK should allow FindBugs to run correctly.<li> Some versions of the Apache Xalan XSLT processor includean old version of BCEL in <code>xalan.jar</code>.</ul><p> In all of these cases, you should be able to run FindBugsby either removing the offending version of BCEL from your JRE,or installing a clean JRE or JDK and using that to run FindBugs.<p> Many thanks to Peter Meulmeester, Michael Levi, and Thomas Klaegerfor providing information on this problem.<h2><a name="q3">Q3: FindBugs is running out of memory, or is taking a long time to finish</a></h2><p> In general, FindBugs requires lots of memory and a relativelyfast CPU. For large applications, 512M or more of heap space may berequired. By default, FindBugs allocates 256M of heap space.You can increase this using the <code>-maxHeap <i>n</i></code> option,where <i>n</i> is the number of megabytes of heap space to allocate.<p>If you are using the GUI version of FindBugs, and have many classes to analyze,a good amount of memory is needed to generate the summary report. If the processappears to be hanging after all classes have been parsed, but before the finaldetails have been shown, you can turn this summary report off, by specifying<br/><code>-jvmArgs "-Dfindbugs.noSummary=true"</code><br/> on the command line.</p><p> Version 0.6.9 of FindBugs introduced new types of analysis thatimprove precision, but require more memory and time to perform.In version 0.7.0 and later, you can disable these analyses byadding the <code>-conserveSpace</code> option to the FindBugscommand line. E.g.:<pre> findbugs -textui -conserveSpace -xml -project myProject.fb -outputFile out.xml</pre><h2><a name="q4">Q4: What is the "auxiliary classpath"? Why should I specify it?</a></h2><p> Many important facts about a Java class require information aboutthe classes that it references. For example:<ul><li> What other classes and interfaces the class inherits from<li> What exceptions can be thrown by methods in external classesand interfaces</ul><p> The "auxiliary classpath" is a list of Jar files, directories, andclass files containing classes that are <em>used</em> by the code youwant FindBugs to analyze, but should not themselves be analyzedby FindBugs.<p> If FindBugs doesn't have complete information about referenced classes,it will not be able to produce results that are as accurate as possible. For example, having a complete repository of referenced classes allowsFindBugs to prune control flow information so it can concentrate onpaths through methods that are most likely to be feasible at runtime. Also, some bug detectors (such as the suspicious reference comparison detector)rely on being able to perform type inference, which requires completetype hierarchy information.<p> For these reasons, we strongly recommend that you completely specifythe auxiliary classpath when you run FindBugs. You can do thisby using the <code>-auxclasspath</code> command line option, or the"Classpath entries" list in the GUI project editor dialog.<p> If FindBugs cannot find a class referenced by your application, itwill print out a message when the analysis completes, specifying theclasses that were missing. You should modify the auxiliary classpathto specify how to find the missing classes, and then run FindBugs again.<h2><a name="q5">Q5: The Eclipse plugin doesn't load</a></h2><p> The symptom of this problem is that Eclipse fails to loadthe FindBugs UI plugin with the message:<blockquote>Plug-in "edu.umd.cs.findbugs.plugin.eclipse" was disabled due to missing or disabledprerequisite plug-in "org.eclipse.ui.ide"</blockquote><p> The reason for this problem is that the Eclipseplugin distributed with FindBugsdoes not work with 2.x versions of Eclipse.Please use Eclipse version 3.3 (June 2007) or newer.<h2><a name="q6">Q6: I'm getting a lot of false "OS" and "ODR" warnings</a></h2><p> By default, FindBugs assumes that any method invocation canthrow an unchecked runtime exception. As a result,it may assume that an unchecked exception thrown out of themethod could bypass a call to a <code>close()</code> methodfor a stream or database resource.<p> You can use the <code>-workHard</code> command line argumentor the <code>findbugs.workHard</code> boolean analysis propertyto make FindBugs work harder to prune unlikely exceptionedges. This generally reduces the number offalse warnings, at the expense of slowing down theanalysis.<h2><a name="q7">Q7: The Eclipse plugin loads, but doesn't work correctly</a></h2><p> In versions 0.0.6 and 0.0.7 of the FindBugs Eclipse plugin,which correspond to the 0.7.4 and 0.8.0 releases,bugs in the experimental SwitchFallthrough detector can preventFindBugs from running properly within Eclipse.<p> To work around the problem, make sure that SwitchFallthroughis disabled in the FindBugs Properties of your project. Right click on your project, and choose "Properties". In the Properties dialog, choose "FindBugs",and disable the checkbox next to SwitchFallthrough.<p> Another common problem with the Eclipse plugin is thatthe FindBugs warnings do not appear in the "Problems" view. Make sure that FindBugs warnings are enabled in the filtersfor this view. The Filters menu is accessible byclicking on the icon that looks like this:<blockquote><img src="eclipse-filters-icon.png"></blockquote>Make sure the "FindBugs Problem" checkbox is enabled.<h2><a name="q8">Q8: Where is the Maven plugin for FindBugs?</a></h2><p>The <a href="http://maven.apache.org/">Maven</a> Plugin for FindBugsmay be found <a href="http://maven-plugins.sourceforge.net/maven-findbugs-plugin/index.html">here</a>. Please note that the Maven plugin is not maintained by the FindBugs developers,so we can't answer questions about it.</p><h2><a name="q9">Q9: Where is the NetBeans plugin for FindBugs?</a></h2><p>The <a href="http://www.netbeans.org/">NetBeans</a> Plugin for FindBugsmay be obtained by pointing UpdateCenter to<a href="https://sqe.dev.java.net/updatecenters/nbheaven-updatecenter.xml">https://sqe.dev.java.net/updatecenters/nbheaven-updatecenter.xml</a>.(An older human-readable page is <a href="http://fnleisurehacker.fn.funpic.de/wordpress/?page_id=102">here</a>.)This distribution apparently bundles the detectors fromfb-contrib,which are not controlled by the FindBugs project. The lead FindBugs team does not vouch for the relevance, accuracy or wisdom of the warnings generated by any third-party plugin. and encourages all FindBugs users to carefully evaluate 3rd party plugins for FindBugs. </p><p>Again, please note that the NetBeans plugin is not maintained by the FindBugs developers,so we can't answer questions about it.</p><hr> <p> <script language="JavaScript" type="text/javascript"> <!---//hide script from old browsers document.write( "Last updated "+ document.lastModified + "." ); //end hiding contents ---> </script> <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbugs@cs.umd.edu</a> <p> <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=96405&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A></td></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -