summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/bridge/jni/jni_class.cpp5
-rw-r--r--WebCore/bridge/jni/jni_runtime.cpp3
-rw-r--r--WebCore/bridge/jni/jni_utility.h3
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp14
-rw-r--r--WebKit/android/jni/WebCoreJni.h7
5 files changed, 25 insertions, 7 deletions
diff --git a/WebCore/bridge/jni/jni_class.cpp b/WebCore/bridge/jni/jni_class.cpp
index 87750aa..4e3b5f9 100644
--- a/WebCore/bridge/jni/jni_class.cpp
+++ b/WebCore/bridge/jni/jni_class.cpp
@@ -85,6 +85,11 @@ JavaClass::JavaClass(jobject anInstance)
methodList->append(aMethod);
env->DeleteLocalRef(aJMethod);
}
+#ifdef ANDROID_FIX
+ env->DeleteLocalRef(fields);
+ env->DeleteLocalRef(methods);
+ env->DeleteLocalRef(aClass);
+#endif
}
JavaClass::~JavaClass() {
diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp
index 932e56c..38d6d6c 100644
--- a/WebCore/bridge/jni/jni_runtime.cpp
+++ b/WebCore/bridge/jni/jni_runtime.cpp
@@ -284,6 +284,9 @@ JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod)
jclass modifierClass = env->FindClass("java/lang/reflect/Modifier");
int modifiers = callJNIMethod<jint>(aMethod, "getModifiers", "()I");
_isStatic = (bool)callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers);
+#ifdef ANDROID_FIX
+ env->DeleteLocalRef(modifierClass);
+#endif
}
JavaMethod::~JavaMethod()
diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/jni_utility.h
index a08cc5d..e76570c 100644
--- a/WebCore/bridge/jni/jni_utility.h
+++ b/WebCore/bridge/jni/jni_utility.h
@@ -216,6 +216,9 @@ static T callJNIMethodV(jobject obj, const char *name, const char *sig, va_list
jmethodID mid = env->GetMethodID(cls, name, sig);
if ( mid != NULL )
{
+#ifdef ANDROID_FIX // Avoids references to cls without popping the local frame.
+ env->DeleteLocalRef(cls);
+#endif
return JNICaller<T>::callV(obj, mid, args);
}
else
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index ccca088..91103fb 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -953,10 +953,10 @@ protected:
JNIEnv* env = getJNIEnv();
// This is odd. getRealObject returns an AutoJObject which is used to
// cleanly create and delete a local reference. But, here we need to
- // maintain the local reference across calls to strong() and weak().
- // So, create a new local reference to the real object here and delete
- // it in weak().
- _realObject = env->NewLocalRef(getRealObject(env, _weakRef).get());
+ // maintain the local reference across calls to virtualBegin() and
+ // virtualEnd(). So, release the local reference from the AutoJObject
+ // and delete the local reference in virtualEnd().
+ _realObject = getRealObject(env, _weakRef).release();
// Point to the real object
_instance->_instance = _realObject;
// Call the base class method
@@ -964,12 +964,12 @@ protected:
}
virtual void virtualEnd() {
- // Get rid of the local reference to the real object
+ // Call the base class method first to pop the local frame.
+ INHERITED::virtualEnd();
+ // Get rid of the local reference to the real object.
getJNIEnv()->DeleteLocalRef(_realObject);
// Point back to the WeakReference.
_instance->_instance = _weakRef;
- // Call the base class method
- INHERITED::virtualEnd();
}
private:
diff --git a/WebKit/android/jni/WebCoreJni.h b/WebKit/android/jni/WebCoreJni.h
index d6e48c7..0b55497 100644
--- a/WebKit/android/jni/WebCoreJni.h
+++ b/WebKit/android/jni/WebCoreJni.h
@@ -42,6 +42,13 @@ public:
jobject get() const {
return m_obj;
}
+ // Releases the local reference to the caller. The caller *must* delete the
+ // local reference when it is done with it.
+ jobject release() {
+ jobject obj = m_obj;
+ m_obj = 0;
+ return obj;
+ }
JNIEnv* env() const {
return m_env;
}