title: Java 8: create new instance of class with generics using reflection
body: <p>I have the following method:</p>
  
  <pre><code>public Comparator&lt;T&gt; getComparator()  throws ReflectiveOperationException {
      String className = "some.ClassName";
      Class&lt;Comparator&lt;T&gt;&gt; c = Class.forName(className); // (1)
      return (Comparator&lt;T&gt;) c. newInstance();
  }
  </code></pre>
  
  <p>In the line (1) I get this error:</p>
  
  <blockquote>
    <p>Type mismatch: cannot convert from Class &lt;capture#1-of ?&gt; to
    Class&lt;Comparator&lt;T&gt;&gt;</p>
  </blockquote>
  
  <p>What's wrong in this code and how should I make an instance of <code>Comparator&lt;T&gt;</code>?</p>