Throw if ResolveMethod fails.
It's impractical for the lower-level Find*Method calls to throw because
they're used in class initialization and exception throwing.
Change-Id: Idece1ea99553a758ebc23d987e46b59f0445ea67
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 7adbaeb..5ab8692 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -288,11 +288,10 @@
}
if (method == NULL || method->IsStatic() != is_static) {
- Thread* self = Thread::Current();
std::string method_name(PrettyMethod(method));
// TODO: try searching for the opposite kind of method from is_static
// for better diagnostics?
- self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
+ ts.Self()->ThrowNewException("Ljava/lang/NoSuchMethodError;",
"no %s method %s", is_static ? "static" : "non-static",
method_name.c_str());
return NULL;
@@ -2119,16 +2118,14 @@
m = c->FindVirtualMethod(name, sig);
}
if (m == NULL) {
- Thread* self = Thread::Current();
std::string class_descriptor(c->GetDescriptor()->ToModifiedUtf8());
- self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
+ ts.Self()->ThrowNewException("Ljava/lang/NoSuchMethodError;",
"no method \"%s.%s%s\"",
class_descriptor.c_str(), name, sig);
return JNI_ERR;
} else if (!m->IsNative()) {
- Thread* self = Thread::Current();
std::string class_descriptor(c->GetDescriptor()->ToModifiedUtf8());
- self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
+ ts.Self()->ThrowNewException("Ljava/lang/NoSuchMethodError;",
"method \"%s.%s%s\" is not native",
class_descriptor.c_str(), name, sig);
return JNI_ERR;