summaryrefslogtreecommitdiff
path: root/src/jvm
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-06-02 21:58:50 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-06-02 21:58:50 +0300
commit6e5e3de6214bb792b126d481598e3e9313ea3bbb (patch)
tree983da788b4fce10f4da1b0651b661652a6f6ec10 /src/jvm
parentd56eea0f7f348984c5beeb81b8b7e2253dcb1b70 (diff)
jvm: Store class names like they are in java
com.foo.bar instead of com/foo/bar, only convert to latter form when needed.
Diffstat (limited to 'src/jvm')
-rw-r--r--src/jvm/jvm.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/jvm/jvm.c b/src/jvm/jvm.c
index a15f2b1..f54aad5 100644
--- a/src/jvm/jvm.c
+++ b/src/jvm/jvm.c
@@ -320,18 +320,13 @@ JNIEnv_DefineClass(JNIEnv* p0, const char* p1, jobject p2, const jbyte* p3, jsiz
return NULL;
}
-static char*
-cstr_replace(char *cstr, const char replace, const char with)
+static void
+cstr_replace(char *cstr, const char *replace, const char with)
{
- assert(cstr && replace != with);
-
- if (replace == with)
- return cstr;
-
+ assert(cstr && replace);
char *s = cstr;
- while ((s = strchr(s, replace)))
- *s = with;
- return cstr;
+ for (size_t i; *s && (i = strcspn(s, replace)) && s[i]; s += (i + 1))
+ s[i] = with;
}
static jclass
@@ -340,7 +335,7 @@ jvm_make_class(struct jvm *jvm, const char *name)
assert(jvm && name);
struct jvm_object o = { .this_klass = (jclass)1, .type = JVM_OBJECT_CLASS };
jvm_string_set_cstr(&o.klass.name, name, true);
- cstr_replace((char*)o.klass.name.data, '.', '/');
+ cstr_replace((char*)o.klass.name.data, "/", '.');
return jvm_add_object_if_not_there(jvm, &o);
}
@@ -558,8 +553,7 @@ jvm_form_symbol(struct jvm *jvm, const struct jvm_method *method, char *symbol,
assert(jvm && method);
verbose("%s::%s::%s", jvm_get_object_of_type(jvm, method->klass, JVM_OBJECT_CLASS)->klass.name.data, method->name.data, method->signature.data);
snprintf(symbol, symbol_sz, "%s_%s", jvm_get_object_of_type(jvm, method->klass, JVM_OBJECT_CLASS)->klass.name.data, method->name.data);
- cstr_replace(symbol, '/', '_');
- cstr_replace(symbol, '$', '_');
+ cstr_replace(symbol, "./$", '_');
}
static void*