Strings are converted automatically to native C representation (NUL-
terminated array of char). You don't need to do anything special.
If for some reason you absolutely need a character buffer (the native
code modifies the buffer contents, for instance), use
Native.toCharArray(String) or Native.toByteArray(String), depending on
whether you need wide characters or not.
On Nov 3, 2008, at 3:34 PM, Kolonay, Raymond M Civ USAF AFMC AFRL/RBSD
wrote:
Hi Tim,
More jna questions. I was trying to use the class NativeString to
pass a
java String to c as an array of char. First issue I ran into is that
NativeString is not a public class. Is this a bug? The API says that
it
is public but the source does not declare the class as public. I tried
to change the class to public and rebuild the jna jar file. I was able
to do this but I then got a runtime error
java.lang.IllegalArgumentException: Unsupported argument type
com.sun.jna.NativeString in the
con.sun.jna.Function.convertArgument(Function.java;518). Should I be
able to use a NativeString as an argument? I would have thought so. Is
there a more appropriate way of passing a String to c using jna?
Thanks for your help.
Regards
Ray Kolonay