Improper signature when parsing an enum
ASM 3.2 is giving me contradictory information about the constructor of an
enum. The description (i.e. the type erased signature) seems right and the
signature seems wrong.
I have a simple enum:
public enum MyEnum {
MINE;
}
I've implemented a simple ClassVisitor named ClassPrinter which I run like so:
public static void main(String[] args) {
try {
ClassPrinter cp = new ClassPrinter();
final InputStream stream =
ClassLoader.getSystemResourceAsStream("MyEnum.class");
ClassReader cr = new ClassReader(stream);
cr.accept(cp, 0);
} catch (IOException e) {
e.printStackTrace();
}
}
The ClassPrinter just prints the information each visit method gets. When the
constructor of the MyEnum is called, this is the critical information:
method: <init>
desc: (Ljava/lang/String;I)V
sig: ()V
access: private
So the description says that the constructor takes a string and an int and
returns void, while the signature says the constructor takes no arguments and
returns void. If I print out the class with javap, it show the same
information as the description.
Particularly confusing to me is that for every other example I've worked
through, if the description is complete, i.e. there are no generics in the
method, then the signature is always null. Why in this case is the signature
non-null and wrong?
I'm using JDK 1.6.0_16 to compile and run this example.