This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 247987 - Initialized Class Variables Stop NetBeans Debugger from Stepping Into Explicit super() Call
Summary: Initialized Class Variables Stop NetBeans Debugger from Stepping Into Explici...
Status: RESOLVED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.0
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-16 20:01 UTC by stevensrmiller
Modified: 2014-11-08 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stevensrmiller 2014-10-16 20:01:20 UTC
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;
    
    public SuperClass()
    {
        y = x;
    }
}

public class SubClass extends SuperClass
{
    protected double mine = 3.14159;
    
    public SubClass()
    {
        super();
        
        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.
Comment 1 Martin Entlicher 2014-11-05 12:11:20 UTC
Reproduced.

This is some strange bug of Step Into (F7). As a workaround, please use Step Into Next Method (Shift-F7).
Comment 2 stevensrmiller 2014-11-05 14:30:30 UTC
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.)
Comment 3 Martin Entlicher 2014-11-07 21:16:42 UTC
Fixed by changeset:   280903:3895fd936dbb
http://hg.netbeans.org/core-main/rev/3895fd936dbb
Comment 4 Quality Engineering 2014-11-08 10:59:12 UTC
Integrated into 'main-silver', will be available in build *201411080653* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3895fd936dbb
User: mentlicher@netbeans.org
Log: #247987: Consider indexes that are not on lines lower than startLine.