After this, now I want handler to be castable to a different interface, let's say Iface2.
If I try to do so:
Iface2 try = (Iface2)handler;
it will throw a class cast exception. I know I could create a new proxy, but that won't work for me because I may already have places in the code that have a reference to this specific instance.
So, either I want to be able to magically make the handler instance castable to a new type, or... is there some way in the initial creation of handler that I could make it castable to any anything to begin with?
I want a proxy that is castable to anything (or that I can add things at runtime)--any calls to it go to InvocationHandler.invoke anyway, so... casting doesn't matter.