title: Instance of an interface without an implementation class
body: <p>I have a JET Template that is meant to generate code for an interface implementation class. I am having trouble coming up with an executable test class that prints out this generated code because I am unable to get an object for the argument of the <code>generate</code> method created from the JET Template.</p>
  
  <p>I want the test class to work something like this:</p>
  
  <pre><code>/**
   * An executable test class that prints out exemplary generator output
   * and demonstrates that the JET template does what it should.
   */
  public class TestClass {
      public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
  
          String className = "A"; // "A" is the name of the interface in the same package.
  
          Class c = Class.forName(className);
          Object o = c.newInstance();
  
          Q2Generator g = new Q2Generator(); // Class created from the JET Template
          String result = g.generate(o);
          System.out.println(result);
      }
  }
  </code></pre>
  
  <p>But obviously, <code>c.newInstance();</code> doesn't work for an interface. Is there another way I could possibly feed an object of the interface through to the <code>generate</code> method? I need the object of the interface because in the Q2Generator's <code>generate</code> method, it takes information about the method declarations in the interface from the object argument.</p>
  
  <p>I'm not sure if that provides enough context, but if it isn't enough there are more details in another question I asked here: <a href="https://stackoverflow.com/questions/7762304/using-jet-to-generate-code-indenting-code">Using JET to generate code: Indenting code</a></p>
  
  <p>Thanks.</p>