Wednesday, April 25, 2012

jni getobjectclass function error "SIGSEGV"

Here is my code :

    midMain = env->GetStaticMethodID( clsMTT, "TagCalculation", "()LReturnTags;");
        tagInfo = env->CallStaticObjectMethod(clsMTT, midMain, NULL);
        clsR = env->GetObjectClass(tagInfo);





When I run this program, I get the following the "SIGSEGV" error caused by GetObjectClass function.

The reason is the function "TagCalculation" returned a empty object "tagInfo" when I run "CallStaticObjectMethod".
Therefore, the GetObjectClass tries to find a class from an empty object. This will be wrong.
The solution is very simple: I change the function "TagCalculation" to always return a real object, which is not empty.
Then, the error gone.

No comments: