[armedbear-devel] multidimensional java arrays?

Mark Evenson evenson at panix.com
Thu Feb 6 14:47:21 UTC 2014


On Feb 6, 2014, at 2:52, Cyrus Harmon <ch-lisp at bobobeach.com> wrote:

> I am trying to connect ABCL up with some java code that uses multidimensional arrays of the form:
> 
>        int[][] theArray = new int[4][4];
> 
> The problem is that when I call this code I get something like this in return:
> 
> 	#(#<jarray [I at 2d983837 {6492BA43}> #<jarray [I at 5d02b84a {5D9131FA}> #<jarray [I at 67684413 {6E4D706E}> #<jarray [I at 1e107e55 {4CD60DDE}>) 
> 
> that is a lisp array that contains 4 java arrays. I can’t pass this off to a method like this:
> 
>    static public int[][] arrayTest2(int[][] oldArray) {
>>    }
> 
> I can work around this by creating a new java array myself (and populating it appropriately), but this is no fun. Is this the intended behavior?

Regardless of whether this behavior was intended—for which I can find no evidence—it certainly seems wrong given that for the Java class:

public class Array {
  public static int[][] getMultiDimensional() {
    return new int[4][4];
  }
  
  public static int[][] returnRef(int[][] ref) {
    return ref;
  }
}

Compiled with javac, (java:add-to-classpath “~/directory/“), then the following

CL-USER> (java:jnew-array "int" 4 4)
#<jarray [[I at 2e9e32cc {141906FD}>
CL-USER> (jstatic "returnRef" "Array" *)
#(#<jarray [I at 4147aa25 {47F3849E}> #<jarray [I at 4487c5f9 {2DD68195}>
  #<jarray [I at 5dd574b5 {68E14733}> #<jarray [I at 1e099b10 {8A346D8}>)

shows that we are clearly getting a different sort of Lisp object than we pass into the Java FFI for what should be a symmetric reflection.

Filed as [ticket-347][].


[ticket-347]: http://abcl.org/trac/ticket/347



-- 
"A screaming comes across the sky.  It has happened before but there is nothing 
to compare to it now."








More information about the armedbear-devel mailing list