这么改是能把问题解决了,但是Collection.class.getInterfaces()这个返回的就是一个Class[]数组噢 。而且张老师的一个方法中也有这样的应用噢
- private static Object getProxy(final Object target, final Advice advice) {
- Object proxy = Proxy.newProxyInstance(target.getClass()
- .getClassLoader(), target.getClass().getInterfaces(),
- new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method,
- Object[] args) throws Throwable {
- // TODO Auto-generated method stub
- advice.beginMethod();
- Object retVal = method.invoke(target, args);
- advice.endMethod();
- return retVal;
- }
- });
- return proxy;
- }
复制代码 |