-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
-
b26
The hashCode() doesn't depend on the relative order of the bytes in the underlying array.
Cache.EqualByteArray a1 = new Cache.EqualByteArray(new byte[] {1,2,3});
Cache.EqualByteArray a2 = new Cache.EqualByteArray(new byte[] {2,3,1});
Cache.EqualByteArray a3 = new Cache.EqualByteArray(new byte[] {3,1,2});
System.out.println(a1.hashCode());
System.out.println(a2.hashCode());
System.out.println(a3.hashCode());
Prints
226
226
226
It may be better to use Arrays.hashCode(byte[]).
Cache.EqualByteArray a1 = new Cache.EqualByteArray(new byte[] {1,2,3});
Cache.EqualByteArray a2 = new Cache.EqualByteArray(new byte[] {2,3,1});
Cache.EqualByteArray a3 = new Cache.EqualByteArray(new byte[] {3,1,2});
System.out.println(a1.hashCode());
System.out.println(a2.hashCode());
System.out.println(a3.hashCode());
Prints
226
226
226
It may be better to use Arrays.hashCode(byte[]).
- links to