[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] proxying subclasses
|
Wes Isberg wrote:
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"; }
};
}
But would you really want to create a proxy here? It seems to me if
you're explicitly making 'me' a subclass of Foo, you wouldn't want to
replace it with a possiblly imcompatible subclass created from
Foostub.create(..). But, if the advice were inlined your solution above
would work, I think.
Jeff
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
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
--
Jeffrey Palm --> http://www.ccs.neu.edu/home/jpalm