Better unresolved type support.

Also fix bug where miranda methods were changing their declaring class
and thereby breaking their return type indices.
Add support for dumping stacks on abort.

Change-Id: I3782864736b12d1f81ab9aea4909213d3344ba13
diff --git a/src/runtime.cc b/src/runtime.cc
index 9e8b28b..7aa4f51 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -82,7 +82,21 @@
 
   // Many people have difficulty distinguish aborts from crashes,
   // so be explicit.
-  LogMessage(file, line, ERROR, -1).stream() << "Runtime aborting...";
+  {
+    LogMessage log(file, line, ERROR, -1);
+    log.stream() << "Runtime aborting..." << std::endl;
+    // Add Java stack trace if possible
+    Thread* thread = Thread::Current();
+    if (thread != NULL) {
+      log.stream() << "Java stack trace of aborting thread:" << std::endl;
+      thread->DumpStack(log.stream());
+      if (thread->IsExceptionPending()) {
+        Throwable* e = thread->GetException();
+        log.stream() << "Pending exception on thread: " << PrettyTypeOf(e) << std::endl;
+        log.stream() << e->Dump();
+      }
+    }
+  }
 
   // Perform any platform-specific pre-abort actions.
   PlatformAbort(file, line);