lundi 18 février 2019

Add annotation to a field during runtime [duplicate]

This question already has an answer here:

Class MyClass has a numeric field number with annotations.

class MyClass {

    @Min(10)
    Number number;
}

I would like to use reflection and add a new annotation @Max(20) to the field on runtime.

How?

I have read an article https://www.baeldung.com/java-reflection-change-annotation-params, I could not find annotationData. There is not public method see or append or put annotation.

I use open-jdk-10.

I found here. I would like to close my question. Adding Java Annotations at Runtime





Aucun commentaire:

Enregistrer un commentaire