#251: ffi callbacks don't unbox integer values -----------------------+---------------------------------------------------- Reporter: sboukarev | Owner: nobody Type: defect | Status: new Priority: major | Milestone: 1.1.0 Component: java | Version: 1.1.0-dev Keywords: | -----------------------+---------------------------------------------------- It very well may be a cffi issue.
Compile the following C code with gcc -shared test.c -o test.so
{{{ #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT #endif
DLLEXPORT short test(short (*f)(short, short)) { return f(23, 24); } }}}
Then
{{{ (cffi:load-foreign-library "/tmp/test.so")
(cffi:defcfun test :short (function :pointer))
(cffi:defcallback (test-callback) :short ((a :short) (b :short)) (+ a b))
}}}
And finally
{{{ (test (cffi:get-callback 'test-callback)) => The value #<java.lang.Short 23 {5EE76547}> is not of type NUMBER. }}}
That's on 64-bit x86 linux, with OpenJDK 1.6.0_24 and jna downloaded by maven.