Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium

New issue 288 by [email protected]: Generated java hashcode() function inconsistent across JVMs.
http://code.google.com/p/protobuf/issues/detail?id=288

What steps will reproduce the problem?
1. Write program that serializes a single String into a simple one-field protobuf with java_generate_equals_and_hashcode enabled.
2.  Run it, construct one, print myMsg.hashcode().
3.  Do it again.  Note difference.

Looking at the generated hashcode() function, I found the issue. The hashcode incorporates getDescriptorForType().hashCode();. This returns an instance of com.google.protobuf.Descriptors.Descriptor, which inherits hashcode() from object.

This violates the contract with equals(). You can probably just remove that line and get the correct behavior, unless it's there for a reason that I don't understand. (I suppose you could also add the == constraint to equals and satisfy the contract but that helps nobody).


--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to