Why is Collection<String>.class Illegal?
<p>I am puzzled by generics. You can declare a field like:</p>

<pre><code>Class&lt;Collection&lt;String&gt;&gt; clazz = ...
</code></pre>

<p>It seems logical that you could assign this field with:</p>

<pre><code>Class&lt;Collection&lt;String&gt;&gt; clazz = Collection&lt;String&gt;.class;
</code></pre>

<p>However, this generates an error:</p>

<pre><code>  Syntax error on token "&gt;", void expected after this token
</code></pre>

<p>So it looks like the .class operator does not work with generics. So I tried:</p>

<pre><code>  class A&lt;S&gt; {}
  class B extends A&lt;String&gt; {}
  Class&lt;A&lt;String&gt;&gt; c = B.class;
</code></pre>

<p>Also does not work, generates:</p>

<pre><code>  Type mismatch: cannot convert from Class&lt;Test.StringCollection&gt; 
  to Class&lt;Collection&lt;String&gt;&gt;
</code></pre>

<p>Now, I really fail to see why this should not work. I know generic types are not reified but in both cases it seems to be fully type safe without having access to runtime generic types. Anybody an idea?</p>

<p>Peter Kriens</p>
