summaryrefslogtreecommitdiffstats
path: root/xml
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-10-01 11:20:29 -0700
committerElliott Hughes <enh@google.com>2009-10-01 11:20:29 -0700
commit738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a (patch)
treea803f5fda92fe4a84c6f00d76db4f8e20e4a61ae /xml
parent109fc1115e7afd2907544b805eaa2cc8a0e2635f (diff)
downloadlibcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.zip
libcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.tar.gz
libcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.tar.bz2
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 'xml')
-rw-r--r--xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index 6132107..15f1d28 100644
--- a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/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