* Removed all Id tags.
[cacao.git] / src / cacaoh / cacaoh.c
index 29d686063db4f286e1caf4c482b4b6b1fa48a030..105030001449ae9d7cbccf1f207972ad3eebab29 100644 (file)
@@ -1,6 +1,6 @@
 /* src/cacaoh/cacaoh.c - main for header generation (cacaoh)
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-            Mark Probst
-            Philipp Tomsich
-            Christian Thalinger
-
-   $Id: cacaoh.c 6243 2006-12-27 13:56:31Z twisti $
-
 */
 
 
 #include "vm/types.h"
 
 #include "cacaoh/headers.h"
+
 #include "mm/gc-common.h"
 #include "mm/memory.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
 
+#include "toolbox/hashtable.h"
 #include "toolbox/logging.h"
-#include "vm/classcache.h"
+
 #include "vm/exceptions.h"
 #include "vm/global.h"
-#include "vm/hashtable.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/statistics.h"
 #include "vm/stringlocal.h"
-#include "vm/suck.h"
-
-
-/* define heap sizes **********************************************************/
+#include "vm/vm.h"
 
-#define HEAP_MAXSIZE      2 * 1024 * 1024   /* default 2MB                    */
-#define HEAP_STARTSIZE         100 * 1024   /* default 100kB                  */
+#include "vmcore/classcache.h"
+#include "vmcore/loader.h"
+#include "vmcore/options.h"
+#include "vmcore/statistics.h"
+#include "vmcore/suck.h"
 
 
 /* define cacaoh options ******************************************************/
@@ -100,7 +84,7 @@ opt_struct opts[] = {
 
 *******************************************************************************/
 
-static void usage(void)
+void usage(void)
 {
        printf("Usage: cacaoh [options] <classes>\n"
                   "\n"
@@ -127,7 +111,7 @@ static void usage(void)
 static void version(void)
 {
        printf("cacaoh version "VERSION"\n");
-       printf("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,\n");
+       printf("Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,\n");
        printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
        printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
        printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
@@ -171,8 +155,6 @@ int main(int argc, char **argv)
        char *classpath;
        char *cp;
        s4    cplen;
-       u4    heapmaxsize;
-       u4    heapstartsize;
 
        if (argc < 2)
                usage();
@@ -222,9 +204,6 @@ int main(int argc, char **argv)
        opt_verbose = false;
        opt_directory = NULL;
 
-       heapmaxsize = HEAP_MAXSIZE;
-       heapstartsize = HEAP_STARTSIZE;
-
 
        /* parse the options ******************************************************/
 
@@ -280,43 +259,26 @@ int main(int argc, char **argv)
 
        if (opt_verbose) {
                log_init(NULL);
-               log_text("Java - header-generator started"); 
+               log_println("Java - header-generator started"); 
        }
-       
-#if defined(ENABLE_THREADS)
-       /* pre-initialize some core thread stuff, like the stopworldlock,
-          thus this has to happen _before_ gc_init()!!! */
-
-       threads_preinit();
-#endif
-
-       /* initialize the garbage collector */
-
-       gc_init(heapmaxsize, heapstartsize);
-
-       /* initialize the string hashtable stuff: lock (must be done
-          _after_ threads_preinit) */
-
-       if (!string_init())
-               throw_main_exception_exit();
 
        /* initialize the utf8 hashtable stuff: lock, often used utf8 strings
           (must be done _after_ threads_preinit) */
 
        if (!utf8_init())
-               throw_main_exception_exit();
+               vm_abort("utf8_init failed\n");
 
        /* initialize the classcache hashtable stuff: lock, hashtable
           (must be done _after_ threads_preinit) */
 
        if (!classcache_init())
-               throw_main_exception_exit();
+               vm_abort("classcache_init failed\n");
 
        /* initialize the loader with bootclasspath (must be done _after_
           thread_preinit) */
 
        if (!suck_init())
-               throw_main_exception_exit();
+               vm_abort("suck_init failed\n");
 
        suck_add(bootclasspath);
 
@@ -329,7 +291,7 @@ int main(int argc, char **argv)
        classcache_init) */
 
        if (!loader_init())
-               throw_main_exception_exit();
+               vm_abort("loader_init failed\n");
 
 
        /* load Java classes ******************************************************/
@@ -353,12 +315,10 @@ int main(int argc, char **argv)
                /* exceptions are catched with new_exception call */
 
                if (!(c = load_class_bootstrap(utf_new_char(cp))))
-                       throw_cacao_exception_exit(string_java_lang_NoClassDefFoundError,
-                                                                          cp);
+                       vm_abort("java.lang.NoClassDefFoundError: %s\n", cp);
 
                if (!link_class(c))
-                       throw_cacao_exception_exit(string_java_lang_LinkageError,
-                                                                          cp);
+                       vm_abort("java.lang.LinkageError: %s\n", cp);
 
                headerfile_generate(c, opt_directory);
        }
@@ -368,9 +328,9 @@ int main(int argc, char **argv)
        loader_close();
 
        if (opt_verbose) {
-               log_text("Java - header-generator stopped");
+               log_println("Java - header-generator stopped");
 #if defined(ENABLE_STATISTICS)
-               mem_usagelog(true);
+               statistics_print_memory_usage();
 #endif
        }