JDWP: fix java.lang.String creation
Bug: 25439464
Change-Id: I56f11ed942585e8110dbbba1178cf11ec76e032f
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 7117be9..e523fbb 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -1231,7 +1231,15 @@
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();