Posted By:
Ksenia_Golod
Posted On:
Tuesday, March 25, 2003 09:10 AM
Hello, I'm using JNI for a simple communication between Java and C++ (there are basically a few methods with bool return value). I have created a shared library and the needed wrappers for every method, and under normal conditions it works great. However, if C++ throws an exception and tries to catch it, this fails and the program aborts. I've done some reading on the web, and someone mentioned that with gcc, shared libraries are unable to catch their own exceptions. Therefore, I've decided to use a static library for the C++ code. But (as far as I've understood) Java can load only a shared library, so my solution was to create proxy for the C++ method calls in a shared library, and then link it to my static library.
More>>
Hello,
I'm using JNI for a simple communication between Java and C++ (there are basically a few methods with bool return value). I have created a shared library and the needed wrappers for every method, and under normal conditions it works great.
However, if C++ throws an exception and tries to catch it, this fails and the program aborts.
I've done some reading on the web, and someone mentioned that with gcc, shared libraries are unable to catch their own exceptions.
Therefore, I've decided to use a static library for the C++ code. But (as far as I've understood) Java can load only a shared library, so my solution was to create proxy for the C++ method calls in a shared library, and then link it to my static library.
But after all this effort, a still see the same behaviour - any exception that is thrown by C++ code is failing to be caught, and the program aborts.
Another thing to try would be to catch the exceptions on the Java side, but unfortunately in my situation I cannot do that.
Can someone please suggest an alternative? Or perhaps I'm missing something?
I will greatly appreciate any feedback!
Thanks a lot,
Ksenia
<<Less