Hi,
-- I've done a fair amount of searching but not found anything related (so hopefully this is something stupid I'm doing).
I have a class for which I override hashCode() and equals(). The hashCode() method in Java always returns a value Integer.MIN_VALUE<=x<=Integer.MAX_VALUE. Great :)
In SuperDevMode and "production" mode (i.e. fully compiled and running in a J2EE container) the hashCode() method returns values less than MIN_VALUE and greater than MAX_VALUE.
The problem I encounter comes with the comparison of the hashCodes; e.g. hc1==hc2; where the HashCodes have been calculated similar to the following (I've stepped through my actual code in SDM):
HC1
result = 1;
result = 31 * result + (child1.hashCode()); // child1 hashCode is the same as child1 hashCode below
result = 31 * result + (child2.hashCode()); // child2's hashCode == 0
result = 2.3950366067525864e+39
HC2
result = 1;
result = 31 * result + (child1.hashCode()); // child1 hashCode is the same as child1 hashCode above
result = 31 * result + (child2.hashCode()); // child2's hashCode = 100
result = 2.3950366067525864e+39
GWT evaluates the two hashCodes as equal; whereas in reality they are minimally different (but identical at the precision shown).
Can anybody recommend the best practice to generate GWT (JavaScript)-friendly hash codes; or a workaround? (e.g. I notice GWT's AbstractList's hashCode performs "k = ~~ k" to presumably keep the value within limits?).
With kind regards,
Mike
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment