Hi,

I am looking for the point-cut for contains method (line 9) in the following Java code:

   Collection<String> c;
   c = new ArrayList<String>();
   c.add("x");
   c.add("y");

   String s;
   s = "z";

   if(!c.contains(s)) {
        c.add(s);
   }


This Pointcut works:

   public aspect DequeAspect {

      pointcut test(Collection c, String s): target(c) &&
                                             args(s) &&
                                             call(* Collection.contains(..));

      after(Collection c, String s): test(c, s) {
         System.err.println("AFTER: "+c.toString()+" CONTAINS "+s);
      }
   }


After a look at the page <Appendix B. Language Semantics>
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html

It seems to be that the wildcard '..' in the contains Method can also be a TypePattern.

But I tested :
   pointcut test(Collection c, String s): target(c) && args(s) &&
                                          call(* Collection.contains(String));

and that is not working (I also tried Object+ or String+).


In this example, using the wildcard is not big deal, but what if you just want to test the Type of the argument (without exposing this values) :
   pointcut test(Collection c): target(c) &&
                                call(* Collection.contains(String));

produce a AdviceDidNotUsed warning (on the Advice using this pointcut)


How do you define correctly the MethodPattern (especially the TypePattern) without the wildcard '..'? Is that possible?


Regards,

Jérémie



_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to