private void buildClassAnnotations(ClassDefinition classDef, ClassVisitor cw) {
if (classDef.getAnnotations() != null) {
for (AnnotationDefinition ad : classDef.getAnnotations()) {
AnnotationVisitor av = cw.visitAnnotation("L"+getInternalType(ad.getName())+";", true);
for (String key : ad.getValues().keySet()) {
AnnotationDefinition.AnnotationPropertyVal apv = ad.getValues().get(key);
switch (apv.getValType()) {
case STRINGARRAY:
AnnotationVisitor subAv = av.visitArray(apv.getProperty());
Object[] array = (Object[]) apv.getValue();
for (Object o : array) {
subAv.visit(null,o);
}
subAv.visitEnd();
break;
case PRIMARRAY:
av.visit(apv.getProperty(),apv.getValue());
break;
case ENUMARRAY:
AnnotationVisitor subEnav = av.visitArray(apv.getProperty());
Enum[] enArray = (Enum[]) apv.getValue();
String aenumType = "L" + getInternalType(enArray[0].getClass().getName()) + ";";
for (Enum enumer : enArray) {
subEnav.visitEnum(null,aenumType,enumer.name());
}
subEnav.visitEnd();
break;
case CLASSARRAY:
AnnotationVisitor subKlav = av.visitArray(apv.getProperty());
Class[] klarray = (Class[]) apv.getValue();
for (Class klass : klarray) {
subKlav.visit(null,Type.getType("L"+getInternalType(klass.getName())+";"));
}
subKlav.visitEnd();
break;
case ENUMERATION:
String enumType = "L" + getInternalType(apv.getType().getName()) + ";";
av.visitEnum(apv.getProperty(),enumType,((Enum) apv.getValue()).name());
break;