From 2df76cb7f62e2dff6476e39e0783815b74161574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 1 Aug 2013 21:25:20 +0200 Subject: [PATCH 1/3] Check for exception after calling constructor --- jnius/jnius_export_class.pxi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jnius/jnius_export_class.pxi b/jnius/jnius_export_class.pxi index 1256720..790d967 100644 --- a/jnius/jnius_export_class.pxi +++ b/jnius/jnius_export_class.pxi @@ -218,6 +218,8 @@ cdef class JavaClass(object): # create the object j_self = j_env[0].NewObjectA(j_env, self.j_cls, constructor, j_args) + + check_exception(j_env) if j_self == NULL: raise JavaException('Unable to instanciate {0}'.format( self.__javaclass__)) From d6a3d1cf5f609a94671c697e30dac6df71e90578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 1 Aug 2013 22:38:27 +0200 Subject: [PATCH 2/3] Delete local reference after constructing class --- jnius/jnius_export_class.pxi | 1 + 1 file changed, 1 insertion(+) diff --git a/jnius/jnius_export_class.pxi b/jnius/jnius_export_class.pxi index 790d967..a62a913 100644 --- a/jnius/jnius_export_class.pxi +++ b/jnius/jnius_export_class.pxi @@ -225,6 +225,7 @@ cdef class JavaClass(object): self.__javaclass__)) self.j_self = create_local_ref(j_env, j_self) + j_env[0].DeleteLocalRef(j_env, j_self) finally: if j_args != NULL: free(j_args) From 35c410e542f6f45f6b56f6ff051ecb407afde23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Fri, 2 Aug 2013 14:14:50 +0200 Subject: [PATCH 3/3] fix lookup_java_object_name local reference leak --- jnius/jnius_utils.pxi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jnius/jnius_utils.pxi b/jnius/jnius_utils.pxi index 7d893b4..05d54f7 100644 --- a/jnius/jnius_utils.pxi +++ b/jnius/jnius_utils.pxi @@ -77,6 +77,9 @@ cdef bytes lookup_java_object_name(JNIEnv *j_env, jobject j_obj): cdef jmethodID jmeth = j_env[0].GetMethodID(j_env, jcls2, 'getName', '()Ljava/lang/String;') cdef jobject js = j_env[0].CallObjectMethod(j_env, jcls, jmeth) name = convert_jobject_to_python(j_env, b'Ljava/lang/String;', js) + j_env[0].DeleteLocalRef(j_env, js) + j_env[0].DeleteLocalRef(j_env, jcls) + j_env[0].DeleteLocalRef(j_env, jcls2) return name.replace('.', '/')