About pointcut

Kawtip Nippon <[email protected]>
Newsgroups gmane.comp.programming.aspect.general
Message-ID <[email protected]>
Dear all, 
   
       I'd like to ask some more questions. From this quotation from aspectj tutorials... 
  --------------------------------------------------------
  When matching method-execution join points, if the execution pointcut method signature specifies a declaring type, the pointcut will only match methods declared in that type, or methods that override methods declared in or inherited by that type. So the pointcut 

  execution(public void Middle.*())  
  picks out all method executions for public methods returning void and having no arguments that are either declared in, or inherited by, Middle, even if those methods are overridden in a subclass of Middle. So the pointcut would pick out the method-execution join point for Sub.m() in this code: 

  class Super {      protected void m() { ... }    }    class Middle extends Super {    }    class Sub extends Middle {      public void m() { ... }    }

--------------------------------

   I try to write some code to test. This is the code...

--------------------------------------------------------

class TestAccessModifiers {

 public void printA(){
  System.out.println("A");
 }
}
class Level2 extends TestAccessModifiers{
 
}
class Level3 extends Level2{
 public void printA(){
  System.out.println("Level3 protected");
 }
 public static void main(String[] args){
  Level2 l2 = new Level2();
  l2.printA();
  Level3 l3 = new Level3();
  l3.printA();
  Level2 l22 = new Level3();
  l22.printA();
 }
  }

aspect CallMethods {
 pointcut exeM(): execution(public void Level2.*());
 before(): exeM(){
  System.out.println(thisJoinPoint);
 }
 
}
  --------------------------------------------------------
       and this is the result after i run the class (using ajdt with eclipse)
--------------------------------------------------------
  A
  execution(void p8.Level3.printA())
  Level3 protected
  execution(void p8.Level3.printA())
  Level3 protected
  --------------------------------------------------------
       I questioned that why the poincut can capture Level3.printA(). I thought that it can't capture this JoinPoint and it can capture this JoinPoint if the pointcut specify that execution(public void Level2+.*()) instead (+ should make the pointcut cover methods in Level3 class).
       And I wonder that why the pointcut can't capture a joinpoint l2.printA().
   
       Thank you very much in advance for you all,
  Kawtip

 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

_______________________________________________
discuss mailing list    -    [email protected]

To unsubscribe and change options, go to:
http://aosd.net/mailman/listinfo/discuss_aosd.net

Check out the AOSD.net Wiki: http://aosd.net/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.