[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] @DeclareParents and this.getClass()
|
Roland,
With "declare parents implements"
in an ITD method "this" will refer to the interface type. That
behaviour _is_ the same between the two programming styles. However, that
is the only guarantee we can make (please read http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-itds.html).
With code style "this" can also refer to the "declare parents
implements" target but only by casting to the correct type. In general
though this is probably not good programming technique.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM United Kingdom Limited
Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Roland Reckel <rreckel@xxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx
30/03/2007 07:37
Please respond to
aspectj-users@xxxxxxxxxxx |
|
To
| aspectj-users@xxxxxxxxxxx
|
cc
|
|
Subject
| Re: [aspectj-users] @DeclareParents
and this.getClass() |
|
I tried to do exactly the same aspect using "code
style" and it worked
perfectly. But in the doc I found this:
"Whichever style you use, the AspectJ weaver ensures that your program
has exactly the same semantics."
I think this is not true! "this" returns different instances
in the
different styles.
Is this a bug in the annotation style or is this intended?!?!?
I really like the annotation style with the LTW (very flexible and
dynamic, can even compile in Continuum without ajc etc......), but for
now it is unusable to me :-((
Please help!
Thanks
On Wed, 2007-03-28 at 14:50 +0200, Roland Reckel wrote:
> Hi
>
> I have a problem with the @DeclareParents annotation:
> this.getClass() returns the implementation class of the Aspect and
not
> the "aspected" class.
>
> Is this a bug? Or does any other method exist to get the aspected
class?
> BTW: I use AspectJ 1.5.3
>
> Here an example:
>
> @Aspect
> public class PersistenceAspect {
>
> public interface IPersistentObject {
> void store();
>
> void delete();
> }
>
> public static class PersistentObjectImpl implements
> IPersistentObject {
>
> public void store() {
> }
>
> public void delete() {
>
System.out.println("Class: " + this.getClass()) // Does
return
> PersistentAspect$PersistentObjectImpl !?!?!?!?
> }
> }
>
> @DeclareParents(value = "@lu.vdl.trasal.annotation.PersistentObject
> *", defaultImpl = PersistentObjectImpl.class)
> private IPersistentObject implementedInterface;
>
> }
>
>
> Does anybody have the same problem? (I found some mails with the same
> problem but no answer or bug report :-((
>
> Thx for your help
>
>
> _______________________________________________
> 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
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU