Reflection problem

Hi!

I write a class for accessing to list of locales supported by vanilla game. Sponge API already has the Locales class but it is providing only separated constants of locales. But I need a method like Set<Locale> getLocales().

As a result, when writing a class, I was faced with the fact that the fields of this class are not final, although it is not. How can this be?

My code here: GameLocales.java
Line 14, Modifier.isFinal(modifier) ==> false

Of course, I can simply omit this check, but it will not be beautiful. :slight_smile:

When you check, the final modifiers are already removed by access transformers used in spongecommon. So remove the isFinal check simply. The fact is that those fields are not final in the environment but final in the jar/untransformed bytecode.

1 Like