Is JNI able to be multi-processing? and How can I receive Unicode from C-DLL?
Created May 4, 2012
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.
Good luck,
Alex