9 messages in net.java.dev.jna.usersRe: Structure ... has unknown size
FromSent OnAttachments
Peter NabbefeldApr 20, 2008 3:33 am 
Timothy WallApr 20, 2008 4:52 am 
Peter NabbefeldApr 20, 2008 11:01 am 
Timothy WallApr 20, 2008 1:40 pm 
Peter NabbefeldApr 20, 2008 1:42 pm 
Timothy WallApr 20, 2008 2:11 pm 
Peter NabbefeldApr 20, 2008 10:38 pm 
Peter NabbefeldApr 20, 2008 10:38 pm 
Timothy WallApr 23, 2008 6:12 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Structure ... has unknown sizeActions...
From:Peter Nabbefeld (Pete@gmx.de)
Date:Apr 20, 2008 10:38:58 pm
List:net.java.dev.jna.users

Timothy Wall wrote:

On Apr 20, 2008, at 4:43 PM, Peter Nabbefeld wrote:

I've now tried 3.0 (because there's a src.zip for it, needed for debug), and now I've got other problems. The exception I've got before (from 3.02) might be a bug.

Current problem is "Exception in thread "main" java.lang.IllegalStateException: Array fields must be initialized"

The only array in a Structure not yet initialized is declared as "public StructUsbDevice.ByReference[] children;"

The original c code is "struct usb_device **children;"

It will be hard to initialize this array ... What do I have to do?

Arrays within a Java Structure are inlined, which is not what you want. Use a Pointer and use the getXXX methods to extract the information you need.

public Pointer children;

...

usb_device first = new usb_device() { { useMemory(s.children.getPointer(0)); }}; usb_device[] kids = (usb_device[])first.toArray(length);

Thank You for the guidance - at least, my test app now starts :-)

Kind regards

Peter