@Test public void testObject() { new AssertThrows(new IllegalArgumentException( "Can not create a proxy using the InterfaceProxyFactory, " + "because the class java.lang.Object does not implement any interfaces")) { public void test() { createProxy(new Object()).equals(null); }}; }
@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);  }