Thursday, March 05, 2009

Found bug in Sun's Java Swing implementation (?)

Previously, I had noticed a common mistake/bug in the code of the project I was working on at the time.

Today I noticed that same bug in Sun's code.  Its in javax.swing.AbstractAction, line 160 in the version I'm running (1.6 something):

       if (key == "enabled")
From the inline comments in the source, its a hack to synchronize the action's boolean enabled status with putValue("enabled", true/false) which stores the value in a map.

Kudos to Sun for including the source to Java's libraries.