Increase use of ScopedJniThreadState.

Move the routines for changing Object* to jobject and vice-versa
(AddLocalReference and Decode) to ScopedJniThreadState to enforce use of
Object*s in the Runnable thread state. In the Runnable thread state
suspension is necessary before GC can take place.

Reduce use of const ClassLoader* as the code bottoms out in FindClass
and with a field assignment where the const is cast away (ie if we're
not going to enforce the const-ness we shouldn't pretend it is).

Refactor the Thread::Attach API so that we're not handling raw Objects on
unattached threads.

Remove some unreachable code.

Change-Id: I0fa969f49ee6a8f10752af74a6b0e04d46b4cd97
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index e3faa3b..088726f 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -31,13 +31,13 @@
 
 class CompilerTest : public CommonTest {
  protected:
-  void CompileAll(const ClassLoader* class_loader) {
+  void CompileAll(ClassLoader* class_loader) {
     compiler_->CompileAll(class_loader, Runtime::Current()->GetCompileTimeClassPath(class_loader));
     MakeAllExecutable(class_loader);
   }
 
-  void EnsureCompiled(const ClassLoader* class_loader,
-      const char* class_name, const char* method, const char* signature, bool is_virtual) {
+  void EnsureCompiled(ClassLoader* class_loader, const char* class_name, const char* method,
+                      const char* signature, bool is_virtual) {
     CompileAll(class_loader);
     runtime_->Start();
     env_ = Thread::Current()->GetJniEnv();
@@ -51,7 +51,7 @@
     CHECK(mid_ != NULL) << "Method not found: " << class_name << "." << method << signature;
   }
 
-  void MakeAllExecutable(const ClassLoader* class_loader) {
+  void MakeAllExecutable(ClassLoader* class_loader) {
     const std::vector<const DexFile*>& class_path
         = Runtime::Current()->GetCompileTimeClassPath(class_loader);
     for (size_t i = 0; i != class_path.size(); ++i) {
@@ -61,7 +61,7 @@
     }
   }
 
-  void MakeDexFileExecutable(const ClassLoader* class_loader, const DexFile& dex_file) {
+  void MakeDexFileExecutable(ClassLoader* class_loader, const DexFile& dex_file) {
     ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
     for (size_t i = 0; i < dex_file.NumClassDefs(); i++) {
       const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);