public inbox for
 help / color / mirror / Atom feed
* Re: ClassCastException (class java.lang.Integer cannot be cast to class gnu.math.IntNum)
       [not found] ` <550c8c8b-d654-43cc-be7b-4e34d7606dac@Spark>
@ 2023-02-24 15:18   ` Per Bothner
  0 siblings, 0 replies; only message in thread
From: Per Bothner @ 2023-02-24 15:18 UTC (permalink / raw)
  To: Zachary Kurmas, Andy Keep via Kawa; +Cc: Kawa Community

(Please don't use Reply-to without the list.  If you post a question to the
list, the answer should also go to the list, with few exceptions.  One reason
is to avoid wasting people's time if multiple people answer.)

On 2/24/23 06:26, Zachary Kurmas via Kawa wrote:
> Does anybody recognize this exception:
> java.lang.ClassCastException: class java.lang.Integer cannot be cast to class gnu.math.IntNum (java.lang.Integer is in module java.base of loader 'bootstrap'; gnu.math.IntNum is in unnamed module of loader 'app')

If it helps: java.lang.Integer is the standard "boxing" (i.e. conversion to Object) of 32-bit int values.
gnu.math.IntNum handles "infinite-precision" integers. It is like (but predates) java.math.BigInteger,
but with some optmizations and it is part of the gnu.math.Numeric hierarchy, which is used
to implement the Scheme "number tower".

Kawa can certainly convert java.lang.Integer to gnu.math.IntNum but it needs to actually
generate some code to do so - it can't just use a primitive cast. if you have Java code
that calls a Kawa method that expects a gnu.math.IntNum you may have to do the
conversion yourself.  (If you call the method indirectly as a Kawa Procedure object,
using one of the 'apply' method, I believe the 'apply' glue should be able to take
care of the conversion - but I'm not 100% sure.)

> So, trying to isolate the bug makes it go away.  Also, when connect4.scm calls connet4_engine.scm the stack trace does not contain line numbers of connect4_engine, so I don’t have a good sense of where the bug is popping up.

Are you getting a stack trace? If not, that might be helpful.
	--Per Bothner

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-24 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <e65a1af5-112e-4874-9640-4878a79be01d@Spark>
     [not found] ` <550c8c8b-d654-43cc-be7b-4e34d7606dac@Spark>
2023-02-24 15:18   ` ClassCastException (class java.lang.Integer cannot be cast to class gnu.math.IntNum) Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).