OSDN Git Service

Get DCHECK back to EncodedStaticFieldValueIterator
authorShinichiro Hamaji <hamaji@google.com>
Fri, 11 Dec 2015 00:45:28 +0000 (09:45 +0900)
committerShinichiro Hamaji <hamaji@google.com>
Mon, 14 Dec 2015 06:43:49 +0000 (15:43 +0900)
This is a follow-up of
https://android-review.googlesource.com/#/c/185000/

Change-Id: Ia7311ab948712324f92814e4d415a0a78d16bb84

runtime/dex_file.cc
runtime/dex_file.h

index 4e15e80..b1a0538 100644 (file)
@@ -2210,22 +2210,47 @@ void ClassDataItemIterator::ReadClassDataMethod() {
 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 {
index 6b019f1..ed1597b 100644 (file)
@@ -1516,9 +1516,11 @@ class EncodedStaticFieldValueIterator {
                                   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 @@ class EncodedStaticFieldValueIterator {
   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;