I am stepping through the construction of a class that extends another class. Both have their own class variables. With no explicit call in the subclass constructor to super(), the NetBeans IDE debugger shows every step as I expect it to. That is, it steps through the superclass initialization of its own class variables, then its constructor code, then the subclass initialization of its class variables, then its constructor code. But, if I add an explicit call to super() in the subclass, the debugger never enters the superclass (unless I add a breakpoint in that class's code, in which case the debugger suspends when it hits that breakpoint). Further confusing things, the debugger does enter the superclass code if I include my explicit call to super(), but remove the subclass's class variables.
This code shows the problem:
public class Main
public static void main(String args)
SubClass sub = new SubClass();
public class SuperClass
private int x = 3;
public int y;
y = x;
public class SubClass extends SuperClass
protected double mine = 3.14159;
this.y = 5;
This code exhibits the behavior I don't understand. If a breakpoint is set at at the first line of the SubClass constructor (the call to super() ), or at any prior point, stepping into each line does not step into the super() call, even though the superclass constructor and initiaization code does get executed. Commenting out the call to super() results in the debugger stepping through the superclass constructor as expected. If, instead of commenting out the call to super(), I comment out the subclass member variable initialization in SubClass, the debugger once again does step through the superclass initialization code.
While the call to super() is actually superfluous, there are several calls to super() in Swing source code, and this problem makes it difficult to step through that code.
This is some strange bug of Step Into (F7). As a workaround, please use Step Into Next Method (Shift-F7).
Great workaround, Martin. Thanks! (I didn't even know that "Step Into Next Method" was available, since there's no GUI for it. Great to learn something new while also getting around this bug. And it does work in the Swing code I was interested in.)
Fixed by changeset: 280903:3895fd936dbb
Integrated into 'main-silver', will be available in build *201411080653* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Log: #247987: Consider indexes that are not on lines lower than startLine.