Inherit java.lang.ref-ness from superclasses.

Otherwise the GC doesn't know to treat you specially.

Also sweep system weaks. (Though sweeping the monitors is still unimplemented.)

Change-Id: Ia89b58fd36dfd5c6c7dca70d432ddc838ca37ac5
diff --git a/src/class_linker.cc b/src/class_linker.cc
index f6cf291..b6d2357 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1927,6 +1927,12 @@
     klass->SetFinalizable();
   }
 
+  // Inherit reference flags (if any) from the superclass.
+  int reference_flags = (super->GetAccessFlags() & kAccReferenceFlagsMask);
+  if (reference_flags != 0) {
+    klass->SetAccessFlags(klass->GetAccessFlags() | reference_flags);
+  }
+
 #ifndef NDEBUG
   // Ensure super classes are fully resolved prior to resolving fields..
   while (super != NULL) {
diff --git a/src/heap.cc b/src/heap.cc
index 65bc4c0..3f42c6b 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -478,7 +478,8 @@
 
     mark_sweep.ProcessReferences(false);
 
-    // TODO: swap bitmaps
+    // TODO: if concurrent
+    //    swap bitmaps
 
     mark_sweep.Sweep();
 
diff --git a/src/mark_sweep.cc b/src/mark_sweep.cc
index ae6edea..05f229d 100644
--- a/src/mark_sweep.cc
+++ b/src/mark_sweep.cc
@@ -136,7 +136,7 @@
 };
 
 void MarkSweep::SweepMonitorList() {
-  UNIMPLEMENTED(FATAL);
+  UNIMPLEMENTED(WARNING);
   //dvmSweepMonitorList(&gDvm.monitorList, isUnmarkedObject);
 }
 
@@ -158,6 +158,8 @@
 }
 
 void MarkSweep::Sweep() {
+  SweepSystemWeaks();
+
   const std::vector<Space*>& spaces = Heap::GetSpaces();
   for (size_t i = 0; i < spaces.size(); ++i) {
     if (spaces[i]->IsCondemned()) {
@@ -175,9 +177,7 @@
   DCHECK(obj != NULL);
   Class* klass = obj->GetClass();
   DCHECK(klass != NULL);
-  ScanFields(obj,
-             klass->GetReferenceInstanceOffsets(),
-             false);
+  ScanFields(obj, klass->GetReferenceInstanceOffsets(), false);
 }
 
 // Scans static storage on a Class.
@@ -186,9 +186,7 @@
   ScanFields(klass, klass->GetReferenceStaticOffsets(), true);
 }
 
-void MarkSweep::ScanFields(const Object* obj,
-                           uint32_t ref_offsets,
-                           bool is_static) {
+void MarkSweep::ScanFields(const Object* obj, uint32_t ref_offsets, bool is_static) {
   if (ref_offsets != CLASS_WALK_SUPER) {
     // Found a reference offset bitmap.  Mark the specified offsets.
     while (ref_offsets != 0) {