I am not sure if this is Java behaviour or rogue GWT behaviour. But here goes.
I have a class for 2D vectors, called Vector2. In my program I do some simulation of 2D particles represented by instances of this class. I have two arrays of Vector2, m_x and m_oldx that are members of another class, with a function that does some processing. Part of this function is the following, and I'm awfully confused by its behaviour:
Vector2 old = m_x[i];
Vector2 test = new Vector2(9.0f,9.0f);
m_x[i] = test;
// 1: at this point, m_x[i]'s values are 9.0,9.0
m_oldx[i] = old;
// 2: at this point, m_x[i]'s values are 100.0,100.0 - their original values before I assigned test to m_x[i]!
So basically, it appears that by virtue of the fact that I assign old to the m_oldx array, m_x[i]'s value gets reset to its original value! It's no longer equal to the test variable I assigned to it earlier.
Surely that can't be right? But this is what's happening for me. I should say again that I am using GWT here - i.e. this code gets compiled down to Javascript by Google's compiler. Is this regular java behaviour or is GWT doing something wrong? Thanks for any help...tearing my hair out :(