JNI notification system

I’m struggling with calling a C*+ function in one of my classes from my main java activity. I’ve gotten JNI working the other direction, and though it’s definitely a learning curve, it’s way easier to understand calling java from C*+ than the other way around. My main problem is that there is this big “now just compile your main java class with your native functions defined using ‘javah’ and that will generate the necessary header files”. I’m having huge problems with that ‘simple’ step. But that’s another issue. I wanted to ask about the feasibility of extending cocos2d-x in the following way:

Has anyone considered creating a generic notification system on the java side (extending the Cocos2dxActivity java class for example) tied into the cocos-2d notification system? I’m imagining setting up a normal notification listener using CCNotificationCenter on the C*+ side like:
CCNotificationCenter::sharedNotificationCenter->addObserver, RESPOND_TO_URL_NOTIFICATION, NULL);
and do something on the java side like:
this.sendCplusplusNotification;
I don’t really even know if this is feasible, because of how the java types and C*+ types aren’t compatible, though it seems there should be a way to use JNI in a more generic sense. Even without passing arguments it would be really great to send basic signals back and forth without having to dig into JNI. I’m still looking for a solid example on calling C*+ from java.
BTW what I’m trying to do is have a webView on the java side call a function in one of my C*+ classes when a user has clicked on an image in the webView.

I have some doubts about cocos2d-x being extended that way, because, as you said, marshalling types between C*+ and Java is not easy, and it depends a lot on how many types you want to support. It is definitely feasible, using introspection .
As for a simple version of that, I happen to already do that for Java => C**, using a string as only parameter, here is the code
Code to add in a c*+ file :

void notifyInAppEventNative(const char* name, const char* argument)
{
    LOGD("Notifying in app event : %s", name);
    CCNotificationCenter::sharedNotificationCenter()->postNotification(name, Screate(argument));
}

extern "C"
{
void Java_org_cocos2dx_yourpackage_YourClass_notifyInAppEvent(JNIEnv* envParam, jobject thiz, jstring event, jstring argument)
{
    const char* eventUTF = env->GetStringUTFChars(event, 0);
    const char* argumentUTF = env->GetStringUTFChars(argument, 0);
    notifyInAppEventNative(eventUTF, argumentUTF);
    envParam->ReleaseStringUTFChars(event, eventUTF);
    envParam->ReleaseStringUTFChars(argument, argumentUTF);
}
}

And in your java code :

private native void notifyInAppEvent(String name, String argument);