In this paper we compare different approaches to maintain shadow state for heap objects in Java. We identify dynamic analyses that need to shadow heap objects, and we consider their requirements. We describe three very different approaches in detail: using a hash map, heap tagging, and injecting shadow fields.
We discuss the tradeoffs between the different approaches, and we empirically evaluate the viability and performance of the hash map and heap tagging approaches, the two approaches that work on Hotspot, the most prevalent JVM. We find that both approaches work reliably, but that -- with the contemporary JVM implementation of heap tagging -- the simpler hash map approach has far superior performance.