Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] call from advice body



Doug,

A quick search on Bugzilla for "around advice" reveals
https://bugs.eclipse.org/bugs/show_bug.cgi?id=71377. I believe your problem
should be fixed in the latest development build and I can't reproduce it in
AJDT 1.1.12 which contains bug fixes to AspectJ 1.2.

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/


"Wes Isberg" <wes@xxxxxxxxxxxxxx>@eclipse.org on 06/10/2004 02:20:57

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    Re: [aspectj-users] call from advice body


Hi Doug -

Yes, you should be able to advise join points in advice.

This looks like a long-standing bug with calling a method
from advice advising the same method-call join point.
Other method-call join points in advice can be advised fine,
and this case worked fine in AspectJ 1.0, so long as the
factBaseCase(..) around advice is first/precedent.

It's worth submitting as a bug; I'll do that if I don't hear
from you that you've done so.  Thanks for finding it.

Wes

> ------------Original Message------------
> From: Doug Orleans <dougo@xxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Tue, Oct-5-2004 4:05 PM
> Subject: [aspectj-users] call from advice body
>
> I have the following aspect:
>
> aspect Fact {
>   static int fact(int n) {
>     throw new RuntimeException("Message not understood: fact(" + n +
> ")");
>   }
>
>   pointcut factBaseCase(int n):
>     factCall(n) &&
>     if(n == 0);
>   int around(): factBaseCase(int) { return 1; }
>
>   pointcut factCall(int n):
>     call(int fact(int)) &&
>     args(n);
>   int around(int n): factCall(n) { return n * fact(n-1); }
>
>   public static void main(String[] args) {
>     System.out.println(fact(5));
>   }
> }
>
> It throws the exception: Message not understood: fact(4)
> But if I change factCall to use execution instead of call, it works
> fine (printing 120).
>
> Why doesn't the call to fact(4) get advised?  Is there some rule that
> advice can't apply to calls from advice bodies?
>
> --dougo@xxxxxxxxx
>
> P.S. It would be nice to rewrite factBaseCase as follows:
>
>   pointcut factBaseCase():
>     factCall(int n) &&
>     if(n == 0);
>
> since the pointcut doesn't actually need to expose any context.  Is
> this a reasonable feature request, or is it not really feasible?
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>


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





Back to the top