Java 如何在运行时动态更新注释中的值?

Java 如何在运行时动态更新注释中的值?,java,annotations,Java,Annotations,以下是示例代码: @interface MyAnnotation { String stringValue1(); String stringValue2(); } public class Ann{ private String requireString = "str"; @MyAnnotation(stringValue1 = "abc" , stringValue2 = "") public String getstringValue1() { return (this.r

以下是示例代码:

@interface MyAnnotation {
String stringValue1();

String stringValue2();
}

public class Ann{
private String requireString = "str";
@MyAnnotation(stringValue1 = "abc" , stringValue2 = "")
public String getstringValue1() 
{
    return (this.requireString);
}
}
在这里,我想用“this.requireString”返回的值来更新getStringValue()方法的MyAnnotation的stringValue2元素的值


你能告诉我怎么做吗

此代码无法编译。。。(提示:
getstringValue1()
应该返回一个布尔值-而不是字符串)我错误地编写了boolean,实际上,该方法只返回字符串,上面示例中的注释有什么好处?可以从另一个包中的另一个java类访问该注释,而不会影响依赖性我不确定是否理解,你能示范一下(小例子)吗?