Intellij Idea 13.x and ASM 5.x library incompatible?

Posted by Jarrod Roberson on Stack Overflow See other posts from Stack Overflow or by Jarrod Roberson
Published on 2014-05-26T20:47:52Z Indexed on 2014/05/27 3:28 UTC
Read the original article Hit count: 360

I can't get Intellij Idea 13.0 to compile my code against ASM 5.0.3

I have a multi-module Maven project. It compiles and installs successfully.

Apparently com.google.findbugs:findbugs has a dependency on asm:asm:3.3 and I want to use org.ow2.asm:asm:5.0.3 to manipulate some bytecode.

So in the parent pom.xml I exclude the asm:asm:3.3 dependencies from the classpath. This works fine when I run mvn install from the command line.

I can't get the Build -> Make Project menu selection to work in Intellij Idea.

Here is the relevant parts of my pom.xml files.

parent.pom

<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>

Here is the code that is failing

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   }

Here is the error message:

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.

As you can see in the screen capture, it reports the correct version of the libraries in the Javadoc but the AutoComplete shows the old 3.3 non-typesafe return value of List instead of List<MethodNode>:

JavaDoc PopUp

Here is what Maven knows, which is correct:

[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

How do I get Intellij Idea to use the correct dependency internally?

© Stack Overflow or respective owner

Related posts about java

Related posts about maven