Closed Piasy closed 9 years ago
That's a very bad idea. If you supply a mutable ArrayList and I make a defensive copy using an ImmutableLinkedList I destroy all your performance assumptions.
No defensive copies under the hood. If you want immutable collections then supply immutable collections. You can do the defensive copy in the factory method.
Sorry for my lack of deep thought...
Otherwise, the so called 'immutable' object is actually mutable.
Such as the object contains a List, it can modify the items in the List by both using the reference used to build the object, and using the reference get from the accessor.