Factor out class names from throw statements.
Most exception throwing now happens via purpose-built wrapper
functions, each of which encapsulates the actual exception class name,
reducing one source of error (examples of which I fixed during this
exercise) and generally tidying things up.
This change doesn't fix all uses of exception class names, nor even
all throws, because (a) there were classes I didn't get to; (b)
because I didn't make wrappers for all the possible throw function
variants (e.g. the one that takes a cause, the one that takes varargs
for string formatting, etc.); and (c) there are uses of exception
classes in contexts other than throwing. But this change at least makes
a dent in the problem.
Change-Id: I6586ddd3e66ac0fc32c23181b17600ded0b914b2
diff --git a/vm/Thread.c b/vm/Thread.c
index 6745dae..cdc9f4f 100644
--- a/vm/Thread.c
+++ b/vm/Thread.c
@@ -1467,7 +1467,7 @@
if (dvmGetFieldObject(threadObj, gDvm.offJavaLangThread_vmThread) != NULL) {
dvmUnlockThreadList();
- dvmThrowException("Ljava/lang/IllegalThreadStateException;",
+ dvmThrowIllegalThreadStateException(
"thread has already been started");
goto fail;
}
@@ -1503,8 +1503,7 @@
dvmSetFieldObject(threadObj, gDvm.offJavaLangThread_vmThread, NULL);
- dvmThrowException("Ljava/lang/OutOfMemoryError;",
- "thread creation failed");
+ dvmThrowOutOfMemoryError("thread creation failed");
goto fail;
}
@@ -2097,7 +2096,7 @@
*/
if (dvmGetFieldObject(threadObj, gDvm.offJavaLangThread_vmThread) != NULL) {
LOGW("WOW: thread start hijack\n");
- dvmThrowException("Ljava/lang/IllegalThreadStateException;",
+ dvmThrowIllegalThreadStateException(
"thread has already been started");
/* We don't want to free anything associated with the thread
* because someone is obviously interested in it. Just let
@@ -3208,7 +3207,7 @@
groupObj = dvmGetStaticFieldObject(groupField);
if (groupObj == NULL) {
LOGE("java.lang.ThreadGroup.%s not initialized\n", fieldName);
- dvmThrowException("Ljava/lang/InternalError;", NULL);
+ dvmThrowInternalError(NULL);
return NULL;
}