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:
- always call
exceptioncheckorexceptionoccurredwhen calling jni functions may raise exceptions. - 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
Post a Comment