Hi everybody,
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
Hadas



On Mon, Aug 25, 2014 at 9:59 PM, Bradley Lowekamp <blowekamp@mail.nih.gov> wrote:
Hello,

This sounds familiar. I had to explicitly call the parents constructor via "super()" in my derived director class:


Hope this helps,
Brad

On Aug 25, 2014, at 2:49 PM, hadass yaari <hadassyaari@gmail.com> wrote:

Hello, this is my first question in this mailing list.
I have a problem:
I want to call Java callback from my cpp application.
I created callback in cpp and using director and swig the relevant class was created in Java automatically.
This callback is called twice: 
1. When the context is java thread context - this works great.
2. When the context is the cpp context.- the application collapses with segmentation fault.

I debugged this and found out that in the wrapper_cxx file, in the relevant function, it collapses when swig_get_self(jenv) is executed.
After reading a lot on the internet, I understand that the problem is that the right java thread is not attached. I also understand what I have to do manually.

I would like to know what solution does the swig give me automatically.
I would be greatful for your responses
Hadas
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/_______________________________________________
Swig-user mailing list
Swig-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user