Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] proxying subclasses

Normally you can supply a stub/mock/proxy as follows:

  Foo around() : call(Foo.new(..)) {
      return FooStub.create(thisJoinPoint.getArgs());
  }

but this fails to handle subclasses, esp. anonymous ones:

  void someMethod() {
      Foo me = new Foo("foo") {
          public String toString() { return "bar"; }
      };
  }

The only alternative seems to be some combination of advising all the target method-call and field g/set join points, or using declare-parents to interpose the stub:

  declare parents (Foo+ && !Foo) : FooStub;

Both of those have their own drawbacks.

Can anyone think of a good workaround?

Wes



Back to the top