public class MethodExecutionCounterProxy implements InvocationHandler {
private Object target;
private int count = 0;
public MethodExecutionCounterProxy(Object target) {
this.target = target;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
count++;
System.out.println("Method " + method.getName() + " has been called " + count + " times.");
return method.invoke(target, args);
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-
上一篇:返回栏目
下一篇:java记录main方法执行次数