Avoid compile time rewriting of dex code by verifier.

Compile time rewriting of dex code leads to dead code that is causing
issues with the LLVM compiler. Make instantiation and incompatible class
change errors be detected in slow path field and invoke logic so its
safe for the compile time verification just to softly fail the effected
classes.

This change places incompatible class change logic into the class
linkers ResolveMethod and consequently changes a number of APIs.

Change-Id: Ifb25f09accea348d15180f6ff041e38dfe0d536e
diff --git a/src/dex_file.h b/src/dex_file.h
index 5f33ef8..99a748d 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -21,9 +21,11 @@
 #include <vector>
 
 #include "globals.h"
+#include "invoke_type.h"
 #include "jni.h"
 #include "logging.h"
 #include "mem_map.h"
+#include "modifiers.h"
 #include "mutex.h"
 #include "safe_map.h"
 #include "stringpiece.h"
@@ -1024,6 +1026,24 @@
       return method_.access_flags_;
     }
   }
+  InvokeType GetMethodInvokeType(const DexFile::ClassDef& class_def) const {
+    if (HasNextDirectMethod()) {
+      if ((GetMemberAccessFlags() & kAccStatic) != 0 ) {
+        return kStatic;
+      } else {
+        return kDirect;
+      }
+    } else {
+      CHECK_EQ(GetMemberAccessFlags() & kAccStatic, 0U);
+      if ((class_def.access_flags_ & kAccInterface) != 0) {
+        return kInterface;
+      } else if ((GetMemberAccessFlags() & kAccConstructor) != 0) {
+        return kSuper;
+      } else {
+        return kVirtual;
+      }
+    }
+  }
   const DexFile::CodeItem* GetMethodCodeItem() const {
     return dex_file_.GetCodeItem(method_.code_off_);
   }