import org.aspectj.apache.bcel.classfile.ConstantClass;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
+import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue;
import org.aspectj.apache.bcel.generic.ConstantPoolGen;
import org.aspectj.apache.bcel.generic.ObjectType;
this.idx = cpool.addClass(t);
}
- public int getIndex() {
+ public ClassElementValueGen(ClassElementValue value, ConstantPoolGen cpool) {
+ super(CLASS,cpool);
+ idx = value.getIndex();
+ }
+
+ public int getIndex() {
return idx;
}
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue;
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue;
+import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
case '[': // Array
return new ArrayElementValueGen((ArrayElementValue)value,cpool);
+ case 'c': // Class
+ return new ClassElementValueGen((ClassElementValue)value,cpool);
+
default:
throw new RuntimeException("Not implemented yet! ("+value.getElementValueType()+")");
}
import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
+import org.aspectj.apache.bcel.generic.ClassGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
import org.aspectj.apache.bcel.util.SyntheticRepository;
verifyClassAnnotation(clazz);
}
+ public void testAnnotationClassElementCopying() throws ClassNotFoundException {
+ SyntheticRepository repos = createRepos("testcode.jar");
+ JavaClass clazz = repos.loadClass("AnnotatedWithClassClass");
+ Annotation[] anns = clazz.getAnnotations();
+ ClassGen cg = new ClassGen(clazz);
+ // Checks we can copy class values in an annotation
+ new AnnotationGen(anns[0],cg.getConstantPool());
+ }
+
public void testAnnotationClassElementReadWrite() throws ClassNotFoundException,IOException {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("AnnotatedWithClassClass");