Skip to content

Commit c4489a0

Browse files
committed
unix/modjni: Propagate Java exceptions on list access.
1 parent 0eba162 commit c4489a0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

unix/modjni.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ STATIC bool is_object_type(const char *jtypesig) {
9292
return false;
9393
}
9494

95+
STATIC void check_exception(void) {
96+
jobject exc = JJ1(ExceptionOccurred);
97+
if (exc) {
98+
//JJ1(ExceptionDescribe);
99+
mp_obj_t py_e = new_jobject(exc);
100+
JJ1(ExceptionClear);
101+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_Exception, py_e));
102+
}
103+
}
104+
95105
// jclass
96106

97107
STATIC void jclass_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@@ -200,6 +210,9 @@ STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value)
200210
} else if (value == MP_OBJ_SENTINEL) {
201211
// load
202212
jobject el = JJ(CallObjectMethod, self->obj, List_get_mid, idx);
213+
if (el == NULL) {
214+
check_exception();
215+
}
203216
return new_jobject(el);
204217
} else {
205218
// store

0 commit comments

Comments
 (0)