I've attached an example program to show the necessity of the SwingUtilities.invokeLater I added in the patch. Build with "ant" (needs JarBundler in the classpath), then run test.sh to test the program 100 times. With the invokeLater, it works every time for me. Then change "works()" in the main method to "fails()" and try again (only change is that there is no invokeLater). This time, the program fails (should pop up a message box) about 1 of every 5 trials. I think this must be an undocumented "feature" of Apple's version of Java - I'm using Java for Mac OS X 10.6 Update 3.
You can try adding delays or opening a JFrame before adding the application listener (like jEdit actually does). Some changes can make the problem less frequent, but the only one that seems to always work is to use invokeLater.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I realized that I never uploaded the example program, so I've done so now. I can also verify that the issue is still present in the latest Java update for OSX 10.6. I've posted about the issue on Apple's java-dev mailing list and a member of Apple's java team confirmed that this is not the expected behavior and seemed to be a JVM bug: http://lists.apple.com/archives/java-dev/2011/Feb/msg00096.html.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've attached an example program to show the necessity of the SwingUtilities.invokeLater I added in the patch. Build with "ant" (needs JarBundler in the classpath), then run test.sh to test the program 100 times. With the invokeLater, it works every time for me. Then change "works()" in the main method to "fails()" and try again (only change is that there is no invokeLater). This time, the program fails (should pop up a message box) about 1 of every 5 trials. I think this must be an undocumented "feature" of Apple's version of Java - I'm using Java for Mac OS X 10.6 Update 3.
You can try adding delays or opening a JFrame before adding the application listener (like jEdit actually does). Some changes can make the problem less frequent, but the only one that seems to always work is to use invokeLater.
Example program demonstrating JVM bug
I realized that I never uploaded the example program, so I've done so now. I can also verify that the issue is still present in the latest Java update for OSX 10.6. I've posted about the issue on Apple's java-dev mailing list and a member of Apple's java team confirmed that this is not the expected behavior and seemed to be a JVM bug: http://lists.apple.com/archives/java-dev/2011/Feb/msg00096.html.
applied in rev: 19932
The entry has been pending for 14 days or more and is being closed now.
The procedure is described in wiki:
https://sourceforge.net/apps/mediawiki/jedit/index.php?title=Bug_tracker_details#Pending