I have a class with a method having custom annotation
@Target(ElementType.METHOD)
public @interface MethodXY {
public int x();
public int y();
}
public class AnnotationTest {
@MethodXY(x=5, y=5)
public void myMethodA(){ ... }
@MethodXY(x=3, y=2)
public void myMethodB(){ ... }
}
I want to add N number of methods in this class at run time once when the class loads. The values of X & Y will be read from an array of size N ( any collection / properties file )
I am able to change values of annotation at run time
MethodXY anno2 = (MethodXY) setAttrValue(anno, MethodXY.class, "x", "400");
System.out.println(String.format("New values: %s, %s", anno2.X(), anno2.y()));
but unable to pass new annotation value to method .
How could it be done in java .
Aucun commentaire:
Enregistrer un commentaire