6 messages in net.java.dev.jna.usersRE: [jna-users] how to set a pointer
FromSent OnAttachments
Glick, Gene (GE Indust, Security)Sep 19, 2007 2:02 pm 
Timothy WallSep 19, 2007 2:55 pm 
Glick, Gene (GE Indust, Security)Sep 20, 2007 9:00 am 
Albert StrasheimSep 20, 2007 9:23 am 
Timothy WallSep 20, 2007 9:30 am 
Glick, Gene (GE Indust, Security)Sep 20, 2007 11:23 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: [jna-users] how to set a pointerActions...
From:Glick, Gene (GE Indust, Security) (gene@ge.com)
Date:Sep 20, 2007 11:23:43 am
List:net.java.dev.jna.users

Look at ByteBuffer.wrap (a static method).

Yep - missed that. Thanks.

Since your C method is expecting a pointer to uint8_t, you can safely declare the argument on the Java side as "byte[]". No conversion necessary. I'd recommend changing the Java interface definition to be more precise.

OK, so this is ok? I'll try it.

in C it goes something like this: a) byte buf[10]; b) byte *ptrBuf; c) ptrBuf = &buf[0]; d) someMethod(uint8_t *ptrBuf); in Java, using the JNA it goes something like this: a) byte [] buf = new byte[10];

b) write someMethod as follows: public void someMethod(byte [] buf);

c) then call

someInstance.someMethod(buf);