Overridden default methods are ignored in interface adapters
ljfa-ag opened this issue ยท 0 comments
Suppose you have a Java interface with a default method like this:
public interface Foo {
default String someMethod() {
return "default";
}
}as well as some method which expects an instance of this interface:
public static void consumeFoo(Foo f) {
logger.info(f.someMethod());
}If you try to wrap a JS object as an instance of this interface and override the default method:
consumeFoo({
someMethod: () => "overridden"
})it does not work as expected: The default implementation will be called rather than the function given by the JS object, logging "default" rather than "overridden".
I believe the problem is in these lines: The default method will be called for any defaulted interface method, regardless of whether the target overrides it.
Rhino version: 2101.2.7-build.74, KubeJS version: 2101.7.2-build.233, Minecraft 1.21.1