fix: use the env->IsSameObject function correctly checking class types

This commit is contained in:
0x330a 2023-07-26 14:42:30 +10:00
parent 2acb7b5169
commit 6998ae7c88
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
3 changed files with 6 additions and 6 deletions

View File

@ -29,8 +29,7 @@ inline jobject serialize_contact(JNIEnv *env, session::config::contact_info info
return returnObj;
}
inline session::config::contact_info
deserialize_contact(JNIEnv *env, jobject info, session::config::Contacts *conf) {
inline session::config::contact_info deserialize_contact(JNIEnv *env, jobject info, session::config::Contacts *conf) {
jclass contactClass = env->FindClass("network/loki/messenger/libsession_util/util/Contact");
jfieldID getId, getName, getNick, getApproved, getApprovedMe, getBlocked, getUserPic, getPriority, getExpiry, getHidden;

View File

@ -144,10 +144,11 @@ Java_network_loki_messenger_libsession_1util_UserGroupsConfig_erase__Lnetwork_lo
auto conf = ptrToUserGroups(env, thiz);
auto communityInfo = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$CommunityGroupInfo");
auto legacyInfo = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
if (env->GetObjectClass(group_info) == communityInfo) {
auto group_object = env->GetObjectClass(group_info);
if (env->IsSameObject(group_object, communityInfo)) {
auto deserialized = deserialize_community_info(env, group_info, conf);
conf->erase(deserialized);
} else if (env->GetObjectClass(group_info) == legacyInfo) {
} else if (env->IsSameObject(group_object, legacyInfo)) {
auto deserialized = deserialize_legacy_group_info(env, group_info, conf);
conf->erase(deserialized);
}

View File

@ -96,9 +96,9 @@ namespace util {
jclass object_class = env->GetObjectClass(expiry_mode);
if (object_class == after_read) {
if (env->IsSameObject(object_class, after_read)) {
return std::pair(session::config::expiration_mode::after_read, env->GetLongField(expiry_mode, duration_seconds));
} else if (object_class == after_send) {
} else if (env->IsSameObject(object_class, after_send)) {
return std::pair(session::config::expiration_mode::after_send, env->GetLongField(expiry_mode, duration_seconds));
}
return std::pair(session::config::expiration_mode::none, 0);