summaryrefslogtreecommitdiffstats
path: root/vm/Exception.h
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2011-02-24 10:32:47 -0800
committerDan Bornstein <danfuzz@android.com>2011-02-24 10:32:47 -0800
commit74501e600dcb5634aa26aee0a3f57f2b45b213f2 (patch)
tree7cac88fd09a8a5f8d7e42ce130e9e975be154152 /vm/Exception.h
parentabe1ed34b2c658935a72a5aec507c92d93d66402 (diff)
downloadandroid_dalvik-74501e600dcb5634aa26aee0a3f57f2b45b213f2.tar.gz
android_dalvik-74501e600dcb5634aa26aee0a3f57f2b45b213f2.tar.bz2
android_dalvik-74501e600dcb5634aa26aee0a3f57f2b45b213f2.zip
Round three of exception cleanup.
I expanded AIOOBE since it was the odd one out, migrated the wrappers in Exception.h to the end of the file where they're less disruptive, and tweaked a couple other throws in the main vm code. Change-Id: Iae11fda2c47989ce7579483df226124ffeb2ac84
Diffstat (limited to 'vm/Exception.h')
-rw-r--r--vm/Exception.h342
1 files changed, 174 insertions, 168 deletions
diff --git a/vm/Exception.h b/vm/Exception.h
index e2ee77fe5..ff86cd5b5 100644
--- a/vm/Exception.h
+++ b/vm/Exception.h
@@ -36,10 +36,169 @@ INLINE void dvmThrowException(const char* exceptionDescriptor,
}
/*
- * Throw an ArrayIndexOutOfBoundsException in the current thread, using the given
- * index and array length in the detail message.
+ * Like dvmThrowChainedException, but takes printf-style args for the message.
+ */
+void dvmThrowExceptionFmtV(const char* exceptionDescriptor, const char* fmt,
+ va_list args);
+void dvmThrowExceptionFmt(const char* exceptionDescriptor, const char* fmt, ...)
+#if defined(__GNUC__)
+ __attribute__ ((format(printf, 2, 3)))
+#endif
+ ;
+INLINE void dvmThrowExceptionFmt(const char* exceptionDescriptor,
+ const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ dvmThrowExceptionFmtV(exceptionDescriptor, fmt, args);
+ va_end(args);
+}
+
+/*
+ * Throw an exception in the current thread, by class object.
+ */
+void dvmThrowChainedExceptionByClass(ClassObject* exceptionClass,
+ const char* msg, Object* cause);
+INLINE void dvmThrowExceptionByClass(ClassObject* exceptionClass,
+ const char* msg)
+{
+ dvmThrowChainedExceptionByClass(exceptionClass, msg, NULL);
+}
+
+/*
+ * Throw the named exception using the human-readable form of the class
+ * descriptor as the exception message, and with the specified cause.
+ */
+void dvmThrowChainedExceptionWithClassMessage(const char* exceptionDescriptor,
+ const char* messageDescriptor, Object* cause);
+INLINE void dvmThrowExceptionWithClassMessage(const char* exceptionDescriptor,
+ const char* messageDescriptor)
+{
+ dvmThrowChainedExceptionWithClassMessage(exceptionDescriptor,
+ messageDescriptor, NULL);
+}
+
+/*
+ * Like dvmThrowException, but take a class object instead of a name
+ * and turn the given message into the human-readable form for a descriptor.
+ */
+void dvmThrowExceptionByClassWithClassMessage(ClassObject* exceptionClass,
+ const char* messageDescriptor);
+
+/*
+ * Return the exception being thrown in the current thread, or NULL if
+ * no exception is pending.
+ */
+INLINE Object* dvmGetException(Thread* self) {
+ return self->exception;
+}
+
+/*
+ * Set the exception being thrown in the current thread.
+ */
+INLINE void dvmSetException(Thread* self, Object* exception)
+{
+ assert(exception != NULL);
+ self->exception = exception;
+}
+
+/*
+ * Clear the pending exception.
+ *
+ * (We use this rather than "set(null)" because we may need to have special
+ * fixups here for StackOverflowError stuff. Calling "clear" in the code
+ * makes it obvious.)
*/
-void dvmThrowAIOOBE(int index, int length);
+INLINE void dvmClearException(Thread* self) {
+ self->exception = NULL;
+}
+
+/*
+ * Clear the pending exception. Used by the optimization and verification
+ * code, which has to run with "initializing" set to avoid going into a
+ * death-spin if the "class not found" exception can't be found.
+ */
+void dvmClearOptException(Thread* self);
+
+/*
+ * Returns "true" if an exception is pending. Use this if you have a
+ * "self" pointer.
+ */
+INLINE bool dvmCheckException(Thread* self) {
+ return (self->exception != NULL);
+}
+
+/*
+ * Returns "true" if this is a "checked" exception, i.e. it's a subclass
+ * of Throwable (assumed) but not a subclass of RuntimeException or Error.
+ */
+bool dvmIsCheckedException(const Object* exception);
+
+/*
+ * Wrap the now-pending exception in a different exception.
+ *
+ * If something fails, an (unchecked) exception related to that failure
+ * will be pending instead.
+ */
+void dvmWrapException(const char* newExcepStr);
+
+/*
+ * Get the "cause" field from an exception.
+ *
+ * Returns NULL if the field is null or uninitialized.
+ */
+Object* dvmGetExceptionCause(const Object* exception);
+
+/*
+ * Print the exception stack trace on stderr. Calls the exception's
+ * print function.
+ */
+void dvmPrintExceptionStackTrace(void);
+
+/*
+ * Print the exception stack trace to the log file. The exception stack
+ * trace is computed within the VM.
+ */
+void dvmLogExceptionStackTrace(void);
+
+/*
+ * Search for a catch block that matches "exception".
+ *
+ * "*newFrame" gets a copy of the new frame pointer.
+ *
+ * If "doUnroll" is set, we unroll "thread"s stack as we go (and update
+ * self->curFrame with the same value as in *newFrame).
+ *
+ * Returns the offset to the catch code on success, or -1 if we couldn't
+ * find a catcher.
+ */
+int dvmFindCatchBlock(Thread* self, int relPc, Object* exception,
+ bool doUnroll, void** newFrame);
+
+/*
+ * Support for saving exception stack traces and converting them to
+ * usable form. Use the "FillIn" function to generate a compact array
+ * that represents the stack frames, then "GetStackTrace" to convert it
+ * to an array of StackTraceElement objects.
+ *
+ * Don't call the "Internal" form of the function directly.
+ */
+void* dvmFillInStackTraceInternal(Thread* thread, bool wantObject, int* pCount);
+/* return an [I for use by interpreted code */
+INLINE Object* dvmFillInStackTrace(Thread* thread) {
+ return (Object*) dvmFillInStackTraceInternal(thread, true, NULL);
+}
+ArrayObject* dvmGetStackTrace(const Object* stackState);
+/* return an int* and array count; caller must free() the return value */
+INLINE int* dvmFillInStackTraceRaw(Thread* thread, int* pCount) {
+ return (int*) dvmFillInStackTraceInternal(thread, false, pCount);
+}
+ArrayObject* dvmGetStackTraceRaw(const int* intVals, int stackDepth);
+
+/*
+ * Print a formatted version of a raw stack trace to the log file.
+ */
+void dvmLogRawStackTrace(const int* intVals, int stackDepth);
/**
* Throw an AbstractMethodError in the current thread, with the given detail
@@ -54,6 +213,12 @@ void dvmThrowAbstractMethodError(const char* msg);
void dvmThrowArithmeticException(const char* msg);
/*
+ * Throw an ArrayIndexOutOfBoundsException in the current thread,
+ * using the given index and array length in the detail message.
+ */
+void dvmThrowArrayIndexOutOfBoundsException(int index, int length);
+
+/*
* Throw an ArrayStoreException in the current thread, using the given classes'
* names in the detail message.
*/
@@ -211,6 +376,12 @@ void dvmThrowOutOfMemoryError(const char* msg);
void dvmThrowRuntimeException(const char* msg);
/**
+ * Throw a StaleDexCacheError in the current thread, with
+ * the given detail message.
+ */
+void dvmThrowStaleDexCacheError(const char* msg);
+
+/**
* Throw a StringIndexOutOfBoundsException in the current thread, with
* the given detail message.
*/
@@ -234,169 +405,4 @@ void dvmThrowUnsupportedOperationException(const char* msg);
*/
void dvmThrowVirtualMachineError(const char* msg);
-/*
- * Like dvmThrowChainedException, but takes printf-style args for the message.
- */
-void dvmThrowExceptionFmtV(const char* exceptionDescriptor, const char* fmt,
- va_list args);
-void dvmThrowExceptionFmt(const char* exceptionDescriptor, const char* fmt, ...)
-#if defined(__GNUC__)
- __attribute__ ((format(printf, 2, 3)))
-#endif
- ;
-INLINE void dvmThrowExceptionFmt(const char* exceptionDescriptor,
- const char* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- dvmThrowExceptionFmtV(exceptionDescriptor, fmt, args);
- va_end(args);
-}
-
-/*
- * Throw an exception in the current thread, by class object.
- */
-void dvmThrowChainedExceptionByClass(ClassObject* exceptionClass,
- const char* msg, Object* cause);
-INLINE void dvmThrowExceptionByClass(ClassObject* exceptionClass,
- const char* msg)
-{
- dvmThrowChainedExceptionByClass(exceptionClass, msg, NULL);
-}
-
-/*
- * Throw the named exception using the human-readable form of the class
- * descriptor as the exception message, and with the specified cause.
- */
-void dvmThrowChainedExceptionWithClassMessage(const char* exceptionDescriptor,
- const char* messageDescriptor, Object* cause);
-INLINE void dvmThrowExceptionWithClassMessage(const char* exceptionDescriptor,
- const char* messageDescriptor)
-{
- dvmThrowChainedExceptionWithClassMessage(exceptionDescriptor,
- messageDescriptor, NULL);
-}
-
-/*
- * Like dvmThrowException, but take a class object instead of a name
- * and turn the given message into the human-readable form for a descriptor.
- */
-void dvmThrowExceptionByClassWithClassMessage(ClassObject* exceptionClass,
- const char* messageDescriptor);
-
-/*
- * Return the exception being thrown in the current thread, or NULL if
- * no exception is pending.
- */
-INLINE Object* dvmGetException(Thread* self) {
- return self->exception;
-}
-
-/*
- * Set the exception being thrown in the current thread.
- */
-INLINE void dvmSetException(Thread* self, Object* exception)
-{
- assert(exception != NULL);
- self->exception = exception;
-}
-
-/*
- * Clear the pending exception.
- *
- * (We use this rather than "set(null)" because we may need to have special
- * fixups here for StackOverflowError stuff. Calling "clear" in the code
- * makes it obvious.)
- */
-INLINE void dvmClearException(Thread* self) {
- self->exception = NULL;
-}
-
-/*
- * Clear the pending exception. Used by the optimization and verification
- * code, which has to run with "initializing" set to avoid going into a
- * death-spin if the "class not found" exception can't be found.
- */
-void dvmClearOptException(Thread* self);
-
-/*
- * Returns "true" if an exception is pending. Use this if you have a
- * "self" pointer.
- */
-INLINE bool dvmCheckException(Thread* self) {
- return (self->exception != NULL);
-}
-
-/*
- * Returns "true" if this is a "checked" exception, i.e. it's a subclass
- * of Throwable (assumed) but not a subclass of RuntimeException or Error.
- */
-bool dvmIsCheckedException(const Object* exception);
-
-/*
- * Wrap the now-pending exception in a different exception.
- *
- * If something fails, an (unchecked) exception related to that failure
- * will be pending instead.
- */
-void dvmWrapException(const char* newExcepStr);
-
-/*
- * Get the "cause" field from an exception.
- *
- * Returns NULL if the field is null or uninitialized.
- */
-Object* dvmGetExceptionCause(const Object* exception);
-
-/*
- * Print the exception stack trace on stderr. Calls the exception's
- * print function.
- */
-void dvmPrintExceptionStackTrace(void);
-
-/*
- * Print the exception stack trace to the log file. The exception stack
- * trace is computed within the VM.
- */
-void dvmLogExceptionStackTrace(void);
-
-/*
- * Search for a catch block that matches "exception".
- *
- * "*newFrame" gets a copy of the new frame pointer.
- *
- * If "doUnroll" is set, we unroll "thread"s stack as we go (and update
- * self->curFrame with the same value as in *newFrame).
- *
- * Returns the offset to the catch code on success, or -1 if we couldn't
- * find a catcher.
- */
-int dvmFindCatchBlock(Thread* self, int relPc, Object* exception,
- bool doUnroll, void** newFrame);
-
-/*
- * Support for saving exception stack traces and converting them to
- * usable form. Use the "FillIn" function to generate a compact array
- * that represents the stack frames, then "GetStackTrace" to convert it
- * to an array of StackTraceElement objects.
- *
- * Don't call the "Internal" form of the function directly.
- */
-void* dvmFillInStackTraceInternal(Thread* thread, bool wantObject, int* pCount);
-/* return an [I for use by interpreted code */
-INLINE Object* dvmFillInStackTrace(Thread* thread) {
- return (Object*) dvmFillInStackTraceInternal(thread, true, NULL);
-}
-ArrayObject* dvmGetStackTrace(const Object* stackState);
-/* return an int* and array count; caller must free() the return value */
-INLINE int* dvmFillInStackTraceRaw(Thread* thread, int* pCount) {
- return (int*) dvmFillInStackTraceInternal(thread, false, pCount);
-}
-ArrayObject* dvmGetStackTraceRaw(const int* intVals, int stackDepth);
-
-/*
- * Print a formatted version of a raw stack trace to the log file.
- */
-void dvmLogRawStackTrace(const int* intVals, int stackDepth);
-
#endif /*_DALVIK_EXCEPTION*/