Clear NoSuchMethodError Exception when JniHelper fails to find methodID

When calling GetMethodID a NoSuchMethodError will be raised if the method cannot be found.
See http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#wp16660
This exception should be cleared if JNI execution is to be continued.
Currently JniHelper informs that the method is not found, but there is no way to continue execution without manually clearing the exception. This prevents checking for the existence of a method and recovering from it being missing.

This fix will clear the exception if JniHelper fails to find the method.
This commit is contained in:
Andrew Glass 2013-10-28 18:40:58 +00:00
parent 0380059445
commit 06bd7fafd5
1 changed files with 2 additions and 0 deletions

View File

@ -213,6 +213,7 @@ namespace cocos2d {
jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode);
if (! methodID) {
LOGD("Failed to find method id of %s", methodName);
pEnv->ExceptionClear();
return false;
}
@ -247,6 +248,7 @@ namespace cocos2d {
jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode);
if (! methodID) {
LOGD("Failed to find method id of %s", methodName);
pEnv->ExceptionClear();
return false;
}