Skip to main content



      Home
Home » Modeling » EMF » Casting Object to EObject(fails with ClassCastException)
Casting Object to EObject [message #1385106] Wed, 04 June 2014 07:37 Go to next message
Eclipse UserFriend
Hello everyone!

I am trying to cast an Object to an EObject:

Object ob = context.getNewObject();
EObject eob = (EObject) ob;


This leads to the following exception:
java.lang.ClassCastException: org.eclipse.core.internal.resources.File cannot be cast to org.eclipse.emf.ecore.EObject


As far as I know, this casting should work. Have I missed something?

I appreciate any counsel!
Re: Casting Object to EObject [message #1385124 is a reply to message #1385106] Wed, 04 June 2014 09:13 Go to previous message
Eclipse UserFriend
Hi

Check the inheritance. File is not an EObject.

Regards

Ed Willink


On 04/06/2014 12:37, John Cole wrote:
> Hello everyone!
>
> I am trying to cast an Object to an EObject:
>
>
> Object ob = context.getNewObject();
> EObject eob = (EObject) ob;
>
>
> This leads to the following exception:
> java.lang.ClassCastException: org.eclipse.core.internal.resources.File
> cannot be cast to org.eclipse.emf.ecore.EObject
>
> As far as I know, this casting should work. Have I missed something?
>
> I appreciate any counsel!
Previous Topic:StackOverflowError with EContentAdapter
Next Topic:[CDO/Hibernate] Count all objects in a resource
Goto Forum:
  


Current Time: Sat Jul 12 22:07:53 EDT 2025

Powered by FUDForum. Page generated in 0.04489 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top