[armedbear-devel] Adjustable arrays and Java

Erik Huelsmann ehuels at gmail.com
Wed Jul 20 10:10:25 UTC 2011


Hi Yong,

Thanks for the report!

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.
>

I think you're right. Could you try this patch to see if that solves your
issue:

Index: ComplexString.java
===================================================================
--- ComplexString.java (revision 13405)
+++ ComplexString.java (working copy)
@@ -330,7 +330,7 @@
   @Override
   public Object javaInstance()
   {
-    return new String(chars());
+    return new String(getStringValue());
   }

   @Override


If it does, I'll commit and backport to 0.26.1.



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

Erik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20110720/50f5362c/attachment.html>


More information about the armedbear-devel mailing list