Skip to content

Instantly share code, notes, and snippets.

@ncornette
Last active November 16, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncornette/1e44d0d24e7eda0a38b3 to your computer and use it in GitHub Desktop.
Save ncornette/1e44d0d24e7eda0a38b3 to your computer and use it in GitHub Desktop.
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class DynamicProxy {
private static final InvocationHandler INVOKE_DO_NOTHING = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
};
public static <T> T create(Class<T> ifc) {
return (T) Proxy.newProxyInstance(ifc.getClassLoader(), new Class[]{ifc}, INVOKE_DO_NOTHING);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment