py4j / py4j

Py4J enables Python programs to dynamically access arbitrary Java objects

Home Page:https://www.py4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interface default method not exist when extended by another interface

Vancior opened this issue · comments

Suppose we have class C -|> interface IB -|> interface IA, while IA has a default method foo which is not overwriten by any of its children, then invocation on c.foo() would fail with Method foo([]) does not exist.

interface IA {
    default String foo() {
        return "foo " + bar();
    }
    String bar();
}

interface IB extends IA {}

public static class C implements IB {
    public String bar() {
        return "C#bar()";
    }
}

Interesting. Does this work in the regular reflection but not work in Py4J?

Interesting. Does this work in the regular reflection but not work in Py4J?

C.class.getMethod("foo").invoke(new C()) works.

I guess it's here that super classes of interfaces are not scanned.

for (Class<?> intf : clazz.getInterfaces()) {
methodsToCheck.addAll(Arrays.asList(intf.getDeclaredMethods()));
}