removeFinalModifier does not clean up after itself.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1562985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2014-01-30 21:36:38 +00:00
parent 2c8822657d
commit c79f82491a
1 changed files with 5 additions and 1 deletions

View File

@ -680,7 +680,11 @@ public class FieldUtils {
if (Modifier.isFinal(field.getModifiers())) {
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
try {
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
} finally {
modifiersField.setAccessible(false);
}
}
} catch (NoSuchFieldException ignored) {
// The field class contains always a modifiers field