diff --git a/mozilla/lib/layout/layform.c b/mozilla/lib/layout/layform.c index 728c67bf044..b7f3e76fefb 100644 --- a/mozilla/lib/layout/layform.c +++ b/mozilla/lib/layout/layform.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -24,6 +24,9 @@ #include "layout.h" #ifdef JAVA #include "java.h" +#elif defined(OJI) +#include "np.h" +#include "np2.h" #endif #include "laylayer.h" #include "libevent.h" @@ -2923,24 +2926,14 @@ lo_get_form_element_data(MWContext *context, name = lo_dup_block(form_data->name); #ifdef OJI - { -#include "np.h" -#include "np2.h" - - NPEmbeddedApp *embed = (NPEmbeddedApp*) form_data->object->objTag.FE_Data; - if (embed) { - struct nsIPluginInstance *pNPI = NPL_GetOJIPluginInstance(embed); - object_value = NPL_GetText(pNPI); - NPL_Release((struct nsISupports *)pNPI); - } - } + object_value = NPL_GetText(&form_data->object->objTag); if (object_value != NULL) { - value = PA_ALLOC(XP_STRLEN(object_value) + 1); - PA_LOCK(vstr, char *, value); - XP_STRCPY(vstr, object_value); - PA_UNLOCK(value); - XP_FREE(object_value); + value = PA_ALLOC(XP_STRLEN(object_value) + 1); + PA_LOCK(vstr, char *, value); + XP_STRCPY(vstr, object_value); + PA_UNLOCK(value); + XP_FREE(object_value); } #else object_value = LJ_Applet_GetText(form_data->object->objTag.session_data); diff --git a/mozilla/lib/layout/laymocha.c b/mozilla/lib/layout/laymocha.c index 888a4eda035..e7d5237f147 100644 --- a/mozilla/lib/layout/laymocha.c +++ b/mozilla/lib/layout/laymocha.c @@ -30,7 +30,7 @@ #include "jsjava.h" #elif defined (OJI) #include "jsjava.h" -#include "np2.h" +#include "jvmmgr.h" #endif #include "layers.h" @@ -571,7 +571,7 @@ LO_GetAppletByIndex(MWContext *context, int32 layer_id, uint index) #ifdef OJI - if (!NPL_IsJVMAndMochaPrefsEnabled()) + if (!JVM_IsLiveConnectEnabled()) return NULL; #else /* XXX */ @@ -614,12 +614,12 @@ LO_EnumerateApplets(MWContext *context, int32 layer_id) lo_DocLists *doc_lists; #ifdef OJI - if (!NPL_IsJVMAndMochaPrefsEnabled()) - return NULL; + if (!JVM_IsLiveConnectEnabled()) + return 0; #else /* XXX */ if (!JSJ_IsEnabled()) - return NULL; + return 0; #endif @@ -659,12 +659,12 @@ LO_GetEmbedByIndex(MWContext *context, int32 layer_id, uint index) lo_DocLists *doc_lists; #ifdef OJI - if (!NPL_IsJVMAndMochaPrefsEnabled()) + if (!JVM_IsLiveConnectEnabled()) return NULL; #else /* XXX */ if (!JSJ_IsEnabled()) - return 0; + return NULL; #endif @@ -703,12 +703,12 @@ LO_EnumerateEmbeds(MWContext *context, int32 layer_id) lo_DocLists *doc_lists; #ifdef OJI - if (!NPL_IsJVMAndMochaPrefsEnabled()) - return NULL; + if (!JVM_IsLiveConnectEnabled()) + return 0; #else /* XXX */ if (!JSJ_IsEnabled()) - return NULL; + return 0; #endif top_state = lo_GetMochaTopState(context); diff --git a/mozilla/lib/libmocha/et_moz.c b/mozilla/lib/libmocha/et_moz.c index 919b884f076..ce4d8afb524 100644 --- a/mozilla/lib/libmocha/et_moz.c +++ b/mozilla/lib/libmocha/et_moz.c @@ -35,9 +35,9 @@ #include "np.h" #include "prefapi.h" #include "pa_parse.h" -/* #include "netcache.h" */ +#include "netcache.h" #include "secnav.h" - +#include "secstubn.h" #define IL_CLIENT #include "libimg.h" /* Image Library public API. */ @@ -2095,7 +2095,7 @@ ET_moz_CallFunctionString(ETStringPtrFunc fn, void * data) char * ret; MozillaEvent_CallFuncString* event = PR_NEW(MozillaEvent_CallFuncString); if (event == NULL) - return PR_FALSE; + return NULL; PR_InitEvent(&event->ce.event, NULL, (PRHandleEventProc)et_HandleEvent_CallFunctionString, (PRDestroyEventProc)et_DestroyEvent_GenericEvent); @@ -2615,7 +2615,7 @@ ET_TweakLayer(MWContext * context, CL_Layer* layer, int32 x, int32 y, MozillaEvent_TweakLayer * event; event = PR_NEW(MozillaEvent_TweakLayer); if (event == NULL) - return NULL; + return 0; PR_InitEvent(&event->ce.event, context, (PRHandleEventProc)et_HandleEvent_TweakLayer, diff --git a/mozilla/lib/libmocha/lm_applt.c b/mozilla/lib/libmocha/lm_applt.c index 6fa6d24676f..0ed0a8e2dc7 100644 --- a/mozilla/lib/libmocha/lm_applt.c +++ b/mozilla/lib/libmocha/lm_applt.c @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -243,31 +243,15 @@ lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, #ifdef OJI { - if (! NPL_IsJVMAndMochaPrefsEnabled()) { - return lo_embed->mocha_object = lm_DummyObject; - } + jsval val; + if (!JVM_IsLiveConnectEnabled()) { + return lo_embed->mocha_object = lm_DummyObject; + } - embed = (NPEmbeddedApp*) lo_embed->FE_Data; - if (embed) { - struct nsIPluginInstance *pNPI = NULL; - JNIEnv *jniEnv = NULL; - jsval val; - - pNPI = NPL_GetOJIPluginInstance(embed); - javaobject = NPL_GetJavaObject(pNPI); - NPL_Release((struct nsISupports *)pNPI); + javaobject = NPL_GetJavaObject(lo_embed); -#if 0 - jniEnv = NPL_EnsureJNIExecEnv(NULL); - obj = JSJ_WrapJavaObject(decoder->js_context, - jniEnv, - javaobject, - (*jniEnv)->GetObjectClass(jniEnv, javaobject)); -#else - if (JSJ_ConvertJavaObjectToJSValue(decoder->js_context, javaobject, &val)) - obj = JSVAL_TO_OBJECT(val); -#endif - } + if (JSJ_ConvertJavaObjectToJSValue(decoder->js_context, javaobject, &val)) + obj = JSVAL_TO_OBJECT(val); } #else /* set the element to something bad if we can't get the java obj */ @@ -349,7 +333,7 @@ LM_ReflectApplet(MWContext *context, LO_JavaAppStruct *applet_data, JSContext *cx; char *name; #ifdef OJI - LO_EmbedStruct *embed = (LO_EmbedStruct *)applet_data; + LO_EmbedStruct *embed = (LO_EmbedStruct *)applet_data; #endif obj = applet_data->objTag.mocha_object; @@ -362,10 +346,10 @@ LM_ReflectApplet(MWContext *context, LO_JavaAppStruct *applet_data, cx = decoder->js_context; #ifdef OJI - /* this is really skanky, but we don't really have a LO_JavaAppStruct, but instead a LO_EmbedStruct. */ - name = getValue(&embed->attributes, "NAME"); - if (name != NULL) - name = JS_strdup(cx, name); + /* this is really skanky, but we don't really have a LO_JavaAppStruct, but instead a LO_EmbedStruct. */ + name = getValue(&embed->attributes, "NAME"); + if (name != NULL) + name = JS_strdup(cx, name); #else /* get the name */ if (applet_data->attr_name) { diff --git a/mozilla/lib/libmocha/lm_doc.c b/mozilla/lib/libmocha/lm_doc.c index bea8e02da45..37238179ade 100644 --- a/mozilla/lib/libmocha/lm_doc.c +++ b/mozilla/lib/libmocha/lm_doc.c @@ -765,16 +765,8 @@ doc_list_properties(JSContext *cx, JSObject *obj) return JS_FALSE; #ifdef OJI - { - PRBool jvmMochaPrefsEnabled = PR_FALSE; - if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { - jvmMochaPrefsEnabled = PR_TRUE; - } - if (jvmMochaPrefsEnabled == PR_FALSE) { - return JS_TRUE; - } + if (JVM_IsLiveConnectEnabled()) lm_reflect_stuff_eagerly(context, doc->layer_id); - } #else if (JSJ_IsEnabled()) lm_reflect_stuff_eagerly(context, doc->layer_id); diff --git a/mozilla/lib/libmocha/lm_embed.c b/mozilla/lib/libmocha/lm_embed.c index dcea423bef1..1904f7f642b 100644 --- a/mozilla/lib/libmocha/lm_embed.c +++ b/mozilla/lib/libmocha/lm_embed.c @@ -33,7 +33,7 @@ #include "nppriv.h" #ifdef OJI #include "jni.h" -#include "np2.h" +#include "jvmmgr.h" #else #include "jri.h" #endif @@ -221,16 +221,10 @@ lm_ReallyReflectEmbed(MWContext *context, LO_EmbedStruct *lo_embed, } #ifdef OJI - { - PRBool jvmMochaPrefsEnabled = PR_FALSE; - if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { - jvmMochaPrefsEnabled = PR_TRUE; - } - if (jvmMochaPrefsEnabled == PR_FALSE) { - PR_LOG(Moja, debug, ("reflected embed 0x%x as null\n", - lo_embed)); - return lo_embed->objTag.mocha_object = lm_DummyObject; - } + if (!JVM_IsLiveConnectEnabled()) { + PR_LOG(Moja, debug, ("reflected embed 0x%x as null\n", + lo_embed)); + return lo_embed->objTag.mocha_object = lm_DummyObject; } #else /* set the element to something bad if we can't get the java obj */ @@ -260,18 +254,9 @@ lm_ReallyReflectEmbed(MWContext *context, LO_EmbedStruct *lo_embed, #ifdef OJI { -#if 0 - JNIEnv *jniEnv = NULL; - jniEnv = NPL_EnsureJNIExecEnv(NULL); - obj = JSJ_WrapJavaObject(decoder->js_context, - jniEnv, - jembed, - (*jniEnv)->GetObjectClass(jniEnv, jembed)); -#else jsval val; if (JSJ_ConvertJavaObjectToJSValue(decoder->js_context, jembed, &val)) obj = JSVAL_TO_OBJECT(val); -#endif } #else obj = js_ReflectJObjectToJSObject(decoder->js_context, diff --git a/mozilla/lib/libmocha/lm_init.c b/mozilla/lib/libmocha/lm_init.c index 1a3e37ea106..68596c15771 100644 --- a/mozilla/lib/libmocha/lm_init.c +++ b/mozilla/lib/libmocha/lm_init.c @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -40,9 +40,12 @@ #include "jriext.h" #include "java.h" #elif defined (OJI) +/* #include "jni.h" #include "np2.h" #include "jsjava.h" +*/ +#include "jvmmgr.h" #endif #include "prefapi.h" @@ -708,19 +711,10 @@ lm_ReallyInitMocha(void) lm_crippled_decoder = lm_new_decoder(lm_runtime, &lm_dummy_class); lm_crippled_context = lm_crippled_decoder->js_context; -#ifdef OJI - { - PRBool jvmMochaPrefsEnabled = PR_FALSE; - if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { - jvmMochaPrefsEnabled = NPL_JSJInit(); - } +#if defined(OJI) + (void)JVM_MaybeStartupLiveConnect(lm_crippled_context, JS_GetGlobalObject(lm_crippled_context)); - if (jvmMochaPrefsEnabled == PR_TRUE) - { - JSJ_InitJSContext(lm_crippled_context, JS_GetGlobalObject(lm_crippled_context), NULL); - } - } -#elif defined (JAVA) +#elif defined(JAVA) LJ_JSJ_Init(); /* @@ -797,6 +791,12 @@ lm_ReallyInitMocha(void) return; } +JSContext* +LM_GetCrippledContext(void) +{ + return lm_crippled_context; +} + void LM_ForceJSEnabled(MWContext *cx) { @@ -857,14 +857,15 @@ LM_InitMoja() if (lm_moja_initialized != LM_MOJA_UNINITIALIZED) return lm_moja_initialized; #if defined(OJI) - lm_JSEnv = NPL_EnsureJNIExecEnv(lm_InterpretThread); - if (lm_JSEnv == NULL) { - lm_moja_initialized = LM_MOJA_JAVA_FAILED; - return lm_moja_initialized; + { + nsJVMStatus status = JVM_GetJVMStatus(); + if (status != nsJVMStatus_Running) { + lm_moja_initialized = LM_MOJA_JAVA_FAILED; + return lm_moja_initialized; + } + + lm_moja_initialized = LM_MOJA_OK; } - - lm_moja_initialized = LM_MOJA_OK; - #elif defined(JAVA) /* initialize the java env associated with the mocha thread */ lm_JSEnv = LJ_EnsureJavaEnv(lm_InterpretThread); diff --git a/mozilla/lib/libmocha/lm_win.c b/mozilla/lib/libmocha/lm_win.c index 876e278c908..8efd2d2c43c 100644 --- a/mozilla/lib/libmocha/lm_win.c +++ b/mozilla/lib/libmocha/lm_win.c @@ -42,8 +42,11 @@ #if defined(JAVA) #include "jsjava.h" #elif defined (OJI) +/* #include "np2.h" #include "jsjava.h" +*/ +#include "jvmmgr.h" #endif #undef FREE_AND_CLEAR /* XXX over-including Mac compiled headers */ @@ -3235,6 +3238,8 @@ lm_InitWindowContent(MochaDecoder *decoder) return JS_FALSE; #if defined(OJI) + JVM_MaybeStartupLiveConnect(cx, obj); +#if 0 { PRBool jvmMochaPrefsEnabled = PR_FALSE; if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { @@ -3247,6 +3252,7 @@ lm_InitWindowContent(MochaDecoder *decoder) return JS_FALSE; } } +#endif #elif defined(JAVA) if (JSJ_IsEnabled() && !JSJ_InitContext(cx, obj)) return JS_FALSE; diff --git a/mozilla/modules/oji/src/jvmmgr.cpp b/mozilla/modules/oji/src/jvmmgr.cpp index d5afed95fb3..04bea67023e 100644 --- a/mozilla/modules/oji/src/jvmmgr.cpp +++ b/mozilla/modules/oji/src/jvmmgr.cpp @@ -23,10 +23,8 @@ #include "jvmmgr.h" #include "npglue.h" #include "xp.h" -#include "net.h" #include "prefapi.h" #include "xp_str.h" -#include "libmocha.h" #include "np.h" #include "prio.h" #include "prmem.h" @@ -42,7 +40,7 @@ extern "C" int XP_PROGRESS_STARTING_JAVA; extern "C" int XP_PROGRESS_STARTING_JAVA_DONE; extern "C" int XP_JAVA_NO_CLASSES; -extern "C" int XP_JAVA_WRONG_CLASSES; +extern "C" int XP_JAVA_GENERAL_FAILURE; extern "C" int XP_JAVA_STARTUP_FAILED; extern "C" int XP_JAVA_DEBUGGER_FAILED; @@ -76,30 +74,11 @@ nsJVMMgr::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) if (outer && !aIID.Equals(kISupportsIID)) return NS_NOINTERFACE; // XXX right error? nsJVMMgr* jvmmgr = new nsJVMMgr(outer); - nsresult result = jvmmgr->QueryInterface(aIID, aInstancePtr); - if (result != NS_OK) { - delete jvmmgr; - } - return result; -} - -nsIJVMPlugin* -nsJVMMgr::GetJVMPlugin(void) -{ - // lazily loads the JVM plugin. - if (fJVM == NULL) { - nsIPlugin* plugin = NPL_LoadPluginByType(NPJVM_MIME_TYPE); - if (plugin != NULL) { - nsresult rslt = plugin->QueryInterface(kIJVMPluginIID, (void**)&fJVM); - if (rslt != NS_OK) fJVM = NULL; - } - } - // always add an additional reference. - if (fJVM != NULL) { - fJVM->AddRef(); - return fJVM; - } - return NULL; + if (jvmmgr == NULL) + return NS_ERROR_OUT_OF_MEMORY; + jvmmgr->AddRef(); + *aInstancePtr = jvmmgr->GetInner(); + return NS_OK; } nsJVMMgr::nsJVMMgr(nsISupports* outer) @@ -178,17 +157,10 @@ PR_BEGIN_EXTERN_C #ifdef MOCHA -PR_EXTERN(JSContext*) map_jsj_thread_to_js_context_impl(JSJavaThreadState *jsj_env, JNIEnv *env, char **errp); -PR_EXTERN(JSJavaThreadState*) map_js_context_to_jsj_thread_impl(JSContext *cx, char **errp); -PR_EXTERN(JSObject*) map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp); -PR_EXTERN(JavaVM*) get_java_vm_impl(char **errp); - -PR_EXTERN_DATA(JSContext*) lm_crippled_context; /* XXX kill me */ - -PR_IMPLEMENT(JSContext *) +static JSContext* PR_CALLBACK map_jsj_thread_to_js_context_impl(JSJavaThreadState *jsj_env, JNIEnv *env, char **errp) { - JSContext *cx = lm_crippled_context; + JSContext *cx = LM_GetCrippledContext(); PRBool jvmMochaPrefsEnabled = PR_FALSE; *errp = NULL; @@ -196,7 +168,7 @@ map_jsj_thread_to_js_context_impl(JSJavaThreadState *jsj_env, JNIEnv *env, char nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); if (pJVMMgr != NULL) { nsIJVMPlugin* pJVMPI = pJVMMgr->GetJVMPlugin(); - jvmMochaPrefsEnabled = pJVMMgr->IsJVMAndMochaPrefsEnabled(); + jvmMochaPrefsEnabled = LM_GetMochaEnabled(); if (pJVMPI != NULL) { nsIPluginInstance* pPIT; nsresult err = pJVMPI->GetPluginInstance(env, &pPIT); @@ -214,7 +186,7 @@ map_jsj_thread_to_js_context_impl(JSJavaThreadState *jsj_env, JNIEnv *env, char } pPIT->Release(); } - pJVMPI->Release(); + // pJVMPI->Release(); // GetJVMPlugin no longer calls AddRef } pJVMMgr->Release(); } @@ -245,7 +217,7 @@ map_jsj_thread_to_js_context_impl(JSJavaThreadState *jsj_env, JNIEnv *env, char ** to a java thread. JSJ_AttachCurrentThreadToJava just calls AttachCurrentThread ** on the java vm. */ -PR_IMPLEMENT(JSJavaThreadState *) +static JSJavaThreadState* PR_CALLBACK map_js_context_to_jsj_thread_impl(JSContext *cx, char **errp) { *errp = NULL; @@ -286,7 +258,7 @@ map_js_context_to_jsj_thread_impl(JSContext *cx, char **errp) ** is made, all subsequent method calls via JSObject use the internal field ** to get to the javascript JSObject. */ -PR_IMPLEMENT(JSObject *) +static JSObject* PR_CALLBACK map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp) { MWContext *cx; @@ -312,7 +284,7 @@ map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp) nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); if (pJVMMgr != NULL) { nsIJVMPlugin* pJVMPI = pJVMMgr->GetJVMPlugin(); - jvmMochaPrefsEnabled = pJVMMgr->IsJVMAndMochaPrefsEnabled(); + jvmMochaPrefsEnabled = LM_GetMochaEnabled(); if (pJVMPI != NULL) { jobject javaObject = applet; nsIPluginInstance* pPIT; @@ -338,7 +310,7 @@ map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp) } pPIT->Release(); } - pJVMPI->Release(); + // pJVMPI->Release(); // GetJVMPlugin no longer calls AddRef } pJVMMgr->Release(); } @@ -372,7 +344,7 @@ map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp) return 0; } -PR_IMPLEMENT(JavaVM *) +static JavaVM* PR_CALLBACK get_java_vm_impl(char **errp) { *errp = NULL; @@ -384,7 +356,7 @@ get_java_vm_impl(char **errp) if (pJVMPI != NULL) { nsresult err = pJVMPI->GetJavaVM(&pJavaVM); PR_ASSERT(err != NS_OK ? pJavaVM == NULL : PR_TRUE); - pJVMPI->Release(); + // pJVMPI->Release(); // GetJVMPlugin no longer calls AddRef } pJVMMgr->Release(); } @@ -433,46 +405,9 @@ static JSJCallbacks jsj_callbacks = { get_java_vm_impl }; -PRBool -nsJVMMgr::JSJInit() -{ - nsIJVMPlugin* pJVMPI = NULL; - PRBool bJSJInited = PR_FALSE; - - if(fJSJavaVM == NULL) - { - if( (pJVMPI = GetJVMPlugin()) != NULL) - { - JSJ_Init(&jsj_callbacks); - if (StartupJVM() == nsJVMStatus_Running) { - const char* classpath = NULL; - nsresult err = pJVMPI->GetClassPath(&classpath); - PR_ASSERT(err == NS_OK); - fJSJavaVM = JSJ_ConnectToJavaVM(JVM_GetJavaVM(), classpath); - } - pJVMPI->Release(); - bJSJInited = PR_TRUE; - } - } - else - { - bJSJInited = PR_TRUE; - } - - return bJSJInited; -} - //////////////////////////////////////////////////////////////////////////////// #if 0 -NS_METHOD_(PRBool) -nsJVMMgr::HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) -{ - return LM_HandOffJSLock(oldOwner, newOwner); -} - -//////////////////////////////////////////////////////////////////////////////// - static const char* ConvertToPlatformPathList(const char* cp) { @@ -514,44 +449,45 @@ ConvertToPlatformPathList(const char* cp) return c; #endif } +#endif -NS_METHOD -nsJVMMgr::ReportJVMError(void* env, nsresult err) +void +nsJVMMgr::ReportJVMError(nsresult err) { MWContext* cx = XP_FindSomeContext(); char *s; switch (err) { case NS_JVM_ERROR_NO_CLASSES: { - const char* cp = fJVM->GetClassPath(); - const char* jarName = ""; // XXX fJVM->GetSystemJARPath(); - cp = ConvertToPlatformPathList(cp); - s = PR_smprintf(XP_GetString(XP_JAVA_NO_CLASSES), - jarName, jarName, - (cp ? cp : "")); - free((void*)cp); + s = PR_smprintf(XP_GetString(XP_JAVA_NO_CLASSES)); break; } case NS_JVM_ERROR_JAVA_ERROR: { - const char* msg = GetJavaErrorString((JRIEnv*)env); + nsIJVMPlugin* plugin = GetJVMPlugin(); + PR_ASSERT(plugin != NULL); + if (plugin == NULL) break; + JNIEnv* env; + plugin->GetJNIEnv(&env); + const char* msg = GetJavaErrorString(env); + plugin->ReleaseJNIEnv(env); #ifdef DEBUG -# ifdef XP_MAC - ((JRIEnv*)env)->ExceptionDescribe(); -# else - JRI_ExceptionDescribe((JRIEnv*)env); -# endif + env->ExceptionDescribe(); #endif s = PR_smprintf(XP_GetString(XP_JAVA_STARTUP_FAILED), (msg ? msg : "")); if (msg) free((void*)msg); break; } + case NS_JVM_ERROR_NO_DEBUGGER: { s = PR_smprintf(XP_GetString(XP_JAVA_DEBUGGER_FAILED)); break; } - default: - return; /* don't report anything */ + + default: { + s = PR_smprintf(XP_GetString(XP_JAVA_GENERAL_FAILURE), err); + break; + } } if (s) { FE_Alert(cx, s); @@ -565,14 +501,14 @@ nsJVMMgr::ReportJVMError(void* env, nsresult err) #define sig_java_lang_Object_toString "()Ljava/lang/String;" const char* -nsJVMMgr::GetJavaErrorString(JRIEnv* env) +nsJVMMgr::GetJavaErrorString(JNIEnv* env) { /* XXX javah is a pain wrt mixing JRI and JDK native methods. Since we need to call a method on Object, we'll do it the hard way to avoid using javah for this. Maybe we need a new JRI entry point for toString. Yikes! */ -#ifdef XP_MAC +#if 1 //def XP_MAC jthrowable exc = env->ExceptionOccurred(); if (exc == NULL) { return strdup(""); /* XXX better "no error" message? */ @@ -628,10 +564,11 @@ nsJVMMgr::GetJavaErrorString(JRIEnv* env) return strdup(msg); #endif } -#endif // 0 //////////////////////////////////////////////////////////////////////////////// +PRLogModuleInfo* NSJAVA = NULL; + #ifdef MOZ_SMARTUPDATE static NS_DEFINE_IID(kIJRIPluginIID, NS_IJRIPLUGIN_IID); @@ -654,8 +591,28 @@ nsJVMMgr::StartupJVM(void) break; } - nsIJVMPlugin* jvm = GetJVMPlugin(); - if (jvm == NULL) { +#ifdef DEBUG + PRIntervalTime start = PR_IntervalNow(); + if (NSJAVA == NULL) + NSJAVA = PR_NewLogModule("NSJAVA"); + PR_LOG(NSJAVA, PR_LOG_ALWAYS, ("Starting java...")); +#endif + + MWContext* someRandomContext = XP_FindSomeContext(); + if (someRandomContext) { + FE_Progress(someRandomContext, XP_GetString(XP_PROGRESS_STARTING_JAVA)); + } + + PR_ASSERT(fJVM == NULL); + nsIPlugin* plugin = NPL_LoadPluginByType(NPJVM_MIME_TYPE); + if (plugin == NULL) { + fStatus = nsJVMStatus_Failed; + return fStatus; + } + + nsresult rslt = plugin->QueryInterface(kIJVMPluginIID, (void**)&fJVM); + if (rslt != NS_OK) { + PR_ASSERT(fJVM == NULL); fStatus = nsJVMStatus_Failed; return fStatus; } @@ -700,24 +657,49 @@ nsJVMMgr::StartupJVM(void) } #endif } - jvm->Release(); + else { + ReportJVMError(err); + fStatus = nsJVMStatus_Failed; + } + +#if 0 + JSContext* crippledContext = LM_GetCrippledContext(); + MaybeStartupLiveConnect(crippledContext, JS_GetGlobalObject(crippledContext)); +#endif + + fJVM->Release(); + +#ifdef DEBUG + PRIntervalTime end = PR_IntervalNow(); + PRInt32 d = PR_IntervalToMilliseconds(end - start); + PR_LOG(NSJAVA, PR_LOG_ALWAYS, + ("Starting java...%s (%ld ms)", + (fStatus == nsJVMStatus_Running ? "done" : "failed"), d)); +#endif + + if (someRandomContext) { + FE_Progress(someRandomContext, XP_GetString(XP_PROGRESS_STARTING_JAVA_DONE)); + } return fStatus; } nsJVMStatus nsJVMMgr::ShutdownJVM(PRBool fullShutdown) { - if (fJVM) { - // XXX we should just make nsPluginError and nsJVMStatus be nsresult + if (fStatus == nsJVMStatus_Running) { + PR_ASSERT(fJVM != NULL); + (void)MaybeShutdownLiveConnect(); nsresult err = fJVM->ShutdownJVM(fullShutdown); if (err == NS_OK) - return nsJVMStatus_Enabled; + fStatus = nsJVMStatus_Enabled; else { - // XXX report error? - return nsJVMStatus_Disabled; + ReportJVMError(err); + fStatus = nsJVMStatus_Disabled; } + fJVM = NULL; } - return nsJVMStatus_Enabled; // XXX what if there's no plugin available? + PR_ASSERT(fJVM == NULL); + return fStatus; } //////////////////////////////////////////////////////////////////////////////// @@ -748,8 +730,7 @@ nsJVMMgr::SetJVMEnabled(PRBool enabled) else { if (fStatus == nsJVMStatus_Running) (void)ShutdownJVM(); - else - fStatus = nsJVMStatus_Disabled; + fStatus = nsJVMStatus_Disabled; } } @@ -770,18 +751,50 @@ nsJVMMgr::GetJVMStatus(void) return fStatus; } -PRBool -nsJVMMgr::IsJVMAndMochaPrefsEnabled(void) +PRBool +nsJVMMgr::MaybeStartupLiveConnect(JSContext* cx, JSObject* obj) { - if (GetJVMStatus() == nsJVMStatus_Disabled) { - return PR_FALSE; + if (fJSJavaVM) + return PR_TRUE; + + if (IsLiveConnectEnabled()) { + JSJ_Init(&jsj_callbacks); + nsIJVMPlugin* plugin = GetJVMPlugin(); + if (plugin) { + const char* classpath = NULL; + nsresult err = plugin->GetClassPath(&classpath); + if (err) return err; + JavaVM* javaVM = NULL; + err = plugin->GetJavaVM(&javaVM); + if (err) return err; + fJSJavaVM = JSJ_ConnectToJavaVM(javaVM, classpath); + if (fJSJavaVM) { + JSJ_InitJSContext(cx, obj, NULL); + } + // plugin->Release(); // GetJVMPlugin no longer calls AddRef + return PR_TRUE; + } } - if (!LM_GetMochaEnabled()) { - return PR_FALSE; - } - return PR_TRUE; + return PR_FALSE; } +PRBool +nsJVMMgr::MaybeShutdownLiveConnect(void) +{ + if (fJSJavaVM) { + JSJ_DisconnectFromJavaVM(fJSJavaVM); + fJSJavaVM = NULL; + return PR_TRUE; + } + return PR_FALSE; +} + +PRBool +nsJVMMgr::IsLiveConnectEnabled(void) +{ + return LM_GetMochaEnabled() + && GetJVMStatus() == nsJVMStatus_Running; +} //////////////////////////////////////////////////////////////////////////////// @@ -828,7 +841,7 @@ nsJVMMgr::AddToClassPath(const char* dirPath) fClassPathAdditions->Add((void*)dirPath); if (jvm) { jvm->AddToClassPath(dirPath); - jvm->Release(); + // jvm->Release(); // GetJVMPlugin no longer calls AddRef } return NS_OK; } @@ -1000,20 +1013,20 @@ nsJVMPluginTagInfo::Create(nsISupports* outer, const nsIID& aIID, void* *aInstan if (outer && !aIID.Equals(kISupportsIID)) return NS_NOINTERFACE; // XXX right error? - nsJVMPluginTagInfo* jvmInstPeer = new nsJVMPluginTagInfo(outer, info); - if (jvmInstPeer == NULL) + nsJVMPluginTagInfo* jvmTagInfo = new nsJVMPluginTagInfo(outer, info); + if (jvmTagInfo == NULL) return NS_ERROR_OUT_OF_MEMORY; - nsresult result = jvmInstPeer->QueryInterface(aIID, aInstancePtr); - if (result != NS_OK) goto error; + jvmTagInfo->AddRef(); + *aInstancePtr = jvmTagInfo->GetInner(); - result = outer->QueryInterface(kIPluginTagInfo2IID, - (void**)&jvmInstPeer->fPluginTagInfo); + nsresult result = outer->QueryInterface(kIPluginTagInfo2IID, + (void**)&jvmTagInfo->fPluginTagInfo); if (result != NS_OK) goto error; outer->Release(); // no need to AddRef outer return result; error: - delete jvmInstPeer; + delete jvmTagInfo; return result; } @@ -1057,21 +1070,19 @@ GetRunningJVM(void) return jvm; } -PR_IMPLEMENT(PRBool) -JVM_IsJVMAvailable(void) +PR_IMPLEMENT(nsJVMStatus) +JVM_GetJVMStatus(void) { - PRBool result = PR_FALSE; + nsJVMStatus status = nsJVMStatus_Disabled; nsJVMMgr* mgr = JVM_GetJVMMgr(); if (mgr) { - nsJVMStatus status = mgr->GetJVMStatus(); - result = status != nsJVMStatus_Failed - && status != nsJVMStatus_Disabled; + status = mgr->GetJVMStatus(); mgr->Release(); } - return result; + return status; } -PR_IMPLEMENT(nsresult) +PR_IMPLEMENT(PRBool) JVM_AddToClassPath(const char* dirPath) { nsresult err = NS_ERROR_FAILURE; @@ -1080,7 +1091,7 @@ JVM_AddToClassPath(const char* dirPath) err = mgr->AddToClassPath(dirPath); mgr->Release(); } - return err; + return err == NS_OK; } // This will get the JVMConsole if one is available. You have to Release it @@ -1092,7 +1103,7 @@ GetConsole(void) nsIJVMPlugin* jvm = GetRunningJVM(); if (jvm) { jvm->QueryInterface(kIJVMConsoleIID, (void**)&console); - jvm->Release(); + // jvm->Release(); // GetRunningJVM no longer calls AddRef } return console; } @@ -1110,10 +1121,13 @@ JVM_ShowConsole(void) PR_IMPLEMENT(void) JVM_HideConsole(void) { - nsIJVMConsole* console = GetConsole(); - if (console) { - console->HideConsole(); - console->Release(); + nsJVMStatus status = JVM_GetJVMStatus(); + if (status == nsJVMStatus_Running) { + nsIJVMConsole* console = GetConsole(); + if (console) { + console->HideConsole(); + console->Release(); + } } } @@ -1121,11 +1135,14 @@ PR_IMPLEMENT(PRBool) JVM_IsConsoleVisible(void) { PRBool result = PR_FALSE; - nsIJVMConsole* console = GetConsole(); - if (console) { - nsresult err = console->IsConsoleVisible(&result); - PR_ASSERT(err != NS_OK ? result == PR_FALSE : PR_TRUE); - console->Release(); + nsJVMStatus status = JVM_GetJVMStatus(); + if (status == nsJVMStatus_Running) { + nsIJVMConsole* console = GetConsole(); + if (console) { + nsresult err = console->IsConsoleVisible(&result); + PR_ASSERT(err != NS_OK ? result == PR_FALSE : PR_TRUE); + console->Release(); + } } return result; } @@ -1149,6 +1166,9 @@ JVM_ToggleConsole(void) PR_IMPLEMENT(void) JVM_PrintToConsole(const char* msg) { + nsJVMStatus status = JVM_GetJVMStatus(); + if (status != nsJVMStatus_Running) + return; nsIJVMConsole* console = GetConsole(); if (console) { console->Print(msg); @@ -1167,7 +1187,7 @@ JVM_StartDebugger(void) debugger->StartDebugger(nsSymantecDebugPort_SharedMemory); debugger->Release(); } - jvm->Release(); + // jvm->Release(); // GetRunningJVM no longer calls AddRef } } @@ -1179,7 +1199,7 @@ JVM_GetJavaVM(void) if (jvm) { nsresult err = jvm->GetJavaVM(&javaVM); PR_ASSERT(err == NS_OK); - jvm->Release(); + // jvm->Release(); // GetRunningJVM no longer calls AddRef } return javaVM; } @@ -1205,7 +1225,7 @@ JVM_GetJNIEnv(void) nsIJVMPlugin* jvm = GetRunningJVM(); if (jvm) { (void)jvm->GetJNIEnv(&env); - jvm->Release(); + // jvm->Release(); // GetRunningJVM no longer calls AddRef } /* Associate the JNIEnv with the current thread. */ @@ -1214,6 +1234,54 @@ JVM_GetJNIEnv(void) return env; } +PR_IMPLEMENT(PRBool) +JVM_MaybeStartupLiveConnect(JSContext* cx, JSObject* obj) +{ + PRBool result = PR_FALSE; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + result = mgr->MaybeStartupLiveConnect(cx, obj); + mgr->Release(); + } + return result; +} + +PR_IMPLEMENT(PRBool) +JVM_MaybeShutdownLiveConnect(void) +{ + PRBool result = PR_FALSE; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + result = mgr->MaybeShutdownLiveConnect(); + mgr->Release(); + } + return result; +} + +PR_IMPLEMENT(PRBool) +JVM_IsLiveConnectEnabled(void) +{ + PRBool result = PR_FALSE; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + result = mgr->IsLiveConnectEnabled(); + mgr->Release(); + } + return result; +} + +PR_IMPLEMENT(nsJVMStatus) +JVM_ShutdownJVM(void) +{ + nsJVMStatus status = nsJVMStatus_Failed; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + status = mgr->ShutdownJVM(); + mgr->Release(); + } + return status; +} + PR_END_EXTERN_C //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/oji/src/jvmmgr.h b/mozilla/modules/oji/src/jvmmgr.h index a2db4e6931a..8f32c3e7182 100644 --- a/mozilla/modules/oji/src/jvmmgr.h +++ b/mozilla/modules/oji/src/jvmmgr.h @@ -20,6 +20,21 @@ #define jvmmgr_h___ #include "xp_core.h" // include first because of Bool problem +#include "prtypes.h" +#include "nsCom.h" +#include "jni.h" + +struct nsJVMMgr; + +typedef enum nsJVMStatus { + nsJVMStatus_Enabled, // but not Running + nsJVMStatus_Disabled, // explicitly disabled + nsJVMStatus_Running, // enabled and started + nsJVMStatus_Failed // enabled but failed to start +} nsJVMStatus; + +#ifdef __cplusplus + #include "nsjvm.h" #include "nsAgg.h" #include "jsjava.h" @@ -28,19 +43,13 @@ class nsIPluginTagInfo2; class nsSymantecDebugManager; -enum nsJVMStatus { - nsJVMStatus_Enabled, // but not Running - nsJVMStatus_Disabled, // explicitly disabled - nsJVMStatus_Running, // enabled and started - nsJVMStatus_Failed // enabled but failed to start -}; +/******************************************************************************* + * JVMMgr is the interface to the JVM manager that the browser sees. All + * files that want to include java services should include this header file. + * nsIJVMManager is the more limited interface what the JVM plugin sees. + ******************************************************************************/ -//////////////////////////////////////////////////////////////////////////////// -// JVMMgr is the interface to the JVM manager that the browser sees. All -// files that want to include java services should include this header file. -// nsIJVMManager is the more limited interface what the JVM plugin sees. - -class nsJVMMgr : public nsIJVMManager { +struct nsJVMMgr : public nsIJVMManager { public: NS_DECL_AGGREGATED @@ -56,7 +65,7 @@ public: static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); - nsIJVMPlugin* GetJVMPlugin(void); + nsIJVMPlugin* GetJVMPlugin(void) { return fJVM; } // Unlike the nsIJVMPlugin::StartupJVM, this version handles putting // up any error dialog: @@ -64,10 +73,14 @@ public: nsJVMStatus ShutdownJVM(PRBool fullShutdown = PR_FALSE); nsJVMStatus GetJVMStatus(void); void SetJVMEnabled(PRBool enabled); + + void ReportJVMError(nsresult err); + const char* GetJavaErrorString(JNIEnv* env); nsresult AddToClassPath(const char* dirPath); - PRBool JSJInit(); - PRBool IsJVMAndMochaPrefsEnabled(void); + PRBool MaybeStartupLiveConnect(JSContext* cx, JSObject* obj); + PRBool MaybeShutdownLiveConnect(void); + PRBool IsLiveConnectEnabled(void); JSJavaVM* GetJSJavaVM() { return fJSJavaVM; } @@ -158,21 +171,22 @@ protected: char* fSimulatedCode; }; +#endif // __cplusplus + //////////////////////////////////////////////////////////////////////////////// // Convenience Routines PR_BEGIN_EXTERN_C -// Returns the JVM manager. You must do a Release on the -// pointer returned when you're done with it. -PR_EXTERN(nsJVMMgr*) +/* Returns the JVM manager. You must do a Release on the pointer returned when + you're done with it. */ +PR_EXTERN(struct nsJVMMgr*) JVM_GetJVMMgr(void); -// Returns true if java is enabled, and has not failed to load. -PR_EXTERN(PRBool) -JVM_IsJVMAvailable(void); +PR_EXTERN(nsJVMStatus) +JVM_GetJVMStatus(void); -PR_EXTERN(nsresult) +PR_EXTERN(PRBool) JVM_AddToClassPath(const char* dirPath); PR_EXTERN(void) @@ -199,6 +213,18 @@ JVM_GetJavaVM(void); PR_EXTERN(JNIEnv*) JVM_GetJNIEnv(void); +PR_EXTERN(PRBool) +JVM_MaybeStartupLiveConnect(JSContext* cx, JSObject* obj); + +PR_EXTERN(PRBool) +JVM_MaybeShutdownLiveConnect(void); + +PR_EXTERN(PRBool) +JVM_IsLiveConnectEnabled(void); + +PR_EXTERN(nsJVMStatus) +JVM_ShutdownJVM(void); + PR_END_EXTERN_C //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/oji/src/scd.cpp b/mozilla/modules/oji/src/scd.cpp index b88436511ec..a7474dd7b19 100644 --- a/mozilla/modules/oji/src/scd.cpp +++ b/mozilla/modules/oji/src/scd.cpp @@ -55,11 +55,11 @@ nsSymantecDebugManager::Create(nsISupports* outer, const nsIID& aIID, void* *aIn if (outer && !aIID.Equals(kISupportsIID)) return NS_NOINTERFACE; // XXX right error? nsSymantecDebugManager* dbgr = new nsSymantecDebugManager(outer, jvmMgr); - nsresult result = dbgr->QueryInterface(aIID, aInstancePtr); - if (result != NS_OK) { - delete dbgr; - } - return result; + if (dbgr == NULL) + return NS_ERROR_OUT_OF_MEMORY; + dbgr->AddRef(); + *aInstancePtr = dbgr->GetInner(); + return NS_OK; } #if defined(XP_PC) && defined(_WIN32) diff --git a/mozilla/modules/plugin/src/npglue.cpp b/mozilla/modules/plugin/src/npglue.cpp index 9a2a07d1dbd..d3c723ca052 100644 --- a/mozilla/modules/plugin/src/npglue.cpp +++ b/mozilla/modules/plugin/src/npglue.cpp @@ -2308,6 +2308,7 @@ ET_SetPluginWindow(MWContext *cx, void *instance); NS_DEFINE_IID(kPluginInstanceIID, NS_IPLUGININSTANCE_IID); NS_DEFINE_IID(kLiveConnectPluginIID, NS_ILIVECONNECTPLUGIN_IID); +NS_DEFINE_IID(kIJVMPluginIID, NS_IJVMPLUGIN_IID); #if defined(XP_MAC) && !defined(powerc) #pragma pointers_in_D0 @@ -2875,7 +2876,16 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, } #endif } - +#ifdef OJI +#if 0 + if (handle->userPlugin) { + nsIJVMPlugin* jvmPlugin; + if (handle->userPlugin->QueryInterface(kIJVMPluginIID, (void**)&jvmPlugin) == NS_OK) { + nsresult err = jvmPlugin->StartupJVM(); + if (err != NS_OK) goto error; + } + } +#endif /* XXX This is _not_ where Start() should go (IMO). Start() should be called whenever we re-visit an applet @@ -2888,6 +2898,7 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, } */ +#endif #ifdef MOCHA { /* only wait on applets if onload flag */ @@ -4500,22 +4511,7 @@ NPL_LoadPluginByType(const char* typeAttribute) } } -extern "C" -{ -// Used by layout code to translate between a np_instance and a -// OJI plugin instance. -PR_IMPLEMENT(struct nsIPluginInstance*) -NPL_GetOJIPluginInstance(NPEmbeddedApp *embed) -{ - nsIPluginInstance* pluginInst = NULL; - np_data *ndata = (np_data*) embed->np_data; - np_instance *instance = ndata->instance; - if (instance != NULL) { - nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; - pluginInst = peerInst->GetPluginInstance(); - } - return pluginInst; -} +PR_BEGIN_EXTERN_C #ifdef OJI static NS_DEFINE_IID(kJVMPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); @@ -4523,81 +4519,64 @@ static NS_DEFINE_IID(kJVMPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); // Used by layout code to get to a text representing a java bean. PR_IMPLEMENT(const char *) -NPL_GetText(nsIPluginInstance* pluginInst) +NPL_GetText(LO_CommonPluginStruct* lo_embed) { const char *text = NULL; #ifdef OJI + NPEmbeddedApp *embed = (NPEmbeddedApp*) lo_embed->FE_Data; + if (embed == NULL) + return NULL; + np_data *ndata = (np_data*) embed->np_data; + np_instance *instance = ndata->instance; + if (instance == NULL) + return NULL; + + nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + if (pluginInst == NULL) + return NULL; + nsIJVMPluginInstance *jvmInst = NULL; if (pluginInst->QueryInterface(kJVMPluginInstanceIID, (void**)&jvmInst) == NS_OK) { nsresult err = jvmInst->GetText(&text); PR_ASSERT(err == NS_OK); jvmInst->Release(); } + pluginInst->Release(); #endif return text; } PR_IMPLEMENT(jobject) -NPL_GetJavaObject(nsIPluginInstance* pluginInst) +NPL_GetJavaObject(LO_CommonPluginStruct* lo_embed) { jobject javaobject = NULL; #if OJI + NPEmbeddedApp *embed = (NPEmbeddedApp*) lo_embed->FE_Data; + if (embed == NULL) + return NULL; + np_data *ndata = (np_data*) embed->np_data; + np_instance *instance = ndata->instance; + if (instance == NULL) + return NULL; + + nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + if (pluginInst == NULL) + return NULL; + nsIJVMPluginInstance *jvmInst = NULL; if (pluginInst->QueryInterface(kJVMPluginInstanceIID, (void**)&jvmInst) == NS_OK) { nsresult err = jvmInst->GetJavaObject(&javaobject); PR_ASSERT(err == NS_OK); jvmInst->Release(); } + pluginInst->Release(); #endif return javaobject; } -PR_IMPLEMENT(void) NPL_Release(struct nsISupports *supports) -{ - supports->Release(); -} - -PR_IMPLEMENT(XP_Bool) NPL_IsJVMAndMochaPrefsEnabled(void) -{ - XP_Bool bPrefs = PR_FALSE; -#if OJI - nsJVMMgr *pJVMMgr = JVM_GetJVMMgr(); - - if (pJVMMgr != NULL) { - if (pJVMMgr->IsJVMAndMochaPrefsEnabled() == PR_TRUE) { - bPrefs = PR_TRUE; - } - pJVMMgr->Release(); - } -#endif - return bPrefs; -} - -PR_IMPLEMENT(PRBool)NPL_JSJInit(void) -{ - PRBool bJSJInited = PR_FALSE; -#ifdef OJI - nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); - if (pJVMMgr != NULL) { - bJSJInited = pJVMMgr->JSJInit(); - pJVMMgr->Release(); - } -#endif - return bJSJInited; -} - -PR_IMPLEMENT(JNIEnv *)NPL_EnsureJNIExecEnv(PRThread* thread) -{ -#ifdef OJI - return npn_getJavaEnv(); -#else - return NULL; -#endif -} - - -} /* extern "C" */ - +PR_END_EXTERN_C /* * This is called by the front-end to create a new plug-in. It will