A simple question, regarding dynamic java, is it do-able, or totally not possible
//you have an instance of classA and it has a method doIT(), for example,
ClassA obj = new ClassA();
//you call method doIT() of ClassA
obj.doIt();
Now I have to re-model ClassA it becomes a superclass, and its methods and members are pushed down into its subclass, let's say ClassB, so ClassB extends ClassA, and method doIt() is moving into ClassB now, everyone knows as usual I need to change the above code to below, either manually or with help of modern IDE refactoring capacity
//you create an instance of ClassB,
ClassB obj = new ClassB();
//or ClassB obj = new ClassA(); you have little code in the ClassA constuctor, etc.
//then you call a method
obj.doIt();
I know that, but my question is, without make changes to it
ClassA obj = new ClassA();
obj.doIt();
is there any tricks that will make it works with the new model? that means, some how I could return a real instance of ClassB to
ClassA obj = new ClassA();
but java compiler won't let me go with
obj.doIt();
because method doIt() is not inside ClassA anymore, even the return copy is a real ClassB,
is there any trick to fool compiler or make the idea working?