Create Class objects based on type signature
<pre><code>Class.forName(boolean.class.getName());
</code></pre>

<p>This doesn't work in Java - the virtual machine slaps you with a ClassNotFoundException. I was in need for something like that because I wanted to reflect methods based on Strings that included the method signatures, like</p>

<pre><code>public void doSomething(boolean yesWeCan, java.lang.String[] presidents);
</code></pre>

<p>At the end I came up with a custom 'ClassFactory' which translates the type Strings to class objects. This factory includes a lot of handlers for primitive and array type values.</p>

<p>The handler for array type objects is something like:</p>

<pre><code>if (isArrayOfObjects) {
   return Class.forName("L["+typeName.replace("[]", "")+";");
}
</code></pre>

<p>My question is - have I missed something in the Java 1.5+ API that might do the trick? </p>

<p><strong>Edit</strong></p>

<p>Thanks for your answers, it's not a surprise that <code>Class.forName</code> works pretty well with the wrapper classes. But I'm looking for a solution for all java types, including arrays and primitives. Thus my first line is not a typo. Some method signatures do have java primitives as parameters, I can't just use a wrapper class to reflect the method in a library, I really need the Class object for that type (like boolean).</p>

<pre><code>Class&lt;boolean&gt; booleanClassObject = boolean.class;
</code></pre>

<p>works fine, as well as</p>

<pre><code>String name = boolean.class.getName();
</code></pre>
