jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From   <...@thingfind.com>
Subject Replacing Methods From Different Classes
Date Thu, 22 Jul 2004 23:26:38 GMT
Hi,
I am trying to replace a method binding from one class with another method in another class.
 I haven't quite gotten this to work and any help would be appreciated.  Consider the example
below:


public class A {

    public class X {
        public X() { 
            m();      //can this be changed?
        }
	
        public void m() {
            System.out.println("A.X.m()");
        }
    }

    public static void main (String args []) {
    A a = new A();
    X x = a.new X();
    }
}


public class B extends A {

    public class X {
        public void m() {
            System.out.println("B.X.m()");
        }
    }
}



I am wondering if it is possible to change A.X.m() to reference B.X.m().  I know the use of
inner classes here is not essential, and the fact that B extends A would make the need for
overriding A.X.m() in A seemingly absurd.  This is more of a test to see if methods can be
replaced in odd contexts.  My real goal is much larger.

I have used BCELifier to create some files and I tried to edit them to reflect the desired
change, but got stuck on VerifiyErrors.  I'm not sure exactly what needs to be updated.  Also,
I thought ClassGen.replaceMethod would work, but found a few errors.  Can anyone provide some
insights?


_____________________________________________________________
Get free email chat news and more ---> http://www.thingfind.com
Send a virtual greeting card!--->http://thingfind.com/cards/create.html 
Free domain names!--->http://signup.nom.vg

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Mime
View raw message