Skip to content

Commit 91f2168

Browse files
committed
unix/modjni: Actually check argument type when doing method resolution.
This is required to properly select among overloaded methods. It however relies on java.lang.Object-overloaded method to come last, which appears to be the case for OpenJDK.
1 parent ee7bebc commit 91f2168

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

unix/modjni.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
361361
return false;
362362
}
363363
} else if (type == &jobject_type) {
364-
printf("TODO: Check java arg type!!\n");
365364
bool is_object = false;
365+
const char *expected_type = arg_type;
366366
while (1) {
367367
if (isalpha(*arg_type)) {
368368
} else if (*arg_type == '.') {
@@ -376,6 +376,14 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
376376
return false;
377377
}
378378
mp_obj_jobject_t *jo = arg;
379+
if (!MATCH(expected_type, "java.lang.Object")) {
380+
char class_name[64];
381+
get_jclass_name(jo->obj, class_name);
382+
//printf("Arg class: %s\n", class_name);
383+
if (strcmp(class_name, expected_type) != 0) {
384+
return false;
385+
}
386+
}
379387
out->l = jo->obj;
380388
} else if (type == &mp_type_bool) {
381389
if (IMATCH(arg_type, "boolean")) {

0 commit comments

Comments
 (0)