Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328670 - Comply with EMF contract in equals/hashCode implementations
Summary: Comply with EMF contract in equals/hashCode implementations
Status: CLOSED FIXED
Alias: None
Product: STEM
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.1.2   Edit
Assignee: Matthew Davis CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-25 23:59 EDT by Tero Parviainen CLA
Modified: 2012-01-20 19:38 EST (History)
2 users (show)

See Also:


Attachments
Patch against trunk, r1115 (18.71 KB, patch)
2010-10-25 23:59 EDT, Tero Parviainen CLA
sedlund: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tero Parviainen CLA 2010-10-25 23:59:39 EDT
Created attachment 181690 [details]
Patch against trunk, r1115

In EMF, equals and hashCode need to be implemented with object identity semantics (as per http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg05253.html).
If we in the future decide to enable CDO, this rule is actually enforced, as CDOObjectImpl declares these methods as final.

The attached patch changes the implementation of the three models that don't currently comply with this rule: STEMTime, DoubleValue, and StringValue. Instead of implementing equals, these classes now have a method called "valueEquals" which checks equality based on value. The hashCode method is removed.

All places where equality checks are done for these classes need to be updated. The patch does this for all instances I was able to find. I'm not 100% this covers all of them, though, and I hope someone with a deeper understanding of the codebase will double-check this.

The patch also introduces final implementations of equals and hashCode in IdentifiableImpl, so that this rule will be enforced in all models that derive from it.
Comment 1 Matthew Davis CLA 2010-10-26 18:26:55 EDT
Thanks Tero for the patch.  Assigning to myself to evaluate for inclusion.
Comment 2 Matthew Davis CLA 2010-10-26 18:27:07 EDT
forgot to move to assigned.
Comment 3 Matthew Davis CLA 2010-10-29 16:53:16 EDT
Thanks again, Tero, for the contribution.

I have reviewed the patch and can confirm that it complies with Eclipse conventions and does not contain any items (cryptography) that require additional approvals.

Tero, please confirm again:
1) The code contributed was authored by you alone
2) That you have permission to submit this code to Eclipse (we have your contribution form on record, this is just a confirmation).
Comment 4 Tero Parviainen CLA 2010-10-30 04:22:45 EDT
(In reply to comment #3)
> Tero, please confirm again:
> 1) The code contributed was authored by you alone
> 2) That you have permission to submit this code to Eclipse (we have your
> contribution form on record, this is just a confirmation).

I confirm both points.
Comment 5 Matthew Davis CLA 2010-11-01 13:41:35 EDT
Patch applied and committed to trunk for revision 1122.

Affected projects:
org.eclipse.stem.core
org.eclipse.stem.tests.core

Thank you again, Tero.
Comment 6 James Kaufman CLA 2011-07-18 21:43:06 EDT
Complete