title: Java Generics Hell
body: <p>I suspect this has been asked here (and answered) before, but I don't know how to name the problem.  Why can I express the wildcards without problem only when I'm not passing the class itself?  </p>
  
  <p>It all boils down to this code.  Everything works as expected except for the call to <code>genericsHell(ShapeSaver.class)</code>:</p>
  
  <pre><code>interface Shape { }
  
  interface Circle extends Shape { }
  
  interface ShapeProcessor&lt;T extends Shape&gt; { }
  
  class CircleDrawer implements ShapeProcessor&lt;Circle&gt; { } 
  
  class ShapeSaver&lt;T extends Shape&gt; implements ShapeProcessor&lt;T&gt; { }
  
  class Test {
      void genericsHeaven(ShapeProcessor&lt;? extends Shape&gt; a) {}
  
      void genericsHell(Class&lt;? extends ShapeProcessor&lt;? extends Shape&gt;&gt; a) {}
  
      void test() {
          genericsHeaven(new CircleDrawer());
          genericsHeaven(new ShapeSaver&lt;Circle&gt;());
          genericsHell(CircleDrawer.class);
          genericsHell(ShapeSaver.class); // ERROR: The method genericsHell is not applicable for the arguments (Class&lt;ShapeSaver&gt;)
      }
  }
  </code></pre>