I am using an interface in my code which has been there for a long time and many classes have implemented it. Now i have to add a new method to this interface for a new class [old classes dont need the new method]. So as has been suggested at many places that i can extend that old interface and create a new one with new method. Now my problem is that app launcher which uses the interface implementation is only having reference to base interface and using base interface i can't call method in new interface.
baseInterface is extended by newInterface
Class Applauncher{
baseInterface b;
}
So as can be seen i can't call new method in "newInterface" in Applauncher class.
I want a solution which will not shake up my old implementation.
Applauncherclass cannot be changed, and holds a reference tobaseInterface- but the actual reference being stored is to anewInterface? If so, I think you might be able to handle your problem with casting. SonewInterface asNew = (newInterface) b, wherebis a variable of typebaseInterfacewhich actually stores a reference tonewInterface.