Skip to content
Snippets Groups Projects
Commit 91f2168d authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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.
parent ee7bebc9
No related branches found
No related tags found
No related merge requests found
...@@ -361,8 +361,8 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) { ...@@ -361,8 +361,8 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
return false; return false;
} }
} else if (type == &jobject_type) { } else if (type == &jobject_type) {
printf("TODO: Check java arg type!!\n");
bool is_object = false; bool is_object = false;
const char *expected_type = arg_type;
while (1) { while (1) {
if (isalpha(*arg_type)) { if (isalpha(*arg_type)) {
} else if (*arg_type == '.') { } else if (*arg_type == '.') {
...@@ -376,6 +376,14 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) { ...@@ -376,6 +376,14 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
return false; return false;
} }
mp_obj_jobject_t *jo = arg; mp_obj_jobject_t *jo = arg;
if (!MATCH(expected_type, "java.lang.Object")) {
char class_name[64];
get_jclass_name(jo->obj, class_name);
//printf("Arg class: %s\n", class_name);
if (strcmp(class_name, expected_type) != 0) {
return false;
}
}
out->l = jo->obj; out->l = jo->obj;
} else if (type == &mp_type_bool) { } else if (type == &mp_type_bool) {
if (IMATCH(arg_type, "boolean")) { if (IMATCH(arg_type, "boolean")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment