Skip to content

Commit 0eba162

Browse files
committed
unix/modjni: Fix method argument matching.
1 parent f3ca862 commit 0eba162

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

unix/modjni.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <string.h>
2929
#include <errno.h>
3030
#include <dlfcn.h>
31+
#include <ctype.h>
3132

3233
#include "py/nlr.h"
3334
#include "py/runtime0.h"
@@ -298,6 +299,9 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
298299
}
299300
} else if (type == &jobject_type) {
300301
printf("TODO: Check java arg type!!\n");
302+
while (isalpha(*arg_type) || *arg_type == '.') {
303+
arg_type++;
304+
}
301305
mp_obj_jobject_t *jo = arg;
302306
out->l = jo->obj;
303307
} else {
@@ -359,7 +363,7 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool
359363
// printf("name=%p meth_name=%s\n", name, meth_name);
360364

361365
bool found = true;
362-
for (int i = 0; i < n_args; i++) {
366+
for (int i = 0; i < n_args && *arg_types != ')'; i++) {
363367
if (!py2jvalue(&arg_types, args[i], &jargs[i])) {
364368
goto next_method;
365369
}
@@ -369,6 +373,10 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool
369373
}
370374
}
371375

376+
if (*arg_types != ')') {
377+
goto next_method;
378+
}
379+
372380
if (found) {
373381
// printf("found!\n");
374382
jmethodID method_id = JJ(FromReflectedMethod, meth);

0 commit comments

Comments
 (0)