title: Java generics: Illegal forward reference
body: <p>Given a generic interface</p>
  
  <pre><code>interface Foo&lt;A, B&gt; { }
  </code></pre>
  
  <p>I want to write an implementation that requires A to be a subclass of B. So I want to do</p>
  
  <pre><code>class Bar&lt;A, B super A&gt; implements Foo&lt;A, B&gt; { }
  // --&gt; Syntax error
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class Bar&lt;A extends B, B&gt; implements Foo&lt;A, B&gt; { }
  // --&gt; illegal forward reference
  </code></pre>
  
  <p>But the only solution that seems to work is this:</p>
  
  <pre><code>class Bar&lt;B, A extends B&gt; implements Foo&lt;A, B&gt; { }
  </code></pre>
  
  <p>which is kind of ugly, because it reverses the order of the generic parameters.<br>
  Are there any solutions or workarounds to this problem?</p>