From 5cb5ad27944efb08d4556b3c0d362302e37e832b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sun, 2 Oct 2011 12:13:39 -0700 Subject: Fix exception throwing to support no detail message. (The empty string as a detail message is distinct from a NULL detail message, and is treated differently by Throwable.printStackTrace.) Change-Id: I8c65deac9f18c5782dcf6e72e4c37e6dd4174fe9 --- src/java_lang_System.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/java_lang_System.cc') diff --git a/src/java_lang_System.cc b/src/java_lang_System.cc index 42bae22c40..4a6e8db955 100644 --- a/src/java_lang_System.cc +++ b/src/java_lang_System.cc @@ -106,7 +106,8 @@ namespace { void ThrowArrayStoreException_NotAnArray(const char* identifier, Object* array) { std::string actualType(PrettyTypeOf(array)); - Thread::Current()->ThrowNewException("Ljava/lang/ArrayStoreException;", "%s is not an array: %s", identifier, actualType.c_str()); + Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;", + "%s is not an array: %s", identifier, actualType.c_str()); } void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject javaDst, jint dstPos, jint length) { @@ -140,7 +141,7 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject // Bounds checking. if (srcPos < 0 || dstPos < 0 || length < 0 || srcPos > srcArray->GetLength() - length || dstPos > dstArray->GetLength() - length) { - self->ThrowNewException("Ljava/lang/ArrayIndexOutOfBoundsException;", + self->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;", "src.length=%d srcPos=%d dst.length=%d dstPos=%d length=%d", srcArray->GetLength(), srcPos, dstArray->GetLength(), dstPos, length); return; @@ -155,7 +156,7 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject if (srcComponentType->IsPrimitive() != dstComponentType->IsPrimitive() || srcComponentType != dstComponentType) { std::string srcType(PrettyTypeOf(srcArray)); std::string dstType(PrettyTypeOf(dstArray)); - self->ThrowNewException("Ljava/lang/ArrayStoreException;", + self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;", "Incompatible types: src=%s, dst=%s", srcType.c_str(), dstType.c_str()); return; } @@ -231,7 +232,7 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject if (copyCount != length) { std::string actualSrcType(PrettyTypeOf(srcObj[copyCount])); std::string dstType(PrettyTypeOf(dstArray)); - self->ThrowNewException("Ljava/lang/ArrayStoreException;", + self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;", "source[%d] of type %s cannot be stored in destination array of type %s", srcPos + copyCount, actualSrcType.c_str(), dstType.c_str()); return; -- cgit v1.2.3-59-g8ed1b