Merge "Wire up work_around_app_jni_bugs." into dalvik-dev
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 31a7d10..381f7e0 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -107,6 +107,10 @@
     close(fd);
     return NULL;
   }
+  if (S_ISDIR(sbuf.st_mode)) {
+    LOG(ERROR) << "attempt to mmap directory \"" << filename << "\"";
+    return NULL;
+  }
   size_t length = sbuf.st_size;
   UniquePtr<MemMap> map(MemMap::MapFile(length, PROT_READ, MAP_PRIVATE, fd, 0));
   if (map.get() == NULL) {
diff --git a/src/mark_stack.cc b/src/mark_stack.cc
index b61597b..707b98b 100644
--- a/src/mark_stack.cc
+++ b/src/mark_stack.cc
@@ -36,6 +36,8 @@
   }
 }
 
-MarkStack::~MarkStack() {}
+MarkStack::~MarkStack() {
+  CHECK(IsEmpty());
+}
 
 }  // namespace art
diff --git a/src/monitor.cc b/src/monitor.cc
index caaa116..b641160 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -800,12 +800,15 @@
                                 const char*& source_file, uint32_t& line_number) const {
   // If method is null, location is unknown
   if (method == NULL) {
-    source_file = "unknown";
+    source_file = "";
     line_number = 0;
     return;
   }
   MethodHelper mh(method);
   source_file = mh.GetDeclaringClassSourceFile();
+  if (source_file == NULL) {
+    source_file = "";
+  }
   line_number = mh.GetLineNumFromNativePC(pc);
 }
 
diff --git a/src/object_utils.h b/src/object_utils.h
index 0412858..3af7007 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -169,11 +169,8 @@
     std::string descriptor(GetDescriptor());
     const DexFile& dex_file = GetDexFile();
     const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor);
-    if (dex_class_def == NULL) {
-      return NULL;
-    } else {
-      return dex_file.GetSourceFile(*dex_class_def);
-    }
+    CHECK(dex_class_def != NULL);
+    return dex_file.GetSourceFile(*dex_class_def);
   }
 
   std::string GetLocation() {
@@ -477,11 +474,8 @@
     const char* descriptor = GetDeclaringClassDescriptor();
     const DexFile& dex_file = GetDexFile();
     const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor);
-    if (dex_class_def == NULL) {
-      return NULL;
-    } else {
-      return dex_file.GetSourceFile(*dex_class_def);
-    }
+    CHECK(dex_class_def != NULL);
+    return dex_file.GetSourceFile(*dex_class_def);
   }
   bool IsStatic() {
     return method_->IsStatic();