diff --git a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp index be998bfe315..d18c09fc05b 100644 --- a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp +++ b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp @@ -254,10 +254,16 @@ OSStatus MRJSession::open(const char* consolePath) jstring path = env->NewStringUTF(consolePath); if (path) { env->CallStaticVoidMethod(session, openMethod, path); + if (env->ExceptionCheck()) + env->ExceptionClear(); env->DeleteLocalRef(path); } + } else { + env->ExceptionClear(); } env->DeleteLocalRef(session); + } else { + env->ExceptionClear(); } if (mStatus == noErr) @@ -266,11 +272,9 @@ OSStatus MRJSession::open(const char* consolePath) #if REDIRECT_VFPRINTF // XXX test the vfprintf function. jclass notThere = env->FindClass("class/not/Found"); - jobject throwable = env->ExceptionOccurred(); - if (throwable) { + if (env->ExceptionCheck()) { env->ExceptionDescribe(); env->ExceptionClear(); - env->DeleteLocalRef(throwable); } #endif @@ -294,6 +298,8 @@ OSStatus MRJSession::close() jmethodID closeMethod = env->GetStaticMethodID(session, "close", "()V"); if (closeMethod) env->CallStaticVoidMethod(session, closeMethod); + else + env->ExceptionClear(); env->DeleteGlobalRef(mSession); mSession = NULL; } diff --git a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java index 183384925ed..1f43ed18d3b 100644 --- a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java +++ b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java @@ -50,10 +50,10 @@ import java.net.URL; * integrating with the Netscape 6 security system. */ public class MRJSession { - // Save primordial System streams. - private static PrintStream out; - private static PrintStream err; - private static PrintStream console; + // Save primordial System streams. + private static PrintStream out; + private static PrintStream err; + private static PrintStream console; private static Properties loadProperties(String pluginHome) { Properties props = new Properties(); @@ -71,12 +71,19 @@ public class MRJSession { Properties props = loadProperties(pluginHome); boolean append = Boolean.valueOf(props.getProperty("netscape.oji.plugin.console.append")).booleanValue(); - // redirect I/O to specified file. - MRJSession.out = System.out; - MRJSession.err = System.err; + // Make sure the parent directories exist. + File consoleFile = new File(consolePath); + File parentFile = consoleFile.getParentFile(); + if (!parentFile.exists()) { + parentFile.mkdirs(); + } + + // redirect console I/O to specified file. + MRJSession.out = System.out; + MRJSession.err = System.err; console = new PrintStream(new FileOutputStream(consolePath, append)); - System.setOut(console); - System.setErr(console); + System.setOut(console); + System.setErr(console); Date date = new Date(); String version = props.getProperty("netscape.oji.plugin.version"); @@ -98,8 +105,8 @@ public class MRJSession { } public static void close() throws IOException { - System.setOut(MRJSession.out); - System.setErr(MRJSession.err); + System.setOut(MRJSession.out); + System.setErr(MRJSession.err); console.close(); } }