Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecoreutil.copier(Resulting hashcodes of the copied EObject is different from original EObject)
Ecoreutil.copier [message #1786825] Sun, 13 May 2018 14:33 Go to next message
Manoj Keshavaprakash is currently offline Manoj KeshavaprakashFriend
Messages: 4
Registered: October 2017
Junior Member

I am using ECoreUtil.copier to create a copy of my EObject. However, the exact copy is created but with different hashcodes. Could anyone explain me why does the hashcodes change.

Re: Ecoreutil.copier [message #1786827 is a reply to message #1786825] Sun, 13 May 2018 16:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30450
Registered: July 2009
Senior Member
This is a basic Java question. Every Java Object has a hashCode. Unless there is an override of java.lang.Object.hashCode(), it will be the default Java implementation which is an arbitrary int value that is typically (but of course not always) different for two different instances. (And you should never override equals or hashCode for an EObject implementation as documented in the Javadoc for that interface.)
Re: Ecoreutil.copier [message #1786830 is a reply to message #1786827] Sun, 13 May 2018 16:07 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6457
Registered: July 2009
Senior Member

For many/most objects the hashcode is computed from the memory address which will vary for a copy.


Ed Willink
Previous Topic:Unexpected results with EObject::eGet(..)
Next Topic:Validation on doSave()
Goto Forum:

Current Time: Wed Sep 18 13:22:10 GMT 2019

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

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

Back to the top