SpongePowered / Mixin

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

Annotation processor expects full At target signature #303

Open ChloeDawn opened 5 years ago

ChloeDawn commented 5 years ago

Although the signature can be unqualified at runtime, compilation fails here for At targets with ommited owners and signatures during refmap generation. Related: https://github.com/SpongePowered/Mixin/issues/300#issuecomment-463453763

Current version: 0.7.11

Is it possible to resolve this?

https://github.com/SpongePowered/Mixin/blob/81a22a4f1d1cf59089bed40cdab4913860340c22/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerInjector.java#L312-L316

Mumfrey commented 5 years ago

Ah yes. The requirement is because the mappings require the descriptor in order to locate the obfucation mapping. There are two things I think can be done to work around this:

For the time being you can work around this by fully qualifying the reference as described in the other issue, taking into account the full descriptor of the synthetic constructor. But I can definitely attempt to make the AP smarter to address this.

For reference, the injection point itself consumes the signature as a "query" and that query matches candidates in the code. The Annotation Processor cannot access the code and therefore cannot resolve the references which may or may not exist in the method body, it can only look at the target type and figure out what exists there. This means that references such as doSomething can never be resolved on an @At but references such as Lsome\Class;doSomething can potentially be resolved as long as there is only one member with that name in the target class.

I'm labelling this as enhancement rather than bug because this behaviour is intended, but functionality can be improved.