如何捕获无效的间接引用异常?

时间:2016-01-20 08:02:29

标签: android java-native-interface

以下代码在获取包名时会导致dvmAbort()。但是上下文对象是全局Application对象,这个引用应该是有效的。

我想抓住这个例外或解决这个崩溃,谁可以帮助我?

jclass ctx_class = env->GetObjectClass(context);

>>> Backtrace <<<
#00 pc 00022184  /system/lib/libc.so (tgkill+12)
#01 pc 000131d9  /system/lib/libc.so (pthread_kill+48)
#02 pc 000133ed  /system/lib/libc.so (raise+10)
#03 pc 00012123  /system/lib/libc.so (?+0)
#04 pc 00021a38  /system/lib/libc.so (abort+4)
#05 pc 00048c9f  /system/lib/libdvm.so (dvmAbort+78)
#06 pc 0004d607  /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+146)
#07 pc 0005018b  /system/lib/libdvm.so (?+0)
#10 pc 000204cc  /system/lib/libdvm.so (dvmPlatformInvoke+112)
#11 pc 00051157  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#12 pc 00052b41  /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+184)
#13 pc 00029960  /system/lib/libdvm.so (?+0)
#14 pc 00030dec  /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#15 pc 0002e484  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#16 pc 000635b9  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#17 pc 000635dd  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#18 pc 000582bb  /system/lib/libdvm.so (?+0)
#19 pc 0000d2c8  /system/lib/libc.so (__thread_entry+72)
#20 pc 0000d460  /system/lib/libc.so (pthread_create+240)

0 个答案:

没有答案