I think this is not possible. But maybe Andy Clement knows better. It would not 
be the first time he surprised me. Meanwhile, check out my workaround at 
http://stackoverflow.com/a/24797868/1082681.

-- 
Alexander Kriegisch
http://scrum-master.de


Eric B schrieb am 17.07.2014 07:12:

> Thanks.  What if want to advise based on an annotation rather than a type?  I 
> tried
> 
> pointcut addEntity(@MyAnnotation * s):
>         call( * java.util.Collection+.add( * ))
>         && args(s);
> 
> But got syntax error that @MyAnnotation is not allowed.
> 
> 
> On Jul 17, 2014 1:05 AM, "Ulises Juárez Martínez" <ujuare...@gmail.com 
> <mailto:ujuare...@gmail.com> > wrote:
>> add() signature is:
>> 
>> add(E e)
>> 
>> Thus, * matches anything, but java.lang.String is not E.
>> 
>> Change your pointcut to:
>> 
>>     pointcut addEntity(String s):
>>         call( * java.util.Collection+.add( * ))
>>         && args(s);
>> 
>> 
>> 
>> On Wed, Jul 16, 2014 at 10:31 PM, Eric B <ebenza...@gmail.com 
>> <mailto:ebenza...@gmail.com> > wrote:
>> > I'm trying to write a pointcut against a Collection.add() method given a
>> > specific type of argument, but everytime I specify the argument type the
>> > pointcut fails to advise.
>> >
>> > Given the following code:
>> > List<String> x = new ArrayList<String>();
>> > x.add("Some String)";
>> >
>> > This works:
>> >
>> > pointcut addEntity():  call( * java.util.Collection+.add( * ));
>> >
>> > However, this does not:
>> >
>> > pointcut addEntity():  call( * java.util.Collection+.add( java.util.String
>> > ));
>> >
>> >
>> > Is there a specific reason why I cannot specify the type of argument I want
>> > to advise against?
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to