I have a class with a private static final
field that, unfortunately, I need to change it at run-time.
Using reflection I get this error: java.lan
Along with top ranked answer you may use a bit simpliest approach. Apache commons FieldUtils
class already has particular method that can do the stuff. Please, take a look at FieldUtils.removeFinalModifier
method. You should specify target field instance and accessibility forcing flag (if you play with non-public fields). More info you can find here.