summaryrefslogtreecommitdiffstats
path: root/media/jni/android_media_MediaMetadataRetriever.cpp
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-04-05 22:44:45 -0700
committerBrian Carlstrom <bdc@google.com>2011-04-06 10:04:20 -0700
commit46e18c11d46a2bc1a46174f963d0ed1224d94cd2 (patch)
tree266818e339e08cea909f21b9af492f5ffc83079d /media/jni/android_media_MediaMetadataRetriever.cpp
parent14faa3bd8bd6d1deab63a40ad2f8b6e451a16208 (diff)
downloadframeworks_base-46e18c11d46a2bc1a46174f963d0ed1224d94cd2.zip
frameworks_base-46e18c11d46a2bc1a46174f963d0ed1224d94cd2.tar.gz
frameworks_base-46e18c11d46a2bc1a46174f963d0ed1224d94cd2.tar.bz2
Don't use local ref for cached jclass reference in JNI code
Change-Id: Id45b2acb358a819f2fd332e99f3a095f6fc7299b related-to-bug: 4241138
Diffstat (limited to 'media/jni/android_media_MediaMetadataRetriever.cpp')
-rw-r--r--media/jni/android_media_MediaMetadataRetriever.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 5d9a3c5..27b37b7 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -441,19 +441,20 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env)
{
jclass clazz = env->FindClass(kClassPathName);
if (clazz == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find android/media/MediaMetadataRetriever");
return;
}
fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
if (fields.context == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaMetadataRetriever.mNativeContext");
return;
}
- fields.bitmapClazz = env->FindClass("android/graphics/Bitmap");
+ jclass bitmapClazz = env->FindClass("android/graphics/Bitmap");
+ if (bitmapClazz == NULL) {
+ return;
+ }
+ fields.bitmapClazz = (jclass) env->NewGlobalRef(bitmapClazz);
if (fields.bitmapClazz == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find android/graphics/Bitmap");
return;
}
fields.createBitmapMethod =
@@ -461,8 +462,6 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env)
"(IILandroid/graphics/Bitmap$Config;)"
"Landroid/graphics/Bitmap;");
if (fields.createBitmapMethod == NULL) {
- jniThrowException(env, "java/lang/RuntimeException",
- "Can't find Bitmap.createBitmap(int, int, Config) method");
return;
}
fields.createScaledBitmapMethod =
@@ -470,28 +469,25 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env)
"(Landroid/graphics/Bitmap;IIZ)"
"Landroid/graphics/Bitmap;");
if (fields.createScaledBitmapMethod == NULL) {
- jniThrowException(env, "java/lang/RuntimeException",
- "Can't find Bitmap.createScaledBitmap(Bitmap, int, int, boolean) method");
return;
}
fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "I");
if (fields.nativeBitmap == NULL) {
- jniThrowException(env, "java/lang/RuntimeException",
- "Can't find Bitmap.mNativeBitmap field");
+ return;
}
- fields.configClazz = env->FindClass("android/graphics/Bitmap$Config");
+ jclass configClazz = env->FindClass("android/graphics/Bitmap$Config");
+ if (configClazz == NULL) {
+ return;
+ }
+ fields.configClazz = (jclass) env->NewGlobalRef(configClazz);
if (fields.configClazz == NULL) {
- jniThrowException(env, "java/lang/RuntimeException",
- "Can't find Bitmap$Config class");
return;
}
fields.createConfigMethod =
env->GetStaticMethodID(fields.configClazz, "nativeToConfig",
"(I)Landroid/graphics/Bitmap$Config;");
if (fields.createConfigMethod == NULL) {
- jniThrowException(env, "java/lang/RuntimeException",
- "Can't find Bitmap$Config.nativeToConfig(int) method");
return;
}
}