I was analyzing the HotSpot logs for a benchmark I ran for a piece of code in JITWatch and noticed a lot of methods calls not being inlined due to "no static binding". These seem to only occur for calls to default interface methods.
My question is are default interface methods preventing the JIT compiler from inlining their calls?
interface A {
default double a() {
return Math.random();
}
}
interface B extends A {
default double b() {
return a();
}
}
class C implements B {
public double c() {
double c = 0;
for (int i = 0; i < 1_000_000; ++i) {
c += b();
}
return c;
}
public static void main(String[] args) {
System.out.println(new C().c());
}
}
Upon further inspection in JITWatch, it seems that this problem pertains to default interface methods calling other default interface methods. That would make more sense given the "no static binding" message.