Think about Java constructor
<p>In this example:</p>

<pre><code>class A {
    public A() {
        // pre-init1
        // post-init1
    }
}

class B extends A {
    public B() {
        super();
        // init2
    }
}
</code></pre>

<p>I want to let init2 before init1, cuz super() must be occurred at the very beginning, so the only way is to add another init method:</p>

<pre><code>class A {
    public A() {
        init();
    }

    protected void init() {
        // pre-init1
        // post-init1
    }
}

class B extends A {
    public B() {
        super();
    }

    protected void init() {
        // init2
        super.init();
    }
}
</code></pre>

<p>Can I get rid of init() method? </p>

<p><strike>Or, I have to make final fields non-final.</strike> 
Or, is there any way to let A do post-init1 after init2, but not introduce init() method?</p>

<p><em>EDIT</em></p>

<p>Here the code from practice, well I think I need this special init() for the special case,</p>

<p>This is a base support class for Spring JUnit test, for some reasons I can't use the SpringJUnit4Runner from spring-test, so I created my own,</p>

<pre><code>// wire the bean on demand.
public static &lt;T&gt; T selfWire(T bean) {
    if (bean == null)
        throw new NullPointerException("bean");

    ApplicationContext context = buildAnnotationDescribedContext(bean.getClass());
    AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
    beanFactory.autowireBean(bean);

    if (bean instanceof ApplicationContextAware) {
        ((ApplicationContextAware) bean).setApplicationContext(context);
    }
    if (bean instanceof InitializingBean) {
        try {
            ((InitializingBean) bean).afterPropertiesSet();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException("Failed to initialize bean", e);
        }
    }

    return bean;
}

@Import(TestContext.class)
public abstract class WiredTestCase 
        extends Assert
        implements InitializingBean {

    // ...

    public WiredTestCase() {
        init();
        ApplicationContextBuilder.selfWire(this);
        logger.debug("WiredTestCase wired");
    }

    protected void init() {
    }

    @Overrdie
    public void afterPropertiesSet() {
    }

}

@Import({ TestDaoConfig.class })
public class WiredDaoTestCase
        extends WiredTestCase {

    public WiredDaoTestCase() {
        // init... moved to init()
    }

    protected void init() {
        // Collect entity classes from @Using annotation
        // and config the session factory.
    }

}

@Using(IcsfIdentityUnit.class)
@ImportSamples(R_ACLSamples.class)
public class R_AuthorityTest
        extends WiredDaoTestCase {

    @Inject
    R_Authority authority;

    @Inject
    ScannedResourceRegistry registry;

    @Overrdie
    public void afterPropertiesSet() {
        // Do a lot of reflection discoveries.
        // ...
        super.afterPropertiesSet();
    }

    @Test
    public void testXxx() { ... }

    // ...
}
</code></pre>

<p>The code is very long, but the idea is simple, in <code>R_AuthorityTest</code> there are DAO beans to be injected, which depends on <code>SessionFactory</code>, and the session factory is configured in <code>WiredDaoTestCase</code> which is the base class of <code>R_AuthorityTest</code>. Despite of final fields, I have to initialize the session factory before WiredTestCase(). I can't initialize them just in static constructor, because I build the persistence unit on the fly from annotations on <code>this.getClass()</code>. So, personally, I think sometime it's reasonable to do some pre-init before super constructor, and maybe init method is the only way in this case?</p>
