summaryrefslogtreecommitdiffstats
path: root/runtime/native
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/native')
-rw-r--r--runtime/native/java_lang_Class.cc11
1 files changed, 11 insertions, 0 deletions
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 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) {
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();