Is there any way in Java to modify an annotation of a method parameter?
In this case, I would like modify the content of theKey
(currently: CHANGE_ME
) to something new (e.g. I'M CHANGED
).
@ClassAnnotation(foo = "bar")
public interface SomeInterface {
@MethodAnnotation(foo = "bar")
void getDomains(@ParamAnnotation(theKey = "CHANGE_ME") String theString);
}
As far as I found out with runtime debugging, getAnnotations()
in Parameter.java finally leads to sharedGetParameterAnnotations()
in Executable.java which parses some parameterAnnotations
ByteArray and then constructs an Annotation
.
If I'm not mistaken, this would mean, that modifying the value of @ParamAnnotation
's theKey
is not possible (unless messing around with the byte code - which is probably even more ugly then changing stuff with Reflection).
On the other side, this seems to be strange as changing values for foo
in @ClassAnnotation
and @MethodAnnotation
works fine.
Aucun commentaire:
Enregistrer un commentaire