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[]?