Correct method for instantiating object from String containing class name (with known superclass)
<p>I am trying to create new instances of a class (specifically a subclass of an abstract class) by using the forName(String) method.</p>

<p>For example, if I wanted a subclass of Number:</p>

<pre><code>import static java.lang.Class.forName;
import java.lang.reflect.Constructor;

Object[] arguments = new Object[] {0};
String classname = "java.lang.Integer";
try {
 Class&lt;? extends Number&gt; c = forName(classname).asSubclass(Number.class);
 Constructor&lt;? extends Number&gt; constructor = c.getConstructor(Number.class);
 Number x = constructor.newInstance(arguments);
}
catch (Exception e) {
 e.printStackTrace();
}
</code></pre>

<p>What am I doing wrong?</p>

<p>EDIT: Stacktrace</p>

<pre><code>java.lang.NoSuchMethodException: 
java.lang.Integer.&lt;init&gt;(java.lang.Number)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
</code></pre>
