上一篇文章中谈及到fingbugs的使用,此篇文章阐述一下使用中注意的事项:
在使用FindBugs是会报告如下错误java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
官方文档中给与如下说明
The problem here is that the wrong version of the Apache BCEL library is being found. FindBugs requires its own version of BCEL, which normally will be used automatically when you invoke the findbugs
or findbugs.bat
scripts used to launch FindBugs. If an old version of BCEL is installed in 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
- If you install the Java(TM) Web Services Developer Pack 1.2 in the
lib/endorsed
directory of your Java Runtime Environment (JRE). The filexsltc.jar
contains an old version of BCEL that is incompatible with FindBugs. - Another possibility is that you are using the IBM JDK. Some versions include a version of BCEL which conflicts with the one required by FindBugs. This problem is fixed in version 1.4.1 SP1, so upgrading your JDK should allow FindBugs to run correctly.
- Some versions of the Apache Xalan XSLT processor include an old version of BCEL in
xalan.jar
.
In all of these cases, you should be able to run FindBugs by either removing the offending version of BCEL from your JRE, or installing a clean JRE or JDK and using that to run FindBugs.
看上去好像很繁琐吧,其实只有两个文件在作怪,就是ant核心lib下的xalen.jar 和xslt.jar。删除此文件便可以进行使用。
此时使用正常,但是合并出来的文件缺少很多内容,经过查看源码发现时FindBugs中的代码,此代码文件为edu.umd.cs.findbugs.workflow.UnionResults出现错误,并且查到进行了修改当提交tracker时发现有人提交过
下面是官方的tracker截图
其中用红线框标注的为提交的bug类用户可以到如下界面中了解具体情况http://sourceforge.net/tracker/?atid=614695&group_id=96405&func=browse
附件中会给出修改后的源代码文件