The problem is this: I have an abstract class that does some work in its constructor, and a set of child classes that implement the abstract class:
class Abs
I can think of two cases where one might want to do this (actually not):
Case 1, ConcreteClass2 runs shared initialisation from the top class, but then does its own initialisation sequence, which is different/conflicts than the one in ConcreteClass1 -> have an init () method and override it (instead of attempting to override the ConcreteClass1's constructor).
Case 2, you have polymorphic initialisation of one (or more) class member (this is actually a specific case of the previous one):
public class ConcreteClass1 extend AbstractClass
{
protected F1 f;
public ConcreteClass1 () {
super ();
this.f = new F1();
}
}
public ConcreteClass2 extends ConcreteClass1
{
public ConcreteClass2 () {
super (); // I'd like to do super.super() instead (no, you don't)
this.f = new F2(); // We wasted time with new F1 ();
}
}
In such case, either use the init() approach, or do this:
protected ConcreteClass1 ( F1 f ) {
super ();
this.f = f;
}
public ConcreteClass1 () {
this ( new F1 () );
}
...
public ConcreteClass2 () {
super ( new F2 () );
}
In other words, make the reason for the jump explicit, for implicitly jumping over the hierarchy is forbidden and for the good reasons explained in other answers.