We have system here that uses Java JNI to call a function in a C library. Everything running on Solaris.
I have a problem somewhere with string encoding. An arabic character is returned by the function written in C, but the JNI methods receives a string with another encoding. I already tried setting $NLS_LANG, and the vm parameter for encoding the same way, but nothing has worked. So I need to be able to debug the C code and the Java JNI together.
what is the best way to debug it?
JNI is the Java Native Interface. It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++).
The dbx debugger (part of Sun Studio) can attach to a JVM process and let you single step between Java code and native code. The functionality went by the code name "jdbx", although it's all part of dbx. It hasn't been heavily promoted, so it might have bugs. There were issues when the IDE had two debug engines both handling Java, but using the command line dbx avoids those issues.
Of course, there are probably lots of more conventional ways to debug your specific problem without necessarily using source level debugging that can mix the Java and C code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With