java - FindBugs 不接受 ANT 脚本中的 bcel.jar

标签 java ant findbugs task bcel

我将 findbugs 安装到我的 ant lib 目录中,并将以下代码添加到我的主 ANT 脚本中:

<target name="findbugs" depends="init">

    <findbugs home="C:\\findbugs\\" output="html outputFile="C:\\findbugs\\out.html" jvmargs="-Xms512M">
        <sourcePath path="${messageaggregator.src}" />
        <class location="${messageaggregator.src}"/>


    </findbugs>
</target>

在 init 目标中调用以下 xml:

<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">

运行 ANT 脚本时,我得到的只是以下输出:

findbugs:
    [findbugs] Executing findbugs from ant task
    [findbugs] Running FindBugs...
    [findbugs] BCEL class compatability error.
    [findbugs] The version of class org.apache.bcel.generic.ObjectType found was not compatible with
    [findbugs] FindBugs.  Please remove any BCEL libraries that may be interfering. This may happen
    [findbugs] if you have an old version of BCEL or a library that includes an old version of BCEL
    [findbugs] in an "endorsed" directory.
    [findbugs] Output saved to C:\\findbugs\\out.html

为什么 findbugs 不起作用?

最佳答案

您与旧版本的 BCEL 存在冲突,必须消除该冲突。它可能位于您的 jre/lib/ext 目录中(坏主意),或者您项目的 CLASSPATH 的一部分,或者可能是 Ant/lib 的一部分。无论如何,您应该在 CLASSPATH 中找到所有 BCEL JAR,将其删除,然后使用 FindBugs 所需的版本更新它们。

关于java - FindBugs 不接受 ANT 脚本中的 bcel.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/627269/

相关文章:

java - 配置为监听端口 8080 的 Tomcat 连接器无法启动。该端口可能已在使用中或者连接器可能配置错误

java - 获取双 SIM 卡安卓手机的 SimOperatorName

java - 如何将 JRE 1.8 与 Eclipse Neon 一起使用?

ant - 使用 ant,查找与正则表达式匹配的文件并搜索文件中是否存在子字符串

ant - 在 Jenkins 中增加 Findbugs 的 maxHeap arg

java - 设置 Id (PK) 生成值自动和手动

java - 为什么 Eclipse 将/jre 添加到我的 JAVA_HOME

Ant - 只复制文件而不是目录

android - Findbugs 失败并显示 "java.io.IOException: No files to analyze could be opened"

java - 使用 Java 将内部类设为静态有什么好处?