summaryrefslogtreecommitdiffstatshomepage
path: root/unix/modjni.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-10-23 00:33:03 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-10-23 00:33:54 +0300
commit91f2168dd53bf13807a7191b92851bf74fed0920 (patch)
tree8647e8b18916f9324961f01f5379d9928f465884 /unix/modjni.c
parentee7bebc94fa5a19757724187bc2b0b1727bb87ff (diff)
downloadmicropython-91f2168dd53bf13807a7191b92851bf74fed0920.tar.gz
micropython-91f2168dd53bf13807a7191b92851bf74fed0920.zip
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.
Diffstat (limited to 'unix/modjni.c')
-rw-r--r--unix/modjni.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/unix/modjni.c b/unix/modjni.c
index eeed389ba2..27470ae02b 100644
--- a/unix/modjni.c
+++ b/unix/modjni.c
@@ -361,8 +361,8 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
return false;
}
} else if (type == &jobject_type) {
- printf("TODO: Check java arg type!!\n");
bool is_object = false;
+ const char *expected_type = arg_type;
while (1) {
if (isalpha(*arg_type)) {
} else if (*arg_type == '.') {
@@ -376,6 +376,14 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
return false;
}
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;
} else if (type == &mp_type_bool) {
if (IMATCH(arg_type, "boolean")) {