I recently stumbled upon how useful immutable objects are and that e.g. if you pass elements to a constructor and your class should be immutable, you have to copy these elements if they are not immutable themselves.
This requires a lot of checking or knowledge about my project, because if I have
public A(B foo)
B is not immutable,
A I'd have to copy
B. Now imagine
B seems immutable, but itself has mutable classes in the constructor and so on.
Is there a standard or best-practice for documenting if a class is immutable in Java? It seems there is no
@immutable keyword in Javadoc.
The @Immutable annotation seems to be something totally different for auto class generation and not part of standard Java.