nsresult rv = NS_OK; NS_WITH_SERVICE(nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv); if (NS_SUCCEEDED(rv)) {
nsHTMLAppletElement::GetScriptObject(nsIScriptContext* aContext,                                     void** aScriptObject){#if defined(OJI)	nsresult rv = NS_OK;	if (!mReflectedApplet) {		// 1. get the script object corresponding to the <APPLET> element itself.		JSObject* elementObject = nsnull;		rv = mInner.GetScriptObject(aContext, (void**)&elementObject);		if (NS_OK != rv)			return rv;			// 2. get the plugin instance corresponding to this element.		nsIPresShell* shell = mInner.mDocument->GetShellAt(0);		if (nsnull == shell)			return NS_ERROR_FAILURE;		nsIFrame* frame = nsnull;		shell->GetPrimaryFrameFor(mInner.mContent, &frame);		NS_RELEASE(shell);		// 3. get the Java object corresponding to this applet, and reflect it into		// JavaScript using the LiveConnect manager.		JSContext* context = (JSContext*)aContext->GetNativeContext();		JSObject* wrappedAppletObject = nsnull;		nsIPluginInstance* pluginInstance = nsnull;		rv = NS_GetObjectFramePluginInstance(frame, pluginInstance);		if ((rv == NS_OK) && (nsnull != pluginInstance)) {			nsIJVMPluginInstance* javaPluginInstance = nsnull;			if (pluginInstance->QueryInterface(nsIJVMPluginInstance::GetIID(), (void**)&javaPluginInstance) == NS_OK) {				jobject appletObject = nsnull;				rv = javaPluginInstance->GetJavaObject(&appletObject);				if (NS_OK == rv) {					nsILiveConnectManager* manager = NULL;					rv = nsServiceManager::GetService(nsIJVMManager::GetCID(),					                                  nsILiveConnectManager::GetIID(),					                                  (nsISupports **)&manager);					if (rv == NS_OK) {						rv = manager->WrapJavaObject(context, appletObject, &wrappedAppletObject);						nsServiceManager::ReleaseService(nsIJVMManager::GetCID(), manager);					}				}				NS_RELEASE(javaPluginInstance);			}			NS_RELEASE(pluginInstance);		}				// 4. set the __proto__ field of the applet object to be the element script object.		if (nsnull != wrappedAppletObject) {			JS_SetPrototype(context, wrappedAppletObject, elementObject);			mInner.SetScriptObject(wrappedAppletObject);			mReflectedApplet = PR_TRUE;		}		*aScriptObject = wrappedAppletObject;	} else {		rv = mInner.GetScriptObject(aContext, aScriptObject);	}	return rv;#else	return mInner.GetScriptObject(aContext, aScriptObject);#endif}