Question

I'm new to dependency walker and I'm trying to determine if my dll contains a C function that I'm trying to call from Java via JNI. When I select the dll that should contain the C function in Dependency Walker, I get the import and export functions. The import list has the setLogLevel function but the entry point is not bound (as is for all functions in this list) and shows up with a green box with a c. The export list as has a setLogLevel function and has 0x00003C25 as the entry point. When I try to call the setLogLevel from JAVA/JNI I get the below. I'm not sure if the import/exports are right, can anyone confirm?

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.test.jni.SampleJNI.setLogLevel(I)V
            at com.test.jni.SampleJNI.setLogLevel(Native Method)
            at com.test.jni.Sample.setLogLevel(Unknown Source)
            at com.test.jni.Example.setLogLevel(Unknown Source)
            at com.test.jni.Example.main(Unknown Source) 
Was it helpful?

Solution

Your C function is named incorrectly. The name must be prefixed with Java and contain the package and class name. In your case, it should be Java_com_test_jni_SampleJNI_setLogLevel.

OTHER TIPS

I had omitted the java directories that have the jdk's jni.h and jni_md.h header files from the CFLAGS (compile) include in the Makefile. Once I added those to the Makefile I was able to communicate from java to c via JNI method calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top