Background information: I ran into problems when instrumenting ANTLR-generated code for a large lexer. I tried reproducing the bug in settings that would be easier to understand, but ran into this bug instead. Although I think the two bugs are related, I decided to file this bug separately because the symptoms are different.
Here is what's going on: when I instrument code with many nested switch statements (which happens to be similar in its structure to the code generated by ANTLR 3), I get this stack trace:
[EMMA v2.0, build 5312]
emmarun: [MAIN_METHOD_NOT_FOUND] application class [com.emmabugs.Big] does not have a runnable public main() method
Exception in thread "main" com.vladium.emma.EMMARuntimeException: [MAIN_METHOD_NOT_FOUND] application class [com.emmabugs.Big] does not have a runnable public main() method
at com.vladium.emma.rt.AppRunner._run(AppRunner.java:497)
at com.vladium.emma.rt.AppRunner.run(AppRunner.java:97)
at com.vladium.emma.runCommand.run(runCommand.java:247)
at emmarun.main(emmarun.java:27)
Caused by: java.lang.VerifyError: (class: com/emmabugs/Big, method: main signature: ([Ljava/lang/String;)V) Illegal target of jump or branch
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.vladium.emma.rt.AppRunner._run(AppRunner.java:493)
... 3 more
The class does have the main(String[]) method (see the attachment).
This is the command line that I used:
------------------------------------
java -cp c:\emma\emma.jar emmarun -merge n -raw -cp . com.emmabugs.Big 5 6
------------------------------------
This is the small code generator program that I used to make the attached file:
------------------------------------
package com.emmabugs;
public class Generator {
public static void main(String[] args) {
put("package com.emmabugs;\n");
put("public class Big {\n");
for (int i = 0 ; i != 304 ; i++) {
put(" private static final int a", i, "=", i, ";\n");
}
put(" public static void main(String[] args) {\n");
put(" if(args.length<2) return;\n");
put(" int k = Integer.parseInt(args[0]);\n");
put(" int n = Integer.parseInt(args[1]);\n");
put(" switch(k) {\n");
for ( int i = 0 ; i != 100 ; i++) {
put(" case ", i, ":\n");
put(" switch(n) {");
for (int j = 0 ; j != 20 ; j++) {
put(" case ", j, ":\n");
put(" System.out.println(a", j/3+3*i,");\n");
put(" break;\n");
}
put(" }\n break;\n");
}
put(" }\n }\n}\n");
}
private static void put(Object ... args) {
for(Object o : args) {
System.out.print(o);
}
}
}
The file on which the instrumentation fails