title: Error when using Reflections in Java
body: <p>I'm having a casting issue in this code but have no idea how to correct it. </p>
  
  <pre><code>public void showFrame(String className, Object controller) throws Exception{
      try {
         Class c = Class.forName("com." + className);
         // "(Object.class)" I want this to be of type held in className var
         // this type will be same as one passed into  "controller" at runtime
         Constructor ctr = c.getConstructor(Object.class);  
         ctr.newInstance(controller);
      } catch (ClassNotFoundException ex) {
          JOptionPane.showMessageDialog(null, "Error" );
      }
  }
  </code></pre>