CheckAnnotationAdapter.visit() should accept values of type Class and Enum
I got this exception trying to run Cobertura 2.0.3:
java.lang.IllegalArgumentException: Invalid annotation value
at org.objectweb.asm.util.CheckAnnotationAdapter.visit(Unknown Source)
at org.objectweb.asm.ClassReader.a(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at
net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:153)
at
net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at
net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at
net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at
net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
This was running on a normally compiled class - nothing fancy about it.
The corresponding code in CheckAnnotationAdapter looks suspicious:
public void visit(final String name, final Object value) {
checkEnd();
checkName(name);
if (!(value instanceof Byte || value instanceof Boolean
|| value instanceof Character || value instanceof Short
|| value instanceof Integer || value instanceof Long
|| value instanceof Float || value instanceof Double
|| value instanceof String || value instanceof Type
|| value instanceof byte[] || value instanceof boolean[]
|| value instanceof char[] || value instanceof short[]
|| value instanceof int[] || value instanceof long[]
|| value instanceof float[] || value instanceof double[]))
{
throw new IllegalArgumentException("Invalid annotation value");
}
Shouldn't this code also allow values of type Enum and Class?