Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

Allow @Invoker usage for interfaces

Open CertainLach opened this issue 5 years ago • 1 comments

Use case

Expose some class internals as non obfuscated fields, for usage with nashorn;

I.e if i want to be able to call ITextComponent#append, without bothering about script remapping:

@Mixin(ITextComponent.class)
public interface MixinITextComponent {
    @Invoker
    ITextComponent appendText(String text);
}

Before this commit, generated bytecode was

     public synthetic appendText(java.lang.String arg0) { //(Ljava/lang/String;)Lhh;
             aload0 // reference to self
             aload1
             invokevirtual hh.a(Ljava/lang/String;)Lhh;
             areturn
     }

But correct should be

     public synthetic appendText(java.lang.String arg0) { //(Ljava/lang/String;)Lhh;
             aload0 // reference to self
             aload1
             invokeinterface hh.a(Ljava/lang/String;)Lhh;
             areturn
     }

CertainLach avatar Jun 17 '20 08:06 CertainLach

This looks sensible, I will take a look at this and validate there are no unexpected side-effects.

Mumfrey avatar Jun 18 '20 12:06 Mumfrey