[問題] 關於動態代理
當我操作動態代理物件的時候, 底層會自動呼叫實作InvocationHandler的物件的invoke(),
invoke : public Object invoke(Object proxy, Method method, Object[] args)
此時再透過invoke()方法內自己定義的 method.invoke(sub, args);
來呼叫sub物件(被代理類別)的method方法 (這邊method是指前兩行invoke()的參數)
一般反射取得方法的方法是
Method method = classType.getDeclaredMethod("sayHello",
new Class[]{String.class});
我想請問, invoke()中的Method method底層是如何取得的,
我並沒傳入方法名稱啊, Method method是如何獲得的 ?
--
感謝大家的推文
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.69.59.91
※ 文章網址: https://www.ptt.cc/bbs/java/M.1433415481.A.B30.html
※ 編輯: tas72732002 (114.34.181.227), 06/04/2015 22:05:59
→
06/04 22:56, , 1F
06/04 22:56, 1F
→
06/05 11:28, , 2F
06/05 11:28, 2F
java 近期熱門文章
PTT數位生活區 即時熱門文章