title: (Java reference situation) Should iI do what findbugs tools tells me to?
body: <p>I ran Findbug tool on my project and it found 18 problems of the type: </p>
  
  <p><strong>Storing reference to mutable object</strong> -> <strong>May expose internal representation by incorporating reference to mutable object</strong></p>
  
  <p>So I have a class which the constructor accepts array of type Object and assigns it to a private class member variable. Here is an example:</p>
  
  <pre><code>public Class HtmlCellsProcessing extends HtmlTableProcessing
  {
      private Object[] htmlCells;
  
      public HtmlCellsProcessing(Object[] htmlCells)
      {
          this.htmlCells = htmlCells;
      }
  }
  </code></pre>
  
  <p>Here is a further explanation about the warning:</p>
  
  <p><em>This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.</em></p>
  
  <p>The advice they give me is pretty obvious but what happens if the array's size is very big and if I copy its values into the member variable array the application is going to take twice more memory.</p>
  
  <p>What should I do in such a scenario where I have large amount of data? Should I pass it as reference or always copy it?</p>