Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

The type of this does not get properly remapped when calling a @PolymorphicSignature method

Open Floweynt opened this issue 10 months ago • 1 comments

When calling a @PolymorphicSignature method such as the ones provided in VarHandle:

// exception handling omitted
@Unique 
private static final VarHandle someVarHandle = MethodHandles.lookup().findVarHandle(TargetClass.class, "someField", int.class); 

@Inject(method = "foo", at = @At("HEAD"))
private void myHandler() {
    someVarHandle.getAcquire(this);
} 

Javac compiles this down to:

INVOKEVIRTUAL java/lang/invoke/VarHandle.getAcquire (Lcom/example/mixin/TargetClassMixin;)Z

This is not properly handled by Mixin, since Lcom/example/mixin/TargetClassMixin; should be replaced with Lnet/minecraft/TargetClass;.

Floweynt avatar Mar 14 '25 14:03 Floweynt

temp workaround: someVarHandle.getAcquire((TargetClass)(Object) this)

wagyourtail avatar May 21 '25 11:05 wagyourtail