2 Replies Latest reply on Jun 17, 2005 3:10 PM by Bill Burke

    Infinite loop when applying caller aspects

    Ben Livshits Newbie

      I have been using caller aspects successfully until it came to instrumenting calls to some Swing classes.

      In particular, the method I am instrumenting is javax.swing.JTable->addNotify. The interceptor method looks as follows:

       public Object invoke(Invocation invocation) throws Throwable {
       // log.println("Hit " + invocation);
      
       if(invocation instanceof CallerInvocation){
       CallerInvocation cinvocation = (CallerInvocation)invocation;
      
       process_call(cinvocation);
       }else{
       System.err.println("Unexpected " + invocation);
       }
      
       try{
       return invocation.invokeNext();
       }finally{
       //System.err.println("Failed...");
       }
       }
      


      and the problem is that the return statement invocation.invokeNext causes method invoke() to be called on the same method as before leading to an infinite loop.

      Any thoughts?