- #include config.h, vm/class.h, vm/exceptions.h, vm/options.h,
authortwisti <none@none>
Thu, 10 Feb 2005 11:01:26 +0000 (11:01 +0000)
committertwisti <none@none>
Thu, 10 Feb 2005 11:01:26 +0000 (11:01 +0000)
  vm/stringlocal.h
- removed class_* variables
- added string_java_lang_InstantiationException
- renamed init_system_exceptions to exceptions_init

src/vm/exceptions.c
src/vm/exceptions.h

index d2d1eec633bc8982405b60dbddcee9bc6112928b..f251798b50bc65a87d817458e7aa6ba7893788d9 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: exceptions.c 1845 2005-01-04 11:28:16Z twisti $
+   $Id: exceptions.c 1935 2005-02-10 11:01:26Z twisti $
 
 */
 
 #include <stdarg.h>
 #include <stdlib.h>
 
+#include "config.h"
+
 #include "mm/memory.h"
 #include "native/native.h"
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_Throwable.h"
 #include "toolbox/logging.h"
+#include "vm/class.h"
+#include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/loader.h"
+#include "vm/options.h"
+#include "vm/stringlocal.h"
 #include "vm/tables.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.h"
-#include "vm/options.h"
 
 
-/* system exception classes required in cacao */
+/* for raising exceptions from native methods */
 
-classinfo *class_java_lang_Throwable;
-classinfo *class_java_lang_Exception;
-classinfo *class_java_lang_Error;
-classinfo *class_java_lang_OutOfMemoryError;
+#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
+java_objectheader* _exceptionptr = NULL;
+#endif
 
 
 /* exception/error super class */
@@ -103,6 +107,9 @@ const char *string_java_lang_IllegalMonitorStateException =
 const char *string_java_lang_IndexOutOfBoundsException =
     "java/lang/IndexOutOfBoundsException";
 
+const char *string_java_lang_InstantiationException =
+    "java/lang/InstantiationException";
+
 const char *string_java_lang_InterruptedException =
     "java/lang/InterruptedException";
 
@@ -167,59 +174,39 @@ const char *string_java_lang_VirtualMachineError =
     "java/lang/VirtualMachineError";
 
 
-/* init_system_exceptions *****************************************************
+/* init_system_exceptions ******************************************************
 
-   load, link and compile exceptions used in the system
+   Load and link exceptions used in the system.
 
 *******************************************************************************/
 
-bool init_system_exceptions(void)
+bool exceptions_init(void)
 {
        /* java/lang/Throwable */
 
-       class_java_lang_Throwable =
-               class_new(utf_new_char(string_java_lang_Throwable));
-
-       if (!class_load(class_java_lang_Throwable))
-               return false;
-
-       if (!class_link(class_java_lang_Throwable))
+       if (!class_load(class_java_lang_Throwable) ||
+               !class_link(class_java_lang_Throwable))
                return false;
 
 
        /* java/lang/Exception */
 
-       class_java_lang_Exception =
-               class_new(utf_new_char(string_java_lang_Exception));
-
-       if (!class_load(class_java_lang_Exception))
-               return false;
-
-       if (!class_link(class_java_lang_Exception))
+       if (!class_load(class_java_lang_Exception) ||
+               !class_link(class_java_lang_Exception))
                return false;
 
 
        /* java/lang/Error */
 
-       class_java_lang_Error =
-               class_new(utf_new_char(string_java_lang_Error));
-
-       if (!class_load(class_java_lang_Error))
-               return false;
-
-       if (!class_link(class_java_lang_Error))
+       if (!class_load(class_java_lang_Error) ||
+               !class_link(class_java_lang_Error))
                return false;
 
 
        /* java/lang/OutOfMemoryError */
 
-       class_java_lang_OutOfMemoryError =
-               class_new(utf_new_char(string_java_lang_OutOfMemoryError));
-
-       if (!class_load(class_java_lang_OutOfMemoryError))
-               return false;
-
-       if (!class_link(class_java_lang_OutOfMemoryError))
+       if (!class_load(class_java_lang_OutOfMemoryError) ||
+               !class_link(class_java_lang_OutOfMemoryError))
                return false;
 
        return true;
@@ -241,8 +228,8 @@ static void throw_exception_exit_intern(bool doexit)
                c = xptr->vftbl->class;
 
                pss = class_resolveclassmethod(c,
-                                                                          utf_new_char("printStackTrace"),
-                                                                          utf_new_char("()V"),
+                                                                          utf_printStackTrace,
+                                                                          utf_void__void,
                                                                           class_java_lang_Object,
                                                                           false);
 
@@ -265,9 +252,9 @@ static void throw_exception_exit_intern(bool doexit)
                fflush(stderr);
 
                /* good bye! */
-               if (doexit) {
+
+               if (doexit)
                        exit(1);
-               }
        }
 }
 
@@ -316,9 +303,8 @@ void throw_cacao_exception_exit(const char *exception, const char *message, ...)
 
        /* convert to classname */
 
-       for (i = len - 1; i >= 0; i--) {
+       for (i = len - 1; i >= 0; i--)
                if (tmp[i] == '/') tmp[i] = '.';
-       }
 
        fprintf(stderr, "Exception in thread \"main\" %s", tmp);
 
@@ -336,6 +322,7 @@ void throw_cacao_exception_exit(const char *exception, const char *message, ...)
        fflush(stderr);
 
        /* good bye! */
+
        exit(1);
 }
 
index 5bf5c8b093b8b2e1afee655ac01753999396ac47..28f218e892e0170879376c198a717bdd9415c7b3 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: exceptions.h 1846 2005-01-04 11:28:46Z twisti $
+   $Id: exceptions.h 1935 2005-02-10 11:01:26Z twisti $
 
 */
 
 #define _EXCEPTIONS_H
 
 
+#include "config.h"
+
 #include "vm/global.h"
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_Throwable.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+
+#define exceptionptr        builtin_get_exceptionptrptr()
+#define threadrootmethod    builtin_get_threadrootmethod()
+
+#else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
 
+#define exceptionptr        (&_exceptionptr)
+#define threadrootmethod    (&_threadrootmethod)
 
-/* system exception classes required in cacao */
+#endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
 
-extern classinfo *class_java_lang_Throwable;
-extern classinfo *class_java_lang_Exception;
-extern classinfo *class_java_lang_Error;
-extern classinfo *class_java_lang_OutOfMemoryError;
+#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
+extern java_objectheader *_exceptionptr;
+extern methodinfo* _threadrootmethod;
+#endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */
 
 
 /* exception/error super class */
@@ -67,6 +81,7 @@ extern const char *string_java_lang_IllegalAccessException;
 extern const char *string_java_lang_IllegalArgumentException;
 extern const char *string_java_lang_IllegalMonitorStateException;
 extern const char *string_java_lang_IndexOutOfBoundsException;
+extern const char *string_java_lang_InstantiationException;
 extern const char *string_java_lang_InterruptedException;
 extern const char *string_java_lang_NegativeArraySizeException;
 extern const char *string_java_lang_NoSuchFieldException;
@@ -93,11 +108,11 @@ extern const char *string_java_lang_VerifyError;
 extern const char *string_java_lang_VirtualMachineError;
 
 
-/* function prototypes */
+/* function prototypes ********************************************************/
 
-/* load, link and compile exceptions used in the system */
+/* load and link exceptions used in the system */
 
-bool init_system_exceptions(void);
+bool exceptions_init(void);
 
 
 /* exception throwing functions */