Tuesday, November 13, 2012

Bug: Desktop and IDE freezes when debugging swing project

Desktop and IDE freezes and die when debugging swing project.

IDE: Intellij 11.1.4.
OS:  Redhat Enterprise 6.3.
JRE: Both 1.6 and 1.7.

Reason and solution:

The only reasonable solution to this problem is introducing the system property sun.awt.disablegrab which, if passed as the boolean value of true, effectively disables acquiring grabs on X11 platforms. If the user wishes to debug an application and sets a breakpoint in an event handler that gets fired while a popup window is opened (like a combobox popup), the user must specify this system property before debugging the application as follows:

   java -Dsun.awt.disablegrab=true ...<other_options>...

All known IDEs allow specifying the user-supplied command line options to the java command, making this solution easily adoptable. For instance, in Netbeans open the properties of the project, go to the Run section and type the text "-Dsun.awt.disablegrab=true" (w/o the quotes) into the VM Options editbox. Of course, the project must be configured to run with a JRE having the suggested fix in place.