java - Which way should I check exceptions in JNI? -


as know, many methods in jni may cause exception , cannot called after exception caused may crash jvm. can not use exceptionoccurred() or exceptioncheck() determine whether exception occurred or not, can check not equal null or 0. way best practice?

as asking "best practice", answer straightforward:

  1. always call exceptioncheck or exceptionoccurred when calling jni functions may raise exceptions.
  2. always check return values jni functions

calling exceptionoccurred after each jni call, preferably in dedicated function, allows information on exception, logging, , allows call exceptionclear.

make dedicated function return void, , use return values jni functions distinguish between normal , error paths.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -