Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349207 - [EOL] All empty Sequences have the same extended properties
Summary: [EOL] All empty Sequences have the same extended properties
Status: CLOSED FIXED
Alias: None
Product: Epsilon
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Antonio Garcia-Dominguez CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-13 11:58 EDT by Antonio Garcia-Dominguez CLA
Modified: 2012-02-06 10:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Garcia-Dominguez CLA 2011-06-13 11:58:41 EDT
I have observed that all empty Sequence values seem to share the same set of extended properties. For instance, the following test case fails, as y.~extended seems to have been initialized when "x.~extended = 1" was executed:

@test
operation testExtendedPropertyAssignmentUsesIdentity() {
  var x : Sequence;
  var y : Sequence;
  x.~extended = 1;
  assertEquals(1, x.~extended);
  assertTrue(y.~extended.isUndefined());
}

Looking at the code, it seems that the issue is in EolContext, which uses a HashMap instead of an IdentityHashMap for the mapping from an object to its extended properties. HashMap uses the hashCode() function, which is based on the actual contents. Two empty sequences have the same hashCode(), so they end up sharing the extended properties as well.

I believe this is not the wanted behaviour, as it will likely surprise most users and may be a problem if we have different sequences with different meanings that somehow end up having the same literal elements.
Comment 1 Antonio Garcia-Dominguez CLA 2011-06-13 12:05:20 EDT
I have added the above test to the EOL assignment acceptance test suite, and changed EolContext to use an IdentityHashMap for the extended properties. The required code has been committed to SVN.
Comment 2 Dimitris Kolovos CLA 2011-07-25 08:18:30 EDT
Fixed in 0.9.1