Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change annotation value at runtime using reflection? [duplicate]

Below is the annotation.

@Before(value="execution(* class.method(**)")

Can i change the value of single value annotation using java reflection?

Please suggest.

like image 469
Chetan Shirke Avatar asked Dec 06 '25 02:12

Chetan Shirke


1 Answers

The description of what you are looking for can be found here. But be wary about using such approach, some of the caveats of it are also described.

Also, the retention policy of the annotation has to be runtime, for this.

The link in the comment to your question leads to a post that looks like something you are asking about, but the difference is that it is about a JPA/Hibernate annotation where in the run-time you get a proxy class to your class.

like image 138
alterfox Avatar answered Dec 08 '25 14:12

alterfox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!