Fix wrong return bool, string, string array data through jni

This commit is contained in:
volzhs 2016-06-30 01:23:55 +09:00
parent f56a0435f2
commit aac0af043c

View file

@ -259,8 +259,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
for (int i=0; i<stringCount; i++) { for (int i=0; i<stringCount; i++) {
jstring string = (jstring) env->GetObjectArrayElement(arr, i); jstring string = (jstring) env->GetObjectArrayElement(arr, i);
const char *rawString = env->GetStringUTFChars(string, 0); sarr.push_back(String::utf8(env->GetStringUTFChars(string, NULL)));
sarr.push_back(String(rawString));
env->DeleteLocalRef(string); env->DeleteLocalRef(string);
} }
@ -506,7 +505,7 @@ public:
} break; } break;
case Variant::BOOL: { case Variant::BOOL: {
ret = env->CallBooleanMethodA(instance,E->get().method,v); ret = env->CallBooleanMethodA(instance,E->get().method,v)==JNI_TRUE;
//print_line("call bool"); //print_line("call bool");
} break; } break;
case Variant::INT: { case Variant::INT: {
@ -521,8 +520,7 @@ public:
case Variant::STRING: { case Variant::STRING: {
jobject o = env->CallObjectMethodA(instance,E->get().method,v); jobject o = env->CallObjectMethodA(instance,E->get().method,v);
String str = env->GetStringUTFChars((jstring)o, NULL ); ret = String::utf8(env->GetStringUTFChars((jstring)o, NULL));
ret=str;
env->DeleteLocalRef(o); env->DeleteLocalRef(o);
} break; } break;
case Variant::STRING_ARRAY: { case Variant::STRING_ARRAY: {