Dynamic instance creation without generics
<p>I would like to understand why the following doesn't work:</p>

<pre><code>public class HelloClass {

    private class MyClass
    {
        public MyClass() 
        {
           System.out.println ("Oh heck this is me!");   
        }
    }

    public Object newInstance (Object o)
    {
        try {
            // java.lang.InstantiationException here
            return o.getClass().newInstance();        
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return null;
        }
    }

    public void run()
    {
        MyClass m = new MyClass();  
        Object o = newInstance(m);
    }

    public static void main(String[] args) 
    {
        HelloClass hd = new HelloClass();
        hd.run();
    }
}
</code></pre>

<p>I know of the correct way to achieve this via declaring the newInstance argument as Class&lt;T&gt;, but would like to understand why it cannot be done like the above.</p>

<p>UPD: Here is the exception I'm getting:</p>

<pre><code>java.lang.InstantiationException: HelloClass$MyClass
    at java.lang.Class.newInstance0(Class.java:340)
    at java.lang.Class.newInstance(Class.java:308)
    at HelloClass.newInstance(HelloClass.java:14)
    at HelloClass.run(HelloClass.java:24)
    at HelloClass.main(HelloClass.java:30)
</code></pre>
