title: Self bound generic type with fluent interface and inheritance
body: <p>I am using a fluent interface with inheritance. I declared the base class Constructor protected so you cant create a Foo&lt;Bar&gt; which would result in a ClassCastException on calling add(). But i am having trouble with the static method that returns a new Foo instance.</p>
  
  <pre><code>public class Foo&lt;T extends Foo&lt;T&gt;&gt; // if i change to extends Foo i only get warnings
  {
          public static Foo&lt;Foo&gt; createFoo() // &lt;-- error
          {
                  return new Foo&lt;Foo&gt;(); // &lt;-- error
          }
  
          protected Foo() {}
  
          public T add()
          {
                  //...
                  return (T)this;
          }
  }
  
  public class Bar extends Foo&lt;Bar&gt;
  {
          public Bar sub()
          {
                  //...
                  return this;
          }
  }
  </code></pre>
  
  <p>This is mostly an excercise(personal not homework) in Fluent Interfaces, Domain-specific language and Generics, so please dont ask what i need it for.</p>
  
  <p>Edit: Eclipse error</p>
  
  <pre><code>Bound mismatch: The type Foo is not a valid substitute for the bounded parameter &lt;T extends Foo&lt;T&gt;&gt; of the type Foo&lt;T&gt;
  </code></pre>