Reflection does not return a correct instance
<p>I have wired experience with reflections. At first some sample code:</p>

<pre><code>public abstract class A {

    public A () {
        init();
    }

    public abstract void init ();
}


public class B extends A {

    private int i = 0;

    public B () {
        super();
        System.out.println(i);
    }

    public void init () {
        i = 1;
    }
}
</code></pre>

<p>Somewhere in my code I use the reflection api to instantiate an object B.</p>

<pre><code>Class&lt;AbstractSection&gt; bc = (Class&lt;AbstractSection&gt;) Class.forName(B);
Constructor&lt;?&gt; bcon = bc.getConstructor();
B b = (B) bcon.newInstance();
</code></pre>

<p>What I expected was an instance of B with the variable i set to value '1'. What I got is an instance of B with i still set to '0'.
With a closer look with a debugger I saw that this is not exactly correct: i is NOT still set to '0'. It is changed to '1' in
the init() method and set back to '0' in the very moment when the super() call returns.</p>

<p>Anyone a clue? Thanks in advance,</p>

<p>manuel</p>

<p>PS: I know I can solve this by calling init() not in the super class but in the inheriting constructor.</p>
