An interface with a default method is initialized even if this method is overridden and even if it's not at all invoked.
Example:
public interface I {
int a = foo();
default void test1(){
}
static int foo(){
System.out.println("I initialized");
return 15;
}
}
public class C implements I{
public void test2(){
System.out.print("C initialized");
}
}
public class Test {
public static void main(String[] args) {
C c = new C();
c.test2();
}
}
prints:
I initialized
C initialized
What's exactly the problem here?