Skip to content

The onContentChangedByOuterProcess method under native-bridge.cpp has a JNI calling error. #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RocketVV opened this issue Dec 18, 2019 · 2 comments

Comments

@RocketVV
Copy link

RocketVV commented Dec 18, 2019

the onContentChangedByOuterProcess method defined at MMKVContentChangeNotification.java as an interface callback which return type is void

public interface MMKVContentChangeNotification {

    // content change notification of other process
    // trigger by getXXX() or setXXX() or checkContentChangedByOuterProcess()
    void onContentChangedByOuterProcess(String mmapID);
}

but under native-bridge.cpp, the calling method is wrong

void onContentChangedByOuterProcess(const std::string &mmapID) {
    auto currentEnv = getCurrentEnv();
    if (currentEnv && g_callbackOnContentChange) {
        jstring str = string2jstring(currentEnv, mmapID);
        
        //CallStaticIntMethod isn't the original method
        currentEnv->CallStaticIntMethod(g_cls, g_callbackOnContentChange, str);
    }
}

this maybe make newers misunderstanding, we just need change that into below code,

void onContentChangedByOuterProcess(const std::string &mmapID) {
    auto currentEnv = getCurrentEnv();
    if (currentEnv && g_callbackOnContentChange) {
        jstring str = string2jstring(currentEnv, mmapID);
        currentEnv->CallStaticVoidMethod(g_cls, g_callbackOnContentChange, str);
    }
}
@lingol
Copy link
Collaborator

lingol commented Dec 18, 2019

Already fixed in the dev branch.
Thanks anyway.

@lingol
Copy link
Collaborator

lingol commented Jan 17, 2020

Released with v1.0.24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants