[armedbear-devel] Adjustable arrays and Java

Theam Yong Chew senatorzergling at gmail.com
Wed Jul 20 09:56:12 UTC 2011


Hi all,

I might have found an interop issue with adjustable arrays. First create an
adjustable array with some "empty unfilled space".

(defparameter *arr*
  (let ((x (make-array 0
            :fill-pointer 0
            :adjustable   t
            :element-type 'base-char)))
    (vector-push-extend #\a x)
    (vector-push-extend #\b x)
    (vector-push-extend #\c x)
    (vector-push-extend #\d x)
    x))

Pass the array into Java and copy it back into Lisp.

CL-USER> (jcall "getText" (jnew "javax.swing.JButton" *arr*))
"abcd^@^@^@"
CL-USER> (jcall "getText" (jnew "javax.swing.JButton" (copy-seq *arr*)))
"abcd"

I've hand edited the above -- the ^@ character is actually a #\Null
of course.

More examples:

CL-USER> (jnew "java.lang.String" *arr*)
#<java.lang.String abcd^@^@^@ {F10A53}>


Yong.




More information about the armedbear-devel mailing list