Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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

Back to the top