[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] More AjBrowser failure WAS: writing an aspect to check for Swing Thread Safety

Hi Nick,
Yes, please submit - I'm a Mac OSX user at home too :). Since the Eclipse
OSX downloads are in the 2.1 stream, I'll take a look at this as soon as we
move AJDT onto a 2.1 base.  (And I'm going to post an AJDT FAQ about our
plans for doing that - a popular question of late!).

-- Adrian.
Adrian_Colyer@xxxxxxxxxx


                                                                                                                             
                      Lesiecki Nicholas                                                                                      
                      <ndlesiecki@xxxxxxxx        To:       aspectj-users@xxxxxxxxxxx                                        
                      m>                          cc:                                                                        
                      Sent by:                    Subject:  [aspectj-users] More AjBrowser failure WAS: writing an aspect to 
                      aspectj-users-admin@         check for Swing Thread Safety                                             
                      eclipse.org                                                                                            
                                                                                                                             
                                                                                                                             
                      01/08/2003 06:34 PM                                                                                    
                      Please respond to                                                                                      
                      aspectj-users                                                                                          
                                                                                                                             



> You can also use the IDE's (Ajbrowser, et al) to see
> what code is affected by particular advice (once
> they are working with 1.1?  No response to Nick's
> question on point yet).

As a further note, the AJDT for Eclipse under WinXP also exhibits the
problem behavior. (Compiles seem to succeed but crosscutting structure not
displayed). Running the affected classes when built with the AJDT shows no
evidence of weaving (i.e. aspects have no effect). Compiling manually with
ajc works.

(AJDT on OSX suffers from what I like to term "total existence
failure"--not surprising since I have to run a milestone of eclipse 2.1.
The AJDT *does* warn against using versions as newer than 2.0.0.)

I'd like to submit this as a bug but the problem seems so large that I have
difficulty believing that there isn't something I'm missing. Shall I submit
anyway?

cheers,

Nick
--- Wes Isberg <wes@xxxxxxxxxxxxxx> wrote:
> >  Now I am attempting to add a new aspect to
> > help check for Swing Thread Safety.
>
> This is an interesting application.  If you get it to
> work, it would be nice to see the solution on the list.
>
> > I would like to put a
> > pointcut on all executions to javax.swing code
>
> One factor to consider, from the Programming Guide
> appendix C, "implementation limitations":
>
>   execution join points can be advised only if
>   ajc controls the code for the method or
>   constructor body in question
>
> So you can advise only the swing subclasses passed as
> source to the AspectJ compiler.  It will not advise
> libraries on the classpath.  It should advise any
> such subclasses in your sources.  I suspect you know
> this, but thought it worth mentioning.
>
> Another factor is the pointcut:
>
> >     pointcut restrictedExecution(): execution(*
> > javax.swing+.*(..))
> >                                  ||
> > execution(javax.swing+.new());
>
> + works on types, not packages.  Try this (untested):
>
>   from: execution(* javax.swing+.*(..))
>     to: execution(* javax.swing..*+.*(..))
>     or: target(javax.swing..*+) && execution(* *(..))
>
> tip: for staticly-determinable pointcuts like the method
> execution PCD, you can debug it at compile time using
> declare warning:
>
>    pointcut testme() :
>        execution(* javax.swing..*.*(..));
>
>    declare warning() : testme() : "testme";
>
> You can also use the IDE's (Ajbrowser, et al) to see
> what code is affected by particular advice (once
> they are working with 1.1?  No response to Nick's
> question on point yet).
>
> Wes
>
> > Jim Piersol wrote:
> >
> > Hi,
> >
> > Absolute AspectJ newbie here.  Been through the docs and a
> > few examples.  Now I am attempting to add a new aspect to
> > help check for Swing Thread Safety.  I would like to put a
> > pointcut on all executions to javax.swing code to check
> > the SwingUtilities.isEventDispatchThread() method and
> > report a message if the call was made outside the
> > EventThread.  This would be used as a development tool to
> > find any BAD code that could cause GUI anomalies, i.e.
> > deadlocks, painting problems...
> >
> > Here is what I am trying so far.  It doesn't seem to do
> > what I want though.  It finds calls to things like
> > javax.swing.AbstractAction but I purposely added a
> > background Thread in a GUI class to instantiate and
> > operate on a JTextField, and it nevers reports on it.
> >
> > **************************************
> > package strata.aspect;
> >
> > import javax.swing.*;
> > public aspect TraceMyClasses {
> >
> >     pointcut restrictedExecution(): execution(*
> > javax.swing+.*(..))
> >                                  ||
> > execution(javax.swing+.new());
> >
> >
> >     before(): restrictedExecution() {
> >         if (!SwingUtilities.isEventDispatchThread()) {
> >            System.out.println("\n-->FOUND NON SAFE SWING
> > CALL....."
> >                     + "\n--> " +
> > thisJoinPointStaticPart.getSignature()
> >                     + "\n--> " +
> > thisJoinPoint.getSourceLocation().getFileName()
> >                     + "\n--> " +
> > thisJoinPoint.getSourceLocation().getLine()
> >                     + "\n--> " +
> > thisJoinPoint.getSourceLocation().getWithinType());
> >         }
> >     }
> > }
> >
> >
>
****************************************************************************************************

> >
> > Any help or ideas would be appreciated.  I will be sure to
> > post any final results I receive from this thread.
> >
> > Thanks,
> > Jim
> >
> >     Jim Piersol
> > Senior Software Engineer
> > Sun Certified Java Developer
> > Strata Group, Inc.
> > jrp@xxxxxxxxxxxxxxxx
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users