* src/vm/suck.hpp (SuckClasspath): Added as list of classpath entries.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 5 Mar 2009 13:44:30 +0000 (14:44 +0100)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 5 Mar 2009 13:44:30 +0000 (14:44 +0100)
* src/vm/suck.cpp: Moved existing methods into above class.
* src/vm/vm.hpp (VM): Added SuckClasspath as global classpath entries list.
* src/vm/vm.cpp (VM::VM): Adapted to above changes.
* src/vm/loader.cpp (loader_load_all_classes): Likewise.
* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp: Likewise.
* src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp: Likewise.

src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp
src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp
src/vm/loader.cpp
src/vm/suck.cpp
src/vm/suck.hpp
src/vm/vm.cpp
src/vm/vm.hpp

index ba78eaaddf441a7309fec2eee7b96f5fa3495ed6..ac12cc83523f303ebfcba585c6ff676be6d4c272 100644 (file)
@@ -193,7 +193,10 @@ JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *
        char *path;
        utf *uname;
        java_handle_t* descriptor;
-       
+
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
        /* get the classname as char string (do it here for the warning at
        the end of the function) */
 
@@ -201,10 +204,10 @@ JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *
        filenamelen = utf_bytes(uname) + strlen("0");
        filename = MNEW(char, filenamelen);
        utf_copy(filename, uname);
-       
+
        /* walk through all classpath entries */
 
-       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
                list_classpath_entry* lce = *it;
 
 #if defined(ENABLE_ZLIB)
index ebeeb162885c7f07b55162ea875171cfeebc57a2..2c3bc512514d50ee42849f6f56e18fad7021da0f 100644 (file)
@@ -259,6 +259,9 @@ JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv
        struct stat           buf;       /* buffer for stat          */
        jboolean              ret;       /* return value of "add"    */
 
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
        /* get the resource name as utf string */
 
        utfname = javastring_toutf((java_handle_t *) name, false);
@@ -318,7 +321,7 @@ JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv
 
        /* iterate over all classpath entries */
 
-       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
                list_classpath_entry* lce = *it;
 
                /* clear path pointer */
index 7bc8ff4a177568738f2648857c824ef74c470099..083f00b30a7f8d2e6fa034fa7dc286af018de523 100644 (file)
@@ -100,9 +100,12 @@ void loader_preinit(void)
        TRACESUBSYSTEMINITIALIZATION("loader_preinit");
 
 #if defined(ENABLE_THREADS)
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
        /* Initialize the monitor pointer for zip/jar file locking. */
 
-       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
                list_classpath_entry* lce = *it;
 
                if (lce->type == CLASSPATH_ARCHIVE)
@@ -398,7 +401,10 @@ void loader_load_all_classes(void)
        utf                     *u;
 #endif
 
-       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
                list_classpath_entry* lce = *it;
 
 #if defined(ENABLE_ZLIB)
index 1c801c5636fb2756ec89acb067fdc5ed7e0d8247..ecf0a70c3ee5ed2927469e430692661fe3d54b0e 100644 (file)
 #include "vm/zip.hpp"
 
 
-/* global variables ***********************************************************/
-
-List<list_classpath_entry*>* list_classpath_entries;
-
-
-/* suck_init *******************************************************************
-
-   Initializes the suck subsystem like initializing the classpath
-   entries list.
-
-*******************************************************************************/
-
-bool suck_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("suck_init");
-
-#warning Move this list into VM.
-       list_classpath_entries = new List<list_classpath_entry*>();
-
-       /* everything's ok */
-
-       return true;
-}
-
-
 /* scandir_filter **************************************************************
 
    Filters for zip/jar files.
@@ -99,13 +74,10 @@ static int scandir_filter(const struct dirent *a)
 }
 
 
-/* suck_add ********************************************************************
-
-   Adds a classpath to the global classpath entries list.
-
-*******************************************************************************/
-
-void suck_add(char *classpath)
+/**
+ * Adds a classpath to the global classpath entries list.
+ */
+void SuckClasspath::add(char *classpath)
 {
        list_classpath_entry *lce;
        char                 *start;
@@ -206,7 +178,7 @@ void suck_add(char *classpath)
                        /* add current classpath entry, if no error */
 
                        if (lce != NULL)
-                               list_classpath_entries->push_back(lce);
+                               push_back(lce);
                }
 
                /* goto next classpath entry, skip ':' delimiter */
@@ -219,14 +191,11 @@ void suck_add(char *classpath)
 }
 
 
