Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super calls to default interface methods can be mismapped #146

Closed
Chocohead opened this issue Jun 16, 2024 · 1 comment · Fixed by #150
Closed

Super calls to default interface methods can be mismapped #146

Chocohead opened this issue Jun 16, 2024 · 1 comment · Fixed by #150

Comments

@Chocohead
Copy link

Chocohead commented Jun 16, 2024

When a mixin uses one of the target's interface's default methods, any parent class which also implements a method with a matching signature will take the call instead.

In the following situation:

public interface IA {
	String method(int value);
}

public static abstract class A implements IA {
}

public interface IB extends IA {
	default String method(int value) {
		return "I've got " + value;
	}
}

public static class B extends A implements IB {
	public String testCall() {
		return "no mixin";
	}
}

with the following mixin:

@Mixin(B.class)
abstract class BMixin implements IB {
	@Inject(method = "testCall", at = @At("HEAD"))
	private void useInterfaceCall(CallbackInfoReturnable<String> call) {
		call.setReturnValue(IB.super.method(5));
	}
}

You would expect new B().testCall() to return I've got 5, but it instead throws an AbstractMethodError:

java.lang.AbstractMethodError: com.chocohead.example.A.method(I)Ljava/lang/String;
	at com.chocohead.example.B.handler$zzc000$test-mod$addInterfaceCall(B.java:521)
	at com.chocohead.example.B.test(B.java)
	at com.chocohead.example.Test.onInitialize(Test.java)

This is caused by the re-parenting Mixin does to correct super calls in mixins preferring the target's parent interfaces over the target's own...


This crash can be caused in a Minecraft context by having an empty mixin targeting FixedColourVertexConsumer whilst Iris is installed before 1.21. This crash is from opening ModMenu on 1.20.4 for example:

java.lang.AbstractMethodError: Method net/minecraft/class_4585.method_22921(II)Lnet/minecraft/class_4588; is abstract
	at net.minecraft.class_4585.method_22921(class_4585.java)
	at net.minecraft.class_287.method_22921(class_287.java:2095)
	at net.minecraft.class_4588.method_22916(class_4588.java:56)
	at net.minecraft.class_382.method_22944(class_382.java:55)
	at net.minecraft.class_327$class_5232.method_27531(class_327.java:282)
	at net.minecraft.class_327.method_27530(class_327.java:299)
	at net.minecraft.class_327.method_1723(class_327.java:147)
	at net.minecraft.class_327.method_22942(class_327.java:84)
	at net.minecraft.class_332.method_51430(class_332.java:289)
	at net.minecraft.class_332.method_35720(class_332.java:285)
	at com.terraformersmc.modmenu.gui.widget.DescriptionListWidget$DescriptionEntry.method_25343(DescriptionListWidget.java:338)
	at net.minecraft.class_350.method_44397(class_350.java:411)
	at net.minecraft.class_350.method_25311(class_350.java:396)
	at com.terraformersmc.modmenu.gui.widget.DescriptionListWidget.method_25311(DescriptionListWidget.java:226)
	at net.minecraft.class_350.method_48579(class_350.java:184)
	at net.minecraft.class_339.method_25394(class_339.java:66)
	at com.terraformersmc.modmenu.gui.ModsScreen.method_25394(ModsScreen.java:301)
	at net.minecraft.class_437.method_47413(class_437.java:110)
	at net.minecraft.class_757.mixinextras$bridge$method_47413$241(class_757.java)
	at net.minecraft.class_757.wrapOperation$znj000$fabric-screen-api-v1$onRenderScreen(class_757.java:2611)
	at net.minecraft.class_757.method_3192(class_757.java:931)
	at net.minecraft.class_310.method_1523(class_310.java:1327)
	at net.minecraft.class_310.method_1514(class_310.java:888)
	at net.minecraft.client.main.Main.main(Main.java:265)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)

Iris's mixin using BufferVertexConsumer#light is here.

@LlamaLad7
Copy link
Collaborator

Will try to fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants