java.lang.IllegalArgumentException:无法解析classname:FileReader

时间:2014-12-18 14:33:33

标签: exception macros clojure illegalargumentexception

我们正在尝试编写一些Clojure代码,并且我们在几分钟前成功编译了它,但现在我们得到了这个随机异常。

CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: FileReader, compiling:(myproject\core.clj:24:17) 

这是我们的代码:

(ns myproject.core)

(defmacro safe ([bindings & code] form)
 (if (list? bindings)
 `(try 
   ~bindings 
  (catch Throwable except# except#)) 

(if (= (count bindings) 0)
  `(try ~code 
     (catch Throwable except# except#)) 



`(let ~(subvec bindings 0 2)

 (try
   (safe ~(subvec bindings 2) ~@code)
   (catch Throwable except# except#) 

   (finally
     (. ~(bindings 0) close))))))) ;;safe


(def div(safe (/ 12 2)))
(def v (safe [s (FileReader. (java.io.File. "M:/test.txt"))] (. s read)))

1 个答案:

答案 0 :(得分:2)

我们发现了问题。

我们必须从java导入FileReader。

(import '(java.io FileReader File))