After a lot I found that the following is the code that works for me:

  |     ClassFile classFile = newProxyClass.getClassFile();
  |     ConstPool constantPool = classFile.getConstPool();
  |     AnnotationsAttribute attr = new AnnotationsAttribute(constantPool, 
AnnotationsAttribute.visibleTag);
  |     javassist.bytecode.annotation.Annotation a = new 
javassist.bytecode.annotation.Annotation(this.annotationClassName, 
constantPool);
  |     attr.setAnnotation(a);
  |     classFile.addAttribute(attr);
  |     classFile.setVersionToJava5();
  |     
  |     
  |     ByteArrayOutputStream bos = new ByteArrayOutputStream();
  |     DataOutputStream os = new DataOutputStream( bos );
  |     classFile.write( os );
  |     os.close();
  |     
  |     // all done
  |     return bos.toByteArray();
  | 

the above produces the byte code for a class with the added annotation.

Thanks,
Luca

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4140550
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to