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

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.


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, com.example.Class.foo()). 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).


thanks,
ed





On Mon, Mar 31, 2008 at 6:23 PM, Dehua Zhang <dehua.zhang@xxxxxxxxxxxxxx> wrote:

call(* *..*.*(String))

--
Dehua Zhang
Sable Research Group, McGill University
Montréal, Québec, Canada
http://www.cs.mcgill.ca/~dzhang25





-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Ed
Sent: Mon 3/31/2008 20:40
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Matching based on method parameter value

Hi,

 Is it possible to define a pointcut that matches based on the parameter
passed to the method?

e.g.

I would like to match this:

System.out.prinlnt("Constant String");
or even
String foo = "Constant String";
System.out.prinln(foo);

More specifically, if the string is dynamically created, I don't care to
instrument it.

Thanks!
-Ed

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top