Java generics to enforce return type of abstract method
<p>I have the following situation :</p>

<pre><code>abstract class X { abstract X someMethod (...) {...} }.
</code></pre>

<p>Now I want to constrain any implementation of X to have its 'someMethod' method return that particular implementation type, not just X :</p>

<pre><code>class X1 extends X { X1 someMethod (...) {...} }.
class X1 extends X { X someMethod (...) {...} }.  //want this to be flagged as an error
class X2 extends X { X1 someMethod (...) {...} }.  //want this to be flagged as an error too
</code></pre>

<p>Is it possible to achieve this using Java generics ?</p>

<p>EDIT</p>

<p>Okay.  I only asked the yes/no question and got a "yes".  My fault.  What I was actually interested in is "how do I write the declarations".</p>
