@Test public void testPrivateConstructorUsingReflection() { new AssertThrows(new IllegalArgumentException( "Could not create a new proxy instance for the base class " + PrivateConstructor.class.getName() + " (probably because Objenesis is not used)")) { public void test() { createProxy(PrivateConstructor.getInstance(10), true).toString(); }}; }
@Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; }
CglibProxyFactory extends ProxyFactory { @Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; } }
CglibProxyFactory extends ProxyFactory { @Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; }  }
CglibProxyFactory extends ProxyFactory { @Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; }  ObjectCreator getObjectCreator(); void setUseObjenesis(boolean useObjenesis); @Override @SuppressWarnings("unchecked") T createProxy(T obj, final InvocationHandler handler); }
CglibProxyFactory extends ProxyFactory { @Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; }  ObjectCreator getObjectCreator(); void setUseObjenesis(boolean useObjenesis); @Override @SuppressWarnings("unchecked") T createProxy(T obj, final InvocationHandler handler);  }