Hello,
I am currently using bcel.classfile and bcel.util to extract dependencies
from existing class files.
Recently, I have encountered a case when a Subclass is invoking a method
where I need to distinguish between when implementation of the invoked
method is in the subclass itself or the baseclass.
Is it possible to distinguish that a method being referenced for a class is
actually implemented in a base class? See example below.
Note in the example that Triangle extends Shape, and that Triangle calls the
method, setTypeName(String) implemented in Shape. In the current BCEL
methods that I am using, when I process Triangle.class, the class reported
for the location of setTypeName is Triangle rather than Shape. Are there
other methods I could be calling which would help me discover that
setTypeName is actually implemented in Shape rather than Triangle?
public abstract class Shape {
abstract void draw();
private String typename;
public void setTypeName (String typename) {
this.typename = typename;
}
}
public class Triangle extends Shape {
Shape () { setTypeName ("triangle"); }
void draw() { System.out.println("triangle"); }
}
Thanks,
Ev