diff options
author | Steve Block <steveblock@google.com> | 2010-10-27 15:47:41 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-10-28 11:12:43 +0100 |
commit | bf3f67c4fcfd68df256e5c001c67969997a63e28 (patch) | |
tree | e78cada468d14c9cd244f2f565b90918b7e0bc57 /WebKit | |
parent | e59ed3e2c930c8eeed844aa0365e8285d956a8f2 (diff) | |
download | external_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.zip external_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.tar.gz external_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.tar.bz2 |
Make sure we delete local references to jclass objects
Change-Id: I1b398bd0a84ce366eb2e686e5f14335d7aa5ed31
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/jni/CookieManager.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/jni/DeviceMotionAndOrientationManager.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/jni/DeviceMotionClientImpl.cpp | 1 | ||||
-rw-r--r-- | WebKit/android/jni/DeviceOrientationClientImpl.cpp | 1 | ||||
-rwxr-xr-x | WebKit/android/jni/GeolocationPermissionsBridge.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 2 | ||||
-rwxr-xr-x | WebKit/android/jni/MockGeolocation.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreResourceLoader.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/jni/WebIconDatabase.cpp | 7 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 17 | ||||
-rw-r--r-- | WebKit/android/jni/WebStorage.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 5 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 18 |
15 files changed, 74 insertions, 13 deletions
diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp index 154dc5d..9688851 100644 --- a/WebKit/android/jni/CookieManager.cpp +++ b/WebKit/android/jni/CookieManager.cpp @@ -120,8 +120,11 @@ static JNINativeMethod gCookieManagerMethods[] = { int registerCookieManager(JNIEnv* env) { +#ifndef NDEBUG jclass cookieManager = env->FindClass(javaCookieManagerClass); LOG_ASSERT(cookieManager, "Unable to find class"); + env->DeleteLocalRef(cookieManager); +#endif return jniRegisterNativeMethods(env, javaCookieManagerClass, gCookieManagerMethods, NELEM(gCookieManagerMethods)); } diff --git a/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp b/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp index ad96c6c..9db83a3 100644 --- a/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp +++ b/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp @@ -121,6 +121,7 @@ static WebViewCore* getWebViewCore(JNIEnv* env, jobject webViewCoreObject) { jclass webViewCoreClass = env->FindClass("android/webkit/WebViewCore"); jfieldID nativeClassField = env->GetFieldID(webViewCoreClass, "mNativeClass", "I"); + env->DeleteLocalRef(webViewCoreClass); return reinterpret_cast<WebViewCore*>(env->GetIntField(webViewCoreObject, nativeClassField)); } @@ -159,8 +160,12 @@ static JNINativeMethod gDeviceMotionAndOrientationManagerMethods[] = { int registerDeviceMotionAndOrientationManager(JNIEnv* env) { - jclass deviceOrientationManager = env->FindClass(javaDeviceMotionAndOrientationManagerClass); - LOG_ASSERT(deviceOrientationManager, "Unable to find class"); +#ifndef NDEBUG + jclass deviceMotionAndOrientationManager = env->FindClass(javaDeviceMotionAndOrientationManagerClass); + LOG_ASSERT(deviceMotionAndOrientationManager, "Unable to find class"); + env->DeleteLocalRef(deviceMotionAndOrientationManager); +#endif + return jniRegisterNativeMethods(env, javaDeviceMotionAndOrientationManagerClass, gDeviceMotionAndOrientationManagerMethods, NELEM(gDeviceMotionAndOrientationManagerMethods)); } diff --git a/WebKit/android/jni/DeviceMotionClientImpl.cpp b/WebKit/android/jni/DeviceMotionClientImpl.cpp index 1517a19..82f3c35 100644 --- a/WebKit/android/jni/DeviceMotionClientImpl.cpp +++ b/WebKit/android/jni/DeviceMotionClientImpl.cpp @@ -82,6 +82,7 @@ jobject DeviceMotionClientImpl::getJavaInstance() env->GetMethodID(javaServiceClass, "suspend", "()V"); javaServiceClassMethodIDs[ServiceMethodResume] = env->GetMethodID(javaServiceClass, "resume", "()V"); + env->DeleteLocalRef(javaServiceClass); m_javaServiceObject = getJNIEnv()->NewGlobalRef(object); getJNIEnv()->DeleteLocalRef(object); diff --git a/WebKit/android/jni/DeviceOrientationClientImpl.cpp b/WebKit/android/jni/DeviceOrientationClientImpl.cpp index a295bf3..bf3b3c3 100644 --- a/WebKit/android/jni/DeviceOrientationClientImpl.cpp +++ b/WebKit/android/jni/DeviceOrientationClientImpl.cpp @@ -82,6 +82,7 @@ jobject DeviceOrientationClientImpl::getJavaInstance() env->GetMethodID(javaDeviceOrientationServiceClass, "suspend", "()V"); javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodResume] = env->GetMethodID(javaDeviceOrientationServiceClass, "resume", "()V"); + env->DeleteLocalRef(javaDeviceOrientationServiceClass); m_javaDeviceOrientationServiceObject = getJNIEnv()->NewGlobalRef(object); getJNIEnv()->DeleteLocalRef(object); diff --git a/WebKit/android/jni/GeolocationPermissionsBridge.cpp b/WebKit/android/jni/GeolocationPermissionsBridge.cpp index 5fea9a4..17628ab 100755 --- a/WebKit/android/jni/GeolocationPermissionsBridge.cpp +++ b/WebKit/android/jni/GeolocationPermissionsBridge.cpp @@ -47,6 +47,7 @@ static jobject getOrigins(JNIEnv* env, jobject obj) jmethodID constructor = env->GetMethodID(setClass, "<init>", "()V"); jmethodID addMethod = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z"); jobject set = env->NewObject(setClass, constructor); + env->DeleteLocalRef(setClass); GeolocationPermissions::OriginSet::const_iterator end = origins.end(); for (GeolocationPermissions::OriginSet::const_iterator iter = origins.begin(); iter != end; ++iter) { @@ -99,8 +100,11 @@ static JNINativeMethod gGeolocationPermissionsMethods[] = { int registerGeolocationPermissions(JNIEnv* env) { const char* kGeolocationPermissionsClass = "android/webkit/GeolocationPermissions"; +#ifndef NDEBUG jclass geolocationPermissions = env->FindClass(kGeolocationPermissionsClass); LOG_ASSERT(geolocationPermissions, "Unable to find class"); + env->DeleteLocalRef(geolocationPermissions); +#endif return jniRegisterNativeMethods(env, kGeolocationPermissionsClass, gGeolocationPermissionsMethods, NELEM(gGeolocationPermissionsMethods)); diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 9574739..49fb1b1 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -143,6 +143,7 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;"); mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); mResolveFilePathForContentUri = env->GetMethodID(clazz, "resolveFilePathForContentUri", "(Ljava/lang/String;)Ljava/lang/String;"); + env->DeleteLocalRef(clazz); LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer"); LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer"); @@ -491,6 +492,7 @@ int registerJavaBridge(JNIEnv* env) LOG_FATAL_IF(javaBridge == NULL, "Unable to find class android/webkit/JWebCoreJavaBridge"); gJavaBridge_ObjectID = env->GetFieldID(javaBridge, "mNativeBridge", "I"); LOG_FATAL_IF(gJavaBridge_ObjectID == NULL, "Unable to find android/webkit/JWebCoreJavaBridge.mNativeBridge"); + env->DeleteLocalRef(javaBridge); return jniRegisterNativeMethods(env, "android/webkit/JWebCoreJavaBridge", gWebCoreJavaBridgeMethods, NELEM(gWebCoreJavaBridgeMethods)); diff --git a/WebKit/android/jni/MockGeolocation.cpp b/WebKit/android/jni/MockGeolocation.cpp index d10ff83..1370715 100755 --- a/WebKit/android/jni/MockGeolocation.cpp +++ b/WebKit/android/jni/MockGeolocation.cpp @@ -72,8 +72,12 @@ static JNINativeMethod gMockGeolocationMethods[] = { int registerMockGeolocation(JNIEnv* env) { +#ifndef NDEBUG jclass mockGeolocation = env->FindClass(javaMockGeolocationClass); LOG_ASSERT(mockGeolocation, "Unable to find class"); + env->DeleteLocalRef(mockGeolocation); +#endif + return jniRegisterNativeMethods(env, javaMockGeolocationClass, gMockGeolocationMethods, NELEM(gMockGeolocationMethods)); } diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 42843e0..bc20c47 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -276,6 +276,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* "(ILjava/lang/String;Ljava/lang/String;Z)V"); mJavaFrame->mDownloadStart = env->GetMethodID(clazz, "downloadStart", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V"); + env->DeleteLocalRef(clazz); LOG_ASSERT(mJavaFrame->mInputStreamForAndroidResource, "Could not find method inputStreamForAndroidResource"); LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource"); @@ -1708,6 +1709,7 @@ static jobjectArray GetUsernamePassword(JNIEnv *env, jobject obj) if (found) { jclass stringClass = env->FindClass("java/lang/String"); strArray = env->NewObjectArray(2, stringClass, NULL); + env->DeleteLocalRef(stringClass); env->SetObjectArrayElement(strArray, 0, env->NewString(username.characters(), username.length())); env->SetObjectArrayElement(strArray, 1, env->NewString(password.characters(), password.length())); } @@ -1921,6 +1923,7 @@ int registerWebFrame(JNIEnv* env) LOG_ASSERT(clazz, "Cannot find BrowserFrame"); gFrameField = env->GetFieldID(clazz, "mNativeFrame", "I"); LOG_ASSERT(gFrameField, "Cannot find mNativeFrame on BrowserFrame"); + env->DeleteLocalRef(clazz); return jniRegisterNativeMethods(env, "android/webkit/BrowserFrame", gBrowserFrameNativeMethods, NELEM(gBrowserFrameNativeMethods)); diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index 06f0021..301ccde 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -122,9 +122,9 @@ bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t WTF::String urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); - bool val = env->CallStaticBooleanMethod(resourceLoader, - gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier); + bool val = env->CallStaticBooleanMethod(resourceLoader, gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier); checkException(env); + env->DeleteLocalRef(resourceLoader); env->DeleteLocalRef(jUrlStr); return val; @@ -347,6 +347,8 @@ int registerResourceLoader(JNIEnv* env) LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL, "Could not find static method willLoadFromCache on LoadListener"); + env->DeleteLocalRef(resourceLoader); + return jniRegisterNativeMethods(env, "android/webkit/LoadListener", gResourceloaderMethods, NELEM(gResourceloaderMethods)); } diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index 474574e..deff687 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -329,6 +329,7 @@ void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) // Allocate a blank WebHistoryItem jclass clazz = env->FindClass("android/webkit/WebHistoryItem"); jobject newItem = env->NewObject(clazz, gWebHistoryItem.mInit); + env->DeleteLocalRef(clazz); // Create the bridge, make it active, and attach it to the item. WebHistoryItem* bridge = new WebHistoryItem(env, newItem, item); @@ -815,6 +816,7 @@ int registerWebHistory(JNIEnv* env) LOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem"); gWebHistoryItem.mUrl = env->GetFieldID(clazz, "mUrl", "Ljava/lang/String;"); LOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem"); + env->DeleteLocalRef(clazz); // Find the WebBackForwardList object and method. clazz = env->FindClass("android/webkit/WebBackForwardList"); @@ -827,6 +829,7 @@ int registerWebHistory(JNIEnv* env) LOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem"); gWebBackForwardList.mSetCurrentIndex = env->GetMethodID(clazz, "setCurrentIndex", "(I)V"); LOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex"); + env->DeleteLocalRef(clazz); int result = jniRegisterNativeMethods(env, "android/webkit/WebBackForwardList", gWebBackForwardListMethods, NELEM(gWebBackForwardListMethods)); diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp index 8f5aa87..a9f6b05 100644 --- a/WebKit/android/jni/WebIconDatabase.cpp +++ b/WebKit/android/jni/WebIconDatabase.cpp @@ -206,8 +206,11 @@ static JNINativeMethod gWebIconDatabaseMethods[] = { int registerWebIconDatabase(JNIEnv* env) { - jclass webIconDB = env->FindClass("android/webkit/WebIconDatabase"); - LOG_ASSERT(webIconDB, "Unable to find class android.webkit.WebIconDatabase"); +#ifndef NDEBUG + jclass webIconDatabase = env->FindClass("android/webkit/WebIconDatabase"); + LOG_ASSERT(webIconDatabase, "Unable to find class android.webkit.WebIconDatabase"); + env->DeleteLocalRef(webIconDatabase); +#endif return jniRegisterNativeMethods(env, "android/webkit/WebIconDatabase", gWebIconDatabaseMethods, NELEM(gWebIconDatabaseMethods)); diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 825476b..62594ff 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -140,6 +140,7 @@ struct FieldIds { mAutoFillProfileZipCode = env->GetFieldID(autoFillProfileClass, "mZipCode", "Ljava/lang/String;"); mAutoFillProfileCountry = env->GetFieldID(autoFillProfileClass, "mCountry", "Ljava/lang/String;"); mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;"); + env->DeleteLocalRef(autoFillProfileClass); #endif LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); @@ -181,13 +182,16 @@ struct FieldIds { LOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); LOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); - jclass c = env->FindClass("java/lang/Enum"); - LOG_ASSERT(c, "Could not find Enum class!"); - mOrdinal = env->GetMethodID(c, "ordinal", "()I"); + jclass enumClass = env->FindClass("java/lang/Enum"); + LOG_ASSERT(enumClass, "Could not find Enum class!"); + mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I"); LOG_ASSERT(mOrdinal, "Could not find method ordinal"); - c = env->FindClass("android/webkit/WebSettings$TextSize"); - LOG_ASSERT(c, "Could not find TextSize enum"); - mTextSizeValue = env->GetFieldID(c, "value", "I"); + env->DeleteLocalRef(enumClass); + + jclass textSizeClass = env->FindClass("android/webkit/WebSettings$TextSize"); + LOG_ASSERT(textSizeClass, "Could not find TextSize enum"); + mTextSizeValue = env->GetFieldID(textSizeClass, "value", "I"); + env->DeleteLocalRef(textSizeClass); } // Field ids @@ -534,6 +538,7 @@ int registerWebSettings(JNIEnv* env) jclass clazz = env->FindClass("android/webkit/WebSettings"); LOG_ASSERT(clazz, "Unable to find class WebSettings!"); gFieldIds = new FieldIds(env, clazz); + env->DeleteLocalRef(clazz); return jniRegisterNativeMethods(env, "android/webkit/WebSettings", gWebSettingsMethods, NELEM(gWebSettingsMethods)); } diff --git a/WebKit/android/jni/WebStorage.cpp b/WebKit/android/jni/WebStorage.cpp index 10e0de0..23220f4 100644 --- a/WebKit/android/jni/WebStorage.cpp +++ b/WebKit/android/jni/WebStorage.cpp @@ -58,6 +58,7 @@ static jobject GetOrigins(JNIEnv* env, jobject obj) jmethodID cid = env->GetMethodID(setClass, "<init>", "()V"); jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z"); jobject set = env->NewObject(setClass, cid); + env->DeleteLocalRef(setClass); for (unsigned i = 0; i < coreOrigins.size(); ++i) { WebCore::SecurityOrigin* origin = coreOrigins[i].get(); @@ -165,8 +166,11 @@ static JNINativeMethod gWebStorageMethods[] = { int registerWebStorage(JNIEnv* env) { +#ifndef NDEBUG jclass webStorage = env->FindClass("android/webkit/WebStorage"); LOG_ASSERT(webStorage, "Unable to find class android.webkit.WebStorage"); + env->DeleteLocalRef(webStorage); +#endif return jniRegisterNativeMethods(env, "android/webkit/WebStorage", gWebStorageMethods, NELEM(gWebStorageMethods)); diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 1c903f4..9edc1e2 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -195,6 +195,7 @@ jobject WebViewCore::getApplicationContext() { JNIEnv* env = JSC::Bindings::getJNIEnv(); jclass contextClass = env->GetObjectClass(context); jmethodID appContextMethod = env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;"); + env->DeleteLocalRef(contextClass); jobject result = env->CallObjectMethod(context, appContextMethod); checkException(env); return result; @@ -213,6 +214,7 @@ bool WebViewCore::isSupportedMediaMimeType(const WTF::String& mimeType) { bool val = env->CallStaticBooleanMethod(webViewCore, gWebViewCoreStaticMethods.m_isSupportedMediaMimeType, jMimeType); checkException(env); + env->DeleteLocalRef(webViewCore); env->DeleteLocalRef(jMimeType); return val; @@ -378,6 +380,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_setScrollbarModes = GetJMethod(env, clazz, "setScrollbarModes", "(II)V"); m_javaGlue->m_setInstallableWebApp = GetJMethod(env, clazz, "setInstallableWebApp", "()V"); m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(I)V"); + env->DeleteLocalRef(clazz); env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); @@ -4115,6 +4118,8 @@ int registerWebViewCore(JNIEnv* env) LOG_FATAL_IF(gWebViewCoreStaticMethods.m_isSupportedMediaMimeType == NULL, "Could not find static method isSupportedMediaMimeType from WebViewCore"); + env->DeleteLocalRef(widget); + return jniRegisterNativeMethods(env, "android/webkit/WebViewCore", gJavaWebViewCoreMethods, NELEM(gJavaWebViewCoreMethods)); } diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 31c8bb5..ae09a7e 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -156,18 +156,24 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) : m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V"); m_javaGlue.m_postInvalidateDelayed = GetJMethod(env, clazz, "viewInvalidateDelayed", "(JIIII)V"); + env->DeleteLocalRef(clazz); + jclass rectClass = env->FindClass("android/graphics/Rect"); LOG_ASSERT(rectClass, "Could not find Rect class"); m_javaGlue.m_rectLeft = env->GetFieldID(rectClass, "left", "I"); m_javaGlue.m_rectTop = env->GetFieldID(rectClass, "top", "I"); m_javaGlue.m_rectWidth = GetJMethod(env, rectClass, "width", "()I"); m_javaGlue.m_rectHeight = GetJMethod(env, rectClass, "height", "()I"); + env->DeleteLocalRef(rectClass); + jclass rectClassF = env->FindClass("android/graphics/RectF"); LOG_ASSERT(rectClassF, "Could not find RectF class"); m_javaGlue.m_rectFLeft = env->GetFieldID(rectClassF, "left", "F"); m_javaGlue.m_rectFTop = env->GetFieldID(rectClassF, "top", "F"); m_javaGlue.m_rectFWidth = GetJMethod(env, rectClassF, "width", "()F"); m_javaGlue.m_rectFHeight = GetJMethod(env, rectClassF, "height", "()F"); + env->DeleteLocalRef(rectClassF); + env->SetIntField(javaWebView, gWebViewField, (jint)this); m_viewImpl = (WebViewCore*) viewImpl; m_frameCacheUI = 0; @@ -345,6 +351,7 @@ void calcOurContentVisibleRect(SkRect* r) r->fTop = env->GetFloatField(jRect, m_javaGlue.m_rectFTop); r->fRight = r->fLeft + env->CallFloatMethod(jRect, m_javaGlue.m_rectFWidth); r->fBottom = r->fTop + env->CallFloatMethod(jRect, m_javaGlue.m_rectFHeight); + env->DeleteLocalRef(rectClass); env->DeleteLocalRef(jRect); checkException(env); } @@ -1356,6 +1363,7 @@ static jobject nativeCacheHitNodeBounds(JNIEnv *env, jobject obj) jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); jobject rect = env->NewObject(rectClass, init, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + env->DeleteLocalRef(rectClass); return rect; } @@ -1489,6 +1497,7 @@ static jobject nativeCursorNodeBounds(JNIEnv *env, jobject obj) jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); jobject rect = env->NewObject(rectClass, init, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + env->DeleteLocalRef(rectClass); return rect; } @@ -1508,6 +1517,7 @@ static jobject nativeCursorPosition(JNIEnv *env, jobject obj) jclass pointClass = env->FindClass("android/graphics/Point"); jmethodID init = env->GetMethodID(pointClass, "<init>", "(II)V"); jobject point = env->NewObject(pointClass, init, pos.x(), pos.y()); + env->DeleteLocalRef(pointClass); return point; } @@ -1669,6 +1679,7 @@ static jobject createJavaRect(JNIEnv* env, int x, int y, int right, int bottom) jclass rectClass = env->FindClass("android/graphics/Rect"); jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); jobject rect = env->NewObject(rectClass, init, x, y, right, bottom); + env->DeleteLocalRef(rectClass); return rect; } @@ -1742,6 +1753,7 @@ static jobject nativeFocusNodeBounds(JNIEnv *env, jobject obj) jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); jobject rect = env->NewObject(rectClass, init, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + env->DeleteLocalRef(rectClass); return rect; } @@ -1793,8 +1805,10 @@ static jobject nativeSubtractLayers(JNIEnv* env, jobject obj, jobject jrect) #endif jclass rectClass = env->FindClass("android/graphics/Rect"); jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); - return env->NewObject(rectClass, init, irect.fLeft, irect.fTop, + jobject rect = env->NewObject(rectClass, init, irect.fLeft, irect.fTop, irect.fRight, irect.fBottom); + env->DeleteLocalRef(rectClass); + return rect; } static jint nativeTextGeneration(JNIEnv *env, jobject obj) @@ -1881,6 +1895,7 @@ static jobject nativeGetCursorRingBounds(JNIEnv *env, jobject obj) view->cursorRingBounds(&webRect); jobject rect = env->NewObject(rectClass, init, webRect.x(), webRect.y(), webRect.right(), webRect.bottom()); + env->DeleteLocalRef(rectClass); return rect; } @@ -2363,6 +2378,7 @@ int registerWebView(JNIEnv* env) LOG_ASSERT(clazz, "Unable to find class android/webkit/WebView"); gWebViewField = env->GetFieldID(clazz, "mNativeClass", "I"); LOG_ASSERT(gWebViewField, "Unable to find android/webkit/WebView.mNativeClass"); + env->DeleteLocalRef(clazz); return jniRegisterNativeMethods(env, "android/webkit/WebView", gJavaWebViewMethods, NELEM(gJavaWebViewMethods)); } |