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...

Hi Adrian,

Thank you for your comments.

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

Yes.

Adrian> For the contrived example

Adrian> void foo() {
Adrian>   Object lock = new Object();
Adrian>   someoneElse.passLockReference(lock);
Adrian>   synchronized(lock) {
Adrian>       // ...
Adrian>   }
Adrian> }

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

Right.

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

I'd also like to use this for assertion of lock order.
for example, suppose Test.class has two Object for lock, 
Test{
 Object lock1 = new Object();
 Object lock2 = new Object();
}

And I need to assert that lock2 must be monitored after monitor lock1, then
I can write aspect like this.

declare warning : cflowbelow(monitor(Object Test.lock2)) && monitor(Object Test.lock1) :
   "Check lock order!"

Thanks and regards,
Watanabe


Back to the top