public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Zachary Kurmas <kurmasz@gvsu.edu>,
	Andy Keep via Kawa <kawa@sourceware.org>
Cc: Kawa Community <kawa@sourceware.org>
Subject: Re: ClassCastException (class java.lang.Integer cannot be cast to class gnu.math.IntNum)
Date: Fri, 24 Feb 2023 07:18:09 -0800	[thread overview]
Message-ID: <678da991-45f5-ed45-baff-456b27f10115@bothner.com> (raw)
In-Reply-To: <550c8c8b-d654-43cc-be7b-4e34d7606dac@Spark>

(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
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2023-02-24 15:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e65a1af5-112e-4874-9640-4878a79be01d@Spark>
2023-02-24 14:26 ` Zachary Kurmas
2023-02-24 15:18   ` Per Bothner [this message]
2023-02-24 15:41     ` Zachary Kurmas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=678da991-45f5-ed45-baff-456b27f10115@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    --cc=kurmasz@gvsu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).