Delete comment from: Stephen Colebourne's blog
On immutable, a simpler approach is to use a marker interface. This makes it possible to identify an immutable object using existing Java syntax. As for performance gains, a compiler could already recognise a class that had no mutators and was thus immutable. However, another property often suggested in conjunction with immutability is value semantics --- where == maps to equals(). This does allow efficiency gains at least for small objects. In particular arrays can just contain the values instead of references to objects. This saves a reference and an object header for every entry.
Oct 8, 2007, 3:13:25 PM
Posted to JSR-310 and Java 7 language changes