title: create a list of generic classes
body: <p>I have a utility method that creates a one-element list out of some object:</p>
  
  <pre><code>public static final &lt;T&gt; List&lt;T&gt; list(T t) {
      final List&lt;T&gt; rv = new ArrayList&lt;&gt;();
      rv.add(t);
      return rv;
  }
  </code></pre>
  
  <p>I also have a method that accepts an argument of type <code>List&lt;Class&lt;?&gt;&gt;</code>. So I have to create an object of that type. Here's what I try to do:</p>
  
  <pre><code>final Class&lt;?&gt; aClass = Integer.class;
  final List&lt;Class&lt;?&gt;&gt; trivialListOfClasses = list(aClass);
  </code></pre>
  
  <p>&hellip; this fails with:</p>
  
  <pre><code>[javac] /some/path/Foo.java:41: error: incompatible types
  [javac]             final List&lt;Class&lt;?&gt;&gt; trivialListOfClasses = list(aClass);
  [javac]                                                                  ^
  [javac]   required: List&lt;Class&lt;?&gt;&gt;
  [javac]   found:    List&lt;Class&lt;CAP#1&gt;&gt;
  [javac]   where CAP#1 is a fresh type-variable:
  [javac]     CAP#1 extends Object from capture of ?
  [javac] 1 error
  </code></pre>
  
  <p>What's the proper way to accomplish the above? I understand the part about Java generics being invariant but what exactly is going on here?</p>