This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: how to access elements of java array?


Victor,

To access Java array elements, use the primitive-array-get form:

(let* ((doc-parts (invoke
                    (as <org.outerj.daisy.repository.Parts>
          	            (invoke doc 'getParts))        
                    'getArray)))

  ((primitive-array-get <org.outerj.daisy.repository.Part>) doc-parts 0))

Cheers!

Dominique Boucher 
 

> -----Original Message-----
> From: kawa-owner@sourceware.org 
> [mailto:kawa-owner@sourceware.org] On Behalf Of Victor Anyakin
> Sent: Friday, December 16, 2005 8:48 AM
> To: kawa@sources.redhat.com
> Subject: how to access elements of java array?
> 
> Greetings once more,
> 
>   This time I have got a problem getting elements of a plain Java
>   array. I am trying to get elements of a plain java array in
>   following code:
> 
> (let* (
>  (doc-parts (invoke
>               (as <org.outerj.daisy.repository.Parts>
>                 (invoke doc 'getParts))        
>               'getArray)))
>   (log-info (array? doc-parts)) ; says false
>   (array-ref doc-parts 0) ; throws exception, below
> )
> 
> Invalid parameter, was: [Lorg.outerj.daisy.repository.Part;
> java.lang.ClassCastException: [Lorg.outerj.daisy.repository.Part;
> 			      at
>   gnu.kawa.functions.ArrayRef.applyN(ArrayRef.java:34)
>   at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
>   at gnu.kawa.functions.ArrayRef.apply2(ArrayRef.java:28)
>   at atInteractiveLevel$8.dsyCheckout(dsy.scm:58)
>   at atInteractiveLevel$8.apply0(dsy.scm:40)
> 
> 
>  the getParts method of the instance referred by doc variable returns
>   Part[] array.
> 
> 
>   What is the right way to access, get, set elements of plain java
>   arrays returned from the Java code?
> 
> With best regards,
> -- 
> Victor Anyakin                         ()  ascii ribbon campaign
>                                        /\    - against html mail
> 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]