Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 Makefile                      |    1 +
 include/runtime/classloader.h |   10 ++++
 runtime/classloader.c         |   97 +++++++++++++++++++++++++++++++++++++++++
 vm/jato.c                     |   66 +---------------------------
 4 files changed, 109 insertions(+), 65 deletions(-)
 create mode 100644 include/runtime/classloader.h
 create mode 100644 runtime/classloader.c

diff --git a/Makefile b/Makefile
index 24deef4..9aad5f9 100644
--- a/Makefile
+++ b/Makefile
@@ -99,6 +99,7 @@ JIT_OBJS = \
 
 VM_OBJS = \
        runtime/class.o         \
+       runtime/classloader.o   \
        runtime/reflection.o    \
        runtime/runtime.o       \
        runtime/stack-walker.o  \
diff --git a/include/runtime/classloader.h b/include/runtime/classloader.h
new file mode 100644
index 0000000..2f034ae
--- /dev/null
+++ b/include/runtime/classloader.h
@@ -0,0 +1,10 @@
+#ifndef RUNTIME_CLASSLOADER_H
+#define RUNTIME_CLASSLOADER_H
+
+#include "vm/jni.h"
+
+jobject native_vmclassloader_getprimitiveclass(jint type);
+jobject native_vmclassloader_findloadedclass(jobject classloader, jobject 
name);
+jobject native_vmclassloader_loadclass(jobject name, jboolean resolve);
+
+#endif /* RUNTIME_CLASSLOADER_H */
diff --git a/runtime/classloader.c b/runtime/classloader.c
new file mode 100644
index 0000000..5ca54cf
--- /dev/null
+++ b/runtime/classloader.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2009 Tomasz Grabiec
+ *
+ * This file is released under the GPL version 2 with the following
+ * clarification and special exception:
+ *
+ *     Linking this library statically or dynamically with other modules is
+ *     making a combined work based on this library. Thus, the terms and
+ *     conditions of the GNU General Public License cover the whole
+ *     combination.
+ *
+ *     As a special exception, the copyright holders of this library give you
+ *     permission to link this library with independent modules to produce an
+ *     executable, regardless of the license terms of these independent
+ *     modules, and to copy and distribute the resulting executable under terms
+ *     of your choice, provided that you also meet, for each linked independent
+ *     module, the terms and conditions of the license of that module. An
+ *     independent module is a module which is not derived from or based on
+ *     this library. If you modify this library, you may extend this exception
+ *     to your version of the library, but you are not obligated to do so. If
+ *     you do not wish to do so, delete this exception statement from your
+ *     version.
+ *
+ * Please refer to the file LICENSE for details.
+ */
+
+#include "jit/exception.h"
+
+#include "runtime/classloader.h"
+
+#include "vm/class.h"
+#include "vm/object.h"
+#include "vm/classloader.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+jobject native_vmclassloader_getprimitiveclass(jint type)
+{
+       char primitive_class_name[] = { "X" };
+       struct vm_class *class;
+
+       primitive_class_name[0] = (char)type;
+
+       class = classloader_load_primitive(primitive_class_name);
+       if (!class)
+               return NULL;
+
+       vm_class_ensure_init(class);
+       if (exception_occurred())
+               return NULL;
+
+       return class->object;
+}
+
+jobject native_vmclassloader_findloadedclass(jobject classloader, jobject name)
+{
+       struct vm_class *vmc;
+       char *c_name;
+
+       c_name = vm_string_to_cstr(name);
+       if (!c_name)
+               return NULL;
+
+       vmc = classloader_find_class(c_name);
+       free(c_name);
+
+       if (!vmc)
+               return NULL;
+
+       if (vmc->classloader != classloader)
+               return NULL;
+
+       vm_class_ensure_init(vmc);
+       return vmc->object;
+}
+
+/* TODO: respect the @resolve parameter. */
+jobject native_vmclassloader_loadclass(jobject name, jboolean resolve)
+{
+       struct vm_class *vmc;
+       char *c_name;
+
+       c_name = vm_string_to_cstr(name);
+       if (!c_name)
+               return NULL;
+
+       vmc = classloader_load(NULL, c_name);
+       free(c_name);
+       if (!vmc)
+               return NULL;
+
+       if (vm_class_ensure_object(vmc))
+               return NULL;
+
+       return vmc->object;
+}
diff --git a/vm/jato.c b/vm/jato.c
index 73dca95..8980d73 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -53,6 +53,7 @@
 #include "runtime/runtime.h"
 #include "runtime/unsafe.h"
 #include "runtime/class.h"
+#include "runtime/classloader.h"
 
 #include "jit/compiler.h"
 #include "jit/cu-mapping.h"
@@ -400,25 +401,6 @@ native_vmobject_getclass(struct vm_object *object)
        return object->class->object;
 }
 
-static struct vm_object *
-native_vmclassloader_getprimitiveclass(int type)
-{
-       char primitive_class_name[] = { "X" };
-       struct vm_class *class;
-
-       primitive_class_name[0] = (char)type;
-
-       class = classloader_load_primitive(primitive_class_name);
-       if (!class)
-               return NULL;
-
-       vm_class_ensure_init(class);
-       if (exception_occurred())
-               return NULL;
-
-       return class->object;
-}
-
 static int
 native_vmfile_is_directory(struct vm_object *dirpath)
 {
@@ -518,52 +500,6 @@ static void native_vmobject_wait(struct vm_object *object, 
jlong ms, jint ns)
                vm_monitor_timed_wait(&object->monitor, ms, ns);
 }
 
-static struct vm_object *
-native_vmclassloader_findloadedclass(struct vm_object *classloader,
-                                    struct vm_object *name)
-{
-       struct vm_class *vmc;
-       char *c_name;
-
-       c_name = vm_string_to_cstr(name);
-       if (!c_name)
-               return NULL;
-
-       vmc = classloader_find_class(c_name);
-       free(c_name);
-
-       if (!vmc)
-               return NULL;
-
-       if (vmc->classloader != classloader)
-               return NULL;
-
-       vm_class_ensure_init(vmc);
-       return vmc->object;
-}
-
-static struct vm_object *
-native_vmclassloader_loadclass(struct vm_object *name, jboolean resolve)
-{
-       /* XXX: what does @resolve parameter mean? */
-       struct vm_class *vmc;
-       char *c_name;
-
-       c_name = vm_string_to_cstr(name);
-       if (!c_name)
-               return NULL;
-
-       vmc = classloader_load(NULL, c_name);
-       free(c_name);
-       if (!vmc)
-               return NULL;
-
-       if (vm_class_ensure_object(vmc))
-               return NULL;
-
-       return vmc->object;
-}
-
 static struct vm_object *native_vmstring_intern(struct vm_object *str)
 {
        return vm_string_intern(str);
-- 
1.6.0.4


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to