Skip to main content

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

Hi,

1) You might want to try the preinitialization pointcut here
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html

2) Just make sure the static keywird is part of your method signature,  Eg-
pointcut staticCalls() : execution(* static * BorderFactory.*(..));
(not sure if that first * is really necessary, or you may have to
explicitly include a visibility modifier, try it out)

On Sun, Jan 11, 2009 at 11:25 AM, Ryan Sawatzky <rsawatzky@xxxxxxxxxxx> wrote:
> 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
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top