I am reading \"Effective Java\" by Joshua Bloch, item 39 make defensive copy, and I have some questions. I always use the following construct:
MyObject.getSo
call getSomeRef() two times and compare there reference if they are different then function is returning the copy else it is returning the same instance.
if(MyObject.getSomeRef() == MyObject.getSomeRef()){ // same instance }else{ // copied instance }