Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Plans for the next release of AspectJ...


> 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


you mean 'matches monitor(Object Test.lock)' for the FIELD_PAT, right?

For the contrived example

void foo() {

  Object lock = new Object();
  someoneElse.passLockReference(lock);
  synchronized(lock) {
      // ...
  }
}

you could only ever match on TYPE_PAT, and not FIELD_PAT?


I fully understand the value of this for tracing / debugging / instrumenting multi-threaded applications. I'd be very interested to hear use cases anyone has for this proposed extension that go beyond such examples.

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Toru Watanabe <t-watanabe@xxxxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

17/12/2003 10:11
Please respond to aspectj-users

       
        To:        aspectj-users@xxxxxxxxxxx
        cc:        
        Subject:        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
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top