Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The major problem you have got here is, there is no class literal for concrete parameterized type. And that makes sense, since parameterized types don't have any runtime type information. So, you can only have class literal with raw types, in this case <code>Generic.class</code>.</p> <p><strong>Reference:</strong> </p> <ul> <li><a href="http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html" rel="nofollow">Java Generics FAQs</a> <ul> <li><a href="http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#Why%20is%20there%20no%20class%20literal%20for%20the%20concrete%20instantiation%20of%20a%20parameterized%20type?" rel="nofollow">Why is there no class literal for concrete parameterized types? </a>:</li> </ul></li> </ul> <p>Well, that's fine, but <code>Generic.class</code> gives you a <code>Class&lt;Generic&gt;</code> which is not compatible with <code>Class&lt;Generic&lt;T&gt;&gt;</code>. A workaround is to find a way to convert it to <code>Class&lt;Generic&lt;T&gt;&gt;</code>, but that too you can't do directly. You would have to add an intermediate cast to <code>Class&lt;?&gt;</code>, which represents the family of all the instantiation of <code>Class</code>. And then downcast to <code>Class&lt;Generic&lt;T&gt;&gt;</code>, which will remove the compiler error, though you will an unchecked cast warning. You can annotate the constructor with <code>@SuppressWarnings("unchecked")</code> to remove the warning.</p> <pre><code>class Generic&lt;T&gt; extends Abstract&lt;Generic&lt;T&gt;&gt; { public Generic() { super((Class&lt;Generic&lt;T&gt;&gt;)(Class&lt;?&gt;)Generic.class); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload