Remove final modifier to fix illegal reflective access warning

Java 9 runtimes report warnings for reflective access on JRE
classes (in this case Field.modifiers). Future versions of Java
may deny the access completely.

Since we access our own code here, we could just remove the final modifier.
With it's current visibility (of private) it's unlikely that it will be
modified from somewhere else except our Settings class.
This commit is contained in:
games647 2018-03-13 16:20:02 +01:00
parent 7e40d13947
commit d24fbc9f55
No known key found for this signature in database
GPG key ID: BFC68C8708713A88
2 changed files with 3 additions and 7 deletions

View file

@ -1338,11 +1338,7 @@ public class Settings implements net.ess3.api.ISettings {
try {
Field field = NumberUtil.class.getDeclaredField("PRETTY_FORMAT");
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, currencyFormat);
modifiersField.setAccessible(false);
field.setAccessible(false);
} catch (NoSuchFieldException | IllegalAccessException e) {
ess.getLogger().severe("Failed to apply custom currency format: " + e.getMessage());