Is JNI able to be multi-processing? and How can I receive Unicode from C-DLL?
1 posts in topic
Flat View  Flat View

Posted By:   william_ho
Posted On:   Wednesday, March 28, 2001 05:17 PM

Java exception is occured when calling C-DLL through JNI in multi-processing. Is JNI able to be multi-processing? If yes, what is the reason of the above exception existing?

Also, I'm collecting data including Unicode from Oracle through store procedure by calling C-DLL. I have tried to use NewString() function to collect Unicode but the returned data is unexpected e.g. "????". Can you suggest method to receive the correct Unicode data?

I would be appreciated to your help. Thank you!

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

Posted By:   Alexander_Krapf  
Posted On:   Friday, March 30, 2001 09:53 AM


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,


About | Sitemap | Contact