The singleton design pattern in Java is one that I found over the years to be both tricky and interesting. There are many ways in which this pattern can be broken – this article talks about reflection based attacks.
Preventing this line of attack is easy when your singleton is initialized at class-load time – but what if there's a need for lazy initialization? This write-up explains how to reflection-proof your Java singleton in such situations.
Recent Comments