if (!InitializeJavaGlobals(env)) { FreeJavaGlobals(env); ThrowXPCOMException(env, 0); return;
nsresult rv = NS_OK; if (InitializeJavaGlobals(env)) {  nsCOMPtr<nsILocalFile> directory; if (aMozBinDirectory) { rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory)); }  if (NS_SUCCEEDED(rv)) { nsAppFileLocProviderProxy* provider = nsnull; if (aAppFileLocProvider) { provider = new nsAppFileLocProviderProxy(env, aAppFileLocProvider); }  rv = NS_InitEmbedding(directory, provider); if (provider) { delete provider; } if (NS_SUCCEEDED(rv)) { return; } }
GECKO_NATIVE(initEmbedding) (JNIEnv* env, jclass, jobject aMozBinDirectory,                             jobject aAppFileLocProvider){  if (!InitializeJavaGlobals(env)) {    FreeJavaGlobals(env);    ThrowXPCOMException(env, 0);    return;  }  nsresult rv;  nsCOMPtr<nsILocalFile> directory;  if (aMozBinDirectory)  {    // Find corresponding XPCOM object    void* xpcomObj = GetMatchingXPCOMObject(env, aMozBinDirectory);    NS_ASSERTION(xpcomObj != nsnull, "Failed to get matching XPCOM object");    if (xpcomObj == nsnull) {      ThrowXPCOMException(env, 0);      return;    }    NS_ASSERTION(!IsXPTCStub(xpcomObj), "Expected JavaXPCOMInstance, but got nsJavaXPTCStub");    directory = do_QueryInterface(((JavaXPCOMInstance*) xpcomObj)->GetInstance());  }  /* XXX How do we handle AppFileLocProvider, if we can't create any of the   * Java<->XPCOM mappings before NS_InitEmbedding has been called?   */  nsIDirectoryServiceProvider* provider = nsnull;/*  if (aAppFileLocProvider)  {    JavaXPCOMInstance* inst = (JavaXPCOMInstance*) aMozBinDirectory;    provider = (nsIDirectoryServiceProvider*) inst->GetInstance();  } */  rv = NS_InitEmbedding(directory, provider);  if (NS_FAILED(rv))    ThrowXPCOMException(env, rv);  gEmbeddingInitialized = PR_TRUE;}