In the end I managed to work it out and answer my own question. The key was understanding
that you need to add the AnnotationsAttribute instance to the Info of the method.
That is the rough solution is:
| CtClass clazz = ....
| ClassFile classFile = clazz.getClassFile();
| ConstPool cp = classFile.getConstPool();
| AnnotationsAttribute attr = new AnnotationsAttribute(cp,
AnnotationsAttribute.visibleTag);
|
| Annotation useAnnotation = new Annotation("org.package.AnnotationType",cp);
| annotation.addMemberValue("name", new
StringMemberValue("Paul",cp));
|
| attr.setAnnotation(useAnnotation);
|
| m.getMethodInfo().addAttribute(attr);
|
|
So the only real difference between the CtClass, CtMethod and even parameters is I needed
to do the appropriate getXXXInfo and then add the attribute directly.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241819#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...