Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassCastException when returning LazySeq from Clojure to Java

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?

like image 459
Paul Reiners Avatar asked Dec 30 '25 11:12

Paul Reiners


1 Answers

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.

like image 172
Thomas Avatar answered Jan 01 '26 00:01

Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!