Bug 709230 - Part 1: Add Android JNI error logging. r=blassey

This commit is contained in:
Chris Peterson 2012-07-11 10:29:03 -07:00
parent 60c32db945
commit bd1199a83c

View File

@ -92,17 +92,68 @@ jmethodID AndroidGeckoSurfaceView::jGetSoftwareDrawBufferMethod = 0;
jmethodID AndroidGeckoSurfaceView::jGetSurfaceMethod = 0;
jmethodID AndroidGeckoSurfaceView::jGetHolderMethod = 0;
static jclass GetClassGlobalRef(JNIEnv* env, const char* className)
{
jobject classLocalRef = env->FindClass(className);
if (!classLocalRef) {
ALOG(">>> FATAL JNI ERROR! FindClass(className=\"%s\") failed. Did "
"ProGuard optimize away a non-public class?", className);
env->ExceptionDescribe();
MOZ_CRASH();
}
jobject classGlobalRef = env->NewGlobalRef(classLocalRef);
if (!classGlobalRef) {
env->ExceptionDescribe();
MOZ_CRASH();
}
// Local ref no longer necessary because we have a global ref.
env->DeleteLocalRef(classLocalRef);
classLocalRef = NULL;
return static_cast<jclass>(classGlobalRef);
}
static jfieldID GetFieldID(JNIEnv* env, jclass jClass,
const char* fieldName, const char* fieldType)
{
jfieldID fieldID = env->GetFieldID(jClass, fieldName, fieldType);
if (!fieldID) {
ALOG(">>> FATAL JNI ERROR! GetFieldID(fieldName=\"%s\", "
"fieldType=\"%s\") failed. Did ProGuard optimize away a non-"
"public field?", fieldName, fieldType);
env->ExceptionDescribe();
MOZ_CRASH();
}
return fieldID;
}
static jmethodID GetMethodID(JNIEnv* env, jclass jClass,
const char* methodName, const char* methodType)
{
jmethodID methodID = env->GetMethodID(jClass, methodName, methodType);
if (!methodID) {
ALOG(">>> FATAL JNI ERROR! GetMethodID(methodName=\"%s\", "
"methodType=\"%s\") failed. Did ProGuard optimize away a non-"
"public method?", methodName, methodType);
env->ExceptionDescribe();
MOZ_CRASH();
}
return methodID;
}
#define initInit() jclass jClass
// note that this also sets jClass
#define getClassGlobalRef(cname) \
(jClass = jclass(jEnv->NewGlobalRef(jEnv->FindClass(cname))))
(jClass = GetClassGlobalRef(jEnv, cname))
#define getField(fname, ftype) \
((jfieldID) jEnv->GetFieldID(jClass, fname, ftype))
GetFieldID(jEnv, jClass, fname, ftype)
#define getMethod(fname, ftype) \
((jmethodID) jEnv->GetMethodID(jClass, fname, ftype))
GetMethodID(jEnv, jClass, fname, ftype)
RefCountedJavaObject::~RefCountedJavaObject() {
if (mObject)