I am trying to cast jobject to jboolean
jmethodID mGet = env->GetMethodID(cJsonObjClass, "get","(Ljava/lang/String;)Ljava/lang/Object;");
jboolean val = (jboolean)env->CallObjectMethod(object, mGet , key);
getting this compile error:
cast from 'jobject {aka _jobject*}' to 'jboolean {aka unsigned char}' loses precision [-fpermissive]
what does it mean and what to do?
For anyone else who gets the error while using CallObjectMethod
error: cast from pointer to smaller type 'jboolean' (aka 'unsigned char') loses information
The correct way to call a method which returns a boolean ist to use CallObjectMethod
So the answer here is:
change
jboolean val = (jboolean)env->CallObjectMethod(object, mGet , key);
to
jboolean val = (jboolean)env->CallBooleanMethod(object, mGet , key);
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