mercredi 25 juillet 2018

Spring ReflectionTestUtils does not set static final field

I have a static final field like this:

class SomeClass {
    static final String CONST = "oldValue";
}

and i'm trying to change that field in test like this:

ReflectionTestUtils.setField(SomeClass.class, "CONST", "newValue");

but it doesn't work and says

java.lang.IllegalStateException: Could not access method: Can not set static final java.lang.String field





Aucun commentaire:

Enregistrer un commentaire