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 9:00:59 am
List:net.java.dev.jna.users

I'm confused. ByteBuffer is an abstract class. To use it means writing all its
methods first, right? Seems like a lot of work.

Let me be a little more specific in what I'm trying to do:

1. In some java code, I have created a 'byte[] buf' of data. 2. In some c shared library (.dll) the method is looking for a passed parameter
of 'uint8_t *buf' 3. The jna header file (not written by me, but could be modified if need be) is
looking for type 'Pointer buf'.

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) Pointer ptrBuf = new Pointer(); c) *** here's where I am lost *** d) someInstance.someMethod(Pointer ptrBuf);

So, how to get the Pointer to be set to &buf[0]?

thanks,

gene

-----Original Message----- From: Timothy Wall [mailto:twal@dev.java.net] Sent: Wednesday, September 19, 2007 5:56 PM To: use@jna.dev.java.net Subject: Re: [jna-users] how to set a pointer

Use ByteBuffer.wrap() and declare the argument type as "Buffer", if declaring the argument type as byte[] isn't appropriate in your case.

Pointer is kind of a fallback when nothing else really fits.

On Sep 19, 2007, at 5:02 PM, Glick, Gene (GE Indust, Security) wrote:

I have a java byte[] and need to make a pointer to it in jna. Creating a new Pointer seems easy enough, but how do I set the pointer to point at the byte[]?