Chris Laffra <###@###.###>
Wants base class constructor to call base class versions of overridden methods.
In the example below, the desired call sequence is:
SuperClass::constructor(),
SuperClass::init()
DerivedClass::constructor()
DerivedClass::init().
Steps to reproduce:
Compile and run attached code
class SuperClass
{
SuperClass()
{
System.out.println("In SuperClass constructor");
this.init();
}
void init()
{
System.out.println("In SuperClass::init()");
}
void fn2()
{
System.out.println("In SuperClass::fn2()");
init();
}
};
class DerivedClass extends SuperClass
{
DerivedClass()
{
System.out.println("In DerivedClass constructor");
init();
}
void init()
{
System.out.println("In DerivedClass::init()");
}
};
public class bug3517
{
public static void main(String argv[])
{
SuperClass sc = new DerivedClass();
sc.fn2();
}
}
/* ***** Output *****
In SuperClass constructor
In DerivedClass::init()
In DerivedClass constructor
In DerivedClass::init()
In SuperClass::fn2()
In DerivedClass::init()
*/
Wants base class constructor to call base class versions of overridden methods.
In the example below, the desired call sequence is:
SuperClass::constructor(),
SuperClass::init()
DerivedClass::constructor()
DerivedClass::init().
Steps to reproduce:
Compile and run attached code
class SuperClass
{
SuperClass()
{
System.out.println("In SuperClass constructor");
this.init();
}
void init()
{
System.out.println("In SuperClass::init()");
}
void fn2()
{
System.out.println("In SuperClass::fn2()");
init();
}
};
class DerivedClass extends SuperClass
{
DerivedClass()
{
System.out.println("In DerivedClass constructor");
init();
}
void init()
{
System.out.println("In DerivedClass::init()");
}
};
public class bug3517
{
public static void main(String argv[])
{
SuperClass sc = new DerivedClass();
sc.fn2();
}
}
/* ***** Output *****
In SuperClass constructor
In DerivedClass::init()
In DerivedClass constructor
In DerivedClass::init()
In SuperClass::fn2()
In DerivedClass::init()
*/