[jboss-user] [Javassist user questions] - Help on class anotation

theyurinator do-not-reply at jboss.com
Wed Aug 13 01:21:47 EDT 2008


Hello,

I am new to Javassist, so excuse me for all the things I do not know yet.

I am having trouble adding a class annotation. I do exactly what the AnnotationsAttribute API page sample does:

 ClassFile cf = ... ;
 ConstPool cp = cf.getConstPool();
 AnnotationsAttribute attr
     = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
 Annotation a = new Annotation("Author", cp);
 a.addMemberValue("name", new StringMemberValue("Chiba", cp));
 attr.setAnnotation(a);
 cf.addAttribute(attr);
 cf.setVersionToJava5();

But when I create this page, using ct.write(), I just get a class which extends an Object with an empty constructor, but no annotation.

Any insight?

Thank you.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170227#4170227

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170227



More information about the jboss-user mailing list