Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] One target for intertype declarations

Hi Wes,

aspect A {
  interface I {}
  declare parents : my.packages..* implements I;
  int I.theField = 2;

Actually, this pattern is rather interesting to me! I had tried something like it, but instead including the "int theField" inside the interface declaration itself. This caused problems when I tried to modify it, since the field was regarded as final. In fact, I'm slightly unsure why the above works ?

Anyway, it doesn't actually solve my problem since I want to add fields to *all* objects. I tried the following:

declare parents : * implements I;

Which causes some "typeNotExposedToWeaver" warnings and the following error:

> [error] can''t change the parents of java.lang.Object

I wonder, is there anyway to say "everything except java.lang.Object" ?

Cheers,

Dave



------------Original Message------------
From: David Pearce <david.pearce@xxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Date: Wed, Nov-10-2004 7:55 PM
Subject: [aspectj-users] One target for intertype declarations

Hi all,

I would just like to confirm something regarding the elimination of "multi-intertype declarations". Basically, I want to add a field to every object instance. So, perviously, I could have just used something like:

aspect A {
        public int *.theField = 0;
}

But, since AspectJ 1.1 this syntax is no more. So, now my question. Is the pertarget specifier supposed to be used instead of the above now? I realise that the README-11.html indicates pertype should be used for static field member introduction (if it existed, that is), so I figure the reasoning is the same.

Also, how is pertarget actually implemented? Does it involve some kind
of hashmap lookup or not?  If not, then what?

Any help would be appreciated!

David J. Pearce
_______________________________________________
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



Back to the top