@@ -354,29 +354,31 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool
354354// printf("found!\n");
355355 jmethodID method_id = JJ (FromReflectedMethod , meth );
356356 jobject res ;
357+ mp_obj_t ret ;
357358 if (is_constr ) {
358- res = JJ (NewObjectA , obj , method_id , jargs );
359359 JJ (ReleaseStringUTFChars , name_o , decl );
360+ res = JJ (NewObjectA , obj , method_id , jargs );
360361 return new_jobject (res );
361362 } else {
362363 if (MATCH (ret_type , "void" )) {
363364 JJ (CallVoidMethodA , obj , method_id , jargs );
364- return mp_const_none ;
365+ ret = mp_const_none ;
365366 } else if (MATCH (ret_type , "int" )) {
366367 jint res = JJ (CallIntMethodA , obj , method_id , jargs );
367- return mp_obj_new_int (res );
368+ ret = mp_obj_new_int (res );
368369 } else if (MATCH (ret_type , "boolean" )) {
369370 jboolean res = JJ (CallBooleanMethodA , obj , method_id , jargs );
370- return mp_obj_new_bool (res );
371+ ret = mp_obj_new_bool (res );
371372 } else if (is_object_type (ret_type )) {
372373 res = JJ (CallObjectMethodA , obj , method_id , jargs );
373- mp_obj_t ret = jvalue2py (ret_type , res );
374+ ret = new_jobject (res );
375+ } else {
374376 JJ (ReleaseStringUTFChars , name_o , decl );
375- if (ret != MP_OBJ_NULL ) {
376- return ret ;
377- }
377+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError , "cannot handle return type" ));
378378 }
379- nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError , "cannot handle return type" ));
379+
380+ JJ (ReleaseStringUTFChars , name_o , decl );
381+ return ret ;
380382 }
381383 }
382384
0 commit comments