Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for 
change notification.

The "CodeStyle" page has been changed by sebbapache:
https://wiki.apache.org/commons/CodeStyle?action=diff&rev1=13&rev2=14

   1. Mutable data: this increases the difficulty of ensuring thread-safety 
(including safe publication of changes). Data should be confined to a class; 
mutation should only be allowed via a setter which can ensure thread-safety. Be 
careful that the getter does not expose array contents (which are always 
mutable)
   1. Even constants can cause problems: the Java compiler can inline constant 
values from another class. So if the constant should ever change, classes that 
are not recompiled could contain the old value.
   1. Array entries are always mutable. Only empty arrays are immutable; they 
can be safely shared.
+  1. If a reference to a mutable object is exposed via a getter, then it can 
be modified in a way that breaks thread-safety.
+  1. If a mutable object is saved by a setter and the caller keeps a reference 
to the object then it can be changed without using the setter, bypassing any 
restrictions the setter would have enforced.
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to