For context, say I have these classes:
public class Foo {
public void doStuff() {}
}
public class Bar extends Foo {
@Override
public void doStuff() {}
}
public class Zig extends Foo {
@Override
public void doStuff() {}
}
I'm trying to find only calls to Bar#doStuff().
I've tried:
- Java Search for
Bar.doStuff - "Open Call Hierarchy" on
Bar#doStuff()
but they appear to return calls to both Bar.doStuff() and Foo.doStuff() and Zig.doStuff(). Is there something else I need to do, or am I misunderstanding the results I'm getting?
Well, due to polymorphism, there's not a good way for the IDE to know that a given Foo isn't potentially a Bar -- so it will show you all calls to
doStuff. I suppose it could do more analysis to determine that the concrete type of aFooreally is aFoo-- for example, in the case:it is definitely not a
Bar-- but that's a lot of work for little benefit.You will notice the same holds true for interfaces and their implementations, at least in Eclipse.