ExceptionOccurred creates a local reference for the jthrowable, but the generated code simply checks if it is non-null. Use ExceptionCheck instead.
--- java.cxx (revision 12640)
+++ java.cxx (working copy)
@@ -3990,7 +3990,7 @@
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
- Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
+ Printf(w->code, "if (jenv->ExceptionCheck() == JNI_TRUE) return $null;\n");
if (!is_void) {
String *jresult_str = NewString("jresult");
Thanks, applied for swig-2.0.4.