Fix java_lang_Class newInstance for strings; also quick entrypoints.
Change-Id: I35fd23c5a9051e1ffda0ecc2cbafb5d318c7b5e6
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index c4aecb1..a779e97 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -487,6 +487,17 @@
PrettyClass(klass.Get()).c_str());
return nullptr;
}
+ // Invoke the string allocator to return an empty string for the string class.
+ if (klass->IsStringClass()) {
+ gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
+ mirror::SetStringCountVisitor visitor(0);
+ mirror::Object* obj = mirror::String::Alloc<true>(soa.Self(), 0, allocator_type, visitor);
+ if (UNLIKELY(soa.Self()->IsExceptionPending())) {
+ return nullptr;
+ } else {
+ return soa.AddLocalReference<jobject>(obj);
+ }
+ }
auto receiver = hs.NewHandle(klass->AllocObject(soa.Self()));
if (UNLIKELY(receiver.Get() == nullptr)) {
soa.Self()->AssertPendingOOMException();