}
/*
- * Throw the named exception using the dotted form of the class
+ * 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)
{
- char* message = dvmDescriptorToDot(messageDescriptor);
+ char* message = dvmHumanReadableDescriptor(messageDescriptor);
dvmThrowChainedException(exceptionDescriptor, message, cause);
free(message);
if (exception == NULL)
return;
+ dvmAddTrackedAlloc(exception, self);
self->exception = NULL;
printMethod = dvmFindVirtualMethodHierByDescriptor(exception->clazz,
"printStackTrace", "()V");
}
self->exception = exception;
+ dvmReleaseTrackedAlloc(exception, self);
}
/*
else
lineNumber = dvmLineNumFromPC(meth, pc);
- dotName = dvmDescriptorToDot(meth->clazz->descriptor);
+ dotName = dvmHumanReadableDescriptor(meth->clazz->descriptor);
className = dvmCreateStringFromCstr(dotName);
free(dotName);
lineNumber = dvmLineNumFromPC(meth, pc);
// probably don't need to do this, but it looks nicer
- dotName = dvmDescriptorToDot(meth->clazz->descriptor);
+ dotName = dvmHumanReadableDescriptor(meth->clazz->descriptor);
if (dvmIsNativeMethod(meth)) {
LOGI("\tat %s.%s(Native Method)\n", dotName, meth->name);
StringObject* messageStr = NULL;
assert(exception == self->exception);
+ dvmAddTrackedAlloc(exception, self);
self->exception = NULL;
getMessageMethod = dvmFindVirtualMethodHierByDescriptor(exception->clazz,
}
self->exception = exception;
+ dvmReleaseTrackedAlloc(exception, self);
return messageStr;
}
const int* intVals;
char* className;
- className = dvmDescriptorToDot(exception->clazz->descriptor);
+ className = dvmHumanReadableDescriptor(exception->clazz->descriptor);
messageStr = getExceptionMessage(exception);
if (messageStr != NULL) {
char* cp = dvmCreateCstrFromString(messageStr);
exception = cause;
}
}
+
+void dvmThrowAIOOBE(int index, int length)
+{
+ dvmThrowExceptionFmt("Ljava/lang/ArrayIndexOutOfBoundsException;",
+ "index=%d length=%d", index, length);
+}
+
+static void dvmThrowTypeError(const char* exceptionClassName, const char* fmt,
+ ClassObject* actual, ClassObject* desired)
+{
+ char* actualClassName = dvmHumanReadableDescriptor(actual->descriptor);
+ char* desiredClassName = dvmHumanReadableDescriptor(desired->descriptor);
+ dvmThrowExceptionFmt(exceptionClassName, fmt,
+ actualClassName, desiredClassName);
+ free(desiredClassName);
+ free(actualClassName);
+}
+
+void dvmThrowArrayStoreException(ClassObject* actual, ClassObject* desired)
+{
+ dvmThrowTypeError("Ljava/lang/ArrayStoreException;",
+ "%s cannot be stored in an array of type %s",
+ actual, desired);
+}
+
+void dvmThrowClassCastException(ClassObject* actual, ClassObject* desired)
+{
+ dvmThrowTypeError("Ljava/lang/ClassCastException;",
+ "%s cannot be cast to %s", actual, desired);
+}