* 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.
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) */
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)
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);
/* 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 */
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)
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)
#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.
}
-/* 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;
/* 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 */
}
-/* 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;
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)
#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"
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
#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 ********************************
#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);
/* 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.
// 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) */
#endif
#include "vm/properties.hpp"
+#include "vm/suck.hpp"
#include "vm/jit/optimizing/recompiler.hpp"
#endif
NativeLibraries _nativelibraries; ///< Native library table.
NativeMethods _nativemethods; ///< Native methods table.
+ SuckClasspath _suckclasspath; ///< Classpath entries list.
public:
// Constructor, Destructor.
#endif
NativeLibraries& get_nativelibraries() { return _nativelibraries; }
NativeMethods& get_nativemethods () { return _nativemethods; }
+ SuckClasspath& get_suckclasspath () { return _suckclasspath; }
};
#else