summaryrefslogtreecommitdiffstats
path: root/WebCore/bridge/jni/jni_jsobject.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bridge/jni/jni_jsobject.mm')
-rw-r--r--WebCore/bridge/jni/jni_jsobject.mm45
1 files changed, 23 insertions, 22 deletions
diff --git a/WebCore/bridge/jni/jni_jsobject.mm b/WebCore/bridge/jni/jni_jsobject.mm
index de67711..603624f 100644
--- a/WebCore/bridge/jni/jni_jsobject.mm
+++ b/WebCore/bridge/jni/jni_jsobject.mm
@@ -128,7 +128,7 @@ static void dispatchToJavaScriptThread(JSObjectCallContext *context)
completionSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext);
CFRunLoopAddSource(currentRunLoop, completionSource, kCFRunLoopDefaultMode);
- // Wakeup JavaScript access thread and make it do it's work.
+ // Wakeup JavaScript access thread and make it do its work.
CFRunLoopSourceSignal(_performJavaScriptSource);
if (CFRunLoopIsWaiting(_performJavaScriptRunLoop))
CFRunLoopWakeUp(_performJavaScriptRunLoop);
@@ -533,7 +533,7 @@ jobject JavaJSObject::convertValueToJObject(JSValue value) const
// We either have a wrapper around a Java instance or a JavaScript
// object. If we have a wrapper around a Java instance, return that
// instance, otherwise create a new Java JavaJSObject with the JSObject*
- // as it's nativeHandle.
+ // as its nativeHandle.
if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) {
RuntimeObjectImp* runtimeImp = static_cast<RuntimeObjectImp*>(imp);
JavaInstance *runtimeInstance = static_cast<JavaInstance *>(runtimeImp->getInternalInstance());
@@ -552,7 +552,7 @@ jobject JavaJSObject::convertValueToJObject(JSValue value) const
nativeHandle = UndefinedHandle;
}
- // Now create the Java JavaJSObject. Look for the JavaJSObject in it's new (Tiger)
+ // Now create the Java JavaJSObject. Look for the JavaJSObject in its new (Tiger)
// location and in the original Java 1.4.2 location.
jclass JSObjectClass;
@@ -580,30 +580,31 @@ JSValue JavaJSObject::convertJObjectToValue(ExecState* exec, jobject theObject)
// See section 22.7 of 'JavaScript: The Definitive Guide, 4th Edition',
// figure 22-4.
jobject classOfInstance = callJNIMethod<jobject>(theObject, "getClass", "()Ljava/lang/Class;");
- jstring className = (jstring)callJNIMethod<jobject>(classOfInstance, "getName", "()Ljava/lang/String;");
-
+ if (!classOfInstance) {
+ JSLock lock(SilenceAssertionsOnly);
+ return JavaInstance::create(theObject, _rootObject)->createRuntimeObject(exec);
+ }
+
// Only the sun.plugin.javascript.webkit.JSObject has a member called nativeJSObject. This class is
// created above to wrap internal browser objects. The constructor of this class takes the native
// pointer and stores it in this object, so that it can be retrieved below.
- if (strcmp(JavaString(className).UTF8String(), "sun.plugin.javascript.webkit.JSObject") == 0) {
- // Pull the nativeJSObject value from the Java instance. This is a
- // pointer to the JSObject.
- JNIEnv *env = getJNIEnv();
- jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "J");
- if (fieldID == NULL) {
- return jsUndefined();
- }
- jlong nativeHandle = env->GetLongField(theObject, fieldID);
- if (nativeHandle == UndefinedHandle) {
- return jsUndefined();
- }
- JSObject *imp = static_cast<JSObject*>(jlong_to_impptr(nativeHandle));
- return imp;
+ jstring className = (jstring)callJNIMethod<jobject>(classOfInstance, "getName", "()Ljava/lang/String;");
+ if (!className || (strcmp(JavaString(className).UTF8String(), "sun.plugin.javascript.webkit.JSObject") != 0)) {
+ JSLock lock(SilenceAssertionsOnly);
+ return JavaInstance::create(theObject, _rootObject)->createRuntimeObject(exec);
}
- JSLock lock(SilenceAssertionsOnly);
-
- return JavaInstance::create(theObject, _rootObject)->createRuntimeObject(exec);
+ // Pull the nativeJSObject value from the Java instance. This is a
+ // pointer to the JSObject.
+ JNIEnv *env = getJNIEnv();
+ jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "J");
+ if (fieldID == NULL)
+ return jsUndefined();
+ jlong nativeHandle = env->GetLongField(theObject, fieldID);
+ if (nativeHandle == UndefinedHandle)
+ return jsUndefined();
+ JSObject *imp = static_cast<JSObject*>(jlong_to_impptr(nativeHandle));
+ return imp;
}
void JavaJSObject::getListFromJArray(ExecState* exec, jobjectArray jArray, MarkedArgumentBuffer& list) const