diff options
| author | Elliott Hughes <enh@google.com> | 2009-10-01 11:20:29 -0700 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2009-10-01 11:20:29 -0700 |
| commit | 76ecf19c339da1f38a0e954ef39d9ff411b15925 (patch) | |
| tree | c80a7bb71123af466ec53f2d66a212ee2367f9ce /libcore/xml | |
| parent | 76a477ed7e878fb1193de51ce7caec46b2d1f515 (diff) | |
| download | android_dalvik-76ecf19c339da1f38a0e954ef39d9ff411b15925.tar.gz android_dalvik-76ecf19c339da1f38a0e954ef39d9ff411b15925.tar.bz2 android_dalvik-76ecf19c339da1f38a0e954ef39d9ff411b15925.zip | |
Use jniThrowException instead of FindClass/ThrowNew.
Always use our best-of-breed code for throwing exceptions. The remaining
callers of Throw have good reason, and the only caller of ThrowNew is
now JNIHelp.c (jniThrowException) itself.
Diffstat (limited to 'libcore/xml')
| -rw-r--r-- | libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp index 61321073a..15f1d28d7 100644 --- a/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp +++ b/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp @@ -327,15 +327,9 @@ static jstring internStringOfLength(JNIEnv* env, ParsingContext* parsingContext, return internString(env, parsingContext, nullTerminated); } -/** - * Throw an assertion error. - * - * @param message to show - */ -static void fail(JNIEnv* env, const char* message) { - jclass clazz; - clazz = env->FindClass("java/lang/AssertionError"); - env->ThrowNew(clazz, message); +static void jniThrowExpatException(JNIEnv* env, XML_Error error) { + const char* message = XML_ErrorString(error); + jniThrowException(env, "org/apache/harmony/xml/ExpatException", message); } /** @@ -1001,9 +995,7 @@ static void appendString(JNIEnv* env, jobject object, jint pointer, jstring xml, if (!XML_Parse(parser, (char*) characters, length, isFinal) && !env->ExceptionCheck()) { - jclass clazz = env->FindClass("org/apache/harmony/xml/ExpatException"); - const char* errorMessage = XML_ErrorString(XML_GetErrorCode(parser)); - env->ThrowNew(clazz, errorMessage); + jniThrowExpatException(env, XML_GetErrorCode(parser)); } // We have to temporarily clear an exception before we can release local @@ -1041,9 +1033,7 @@ static void appendCharacters(JNIEnv* env, jobject object, jint pointer, if (!XML_Parse(parser, ((char*) characters) + (offset << 1), length << 1, XML_FALSE) && !env->ExceptionCheck()) { - jclass clazz = env->FindClass("org/apache/harmony/xml/ExpatException"); - const char* errorMessage = XML_ErrorString(XML_GetErrorCode(parser)); - env->ThrowNew(clazz, errorMessage); + jniThrowExpatException(env, XML_GetErrorCode(parser)); } // We have to temporarily clear an exception before we can release local @@ -1081,9 +1071,7 @@ static void appendBytes(JNIEnv* env, jobject object, jint pointer, if (!XML_Parse(parser, ((char*) bytes) + offset, length, XML_FALSE) && !env->ExceptionCheck()) { - jclass clazz = env->FindClass("org/apache/harmony/xml/ExpatException"); - const char* errorMessage = XML_ErrorString(XML_GetErrorCode(parser)); - env->ThrowNew(clazz, errorMessage); + jniThrowExpatException(env, XML_GetErrorCode(parser)); } // We have to temporarily clear an exception before we can release local |
