• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Initialized Class Variables Stop NetBeans Debugger from Stepping Into Explicit super() Call

 
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Here's my code:


This code exhibits the behavior I don't understand. If a breakpoint is set at Line 26 (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() at line 26 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 at Line 22, the debugger once again does step through the superclass initialization code.

Can anyone explain why the presence of the explicit call to super() and the presence of the initialized member variables in the subclass together prevent the NetBeans debugger from descending into the expicit call to super(), while leaving either out results in the debugger stepping through the superclass initialization code (which is what one would expect)?

Note: I expect someone to ask me why I am making a no-argument call to super(), since leaving it out should make no difference to my code (since Java supplies the same call for me). The answer is that I'm not the one making the call, Swing is. In the no-argument constructor for JComboBox, there is a no-argument call to super(), which ought to have the debugger descend into the initialization code for JComboBox's parent class, JComponent. But it doesn't. My sample code, above, demonstrates the same behavior, which I am trying to understand. Thanks.

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. Sorry. But I'll try duplicating this discussion in the IDEs forum.
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. A better place.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Java version is it?
Possibly also what Netbeans version?
Java 1.7 in IntelliJ doesn't show this, and steps into the super() call as expected.
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using NetBeans 8.0, JDK 1.8.0_05.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of which I have neither...sorry.
At least with that info someone else may be able to test it on different IDE's.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please update that JDK8 installation; it is out of date.
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Please update that JDK8 installation; it is out of date.


Done. (Doesn't affect the issue, but done.)
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stevens Miller wrote:I'm using NetBeans 8.0, JDK 1.8.0_05.


I can confirm the behavior. (JDK 1.8.0_20).

Looks like a bug in the debugger. Oh, the irony!
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Looks like a bug in the debugger. Oh, the irony!


Quite. I have filed a report at netbeans.org. It is Bug 247987, if anyone should care to vote.

Parallel question: Why would the JComboBox coder have used an explicit call to super()? Online comments I have found suggest it might be done to call special attention to the importance of a superclass's constructor to a particular subclass's behavior, but a comment would do that just as well (or even better). With further irony, some suggest it is a convenient place for a debugger breakpoint, but one can also just place that at the constructor's entry point. I've seen it discussed that maybe not every language automatically calls a superclass's constructor, but I doubt that ever applied to Java.

Any ideas?
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The good people at netbeans.org have found a workaround: use the "Step Into Next Method" operation, instead of "Step Into." There is no GUI button for that, so I didn't even know it existed. You can find it on the Debug menu, where you can also see that it is assigned to the "Shift F7" accelerator. I've tried it, and it works.

Check the bug report if you want to track this or upvote it.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for sharing the workaround here. That deserves a cow!
 
Stevens Miller
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Thank you for sharing the workaround here. That deserves a cow!


Thanks, Darryl! I'm happy to accept a cow, and will think of it as being earned equally by Martin Entlicher, who discovered the workaround in response to my bug report.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic