Yeah, you would and the hugh down side to it, is that you would have to 
introduce a buddy class for each real class, thereby just making the 
implementation of the aspects tightly coupled to the classes.  I think he 
generic aspect with the map implementation is the right way to go.

Ron DiFrango
Director / Architect  |  CapTech
(804) 855-9196  |  
[email protected]<https://email4.captechventures.com/owa/UrlBlockedError.aspx>

From: y a 
<[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Saturday, March 9, 2013 10:29 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [aspectj-users] Adding a new buddy field for EVERY existing field 
in a class ?!

Thanks Ron

About this shaodw class...
Even if i have a shadow class for each original class
The set() advice still need runtime reflection or a switch statement
to set the shadow field ?!
I cant find too many examples on set()/get()


UPDATE
The map solution is easy and works

I thought about injecting a buddy *object* into each real object (i.e. no new 
classes), using aspectj to skip all method execution, and only use the fields 
for storage.
Is there some execution side effect which i wont be able to skip?

TIA


On Sat, Mar 9, 2013 at 4:20 PM, Ron DiFrango 
<[email protected]<mailto:[email protected]>> wrote:
Without creating a aspectj shadow class that gets "injected" via an intertype 
declaration, I don't see a way to do it without reflection and/or using the map 
approached referenced in your post.

Ron DiFrango
Director / Architect  |  CapTech
(804) 855-9196<tel:%28804%29%20855-9196>  |  
[email protected]<https://email4.captechventures.com/owa/UrlBlockedError.aspx>
________________________________
From: 
[email protected]<mailto:[email protected]> 
[[email protected]<mailto:[email protected]>] 
on behalf of y a 
[[email protected]<mailto:[email protected]>]
Sent: Saturday, March 09, 2013 7:18 AM
To: [email protected]<mailto:[email protected]>
Subject: [aspectj-users] Adding a new buddy field for EVERY existing field in a 
class ?!

I want an aspect to store the old value for each field set operation
So if a class has 3 long fields, i now need 3 new fields in the aspect

Is this possible ?!
And is there a suitable ajc syntax to access such a buddy field in a set() 
advice ?

my example:

aspect to  "print" the field changes, but i need the new fields to "store" the 
values

import java.io.*;
import org.aspectj.lang.reflect.FieldSignature;

aspect AspectField  {
      before(long newval): set(long *) && args(newval) {

         FieldSignature fs;
         fs = (FieldSignature)thisJoinPointStaticPart.getSignature();
         System.out.println(fs.getFieldType());
         System.out.println("FIELD SET TO " + newval);

         // i want to store the newval here in a "buddy field"
      }
  }

[[ Eventually i want all of this to be done statically with out reflection but 
one bridge at a time.. ]]
[[ 
http://stackoverflow.com/questions/6698203/exposing-previous-value-in-aspectj-set-pointcut
 - this discussion stores all the fields in a single map - i dis like solution 
for performance.. ]]


TIA

_______________________________________________
aspectj-users mailing list
[email protected]<mailto:[email protected]>
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to