In my application I have:
Class B
Class C extends B. Class C contains one method that overrides a method in B. Lets call the method myMethod and Class C has the constructors that simply call the super method in the parent class.
In a JSP file that uses these objectsI have an object: ob and the following code:
if (some_condition) {
//Here I want to accomplish the following:
((C)ob).myMethod();
// That is I want to execute the method as if the ob was actually of class C.
}
I can code it to avoid compilation problems as above. But I keep getting a cannot CAST from B to C runtime error.
Any ideas?
The high level puprose of this is that there is one type of user of the application who has some special code they want to execute. And for obscure reasons the company does not want to put conditional code in the code for class B.