JDK动态代理
public class JDKProxy2 implements InvocationHandler { private Object targetObject; public Object JDKProxy2(Object targetObject) { this.targetObject = targetObject; return Proxy.newProxyInstance(targetObject.getClass().getClassLoader(), targetObject.getClass().getInterfaces(), this); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("1"); Object obj = method.invoke(targetObject, args); System.out.println("2"); return obj; } }