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

Or, try declaring the field on an interface that your target
classes implement:

----
aspect A {
  interface I {}
  declare parents : my.packages..* implements I;
  int I.theField = 2;
  // sample use 
  before(I i) : target(i) && call(String toString()) {
     i.theField++;
  }
}
----

Wes

> ------------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
> 




Back to the top