有没有办法可以给方法注释一个方法作为输入。 然后使用从它返回的值传递给注释?
public String fnc(String value){
//do something
return ret;
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface MAnon{
String cond = fnc(cond);
}
@MAnon(fnc("Something")) //does not work
@MAnon("Something")
public void foo(){ ... }
public void bar(){
//reflection call
MAnon a = ...getDeclaredAnnotations()[0]
String foo = a; //may not be the same as what is typed
}