OSDN Git Service

JDWP: fix java.lang.String creation
authorSebastien Hertz <shertz@google.com>
Tue, 3 Nov 2015 16:38:35 +0000 (17:38 +0100)
committerSebastien Hertz <shertz@google.com>
Tue, 3 Nov 2015 16:38:35 +0000 (17:38 +0100)
Bug: 25439464
Change-Id: I56f11ed942585e8110dbbba1178cf11ec76e032f

runtime/debugger.cc

index 7117be9..e523fbb 100644 (file)
@@ -1231,7 +1231,15 @@ JDWP::JdwpError Dbg::CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_
     return error;
   }
   Thread* self = Thread::Current();
-  mirror::Object* new_object = c->AllocObject(self);
+  mirror::Object* new_object;
+  if (c->IsStringClass()) {
+    // Special case for java.lang.String.
+    gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
+    mirror::SetStringCountVisitor visitor(0);
+    new_object = mirror::String::Alloc<true>(self, 0, allocator_type, visitor);
+  } else {
+    new_object = c->AllocObject(self);
+  }
   if (new_object == nullptr) {
     DCHECK(self->IsExceptionPending());
     self->ClearException();