ClassCastException when returning LazySeq from Clojure to Java
-
27-10-2019 - |
Question
I have Clojure function that returns a LazySeq. When I run this function from the REPL, it works just fine. However, if I try to call the same function from Java code like this:
Object result = com.acme.forecast.core.runforecast("file1.csv", "file2.txt");
I get the following exception:
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)
My gen-class says I'm returning a LazySeq, not a Number:
(:gen-class
:name com.acme.forecast.core
:methods [#^{:static true} [runforecast [String String] clojure.lang.LazySeq]])
What is going wrong here?
Solution
The error does say you're returning LazySeq. The problem is that it's trying to get stored in a Number, though I can't see where in this code segment.
OTHER TIPS
Never mind. I found the problem. There was an old version of the .class file lying around.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow