3 messages in net.java.dev.jna.users[jna-users] Re: jna
FromSent OnAttachments
Timothy WallOct 23, 2008 6:46 am 
Timothy WallOct 23, 2008 10:23 am 
Timothy WallNov 3, 2008 12:49 pm 
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:[jna-users] Re: jnaActions...
From:Timothy Wall (twal@dev.java.net)
Date:Nov 3, 2008 12:49:24 pm
List:net.java.dev.jna.users

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