我有一个返回 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]])
这里出了什么问题?
最佳答案
错误确实表明您正在返回 LazySeq。问题是它试图存储在一个数字中,但我看不到这段代码中的位置。
关于java - 将 LazySeq 从 Clojure 返回到 Java 时出现 ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9335667/