Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: AW: [aspectj-users] Using AJ to change program flow

From Wes:

> The method-call join point is the call itself, and
> does not include any required parameter evaluation.
> That means causing the call to not proceed does not
> prevent the arguments from being evaluated.

This is true for byte code weaving (evaluating arguments
and putting them on the stack is not an aspectj joint point).
And I think this was true for source code weaving, too. 
(Can someone clarify this?)

You can visualize this as follows:

public void aroundLog(String argument) {
      if (logIsOn)
      {
         log.log(argument);
      }
}

The parameter evaluation takes place before the around advice.

So the misunderstanding is a wrong assumption about what a
call join point is in aspectj. And it is only the call itself.

And consider this snippet:

if (thisJoinPoint.getArgs()[0] != null) {
    proceed();
}

Not calling proceed would not be sufficient to prevent parameter
evaluation.


Vincenz


-----Ursprüngliche Nachricht-----
Von: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] Im Auftrag von Jim Carroll
Gesendet: Montag, 16. August 2004 17:03
An: aspectj-users@xxxxxxxxxxx
Betreff: RE: AW: [aspectj-users] Using AJ to change program flow

Vincenz,

Thanks for the response. I'm surprised about this. It seems that it should
work either way depending on how you pick out of the join points. If the
join points are 'calls' then the the parameter evaluation should not
execute. If the join point is 'execution' then I would expect it to. I think
this because I visualize what is taking place as the insertion of code into
the original source. I see the code inserted where a 'call' is made when the
'call' join points are selected, but I see it as inserting code into the
method where 'execution' is used. So I would have thought that an 'around'
advice would put code 'around' the call (if a 'call' joinpint is used) as
follows:

aspect Logcheck
{
   pointcut logcall(): call[or execute](public Logger.log(..));

   around (): logcall() {
      if (logIsOn)
      {
         proceed();
      }
   }
}

... would cause (in the case of the call) ....

    ...
      log.log("bla" + " bla" + "bla" );
    ...

to be 'converted' to:


      if (logIsOn)
      {
         log.log("bla" + " bla" + "bla" );
      }

But in the case the joinpoint was picked out using an 'execution' it would
modify the log call itself, e.g:

     public class Logger {
      ...
      public void log(String s)
      {
        if (logIsOn)
        {
           [... body of the original log method ...]
        }
      }
      ...
     }


So, what is it about my understanding that is incorrect? (I can't seem to
access the thread you referenced so if the answer is simple and you can
straighten out my misunderstanding, please do).

Thanks
Jim
 

"Vincenz Braun" <vb@xxxxxxxxx> wrote:

>Hi,
>
>you can't do this at the moment.
>You can have an around advice that prevents the actual call
>of a log statement (described in the previous post with a conditional
>proceed()). But the cost of the parameter creation
>can not be avoided. Here is the post from Wes:
> ...

__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top