Suppose I have a class which I have made immutable by following the steps below only.
- Mark class as final which has two fields one is String and other is List type.
- mark fields as private but NOT final.
- Creating a new ArrayList in constructor by the parameter passed and assign to the private List field.
- Make the getter of the List field return a Deep Copy always.
- Returning the String field by simply "return name".
As per my understanding I have made this class Immutable and its instances cannot be changed.
But what could still be the loopholes, security issues and ways where the immutability of this class can be broken/compromised/violated.