mardi 4 février 2020

Modify annotation value on Java 8 using reflection

So, we got a enum type with some annotations:

@AnnotationName(parameter1="value1", parameter2="value2")
public enum enumType {

    VALUE1,
    VALUE2

}

We got a class that is using this enum type, and we need to change the value of the annotation for a unit test. I've been suggested to use reflection, but I'm not finding a clear way to make this. There's any simple way to access this field (which is a custom annotation, by the way) and update the values.





Aucun commentaire:

Enregistrer un commentaire