Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Adding a field to a direct subclass only...

 I'm trying to use ITD to add a field only to a direct subclass of a give class (and not to direct and indirect as aspectj allows by default), but I cannot find the correct _expression_ to do so. The problem is that I have to keep a single value for every instance (ideally I would like to add a field to java.lang.Object, but this not possible on Sun's JVM), and if apply the aspect to "* && !java.lang.Object" the field is added on every class..

 I want to do something like:

 interface MyInterface {}
 aspect X {
     int MyInterface.afield;
     declare parents: * && isDirectSubclassOf(java.lang.Object) && !java.lang.Object implements MyInterface;

  Is there a way to specify that?

 (I cannot use perthis()/pertarget() because it introduces too much overhead..).

Many thanks,


PS: Is there a way to enable ITD to JDK classes? I was able to weave aspects that do not use static crosscutting to JDK classes with ajc, but static crosscutting does not apply to JDK classes. Probably an option should be added to allow this...

Back to the top