initContext->env = env;
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeCreateInitContext(JNIEnv *env, jobject obj, jint windowPtr, jint x, jint y,  jint width, jint height, jobject aBrowserControlImpl){    jobject			jobj = obj;#ifdef XP_MAC    WindowPtr		pWindow = (WindowPtr) windowPtr;    Rect			webRect = pWindow->portRect;    // nsIWidget	*	pWidget = (nsIWidget *) widgetPtr;#elif defined(XP_PC)    // elif defined(XP_WIN)    HWND parentHWnd = (HWND)windowPtr;#elif defined(XP_UNIX)    GtkWidget * parentHWnd = (GtkWidget *) windowPtr;#endif        if (parentHWnd == nsnull) {      ::util_ThrowExceptionToJava(env, "Exception: null window handle passed to raptorWebShellCreate");      return (jint) 0;    }    WebShellInitContext* initContext = new WebShellInitContext;        initContext->initComplete = FALSE;    initContext->initFailCode = 0;    initContext->parentHWnd = parentHWnd;    initContext->webShell = nsnull;    initContext->embeddedThread = nsnull;    initContext->sessionHistory = nsnull;    initContext->actionQueue = nsnull;    initContext->nativeEventThread = nsnull;    initContext->env = env;    initContext->stopThread = FALSE;    initContext->x = x;    initContext->y = y;    initContext->w = width;    initContext->h = height;#ifdef XP_UNIX    jclass cls = env->GetObjectClass(aBrowserControlImpl);  // Get Class for BrowserControlImpl object    jclass clz = env->FindClass("org/mozilla/webclient/BrowserControlImpl");    if (nsnull == clz) {      ::util_ThrowExceptionToJava(env, "Exception: Could not find class for BrowserControlImpl");      return (jint) 0;    }    jboolean ans = env->IsInstanceOf(aBrowserControlImpl, clz);    if (JNI_FALSE == ans) {      ::util_ThrowExceptionToJava(env, "Exception: We have a problem");      return (jint) 0;    }    // Get myCanvas IVar    jfieldID fid = env->GetFieldID(cls, "myCanvas", "Lorg/mozilla/webclient/BrowserControlCanvas;");    if (nsnull == fid) {      ::util_ThrowExceptionToJava(env, "Exception: field myCanvas not found in the jobject for BrowserControlImpl");          return (jint) 0;    }    jobject canvasObj = env->GetObjectField(aBrowserControlImpl, fid);    jclass canvasCls = env->GetObjectClass(canvasObj);    if (nsnull == canvasCls) {      ::util_ThrowExceptionToJava(env, "Exception: Could Not find Class for CanvasObj");      return (jint) 0;    }    jfieldID gtkfid = env->GetFieldID(canvasCls, "gtkWinPtr", "I");    if (nsnull == gtkfid) {      ::util_ThrowExceptionToJava(env, "Exception: field gtkWinPtr not found in the jobject for BrowserControlCanvas");      return (jint) 0;    }    jint mozPtr = env->GetIntField(canvasObj, gtkfid);    initContext->gtkWinPtr = (int) mozPtr;#else    initContext->gtkWinPtr = nsnull;#endif        return (jint) initContext;}