All articles

Java

The language and standard library underneath: collections, hashing and the contracts they rely on.

  1. Why Mutable Objects Break HashSet: A Deep Dive into Java Hashing Internals

    15 min read

    Change one field on an object after putting it in a HashSet and the set can no longer find it, remove it, or stop you adding it twice. This article traces the bug through the real HashMap source: how a bucket is chosen, why every node caches its hash, what the equals/hashCode contracts actually promise, and how to prevent or recover from it.

    • Java
    • HashSet
    • HashMap
    • Data Structures
    • Collections Framework
    • Java Internals
    • Backend Engineering
    • Software Engineering
    • Performance