Whoops, corrected example...

public abstract class Shape {
    private String typename;
    abstract void draw();
    public void setTypeName (String typename) {
       this.typename = typename;
    }
}

public class Triangle extends Shape {
    Triangle() { setTypeName("triangle"); }
    void draw() { System.out.println("triangle"); }
}

-----Original Message-----
From: Ev Jordan [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 03, 2005 5:41 PM
To: [email protected]
Subject: Telling the difference between a self reference and a base class
reference

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

 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to