I have requirement to extend a .class file in my project and need to override a simple method. Consider i have class A which is in some .jar package.Now i want to override test() method of class A.I did it using creating subclass B of A and override it. Now in my application package (it is .jar) Object is created for class A. This object invoke the method of class A. But i want to make a call to class B method.
My idea is to proxy the object creation in whole application. Whenever the obj of class A is created at that time i want to some configuration to create object of class B & handed over to class A initiate.
Some one please help me to implement this type of mechanism.
Following is the simple approach(using type casting) through which we can use Parent class object to call Child class method :