From f832284dd847ff077577bb5712225430bbbb3b67 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 16 May 2014 10:59:25 -0700 Subject: Delete ClassHelper and fix compaction bug in GetDirectInterface Cleanup helps to prevent compaction bugs. Fixed a fairly serious compaction error caused by calling ClassHelper::GetDirectInterface without handling the case where it causes thread suspension due to ResolveType. Bug: 8981901 Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408 --- runtime/native/dalvik_system_VMRuntime.cc | 8 +++++--- runtime/native/java_lang_Class.cc | 5 +++-- runtime/native/java_lang_reflect_Array.cc | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'runtime/native') diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index 8d183da..69b05f4 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -262,12 +262,14 @@ static void PreloadDexCachesResolveField(Handle& dex_cache, } const DexFile* dex_file = dex_cache->GetDexFile(); const DexFile::FieldId& field_id = dex_file->GetFieldId(field_idx); - mirror::Class* klass = dex_cache->GetResolvedType(field_id.class_idx_); - if (klass == NULL) { + Thread* const self = Thread::Current(); + StackHandleScope<1> hs(self); + Handle klass(hs.NewHandle(dex_cache->GetResolvedType(field_id.class_idx_))); + if (klass.Get() == NULL) { return; } if (is_static) { - field = klass->FindStaticField(dex_cache.Get(), field_idx); + field = mirror::Class::FindStaticField(self, klass, dex_cache.Get(), field_idx); } else { field = klass->FindInstanceField(dex_cache.Get(), field_idx); } diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index b6cf7d8..e619dda 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -84,8 +84,9 @@ static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean static jstring Class_getNameNative(JNIEnv* env, jobject javaThis) { ScopedFastNativeObjectAccess soa(env); - mirror::Class* c = DecodeClass(soa, javaThis); - return soa.AddLocalReference(c->ComputeName()); + StackHandleScope<1> hs(soa.Self()); + mirror::Class* const c = DecodeClass(soa, javaThis); + return soa.AddLocalReference(mirror::Class::ComputeName(hs.NewHandle(c))); } static jobjectArray Class_getProxyInterfaces(JNIEnv* env, jobject javaThis) { diff --git a/runtime/native/java_lang_reflect_Array.cc b/runtime/native/java_lang_reflect_Array.cc index 7c6f2f3..db77437 100644 --- a/runtime/native/java_lang_reflect_Array.cc +++ b/runtime/native/java_lang_reflect_Array.cc @@ -35,7 +35,7 @@ static jobject Array_createMultiArray(JNIEnv* env, jclass, jclass javaElementCla DCHECK(javaDimArray != NULL); mirror::Object* dimensions_obj = soa.Decode(javaDimArray); DCHECK(dimensions_obj->IsArrayInstance()); - DCHECK_STREQ(ClassHelper(dimensions_obj->GetClass()).GetDescriptor(), "[I"); + DCHECK_STREQ(dimensions_obj->GetClass()->GetDescriptor().c_str(), "[I"); Handle dimensions_array( hs.NewHandle(down_cast(dimensions_obj))); mirror::Array* new_array = mirror::Array::CreateMultiArray(soa.Self(), element_class, -- cgit v1.1