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 07:37 Go to next message
John Cole is currently offline John Cole
Messages: 26
Registered: June 2013
Junior 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 09:13 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4003
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 Jul 24 11:31:26 EDT 2014

Powered by FUDForum. Page generated in 0.01453 seconds