On Sep 4, 2007, at 1:49 PM, Phil Borlin wrote:
I bit the bullet and got the debugger out and figured out where the
i nvalid memory access error was occurring. I don't know why this
is the case but I was able to map my first char pointer to a String
and the char array to a String, but on my 3rd and 4th char pointers
I had to map to Pointer to get rid of the error. Everything is
working beautifully now! JNA is really fun to use unlike every
other native solution I have ever tried to use.
We've tried hard to make the easy and common things trivial and
everything else just a matter of a little more Java code (patterns,
not boilerplate). Thanks for the feedback!
char * psz_device;
char psz_cachefile[PATH_MAX];
char * psz_block;
char * psz_error;
Maps to:
public String psz_device;
public String psz_cachefile;
// public String psz_block;
public Pointer psz_block;
// public String psz_error;
public Pointer psz_error;
It all depends on how your native code uses the pointers. String is
technically mapped to "const char*", meaning the native code is only
going to read the memory. Native writes are ignored, unless they
write outside the allocated string, which usually crashes the VM.
What are the psz_block/error parameters for, and how are they used?
Did you initialize pointers to pass, or just use "null"?