Firstly, this is what works, and then I will describe what is not: using SWIG we took some third-party code and created the source of the Java and C shell. We created a jar file of Java classes and a common library of C shell code. We have a Java base data that loads a shared library and can optionally activate its own code. This works on Sun HostSpot JVM 1.5.0.14. Do not worry here.
Now this does not work: using the same JVM jar file with Java shell code and the same shared library described above, I am trying to use Jython to create some scripts. The CLASSPATH and LD_LIBRARY_PATH environment classes are set correctly. From Jython, I can run java.lang.System.loadLibrary (...) and load the shared library without errors. However, when the first native method from this library is called for the Java object in my Jython script, I get UnsatisfiedLinkError from the JVM .
I ran nm in a shared library, and I see that this method is present in the library (with a name change for native methods, as described in the JNI specification). So the question is, what can stop the JVM from resolving the method name?
I went through the JNI specification, and I see that the library can be unloaded by GC. Could this happen before I call the method? What else could cause a failure?
source
share