如何键入此反射警告?

时间:2009-10-06 09:48:27

标签: reflection clojure

(set! *warn-on-reflection* true)
(proxy [javax.swing.JPanel] []
  (paintComponent [#^java.awt.Graphics g]
    (proxy-super paintComponent g)
    (.fillRect g 100 100 10 10)))

“反射警告,无法解析对paintComponent的调用”

2 个答案:

答案 0 :(得分:3)

看起来警告是针对该行

(proxy-super paintComponent g)

javax.swing.JPanel的父类是否有paintComponent方法?

删除该行对我有用。

答案 1 :(得分:1)

因为proxy-super使用隐式this

(let [^javax.swing.JPanel this this]
  (proxy-super paintComponent g))