Monday, November 22, 2010

Java: Binary Compatibility - more than meets the eye


You were a fool, Joseph Curwen, to fancy that a mere visual identity would be enough. Why didn't you think of the speech and the voice and the handwriting? It hasn't worked, you see, after all.


- "The Case of Charles Dexter Ward", H.P. Lovecraft

Just a quick entry before Thanksgiving, this time concerning binary compatibility for Java.

Most of the time when a method is altered it's easy to spot when a change is not backward compatible with the prior version. After all, if the prior method took a String as its argument and now takes List<String> instead, clearly any client code calling the method will need to be updated. But what happens when you loosen the restrictions, for instance you originally required a HashMap and you want to change the method to require just a Map interface? If you've not encountered this situation before, you may find the answer suprising: your client's code will not run unless they first recompile with your updated code.