Is this a Design issue or Eclipse's issue or Java's loophole?
Let us have the following classes defined in eclipse's work space:
public abstract class A {
public void foo() {
System.out.println("Hi.. this is foo()");
}
}
public interface I {
void foo();
}
public class B extends A implements I {
public void bark() {
System.out.println("Hi.. this is bark()");
}
}
public class C {
public void woo() {
I i = new B();
i.foo();
}
}
Now the problem is eclipse doesn't show any references for A.foo() on searching through
- References -> Project or
- References - Hierarchy
I see this a desi开发者_Go百科gn issue. What do you think?
Sounds perfectly reasonable to me as in your provided code A does not implement I, only B does. Event though in declaration of B code reads out extends A implements I it does not mean A would retrospectively be implementing interface I - it says "B extends A and also implements I".
Works for me in Eclipse:
A a = new A() { };
a.foo(); // <-- A.foo() found this reference by Eclipse in "References -> Project"
加载中,请稍侯......
精彩评论