这是设计问题还是 Eclipse 问题还是 Java 漏洞?
让我们在 Eclipse 的工作空间中定义以下类:
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();
}
}
现在的问题是 Eclipse 在搜索引用时没有显示 A.foo() 的任何引用
- ->项目或
- 参考 - 层次结构
我认为这是一个设计问题。你怎么认为?
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 design issue. What do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说听起来完全合理,因为在您提供的代码
A
中,没有实现I
,只有B
实现。尽管在B
代码声明中的事件读出extends A Implements I
,但这并不意味着A
会追溯实现接口I - 它说“B扩展了A并且还实现了I”。
Sounds perfectly reasonable to me as in your provided code
A
does not implementI
, onlyB
does. Event though in declaration ofB
code reads outextends A implements I
it does not meanA
would retrospectively be implementing interfaceI
- it says "B extends A and also implements I".在 Eclipse 中为我工作:
Works for me in Eclipse: