The Bathyscaphe logo, a line drawing of
bathyscaphe Trieste
by Mike Nakis, based on art found at
bertrandpiccard.com
|
Abstract
This article introduces Bathyscaphe, an open-source java library that you can use to assert that your objects are immutable and/or thread-safe.
The problem
Programmers all over the world are embracing immutability more and more; however, mutation is still a thing, and in all likelihood will continue being a thing for as long as there will be programmers. In a world where both mutable and immutable objects exist side by side, there is often a need to ascertain that an object is of the immutable variety before proceeding to use it for certain purposes. For example, when an object is used as a key in a hash map, it better be immutable, or else the hash code of the key may change, causing the map to severely malfunction.