Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Small doubt on --> proceed(Object[] args)

I presume you mean this documentation:

===
In code style, the proceed method has the same signature as the
advice, any reordering of actual arguments to the joinpoint that is
done in the advice signature must be respected. Annotation style is
different. The proceed(..) call takes, in this order:

    * If 'this()' was used in the pointcut for binding, it must be
passed first in proceed(..).
    * If 'target()' was used in the pointcut for binding, it must be
passed next in proceed(..) - it will be the first argument to
proceed(..) if this() was not used for binding.
    * Finally come all the arguments expected at the join point, in
the order they are supplied at the join point. Effectively the advice
signature is ignored - it doesn't matter if a subset of arguments were
bound or the ordering was changed in the advice signature, the
proceed(..) calls takes all of them in the right order for the join
point.

Since proceed(..) in this case takes an Object array, AspectJ cannot
do as much compile time checking as it can for code style. If the
rules above aren't obeyed then it will unfortunately manifest as a
runtime error.
===

At your join point 'Point.move(int,int)', there are 2 arguments
expected, the two integers. and then according to rule (1) above you
used this() for binding so it must be passed first in proceed.  That
gives the structure:

new Object[]{p, dx, dy}

p is not considered an argument expected at the join point as the join
point is 'move(int,int)'

Andy

2009/9/6 João Gonçalves <jocolimonada@xxxxxxxxx>:
> Here's a small working example:
>
> @Pointcut("execution(public void figures.Point.move(int, int))"
>          + "&& this(p) && args(dx, dy)")
> void movingPoint(int dx, int dy, Point p) {}
>
> @Around("movingPoint(dx, dy, p)")
> public void doNothing(ProceedingJoinPoint thisJoinPoint,
>          int dx, int dy, Point p) throws Throwable {
>    thisJoinPoint.proceed( new Object[]{p, dx, dy} );
> }
>
> The above snippet works without any problem, but, from the explanation of
> the AspectJ 5 Developer's Notebook I got the idea that the correct Object[]
> argument should be:
>
> new Object[]{p, dx, dy, p}
>
> p - from "this()"
> dx, dy, p - all the arguments expected at the join point (or p isn't
> considered an argument expected at the join point?)
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top