00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 // rt_NThrowable.h 00003 00004 /* 00005 native method declarations for java.lang.Throwable 00006 */ 00007 00008 #ifndef RT_NTHROWABLE_H 00009 #define RT_NTHROWABLE_H 00010 00011 extern "C" { 00012 00013 /* public */ 00014 extern jobject Java_java_lang_Throwable_sin(JNIENV jobject); 00015 extern jobject Java_java_lang_Throwable_fillInStackTrace(JNIENV jobject); 00016 00017 /* private */ 00018 extern void Java_java_lang_Throwable_printStackTrace0(JNIENV jobject, 00019 jobject); 00020 00021 } 00022 00023 00024 struct NThrowable { 00025 00026 static void init2(); 00027 00028 // "return throwable.getMessage();" 00029 static JObject *getMessage(JObject *throwable); 00030 00031 // "return throwable.toString();" 00032 static JObject *toString(JObject *throwable); 00033 00034 00035 /* 00036 Create instances of java.lang.Throwable 00037 */ 00038 00039 // "return new <className>Exception(msg);" 00040 static JObject *buildExceptionFromName(char *className, char *msg); 00041 static JObject *buildException(JClass *clazz, char *msg); 00042 static JObject *_build_(exception_enum id, char *message); 00043 00044 // main entry point for building an IOException subtype 00045 static JObject *_buildIOException(int errNum, char *msg); 00046 00047 static JObject *buildIOException(char *msg); 00048 static JObject *buildEOFException(char *msg); 00049 static JObject *buildFileNotFoundException(char *msg); 00050 00051 00052 00053 /* 00054 Functions that will manage the throwing of an Exception 00055 (and therefore not return to the caller). 00056 */ 00057 00058 static void _throw_ (exception_enum id, char *message); 00059 00060 static void throwException (char *className, char *msg); 00061 static void throwException2 (char *className, char *format, char *arg); 00062 00063 static void throwIOException (int errNum, char *msg); 00064 static void throwIOException2(int errNum, char *format, char *arg); 00065 00066 private: 00067 static JClass *EOFExceptionJClass; 00068 static JClass *IOExceptionJClass; 00069 static JClass *FileNotFoundExceptionJClass; 00070 00071 }; 00072 00073 /* 00074 Java methods that RTS also provides an implementation for. 00075 */ 00076 extern "C" { 00077 00078 TD_DECL_PROC_1(Throwable_getMessage, JObject*, JObject*); 00079 TD_DECL_PROC_1(Throwable_toString, JObject*, JObject*); 00080 00081 TD_DECL_PROC_2(EOFException_init, void, JObject*, JObject*); 00082 TD_DECL_PROC_2(IOException_init, void, JObject*, JObject*); 00083 TD_DECL_PROC_2(FileNotFoundException_init, void, JObject*, JObject*); 00084 00085 } 00086 00087 00088 #endif /* RT_NTHROWABLE_H */