• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How return char array from native method to Java?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JNI method that creates a char[] array and then will return it do the java program that called it. how do i do this? Do I have to create a jcharArray? how do I do that?
Basically what I want to do is: (pseudo code)

How would I do something like that?
Also, related:
1. Can I return a jobject (or something else) for an object of a non-"standard" class? For example, IP_ADAPTER_INFO (found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_adapter_info.asp )
2. Anyone know of a really good JNI explanation site? The Sun stuff is not the best.
[ March 04, 2003: Message edited by: Robert Paris ]
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I finally figured it out. Here's the code for anyone who's interested:

That's it! However: does anyone know if there's any cleanup I need to do? Is there anything else I need to do to make sure the jbyteArray is returned but can be garbage collected later and that there are no "leaks?"
[ March 04, 2003: Message edited by: Robert Paris ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic