Mixin
Mixin copied to clipboard
The type of this does not get properly remapped when calling a @PolymorphicSignature method
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;.
temp workaround: someVarHandle.getAcquire((TargetClass)(Object) this)