I'm pretty sure you're right. I have a MWE below that shows an unintuitive difference. Thx. --Brad
(defun void-function ()
(let* ((result (jstatic "square" "Main" 32)))
(format t "in void-function, result of calling square(32): ~a~%" result)))
(defun void-function-short ()
(let* ((result (jstatic "squareshort" "Main" 16)))
(format t "in void-function, result of calling squareshort(16): ~a~%" result)))
(void-function)
(void-function-short)
import org.armedbear.lisp.*;
public class Main
{
public static int square(int a) {
return a * a;
}
public static int squareshort(short a)
{
return a * a;
} } $ java -cp ~/abcl_excel_gen/abcl-bin-1.6.0/abcl.jar:. org.armedbear.lisp.Main Armed Bear Common Lisp 1.6.0
Java 11.0.1 Oracle Corporation
Java HotSpot(TM) 64-Bit Server VM
Low-level initialization completed in 0.295 seconds.
Startup completed in 1.663 seconds.
Type ":help" for a list of available commands.
CL-USER(1): (load "lispfunctions.lisp")
in void-function, result of calling square(32): 1024
Error loading /Users/bknotwel/abcl_excel_gen/bug/lispfunctions.lisp at line 11 (offset 358)
#<THREAD "interpreter" {560A10B3}>: Debugger invoked on condition of type ERROR
no such method
Restarts:
0: TOP-LEVEL Return to top level. [1] CL-USER(2):
On Tuesday, November 26, 2019, 3:53:11 PM PST, Mark Evenson evenson@panix.com wrote:
On Nov 26, 2019, at 18:38, Brad Knotwell bknotwell@yahoo.com wrote:
I've been using ABCL to get access to a Java library and it's worked generally well. I have run into one problem I haven't been able to workaround.
I need to make a call to a method that takes a short as an argument. I'm passing in a value--10--that fits in a short but ABCL can't find the method (presumedly due to a type issue). I've tried using jcoerce but it's not doing what I expect. What's the right way to do this?
This is probably a bug in how the Bear’s FFI converts the “10” when it attempts to locate your specific Java call site, but without a test the contains the Java code that you are calling into diagnosing exactly what is going in is difficult.
When I get the time (or unless someone beats me to it), I will try to make such a test to figure out what is going on.
We could certainly do with a test suite that combinatorally probes our call site location logic.