summaryrefslogtreecommitdiff
path: root/src/java_lang_Class.cc
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2011-10-02 12:13:39 -0700
committer Elliott Hughes <enh@google.com> 2011-10-02 12:13:39 -0700
commit5cb5ad27944efb08d4556b3c0d362302e37e832b (patch)
tree63334f19072ca2ba7179973f0ce62101ee89605d /src/java_lang_Class.cc
parentd6fe38d96b6116bd53cf2cb14734af8d69e08661 (diff)
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
Diffstat (limited to 'src/java_lang_Class.cc')
-rw-r--r--src/java_lang_Class.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/java_lang_Class.cc b/src/java_lang_Class.cc
index de5315ada8..a40452355e 100644
--- a/src/java_lang_Class.cc
+++ b/src/java_lang_Class.cc
@@ -38,7 +38,7 @@ jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean initia
// is especially handy for array types, since we want to avoid
// auto-generating bogus array classes.
if (!IsValidClassName(name.c_str(), true, true)) {
- Thread::Current()->ThrowNewException("Ljava/lang/ClassNotFoundException;",
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/ClassNotFoundException;",
"Invalid name: %s", name.c_str());
return NULL;
}
@@ -53,8 +53,7 @@ jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean initia
// TODO: chain exceptions?
DCHECK(env->ExceptionCheck());
env->ExceptionClear();
- Thread::Current()->ThrowNewException("Ljava/lang/ClassNotFoundException;",
- "%s", name.c_str());
+ Thread::Current()->ThrowNewException("Ljava/lang/ClassNotFoundException;", name.c_str());
return NULL;
}
if (initialize) {
@@ -373,7 +372,7 @@ bool CheckMemberAccess(const Class* access_from, const Class* access_to, uint32_
jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) {
Class* c = Decode<Class*>(env, javaThis);
if (c->IsPrimitive() || c->IsInterface() || c->IsArrayClass() || c->IsAbstract()) {
- Thread::Current()->ThrowNewException("Ljava/lang/InstantiationException;",
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
"Class %s can not be instantiated", PrettyDescriptor(c->GetDescriptor()).c_str());
return NULL;
}
@@ -384,7 +383,7 @@ jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) {
Method* init = c->FindDirectMethod("<init>", "()V");
if (init == NULL) {
- Thread::Current()->ThrowNewException("Ljava/lang/InstantiationException;",
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
"Class %s has no default <init>()V constructor", PrettyDescriptor(c->GetDescriptor()).c_str());
return NULL;
}
@@ -405,17 +404,17 @@ jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) {
Class* caller_class = caller_caller->GetDeclaringClass();
if (!caller_class->CanAccess(c)) {
- Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessException;",
- "Class %s is not accessible from class %s",
- PrettyDescriptor(c->GetDescriptor()).c_str(),
- PrettyDescriptor(caller_class->GetDescriptor()).c_str());
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessException;",
+ "Class %s is not accessible from class %s",
+ PrettyDescriptor(c->GetDescriptor()).c_str(),
+ PrettyDescriptor(caller_class->GetDescriptor()).c_str());
return NULL;
}
if (!CheckMemberAccess(caller_class, init->GetDeclaringClass(), init->GetAccessFlags())) {
- Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessException;",
- "%s is not accessible from class %s",
- PrettyMethod(init).c_str(),
- PrettyDescriptor(caller_class->GetDescriptor()).c_str());
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessException;",
+ "%s is not accessible from class %s",
+ PrettyMethod(init).c_str(),
+ PrettyDescriptor(caller_class->GetDescriptor()).c_str());
return NULL;
}