Remove FieldHelper.
Change-Id: I2d74e2d5b3c35a691c95339de0db9361847fca11
diff --git a/runtime/mirror/art_field-inl.h b/runtime/mirror/art_field-inl.h
index 03425cc..2b406bd 100644
--- a/runtime/mirror/art_field-inl.h
+++ b/runtime/mirror/art_field-inl.h
@@ -20,6 +20,7 @@
#include "art_field.h"
#include "base/logging.h"
+#include "class_linker.h"
#include "dex_cache.h"
#include "gc/accounting/card_table-inl.h"
#include "jvalue.h"
@@ -289,6 +290,22 @@
return GetTypeAsPrimitiveType() != Primitive::kPrimNot;
}
+inline Class* ArtField::GetType(bool resolve) {
+ uint32_t field_index = GetDexFieldIndex();
+ if (UNLIKELY(GetDeclaringClass()->IsProxyClass())) {
+ return Runtime::Current()->GetClassLinker()->FindSystemClass(Thread::Current(),
+ GetTypeDescriptor());
+ }
+ const DexFile* dex_file = GetDexFile();
+ const DexFile::FieldId& field_id = dex_file->GetFieldId(field_index);
+ mirror::Class* type = GetDexCache()->GetResolvedType(field_id.type_idx_);
+ if (resolve && (type == nullptr)) {
+ type = Runtime::Current()->GetClassLinker()->ResolveType(field_id.type_idx_, this);
+ CHECK(type != nullptr || Thread::Current()->IsExceptionPending());
+ }
+ return type;
+}
+
inline size_t ArtField::FieldSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
return Primitive::ComponentSize(GetTypeAsPrimitiveType());
}
diff --git a/runtime/mirror/art_field.h b/runtime/mirror/art_field.h
index 50299b6..a1d8844 100644
--- a/runtime/mirror/art_field.h
+++ b/runtime/mirror/art_field.h
@@ -161,6 +161,8 @@
bool IsPrimitiveType() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ Class* GetType(bool resolve) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
size_t FieldSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index fa1f226..65d6ade 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -24,7 +24,6 @@
#include "class.h"
#include "class-inl.h"
#include "class_linker-inl.h"
-#include "field_helper.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/heap.h"
#include "iftable-inl.h"
@@ -202,12 +201,16 @@
if (fields != NULL) {
size_t num_ifields = fields->GetLength();
for (size_t i = 0; i < num_ifields; ++i) {
+ StackHandleScope<1> hs(Thread::Current());
+ Handle<Object> h_object(hs.NewHandle(new_value));
ArtField* field = fields->Get(i);
if (field->GetOffset().Int32Value() == field_offset.Int32Value()) {
CHECK_NE(field->GetTypeAsPrimitiveType(), Primitive::kPrimNot);
- StackHandleScope<1> hs(Thread::Current());
- FieldHelper fh(hs.NewHandle(field));
- CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass()));
+ // TODO: resolve the field type for moving GC.
+ mirror::Class* field_type = field->GetType(!kMovingCollector);
+ if (field_type != nullptr) {
+ CHECK(field_type->IsAssignableFrom(new_value->GetClass()));
+ }
return;
}
}
@@ -225,9 +228,11 @@
ArtField* field = fields->Get(i);
if (field->GetOffset().Int32Value() == field_offset.Int32Value()) {
CHECK_NE(field->GetTypeAsPrimitiveType(), Primitive::kPrimNot);
- StackHandleScope<1> hs(Thread::Current());
- FieldHelper fh(hs.NewHandle(field));
- CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass()));
+ // TODO: resolve the field type for moving GC.
+ mirror::Class* field_type = field->GetType(!kMovingCollector);
+ if (field_type != nullptr) {
+ CHECK(field_type->IsAssignableFrom(new_value->GetClass()));
+ }
return;
}
}
@@ -235,6 +240,7 @@
}
LOG(FATAL) << "Failed to find field for assignment to " << reinterpret_cast<void*>(this)
<< " of type " << PrettyDescriptor(c) << " at offset " << field_offset;
+ UNREACHABLE();
}
} // namespace mirror