Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ vs PostSharp?

On 14 December 2011 13:21, Mark <mark.kharitonov@xxxxxxxxx> wrote:
> Oh, I would want AspectJ to be a kitchen sink. I like it as it is.
>
> My previous post had too many words, most of them irrelevant to what I am
> really looking for in this backdoor.
>
> There are advices and there are pointcuts. Pointcuts are declared using a
> certain syntax. In an ideal world, nothing else is needed. But in reality,
> there are things that one cannot express using the current pointcut syntax.
>
> For instance, I would like to declare a pointcut that matches any method
> with only the primitive parameters. The current syntax does not allow me to
> do so, does it? I can write something like this:
>
> pointcut aaa() : execution(* *.*((int || double || char), (int || double ||
> char), (int || double || char), ..));
>
> But I need to list all the primitive types and create several versions of
> this pointcut for methods with 0, 1, 2, 3, etc arguments until some
> reasonable number.

You can write:

pointcut aaa(): execution(* *.*(!Object+,..));


> Does it make more sense now?

Now you've described your use case, I can see what you want.  Indeed I
did temporarily have a back door for this in an old version.  The
requirement was that the set of modifiers was extensible and you could
plug in a class that defined what matching your modifier meant.  In
the case I remember supporting, the modifier was 'trivial' and the
definition of a trivial method was 'a short one less than 20
instructions with no branches in it'.

pointcut methodsToTrace(): execution(!trivial * *(..));

This meant we could avoid tracing getters/setters, that kind of thing.

Now I think I've taken support out for that now, but a while later
Spring came along with the first class notion of a 'bean'.  This led
to making the pointcut parser extensible so that matching could be
done on 'bean'.  I am not sure how well publicized this interface was
though, I just know Spring is using it, I don't recall if you can pass
in your new designators on the command line though, would need to look
at the code.  Spring has no problem with that because it creates the
pointcut parser directly rather than calling 'ajc'.

Andy


Back to the top