[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Plans for the next release of AspectJ...
|
Hi Gregor,
Gregor> Can you give a couple of small example programs showing how
Gregor> you'd use this? At least one with TYPE_PAT and one with
Gregor> FIELD_PAT? One issue is that I'm not sure I can see how
Gregor> field_pat would work stably.
TYPE_PAT and FIELD_PAT are same as TypePat and FieldPat described in
aspectj quick reference (ASPECTJ_HOME/doc/quick.pdf).
Now, I show my image of monitor pointcut.
Supporse there is a class which name is Test, and method test has
synchronized blocks like following.
public class Test {
Object lock = new Object();
public void test(){
syncronized(this){
//do something
}
synchronized(lock){
//do something
}
}
}
then, this class will be and mapped like following instructions.
aload_0
dup
astore_1
monitorenter
.... -> here matches monitor(Test), monitor(Object+) these are TYPE_PAT
monitorexit
aload_0
getfield <Field java.lang.Object lock>
dup
astore_2
monitorenter
.... -> here matches monitor(Object Test.test), This is FIELD_PAT
also this matches monitor(Object) this is TYPE_PAT
monitorexit
For synchronized method, like
public syncronized void test2(){
//do something
}
public static syncronized void test3(){
//do something
}
you can assume above codes like followings (note binary codes are different)
public void test2(){
synchronized(this){
//do something
}
}
public static void test3(){
synchronized(Test.class){
//do something
}
}
So it is good if synchronized methods also matche monitor pointcut.
Best regards,
Watanabe