Thursday, April 23, 2009

Beware of your IDE code generation!

I just came up against one of the most frustrating bugs this week.
One of the config panels in my Swing application just stopped showing it's contents on my Linux development machine. It displayed the border, but no contents.
As usual, "I have changed nothing" (TM), and the code works perfectly on other machines.

The only change I did recently was upgrading the JVM from 1.6.11 to (64bit) 1.6.13 (to solve a SIGSEGV during JUnit tests run from Eclipse).

Thanks to ad-hoc pair programming session we discovered the cause quite quickly: for no logical reason the panel overrides the isValid() method to return true.
This (apparently) causes the panel not to display it's content on this particular version of Java.

The only reason I can think of why this code was here is accidentally pressing Ctrl-O or what was the shortcut for "override a method" ;-)

Lessons learned:
- get rid of suspicious code when you spot one (or make it clear why it is there)
- get someone to have a look at a problem with you - I would probably spend hours if I tried to solve it myself

No comments:

Post a Comment