From 2450298205d926c2679bd5fd2b25a614112436a0 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 28 May 2009 12:10:42 +0200 Subject: [PATCH] java plugin: Replace dots ('.') with slashes ('/') when loading a class. Thanks to Randy Rizun for pointing this out: Hi! just wanted to point out an issue in cjni_config_load_plugin the call to FindClass passes the "Name" verbatim from the LoadPlugin directive one might intuitively say LoadPlugin "com.foobar.Plugin" whereas FindClass wants to see it as "com/foobar/Plugin" so I guess either (a) document LoadPlugin to say to use slashes or (b) subst / for . in cjni_config_load_plugin or (c) something else?!? of course, everything works fine if my plugin is in the 'default' java package (i.e., no package name) =) either way, thanks a lot for the great work!! -Randy --- src/java.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/java.c b/src/java.c index c12cdfce..6a98d823 100644 --- a/src/java.c +++ b/src/java.c @@ -2179,6 +2179,15 @@ static int cjni_config_load_plugin (oconfig_item_t *ci) /* {{{ */ class->class = NULL; class->object = NULL; + { /* Replace all dots ('.') with slashes ('/'). Dots are usually used + thorough the Java community, but (Sun's) `FindClass' and friends need + slashes. */ + size_t i; + for (i = 0; class->name[i] != 0; i++) + if (class->name[i] == '.') + class->name[i] = '/'; + } + DEBUG ("java plugin: Loading class %s", class->name); class->class = (*jvm_env)->FindClass (jvm_env, class->name); -- 2.30.2