summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Hao <jeffhao@google.com>2015-04-27 20:54:07 -0700
committerJeff Hao <jeffhao@google.com>2015-04-27 20:55:25 -0700
commit69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9 (patch)
tree60b122ece08b503b9f1d020306ab4151d4680ae6
parentf0a3d3dad248ad0dcb7cfc6addcc66d8bd117e48 (diff)
downloadart-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.zip
art-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.tar.gz
art-69bdcb29fdbd8266374e3793cb4e28dcc5daf0f9.tar.bz2
Fix java_lang_Class newInstance for strings; also quick entrypoints.
Change-Id: I35fd23c5a9051e1ffda0ecc2cbafb5d318c7b5e6
-rw-r--r--runtime/arch/quick_alloc_entrypoints.S6
-rw-r--r--runtime/native/java_lang_Class.cc11
2 files changed, 14 insertions, 3 deletions
diff --git a/runtime/arch/quick_alloc_entrypoints.S b/runtime/arch/quick_alloc_entrypoints.S
index eaee19b..fe04bf5 100644
--- a/runtime/arch/quick_alloc_entrypoints.S
+++ b/runtime/arch/quick_alloc_entrypoints.S
@@ -36,11 +36,11 @@ THREE_ARG_DOWNCALL art_quick_check_and_alloc_array\c_suffix, artCheckAndAllocArr
// Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_with_access_check\c_suffix, artCheckAndAllocArrayFromCodeWithAccessCheck\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
// Called by managed code to allocate a string from bytes
-FOUR_ARG_DOWNCALL art_quick_alloc_string_from_bytes\c_suffix, artAllocStringFromBytesFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO
+FOUR_ARG_DOWNCALL art_quick_alloc_string_from_bytes\c_suffix, artAllocStringFromBytesFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
// Called by managed code to allocate a string from chars
-THREE_ARG_DOWNCALL art_quick_alloc_string_from_chars\c_suffix, artAllocStringFromCharsFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO
+THREE_ARG_DOWNCALL art_quick_alloc_string_from_chars\c_suffix, artAllocStringFromCharsFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
// Called by managed code to allocate a string from string
-ONE_ARG_DOWNCALL art_quick_alloc_string_from_string\c_suffix, artAllocStringFromStringFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO
+ONE_ARG_DOWNCALL art_quick_alloc_string_from_string\c_suffix, artAllocStringFromStringFromCode\cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
.endm
.macro GENERATE_ALL_ALLOC_ENTRYPOINTS
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();