@@ -107,13 +107,24 @@ STATIC void check_exception(void) {
107107 }
108108}
109109
110+ STATIC void print_jobject (const mp_print_t * print , jobject obj ) {
111+ jobject str_o = JJ (CallObjectMethod , obj , Object_toString_mid );
112+ const char * str = JJ (GetStringUTFChars , str_o , NULL );
113+ mp_printf (print , str );
114+ JJ (ReleaseStringUTFChars , str_o , str );
115+ }
116+
110117// jclass
111118
112119STATIC void jclass_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
113- (void )kind ;
114120 mp_obj_jclass_t * self = self_in ;
115- // Variable value printed as cast to int
116- mp_printf (print , "<jclass @%p>" , self -> cls );
121+ if (kind == PRINT_REPR ) {
122+ mp_printf (print , "<jclass @%p \"" , self -> cls );
123+ }
124+ print_jobject (print , self -> cls );
125+ if (kind == PRINT_REPR ) {
126+ mp_printf (print , "\">" );
127+ }
117128}
118129
119130STATIC void jclass_attr (mp_obj_t self_in , qstr attr_in , mp_obj_t * dest ) {
@@ -184,10 +195,7 @@ STATIC void jobject_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
184195 if (kind == PRINT_REPR ) {
185196 mp_printf (print , "<jobject @%p \"" , self -> obj );
186197 }
187- jobject str_o = JJ (CallObjectMethod , self -> obj , Object_toString_mid );
188- const char * str = JJ (GetStringUTFChars , str_o , NULL );
189- mp_printf (print , str );
190- JJ (ReleaseStringUTFChars , str_o , str );
198+ print_jobject (print , self -> obj );
191199 if (kind == PRINT_REPR ) {
192200 mp_printf (print , "\">" );
193201 }
0 commit comments