Building simple proxies In the previous post I introduced Java dynamic proxies, and sketched out a way they could be used in testing to simplify the generation of custom Hamcrest matchers. In this post, Iâ™m going to dive into some techniques for implementing proxies in Java 8. Weâ™ll start with a simple case, and build up towards something more complex and full-featured. Consider an instance of java.reflection.InvocationHandler that simply passes every method call through to an underlying instance: public class PassthroughInvocationHandler implements InvocationHandler { private final Object target; public PassthroughInvocationHandler(Object target) { this.target = target; } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return method.invoke(target, args); } } To create a proxy using this invocation handler, we use the newProxyInstance static utility method on the java.reflection.Proxy class: @Sup...