I'd like to have a nice, tidy way of expressing the following java code as JNI:
try {
SomeMethod ();
}
catch (ExceptionType1 e) {
SomeAction ();
}
catch (ExceptionType2 e) {
SomeAction ();
}
catch (ExceptionType3 e) {
SomeAction ();
}
Is there a tidy JNI patter for doing this? At present, I have this:
java_class = (*env)->FindClass (env, EXCEPTION_CLASS_NAME);
if (java_class == NULL) {
*error_type_ref = ERROR_TYPE_FATAL;
*exception_code_ref = EU_StrSprintf ("Class not found: %s", EXCEPTION_CLASS_NAME);
cleanup ();
}
if ((*env)->IsInstanceOf (env, exception, java_class)) {
SomeAction ();
cleanup ();
}
And, of course, this reoccurs for each exception so handled. There has to be a better way. Any recommendations? I'm not interested in porting all of my existing code over to JNA, so I'd like a pattern that can be implemented home-grown, so to speak.