I've made another experiment: using an AnnotationsWriter as follows does not work too:
| | ByteArrayOutputStream aos = new ByteArrayOutputStream(); | AnnotationsWriter aw = new AnnotationsWriter(aos, constantPool); | aw.numAnnotations(1); | aw.annotation(this.annotationClassName, 0); | aw.close(); | byte ab[] = aos.toByteArray(); | attribute = new AnnotationsAttribute(constantPool, AnnotationsAttribute.visibleTag, ab); | | System.out.println("Annotation attribute " + attribute.getName() + " " + attribute.getAnnotations().length); | classFile.addAttribute( attribute ); | The class can be loaded and instantiated, but I cannot access its annotations. In both cases, if I print the classfile content with a ClassFileWriter I got a message that lets me think I've got the annotations: | attribute: SourceFile (2 byte): javassist.bytecode.SourceFileAttribute | attribute: RuntimeVisibleAnnotations (6 byte): javassist.bytecode.AnnotationsAttribute | Moreover, in the case in which I use an AnnotationsWriter I got the following run-time exception when I try to access the annotations thru the Class.getAnnotations() method: | Exception in thread "Thread-Example-Main" java.lang.reflect.GenericSignatureFormatError | at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:103) | at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:233) | at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:359) | at sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:157) | at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:367) | at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:181) | at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69) | at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52) | at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072) | at java.lang.Class.getAnnotations(Class.java:3052) | I cannot find whre I'm doing something wrong. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133207#4133207 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133207 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user