Just a coincidence, I suspect ... there will inevitably be collisions, in which case it seems that the corresponding different bits in the first value are lost effectively.
However, this should not make any difference - anything that uses hash codes must deal with conflicts.
EDIT: This is just a way to calculate hashes. This code shows what happens:
import java.util.*; public class Test { @SuppressWarnings("unchecked") public static void main (String[] args) { AbstractMap.SimpleEntry[] entries = { new AbstractMap.SimpleEntry("campaignId", 4770L), new AbstractMap.SimpleEntry("campaignId", 4936L), new AbstractMap.SimpleEntry("lazy", true), new AbstractMap.SimpleEntry("lazy", false) }; for (AbstractMap.SimpleEntry entry : entries) { System.out.println(entry + ": " + entry.hashCode()); } } }
Results:
campaignId=4770: -1318251287 campaignId=4936: -1318251261 lazy=true: 3315643 lazy=false: 3315617
So, in one pair the first map has a hash 26 less than the second map, and in the other pair the first map has a hash 26 more than the second map.
AbstractMap simply sums the hash values ββ(one way to make sure the ordering doesn't matter), so both end with the same hash code.
This is valid until Boolean.hashCode() , which looks like this:
return value ? 1231 : 1237;
... and Long.hashCode() , which looks like this:
return (int)(value ^ (value >>> 32));
Given the values ββthey selected in Boolean.hashCode() , if your long values ββare only 26 (or 26 * 2 ^ 32 from each other), you will come across the same thing.