Array element set pointcut. Is there a workaround?
I just read that it is not possible to define a pointcut on a single array element (bug link). Considering I really need to detect an array element modification, I would like to know if there is any workaround for this kind of problem (a pattern or something).
Something like what is described in this article
public class FieldPointcuts {
static int ar[];
public static void main(String[] args) {
ar = new int[] {100}; //set
ar[0] = 200; //get
}
}
and advice
before(int i, Object s, Object[] a):
arrayset() && args(i, s) && target(a)
{
Syst开发者_运维技巧em.out.println (" Arrayset:["+i+"/"+(a.length-1)+"] = "+s) ;
}
Thanks in advance.
Unfortunately, there is nothing I can think of that will work. The best that I can think of would be to use Lists instead of arrays, but if you are weaving into third party code, this would not be possible.
精彩评论