I tried Brad suggestion and I still get segmentation fault.
I looked inside the jni auto code and found out this:
1. The Director class is created automatically when the callback class in Java is created. Inside the Director ctr the function GetJavaVm is called and it returns 0. It saves the jvm inside a member swig_jvm_.
2. When we are in CPP context and the callback is called, an instance of the class JniEnvWrapper is created. Inside its ctr the function GetEnv is called using the swig_jvm_ that was saved earlier. This function returns -2, means it failed. Then the function AttachCurrentThread is called and it failed also and return -1.
3. When we are in Java context and the callback is called, an instance of the class JniEnvWrapper is created. Inside its ctr the function GetEnv is called and returns 0, means it succeeded. Then the function AttachCurrentThread ia called and returns also 0.
Please help me. I am working on this for 3 days and still didn't find out the bug.
Thank you very much