-/* suck_add_from_property ******************************************************
-
-   Adds a classpath form a property entry to the global classpath
-   entries list.
-
-*******************************************************************************/
-
-void suck_add_from_property(const char *key)
+/**
+ * Adds a classpath form a property entry to the global classpath
+ * entries list.
+ */
+void SuckClasspath::add_from_property(const char *key)
 {
        const char     *value;
        const char     *start;
@@ -516,9 +485,12 @@ classbuffer *suck_start(classinfo *c)
        utf_copy(filename, c->name);
        strcat(filename, ".class");
 
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
        /* walk through all classpath entries */
 
-       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end() && cb == NULL; it++) {
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end() && cb == NULL; it++) {
                lce = *it;
 
 #if defined(ENABLE_ZLIB)
index 20e2580518a807ef4d7e069805237284dc192943..ff7077387636fb569662d9639708ad8210335707 100644 (file)
 
 #include "config.h"
 
+#ifdef __cplusplus
+#include <list>
+#endif
+
 #include "vm/types.h"
 
 #include "threads/mutex.hpp"
 
 #include "toolbox/hashtable.h"
-#include "toolbox/list.hpp"
 
 #include "vm/class.hpp"
 #include "vm/global.h"
@@ -47,9 +50,7 @@ enum {
        CLASSPATH_ARCHIVE
 };
 
-typedef struct list_classpath_entry list_classpath_entry;
-
-struct list_classpath_entry {
+typedef struct list_classpath_entry {
 #if defined(ENABLE_THREADS)
        Mutex             *mutex;               /* mutex locking on zip/jar files */
 #endif
@@ -59,8 +60,28 @@ struct list_classpath_entry {
 #if defined(ENABLE_ZLIB)
        hashtable         *htclasses;
 #endif
+} list_classpath_entry;
+
+
+#ifdef __cplusplus
+
+/**
+ * Classpath entries list.
+ */
+class SuckClasspath : protected std::list<list_classpath_entry*> {
+public:
+       void add(char *classpath);
+       void add_from_property(const char *key);
+
+       // make iterator of std::list visible
+       using std::list<list_classpath_entry*>::iterator;
+
+       // make functions of std::list visible
+       using std::list<list_classpath_entry*>::begin;
+       using std::list<list_classpath_entry*>::end;
 };
 
+#endif
 
 /* macros to read LE and BE types from a buffer ********************************
 
@@ -148,25 +169,12 @@ struct list_classpath_entry {
 #define suck_s8(a)    (s8) suck_u8((a))
 
 
-/* export variables ***********************************************************/
-
-#ifdef __cplusplus
-extern List<list_classpath_entry*>* list_classpath_entries;
-#else
-extern List* list_classpath_entries;
-#endif
-
 /* function prototypes ********************************************************/
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-bool suck_init(void);
-
-void suck_add(char *classpath);
-void suck_add_from_property(const char *key);
-
 bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
 
 u1 suck_u1(classbuffer *cb);
index 349ab9a3b0955ef446a428c4bb6eab90aaae9934..cc60d2b68cec5f51ef74505252cb9ff77a6f1359 100644 (file)
@@ -1370,10 +1370,7 @@ VM::VM(JavaVMInitArgs* vm_args)
 
        /* AFTER: thread_preinit */
 
-       if (!suck_init())
-               os::abort("vm_create: suck_init failed");
-
-       suck_add_from_property("java.endorsed.dirs");
+       _suckclasspath.add_from_property("java.endorsed.dirs");
 
        /* Now we have all options handled and we can print the version
           information.
@@ -1387,7 +1384,7 @@ VM::VM(JavaVMInitArgs* vm_args)
 
        // FIXME Make boot_class_path const char*.
        boot_class_path = (char*) _properties.get("sun.boot.class.path");
-       suck_add(boot_class_path);
+       _suckclasspath.add(boot_class_path);
 
        /* initialize the classcache hashtable stuff: lock, hashtable
           (must be done _after_ threads_preinit) */
index 4a73ecc351cc86456f08dba13ef3d366d3267745..22a355083dbb3889cc3edcab4b828c647ef9b5af 100644 (file)
@@ -41,6 +41,7 @@
 #endif
 
 #include "vm/properties.hpp"
+#include "vm/suck.hpp"
 
 #include "vm/jit/optimizing/recompiler.hpp"
 
@@ -76,6 +77,7 @@ private:
 #endif
        NativeLibraries _nativelibraries; ///< Native library table.
        NativeMethods   _nativemethods;   ///< Native methods table.
+       SuckClasspath   _suckclasspath;   ///< Classpath entries list.
 
 public:
        // Constructor, Destructor.
@@ -105,6 +107,7 @@ public:
 #endif
        NativeLibraries& get_nativelibraries() { return _nativelibraries; }
        NativeMethods&   get_nativemethods  () { return _nativemethods; }
+       SuckClasspath&   get_suckclasspath  () { return _suckclasspath; }
 };
 
 #else