Community
Participate
Working Groups
The ajc v1.1.1 doesn't seem to regognize the thisEnclosingJoinPointStaticPart keyword. With J2SE's (build 1.3.1_04-b02) and (build 1.4.1-b21) I get compilation errors from Ant and from Eclipse. Ant (v1.5) says: " aj:comp: [iajc] C:\projects\aspectJTest\src\aspects\mypkg\DebugLog.aj:146 thisEnclosingJoinPointStaticPart cannot be resolved [iajc] stream.println("Entering from " + thisEnclosingJoinPointStaticPart.getSignature()); [iajc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
I can't reproduce this error inside the body of a piece of advice. 'thisEnclosingJoinPointStaticPart' is only bound in the body of advice - if you use it outside of that context you will (legitimately) get the error you describe. For example: aspect Foo { after() returning : call(* *(..)) { System.out.println(thisEnclosingJoinPointStaticPart); } } will compile successfully, whereas aspect Foo { after() returning : call(* *(..)) { log(); } void log() { System.out.println(thisEnclosingJoinPointStaticPart); } } does not compile, giving the correct error message: Foo.aj:8 thisEnclosingJoinPointStaticPart cannot be resolved System.out.println(thisEnclosingJoinPointStaticPart); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Are you using thisEnclosingJoinPointStaticPart outside of an advice body?? If not then please reopen this bug..
I was using it outside of an advice body. Didn't know that it wasn't allowed (is this documented somewhere?). My mistake, sorry.
Phew :). Chapter 2 of the programming guide says the following at the top of the section on 'thisJoinPoint' : "AspectJ provides a special reference variable, thisJoinPoint, that contains reflective information about the current join point for the advice to use. The thisJoinPoint variable can only be used in the context of advice, just like this can only be used in the context of non-static methods and variable initializers. " thisJoinPointStaticPart and thisEnclosingJoinPointStaticPart are introduced later in the same section.