diff options
4 files changed, 28 insertions, 4 deletions
diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp index f2dd1d2..e7b854d 100644 --- a/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp @@ -65,15 +65,29 @@ JavaClass* JavaInstanceJobject::getClass() const return m_class.get(); } -JavaValue JavaInstanceJobject::invokeMethod(const JavaMethod* method, JavaValue* args) +// ANDROID +JavaValue JavaInstanceJobject::invokeMethod(const JavaMethod* method, JavaValue* args, bool& didRaiseUncaughtException) { + didRaiseUncaughtException = false; +// END ANDROID + ASSERT(getClass()->methodsNamed(method->name().utf8().data()).find(method) != notFound); unsigned int numParams = method->numParameters(); OwnArrayPtr<jvalue> jvalueArgs = adoptArrayPtr(new jvalue[numParams]); for (unsigned int i = 0; i < numParams; ++i) jvalueArgs[i] = javaValueToJvalue(args[i]); jvalue result = callJNIMethod(javaInstance(), method->returnType(), method->name().utf8().data(), method->signature(), jvalueArgs.get()); + +// ANDROID + JNIEnv* env = getJNIEnv(); + if (env->ExceptionCheck() != JNI_FALSE) { + env->ExceptionClear(); + didRaiseUncaughtException = true; + return JavaValue(); + } + return jvalueToJavaValue(result, method->returnType()); +// END ANDROID } static void appendClassName(StringBuilder& builder, const char* className) diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h index bb38e77..255c190 100644 --- a/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h @@ -52,7 +52,9 @@ public: // JavaInstance implementation virtual JavaClass* getClass() const; - virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args); +// ANDROID + virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args, bool& didRaiseUncaughtException); +// END ANDROID virtual JavaValue getField(const JavaField*); virtual void begin(); virtual void end(); diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h index 7436de7..5a1960a 100644 --- a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h @@ -49,7 +49,9 @@ public: virtual JavaClass* getClass() const = 0; // args must be an array of length greater than or equal to the number of // arguments expected by the method. - virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args) = 0; +// ANDROID + virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args, bool& didRaiseUncaughtException) = 0; +// END ANDROID virtual JavaValue getField(const JavaField*) = 0; // These functions are called before and after the main entry points into diff --git a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp index b22d57f..784ea01 100644 --- a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp @@ -146,10 +146,16 @@ bool JavaNPObjectInvoke(NPObject* obj, NPIdentifier identifier, const NPVariant* for (unsigned int i = 0; i < argCount; i++) jArgs[i] = convertNPVariantToJavaValue(args[i], jMethod->parameterAt(i)); - JavaValue jResult = instance->invokeMethod(jMethod, jArgs); +// ANDROID + bool exceptionOccurred; + JavaValue jResult = instance->invokeMethod(jMethod, jArgs, exceptionOccurred); instance->end(); delete[] jArgs; + if (exceptionOccurred) + return false; +// END ANDROID + VOID_TO_NPVARIANT(*result); convertJavaValueToNPVariant(jResult, result); return true; |