Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] around advice on constructors

Hi,

I'm trying to replace all newly created instances of an interface (Iface) with 
dynamic proxies which delegate to the actual new instance.
This is pretty straight forward if I mandate that all instances must be 
created through factories with a well-known method which returns Iface 
(rather than IfaceImpl).

Ideally I would like to be able to use code like the following:

Iface if = new IfaceImpl();

and an around() which creates a Proxy implementing the classes implemented by 
the result of proceed()

unfortunately this results in a ClassCastException, the dynamic proxy is not 
an instance of IfaceImpl, only Iface.

Does anybody know of any chicanery which might allow me to do this?

Thanks
Daniel


Back to the top