@Test public void testJavaUtilList() { List<String> list = new ArrayList<String>(); createProxy(list).size(); assertEquals("size = 0", buff.toString()); }
@SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { throw new IllegalArgumentException( "Can not create a proxy using the " + InterfaceProxyFactory.class.getSimpleName() + ", because the class " + c.getName() + " does not implement any interfaces"); } return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, handler); }
InterfaceProxyFactory extends ProxyFactory { @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { throw new IllegalArgumentException( "Can not create a proxy using the " + InterfaceProxyFactory.class.getSimpleName() + ", because the class " + c.getName() + " does not implement any interfaces"); } return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, handler); } }
InterfaceProxyFactory extends ProxyFactory { @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { throw new IllegalArgumentException( "Can not create a proxy using the " + InterfaceProxyFactory.class.getSimpleName() + ", because the class " + c.getName() + " does not implement any interfaces"); } return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, handler); }  }
InterfaceProxyFactory extends ProxyFactory { @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { throw new IllegalArgumentException( "Can not create a proxy using the " + InterfaceProxyFactory.class.getSimpleName() + ", because the class " + c.getName() + " does not implement any interfaces"); } return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, handler); }  static InterfaceProxyFactory getInstance(); @SuppressWarnings("unchecked") T createProxy(T obj, final InvocationHandler handler); }
InterfaceProxyFactory extends ProxyFactory { @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { throw new IllegalArgumentException( "Can not create a proxy using the " + InterfaceProxyFactory.class.getSimpleName() + ", because the class " + c.getName() + " does not implement any interfaces"); } return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, handler); }  static InterfaceProxyFactory getInstance(); @SuppressWarnings("unchecked") T createProxy(T obj, final InvocationHandler handler);  }