diff options
author | Jeff Hao <jeffhao@google.com> | 2015-04-27 20:54:07 -0700 |
---|---|---|
committer | Jeff Hao <jeffhao@google.com> | 2015-04-27 20:55:25 -0700 |
commit | 69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9 (patch) | |
tree | 60b122ece08b503b9f1d020306ab4151d4680ae6 /runtime/native | |
parent | f0a3d3dad248ad0dcb7cfc6addcc66d8bd117e48 (diff) | |
download | art-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.zip art-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.tar.gz art-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.tar.bz2 |
Fix java_lang_Class newInstance for strings; also quick entrypoints.
Change-Id: I35fd23c5a9051e1ffda0ecc2cbafb5d318c7b5e6
Diffstat (limited to 'runtime/native')
-rw-r--r-- | runtime/native/java_lang_Class.cc | 11 |
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(); |