Add the runtime lookup of native method implementations.

Plus other bits of cleanup.

Change-Id: I8584001d7eeb118f8e29c4a62652a18b94333be8
diff --git a/src/thread.h b/src/thread.h
index f695df1..820e2aa 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -44,20 +44,20 @@
 
   static Mutex* Create(const char* name);
 
- public:  // TODO: protected
-  void SetOwner(Thread* thread) { owner_ = thread; }
+  // TODO: only needed because we lack a condition variable abstraction.
+  pthread_mutex_t* GetImpl() { return &lock_impl_; }
 
  private:
   explicit Mutex(const char* name) : name_(name), owner_(NULL) {}
 
+  void SetOwner(Thread* thread) { owner_ = thread; }
+
   const char* name_;
 
   Thread* owner_;
 
   pthread_mutex_t lock_impl_;
 
-  friend class SharedLibrary; // For lock_impl_.
-
   DISALLOW_COPY_AND_ASSIGN(Mutex);
 };
 
@@ -256,6 +256,9 @@
   void ThrowNewException(const char* exception_class_descriptor, const char* fmt, ...)
       __attribute__ ((format(printf, 3, 4)));
 
+  // This exception is special, because we need to pre-allocate an instance.
+  void ThrowOutOfMemoryError();
+
   void ClearException() {
     exception_ = NULL;
   }