SpongePowered / Mixin

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

Oberwrite methods (all or only some?) aren't getting deobfuscated when loading obfuscated mixin in deobfuscated environment #256

Open Barteks2x opened 6 years ago

Barteks2x commented 6 years ago

Normally this isn't an issue as one can just use BON2 to properly deobfuscate the jar and it will work fine.

The issue starts the moment I want to have separate API for a mod that uses mixin, and a thing that uses the API. To be able to run the mod that uses such API in dev environment, the actual mod that uses mixin is needed, so it seems like a runtime dependency would be perfect for it. Unfortunately ForgeGradle provides no deobfRuntime dependency, and using runtime dependency by itself is very unlikely to work because forge deobfuscating transformer doesn't deobfuscate some parts that mixin expects to be deobfuscated (does it actually run on the mixin classes at all?). So right now the only way is to manyally get the mod, run it through BON2 and add it into mods/.

I'm reporting it here and not forge because I'm not sure if it's forge issue, but it's definitely specific to mixin.

Mumfrey commented 6 years ago

Yeah obviously this is the reason the AP exists in the dev -> obf direction of travel, but there is no equivalent in the opposite direction. The mixin AP could definitely provide the relevant information into the compiled jar to allow deobfuscation, but then there would need to be some corresponding component in ForgeGradle (or an additional feature in MixinGradle perhaps) which would process that information and apply it, similar to the extraSrgs it supports during the original obf step which MixinGradle leverages.

I seem to remember that FG supports arbitrary ASM transformers at some point in its pipeline, though I may be mis-remembering.

All that said, the fact that the @Overwrite annotation exists and the target can be resolved from the @Mixin annotation might mean that it's possible to do this with no changes to the AP, and only some extra functionality in MixinGradle or ForgeGradle. I'll investigate what the options are and see what I can come up with. In the mean time if you could link me a test project and jars which trigger the problem that would help a lot since I'll have a testbed for the problem then.

Barteks2x commented 6 years ago

Will probably take me up to an hour to set up special test environment for it, in the meantime I can provide cubic chunks jar that shows the issue here: https://oss.sonatype.org/content/repositories/snapshots/io/github/opencubicchunks/cubicchunks/1.12.2-0.0.835.0-SNAPSHOT/cubicchunks-1.12.2-0.0.835.0-20180503.171642-2-all.jar and github link https://github.com/OpenCubicChunks/CubicChunks/tree/6cdb07c9ee0965c1ad47629dc5ff8382ebef396f (if you don't need a small test case just tell me so I don't need to work on it). It throws this exception: https://pastebin.com/raw/QhnQxU8t

The same jar works fine after using BON2 on it.

Barteks2x commented 6 years ago

Looks like this is actually caused by me adding transformer exclusion. Something I never even considered to check for, and initially did because every single coremod example did it, and it has never caused issues before so I never looked at it.

Barteks2x commented 5 years ago

It still doesn't work.