Function returns string containing classpath directories separated by ':'. It will be used to set the 'java.class.path' property.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/vm/classloader.h | 1 + vm/classloader.c | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/include/vm/classloader.h b/include/vm/classloader.h index b4289a3..6cd728f 100644 --- a/include/vm/classloader.h +++ b/include/vm/classloader.h @@ -9,6 +9,7 @@ struct vm_class; int classloader_add_to_classpath(const char *classpath); int try_to_add_zip_to_classpath(const char *zip); +char *get_classpath(void); struct vm_class *classloader_load(const char *class_name); struct vm_class *classloader_load_primitive(const char *class_name); diff --git a/vm/classloader.c b/vm/classloader.c index 577837b..1c3e7f3 100644 --- a/vm/classloader.c +++ b/vm/classloader.c @@ -15,6 +15,8 @@ #include "vm/backtrace.h" #include "vm/trace.h" +#include "lib/string.h" + bool opt_trace_classloader; static __thread int trace_classloader_level = 0; @@ -51,15 +53,38 @@ struct classpath { enum classpath_type type; - union { - const char *dir; - struct zip *zip; - }; + const char *path; + struct zip *zip; }; /* These are the directories we search for classes */ struct list_head classpaths = LIST_HEAD_INIT(classpaths); +char *get_classpath(void) +{ + struct classpath *cp; + struct string *str; + char *value; + bool first; + + str = alloc_str(); + first = true; + + list_for_each_entry(cp, &classpaths, node) { + if (!first) { + str_append(str, ":"); + first = false; + } + + str_append(str, "%s", cp->path); + } + + value = strdup(str->value); + free_str(str); + + return value; +} + static int add_dir_to_classpath(const char *dir) { struct classpath *cp = malloc(sizeof *cp); @@ -67,8 +92,8 @@ static int add_dir_to_classpath(const char *dir) return -ENOMEM; cp->type = CLASSPATH_DIR; - cp->dir= strdup(dir); - if (!cp->dir) { + cp->path = strdup(dir); + if (!cp->path) { NOT_IMPLEMENTED; return -ENOMEM; } @@ -86,6 +111,12 @@ static int add_zip_to_classpath(const char *zip) return -ENOMEM; cp->type = CLASSPATH_ZIP; + cp->path = strdup(zip); + if (!cp->path) { + NOT_IMPLEMENTED; + return -ENOMEM; + } + cp->zip = zip_open(zip, 0, &zip_error); if (!cp->zip) { NOT_IMPLEMENTED; @@ -336,7 +367,7 @@ static struct vm_class *load_class_from_classpath_file(const struct classpath *c { switch (cp->type) { case CLASSPATH_DIR: - return load_class_from_dir(cp->dir, file); + return load_class_from_dir(cp->path, file); case CLASSPATH_ZIP: return load_class_from_zip(cp->zip, file); } -- 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