![](/img/trans.png)
[英]Convert from clojure.lang.LazySeq to type org.apache.spark.api.java.JavaRDD
[英]ClassCastException when returning LazySeq from Clojure to Java
我有Clojure函數返回一個LazySeq。 當我從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。 問題是它試圖存儲在一個數字中,雖然我看不到這段代碼中的位置。
沒關系。 我發現了這個問題。 有一個舊版本的.class文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.