Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a couple of code paths where exceptions weren't checked for #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions _javabridge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,14 @@ cdef class JB_Env:
if oresult == NULL:
result = None
else:
# call apparently succeeded, however:
# make_jb_object will call back into JNI to make global ref, which
# triggers JNI warnings that we did not check for exceptions
# calling code should be doing this as well - but it doesn't
# have the opportunity to do so before the next JNI call in this
# path.
jnienv[0].ExceptionOccurred(jnienv)

result, e = make_jb_object(self, oresult)
if e is not None:
raise e
Expand Down Expand Up @@ -1106,6 +1114,14 @@ cdef class JB_Env:
if oresult == NULL:
result = None
else:
# call apparently succeeded, however:
# make_jb_object will call back into JNI to make global ref, which
# triggers JNI warnings that we did not check for exceptions
# calling code should be doing this as well - but it doesn't
# have the opportunity to do so before the next JNI call in this
# path.
jnienv[0].ExceptionOccurred(jnienv)

result, e = make_jb_object(self, oresult)
if e is not None:
raise e
Expand Down
8 changes: 8 additions & 0 deletions javabridge/jutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,9 +1246,17 @@ def get_nice_result(result, sig):
rklass = env.get_object_class(result)
m = env.get_method_id(rklass, 'getClass', '()Ljava/lang/Class;')
rclass = env.call_method(result, m)
x = env.exception_occurred()
if x is not None:
raise JavaException(x)

rkklass = env.get_object_class(rclass)
m = env.get_method_id(rkklass, 'isPrimitive', '()Z')
is_primitive = env.call_method(rclass, m)
x = env.exception_occurred()
if x is not None:
raise JavaException(x)

if is_primitive:
rc = get_class_wrapper(rclass, True)
classname = rc.getCanonicalName()
Expand Down