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

Hi Doug,

As Matthew says, the problem is no longer present in the latest
version of ajc.

Regarding the feature requested in your postscript: abc provides such
"private pointcut variables". abc is an optimising compiler for the
full AspectJ 1.2 language, designed to be easily extensible - and one
of the example extensions is the one you request. A pre-release
is publicly available from http://aspectbench.org.

Feedback on abc from readers of this list is most welcome!

Best wishes,

-Oege

On Tue, 5 Oct 2004, Doug Orleans wrote:

> 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
>


Back to the top