We should not mangle method's type but method's argumnet string. So method:
gnu/java/nio/channels/FileChannelImpl.write([BII)V should be mangled to: Java_gnu_java_nio_channels_FileChannelImpl_write___3BII not: Java_gnu_java_nio_channels_FileChannelImpl_write__(_3BII)V Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- vm/jni.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/vm/jni.c b/vm/jni.c index 9af45cb..ff6780f 100644 --- a/vm/jni.c +++ b/vm/jni.c @@ -138,6 +138,26 @@ static void *vm_jni_lookup_symbol(const char *symbol_name) return NULL; } +static char *get_method_args(const char *type) +{ + char *result, *end; + + if (type[0] != '(') + return NULL; + + result = strdup(type + 1); + + end = index(result, ')'); + if (!end) { + free(result); + return NULL; + } + + *end = 0; + + return result; +} + void *vm_jni_lookup_method(const char *class_name, const char *method_name, const char *method_type) { @@ -146,10 +166,13 @@ void *vm_jni_lookup_method(const char *class_name, const char *method_name, char *mangled_method_type; char *symbol_name; void *sym_addr; + char *method_args; + + method_args = get_method_args(method_type); mangled_class_name = vm_jni_get_mangled_name(class_name); mangled_method_name = vm_jni_get_mangled_name(method_name); - mangled_method_type = vm_jni_get_mangled_name(method_type); + mangled_method_type = vm_jni_get_mangled_name(method_args); symbol_name = NULL; if (asprintf(&symbol_name, "Java_%s_%s__%s", mangled_class_name, @@ -167,6 +190,7 @@ void *vm_jni_lookup_method(const char *class_name, const char *method_name, sym_addr = vm_jni_lookup_symbol(symbol_name); out: + free(method_args); free(mangled_method_name); free(mangled_class_name); free(mangled_method_type); -- 1.6.0.6 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel