作业你们是怎么写的
InvocationHandler invocationHandler2=new LogHandler(moveable);
Class<?> class2 = moveable.getClass();
Moveable moveable2 =(Moveable)Proxy.newProxyInstance(class2.getClassLoader(), class2.getInterfaces(), invocationHandler2);
moveable2.move();
我是这么写的
Car car = new Car();
Class carClass = car.getClass();
InvocationHandler timeHandler = new TimeHandler(car);
Moveable proxy = (Moveable) Proxy.newProxyInstance(carClass.getClassLoader(),
carClass.getInterfaces(),timeHandler);
InvocationHandler logHandler = new LogHandler(proxy);
Moveable proxy2 = (Moveable) Proxy.newProxyInstance(proxy.getClass().getClassLoader(),
proxy.getClass().getInterfaces(), logHandler);
proxy2.move();
不能同时实现对时间的代理和对日志的代理吗?使得输出结果和静态聚合代理一样的。