Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching based on method parameter value

On 31/03/2008, Ed <afreak@xxxxxxxxx> wrote:
> Sorry, I didn't explain my example very well.
> Here's my case:
> I would like to match
> System.out.println("constant string");
> But, I do not want to match println from:
> public void foo(String runtimeGeneratedString)
>  {
>    System.out.println("fooooo" + runtimeGeneratedString);
> }
> Unfortunately, call(* *..*.*(String)) will match both cases.
> From a static perspective (compile-time weaving), this looks like an easy
> thing to do, but if using load time weaving, I'm not sure how aspectJ
> would/could do this.

Cannot do that right now with AspectJ.

> Going off on a tangent...which may help solve my problem in a different way.
>  To what degree can I limit aspectJ's matching behavior?  I know you can do
> things like !within() or !withincode(), but those limit you to package,
> class, or method scope (com.example.*, com.example.Class,
> Is it at all possible to match the 3rd method call
> of bar() within foo() or even only instrument the method on line XX of my
> code (assuming debugging symbols included).

Can't do that statically with AspectJ either - you can keep counters
in advice to indicate X'th time something is called or look at
joinpoint source location for line number, but not statically, just in
your advice.


Back to the top