[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Matching targets cast to a specific type
|
Hello again,
I'd like a pointcut to match if and only if the target is declared as(cast
to) a specific type. I hope the following example helps understand what I
mean:
public interface IFoo {
public void foo();
}
public class Foo implements IFoo {
public void foo() {}
}
The pointcut should now match
IFoo f = new Foo();
f.foo(); // this
but not
Foo f = new Foo();
f.foo(); // this
or
new Foo().foo();
The following pointcut does what I want:
before(): call(void IFoo.doSomething()) &&
if(thisJoinPointStaticPart.getSignature().getDeclaringType()==IFoo.class)
but costs performance since if(...) is evaluated at runtime. The information
I need for picking out the right join points is already present at
compile-time, though, so my question is: Is there a way of expressing this
pointcut using only compile-time functionality?
Thanks in advance,
Michael Herrmann
--
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++