Get DCHECK back to EncodedStaticFieldValueIterator
This is a follow-up of
https://android-review.googlesource.com/#/c/185000/
Change-Id: Ia7311ab948712324f92814e4d415a0a78d16bb84
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 4e15e80..b1a0538 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -2210,22 +2210,47 @@
EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(
const DexFile& dex_file,
const DexFile::ClassDef& class_def)
- : EncodedStaticFieldValueIterator(dex_file, nullptr, nullptr,
- nullptr, class_def) {
+ : EncodedStaticFieldValueIterator(dex_file,
+ nullptr,
+ nullptr,
+ nullptr,
+ class_def,
+ -1,
+ kByte) {
}
EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(
- const DexFile& dex_file, Handle<mirror::DexCache>* dex_cache,
- Handle<mirror::ClassLoader>* class_loader, ClassLinker* linker,
+ const DexFile& dex_file,
+ Handle<mirror::DexCache>* dex_cache,
+ Handle<mirror::ClassLoader>* class_loader,
+ ClassLinker* linker,
const DexFile::ClassDef& class_def)
+ : EncodedStaticFieldValueIterator(dex_file,
+ dex_cache, class_loader,
+ linker,
+ class_def,
+ -1,
+ kByte) {
+ DCHECK(dex_cache_ != nullptr);
+ DCHECK(class_loader_ != nullptr);
+}
+
+EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(
+ const DexFile& dex_file,
+ Handle<mirror::DexCache>* dex_cache,
+ Handle<mirror::ClassLoader>* class_loader,
+ ClassLinker* linker,
+ const DexFile::ClassDef& class_def,
+ size_t pos,
+ ValueType type)
: dex_file_(dex_file),
dex_cache_(dex_cache),
class_loader_(class_loader),
linker_(linker),
array_size_(),
- pos_(-1),
- type_(kByte) {
- ptr_ = dex_file_.GetEncodedStaticFieldValuesArray(class_def);
+ pos_(pos),
+ type_(type) {
+ ptr_ = dex_file.GetEncodedStaticFieldValuesArray(class_def);
if (ptr_ == nullptr) {
array_size_ = 0;
} else {
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 6b019f1..ed1597b 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -1516,9 +1516,11 @@
const DexFile::ClassDef& class_def);
// A constructor meant to be called from runtime code.
- EncodedStaticFieldValueIterator(const DexFile& dex_file, Handle<mirror::DexCache>* dex_cache,
+ EncodedStaticFieldValueIterator(const DexFile& dex_file,
+ Handle<mirror::DexCache>* dex_cache,
Handle<mirror::ClassLoader>* class_loader,
- ClassLinker* linker, const DexFile::ClassDef& class_def)
+ ClassLinker* linker,
+ const DexFile::ClassDef& class_def)
SHARED_REQUIRES(Locks::mutator_lock_);
template<bool kTransactionActive>
@@ -1551,6 +1553,14 @@
const jvalue& GetJavaValue() const { return jval_; }
private:
+ EncodedStaticFieldValueIterator(const DexFile& dex_file,
+ Handle<mirror::DexCache>* dex_cache,
+ Handle<mirror::ClassLoader>* class_loader,
+ ClassLinker* linker,
+ const DexFile::ClassDef& class_def,
+ size_t pos,
+ ValueType type);
+
static constexpr uint8_t kEncodedValueTypeMask = 0x1f; // 0b11111
static constexpr uint8_t kEncodedValueArgShift = 5;