Disadvantages of using Java Native Interface

前端 未结 6 1131
南旧
南旧 2020-12-29 13:46

I can not get these two disadvantages of using JNI. I want to know more about them:

  • Difficult to debug runtime error in native code

  • Errors i

6条回答
  •  感动是毒
    2020-12-29 14:19

    I'm not sure about JNI, but if you're using JNA, you can set Native.setProtected(true) and it will throw an error instead of crashing the JVM, so that you can catch it in try...catch block. So second disadvantage is not a problem. (see source code)

提交回复
热议问题