[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] (no subject)

hi,

I am trying hard to get a solution to this problem since last 4 days.. but no luck; the issue is as below:

I have java classes of this form

public class UserAttributes implements Interceptable {
    private List<String>        alias;
   
    private void someMethod(){
           alias = new ArrayList(); // point 1
           .... etc etc
    }
}

Now the problem is :

When ever a variable is assigned to new ArrayList() i want it to be changed to new MyArrayList() instead

i.e..: the point 1 above changes to an eqvivalent of

alias = new MYArrayList();

I am able to get this done

aspect abc {
    pointcut listCut(Interceptable m, IN in):target(m) && set(java.util.List+ *);
    after(Interceptable m, IN in):listCut(m,in){
          UserAttributes.setAlias( new MyArrayList());
    }
}

but the point cut is getting very class specific. I have abt 1000 classes which have to be modified this way where ever the ArrayList is being used, now with this approach i need to write 1000 files; isnt there a generic way to do this?

Any pointers/ help ? please suggest.

regards,
ravi