Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Default (non-closure) implementation of around?

sure I can show you an example of both where inlining
is done and where closure class is used.... I have
used AspectJ1.06 to generate the woven code.....But I
am pretty sure the implementation of around advice is
the same.....

I would really like to know if there has been any
change in the implemetation of around/proceed()...


1) where inlinig is used...suppose there is an around
advice defined in Aspect Z as:

void around(int n) : execution(void A.f(int))
                     && args(n);  { 
      proceed(n); 
      System.out.println("Around A.f ");
      return; 
}

then the woven class file A will look like :

public void f(int n) {
    this.around1_f(n, ((AroundClosure)(null)), 
                   Z.aspectInstance);
  } 

final Object dispatch1_f(int n) {
    if (true) {
        System.out.print("   "+ this.f(i));
      } 
    return null;
  } 

public final void around1_f(int n, 
                     final AroundClosure ajc$closure,
       this.dispatch1_f(n);
       System.out.println("Around A.f");
       return;
}

note that the around advice code has been copied to
class A in function around1_f(), and also that "null"
is passed as Argument for AroundClosure while calling
the mehtod from f(), that means no instance of
AroundClosure is created here in this case...ALso note
that mehtof f() is no more calling the advice method
and calls the method created in Class A....

On the other hand if the Around Advice in Aspect Z was
something like:

void around(int n) : execution(void A.f(int))
                     && args(n); { 
    final int no = n; 
    Runnable r = new Runnable() { 
      public void run() {  
        proceed(no);
      } 
    }; 
 } 

then after weaving this advice, the class A would look
like: 

public void f(int n) { 
    try { 
      Z.aspectInstance.around0$ajc(n,this.new 
                                     Closure2()); 
    } catch(RuntimeException ajc$exc) {
      throw ajc$exc; 
    } catch (Error ajc$exc) { 
      throw ajc$exc; 
    } catch (Throwable ajc$ignore) { 
      throw new Error("can\'t throw"); 
    }  
  }  

final Object dispatch1_f(int n) {
    if (true) { 
      System.out.print("   "+ this.f(i));
    }  
    return null; 
  }  

  private class Closure2 extends AroundClosure { 
    Closure2() { super(); }

    public Object run(final java.lang.Object[] _args){

      Fib.this.dispatch1_f(Conversions.intValue( 
                                           
_args[0]));
      return null; 
    }  
}

I have shown only the relevant code here to show the
diffrence between the two code... but note that in
this case a closure class Closure2 is created, and the
mehtod f() now pass an instance of Closure2 class as
parameters ...its not null....and it is calling the
advice method now..... 

It depends on how the proceed is called from the
around advice.....as talked in the "advice weaving in
aspectJ" paper...

Hope this example is helpful......

Swati

--- Nadia Guerroumi <n_guerro@xxxxxxxxxxxxxxxx> wrote:
> HI Swati!
> Do you have any example where you can see this
> inlining.
> All the examples that I run use the closure class.
> Thank you
> Nadia
> ----- Original Message ----- 
> From: "Swati Pradhan" <swatipradhan@xxxxxxxxx>
> To: "AspectJ developer discussions"
> <aspectj-dev@xxxxxxxxxxx>
> Sent: Tuesday, April 19, 2005 4:06 PM
> Subject: Re: [aspectj-dev] Default (non-closure)
> implementation of around?
> 
> 
> > 
> > As far as I know....In the default implementation
> of
> > Around advice....the Closure class is not created
> and
> > the around advice code is inlined wherever it is
> > applied in the source code.....
> > 
> > This is an optimization....because by in-lining
> the
> > code, the compiler avoids not only the runtime
> cost of
> > storing closure state, but also the cost of
> generating
> > a new class......
> > 
> > Swati...
> > --- Adrian Colyer <adrian_colyer@xxxxxxxxxx>
> wrote:
> > > inlining!
> > > 
> > > 19 April 2005 17:50
> > > To: <aspectj-dev@xxxxxxxxxxx>
> > > cc: 
> > > From: "Nadia Guerroumi"
> <n_guerro@xxxxxxxxxxxxxxxx>
> > > Subject: [aspectj-dev] Default (non-closure)
> > > implementation of around?
> > > 
> > > 
> > > I am reading the paper of "advice weaving in
> > > aspectJ" by Hilsdale & Hugunin.
> > > 
> > > Could someone please explain me this paragraph
> about
> > > the inlining of advice ?
> > > 
> > > " We do use inlining strategy for the default
> (non
> > > closure) implementation of around advice...."
> > > 
> > > What is the default (non closure) implementation
> of
> > > around advice??
> > > 
> > > Nadia.>
> > _______________________________________________
> > > aspectj-dev mailing list
> > > aspectj-dev@xxxxxxxxxxx
> > >
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > > 
> > 
> > 
> > 
> > __________________________________ 
> > Do you Yahoo!? 
> > Read only the mail you want - Yahoo! Mail
> SpamGuard. 
> > http://promotions.yahoo.com/new_mail 
> > _______________________________________________
> > aspectj-dev mailing list
> > aspectj-dev@xxxxxxxxxxx
> >
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Back to the top