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.
Thx
Eric
On Jul 17, 2014 1:05 AM, "Ulises Juárez Martínez" <[email protected]>
wrote:
> Hi Eric,
>
> 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);
>
> Best regards.
>
> Ulises
>
>
> On Wed, Jul 16, 2014 at 10:31 PM, Eric B <[email protected]> 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?
> >
> > Thanks,
> >
> > Eric
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > [email protected]
> > To change your delivery options, retrieve your password, or unsubscribe
> from
> > this list, visit
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users