Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] why the !within! in the aspect

Thank you! True I fall in the recursive problem! So Ok for the !within!!
----- Original Message ----- 
From: "Matthew Webster" <matthew_webster@xxxxxxxxxx>
To: <aspectj-users@xxxxxxxxxxx>
Sent: Friday, April 08, 2005 10:24 AM
Subject: Re: [aspectj-users] why the !within! in the aspect


>
>
>
>
> Nadia,
>
> This is because you are still advising the constructor execution for Lolo
> which can be omitted using:
>
>       && !execution(new(..))
>
> however you then fall into the trap of recursion: there is the execution
of
> the before advice itself as well as the "System.out..." statement which
has
> at least 4 join points. You should try using AJDT and the Outline or Cross
> Reference view to see what affect you aspect is having. An alternative is
> -XshowWeaveInfo option in AspectJ 1.2.1.
>
> Using an aspect to advise itself is _very_ problematic and usually
> undesirable. For that reason !within(Aspect) is a popular idiom. More
> importantly advice is typically used with a particular kind of join point
> e.g. method execution a practice which avoids this sort of problem.
>
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139 (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
>
> "Nadia Guerroumi" <n_guerro@xxxxxxxxxxxxxxxx>@eclipse.org on 08/04/2005
> 14:22:00
>
> Please respond to aspectj-users@xxxxxxxxxxx
>
> Sent by:    aspectj-users-bounces@xxxxxxxxxxx
>
>
> To:    <aspectj-users@xxxxxxxxxxx>
> cc:
> Subject:    [aspectj-users] why the !within! in the aspect
>
>
> According to an answer that I had in this forum:
>
> For #2, your before advice in Lolo was executing on staticinitialization
of
> the Lolo aspect, which failed because the aspect wasn’t yet initialized.
> You already figured out the way to avoid the problem J
>
>
>
> I was expecting that the following aspect will work but it still gives the
> error NoAspectBoundException: Lolo
>
> Why???? Why I must put the !within(Lolo)
>
>
> aspect Lolo
>
> {
>
>
> pointcut p2(): !staticinitialization(*)&& ! initialization
> (*.new(..))&&!preinitialization(*.new(..));
>
> before(): p2() {
>
> System.out.println(">>Before the join point:"+thisJoinPoint);
>
> }
>
>
>     class Nadia1 {
>  public static Bank b,c;
>
>
>  public static void main(String[] args) {
>
>
>  b=new Bank();
>
>
>  c=new Bank();}}
>
>
>  class Bank {}
>
>
>  /****************************************************/
>
>
>  #2 The aspect was originally
>
>
>  aspect Lolo
>
>
>  {
>
>
>  pointcut p2():if (true);
>
>
>  before(): p2() {
>
>
>  System.out.println(">>Before the join point:"+thisJoinPoint);
>
>
>  }
>
>
>  }
>
>
>  Thank you
>
>
>  Nadia._______________________________________________
>  aspectj-users mailing list
>  aspectj-users@xxxxxxxxxxx
>  https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


----------------------------------------------------------------------------
----


> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>



Back to the top