Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Do the lock() and unlock() pointcuts allow type matching?

I just looked at some test cases and we have this:

void around(Foo f): unlock() && args(f) {

System.err.println("around(Foo) lock: advice running at "+thisJoinPoint.getSourceLocation());

proceed(f);

}


static class Foo {

public void nonstaticM() {

synchronized (this) {

System.err.println("non-static method running");

}

}

public static void staticM() {

synchronized (String.class) {

System.err.println("static method running");

}

}

}


So your second type of point cut should be OK, if the locks are occurring on that type.

Andy


On 7 March 2014 04:45, Jonathan Mace <jcmace@xxxxxxxxxxxx> wrote:
I'm trying to match all instances in my application where synchronization is used on a specific type.  I would expect this could be written fairly easily as:
    
    after(Object o): args(mytypeexpression) && args(o) && lock() {
        System.out.println("args after lock " + o.toString());
    }

or as

    after(MyType o): args(o) && lock() {
        System.out.println("args after lock " + o.toString());
    }

however, neither of these work, even though o is accessible as an object of type MyType.

Is this expected behaviour?

Jon

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



Back to the top