[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Tracing Aspect
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[quote Sami Lakka::on 2/20/2005 5:49 PM]
| Ok, I changed the pointcut to call, but with a small HelloWorld app:
|
| public class HelloWorld {
|
| public HelloWorld() {
| System.out.println("In HelloWorld constructor");
| }
|
|
| public static void main(String[] args) {
| HelloWorld world = new HelloWorld();
| }
| }
|
| I still get following output:
| Entering [com.aspects.test.HelloWorld.<init>]
| This: null
| Target: null
| Entering [java.io.PrintStream.println]
| This: com.aspects.test.HelloWorld@9664a1
| Target: java.io.PrintStream@1a8c4e7
| In HelloWorld constructor
|
|
| Why the This and the Target are null when calling the HelloWorld
| constructor?
|
When the constructor call occurs you are in a static context: main method => this is null.
Also, when the constructor call occurs the target object is not created yet => target is null.
- --
:alex |.::the_mindstorm::.|
|
|
|
| -----Original Message-----
| From: aspectj-users-admin@xxxxxxxxxxx
| [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Alexandru Popescu
| Sent: 20. helmikuuta 2005 17:38
| To: aspectj-users@xxxxxxxxxxx
| Subject: Re: [aspectj-users] Tracing Aspect
|
| [quote Sami Lakka::on 2/20/2005 5:31 PM]
| | Hi,
| |
| |
| | I'm learning AspectJ and I would like to create a tracing aspect that
| shows
| | method calls made to any object, as well as the calling object (this) and
| | the called object (target). What kind of a pointcut should I make? My
| | current tracing-aspect looks like following:
| |
| |
| |
| | pointcut traceMethods() : (execution(* *.*(..))
| |
| |
| | || execution(*.new(..))) && !within(TraceAspectV1);
| |
| |
| |
| | before() : traceMethods() {
| |
| | Signature sig = thisJoinPointStaticPart.getSignature();
| |
| |
| |
| | System.out.println("Entering ["
| |
| | + sig.getDeclaringType().getName() + "."
| |
| | + sig.getName() + "]");
| |
| | System.out.println("This: "+thisJoinPoint.getThis());
| |
| | System.out.println("Target: "+thisJoinPoint.getTarget());
| |
| | }
| |
| |
| |
| |
| |
| | The thisJoinPoint.getTarget- doesn't seem to return the correct called
| | object.
| |
| |
| |
| |
| |
| |
| |
| |
| You stated you want to track *method calls*, so you should use *call*
| pointcut and not *execution* ;-).
|
| --
| :alex |.::the_mindstorm::.|
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
iD8DBQFCGLTmTTDTje0R2dgRAt1DAJ0RKRrXERZJeMyTBn4tdAJSh8Wz8gCdFlX3
bV/elVNcQfNs+H/mMtM8FJg=
=Js4j
-----END PGP SIGNATURE-----