I need to cast any Object into its related EObject. When I try to do it I get a ClassCastException. My question is it possible to cast an object into a EObject and if it is possible how can I do it.
Thanks
I need to cast any Object into its related EObject. When I try to do it I get a ClassCastException. My question is it possible to cast an object into a EObject and if it is possible how can I do it.
Thanks
If you are getting this exception, then the instance in question is not an EObject. It means that you are trying to say it is an EOjbect when in fact it is not.
You do understand that casting is not a conversion process right? It doesn't 'make' your object an EObject, it simply 'reveals' it as one (if it is one).
Your exception will actually tell you what the object is that you are trying to cast to EObject (which you should have included in your question, btw).
EObjects are interfaces that describe their corresponding objects, but that are not of the same type of them. You cannot cast these. And really, you don't want to. As EObjects and their descendents described models, not your actual program.