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

declare parents : * && (! java.lang.Object) implements I;

Thanks - that did the trick! It hadn't occured to me that I could simply put a negation in there.

Though you probably want a positive limitation (com.foo..*) rather than a negative one (!java.lang..*);

No, I definitely want the negative one because I want to profile programs which are unknown to the aspect writer.

Cheers,

Dave

Cheers,

Nicholas Lesiecki
Software Craftsman, specializing in J2EE,
Agile Methods, and aspect-oriented programming
m: 520 591-1849

Books:
* Mastering AspectJ: http://tinyurl.com/66vf
* Java Tools for Extreme Programming: http://tinyurl.com/66vt

Articles on AspectJ:
* http://tinyurl.com/66vu and http://tinyurl.com/66vv
On Nov 11, 2004, at 4:56 PM, David Pearce wrote:

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


_______________________________________________
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