I am currently working on my programming language and it will have only interfaces and no object inheritance. And I have an issue, because I don't know how to make a vtable so an appropriate method could be called in a class with many interfaces inherited.
In Java, you can write like this
interface A {
void a();
}
interface B {
void b();
}
interface C {
void c();
}
class Something1 implements A, B{
... implementing a() and b() ...
}
class Something2 implements B, C{
... implementing b() and c() ...
}
...
B obj = new Something1();
obj.b();
obj = new Something2();
obj.b();
And the JVM will call b() method with the only knowledge that the object inherits B interface (if not optimized)
So I think, firstly JVM will go to the vtable of the object and then ... How can it find b() in the vtable and what kind of vtable must be generated.
P.S The question is not about Java at all. It could be an example with C++ or PHP, it doesn't matter. It's just simplier to write an example in Java