(defined in Java)
interface Foo {
default int bar() {
throw new RuntimeException("not implemented");
}
}
(defined in Scala)
class FooImpl extends Foo {
override int bar() {
return 42;
}
}
In the above code snippet, I have an interface defined in Java, with a default method bar which just throws exception. The question is how to check if a subclass FooImpl overrides the default method or not. It seems in Java we can check the declaring class on the Method instance from reflection: if FooImpl overrides the method, the declaring class will be itself, and otherwise will be the interface Foo.
However above seems not true in Scala (2.12): in both situations the declaring class will be FooImpl.