Skip to content

Commit 9e0a3d4

Browse files
committed
unix/modjni: Convert Java's IndexOutOfBoundsException to Python's IndexError.
1 parent 90b1cc5 commit 9e0a3d4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

unix/modjni.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ static jmethodID List_get_mid;
5555
static jmethodID List_set_mid;
5656
static jmethodID List_size_mid;
5757

58+
static jclass IndexException_class;
59+
5860
STATIC const mp_obj_type_t jobject_type;
5961
STATIC const mp_obj_type_t jmethod_type;
6062

@@ -98,6 +100,9 @@ STATIC void check_exception(void) {
98100
//JJ1(ExceptionDescribe);
99101
mp_obj_t py_e = new_jobject(exc);
100102
JJ1(ExceptionClear);
103+
if (JJ(IsInstanceOf, exc, IndexException_class)) {
104+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, py_e));
105+
}
101106
nlr_raise(mp_obj_new_exception_arg1(&mp_type_Exception, py_e));
102107
}
103108
}
@@ -513,6 +518,7 @@ STATIC void create_jvm() {
513518
"(ILjava/lang/Object;)Ljava/lang/Object;");
514519
List_size_mid = JJ(GetMethodID, List_class, "size",
515520
"()I");
521+
IndexException_class = JJ(FindClass, "java/lang/IndexOutOfBoundsException");
516522
}
517523

518524
STATIC mp_obj_t mod_jni_cls(mp_obj_t cls_name_in) {

0 commit comments

Comments
 (0)