關于作業的問題
關于作業的代碼實現: InvocationHandler logh=new LogHandler(m); Class
cls2=m.getClass(); Moveable m2=(Moveable)Proxy.newProxyInstance(cls2.getClassLoader(),cls2.getInterfaces(),logh); m2.move(); 請問一下,以上實現方式有啥問題,為什么會報錯?
關于作業的代碼實現: InvocationHandler logh=new LogHandler(m); Class
cls2=m.getClass(); Moveable m2=(Moveable)Proxy.newProxyInstance(cls2.getClassLoader(),cls2.getInterfaces(),logh); m2.move(); 請問一下,以上實現方式有啥問題,為什么會報錯?
2017-08-28
舉報
2021-04-07
2018-04-29
代理類實現的都是moveable接口,所以Class<?> cls = Car.getClass()這一行代碼不用更改,刪掉
Class?cls2=m.getClass();類加載器和接口換回cls就好。
2018-01-24
JDK 動態代理作業可以參考這個
https://github.com/imooc-java/proxy/blob/master/src/test/java/com/imooc/jdkproxy/HandlerTest.java
2017-08-30
有什么錯誤,你貼出來塞
2017-08-29
第二行應該改成 Class<?> clsw = m.getClass();