Skip to content

Commit

Permalink
Merge pull request #129 from tjb900/class_global_ref_pr
Browse files Browse the repository at this point in the history
generate global references for classes
  • Loading branch information
LeeKamentsky committed Mar 27, 2018
2 parents 439246a + aaa92d8 commit b7c9a31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions _javabridge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ cdef extern from "jni.h":
jclass (* FindClass)(JNIEnv *env, char *name) nogil
jclass (* GetObjectClass)(JNIEnv *env, jobject obj) nogil
jboolean (* IsInstanceOf)(JNIEnv *env, jobject obj, jclass klass) nogil
jclass (* NewGlobalRef)(JNIEnv *env, jobject lobj) nogil
jobject (* NewGlobalRef)(JNIEnv *env, jobject lobj) nogil
void (* DeleteGlobalRef)(JNIEnv *env, jobject gref) nogil
void (* DeleteLocalRef)(JNIEnv *env, jobject obj) nogil
#
Expand Down Expand Up @@ -800,8 +800,12 @@ cdef class JB_Env:
if c == NULL:
print "Failed to get class "+name
return
cref = self.env[0].NewGlobalRef(self.env, c)
if cref == NULL:
return (None, MemoryError("Failed to make new global reference"))
self.env[0].DeleteLocalRef(self.env, c)
result = JB_Class()
result.c = c
result.c = cref
return result

def get_object_class(self, JB_Object o):
Expand Down

0 comments on commit b7c9a31

Please sign in to comment.