[jboss-user] [Javassist user questions] - Re: adding annotations
cat4hire
do-not-reply at jboss.com
Wed Mar 5 06:59:13 EST 2008
I'm going mad, anyone with a suggestion?
I've found that the following piece of code:
| ByteArrayOutputStream aos = new ByteArrayOutputStream();
| AnnotationsWriter aw = new AnnotationsWriter(aos, constantPool);
| aw.numAnnotations(1);
| aw.annotation(this.annotationClassName, 0);
| aw.close();
| byte ab[] = aos.toByteArray();
| System.out.println("\n\t++++Annotation bytecode for annotation " + this.annotationClassName + "++++");
| System.out.println(new String(ab) );
| System.out.println("\n\t++++++++++++++\n");
| attribute = new AnnotationsAttribute(constantPool, AnnotationsAttribute.visibleTag, ab);
|
that should create the annotation specified, prints the following:
|
| ++++Annotation bytecode for annotation whitecat.example.DBRoleAnnotation++++
|
|
| +++++++++++++++++++++++
|
|
So I'm pretty sure that the bytecode generated for the annotation is empty, and that the annotation is regularly added to my class, but without a bytecode I cannot access it. Anyone can explain why the bytecode is null?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134189#4134189
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134189
More information about the jboss-user
mailing list