Turn off the 'public' check for main, and improve diagnostics.
We're likely to be able to invoke a static main method before we can invoke
a virtual getModifiers, and right now we don't care whether we've been asked
to run a non-public main.
Also adds PrettyMethod for improved diagnostics.
Change-Id: Iea08f0be980386adbe408b476449c2066c4e6da8
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index a55cdae..6acfb71 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -38,7 +38,7 @@
size_t length = assembler.CodeSize();
void* addr = mmap(NULL, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED) {
- PLOG(FATAL) << "mmap failed";
+ PLOG(FATAL) << "mmap failed for " << PrettyMethod(method, true);
}
MemoryRegion region(addr, length);
assembler.FinalizeInstructions(region);
@@ -405,8 +405,8 @@
if (method->GetCode()) {
(*stub)(method, rcvr, self, args, &result);
} else {
- // TODO: pretty print method here
- LOG(WARNING) << "Not invoking method with no associated code";
+ LOG(WARNING) << "Not invoking method with no associated code: "
+ << PrettyMethod(method, true);
result.j = 0;
}
// Pop transition
@@ -472,12 +472,12 @@
if (method == NULL || method->IsStatic() != is_static) {
Thread* self = Thread::Current();
- std::string class_name(c->GetDescriptor()->ToModifiedUtf8());
+ std::string method_name(PrettyMethod(method, true));
// TODO: try searching for the opposite kind of method from is_static
// for better diagnostics?
self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
- "no %s method \"%s.%s%s\"", is_static ? "static" : "non-static",
- class_name.c_str(), name, sig);
+ "no %s method %s", is_static ? "static" : "non-static",
+ method_name.c_str());
return NULL;
}
@@ -2004,7 +2004,6 @@
if (method == NULL) {
Thread* self = Thread::Current();
std::string class_name = klass->GetDescriptor()->ToModifiedUtf8();
- // TODO: pretty print method names through a single routine
self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
"no method \"%s.%s%s\"",
class_name.c_str(), name, sig);
@@ -2012,7 +2011,6 @@
} else if (!method->IsNative()) {
Thread* self = Thread::Current();
std::string class_name = klass->GetDescriptor()->ToModifiedUtf8();
- // TODO: pretty print method names through a single routine
self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
"method \"%s.%s%s\" is not native",
class_name.c_str(), name, sig);