title: Java: varargs declared constructor
body: <p>I'm trying to use a factory design pattern to instantiate objects. Although, the constructor has a varargs parameter.</p>
  
  <pre><code>public class Foo implements Bar
  
  public Foo(Object... args) {
  }
  </code></pre>
  
  <p>In the factory I'm trying to get the constructor like this:</p>
  
  <pre><code>private Constructor&lt;Bar&gt; getConstructor(Class&lt;Bar&gt; clazz) {
      return clazz.getDeclaredConstructor(Object.class);
  }
  </code></pre>
  
  <p>But it doesn't work. I've also tried:</p>
  
  <pre><code>private Constructor&lt;Bar&gt; getConstructor(Class&lt;Bar&gt; clazz) {
      return clazz.getDeclaredConstructor(Object[].class);
  }
  </code></pre>
  
  <p>But I'll lose the 0 parameter functionality of varargs.</p>
  
  <p>Is there any way to do this?</p>