Skip to main content


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 ColeFriend
Messages: 66
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 WillinkFriend
Messages: 7655
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 Apr 25 21:11:35 GMT 2024

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

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

Back to the top