简体   繁体   English

在Java层中捕获JNI异常

[英]Catch JNI exceptions in Java layer

I have an Android application that I'm writing, and it uses a module that runs on the JNI layer. 我有一个正在编写的Android应用程序,它使用在JNI层上运行的模块。 I have no control or knowledge on how the NDK module works, and it sometimes throws an un-handled exception, and my app crashes. 我对NDK模块的工作方式没有任何控制或知识,有时它会引发未处理的异常,并且我的应用程序崩溃。

Is there any way to catch those JNI propagating exceptions in the Java layer? 有什么方法可以在Java层中捕获那些JNI传播异常? Or at least detect when the DNK is going to crash due to an exception? 或者至少检测DNK何时由于异常而崩溃?

JNI exceptions propagate to the Java layer. JNI异常传播到Java层。 The problem is that they only do so when the JNI method returns. 问题在于它们仅在JNI方法返回时才这样做。 In the meantime it may have perpetrated all kinds of self-harm while in an invalid state due to a prior exception. 同时,由于先前的异常,它可能在处于无效状态时进行各种自残。 You need to get hold of the JNI source code and fix it, or complain to the vendor/supplier if you can't. 您需要掌握并修复JNI源代码,否则,请向供应商/供应商投诉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM