I found this thread: How to change annotation value at runtime using reflection?
And I'm trying to change method annotation, but java.lang.reflect.Method does not contain any map-field like "annotations" or method like "getDeclaredAnnotationMap"
There is only private byte[] annotations
but what can I do with this byte array?
So, how to modify annotation of method?
EDIT:
I created that: http://pastebin.com/T2rewcwU
But that only edit this instance of method, if you uncomment 33 line of code then value will reset.
I wrote a class
AnnotationUtil
to resolve the seris requirements.It can add/remove/change annotation value on class/field/method instance.
Note that use
ReflectUtil
to get root field/method when add/remove annotation.See it on github:
AnnotationUtil
ReflectUtil