Missing generics information in ASM binaries
I tried to use ASM 4.1 in my maven project and included the dependency as follows:
...
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
<version>4.1</version>
</dependency>
...
It works until I try to use classes like Analyzer which use generic type
parameters. My compiler (Oracle JDK) complains that these types and their
constructors have no type parameters.
So I had a look at the official jars (from the maven repos and the download
section of the website) using ASM like this:
public static void main(String[] args) {
try {
ClassReader cr = new ClassReader("org.objectweb.asm.tree.analysis.Analyzer");
TraceClassVisitor tcv = new TraceClassVisitor(null ,new ASMifier(),new
PrintWriter(System.out));
cr.accept(tcv, ClassReader.SKIP_FRAMES);
} catch (IOException e) {
e.printStackTrace();
}
}
It turns out that your classes contain no generics information since all
signatures are null:
cw.visit(V1_2, ACC_PUBLIC + ACC_SUPER,
"org/objectweb/asm/tree/analysis/Analyzer", null, "java/lang/Object", new
String[] { "org/objectweb/asm/Opcodes" });
{
fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "interpreter",
"Lorg/objectweb/asm/tree/analysis/Interpreter;", null, null);
fv.visitEnd();
}
Doing this with other classes like java.util.List gives correct signatures as
expected:
cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, "java/util/List",
"<E:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Collection<TE;>;",
"java/lang/Object", new String[] { "java/util/Collection" });
Since I checked this with multiple JDKs, in Eclipse and manually on command
line, I guess there is something wrong with your builds. I had the same problem
with your ASM 4.0 builds.