Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] empty around advice to completely remove method calls

I would like to be able to completely remove some method
calls in my program.  I'm thinking I can use empty around
advice to do this but some additional code is still weaved
in where the call is made.  (Btw, the motivation for this
is to remove logging atatements to get accurate performance
results.)

For example, let's say I want to remove the call to foo()
in the class Main in the example below:

public class Main {
    public void callTest() {
        Test t = new Test();
        t.foo();
    }
}

public class Test {
    public void foo() {
        System.out.println("foo");
    }
}

... and I attempt to do so with this aspect:

public aspect RemoveCall {
    pointcut remove( ): 
        call( public void Test.foo()) && this(Main);
    void around( ): remove() {
    }
}

After compiling with ajc 1.0 and the preprocess option, the
Main class becomes:

public class Main {
  public void callTest() {
    Test t = new Test();
    this.foo$method_call(t);
  } 

  public Main() {
    super();
  } 
  public final void around1_foo$method_call(final
org.aspectj.runtime.internal.AroundClosure 
      ajc$closure, final RemoveCall this_, final Test
target) {
  } 

  private void foo$method_call(Test target) {
   
this.around1_foo$method_call(((org.aspectj.runtime.internal.AroundClosure)(null)),

        RemoveCall.aspectInstance, target);
  } 

} 

So as you can see, all this extra code is added but I just
want AspectJ to remove the call altogether.  Is there
another way to do this?

Thanks,

Mark

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com


Back to the top