Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] Why no if-poincut for non-static expressions.

What happens when the aspect is 'perthis(pushPop())'; should it
be created before the pointcut is evaluated?  Aspects are
guaranteed to be instantiated before advice runs, but I don't
think we want to guarantee that they will be instantiated 
before pointcuts are evaluated.  So I can imagine a 
NullPointerException resulting from this code:

  before() : if(PushUntilPop.aspectOf().state==2) {
    ...
  }

Which is to say, you can just be a bit careful:

  aspect A {
      static boolean expectedState(int expected) {
          A a = A.aspectOf();
          return ((null != a) && (a.state == expected));
      }
      before() : if(expectedState(2)) {
      }
  }

Wes

> ------------Original Message------------
> From: Eric Bodden <eric@xxxxxxxxx>
> To: aspectj-dev@xxxxxxxxxxx
> Date: Tue, Aug-10-2004 9:39 AM
> Subject: RE: [aspectj-dev] Why no if-poincut for non-static expressions.
>
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Adrian Colyer wrote:
> > I recall Matthew Webster posting an answer to this one a while
> > back.... 
> > http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02107.html.
> 
> Thanks for the quick help. Anyway - would it be possible to consider
> a feature request for this issue for later versions?
> I mean technically any "dynamic" if-pointcut could be "inlined" into
> the connected advices:
> 
> int a;
> 
> after(): if(a==0) && someWhateEverPointcut {
> 		//somecode
> }
> 
> - --becomes--
> 
> int a;
> 
> after(): someWhateEverPointcut {
> 	if(a==0) {
> 		//somecode
> 	}
> }
> 
> Or am I missing something?
> 
> Eric
> 
> - -- 
> Eric Bodden
> Chair I2 for Programming Languages and Program Analysis
> RWTH Aachen University
> 
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 8.0.3
> 
> iQA/AwUBQRj598wiFCm7RlWCEQL3HQCgt3p1H5Tu+uIWEZnvfAehqUsAb1YAn0Ry
> matGkUBa2hB/yHGwYLDyksrM
> =aP6V
> -----END PGP SIGNATURE-----
> 
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 




Back to the top