“忽略InnerClasses属性”警告正在杀死Eclipse

时间:2011-04-08 07:21:50

标签: eclipse apache jar maven

我有几个导入的jar在项目构建时在Eclipse中出现此错误:

[2011-04-08 16:31:48 - MokbeeAndroid] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.sf.antcontrib.logic.ForEach$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

现在,我起初并不在乎,因为没有错误。但我现在已经添加了Apache Sanselan,它有同样的问题。其他的Apache jar也可以这样做,而不是每个jar一次,但每个类有一次内部类,这使得每个构建泵出一个可怕的控制台日志。更糟糕的是,每个警告似乎都会降低Eclipse构建过程的速度,最终Eclipse会因内存溢出错误而崩溃。这是我无法构建任何东西的地方,甚至在我的电脑启动后也是如此。

解决方案似乎是重新编译源代码(开源代码和所有代码),但是除了Maven之外,没有任何东西可以重新编译,在这样做之后无济于事,我怀疑是在导致问题的第一名。

我不关心警告的结果,只是Eclipse并没有把所有的内存花在告诉我这件事上。那么,有没有办法可以解决问题,让Eclipse停止放慢速度(可能会跳过那个检查)?

2 个答案:

答案 0 :(得分:8)

android-maven-plugin和其他包含commons-logging的库让我感到很痛苦。它阻止了我的构建。更糟糕的是,有些库是可传递的,所以简单地使用<exclude>是行不通的。通过another post的一点提示,我确定我可以用这样的东西完全阻止违规库:

    <!-- prevent commons-logging from being included by the Google HTTP client 
        dependencies -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>

答案 1 :(得分:1)

如果在Maven中重新编译库的源代码,则可能需要将POM中的Java版本更新为1.6(或者您正在为项目使用的任何Java版本)。仅仅看一下Sanselan,我注意到它的版本特别是1.4。