title: Java: Reference "own type" in interface
body: <p>I'd like to specify in an interface that an implementing method must return a class of its own type.  For example, the clone method:</p>
  
  <pre><code>interface MyArray{
      MyArray clone();
  }
  
  interface MyVector extends MyArray{
      // ... 1d-array specific methods
      MyVector clone();
  }
  
  class MyDoubleVector implements MyVector{
      //...
      @Override
      public MyDoubleVector clone(){
          //...
          return new MyDoubleVector(Arrays.copyOf(data));
      }
  }
  </code></pre>
  
  <p>Now I can call:</p>
  
  <pre><code>MyVector vec1 = new DoubleVector(...);
  MyVector vec2 = vec1.clone();
  </code></pre>
  
  <p>I want to force all implementers of MyArray to have a clone method that returns the same type as the implementer.  I could save a lot of lines if there were some built-in "meta-type" representing "same type as this class/interface" like:</p>
  
  <pre><code>interface MyArray{
      &lt;ArrayOfSameType&gt; clone();
  }
  </code></pre>
  
  <p>And not have to redefine the method in extending interfaces in order call the vec1->vec2 clone operation as shown above.</p>
  
  <p>Does Java have some built-in construct for doing this, or is copying and pasting a ton of boilerplate code just the sad fate of a java programmer?</p>