import java.lang.reflect.*; interface Foo {} interface Bar {} class FooBar1 implements Foo, Bar {public String toString() { return "FooBar1"; }} class FooBar2 implements Foo, Bar {public String toString() { return "FooBar2"; }} class FooBar { static T getFooBar1() { return (T) new FooBar1(); } static T getFooBar2() { return (T) new FooBar2(); } static T getFooBar() { return (T) Proxy.newProxyInstance( Foo.class.getClassLoader(), new Class[] { Foo.class, Bar.class }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) { return "PROXY!!!";}}); } static void show(U u) { System.out.println(u); } public static void main(String[] args) { show(getFooBar()); show(getFooBar1()); show(getFooBar2()); } }