Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Casting Object to EObject(fails with ClassCastException)
Casting Object to EObject [message #1385106] Wed, 04 June 2014 11:37 Go to next message
John Cole is currently offline John Cole
Messages: 35
Registered: June 2013
Member
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 13:13 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
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: Thu Oct 23 16:35:24 GMT 2014

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

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