if (env->IsInstanceOf(typedListener, clazz)) {
if (::util_IsInstanceOf(env, typedListener, clazz)) {
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener){    WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;    if (initContext == nsnull) {        ::util_ThrowExceptionToJava(env, "Exception: null initContext passed tonativeAddListener");        return;    }        if (nsnull == initContext->nativeEventThread) {        // store the java EventRegistrationImpl class in the initContext        initContext->nativeEventThread = obj; // VERY IMPORTANT!!        // This enables the listener to call back into java    }        jclass clazz = nsnull;    int listenerType = 0;    while (nsnull != gSupportedListenerInterfaces[listenerType]) {        if (nsnull ==             (clazz =              env->FindClass(gSupportedListenerInterfaces[listenerType]))) {            return;        }        if (env->IsInstanceOf(typedListener, clazz)) {            // We've got a winner!            break;        }        listenerType++;    }        if (LISTENER_NOT_FOUND == (LISTENER_CLASSES) listenerType) {        ::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't find listener \n\tclass for argument");        return;    }    jobject globalRef = nsnull;    // PENDING(edburns): make sure do DeleteGlobalRef on the removeListener    if (nsnull == (globalRef = env->NewGlobalRef(typedListener))) {        ::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't create NewGlobalRef\n\tfor argument");        return;    }    switch(listenerType) {    case DOCUMENT_LOAD_LISTENER:        addDocumentLoadListener(env, initContext, globalRef);         break;    }}