[英]Intellij Idea 13.x and ASM 5.x library incompatible?
我有一個多模塊Maven項目。 它可以編譯並成功安裝。
顯然com.google.findbugs:findbugs
依賴於asm:asm:3.3
,我想使用org.ow2.asm:asm:5.0.3
來處理某些字節碼。
因此,在父pom.xml
我從類路徑中排除了asm:asm:3.3
依賴項。 當我從命令行運行mvn install
時,這可以正常工作。
我無法在Intellij Idea中使用Build- > Make Project菜單選擇。
這是我的pom.xml
文件的相關部分。
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.3</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
</exclusion>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm-tree</artifactId>
</exclusion>
</exclusions>
</dependency>
18 public static void main(final String[] args) throws IOException
19 {
20 final InputStream is = NotEmptyTest.class.getResourceAsStream("/com/vertigrated/annotation/NotEmptyTest.class");
21 final ClassReader cr = new ClassReader(is);
22 final ClassNode cn = new ClassNode();
23 cr.accept(cn, 0);
24 for (final MethodNode mn : cn.methods)
25 {
26 - 38 snipped for brevity
39 }
40 }
41 }
Information:Using javac 1.7.0_25 to compile java sources
Information:java: Errors occurred while compiling module 'tests'
Information:Compilation completed with 1 error and 2 warnings in 2 sec
Information:1 error
Information:2 warnings
/<path to my source code>/NotEmptyTest.java
Error:Error:line (24)java: incompatible types
required: org.objectweb.asm.tree.MethodNode
found: java.lang.Object
Warning:Warning:java: /<path to my project>//NotEmptyTest.java uses unchecked or unsafe operations.
Warning:Warning:java: Recompile with -Xlint:unchecked for details.
3.3
非類型安全返回值List
而不是List<MethodNode>
:
(來源: vertigrated.com )
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ tests ---
[INFO]
[INFO] The following files have been resolved:
[INFO] com.google.code.findbugs:bcel:jar:2.0.1:compile
[INFO] junit:junit:jar:4.11:test
[INFO] xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] com.apple:AppleJavaExtensions:jar:1.4:compile
[INFO] javax.inject:javax.inject:jar:1:compile
[INFO] jaxen:jaxen:jar:1.1.6:compile
[INFO] org.ow2.asm:asm-util:jar:5.0.3:compile
[INFO] com.google.inject:guice:jar:3.0:compile
[INFO] dom4j:dom4j:jar:1.6.1:compile
[INFO] com.google.code.findbugs:jFormatString:jar:2.0.1:compile
[INFO] net.jcip:jcip-annotations:jar:1.0:compile
[INFO] org.ow2.asm:asm-tree:jar:5.0.3:compile
[INFO] commons-lang:commons-lang:jar:2.6:compile
[INFO] com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] com.google.code.findbugs:findbugs:jar:2.0.3:compile
[INFO] org.ow2.asm:asm-commons:jar:5.0.3:compile
[INFO] org.ow2.asm:asm:jar:5.0.3:compile
看來您最終在IntelliJ IDEA的編譯類路徑中有asm-5.0.3.jar
。 通過剝離可能被剝離的所有位(包括通用簽名),JAR針對最小大小進行了優化(這就是List<MethodNode>
成為List
,在您的情況下實際上就是List<Object>
)。
為了確保是這種情況,請嘗試用asm-debug-all
替換對asm
, asm-tree
等的依賴。 您獲得的JAR會更大,但項目現在應該可以編譯。
下一個問題是如何在mvn
編譯,但在IntelliJ IDEA中失敗。 您可以在“依賴關系”選項卡上“模塊”下的“項目結構”對話框中看到類路徑。 也許是在IntelliJ中沒有正確導入類路徑(在這種情況下,請向IntelliJ IDEA的問題跟蹤器報告,您很快就會得到幫助)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.