Comparing JNI Object Links

I am calling a Java method from C ++ through JNI. The Java method returns enum STATUS. I already have assignments representing the enumerations in my C ++ code, for example here: https://stackoverflow.com/a/316677/

jclass clSTATUS = env->FindClass("MyClass$STATUS"); jfieldID fidONE = env->GetStaticFieldID(clSTATUS , "ONE", "LMyClass$STATUS;"); jobject STATUS_ONE = env->GetStaticObjectField(clSTATUS, fidONE); 

So the challenge

 jobject o = env->CallObjectMethod(jTestobject, test); 

returns a job representing enum STATUS, especially ONE. So how do I know which listing it returned? I tried to compare it with STATUS_ONE , but they do not match.

+5
source share
1 answer

I found it myself, after Samhayn pointed out my possible mistake. You just need to compare the objects correctly:

 env->IsSameObject(o, STATUS_ONE); 

Thanks!

+6
source

Source: https://habr.com/ru/post/1204193/


All Articles