[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[aspectj-users] Re: thisJoinPoint.getThis() documentation
|
- From: Matthew Webster <matthew_webster@xxxxxxxxxx>
- Date: Wed, 28 Jan 2004 09:55:57 +0000
- Delivered-to: aspectj-users@eclipse.org
- Importance: Normal
- Sensitivity:
Are you using a "call()" join point? In which case "this" will always be
null in a static method. Perhaps you should be using "getTarget()" e.g.
public class Main {
public void test () {
System.out.println("? test()");
}
public void instanceMethod () {
test();
}
public static void main(String[] args) {
Main main = new Main();
main.instanceMethod();
main.test();
}
}
public aspect Logging {
pointcut callTest() :
call(* test());
before () : callTest () {
System.out.println("? Logging.callTest() this=" + thisJoinPoint.getThis() + " target=" + thisJoinPoint.getTarget());
}
}
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/