On Thu, Jan 8, 2009 at 2:43 PM, 100ji <
itz100ji@xxxxxxxxx> wrote:
> Hi all,
>
> I am writing a pointcut whose spec is as follows: "Instrument all add and
> remove calls on a field f of type java.util.Set in class C".
>
> So for example if I have a TestClass like the one below,
>
> public class TestClass {
>
> Event e;
> TestInnerClass ic ;
> Set<Event> s;
> Set<Event> dummy_set;
>
> public boolean addToSet(Event e) {
> s.add(e);
> return dummy_set.add(e);
> }
> }
>
> I want to track all the adds to the field s but not to dummy set. I have
> tried the following approaches:
>
> pointcut p2(Object o) : call(* java.util.Set.add(..)) &&
> target(TestClass.s);
>
> pointcut p2(Object o, Object newValue) :
> args(newValue) && this(o) &&
> target(TestClass.s) &&
> call(* java.util.Set.add(..));
>
> pointcut p2(Object o, Object newValue) :
> args(newValue) && this(o) &&
> call(java.util.Set TestClass.s.add(..));
>
> Obviously, None of these approaches work as expected. Can anyone tell me
> what I am missing?
>
> TIA,
> -S-
>