Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

Annotation processor expects full At target signature

Open ChloeDawn opened this issue 6 years ago • 1 comments

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

ChloeDawn avatar Feb 14 '19 21:02 ChloeDawn

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 structural references like <init> the remapping could be done using the fallback method of remapping the individual parts of the descriptor (eg. class names which appear in the owner and arguments)
  • The missing descriptor could probably be resolved as long as the target is unique

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.

Mumfrey avatar Feb 16 '19 12:02 Mumfrey