I use java.lang.reflect.Proxy
to proxy objects.
I have this class:
public class TransportableImpl extends Transportable{
public class OrderInvoker extends InvocationHandler{
...
}
}
Here i build the Proxy:
Transportable t = new TransportableImpl();
Order myOrder = new OrderImpl();
Class proxyClass = Proxy.getProxyClass(getClass().getClassLoader(), Transportable.class, Order.class);
Object serializable = proxyClass.getConstructor(new Class[]{InvocationHandler.class}).newInstance(t.new OrderInvoker(myOrder));
Problem is: Class is raw type and
Class<? extends Order & Transportable> proxyClass =
(Class<? extends Order & Transportable>)
Proxy.getProxyClass(getClass().getClassLoader(),
Transportable.class, Order.class);
is hard to read.
Any ideas?