Is JNI able to be multi-processing? and How can I receive Unicode from C-DLL?

Alexander Krapf

William,

JNI can be used in multithreaded applications. When you are calling into a C-DLL, there is always the possibility of the DLL not being able to work in a mult-threaded environment. Mutable global variables used in processing are usually a warning signal.

Specifically addressing your problem though:

  • Compare the Unicode character size used in your Oracle library to the definition of jchar in your platform-specific JNI include file. Make sure they are the same size.
  • How does Oracle return Unicode? As UTF-8 or as an array of Unicode characters? It needs to be the latter for NewString to work.
  • You can always try calling one of the String class' constructors that takes an encoding as an argument. That should work with whatever Oracle returns.
  • Check that you're not caching local or object or class references between invocations. That's forbidden in JNI and can result in exceptions.
You might also want to give our JunC++ion product a try. It's not free, but it removes many JNI headaches. Check it out at http://www.codemesh.com. Disclaimer: I am a principal at Codemesh.

Good luck,

Alex

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact