I'm working on a program that relies on objects being unique. I work with the same object in 2 places, and when an update is done in one place, this should be reflected in the other.
If I debug the program (in eclipse), everything works. My 2 object references both point at the same object (ojbect1==object2
returns true
). If I run exactly the same program (in eclipse), there are different objects in both references (same comparison shows false
).
This object is instantiated multiple times, but one of those instances is saved in a TreeMap and picked up later. However, when I pick it up, sometimes (as described above) it's a different object, which does not hold any changes made to the original object in the meantime.
Does anybody have an idea why this is?
I cannot replicate the problem in a smaller scope so unfortunately I can't post code here.