Why when in interface, calling static interface method from default interface method I cannot use this.staticInterfaceMethod()
, while when in regular class, calling static class method from instance method it is perfectly valid to use this.staticClassMethod()
(though it is bad style)?
At the same time, it is perfectly valid to use this
within default methods of interface - I can legally do the following:
interface I {
int MY_CONST = 7;
static void st_f() {}
default void f1() {}
default void f_demo() {
this.f1(); // fine!
int locvar = this.MY_CONST; // also fine!
this.st_f(); // c.ERR: static method of interface I can only be accessed as I.st_f
}
}