Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Adding a new buddy field for EVERY existing field in a class ?!

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  |  rdifrango@xxxxxxxxxxxxxxxxxxxxx

From: aspectj-users-bounces@xxxxxxxxxxx [aspectj-users-bounces@xxxxxxxxxxx] on behalf of y a [yaniv.azriel.samsung@xxxxxxxxx]
Sent: Saturday, March 09, 2013 7:18 AM
To: aspectj-users@xxxxxxxxxxx
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

Back to the top