fixes bug 312946 "javascript:Packages.prototype crashes browser if Java plugin is not found" r=brendan

This commit is contained in:
darin%meer.net 2005-10-19 18:55:44 +00:00
parent 98feb7ca92
commit 6763ec6040
2 changed files with 13 additions and 7 deletions

View File

@ -471,8 +471,10 @@ jsj_ConnectToJavaVM(JSJavaVM *jsjava_vm)
JS_ASSERT(JSJ_callbacks->create_java_vm);
JS_ASSERT(JSJ_callbacks->destroy_java_vm);
ok = JSJ_callbacks->create_java_vm(&jsjava_vm->java_vm, &jsjava_vm->main_thread_env, jsjava_vm->init_args);
if (!ok || jsjava_vm->java_vm == NULL) {
ok = JSJ_callbacks->create_java_vm(&jsjava_vm->java_vm,
&jsjava_vm->main_thread_env,
jsjava_vm->init_args);
if (!ok) {
jsj_LogError("Failed to create Java VM\n");
return JS_FALSE;
}

View File

@ -337,12 +337,16 @@ JS_STATIC_DLL_CALLBACK(PRBool)
create_java_vm_impl(SystemJavaVM* *jvm, JNIEnv* *initialEnv, void* initargs)
{
// const char* classpath = (const char*)initargs;
nsresult rv;
nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
*jvm = NS_REINTERPRET_CAST(SystemJavaVM*, managerService.get()); // unused in the browse
nsCOMPtr<nsIJVMManager> serv = do_GetService(kJVMManagerCID);
if (!serv)
return PR_FALSE;
*initialEnv = JVM_GetJNIEnv();
return (*jvm != NULL && *initialEnv != NULL);
if (!*initialEnv)
return PR_FALSE;
// serv will be released when this function returns, but that's OK because
// the XPCOM service manager will keep it alive.
*jvm = NS_REINTERPRET_CAST(SystemJavaVM*, serv.get());
return PR_TRUE;
}
JS_STATIC_DLL_CALLBACK(PRBool)