diff options
author | Dan Bornstein <danfuzz@android.com> | 2011-02-23 13:07:07 -0800 |
---|---|---|
committer | Dan Bornstein <danfuzz@android.com> | 2011-02-23 13:39:59 -0800 |
commit | d27f3cf3e7b373487f39e035fc4b55168d55c454 (patch) | |
tree | 9273f2145cc3e805464f9932564ba35434842edb /vm/Exception.h | |
parent | 92d6b94f3ef0151a63f621d769dbed6c09e86d19 (diff) | |
download | android_dalvik-d27f3cf3e7b373487f39e035fc4b55168d55c454.tar.gz android_dalvik-d27f3cf3e7b373487f39e035fc4b55168d55c454.tar.bz2 android_dalvik-d27f3cf3e7b373487f39e035fc4b55168d55c454.zip |
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
Diffstat (limited to 'vm/Exception.h')
-rw-r--r-- | vm/Exception.h | 147 |
1 files changed, 143 insertions, 4 deletions
diff --git a/vm/Exception.h b/vm/Exception.h index 6d05b09e1..7f02b9079 100644 --- a/vm/Exception.h +++ b/vm/Exception.h @@ -40,6 +40,19 @@ INLINE void dvmThrowException(const char* exceptionDescriptor, * index and array length in the detail message. */ void dvmThrowAIOOBE(int index, int length); + +/** + * Throw an AbstractMethodError in the current thread, with the given detail + * message. + */ +void dvmThrowAbstractMethodError(const char* msg); + +/** + * Throw an ArithmeticException in the current thread, with the given detail + * message. + */ +void dvmThrowArithmeticException(const char* msg); + /* * Throw an ArrayStoreException in the current thread, using the given classes' * names in the detail message. @@ -52,6 +65,132 @@ void dvmThrowArrayStoreException(ClassObject* actual, ClassObject* desired); */ void dvmThrowClassCastException(ClassObject* actual, ClassObject* desired); +/** + * Throw a ClassNotFoundException in the current thread, with the given + * detail message. + */ +void dvmThrowClassNotFoundException(const char* msg); + +/** + * Throw a FileNotFoundException in the current thread, with the given + * detail message. + */ +void dvmThrowFileNotFoundException(const char* msg); + +/** + * Throw an IOException in the current thread, with the given + * detail message. + */ +void dvmThrowIOException(const char* msg); + +/** + * Throw an IllegalAccessError in the current thread, with the + * given detail message. + */ +void dvmThrowIllegalAccessError(const char* msg); + +/** + * Throw an IllegalAccessException in the current thread, with the + * given detail message. + */ +void dvmThrowIllegalAccessException(const char* msg); + +/** + * Throw an IllegalArgumentException in the current thread, with the + * given detail message. + */ +void dvmThrowIllegalArgumentException(const char* msg); + +/** + * Throw an IllegalMonitorStateException in the current thread, with + * the given detail message. + */ +void dvmThrowIllegalMonitorStateException(const char* msg); + +/** + * Throw an IllegalStateException in the current thread, with + * the given detail message. + */ +void dvmThrowIllegalStateException(const char* msg); + +/** + * Throw an IllegalThreadStateException in the current thread, with + * the given detail message. + */ +void dvmThrowIllegalThreadStateException(const char* msg); + +/** + * Throw an InternalError in the current thread, with the given + * detail message. + */ +void dvmThrowInternalError(const char* msg); + +/** + * Throw an InterruptedException in the current thread, with the given + * detail message. + */ +void dvmThrowInterruptedException(const char* msg); + +/** + * Throw a NegativeArraySizeException in the current thread, with the + * given detail message. + */ +void dvmThrowNegativeArraySizeException(const char* msg); + +/** + * Throw a NoClassDefFoundError in the current thread, with the + * human-readable form of the given descriptor as the detail message. + */ +void dvmThrowNoClassDefFoundError(const char* descriptor); + +/** + * Throw a NoSuchFieldError in the current thread, with the given + * detail message. + */ +void dvmThrowNoSuchFieldError(const char* msg); + +/** + * Throw a NoSuchFieldException in the current thread, with the given + * detail message. + */ +void dvmThrowNoSuchFieldException(const char* msg); + +/** + * Throw a NoSuchMethodError in the current thread, with the given + * detail message. + */ +void dvmThrowNoSuchMethodError(const char* msg); + +/** + * Throw a NullPointerException in the current thread, with the given + * detail message. + */ +void dvmThrowNullPointerException(const char* msg); + +/** + * Throw an OutOfMemoryError in the current thread, with the given + * detail message. + */ +void dvmThrowOutOfMemoryError(const char* msg); + +/** + * Throw a RuntimeException in the current thread, with the given detail + * message. + */ +void dvmThrowRuntimeException(const char* msg); + +/** + * Throw a StringIndexOutOfBoundsException in the current thread, with + * the given detail message. + */ +void dvmThrowStringIndexOutOfBoundsException(const char* msg); + +/** + * Throw an UnsupportedOperationException in the current thread, with + * the given detail message. + */ +void dvmThrowUnsupportedOperationException(const char* msg); + /* * Like dvmThrowChainedException, but takes printf-style args for the message. */ @@ -83,8 +222,8 @@ INLINE void dvmThrowExceptionByClass(ClassObject* exceptionClass, } /* - * Throw the named exception using the name of a class as the exception - * message. + * 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); @@ -96,8 +235,8 @@ INLINE void dvmThrowExceptionWithClassMessage(const char* exceptionDescriptor, } /* - * Like dvmThrowExceptionWithMessageFromDescriptor, but take a - * class object instead of a name. + * 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); |