SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.41k stars 194 forks source link

IllegalAccessError on Java 11 #487

Closed KR33PYK1NG closed 3 years ago

KR33PYK1NG commented 3 years ago

When running code compiled with JDK 11 (in this case, a server software), IllegalAccessErrors related to final field modification can be encountered when mods modify fields which are declared as final (and they do that a lot) Also worth mentioning that when software is compiled with JDK 8, no such error is present. Log: https://mclo.gs/BED8KjM This issue also points out the same problem and possibly can be helpful: https://github.com/spockframework/spock/issues/1011

Earthcomputer commented 3 years ago

Those mods should be using @Mutable, which removes the final modifier from the field.

KR33PYK1NG commented 3 years ago

Those mods should be using @Mutable, which removes the final modifier from the field.

True. However, the very same code works if compiled with JDK 8 (and can logically be expected to work with JDK 11 by mod authors) This introduces unexpected runtime errors just by upgrading to Java 11, which is not a good thing.

Earthcomputer commented 3 years ago

This is not true, the mod authors are wrong. Mods (that don't use @Mutable where required) compiled for JDK8 work on JDK8, and break on JDK11 even when still compiled for JDK8. There is nothing Mixin can do to fix this, it's the mod authors that need to fix their mods by adding @Mutable.

KR33PYK1NG commented 3 years ago

Fine, I'll use a workaround until problematic mods' authors add @Mutable where needed. Thanks for the response anyway.