Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Newbie question


Hi William,

Until recently we had a limitation on binding things multiple times - and we'd
produce an error - *this was regardless of whether you (as the developer) know
they are binding to the same thing*.

Actually when I ran your testcode on AspectJ 1.5.0M1 it is the first set that
fails for me and the second set that work.  This is what I expected, because if
you 'expand' the methods() pointcut in the first case it looks like:

pointcut methods(TestClass tc): ((target(tc) && call(public * set*(..)) && args(int)) ||
                                 (target(tc) && call(public * get*(..)));

and according to the rules about binding, we see 'tc' twice on the right and
fail.

But, that has been fixed since 1.5.0M1 and if you download
the current build, it will succeed with either variant of your pointcuts:

http://download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar

There is currently no AJDT that contains this level of AspectJ but there will
be shortly...

cheers,
Andy.
---
Andy Clement
AspectJ
clemas@xxxxxxxxxx



W.Leeson@xxxxxxx
Sent by: aspectj-users-admin@xxxxxxxxxxx

17/01/2005 10:20

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] Newbie question






Hi All,

       Just started using AspectJ on Friday last week and have being doing a bit of experimentation but have a quick question about the following pointcut definitions

 
// 1st

pointcut setMethods(TestClass tc): target(tc) && call(public * set*(..)) && args(int);

pointcut getMethods(TestClass tc): target(tc) && call(public * get*(..));

pointcut methods(TestClass tc): (setMethods(tc) || getMethods(tc));

       
// 2nd
pointcut setMethods(): call(public * set*(..)) && args(int);

pointcut getMethods(): call(public * get*(..));

pointcut methods(TestClass tc): target(tc) && (setMethods() || getMethods());


Now what I don't understand is why does the first version of methods work and the second one produce the following error


Cannot use target() to match at this location and bind to formal type 'TestClass' - the formal is already bound to 'TestClass'. The secondary source location points to the problematic target().

       -TestAspect.before(TestClass):methods..

       -TestAspect.after(TestClass):methods..


at the following code fragment


       tc.setValue(0);


From my understanding I think they should evaluate to the same thing. I am sure I am missing something some thing fundamental here.


Regards,

William Leeson
Software Development

PILZ Ireland Industrial Automation,
Business & Technology Park, Model Farm Road, Cork, Ireland.
Telephone +353 (021)  4804-982, Fax +353 (021) 4804-994
E-Mail: mailto:w.leeson@xxxxxxx, Internet: http://www.pilz.ie

This email is intended solely for the use of the named addressee(s). Any unauthorised disclosure, copying or distribution of the confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.


Back to the top