For a list of context available as this or target at different kinds of
join points, see the AspectJ Programming Guide, Semantics appendix, section on
Join Points:
Wes
------------Original Message------------
From: Bo Yi <boyi@xxxxxxxxxx>
To: andrew@xxxxxxxxxx, aspectj-users@xxxxxxxxxxx
Cc: aspectj-users-bounces@xxxxxxxxxxx, aspectj-users@xxxxxxxxxxx
Date: Mon, Nov-21-2005 8:22 AM
Subject: Re: [aspectj-users] hashCode() for mixin? Hi Andrew,
this() and target() are sometimes confusing, at least to me :-)
I figured out that when I used execution
pointcut, I should use this(); if I used call pointcut, I should use
target().
The reason is obvious
when you think where the code is injected.
Hope it helps.
Bo
---------------------------------------------------------- Dr.
Bo Yi WebSphere Development & Testing IBM Toronto Lab
A2-713/Q2Z/8200/MKM 8200 Warden Ave. Markham ONT. L6G
1C7 Phone: 905-413-4819 Tie Line: 969-4819 E-Mail:
boyi@xxxxxxxxxx
"andrew cooke"
<andrew@xxxxxxxxxx> Sent by: aspectj-users-bounces@xxxxxxxxxxx
11/21/2005 09:53 AM
Please respond
to andrew and aspectj-users |
|
To
| aspectj-users@xxxxxxxxxxx
|
cc
|
|
Subject
| Re: [aspectj-users]
hashCode() for mixin? |
|
Hi! :o)
OK, it turns out (I think), that thisJoinPoint
doesn't work for inter-type declarations (at least, I got a compile error),
but you made me see that I needed to use the interface as a target - all I
had to do was change from this(mi) to target(mi) in the advice I
had:
public aspect FieldDisplayableHash {
pointcut
miHash(MixinInterface mi): call(public int Object.hashCode())
&& target(mi);
int around(MixinInterface mi): miHash(mi)
{ int hash = proceed(mi); return hash ^
mi.state.hashCode(); }
}
Thanks! (now I must
return to working on Mule...) Andrew
PS I didn't actually have a
hashCode method in the interface -p
Holger Hoffstätte
said: > (hi Andrew, good to see you here too :) > > andrew
cooke wrote: >> Now I want to alter the hashCode method on the
affected classes so that >> the value reflects not just the state of
the original class, but >> includes >> the mixin state
too. > > I cannot test right now but maybe
thisJoinPoint().getTarget().hashCode() > will give you what you want? I
had a similar problem a long time ago and > *think* that was what got me
further. > > hth, > Holger >
_______________________________________________ > aspectj-users mailing
list > aspectj-users@xxxxxxxxxxx >
https://dev.eclipse.org/mailman/listinfo/aspectj-users > >
_______________________________________________ aspectj-users
mailing
list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users
|