From 06bd7fafd51a164c11894f5f44659cd2fcb386ea Mon Sep 17 00:00:00 2001 From: Andrew Glass Date: Mon, 28 Oct 2013 18:40:58 +0000 Subject: [PATCH] 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. --- cocos/2d/platform/android/jni/JniHelper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/platform/android/jni/JniHelper.cpp b/cocos/2d/platform/android/jni/JniHelper.cpp index ab3bfc3855..9555643d7a 100644 --- a/cocos/2d/platform/android/jni/JniHelper.cpp +++ b/cocos/2d/platform/android/jni/JniHelper.cpp @@ -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; }