MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

Add error/warning for calling an interface injection method without an implementation

Open Earthcomputer opened this issue 2 months ago • 0 comments

Minecraft Development for IntelliJ plugin version

2025.2-1.8.6

Description of the feature request

Interface injection has a problem where if javac can't find the implementation of the method it is calling at compile time, and the owner of the method isn't abstract, then a compile error is generated. The IDE does not pick up this error, so users only discover it at runtime and are often confused about how to solve it. For example:

public class Item implements /*injected*/ MyItemInterface {
   // ...
}

public interface MyItemInterface {
   void foo(); // no default method impl
}

@Mixin(Item.class)
public class ItemMixin implements MyItemInterface {
   @Override
   public void foo() {
      // method is implemented in mixin
   }
}
Item item = ...;
item.foo(); // generates a compile error in javac, but the IDE does not pick it up

Even though no crash would happen at runtime, javac cannot detect that the foo method is in fact implemented by the mixin. Note that this would not occur if the Item class was abstract, as this disables javac's check for whether the method implementation exists.

Earthcomputer avatar Nov 09 '25 23:11 Earthcomputer