Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] AspectJ for Swing Thread Confinement

Hello,

I am attempting to use AspectJ to detect EDT thread violations in my Swing project. I am referencing the implementation of EdtRuleChecker that Alexander Potochkin posted in his blog, here: http://weblogs.java.net/blog/alexfromsun/archive/2006/02/debugging_swing.html

The idea is straightforward. Before any call to any method on any Swing object, check to see if the calling thread is the EDT. If not, then write an error. While the posted aspect is good, it is also incomplete in that it fails to check any object which is not derived from JComponent. So I've been adding to the list of classes that are checked by the aspect, and I've run into two problems.

1) There are several interfaces defined in Swing (ButtonModel, ListModel). When I attempt to change the aspect to include the constructor of any class which implements these interfaces, I receive the following compiler warning... EdtRuleChecker.aj:172::0 advice defined in com.openfox.messenger.EdtRuleChecker has not been applied [Xlint:adviceDidNotMatch]

The aspect code which generates this warning is...
   //calls of any ButtonModel constructor, including subclasses
   before(): call(ButtonModel+.new(..)) {
     if (isStressChecking && !SwingUtilities.isEventDispatchThread()) {
         System.err.println(thisJoinPoint.getSourceLocation());
         System.err.println(thisJoinPoint.getSignature() +
                               " *constructor*");
         System.err.println();
     }
   }

So, is there a different way to insert code when the constructor of any class which implements the ButtonModel interface is called?

2) There are several static methods which should only be called from the EDT. For example, the static methods of the BorderFactory class. How can I catch static method calls of a specific class?


Thanks,
-Ryan




Back to the top