title: In Java, can you use variable arguments without using varargs facility?
body: <p>In Java, I want to create a few geometric shapes based on user input. The trick is that I can't change the existing API, so I can't use varargs syntax like </p>
  
  <pre><code>public Shape(Object... attrs) {}
  </code></pre>
  
  <p>User input:</p>
  
  <pre><code>shape.1.triangle.arg1 = 3
  shape.1.triangle.arg2 = 4
  shape.1.triangle.arg3 = 5
  shape.1.triangle.arg4 = "My first triangle"
  shape.2.rectangle.arg1 = 4
  shape.2.rectangle.arg2 = 7
  shape.2.rectangle.arg3 = "Another string label"
  </code></pre>
  
  <p>Should lead to method invocations like:</p>
  
  <pre><code>Shape s1 = new Triangle(arg1, arg2, arg3, arg4);
  </code></pre>
  
  <p>Or generically to:</p>
  
  <pre><code>String shapeType = "triangle";
  Object[] args = {arg1, arg2, arg3, arg4};
  // This won't work, because newInstance() doesn't take args
  Shape s1 = Class.forName(shapeType).newInstance(args); 
  
  String shapeType = "rectangle";
  Object[] args = {arg1, arg2, arg3};
  // This won't work, because newInstance() doesn't take args
  Shape s2 = Class.forName(shapeType).newInstance(args);
  </code></pre>
  
  <p>The problem is that the constructor for Triangle does not allow varargs (...), and I can't change it. Specifically, the constructors are</p>
  
  <pre><code>public Triangle (int a, int b, int c, String label) {}
  
  public Rectangle (int a, int b, String label) {}
  </code></pre>
  
  <p>So how do I create the right shapes based on user input?</p>