Bug 46011 - thisEnclosingJoinPointStaticPart cannot be resolved
Summary: thisEnclosingJoinPointStaticPart cannot be resolved
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-04 04:50 EST by Jari Nurminen CLA
Modified: 2003-12-08 11:27 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jari Nurminen CLA 2003-11-04 04:50:53 EST
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]                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"
Comment 1 Adrian Colyer CLA 2003-12-08 10:01:48 EST
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..
Comment 2 Jari Nurminen CLA 2003-12-08 10:35:44 EST
I was using it outside of an advice body. Didn't know that it wasn't allowed 
(is this documented somewhere?). My mistake, sorry.
Comment 3 Adrian Colyer CLA 2003-12-08 11:27:29 EST
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.