[jboss-user] [Javassist] New message: "Re: problem adding annotations at runtime"

suresh inala do-not-reply at jboss.com
Fri Feb 19 08:19:32 EST 2010


User development,

A new message was posted in the thread "problem adding annotations at runtime":

http://community.jboss.org/message/527257#527257

Author  : suresh inala
Profile : http://community.jboss.org/people/inalasuresh

Message:
--------------------------------------------------------------
Hi Guys the problem is solved,
the mistake was I’m creating a new instance of AnnotationsAttribute and need to use attr.addAnnotation(annotation); instead of attr.setAnnotation(annotation);
 
Below code is for getting the annotations and add new annotations.
 
Changes on Code snipped :
 
AnnotationsAttribute attr = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
Annotation annotation = new Annotation("javax.jws.HandlerChain",constantPool);
if (attr != null) {
                annotation.addMemberValue("file", new StringMemberValue("HelloWorldClient_handler.xml", constantPool));
}
//attr.setAnnotation(annotation);
attr.addAnnotation(annotation);
classFile.addAttribute(attr);
classFile.setVersionToJava5();
 
i Succeed, with the above code,
 
Thanks & Regards
   Suresh

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/527257#527257




More information about the jboss-user mailing list