3

我有返回 LazySeq 的 Clojure 函数。当我从 REPL 运行这个函数时,它工作得很好。但是,如果我尝试从 Java 代码中调用相同的函数,如下所示:

Object result = com.acme.forecast.core.runforecast("file1.csv", "file2.txt");

我得到以下异常:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: 
  clojure.lang.LazySeq cannot be cast to java.lang.Number
    at com.acme.forecast.core.runforecast(Unknown Source)
    at com.acme.forecast.client.gui.ClientGUI.actionPerformed(ClientGUI.java:180)

我的 gen-class 说我返回的是 LazySeq,而不是数字:

  (:gen-class
    :name com.acme.forecast.core
    :methods [#^{:static true} [runforecast [String String] clojure.lang.LazySeq]])

这里出了什么问题?

4

2 回答 2

3

该错误确实表明您正在返回 LazySeq。问题是它试图存储在一个数字中,尽管我看不到这个代码段的位置。

于 2012-02-17T21:40:23.090 回答
1

没关系。我发现了问题。有一个旧版本的 .class 文件。

于 2012-02-17T21:51:04.493 回答