title: Warning for generic varargs
body: <p>I have declared the following method:</p>
  
  <pre><code>private void mockInvokeDBHandler(Map&lt;String, Object&gt;... rows) {
      List&lt;Map&lt;String, Object&gt;&gt; allRows = Arrays.asList(rows));
      // rest of method omitted
  }
  </code></pre>
  
  <p>It is invoked by clients using something like</p>
  
  <pre><code>Map&lt;String, Object&gt; row1 = new HashMap&lt;String, Object&gt;();
  Map&lt;String, Object&gt; row2 = new HashMap&lt;String, Object&gt;();
  
  mockInvokeDBHandler(row1, row2);
  </code></pre>
  
  <p>However, the last line shown above generates a warning</p>
  
  <blockquote>
    <p>Type safety : A generic array of Map is created for a varargs parameter</p>
  </blockquote>
  
  <p>I don't fully understand this, but I guess it's because varargs params are converted to arrays, and it's a bad idea to have an array whose type is a generic class (because generics are invariant, whereas arrays aren't).</p>
  
  <p>I could resolve this problem by redifining the method as </p>
  
  <pre><code>private void mockInvokeDBHandler(List&lt;Map&lt;String, Object&gt;&gt; rows) {
  }
  </code></pre>
  
  <p>But this places the burden of putting the row objects into a List on the client, which I'd rather avoid. Is there a better solution?</p>