[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-dev] Matching based on method parameter value
|
This question comes from the aspectj-users mailing list:
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.
If this is not possible right now, can someone give me directions where
I have to look in the source code of AspectJ to make this possible for
my project?
In particular,
call(* *..*.*(String))
will match both cases. So, I would like to move to:
call(* *..*.*(String)) && args(checkStatic)
call(* *..*.*(String)) && args(checkDynamic)
Based on a specific name, we will do additional checks in AspectJ itself.
So here, the first one should match System.out.println("constant
string"); while the second one should match System.out.println("fooooo"
+ runtimeGeneratedString);
I looked into the code and I started at the read function in the
ArgsPointcut class where I can set a new flag indicating if there should
be additional checks later. However, I can't find where type matching
and assigning actually happens. Can someone point me to the following
parts of the code.
(1) Where does the type matching happen? I thought it was in
tools/TypePatternMatcherImpl.java but that doesn't seem to be right
(2) I'm looking for the code where the data is assigned to the variable.
For example, where in the code is "constant string" assigned to checkStatic?
Any other suggestions are really appreciated...Thanks a lot!