Switch to UniquePtr.

Only one use of scoped_ptr was incorrect (but then again, I spent an afternoon
with valgrind finding and fixing them just last week).

Change-Id: If5ec1c8aa0794a4f652bfd1c0fffccf95facdc40
diff --git a/src/base64.cc b/src/base64.cc
index a1bb61c..4966314 100644
--- a/src/base64.cc
+++ b/src/base64.cc
@@ -1,10 +1,10 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
-#include "globals.h"
-#include "scoped_ptr.h"
-
 #include <vector>
 
+#include "UniquePtr.h"
+#include "globals.h"
+
 namespace art {
 
 static const byte kMap[256] = {
@@ -65,7 +65,7 @@
   if (y != 0) {
     return NULL;
   }
-  scoped_ptr<byte> dst(new byte[tmp.size()]);
+  UniquePtr<byte[]> dst(new byte[tmp.size()]);
   if (dst_size != NULL) {
     *dst_size = tmp.size();
   }
diff --git a/src/calling_convention.h b/src/calling_convention.h
index 7e59fd5..1385337 100644
--- a/src/calling_convention.h
+++ b/src/calling_convention.h
@@ -97,9 +97,10 @@
 // | Native frame           |
 class JniCallingConvention : public CallingConvention {
  public:
-  explicit JniCallingConvention(Method* native_method) :
-                      CallingConvention(native_method),
-                      spill_regs_(ComputeRegsToSpillPreCall()) {}
+  explicit JniCallingConvention(Method* native_method)
+      : CallingConvention(native_method) {
+    ComputeRegsToSpillPreCall(spill_regs_);
+  }
 
   // Size of frame excluding space for outgoing args (its assumed Method* is
   // always at the bottom of a frame, but this doesn't work for outgoing
@@ -120,7 +121,7 @@
   // Registers that must be spilled (due to clobbering) before the call into
   // the native routine
   const std::vector<ManagedRegister>& RegsToSpillPreCall() {
-    return *spill_regs_.get();
+    return spill_regs_;
   }
 
   // Returns true if the register will be clobbered by an outgoing
@@ -167,10 +168,10 @@
   size_t NumberOfOutgoingStackArgs();
 
   // Compute registers for RegsToSpillPreCall
-  std::vector<ManagedRegister>* ComputeRegsToSpillPreCall();
+  void ComputeRegsToSpillPreCall(std::vector<ManagedRegister>& regs);
 
   // Extra registers to spill before the call into native
-  const scoped_ptr<std::vector<ManagedRegister> > spill_regs_;
+  std::vector<ManagedRegister> spill_regs_;
 
   static size_t NumberOfExtraArgumentsForJni(const Method* method);
   DISALLOW_COPY_AND_ASSIGN(JniCallingConvention);
diff --git a/src/calling_convention_arm.cc b/src/calling_convention_arm.cc
index 826f40d..00720de 100644
--- a/src/calling_convention_arm.cc
+++ b/src/calling_convention_arm.cc
@@ -91,17 +91,14 @@
   return GetMethod()->IsSynchronized() ? (4 * kPointerSize) : kPointerSize;
 }
 
-std::vector<ManagedRegister>* JniCallingConvention::ComputeRegsToSpillPreCall()
-{
+void JniCallingConvention::ComputeRegsToSpillPreCall(std::vector<ManagedRegister>& regs) {
   // A synchronized method will call monitor enter clobbering R1, R2 and R3
   // unless they are spilled.
-  std::vector<ManagedRegister>* result = new std::vector<ManagedRegister>();
   if (GetMethod()->IsSynchronized()) {
-    result->push_back(ManagedRegister::FromCoreRegister(R1));
-    result->push_back(ManagedRegister::FromCoreRegister(R2));
-    result->push_back(ManagedRegister::FromCoreRegister(R3));
+    regs.push_back(ManagedRegister::FromCoreRegister(R1));
+    regs.push_back(ManagedRegister::FromCoreRegister(R2));
+    regs.push_back(ManagedRegister::FromCoreRegister(R3));
   }
-  return result;
 }
 
 // Will reg be crushed by an outgoing argument?
diff --git a/src/calling_convention_x86.cc b/src/calling_convention_x86.cc
index 148eee2..7257ef6 100644
--- a/src/calling_convention_x86.cc
+++ b/src/calling_convention_x86.cc
@@ -71,11 +71,9 @@
   return 0;
 }
 
-std::vector<ManagedRegister>* JniCallingConvention::ComputeRegsToSpillPreCall()
-{
+void JniCallingConvention::ComputeRegsToSpillPreCall(std::vector<ManagedRegister>& regs) {
   // No live values in registers (everything is on the stack) so never anything
   // to preserve.
-  return  new std::vector<ManagedRegister>();
 }
 
 bool JniCallingConvention::IsOutArgRegister(ManagedRegister) {
diff --git a/src/class_linker.cc b/src/class_linker.cc
index e03eca6..9bbcb0c 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2,18 +2,18 @@
 
 #include "class_linker.h"
 
-#include <vector>
 #include <utility>
+#include <vector>
 
+#include "UniquePtr.h"
 #include "casts.h"
 #include "dex_cache.h"
+#include "dex_file.h"
 #include "dex_verifier.h"
 #include "heap.h"
 #include "logging.h"
 #include "monitor.h"
 #include "object.h"
-#include "dex_file.h"
-#include "scoped_ptr.h"
 #include "space.h"
 #include "thread.h"
 #include "utils.h"
@@ -52,7 +52,7 @@
 };
 
 ClassLinker* ClassLinker::Create(const std::vector<const DexFile*>& boot_class_path, Space* space) {
-  scoped_ptr<ClassLinker> class_linker(new ClassLinker);
+  UniquePtr<ClassLinker> class_linker(new ClassLinker);
   if (space == NULL) {
     class_linker->Init(boot_class_path);
   } else {
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index 48408c8..e207fd9 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -1,11 +1,12 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
-#include "common_test.h"
 #include "class_linker.h"
+
+#include "UniquePtr.h"
+#include "common_test.h"
 #include "dex_cache.h"
 #include "dex_file.h"
 #include "heap.h"
-
 #include "gtest/gtest.h"
 
 namespace art {
@@ -273,7 +274,7 @@
 }
 
 TEST_F(ClassLinkerTest, FindClassNested) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("Nested"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("Nested"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
 
   Class* outer = class_linker_->FindClass("LNested;", class_loader);
@@ -328,7 +329,7 @@
   EXPECT_EQ(0U, JavaLangObject->NumStaticFields());
   EXPECT_EQ(0U, JavaLangObject->NumInterfaces());
 
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("MyClass"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("MyClass"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   AssertNonExistentClass("LMyClass;");
   Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader);
@@ -451,8 +452,8 @@
 }
 
 TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) {
-  scoped_ptr<const DexFile> dex_1(OpenTestDexFile("MyClass"));
-  scoped_ptr<const DexFile> dex_2(OpenTestDexFile("MyClass"));
+  UniquePtr<const DexFile> dex_1(OpenTestDexFile("MyClass"));
+  UniquePtr<const DexFile> dex_2(OpenTestDexFile("MyClass"));
   const PathClassLoader* class_loader_1 = AllocPathClassLoader(dex_1.get());
   const PathClassLoader* class_loader_2 = AllocPathClassLoader(dex_2.get());
   Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1);
@@ -464,7 +465,7 @@
 
 TEST_F(ClassLinkerTest, StaticFields) {
   // TODO: uncomment expectations of initial values when InitializeClass works
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("Statics"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("Statics"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* statics = class_linker_->FindClass("LStatics;", class_loader);
   class_linker_->EnsureInitialized(statics);
@@ -534,7 +535,7 @@
 }
 
 TEST_F(ClassLinkerTest, Interfaces) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("Interfaces"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("Interfaces"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader);
   Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader);
diff --git a/src/common_test.h b/src/common_test.h
index 4fcf44d..bb9b93c 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -5,18 +5,17 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include "UniquePtr.h"
 #include "base64.h"
-#include "heap.h"
-#include "thread.h"
-#include "stringprintf.h"
 #include "class_linker.h"
 #include "dex_file.h"
-
+#include "heap.h"
+#include "gtest/gtest.h"
+#include "stringprintf.h"
+#include "thread.h"
 #include "unicode/uclean.h"
 #include "unicode/uvernum.h"
 
-#include "gtest/gtest.h"
-
 namespace art {
 
 static inline const DexFile* OpenDexFileBase64(const char* base64,
@@ -86,7 +85,7 @@
     boot_class_path_.push_back(java_lang_dex_file_.get());
 
     runtime_.reset(Runtime::Create(boot_class_path_));
-    ASSERT_TRUE(runtime_ != NULL);
+    ASSERT_TRUE(runtime_.get() != NULL);
     class_linker_ = runtime_->GetClassLinker();
   }
 
@@ -168,9 +167,9 @@
   bool is_host_;
   std::string android_data_;
   std::string art_cache_;
-  scoped_ptr<const DexFile> java_lang_dex_file_;
+  UniquePtr<const DexFile> java_lang_dex_file_;
   std::vector<const DexFile*> boot_class_path_;
-  scoped_ptr<Runtime> runtime_;
+  UniquePtr<Runtime> runtime_;
   ClassLinker* class_linker_;
 };
 
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index 229235a..63881fd 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -1,16 +1,17 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
+#include "compiler.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "UniquePtr.h"
 #include "class_linker.h"
 #include "common_test.h"
-#include "compiler.h"
 #include "dex_cache.h"
 #include "dex_file.h"
 #include "heap.h"
 #include "object.h"
-#include "scoped_ptr.h"
-
-#include <stdint.h>
-#include <stdio.h>
 
 namespace art {
 
@@ -114,7 +115,7 @@
 #endif // __arm__
   }
  private:
-  scoped_ptr<const DexFile> dex_file_;
+  UniquePtr<const DexFile> dex_file_;
 };
 
 // TODO renenable when compiler can handle libcore
diff --git a/src/dex_cache_test.cc b/src/dex_cache_test.cc
index 4c0939a..843466d 100644
--- a/src/dex_cache_test.cc
+++ b/src/dex_cache_test.cc
@@ -5,7 +5,6 @@
 #include "dex_cache.h"
 #include "heap.h"
 #include "object.h"
-#include "scoped_ptr.h"
 
 #include <stdio.h>
 #include "gtest/gtest.h"
diff --git a/src/dex_file.cc b/src/dex_file.cc
index f782fe9..fde6f01 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -3,7 +3,6 @@
 #include "dex_file.h"
 
 #include <fcntl.h>
-#include <map>
 #include <stdio.h>
 #include <string.h>
 #include <sys/file.h>
@@ -11,11 +10,13 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <map>
+
+#include "UniquePtr.h"
 #include "globals.h"
 #include "logging.h"
 #include "object.h"
 #include "os.h"
-#include "scoped_ptr.h"
 #include "stringprintf.h"
 #include "thread.h"
 #include "utils.h"
@@ -184,13 +185,13 @@
   std::string cache_path_tmp = StringPrintf("%s/art-cache/%s", data_root, cache_file.c_str());
   // Example cache_path_tmp = /data/art-cache/parent@dir@foo.jar@classes.dex
 
-  scoped_ptr<ZipArchive> zip_archive(ZipArchive::Open(filename));
-  if (zip_archive == NULL) {
+  UniquePtr<ZipArchive> zip_archive(ZipArchive::Open(filename));
+  if (zip_archive.get() == NULL) {
     LOG(WARNING) << "Could not open " << filename << " when looking for classes.dex";
     return NULL;
   }
-  scoped_ptr<ZipEntry> zip_entry(zip_archive->Find(kClassesDex));
-  if (zip_entry == NULL) {
+  UniquePtr<ZipEntry> zip_entry(zip_archive->Find(kClassesDex));
+  if (zip_entry.get() == NULL) {
     LOG(WARNING) << "Could not find classes.dex within " << filename;
     return NULL;
   }
@@ -218,11 +219,11 @@
         old = current_thread->GetState();
         current_thread->SetState(Thread::kNative);
     }
-    scoped_ptr<LockedFd> fd(LockedFd::CreateAndLock(cache_path_tmp, 0644));
+    UniquePtr<LockedFd> fd(LockedFd::CreateAndLock(cache_path_tmp, 0644));
     if (current_thread != NULL) {
         current_thread->SetState(old);
     }
-    if (fd == NULL) {
+    if (fd.get() == NULL) {
       return NULL;
     }
 
@@ -248,8 +249,8 @@
 
     // We have the correct file open and locked. Extract classes.dex
     TmpFile tmp_file(cache_path_tmp);
-    scoped_ptr<File> file(OS::FileFromFd(cache_path_tmp.c_str(), fd->GetFd()));
-    if (file == NULL) {
+    UniquePtr<File> file(OS::FileFromFd(cache_path_tmp.c_str(), fd->GetFd()));
+    if (file.get() == NULL) {
       return NULL;
     }
     bool success = zip_entry->Extract(*file);
@@ -265,8 +266,8 @@
       return NULL;
     }
     const size_t kBufSize = 32768;
-    scoped_array<uint8_t> buf(new uint8_t[kBufSize]);
-    if (buf == NULL) {
+    UniquePtr<uint8_t[]> buf(new uint8_t[kBufSize]);
+    if (buf.get() == NULL) {
       return NULL;
     }
     uint32_t computed_crc = crc32(0L, Z_NULL, 0);
@@ -302,7 +303,7 @@
 
 const DexFile* DexFile::Open(const byte* dex_bytes, size_t length,
                              const std::string& location, Closer* closer) {
-  scoped_ptr<DexFile> dex_file(new DexFile(dex_bytes, length, location, closer));
+  UniquePtr<DexFile> dex_file(new DexFile(dex_bytes, length, location, closer));
   if (!dex_file->Init()) {
     return NULL;
   } else {
diff --git a/src/dex_file.h b/src/dex_file.h
index bbc3f81..73e6954 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -7,10 +7,10 @@
 #include <string>
 #include <vector>
 
+#include "UniquePtr.h"
 #include "globals.h"
 #include "leb128.h"
 #include "logging.h"
-#include "scoped_ptr.h"
 #include "stringpiece.h"
 #include "strutil.h"
 #include "utils.h"
@@ -885,7 +885,7 @@
   const std::string location_;
 
   // Helper object to free the underlying allocation.
-  scoped_ptr<Closer> closer_;
+  UniquePtr<Closer> closer_;
 
   // Points to the header section.
   const Header* header_;
diff --git a/src/dex_file_test.cc b/src/dex_file_test.cc
index 96d0477..4271d0c 100644
--- a/src/dex_file_test.cc
+++ b/src/dex_file_test.cc
@@ -1,18 +1,19 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
-#include "common_test.h"
 #include "dex_file.h"
-#include "scoped_ptr.h"
 
 #include <stdio.h>
 
+#include "UniquePtr.h"
+#include "common_test.h"
+
 namespace art {
 
 class DexFileTest : public CommonTest {};
 
 TEST_F(DexFileTest, Open) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("Nested"));
-  ASSERT_TRUE(dex != NULL);
+  UniquePtr<const DexFile> dex(OpenTestDexFile("Nested"));
+  ASSERT_TRUE(dex.get() != NULL);
 }
 
 // Although this is the same content logically as the Nested test dex,
@@ -42,8 +43,8 @@
   "AAMgAAACAAAAiAIAAAQgAAADAAAAlAIAAAAgAAACAAAAqwIAAAAQAAABAAAAxAIAAA==";
 
 TEST_F(DexFileTest, Header) {
-  scoped_ptr<const DexFile> raw(OpenDexFileBase64(kRawDex, "kRawDex"));
-  ASSERT_TRUE(raw != NULL);
+  UniquePtr<const DexFile> raw(OpenDexFileBase64(kRawDex, "kRawDex"));
+  ASSERT_TRUE(raw.get() != NULL);
 
   const DexFile::Header& header = raw->GetHeader();
   // TODO: header.magic_
@@ -70,8 +71,8 @@
 }
 
 TEST_F(DexFileTest, ClassDefs) {
-  scoped_ptr<const DexFile> raw(OpenTestDexFile("Nested"));
-  ASSERT_TRUE(raw != NULL);
+  UniquePtr<const DexFile> raw(OpenTestDexFile("Nested"));
+  ASSERT_TRUE(raw.get() != NULL);
   EXPECT_EQ(2U, raw->NumClassDefs());
 
   const DexFile::ClassDef& c0 = raw->GetClassDef(0);
@@ -82,8 +83,8 @@
 }
 
 TEST_F(DexFileTest, CreateMethodDescriptor) {
-  scoped_ptr<const DexFile> raw(OpenTestDexFile("CreateMethodDescriptor"));
-  ASSERT_TRUE(raw != NULL);
+  UniquePtr<const DexFile> raw(OpenTestDexFile("CreateMethodDescriptor"));
+  ASSERT_TRUE(raw.get() != NULL);
   EXPECT_EQ(1U, raw->NumClassDefs());
 
   const DexFile::ClassDef& class_def = raw->GetClassDef(0);
diff --git a/src/dex_instruction_visitor_test.cc b/src/dex_instruction_visitor_test.cc
index 0edf160..fe0f583 100644
--- a/src/dex_instruction_visitor_test.cc
+++ b/src/dex_instruction_visitor_test.cc
@@ -1,9 +1,10 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
 #include "dex_instruction_visitor.h"
-#include "scoped_ptr.h"
 
 #include <iostream>
+
+#include "UniquePtr.h"
 #include "gtest/gtest.h"
 
 namespace art {
@@ -11,7 +12,7 @@
 class TestVisitor : public DexInstructionVisitor<TestVisitor> {};
 
 TEST(InstructionTest, Init) {
-  scoped_ptr<TestVisitor> visitor(new TestVisitor);
+  UniquePtr<TestVisitor> visitor(new TestVisitor);
 }
 
 class CountVisitor : public DexInstructionVisitor<CountVisitor> {
diff --git a/src/dex_verifier.h b/src/dex_verifier.h
index 29dc140..e909b35 100644
--- a/src/dex_verifier.h
+++ b/src/dex_verifier.h
@@ -3,9 +3,10 @@
 #ifndef ART_SRC_DEX_VERIFY_H_
 #define ART_SRC_DEX_VERIFY_H_
 
+#include "dex_file.h"
+#include "dex_instruction.h"
 #include "macros.h"
 #include "object.h"
-#include "dex_instruction.h"
 
 namespace art {
 
diff --git a/src/dex_verifier_test.cc b/src/dex_verifier_test.cc
index 20a3157..ea419f9 100644
--- a/src/dex_verifier_test.cc
+++ b/src/dex_verifier_test.cc
@@ -1,12 +1,13 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
+#include "dex_verifier.h"
+
+#include <stdio.h>
+
+#include "UniquePtr.h"
 #include "class_linker.h"
 #include "common_test.h"
 #include "dex_file.h"
-#include "dex_verifier.h"
-#include "scoped_ptr.h"
-
-#include <stdio.h>
 
 namespace art {
 
@@ -38,7 +39,7 @@
 }
 
 TEST_F(DexVerifierTest, IntMath) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("IntMath"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("IntMath"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* klass = class_linker_->FindClass("LIntMath;", class_loader);
   ASSERT_TRUE(DexVerify::VerifyClass(klass));
diff --git a/src/exception_test.cc b/src/exception_test.cc
index c384bc1..3611b67 100644
--- a/src/exception_test.cc
+++ b/src/exception_test.cc
@@ -2,14 +2,15 @@
 
 #include <sys/mman.h>
 
+#include "UniquePtr.h"
 #include "assembler.h"
 #include "class_linker.h"
 #include "common_test.h"
 #include "dex_file.h"
+#include "gtest/gtest.h"
 #include "jni_compiler.h"
 #include "runtime.h"
 #include "thread.h"
-#include "gtest/gtest.h"
 
 namespace art {
 
@@ -66,7 +67,7 @@
     CommonTest::SetUp();
 
     dex_.reset(OpenDexFileBase64(kMyClassExceptionHandleDex, "kMyClassExceptionHandleDex"));
-    ASSERT_TRUE(dex_ != NULL);
+    ASSERT_TRUE(dex_.get() != NULL);
     const PathClassLoader* class_loader = AllocPathClassLoader(dex_.get());
     ASSERT_TRUE(class_loader != NULL);
     my_klass_ = class_linker_->FindClass("Ljava/lang/MyClass;", class_loader);
@@ -94,7 +95,7 @@
     return DexFile::CatchHandlerItem();
   }
 
-  scoped_ptr<const DexFile> dex_;
+  UniquePtr<const DexFile> dex_;
 
   Method* method_f_;
   Method* method_g_;
diff --git a/src/file_test.cc b/src/file_test.cc
index 385b3dd..0019c1d 100644
--- a/src/file_test.cc
+++ b/src/file_test.cc
@@ -1,11 +1,11 @@
 // Copyright 2009 Google Inc. All Rights Reserved.
 
-#include "common_test.h"
 #include "file.h"
-#include "os.h"
-#include "scoped_ptr.h"
 
+#include "UniquePtr.h"
+#include "common_test.h"
 #include "gtest/gtest.h"
+#include "os.h"
 
 namespace art {
 
@@ -13,8 +13,8 @@
 
 TEST_F(FileTest, Read) {
   std::string filename = GetLibCoreDexFileName();
-  scoped_ptr<File> file(OS::OpenFile(filename.c_str(), false));
-  ASSERT_TRUE(file != NULL);
+  UniquePtr<File> file(OS::OpenFile(filename.c_str(), false));
+  ASSERT_TRUE(file.get() != NULL);
   EXPECT_STREQ(filename.c_str(), file->name());
   char buffer[3];
   buffer[0] = '\0';
@@ -27,16 +27,16 @@
 
 TEST_F(FileTest, FileLength) {
   std::string filename = GetLibCoreDexFileName();
-  scoped_ptr<File> file(OS::OpenFile(filename.c_str(), false));
-  ASSERT_TRUE(file != NULL);
+  UniquePtr<File> file(OS::OpenFile(filename.c_str(), false));
+  ASSERT_TRUE(file.get() != NULL);
   EXPECT_NE(0, file->Length());
 }
 
 
 TEST_F(FileTest, FilePosition) {
   std::string filename = GetLibCoreDexFileName();
-  scoped_ptr<File> file(OS::OpenFile(filename.c_str(), false));
-  ASSERT_TRUE(file != NULL);
+  UniquePtr<File> file(OS::OpenFile(filename.c_str(), false));
+  ASSERT_TRUE(file.get() != NULL);
   char buf[4];
   EXPECT_TRUE(file->ReadFully(buf, 2));
   EXPECT_EQ(2, file->Position());
@@ -47,8 +47,8 @@
 
 TEST_F(FileTest, FileFd) {
   std::string filename = GetLibCoreDexFileName();
-  scoped_ptr<File> file(OS::OpenFile(filename.c_str(), false));
-  ASSERT_TRUE(file != NULL);
+  UniquePtr<File> file(OS::OpenFile(filename.c_str(), false));
+  ASSERT_TRUE(file.get() != NULL);
   EXPECT_NE(-1, file->Fd());
 }
 
diff --git a/src/heap.cc b/src/heap.cc
index e96714f..286d706 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4,11 +4,11 @@
 
 #include <vector>
 
+#include "UniquePtr.h"
 #include "image.h"
 #include "mark_sweep.h"
 #include "object.h"
 #include "space.h"
-#include "scoped_ptr.h"
 #include "stl_util.h"
 
 namespace art {
@@ -60,14 +60,14 @@
   size_t num_bytes = limit - base;
 
   // Allocate the initial live bitmap.
-  scoped_ptr<HeapBitmap> live_bitmap(HeapBitmap::Create(base, num_bytes));
-  if (live_bitmap == NULL) {
+  UniquePtr<HeapBitmap> live_bitmap(HeapBitmap::Create(base, num_bytes));
+  if (live_bitmap.get() == NULL) {
     return false;
   }
 
   // Allocate the initial mark bitmap.
-  scoped_ptr<HeapBitmap> mark_bitmap(HeapBitmap::Create(base, num_bytes));
-  if (mark_bitmap == NULL) {
+  UniquePtr<HeapBitmap> mark_bitmap(HeapBitmap::Create(base, num_bytes));
+  if (mark_bitmap.get() == NULL) {
     return false;
   }
 
diff --git a/src/image_test.cc b/src/image_test.cc
index bd30e71..34e243d 100644
--- a/src/image_test.cc
+++ b/src/image_test.cc
@@ -36,8 +36,8 @@
   ASSERT_TRUE(success);
 
   {
-    scoped_ptr<File> file(OS::OpenFile(tmp.GetFilename(), false));
-    ASSERT_TRUE(file != NULL);
+    UniquePtr<File> file(OS::OpenFile(tmp.GetFilename(), false));
+    ASSERT_TRUE(file.get() != NULL);
     ImageHeader image_header;
     file->ReadFully(&image_header, sizeof(image_header));
     ASSERT_TRUE(image_header.IsValid());
@@ -51,8 +51,8 @@
   // lucky by pointers that happen to work referencing the earlier
   // dex.
   delete java_lang_dex_file_.release();
-  scoped_ptr<const DexFile> dex(GetLibCoreDex());
-  ASSERT_TRUE(dex != NULL);
+  UniquePtr<const DexFile> dex(GetLibCoreDex());
+  ASSERT_TRUE(dex.get() != NULL);
 
   std::vector<const DexFile*> boot_class_path;
   boot_class_path.push_back(dex.get());
@@ -64,7 +64,7 @@
   options.push_back(std::make_pair(boot_image.c_str(), reinterpret_cast<void*>(NULL)));
 
   runtime_.reset(Runtime::Create(options, false));
-  ASSERT_TRUE(runtime_ != NULL);
+  ASSERT_TRUE(runtime_.get() != NULL);
   class_linker_ = runtime_->GetClassLinker();
 
   ASSERT_EQ(2U, Heap::GetSpaces().size());
diff --git a/src/image_writer.cc b/src/image_writer.cc
index f31586d..0a66664 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -3,10 +3,12 @@
 #include "image_writer.h"
 
 #include <sys/mman.h>
+
 #include <vector>
 
-#include "dex_cache.h"
+#include "UniquePtr.h"
 #include "class_linker.h"
+#include "dex_cache.h"
 #include "file.h"
 #include "globals.h"
 #include "heap.h"
@@ -27,8 +29,8 @@
   CalculateNewObjectOffsets();
   CopyAndFixupObjects();
 
-  scoped_ptr<File> file(OS::OpenFile(filename, true));
-  if (file == NULL) {
+  UniquePtr<File> file(OS::OpenFile(filename, true));
+  if (file.get() == NULL) {
     return false;
   }
   return file->WriteFully(image_->GetAddress(), image_top_);
@@ -39,7 +41,7 @@
   int prot = PROT_READ | PROT_WRITE;
   size_t length = RoundUp(size, kPageSize);
   image_.reset(MemMap::Map(length, prot));
-  if (image_ == NULL) {
+  if (image_.get() == NULL) {
     return false;
   }
   return true;
diff --git a/src/image_writer.h b/src/image_writer.h
index ebd86a5..4299373 100644
--- a/src/image_writer.h
+++ b/src/image_writer.h
@@ -3,13 +3,14 @@
 #ifndef ART_SRC_IMAGE_WRITER_H_
 #define ART_SRC_IMAGE_WRITER_H_
 
-#include <cstddef>
 #include <stdint.h>
 
+#include <cstddef>
+
+#include "UniquePtr.h"
 #include "mem_map.h"
 #include "object.h"
 #include "os.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
@@ -60,7 +61,7 @@
   void FixupFields(const Object* orig, Object* copy, uint32_t ref_offsets, bool is_static);
 
   // memory mapped for generating the image
-  scoped_ptr<MemMap> image_;
+  UniquePtr<MemMap> image_;
 
   // Offset to the free space in image_
   size_t image_top_;
diff --git a/src/intern_table.cc b/src/intern_table.cc
index 703bbe6..7e3a2f6 100644
--- a/src/intern_table.cc
+++ b/src/intern_table.cc
@@ -2,7 +2,7 @@
 
 #include "intern_table.h"
 
-#include "scoped_ptr.h"
+#include "UniquePtr.h"
 #include "utf.h"
 
 namespace art {
@@ -28,7 +28,7 @@
 }
 
 String* InternTable::Intern(int32_t utf16_length, const char* utf8_data_in) {
-  scoped_array<uint16_t> utf16_data_out(new uint16_t[utf16_length]);
+  UniquePtr<uint16_t[]> utf16_data_out(new uint16_t[utf16_length]);
   ConvertModifiedUtf8ToUtf16(utf16_data_out.get(), utf8_data_in);
   int32_t hash_code = ComputeUtf16Hash(utf16_data_out.get(), utf16_length);
   {
diff --git a/src/jni_compiler.cc b/src/jni_compiler.cc
index c277157..79c6714 100644
--- a/src/jni_compiler.cc
+++ b/src/jni_compiler.cc
@@ -387,7 +387,7 @@
   // TODO: this shouldn't be managed by the JniCompiler, we should have a
   // code cache.
   jni_code_.reset(MemMap::Map(kPageSize, PROT_READ | PROT_WRITE | PROT_EXEC));
-  CHECK(jni_code_ !=  NULL);
+  CHECK(jni_code_.get() !=  NULL);
   jni_code_top_ = jni_code_->GetAddress();
 }
 
diff --git a/src/jni_compiler.h b/src/jni_compiler.h
index f1bd4e2..a3b2e53 100644
--- a/src/jni_compiler.h
+++ b/src/jni_compiler.h
@@ -3,11 +3,11 @@
 #ifndef ART_SRC_JNI_COMPILER_H_
 #define ART_SRC_JNI_COMPILER_H_
 
+#include "UniquePtr.h"
 #include "calling_convention.h"
 #include "globals.h"
 #include "macros.h"
 #include "mem_map.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
@@ -34,7 +34,7 @@
   void* AllocateCode(size_t size);
 
   // Allocated code
-  scoped_ptr<MemMap> jni_code_;
+  UniquePtr<MemMap> jni_code_;
 
   // Pointer to the free space
   byte* jni_code_top_;
diff --git a/src/jni_compiler_test.cc b/src/jni_compiler_test.cc
index 016a606..296d647 100644
--- a/src/jni_compiler_test.cc
+++ b/src/jni_compiler_test.cc
@@ -1,19 +1,20 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
+#include "jni_compiler.h"
+
 #include <sys/mman.h>
 
+#include "UniquePtr.h"
 #include "assembler.h"
 #include "class_linker.h"
 #include "common_test.h"
 #include "dex_file.h"
+#include "gtest/gtest.h"
 #include "indirect_reference_table.h"
-#include "jni_compiler.h"
 #include "jni_internal.h"
 #include "mem_map.h"
 #include "runtime.h"
-#include "scoped_ptr.h"
 #include "thread.h"
-#include "gtest/gtest.h"
 
 namespace art {
 
@@ -65,7 +66,7 @@
   static jclass jklass_;
   static jobject jobj_;
  protected:
-  scoped_ptr<const DexFile> dex_;
+  UniquePtr<const DexFile> dex_;
   const PathClassLoader* class_loader_;
   Assembler jni_asm;
   JniCompiler jni_compiler;
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 97c4cea..cc1d8db 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -11,13 +11,13 @@
 #include <vector>
 
 #include "ScopedLocalRef.h"
+#include "UniquePtr.h"
 #include "assembler.h"
 #include "class_linker.h"
 #include "jni.h"
 #include "logging.h"
 #include "object.h"
 #include "runtime.h"
-#include "scoped_ptr.h"
 #include "stringpiece.h"
 #include "thread.h"
 
@@ -176,7 +176,7 @@
 
 byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, va_list ap) {
   size_t num_bytes = method->NumArgArrayBytes();
-  scoped_array<byte> arg_array(new byte[num_bytes]);
+  UniquePtr<byte[]> arg_array(new byte[num_bytes]);
   const StringPiece& shorty = method->GetShorty();
   for (int i = 1, offset = 0; i < shorty.size(); ++i) {
     switch (shorty[i]) {
@@ -213,7 +213,7 @@
 
 byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, jvalue* args) {
   size_t num_bytes = method->NumArgArrayBytes();
-  scoped_array<byte> arg_array(new byte[num_bytes]);
+  UniquePtr<byte[]> arg_array(new byte[num_bytes]);
   const StringPiece& shorty = method->GetShorty();
   for (int i = 1, offset = 0; i < shorty.size(); ++i) {
     switch (shorty[i]) {
@@ -280,7 +280,7 @@
                          jmethodID mid, jvalue* args) {
   Object* receiver = Decode<Object*>(ts, obj);
   Method* method = DecodeMethod(ts, mid);
-  scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
+  UniquePtr<byte[]> arg_array(CreateArgArray(ts, method, args));
   return InvokeWithArgArray(ts, receiver, method, arg_array.get());
 }
 
@@ -288,7 +288,7 @@
                          jmethodID mid, va_list args) {
   Object* receiver = Decode<Object*>(ts, obj);
   Method* method = DecodeMethod(ts, mid);
-  scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
+  UniquePtr<byte[]> arg_array(CreateArgArray(ts, method, args));
   return InvokeWithArgArray(ts, receiver, method, arg_array.get());
 }
 
@@ -299,14 +299,14 @@
 JValue InvokeVirtualOrInterfaceWithJValues(ScopedJniThreadState& ts, jobject obj, jmethodID mid, jvalue* args) {
   Object* receiver = Decode<Object*>(ts, obj);
   Method* method = FindVirtualMethod(receiver, DecodeMethod(ts, mid));
-  scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
+  UniquePtr<byte[]> arg_array(CreateArgArray(ts, method, args));
   return InvokeWithArgArray(ts, receiver, method, arg_array.get());
 }
 
 JValue InvokeVirtualOrInterfaceWithVarArgs(ScopedJniThreadState& ts, jobject obj, jmethodID mid, va_list args) {
   Object* receiver = Decode<Object*>(ts, obj);
   Method* method = FindVirtualMethod(receiver, DecodeMethod(ts, mid));
-  scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
+  UniquePtr<byte[]> arg_array(CreateArgArray(ts, method, args));
   return InvokeWithArgArray(ts, receiver, method, arg_array.get());
 }
 
diff --git a/src/jni_internal_test.cc b/src/jni_internal_test.cc
index fa98dd8..1d0f35f 100644
--- a/src/jni_internal_test.cc
+++ b/src/jni_internal_test.cc
@@ -637,7 +637,7 @@
 
 
 TEST_F(JniInternalTest, GetPrimitiveField_SetPrimitiveField) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("AllFields"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("AllFields"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Thread::Current()->SetClassLoaderOverride(class_loader);
 
@@ -666,7 +666,7 @@
 }
 
 TEST_F(JniInternalTest, GetObjectField_SetObjectField) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("AllFields"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("AllFields"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Thread::Current()->SetClassLoaderOverride(class_loader);
 
@@ -828,7 +828,7 @@
 
 #if defined(__arm__)
 TEST_F(JniInternalTest, StaticMainMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("Main"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("Main"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -854,7 +854,7 @@
 }
 
 TEST_F(JniInternalTest, StaticNopMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -879,7 +879,7 @@
 }
 
 TEST_F(JniInternalTest, StaticIdentityByteMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -925,7 +925,7 @@
 }
 
 TEST_F(JniInternalTest, StaticIdentityIntMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -971,7 +971,7 @@
 }
 
 TEST_F(JniInternalTest, StaticIdentityDoubleMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1018,7 +1018,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumIntIntMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1076,7 +1076,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumIntIntIntMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1141,7 +1141,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumIntIntIntIntMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1212,7 +1212,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumIntIntIntIntIntMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1290,7 +1290,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumDoubleDoubleMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1349,7 +1349,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1401,7 +1401,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleDoubleMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
@@ -1458,7 +1458,7 @@
 }
 
 TEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleDoubleDoubleMethod) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("StaticLeafMethods"));
 
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   ASSERT_TRUE(class_loader != NULL);
diff --git a/src/logging_linux.cc b/src/logging_linux.cc
index fc16563..96e7fbf 100644
--- a/src/logging_linux.cc
+++ b/src/logging_linux.cc
@@ -1,16 +1,15 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
-#include "logging.h"
-
-#include "runtime.h"
-#include "scoped_ptr.h"
-#include "stringprintf.h"
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <cstdio>
 #include <cstring>
 #include <iostream>
-#include <sys/types.h>
-#include <unistd.h>
+
+#include "logging.h"
+#include "runtime.h"
+#include "stringprintf.h"
 
 // glibc doesn't expose gettid(2).
 #define __KERNEL__
diff --git a/src/main.cc b/src/main.cc
index 2056b0b..229135c 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,15 +1,17 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
-#include <cstring>
-#include <cstdio>
 #include <signal.h>
+
+#include <algorithm>
+#include <cstdio>
+#include <cstring>
 #include <string>
 
+#include "ScopedLocalRef.h"
+#include "UniquePtr.h"
 #include "jni.h"
 #include "logging.h"
-#include "scoped_ptr.h"
 #include "toStringArray.h"
-#include "ScopedLocalRef.h"
 
 // Determine whether or not the specified method is public.
 static bool IsMethodPublic(JNIEnv* env, jclass clazz, jmethodID method_id) {
@@ -103,7 +105,7 @@
   // We're over-allocating, because this includes the options to the VM
   // plus the options to the program.
   int option_count = argc;
-  scoped_array<JavaVMOption> options(new JavaVMOption[option_count]());
+  UniquePtr<JavaVMOption[]> options(new JavaVMOption[option_count]());
 
   // Copy options over.  Everything up to the name of the class starts
   // with a '-' (the function hook stuff is strictly internal).
diff --git a/src/mark_stack.cc b/src/mark_stack.cc
index 663cdf7..4a9502b 100644
--- a/src/mark_stack.cc
+++ b/src/mark_stack.cc
@@ -4,14 +4,14 @@
 
 #include <sys/mman.h>
 
+#include "UniquePtr.h"
 #include "globals.h"
 #include "logging.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
 MarkStack* MarkStack::Create() {
-  scoped_ptr<MarkStack> mark_stack(new MarkStack());
+  UniquePtr<MarkStack> mark_stack(new MarkStack);
   bool success = mark_stack->Init();
   if (!success) {
     return NULL;
@@ -23,7 +23,7 @@
 bool MarkStack::Init() {
   size_t length = 64 * MB;
   mem_map_.reset(MemMap::Map(length, PROT_READ | PROT_WRITE));
-  if (mem_map_ == NULL) {
+  if (mem_map_.get() == NULL) {
     return false;
   }
   byte* addr = mem_map_->GetAddress();
diff --git a/src/mark_stack.h b/src/mark_stack.h
index 79026cc..f8beaff 100644
--- a/src/mark_stack.h
+++ b/src/mark_stack.h
@@ -3,10 +3,10 @@
 #ifndef ART_SRC_MARK_STACK_H_
 #define ART_SRC_MARK_STACK_H_
 
+#include "UniquePtr.h"
 #include "logging.h"
 #include "macros.h"
 #include "mem_map.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
@@ -44,7 +44,7 @@
   bool Init();
 
   // Memory mapping of the mark stack.
-  scoped_ptr<MemMap> mem_map_;
+  UniquePtr<MemMap> mem_map_;
 
   // Base of the mark stack.
   const Object* const* base_;
diff --git a/src/object.h b/src/object.h
index 2d07bd5..438b587 100644
--- a/src/object.h
+++ b/src/object.h
@@ -3,6 +3,7 @@
 #ifndef ART_SRC_OBJECT_H_
 #define ART_SRC_OBJECT_H_
 
+#include "UniquePtr.h"
 #include "casts.h"
 #include "constants.h"
 #include "globals.h"
@@ -739,7 +740,7 @@
 
  private:
   // Compiled code associated with this method
-  scoped_ptr<MemMap> code_area_;
+  UniquePtr<MemMap> code_area_;
   const void* code_;
   // Instruction set of the compiled code
   InstructionSet code_instruction_set_;
diff --git a/src/object_bitmap.cc b/src/object_bitmap.cc
index 40dd41d..ae67ee5 100644
--- a/src/object_bitmap.cc
+++ b/src/object_bitmap.cc
@@ -16,13 +16,13 @@
 
 #include <sys/mman.h>
 
+#include "UniquePtr.h"
 #include "logging.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
 HeapBitmap* HeapBitmap::Create(byte* base, size_t length) {
-  scoped_ptr<HeapBitmap> bitmap(new HeapBitmap(base, length));
+  UniquePtr<HeapBitmap> bitmap(new HeapBitmap(base, length));
   if (!bitmap->Init(base, length)) {
     return NULL;
   } else {
@@ -37,7 +37,7 @@
   CHECK(base != NULL);
   size_t length = HB_OFFSET_TO_INDEX(max_size) * kWordSize;
   mem_map_.reset(MemMap::Map(length, PROT_READ | PROT_WRITE));
-  if (mem_map_ == NULL) {
+  if (mem_map_.get() == NULL) {
     return false;
   }
   words_ = reinterpret_cast<word*>(mem_map_->GetAddress());
diff --git a/src/object_bitmap.h b/src/object_bitmap.h
index 3cb1aad..fc9a3a8 100644
--- a/src/object_bitmap.h
+++ b/src/object_bitmap.h
@@ -18,10 +18,10 @@
 #include <limits.h>
 #include <stdint.h>
 
+#include "UniquePtr.h"
 #include "globals.h"
 #include "logging.h"
 #include "mem_map.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
@@ -119,7 +119,7 @@
 
   bool Init(const byte* base, size_t length);
 
-  scoped_ptr<MemMap> mem_map_;
+  UniquePtr<MemMap> mem_map_;
 
   word* words_;
 
diff --git a/src/object_test.cc b/src/object_test.cc
index 1967ea7..99567e8 100644
--- a/src/object_test.cc
+++ b/src/object_test.cc
@@ -1,14 +1,15 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
+#include "object.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "UniquePtr.h"
 #include "class_linker.h"
 #include "common_test.h"
 #include "dex_file.h"
 #include "heap.h"
-#include "object.h"
-#include "scoped_ptr.h"
-
-#include <stdint.h>
-#include <stdio.h>
 #include "gtest/gtest.h"
 
 namespace art {
@@ -274,9 +275,9 @@
 TEST_F(ObjectTest, DescriptorCompare) {
   ClassLinker* linker = class_linker_;
 
-  scoped_ptr<const DexFile> proto1_dex_file(OpenTestDexFile("ProtoCompare"));
+  UniquePtr<const DexFile> proto1_dex_file(OpenTestDexFile("ProtoCompare"));
   const PathClassLoader* class_loader_1 = AllocPathClassLoader(proto1_dex_file.get());
-  scoped_ptr<const DexFile> proto2_dex_file(OpenTestDexFile("ProtoCompare2"));
+  UniquePtr<const DexFile> proto2_dex_file(OpenTestDexFile("ProtoCompare2"));
   const PathClassLoader* class_loader_2 = AllocPathClassLoader(proto2_dex_file.get());
 
   Class* klass1 = linker->FindClass("LProtoCompare;", class_loader_1);
@@ -323,7 +324,7 @@
 }
 
 TEST_F(ObjectTest, InstanceOf) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("XandY"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("XandY"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* X = class_linker_->FindClass("LX;", class_loader);
   Class* Y = class_linker_->FindClass("LY;", class_loader);
@@ -350,7 +351,7 @@
 }
 
 TEST_F(ObjectTest, IsAssignableFrom) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("XandY"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("XandY"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* X = class_linker_->FindClass("LX;", class_loader);
   Class* Y = class_linker_->FindClass("LY;", class_loader);
@@ -362,7 +363,7 @@
 }
 
 TEST_F(ObjectTest, IsAssignableFromArray) {
-  scoped_ptr<const DexFile> dex(OpenTestDexFile("XandY"));
+  UniquePtr<const DexFile> dex(OpenTestDexFile("XandY"));
   const PathClassLoader* class_loader = AllocPathClassLoader(dex.get());
   Class* X = class_linker_->FindClass("LX;", class_loader);
   Class* Y = class_linker_->FindClass("LY;", class_loader);
diff --git a/src/runtime.cc b/src/runtime.cc
index e628f2c..50f25fe 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7,14 +7,16 @@
 #include <limits>
 #include <vector>
 
-#include "JniConstants.h"
+#include "UniquePtr.h"
 #include "class_linker.h"
 #include "heap.h"
 #include "jni_internal.h"
-#include "scoped_ptr.h"
 #include "signal_catcher.h"
 #include "thread.h"
 
+// TODO: this drags in cutil/log.h, which conflicts with our logging.h.
+#include "JniConstants.h"
+
 namespace art {
 
 Runtime* Runtime::instance_ = NULL;
@@ -164,7 +166,7 @@
 }
 
 Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, bool ignore_unrecognized) {
-  scoped_ptr<ParsedOptions> parsed(new ParsedOptions());
+  UniquePtr<ParsedOptions> parsed(new ParsedOptions());
   const char* boot_class_path = getenv("BOOTCLASSPATH");
   parsed->boot_image_ = NULL;
 #ifdef NDEBUG
@@ -279,7 +281,7 @@
   if (Runtime::instance_ != NULL) {
     return NULL;
   }
-  scoped_ptr<Runtime> runtime(new Runtime());
+  UniquePtr<Runtime> runtime(new Runtime());
   bool success = runtime->Init(options, ignore_unrecognized);
   if (!success) {
     return NULL;
@@ -303,8 +305,8 @@
 bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
   CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize);
 
-  scoped_ptr<ParsedOptions> options(ParsedOptions::Create(raw_options, ignore_unrecognized));
-  if (options == NULL) {
+  UniquePtr<ParsedOptions> options(ParsedOptions::Create(raw_options, ignore_unrecognized));
+  if (options.get() == NULL) {
     return false;
   }
   vfprintf_ = options->hook_vfprintf_;
diff --git a/src/runtime.h b/src/runtime.h
index eaf8ace..8694b3c 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -14,7 +14,6 @@
 
 #include "globals.h"
 #include "macros.h"
-#include "scoped_ptr.h"
 #include "stringpiece.h"
 #include "unordered_set.h"
 
diff --git a/src/runtime_test.cc b/src/runtime_test.cc
index 59e39d6..65792c9 100644
--- a/src/runtime_test.cc
+++ b/src/runtime_test.cc
@@ -1,6 +1,8 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
 #include "runtime.h"
+
+#include "UniquePtr.h"
 #include "common_test.h"
 
 namespace art {
@@ -29,8 +31,8 @@
   options.push_back(std::make_pair("vfprintf", test_vfprintf));
   options.push_back(std::make_pair("abort", test_abort));
   options.push_back(std::make_pair("exit", test_exit));
-  scoped_ptr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
-  ASSERT_TRUE(parsed != NULL);
+  UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
+  ASSERT_TRUE(parsed.get() != NULL);
 
   EXPECT_EQ(1U, parsed->boot_class_path_.size());  // bootclasspath overrides -Xbootclasspath
   EXPECT_STREQ("boot_image", parsed->boot_image_);
diff --git a/src/scoped_ptr.h b/src/scoped_ptr.h
deleted file mode 100644
index 4d9b9b6..0000000
--- a/src/scoped_ptr.h
+++ /dev/null
@@ -1,377 +0,0 @@
-// Copyright 2010 Google
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef ART_SRC_SCOPED_PTR_H_
-#define ART_SRC_SCOPED_PTR_H_
-
-//  This is an implementation designed to match the anticipated future TR2
-//  implementation of the scoped_ptr class, and its closely-related brethren,
-//  scoped_array, scoped_ptr_malloc, and make_scoped_ptr.
-
-#include "logging.h"
-#include "macros.h"
-
-#include <stdlib.h>
-
-#include <algorithm>
-#include <cstddef>
-
-template <class C> class scoped_ptr;
-template <class C, class Free> class scoped_ptr_malloc;
-template <class C> class scoped_array;
-
-template <class C>
-scoped_ptr<C> make_scoped_ptr(C * param);
-
-// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
-// automatically deletes the pointer it holds (if any).
-// That is, scoped_ptr<T> owns the T object that it points to.
-// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
-//
-// The size of a scoped_ptr is small:
-// sizeof(scoped_ptr<C>) == sizeof(C*)
-template <class C>
-class scoped_ptr {
- public:
-
-  // The element type
-  typedef C element_type;
-
-  // Constructor.  Defaults to intializing with NULL.
-  // There is no way to create an uninitialized scoped_ptr.
-  // The input parameter must be allocated with new.
-  explicit scoped_ptr(C* p = NULL) : ptr_(p) { }
-
-  // Destructor.  If there is a C object, delete it.
-  // We don't need to test ptr_ == NULL because C++ does that for us.
-  ~scoped_ptr() {
-    enum { type_must_be_complete = sizeof(C) };
-    delete ptr_;
-  }
-
-  // Reset.  Deletes the current owned object, if any.
-  // Then takes ownership of a new object, if given.
-  // this->reset(this->get()) works.
-  void reset(C* p = NULL) {
-    if (p != ptr_) {
-      enum { type_must_be_complete = sizeof(C) };
-      delete ptr_;
-      ptr_ = p;
-    }
-  }
-
-  // Accessors to get the owned object.
-  // operator* and operator-> will DCHECK() if there is no current object.
-  C& operator*() const {
-    DCHECK(ptr_ != NULL);
-    return *ptr_;
-  }
-  C* operator->() const  {
-    DCHECK(ptr_ != NULL);
-    return ptr_;
-  }
-  C* get() const { return ptr_; }
-
-  // Comparison operators.
-  // These return whether two scoped_ptr refer to the same object, not just to
-  // two different but equal objects.
-  bool operator==(C* p) const { return ptr_ == p; }
-  bool operator!=(C* p) const { return ptr_ != p; }
-
-  // Swap two scoped pointers.
-  void swap(scoped_ptr& p2) {
-    C* tmp = ptr_;
-    ptr_ = p2.ptr_;
-    p2.ptr_ = tmp;
-  }
-
-  // Release a pointer.
-  // The return value is the current pointer held by this object.
-  // If this object holds a NULL pointer, the return value is NULL.
-  // After this operation, this object will hold a NULL pointer,
-  // and will not own the object any more.
-  C* release() {
-    C* retVal = ptr_;
-    ptr_ = NULL;
-    return retVal;
-  }
-
- private:
-  C* ptr_;
-
-  // friend class that can access copy ctor (although if it actually
-  // calls a copy ctor, there will be a problem) see below
-  friend scoped_ptr<C> make_scoped_ptr<C>(C *p);
-
-  // Forbid comparison of scoped_ptr types.  If C2 != C, it totally doesn't
-  // make sense, and if C2 == C, it still doesn't make sense because you should
-  // never have the same object owned by two different scoped_ptrs.
-  template <class C2> bool operator==(scoped_ptr<C2> const& p2) const;
-  template <class C2> bool operator!=(scoped_ptr<C2> const& p2) const;
-
-  DISALLOW_COPY_AND_ASSIGN(scoped_ptr);
-};
-
-// Free functions
-template <class C>
-void swap(scoped_ptr<C>& p1, scoped_ptr<C>& p2) {
-  p1.swap(p2);
-}
-
-template <class C>
-bool operator==(C* p1, const scoped_ptr<C>& p2) {
-  return p1 == p2.get();
-}
-
-template <class C>
-bool operator!=(C* p1, const scoped_ptr<C>& p2) {
-  return p1 != p2.get();
-}
-
-template <class C>
-scoped_ptr<C> make_scoped_ptr(C *p) {
-  // This does nothing but to return a scoped_ptr of the type that the passed
-  // pointer is of.  (This eliminates the need to specify the name of T when
-  // making a scoped_ptr that is used anonymously/temporarily.)  From an
-  // access control point of view, we construct an unnamed scoped_ptr here
-  // which we return and thus copy-construct.  Hence, we need to have access
-  // to scoped_ptr::scoped_ptr(scoped_ptr const &).  However, it is guaranteed
-  // that we never actually call the copy constructor, which is a good thing
-  // as we would call the temporary's object destructor (and thus delete p)
-  // if we actually did copy some object, here.
-  return scoped_ptr<C>(p);
-}
-
-// scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate
-// with new [] and the destructor deletes objects with delete [].
-//
-// As with scoped_ptr<C>, a scoped_array<C> either points to an object
-// or is NULL.  A scoped_array<C> owns the object that it points to.
-//
-// Size: sizeof(scoped_array<C>) == sizeof(C*)
-template <class C>
-class scoped_array {
- public:
-
-  // The element type
-  typedef C element_type;
-
-  // Constructor.  Defaults to intializing with NULL.
-  // There is no way to create an uninitialized scoped_array.
-  // The input parameter must be allocated with new [].
-  explicit scoped_array(C* p = NULL) : array_(p) { }
-
-  // Destructor.  If there is a C object, delete it.
-  // We don't need to test ptr_ == NULL because C++ does that for us.
-  ~scoped_array() {
-    enum { type_must_be_complete = sizeof(C) };
-    delete[] array_;
-  }
-
-  // Reset.  Deletes the current owned object, if any.
-  // Then takes ownership of a new object, if given.
-  // this->reset(this->get()) works.
-  void reset(C* p = NULL) {
-    if (p != array_) {
-      enum { type_must_be_complete = sizeof(C) };
-      delete[] array_;
-      array_ = p;
-    }
-  }
-
-  // Get one element of the current object.
-  // Will DCHECK() if there is no current object, or index i is negative.
-  C& operator[](std::ptrdiff_t i) const {
-    DCHECK_GE(i, 0);
-    DCHECK(array_ != NULL);
-    return array_[i];
-  }
-
-  // Get a pointer to the zeroth element of the current object.
-  // If there is no current object, return NULL.
-  C* get() const {
-    return array_;
-  }
-
-  // Comparison operators.
-  // These return whether two scoped_array refer to the same object, not just to
-  // two different but equal objects.
-  bool operator==(C* p) const { return array_ == p; }
-  bool operator!=(C* p) const { return array_ != p; }
-
-  // Swap two scoped arrays.
-  void swap(scoped_array& p2) {
-    C* tmp = array_;
-    array_ = p2.array_;
-    p2.array_ = tmp;
-  }
-
-  // Release an array.
-  // The return value is the current pointer held by this object.
-  // If this object holds a NULL pointer, the return value is NULL.
-  // After this operation, this object will hold a NULL pointer,
-  // and will not own the object any more.
-  C* release() {
-    C* retVal = array_;
-    array_ = NULL;
-    return retVal;
-  }
-
- private:
-  C* array_;
-
-  // Forbid comparison of different scoped_array types.
-  template <class C2> bool operator==(scoped_array<C2> const& p2) const;
-  template <class C2> bool operator!=(scoped_array<C2> const& p2) const;
-
-  DISALLOW_COPY_AND_ASSIGN(scoped_array);
-};
-
-// Free functions
-template <class C>
-void swap(scoped_array<C>& p1, scoped_array<C>& p2) {
-  p1.swap(p2);
-}
-
-template <class C>
-bool operator==(C* p1, const scoped_array<C>& p2) {
-  return p1 == p2.get();
-}
-
-template <class C>
-bool operator!=(C* p1, const scoped_array<C>& p2) {
-  return p1 != p2.get();
-}
-
-// This class wraps the c library function free() in a class that can be
-// passed as a template argument to scoped_ptr_malloc below.
-class ScopedPtrMallocFree {
- public:
-  inline void operator()(void* x) const {
-    free(x);
-  }
-};
-
-// scoped_ptr_malloc<> is similar to scoped_ptr<>, but it accepts a
-// second template argument, the functor used to free the object.
-
-template<class C, class FreeProc = ScopedPtrMallocFree>
-class scoped_ptr_malloc {
- public:
-
-  // The element type
-  typedef C element_type;
-
-  // Constructor.  Defaults to intializing with NULL.
-  // There is no way to create an uninitialized scoped_ptr.
-  // The input parameter must be allocated with an allocator that matches the
-  // Free functor.  For the default Free functor, this is malloc, calloc, or
-  // realloc.
-  explicit scoped_ptr_malloc(C* p = NULL): ptr_(p) {}
-
-  // Destructor.  If there is a C object, call the Free functor.
-  ~scoped_ptr_malloc() {
-    free_(ptr_);
-  }
-
-  // Reset.  Calls the Free functor on the current owned object, if any.
-  // Then takes ownership of a new object, if given.
-  // this->reset(this->get()) works.
-  void reset(C* p = NULL) {
-    if (ptr_ != p) {
-      free_(ptr_);
-      ptr_ = p;
-    }
-  }
-
-  // Get the current object.
-  // operator* and operator-> will cause an DCHECK() failure if there is
-  // no current object.
-  C& operator*() const {
-    DCHECK(ptr_ != NULL);
-    return *ptr_;
-  }
-
-  C* operator->() const {
-    DCHECK(ptr_ != NULL);
-    return ptr_;
-  }
-
-  C* get() const {
-    return ptr_;
-  }
-
-  // Comparison operators.
-  // These return whether a scoped_ptr_malloc and a plain pointer refer
-  // to the same object, not just to two different but equal objects.
-  // For compatibility wwith the boost-derived implementation, these
-  // take non-const arguments.
-  bool operator==(C* p) const {
-    return ptr_ == p;
-  }
-
-  bool operator!=(C* p) const {
-    return ptr_ != p;
-  }
-
-  // Swap two scoped pointers.
-  void swap(scoped_ptr_malloc & b) {
-    C* tmp = b.ptr_;
-    b.ptr_ = ptr_;
-    ptr_ = tmp;
-  }
-
-  // Release a pointer.
-  // The return value is the current pointer held by this object.
-  // If this object holds a NULL pointer, the return value is NULL.
-  // After this operation, this object will hold a NULL pointer,
-  // and will not own the object any more.
-  C* release() {
-    C* tmp = ptr_;
-    ptr_ = NULL;
-    return tmp;
-  }
-
- private:
-  C* ptr_;
-
-  // no reason to use these: each scoped_ptr_malloc should have its own object
-  template <class C2, class GP>
-  bool operator==(scoped_ptr_malloc<C2, GP> const& p) const;
-  template <class C2, class GP>
-  bool operator!=(scoped_ptr_malloc<C2, GP> const& p) const;
-
-  static FreeProc const free_;
-
-  DISALLOW_COPY_AND_ASSIGN(scoped_ptr_malloc);
-};
-
-template<class C, class FP>
-FP const scoped_ptr_malloc<C, FP>::free_ = FP();
-
-template<class C, class FP> inline
-void swap(scoped_ptr_malloc<C, FP>& a, scoped_ptr_malloc<C, FP>& b) {
-  a.swap(b);
-}
-
-template<class C, class FP> inline
-bool operator==(C* p, const scoped_ptr_malloc<C, FP>& b) {
-  return p == b.get();
-}
-
-template<class C, class FP> inline
-bool operator!=(C* p, const scoped_ptr_malloc<C, FP>& b) {
-  return p != b.get();
-}
-
-#endif  // ART_SRC_SCOPED_PTR_H_
diff --git a/src/space.cc b/src/space.cc
index c636e38..36eb1f6 100644
--- a/src/space.cc
+++ b/src/space.cc
@@ -4,18 +4,18 @@
 
 #include <sys/mman.h>
 
+#include "UniquePtr.h"
 #include "file.h"
 #include "image.h"
 #include "logging.h"
 #include "mspace.h"
 #include "os.h"
-#include "scoped_ptr.h"
 #include "utils.h"
 
 namespace art {
 
 Space* Space::Create(size_t initial_size, size_t maximum_size, byte* requested_base) {
-  scoped_ptr<Space> space(new Space());
+  UniquePtr<Space> space(new Space());
   bool success = space->Init(initial_size, maximum_size, requested_base);
   if (!success) {
     return NULL;
@@ -26,7 +26,7 @@
 
 Space* Space::Create(const char* image_file_name) {
   CHECK(image_file_name != NULL);
-  scoped_ptr<Space> space(new Space());
+  UniquePtr<Space> space(new Space());
   bool success = space->Init(image_file_name);
   if (!success) {
     return NULL;
@@ -63,8 +63,8 @@
   }
   size_t length = RoundUp(maximum_size, kPageSize);
   int prot = PROT_READ | PROT_WRITE;
-  scoped_ptr<MemMap> mem_map(MemMap::Map(requested_base, length, prot));
-  if (mem_map == NULL) {
+  UniquePtr<MemMap> mem_map(MemMap::Map(requested_base, length, prot));
+  if (mem_map.get() == NULL) {
     return false;
   }
   Init(mem_map.release());
@@ -81,8 +81,8 @@
 
 
 bool Space::Init(const char* image_file_name) {
-  scoped_ptr<File> file(OS::OpenFile(image_file_name, false));
-  if (file == NULL) {
+  UniquePtr<File> file(OS::OpenFile(image_file_name, false));
+  if (file.get() == NULL) {
     return false;
   }
   ImageHeader image_header;
@@ -90,13 +90,10 @@
   if (!success || !image_header.IsValid()) {
     return false;
   }
-  scoped_ptr<MemMap> map(MemMap::Map(image_header.GetBaseAddr(),
-                                     file->Length(),
-                                     PROT_READ | PROT_WRITE,
-                                     MAP_PRIVATE | MAP_FIXED,
-                                     file->Fd(),
-                                     0));
-  if (map == NULL) {
+  UniquePtr<MemMap> map(MemMap::Map(image_header.GetBaseAddr(),
+      file->Length(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED,
+      file->Fd(), 0));
+  if (map.get() == NULL) {
     return false;
   }
   CHECK_EQ(image_header.GetBaseAddr(), map->GetAddress());
diff --git a/src/space.h b/src/space.h
index 24bcefa..1715a87 100644
--- a/src/space.h
+++ b/src/space.h
@@ -3,11 +3,11 @@
 #ifndef ART_SRC_SPACE_H_
 #define ART_SRC_SPACE_H_
 
+#include "UniquePtr.h"
 #include "globals.h"
 #include "image.h"
 #include "macros.h"
 #include "mem_map.h"
-#include "scoped_ptr.h"
 
 namespace art {
 
@@ -88,7 +88,7 @@
   // TODO: have a Space subclass for image Spaces with image_header_
   ImageHeader* image_header_;
 
-  scoped_ptr<MemMap> mem_map_;
+  UniquePtr<MemMap> mem_map_;
 
   byte* base_;
 
diff --git a/src/space_test.cc b/src/space_test.cc
index 7384021..2e6932d 100644
--- a/src/space_test.cc
+++ b/src/space_test.cc
@@ -5,31 +5,31 @@
 #include "gtest/gtest.h"
 
 #include "globals.h"
-#include "scoped_ptr.h"
+#include "UniquePtr.h"
 
 namespace art {
 
 TEST(SpaceTest, Init) {
   {
     // Less than
-    scoped_ptr<Space> space(Space::Create(16 * MB, 32 * MB, NULL));
-    EXPECT_TRUE(space != NULL);
+    UniquePtr<Space> space(Space::Create(16 * MB, 32 * MB, NULL));
+    EXPECT_TRUE(space.get() != NULL);
   }
   {
     // Equal to
-    scoped_ptr<Space> space(Space::Create(16 * MB, 16 * MB, NULL));
-    EXPECT_TRUE(space != NULL);
+    UniquePtr<Space> space(Space::Create(16 * MB, 16 * MB, NULL));
+    EXPECT_TRUE(space.get() != NULL);
   }
   {
     // Greater than
-    scoped_ptr<Space> space(Space::Create(32 * MB, 16 * MB, NULL));
-    EXPECT_TRUE(space == NULL);
+    UniquePtr<Space> space(Space::Create(32 * MB, 16 * MB, NULL));
+    EXPECT_TRUE(space.get() == NULL);
   }
 }
 
 TEST(SpaceTest, AllocAndFree) {
-  scoped_ptr<Space> space(Space::Create(4 * MB, 16 * MB, NULL));
-  ASSERT_TRUE(space != NULL);
+  UniquePtr<Space> space(Space::Create(4 * MB, 16 * MB, NULL));
+  ASSERT_TRUE(space.get() != NULL);
 
   // Succeeds, fits without adjusting the max allowed footprint.
   void* ptr1 = space->AllocWithoutGrowth(1 * MB);
diff --git a/src/utils.cc b/src/utils.cc
index b908c4d..f957580 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -1,6 +1,7 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 // Author: enh@google.com (Elliott Hughes)
 
+#include "UniquePtr.h"
 #include "file.h"
 #include "object.h"
 #include "os.h"
@@ -9,8 +10,8 @@
 namespace art {
 
 std::string ReadFileToString(const char* file_name) {
-  scoped_ptr<File> file(OS::OpenFile(file_name, false));
-  CHECK(file != NULL);
+  UniquePtr<File> file(OS::OpenFile(file_name, false));
+  CHECK(file.get() != NULL);
 
   std::string contents;
   char buf[8 * KB];
diff --git a/src/zip_archive.cc b/src/zip_archive.cc
index cccaf82..8c77391 100644
--- a/src/zip_archive.cc
+++ b/src/zip_archive.cc
@@ -21,6 +21,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "UniquePtr.h"
+
 namespace art {
 
 // Get 2 little-endian bytes.
@@ -160,13 +162,13 @@
 
 static bool InflateToFile(File& out, int in, size_t uncompressed_length, size_t compressed_length) {
   const size_t kBufSize = 32768;
-  scoped_array<uint8_t> read_buf(new uint8_t[kBufSize]);
-  scoped_array<uint8_t> write_buf(new uint8_t[kBufSize]);
-  if (read_buf == NULL || write_buf == NULL) {
+  UniquePtr<uint8_t[]> read_buf(new uint8_t[kBufSize]);
+  UniquePtr<uint8_t[]> write_buf(new uint8_t[kBufSize]);
+  if (read_buf.get() == NULL || write_buf.get() == NULL) {
     return false;
   }
 
-  scoped_ptr<ZStream> zstream(new ZStream(write_buf.get(), kBufSize));
+  UniquePtr<ZStream> zstream(new ZStream(write_buf.get(), kBufSize));
 
   // Use the undocumented "negative window bits" feature to tell zlib
   // that there's no zlib header waiting for it.
@@ -263,8 +265,8 @@
     PLOG(WARNING) << "Unable to open '" << filename << "'";
     return NULL;
   }
-  scoped_ptr<ZipArchive> zip_archive(new ZipArchive(fd));
-  if (zip_archive == NULL) {
+  UniquePtr<ZipArchive> zip_archive(new ZipArchive(fd));
+  if (zip_archive.get() == NULL) {
       return NULL;
   }
   if (!zip_archive->MapCentralDirectory()) {
@@ -327,8 +329,8 @@
       read_amount = file_length;
   }
 
-  scoped_array<uint8_t> scan_buf(new uint8_t[read_amount]);
-  if (scan_buf == NULL) {
+  UniquePtr<uint8_t[]> scan_buf(new uint8_t[read_amount]);
+  if (scan_buf.get() == NULL) {
     return false;
   }
 
@@ -385,7 +387,7 @@
 
   // It all looks good.  Create a mapping for the CD.
   dir_map_.reset(MemMap::Map(dir_size, PROT_READ, MAP_SHARED, fd_, dir_offset));
-  if (dir_map_ == NULL) {
+  if (dir_map_.get() == NULL) {
     return false;
   }
 
diff --git a/src/zip_archive.h b/src/zip_archive.h
index 26cb438..0c9e6c2 100644
--- a/src/zip_archive.h
+++ b/src/zip_archive.h
@@ -17,16 +17,17 @@
 #ifndef ART_SRC_ZIP_ARCHIVE_H_
 #define ART_SRC_ZIP_ARCHIVE_H_
 
-#include <map>
 #include <stdint.h>
 #include <sys/mman.h>
 #include <zlib.h>
 
+#include <map>
+
+#include "UniquePtr.h"
 #include "file.h"
 #include "globals.h"
 #include "logging.h"
 #include "mem_map.h"
-#include "scoped_ptr.h"
 #include "stringpiece.h"
 #include "unordered_map.h"
 
@@ -118,7 +119,7 @@
   int fd_;
   uint16_t num_entries_;
   off_t dir_offset_;
-  scoped_ptr<MemMap> dir_map_;
+  UniquePtr<MemMap> dir_map_;
   typedef std::tr1::unordered_map<StringPiece, const byte*, StringPieceHash> DirEntries;
   DirEntries dir_entries_;
 
diff --git a/src/zip_archive_test.cc b/src/zip_archive_test.cc
index 19f4ee0..e6b4002 100644
--- a/src/zip_archive_test.cc
+++ b/src/zip_archive_test.cc
@@ -1,28 +1,30 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
+#include "zip_archive.h"
+
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include "UniquePtr.h"
 #include "common_test.h"
-#include "os.h"
-#include "zip_archive.h"
 #include "gtest/gtest.h"
+#include "os.h"
 
 namespace art {
 
 class ZipArchiveTest : public CommonTest {};
 
 TEST_F(ZipArchiveTest, FindAndExtract) {
-  scoped_ptr<ZipArchive> zip_archive(ZipArchive::Open(GetLibCoreDexFileName()));
-  ASSERT_TRUE(zip_archive != false);
-  scoped_ptr<ZipEntry> zip_entry(zip_archive->Find("classes.dex"));
-  ASSERT_TRUE(zip_entry != false);
+  UniquePtr<ZipArchive> zip_archive(ZipArchive::Open(GetLibCoreDexFileName()));
+  ASSERT_TRUE(zip_archive.get() != false);
+  UniquePtr<ZipEntry> zip_entry(zip_archive->Find("classes.dex"));
+  ASSERT_TRUE(zip_entry.get() != false);
 
   ScratchFile tmp;
   ASSERT_NE(-1, tmp.GetFd());
-  scoped_ptr<File> file(OS::FileFromFd(tmp.GetFilename(), tmp.GetFd()));
-  ASSERT_TRUE(file != NULL);
+  UniquePtr<File> file(OS::FileFromFd(tmp.GetFilename(), tmp.GetFd()));
+  ASSERT_TRUE(file.get() != NULL);
   bool success = zip_entry->Extract(*file);
   ASSERT_TRUE(success);
   close(tmp.GetFd());