Signed-off-by: Tomek Grabiec <[email protected]>
---
vm/jato.c | 31 ++++++++++++++++++-------------
vm/jni.c | 16 +---------------
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/vm/jato.c b/vm/jato.c
index a9eb0a7..c6dfd4d 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -93,6 +93,21 @@ static struct vm_object *__vm_native
native_vmstackwalker_getclasscontext(void)
return res;
}
+static void vm_properties_set_property(struct vm_object *p,
+ const char *key, const char *value)
+{
+ struct vm_object *(*trampoline)(struct vm_object *,
+ struct vm_object *, struct vm_object *);
+
+ trampoline
+ = vm_method_trampoline_ptr(vm_java_util_Properties_setProperty);
+
+ struct vm_object *key_obj = vm_object_alloc_string_from_c(key);
+ struct vm_object *value_obj = vm_object_alloc_string_from_c(value);
+
+ trampoline(p, key_obj, value_obj);
+}
+
static void __vm_native native_vmsystemproperties_preinit(struct vm_object *p)
{
struct system_properties_entry {
@@ -101,8 +116,6 @@ static void __vm_native
native_vmsystemproperties_preinit(struct vm_object *p)
};
static const struct system_properties_entry system_properties[] = {
- /* XXX: Don't hardcode this, but detect it at run-time */
- { "java.library.path", "/usr/lib/classpath" },
{ "java.vm.name", "jato" },
{ "java.io.tmpdir", "/tmp" },
{ "file.separator", "/" },
@@ -110,21 +123,13 @@ static void __vm_native
native_vmsystemproperties_preinit(struct vm_object *p)
{ "line.separator", "\n" },
};
- struct vm_object *(*trampoline)(struct vm_object *,
- struct vm_object *, struct vm_object *);
-
- trampoline
- = vm_method_trampoline_ptr(vm_java_util_Properties_setProperty);
+ vm_properties_set_property(p, "java.library.path",
+ getenv("LD_LIBRARY_PATH"));
for (unsigned int i = 0; i < ARRAY_SIZE(system_properties); ++i) {
const struct system_properties_entry *e = &system_properties[i];
- struct vm_object *key, *value;
-
- key = vm_object_alloc_string_from_c(e->key);
- value = vm_object_alloc_string_from_c(e->value);
- /* XXX: Check exceptions? */
- trampoline(p, key, value);
+ vm_properties_set_property(p, e->key, e->value);
}
}
diff --git a/vm/jni.c b/vm/jni.c
index a677a24..8c80afe 100644
--- a/vm/jni.c
+++ b/vm/jni.c
@@ -111,23 +111,9 @@ static int vm_jni_add_object_handle(void *handle)
int vm_jni_load_object(const char *name)
{
- char *classpath_install_dir;
void *handle;
- classpath_install_dir = getenv("CLASSPATH_INSTALL_DIR");
- if (!classpath_install_dir) {
- warn("environment variable CLASSPATH_INSTALL_DIR not set");
- return -1;
- }
-
- char *so_name = NULL;
-
- if (asprintf(&so_name, "%s/lib/classpath/%s", classpath_install_dir,
name) < 0)
- die("asprintf");
-
- handle = dlopen(so_name, RTLD_NOW);
- free(so_name);
-
+ handle = dlopen(name, RTLD_NOW);
if (!handle) {
fprintf(stderr, "%s: %s\n", __func__, dlerror());
return -1;
--
1.6.0.6
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel