1import java.io.Serializable;
2import java.lang.reflect.InvocationHandler;
3import java.lang.reflect.Method;
4import java.lang.reflect.Proxy;
5import java.util.ArrayList;
6
7public class TransferableList extends ArrayList {
8    private static class NullInvocationHandler implements InvocationHandler, Serializable {
9        public Object invoke(Object proxy, Method method, Object[] args)
10          throws Throwable {
11            throw new Error("UNIMPLEMENTED");
12        }
13    }
14
15    public TransferableList() {
16        try {
17            InvocationHandler handler = new NullInvocationHandler();
18            Class<?> proxyClass = Proxy.getProxyClass(
19                ListInterface.class.getClassLoader(),
20                new Class[] { ListInterface.class, AnotherInterface.class });
21            AnotherInterface obj = (AnotherInterface) proxyClass.
22                    getConstructor(new Class[]{InvocationHandler.class}).
23                    newInstance(handler);
24        } catch (Exception e) {
25            e.printStackTrace();
26        }
27    }
28}
29
30interface ListInterface extends Serializable {}
31