Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're right, not sure what I was thinking there! Your comment inspired me to think about it further and I tested it and the cause of the problem has something to do with the recursive definition of the type variables <code>Job&lt;J extends Job&lt;J...</code>, but I'm not entirely clear why. One solution, remove the 'use' of J and R from your definitions.</p> <p>Longer answer:</p> <pre><code>import java.util.ArrayList; class Job&lt;J extends Job, R extends Run&gt; {} class Run&lt;J extends Job, R extends Run&gt; {} class Job2 extends Job&lt;Job2,Run2&gt; {} class Run2 extends Run&lt;Job2,Run2&gt; {} class RunList&lt;J extends Job, R extends Run&gt; extends ArrayList&lt;R&gt; {} class Foo { // #1 works now public void test1(RunList&lt;Job,Run&gt; why) {} // #2 works now too public void test2(RunList&lt;Job&lt;Job,Run&gt;,Run&lt;Job,Run&gt;&gt; why) {} // #3 still works public void test3(RunList&lt;Job2,Run2&gt; why) {} // #4 generic method public &lt;J extends Job, R extends Run&gt; void test4(RunList&lt;J,R&gt; why) {} public static void main(String[] args) { // Calling them even works... new Foo().test1(new RunList&lt;Job,Run&gt;()); new Foo().test2(new RunList&lt;Job&lt;Job,Run&gt;,Run&lt;Job,Run&gt;&gt;()); // Calling the generic method works too new Foo().test4(new RunList&lt;Job,Run&gt;()); new Foo().test4(new RunList&lt;Job&lt;Job,Run&gt;,Run&lt;Job,Run&gt;&gt;()); new Foo().test4(new RunList&lt;Job2,Run2&gt;()); // ...sort of // This doesn't work //new Foo().test1(new RunList&lt;Job&lt;Job,Run&gt;,Run&lt;Job,Run&gt;&gt;()); // This doesn't work //new Foo().test1(new RunList&lt;Job2,Run2&gt;()); } } </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.
 

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