dex_file.h revision 66d1caf42c20efba8305efb3a819993126e8abbf
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_DEX_FILE_H_
18#define ART_RUNTIME_DEX_FILE_H_
19
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "base/logging.h"
25#include "base/mutex.h"  // For Locks::mutator_lock_.
26#include "globals.h"
27#include "invoke_type.h"
28#include "jni.h"
29#include "modifiers.h"
30#include "safe_map.h"
31
32namespace art {
33
34// TODO: remove dependencies on mirror classes, primarily by moving
35// EncodedStaticFieldValueIterator to its own file.
36namespace mirror {
37  class ArtField;
38  class ArtMethod;
39  class ClassLoader;
40  class DexCache;
41}  // namespace mirror
42class ClassLinker;
43class MemMap;
44class Signature;
45template<class T> class Handle;
46class StringPiece;
47class ZipArchive;
48
49// TODO: move all of the macro functionality into the DexCache class.
50class DexFile {
51 public:
52  static const byte kDexMagic[];
53  static const byte kDexMagicVersion[];
54  static const size_t kSha1DigestSize = 20;
55  static const uint32_t kDexEndianConstant = 0x12345678;
56
57  // name of the DexFile entry within a zip archive
58  static const char* kClassesDex;
59
60  // The value of an invalid index.
61  static const uint32_t kDexNoIndex = 0xFFFFFFFF;
62
63  // The value of an invalid index.
64  static const uint16_t kDexNoIndex16 = 0xFFFF;
65
66  // The separator charactor in MultiDex locations.
67  static constexpr char kMultiDexSeparator = ':';
68
69  // A string version of the previous. This is a define so that we can merge string literals in the
70  // preprocessor.
71  #define kMultiDexSeparatorString ":"
72
73  // Raw header_item.
74  struct Header {
75    uint8_t magic_[8];
76    uint32_t checksum_;  // See also location_checksum_
77    uint8_t signature_[kSha1DigestSize];
78    uint32_t file_size_;  // size of entire file
79    uint32_t header_size_;  // offset to start of next section
80    uint32_t endian_tag_;
81    uint32_t link_size_;  // unused
82    uint32_t link_off_;  // unused
83    uint32_t map_off_;  // unused
84    uint32_t string_ids_size_;  // number of StringIds
85    uint32_t string_ids_off_;  // file offset of StringIds array
86    uint32_t type_ids_size_;  // number of TypeIds, we don't support more than 65535
87    uint32_t type_ids_off_;  // file offset of TypeIds array
88    uint32_t proto_ids_size_;  // number of ProtoIds, we don't support more than 65535
89    uint32_t proto_ids_off_;  // file offset of ProtoIds array
90    uint32_t field_ids_size_;  // number of FieldIds
91    uint32_t field_ids_off_;  // file offset of FieldIds array
92    uint32_t method_ids_size_;  // number of MethodIds
93    uint32_t method_ids_off_;  // file offset of MethodIds array
94    uint32_t class_defs_size_;  // number of ClassDefs
95    uint32_t class_defs_off_;  // file offset of ClassDef array
96    uint32_t data_size_;  // unused
97    uint32_t data_off_;  // unused
98
99   private:
100    DISALLOW_COPY_AND_ASSIGN(Header);
101  };
102
103  // Map item type codes.
104  enum {
105    kDexTypeHeaderItem               = 0x0000,
106    kDexTypeStringIdItem             = 0x0001,
107    kDexTypeTypeIdItem               = 0x0002,
108    kDexTypeProtoIdItem              = 0x0003,
109    kDexTypeFieldIdItem              = 0x0004,
110    kDexTypeMethodIdItem             = 0x0005,
111    kDexTypeClassDefItem             = 0x0006,
112    kDexTypeMapList                  = 0x1000,
113    kDexTypeTypeList                 = 0x1001,
114    kDexTypeAnnotationSetRefList     = 0x1002,
115    kDexTypeAnnotationSetItem        = 0x1003,
116    kDexTypeClassDataItem            = 0x2000,
117    kDexTypeCodeItem                 = 0x2001,
118    kDexTypeStringDataItem           = 0x2002,
119    kDexTypeDebugInfoItem            = 0x2003,
120    kDexTypeAnnotationItem           = 0x2004,
121    kDexTypeEncodedArrayItem         = 0x2005,
122    kDexTypeAnnotationsDirectoryItem = 0x2006,
123  };
124
125  struct MapItem {
126    uint16_t type_;
127    uint16_t unused_;
128    uint32_t size_;
129    uint32_t offset_;
130
131   private:
132    DISALLOW_COPY_AND_ASSIGN(MapItem);
133  };
134
135  struct MapList {
136    uint32_t size_;
137    MapItem list_[1];
138
139   private:
140    DISALLOW_COPY_AND_ASSIGN(MapList);
141  };
142
143  // Raw string_id_item.
144  struct StringId {
145    uint32_t string_data_off_;  // offset in bytes from the base address
146
147   private:
148    DISALLOW_COPY_AND_ASSIGN(StringId);
149  };
150
151  // Raw type_id_item.
152  struct TypeId {
153    uint32_t descriptor_idx_;  // index into string_ids
154
155   private:
156    DISALLOW_COPY_AND_ASSIGN(TypeId);
157  };
158
159  // Raw field_id_item.
160  struct FieldId {
161    uint16_t class_idx_;  // index into type_ids_ array for defining class
162    uint16_t type_idx_;  // index into type_ids_ array for field type
163    uint32_t name_idx_;  // index into string_ids_ array for field name
164
165   private:
166    DISALLOW_COPY_AND_ASSIGN(FieldId);
167  };
168
169  // Raw method_id_item.
170  struct MethodId {
171    uint16_t class_idx_;  // index into type_ids_ array for defining class
172    uint16_t proto_idx_;  // index into proto_ids_ array for method prototype
173    uint32_t name_idx_;  // index into string_ids_ array for method name
174
175   private:
176    DISALLOW_COPY_AND_ASSIGN(MethodId);
177  };
178
179  // Raw proto_id_item.
180  struct ProtoId {
181    uint32_t shorty_idx_;  // index into string_ids array for shorty descriptor
182    uint16_t return_type_idx_;  // index into type_ids array for return type
183    uint16_t pad_;             // padding = 0
184    uint32_t parameters_off_;  // file offset to type_list for parameter types
185
186   private:
187    DISALLOW_COPY_AND_ASSIGN(ProtoId);
188  };
189
190  // Raw class_def_item.
191  struct ClassDef {
192    uint16_t class_idx_;  // index into type_ids_ array for this class
193    uint16_t pad1_;  // padding = 0
194    uint32_t access_flags_;
195    uint16_t superclass_idx_;  // index into type_ids_ array for superclass
196    uint16_t pad2_;  // padding = 0
197    uint32_t interfaces_off_;  // file offset to TypeList
198    uint32_t source_file_idx_;  // index into string_ids_ for source file name
199    uint32_t annotations_off_;  // file offset to annotations_directory_item
200    uint32_t class_data_off_;  // file offset to class_data_item
201    uint32_t static_values_off_;  // file offset to EncodedArray
202
203   private:
204    DISALLOW_COPY_AND_ASSIGN(ClassDef);
205  };
206
207  // Raw type_item.
208  struct TypeItem {
209    uint16_t type_idx_;  // index into type_ids section
210
211   private:
212    DISALLOW_COPY_AND_ASSIGN(TypeItem);
213  };
214
215  // Raw type_list.
216  class TypeList {
217   public:
218    uint32_t Size() const {
219      return size_;
220    }
221
222    const TypeItem& GetTypeItem(uint32_t idx) const {
223      DCHECK_LT(idx, this->size_);
224      return this->list_[idx];
225    }
226
227   private:
228    uint32_t size_;  // size of the list, in entries
229    TypeItem list_[1];  // elements of the list
230    DISALLOW_COPY_AND_ASSIGN(TypeList);
231  };
232
233  // Raw code_item.
234  struct CodeItem {
235    uint16_t registers_size_;
236    uint16_t ins_size_;
237    uint16_t outs_size_;
238    uint16_t tries_size_;
239    uint32_t debug_info_off_;  // file offset to debug info stream
240    uint32_t insns_size_in_code_units_;  // size of the insns array, in 2 byte code units
241    uint16_t insns_[1];
242
243   private:
244    DISALLOW_COPY_AND_ASSIGN(CodeItem);
245  };
246
247  // Raw try_item.
248  struct TryItem {
249    uint32_t start_addr_;
250    uint16_t insn_count_;
251    uint16_t handler_off_;
252
253   private:
254    DISALLOW_COPY_AND_ASSIGN(TryItem);
255  };
256
257  // Annotation constants.
258  enum {
259    kDexVisibilityBuild         = 0x00,     /* annotation visibility */
260    kDexVisibilityRuntime       = 0x01,
261    kDexVisibilitySystem        = 0x02,
262
263    kDexAnnotationByte          = 0x00,
264    kDexAnnotationShort         = 0x02,
265    kDexAnnotationChar          = 0x03,
266    kDexAnnotationInt           = 0x04,
267    kDexAnnotationLong          = 0x06,
268    kDexAnnotationFloat         = 0x10,
269    kDexAnnotationDouble        = 0x11,
270    kDexAnnotationString        = 0x17,
271    kDexAnnotationType          = 0x18,
272    kDexAnnotationField         = 0x19,
273    kDexAnnotationMethod        = 0x1a,
274    kDexAnnotationEnum          = 0x1b,
275    kDexAnnotationArray         = 0x1c,
276    kDexAnnotationAnnotation    = 0x1d,
277    kDexAnnotationNull          = 0x1e,
278    kDexAnnotationBoolean       = 0x1f,
279
280    kDexAnnotationValueTypeMask = 0x1f,     /* low 5 bits */
281    kDexAnnotationValueArgShift = 5,
282  };
283
284  struct AnnotationsDirectoryItem {
285    uint32_t class_annotations_off_;
286    uint32_t fields_size_;
287    uint32_t methods_size_;
288    uint32_t parameters_size_;
289
290   private:
291    DISALLOW_COPY_AND_ASSIGN(AnnotationsDirectoryItem);
292  };
293
294  struct FieldAnnotationsItem {
295    uint32_t field_idx_;
296    uint32_t annotations_off_;
297
298   private:
299    DISALLOW_COPY_AND_ASSIGN(FieldAnnotationsItem);
300  };
301
302  struct MethodAnnotationsItem {
303    uint32_t method_idx_;
304    uint32_t annotations_off_;
305
306   private:
307    DISALLOW_COPY_AND_ASSIGN(MethodAnnotationsItem);
308  };
309
310  struct ParameterAnnotationsItem {
311    uint32_t method_idx_;
312    uint32_t annotations_off_;
313
314   private:
315    DISALLOW_COPY_AND_ASSIGN(ParameterAnnotationsItem);
316  };
317
318  struct AnnotationSetRefItem {
319    uint32_t annotations_off_;
320
321   private:
322    DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefItem);
323  };
324
325  struct AnnotationSetRefList {
326    uint32_t size_;
327    AnnotationSetRefItem list_[1];
328
329   private:
330    DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefList);
331  };
332
333  struct AnnotationSetItem {
334    uint32_t size_;
335    uint32_t entries_[1];
336
337   private:
338    DISALLOW_COPY_AND_ASSIGN(AnnotationSetItem);
339  };
340
341  struct AnnotationItem {
342    uint8_t visibility_;
343    uint8_t annotation_[1];
344
345   private:
346    DISALLOW_COPY_AND_ASSIGN(AnnotationItem);
347  };
348
349  typedef std::pair<const DexFile*, const DexFile::ClassDef*> ClassPathEntry;
350  typedef std::vector<const DexFile*> ClassPath;
351
352  // Search a collection of DexFiles for a descriptor
353  static ClassPathEntry FindInClassPath(const char* descriptor,
354                                        const ClassPath& class_path);
355
356  // Returns the checksum of a file for comparison with GetLocationChecksum().
357  // For .dex files, this is the header checksum.
358  // For zip files, this is the classes.dex zip entry CRC32 checksum.
359  // Return true if the checksum could be found, false otherwise.
360  static bool GetChecksum(const char* filename, uint32_t* checksum, std::string* error_msg);
361
362  // Opens .dex files found in the container, guessing the container format based on file extension.
363  static bool Open(const char* filename, const char* location, std::string* error_msg,
364                   std::vector<const DexFile*>* dex_files);
365
366  // Opens .dex file, backed by existing memory
367  static const DexFile* Open(const uint8_t* base, size_t size,
368                             const std::string& location,
369                             uint32_t location_checksum,
370                             std::string* error_msg) {
371    return OpenMemory(base, size, location, location_checksum, NULL, error_msg);
372  }
373
374  // Open all classesXXX.dex files from a zip archive.
375  static bool OpenFromZip(const ZipArchive& zip_archive, const std::string& location,
376                          std::string* error_msg, std::vector<const DexFile*>* dex_files);
377
378  // Closes a .dex file.
379  virtual ~DexFile();
380
381  const std::string& GetLocation() const {
382    return location_;
383  }
384
385  // For normal dex files, location and base location coincide. If a dex file is part of a multidex
386  // archive, the base location is the name of the originating jar/apk, stripped of any internal
387  // classes*.dex path.
388  const std::string GetBaseLocation() const {
389    if (IsMultiDexLocation(location_.c_str())) {
390      std::pair<const char*, const char*> pair = SplitMultiDexLocation(location_.c_str());
391      std::string res(pair.first);
392      delete[] pair.first;
393      return res;
394    } else {
395      return location_;
396    }
397  }
398
399  // For DexFiles directly from .dex files, this is the checksum from the DexFile::Header.
400  // For DexFiles opened from a zip files, this will be the ZipEntry CRC32 of classes.dex.
401  uint32_t GetLocationChecksum() const {
402    return location_checksum_;
403  }
404
405  const Header& GetHeader() const {
406    DCHECK(header_ != NULL) << GetLocation();
407    return *header_;
408  }
409
410  // Decode the dex magic version
411  uint32_t GetVersion() const;
412
413  // Returns true if the byte string points to the magic value.
414  static bool IsMagicValid(const byte* magic);
415
416  // Returns true if the byte string after the magic is the correct value.
417  static bool IsVersionValid(const byte* magic);
418
419  // Returns the number of string identifiers in the .dex file.
420  size_t NumStringIds() const {
421    DCHECK(header_ != NULL) << GetLocation();
422    return header_->string_ids_size_;
423  }
424
425  // Returns the StringId at the specified index.
426  const StringId& GetStringId(uint32_t idx) const {
427    DCHECK_LT(idx, NumStringIds()) << GetLocation();
428    return string_ids_[idx];
429  }
430
431  uint32_t GetIndexForStringId(const StringId& string_id) const {
432    CHECK_GE(&string_id, string_ids_) << GetLocation();
433    CHECK_LT(&string_id, string_ids_ + header_->string_ids_size_) << GetLocation();
434    return &string_id - string_ids_;
435  }
436
437  int32_t GetStringLength(const StringId& string_id) const;
438
439  // Returns a pointer to the UTF-8 string data referred to by the given string_id as well as the
440  // length of the string when decoded as a UTF-16 string. Note the UTF-16 length is not the same
441  // as the string length of the string data.
442  const char* GetStringDataAndUtf16Length(const StringId& string_id, uint32_t* utf16_length) const;
443
444  const char* GetStringData(const StringId& string_id) const {
445    uint32_t ignored;
446    return GetStringDataAndUtf16Length(string_id, &ignored);
447  }
448
449  // Index version of GetStringDataAndUtf16Length.
450  const char* StringDataAndUtf16LengthByIdx(uint32_t idx, uint32_t* utf16_length) const {
451    if (idx == kDexNoIndex) {
452      *utf16_length = 0;
453      return NULL;
454    }
455    const StringId& string_id = GetStringId(idx);
456    return GetStringDataAndUtf16Length(string_id, utf16_length);
457  }
458
459  const char* StringDataByIdx(uint32_t idx) const {
460    uint32_t unicode_length;
461    return StringDataAndUtf16LengthByIdx(idx, &unicode_length);
462  }
463
464  // Looks up a string id for a given modified utf8 string.
465  const StringId* FindStringId(const char* string) const;
466
467  // Looks up a string id for a given utf16 string.
468  const StringId* FindStringId(const uint16_t* string) const;
469
470  // Returns the number of type identifiers in the .dex file.
471  size_t NumTypeIds() const {
472    DCHECK(header_ != NULL) << GetLocation();
473    return header_->type_ids_size_;
474  }
475
476  // Returns the TypeId at the specified index.
477  const TypeId& GetTypeId(uint32_t idx) const {
478    DCHECK_LT(idx, NumTypeIds()) << GetLocation();
479    return type_ids_[idx];
480  }
481
482  uint16_t GetIndexForTypeId(const TypeId& type_id) const {
483    CHECK_GE(&type_id, type_ids_) << GetLocation();
484    CHECK_LT(&type_id, type_ids_ + header_->type_ids_size_) << GetLocation();
485    size_t result = &type_id - type_ids_;
486    DCHECK_LT(result, 65536U) << GetLocation();
487    return static_cast<uint16_t>(result);
488  }
489
490  // Get the descriptor string associated with a given type index.
491  const char* StringByTypeIdx(uint32_t idx, uint32_t* unicode_length) const {
492    const TypeId& type_id = GetTypeId(idx);
493    return StringDataAndUtf16LengthByIdx(type_id.descriptor_idx_, unicode_length);
494  }
495
496  const char* StringByTypeIdx(uint32_t idx) const {
497    const TypeId& type_id = GetTypeId(idx);
498    return StringDataByIdx(type_id.descriptor_idx_);
499  }
500
501  // Returns the type descriptor string of a type id.
502  const char* GetTypeDescriptor(const TypeId& type_id) const {
503    return StringDataByIdx(type_id.descriptor_idx_);
504  }
505
506  // Looks up a type for the given string index
507  const TypeId* FindTypeId(uint32_t string_idx) const;
508
509  // Returns the number of field identifiers in the .dex file.
510  size_t NumFieldIds() const {
511    DCHECK(header_ != NULL) << GetLocation();
512    return header_->field_ids_size_;
513  }
514
515  // Returns the FieldId at the specified index.
516  const FieldId& GetFieldId(uint32_t idx) const {
517    DCHECK_LT(idx, NumFieldIds()) << GetLocation();
518    return field_ids_[idx];
519  }
520
521  uint32_t GetIndexForFieldId(const FieldId& field_id) const {
522    CHECK_GE(&field_id, field_ids_) << GetLocation();
523    CHECK_LT(&field_id, field_ids_ + header_->field_ids_size_) << GetLocation();
524    return &field_id - field_ids_;
525  }
526
527  // Looks up a field by its declaring class, name and type
528  const FieldId* FindFieldId(const DexFile::TypeId& declaring_klass,
529                             const DexFile::StringId& name,
530                             const DexFile::TypeId& type) const;
531
532  // Returns the declaring class descriptor string of a field id.
533  const char* GetFieldDeclaringClassDescriptor(const FieldId& field_id) const {
534    const DexFile::TypeId& type_id = GetTypeId(field_id.class_idx_);
535    return GetTypeDescriptor(type_id);
536  }
537
538  // Returns the class descriptor string of a field id.
539  const char* GetFieldTypeDescriptor(const FieldId& field_id) const {
540    const DexFile::TypeId& type_id = GetTypeId(field_id.type_idx_);
541    return GetTypeDescriptor(type_id);
542  }
543
544  // Returns the name of a field id.
545  const char* GetFieldName(const FieldId& field_id) const {
546    return StringDataByIdx(field_id.name_idx_);
547  }
548
549  // Returns the number of method identifiers in the .dex file.
550  size_t NumMethodIds() const {
551    DCHECK(header_ != NULL) << GetLocation();
552    return header_->method_ids_size_;
553  }
554
555  // Returns the MethodId at the specified index.
556  const MethodId& GetMethodId(uint32_t idx) const {
557    DCHECK_LT(idx, NumMethodIds()) << GetLocation();
558    return method_ids_[idx];
559  }
560
561  uint32_t GetIndexForMethodId(const MethodId& method_id) const {
562    CHECK_GE(&method_id, method_ids_) << GetLocation();
563    CHECK_LT(&method_id, method_ids_ + header_->method_ids_size_) << GetLocation();
564    return &method_id - method_ids_;
565  }
566
567  // Looks up a method by its declaring class, name and proto_id
568  const MethodId* FindMethodId(const DexFile::TypeId& declaring_klass,
569                               const DexFile::StringId& name,
570                               const DexFile::ProtoId& signature) const;
571
572  // Returns the declaring class descriptor string of a method id.
573  const char* GetMethodDeclaringClassDescriptor(const MethodId& method_id) const {
574    const DexFile::TypeId& type_id = GetTypeId(method_id.class_idx_);
575    return GetTypeDescriptor(type_id);
576  }
577
578  // Returns the prototype of a method id.
579  const ProtoId& GetMethodPrototype(const MethodId& method_id) const {
580    return GetProtoId(method_id.proto_idx_);
581  }
582
583  // Returns a representation of the signature of a method id.
584  const Signature GetMethodSignature(const MethodId& method_id) const;
585
586  // Returns the name of a method id.
587  const char* GetMethodName(const MethodId& method_id) const {
588    return StringDataByIdx(method_id.name_idx_);
589  }
590
591  // Returns the shorty of a method id.
592  const char* GetMethodShorty(const MethodId& method_id) const {
593    return StringDataByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_);
594  }
595  const char* GetMethodShorty(const MethodId& method_id, uint32_t* length) const {
596    // Using the UTF16 length is safe here as shorties are guaranteed to be ASCII characters.
597    return StringDataAndUtf16LengthByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_, length);
598  }
599  // Returns the number of class definitions in the .dex file.
600  size_t NumClassDefs() const {
601    DCHECK(header_ != NULL) << GetLocation();
602    return header_->class_defs_size_;
603  }
604
605  // Returns the ClassDef at the specified index.
606  const ClassDef& GetClassDef(uint16_t idx) const {
607    DCHECK_LT(idx, NumClassDefs()) << GetLocation();
608    return class_defs_[idx];
609  }
610
611  uint16_t GetIndexForClassDef(const ClassDef& class_def) const {
612    CHECK_GE(&class_def, class_defs_) << GetLocation();
613    CHECK_LT(&class_def, class_defs_ + header_->class_defs_size_) << GetLocation();
614    return &class_def - class_defs_;
615  }
616
617  // Returns the class descriptor string of a class definition.
618  const char* GetClassDescriptor(const ClassDef& class_def) const {
619    return StringByTypeIdx(class_def.class_idx_);
620  }
621
622  // Looks up a class definition by its class descriptor.
623  const ClassDef* FindClassDef(const char* descriptor) const;
624
625  // Looks up a class definition by its type index.
626  const ClassDef* FindClassDef(uint16_t type_idx) const;
627
628  const TypeList* GetInterfacesList(const ClassDef& class_def) const {
629    if (class_def.interfaces_off_ == 0) {
630        return NULL;
631    } else {
632      const byte* addr = begin_ + class_def.interfaces_off_;
633      return reinterpret_cast<const TypeList*>(addr);
634    }
635  }
636
637  // Returns a pointer to the raw memory mapped class_data_item
638  const byte* GetClassData(const ClassDef& class_def) const {
639    if (class_def.class_data_off_ == 0) {
640      return NULL;
641    } else {
642      return begin_ + class_def.class_data_off_;
643    }
644  }
645
646  //
647  const CodeItem* GetCodeItem(const uint32_t code_off) const {
648    if (code_off == 0) {
649      return NULL;  // native or abstract method
650    } else {
651      const byte* addr = begin_ + code_off;
652      return reinterpret_cast<const CodeItem*>(addr);
653    }
654  }
655
656  const char* GetReturnTypeDescriptor(const ProtoId& proto_id) const {
657    return StringByTypeIdx(proto_id.return_type_idx_);
658  }
659
660  // Returns the number of prototype identifiers in the .dex file.
661  size_t NumProtoIds() const {
662    DCHECK(header_ != NULL) << GetLocation();
663    return header_->proto_ids_size_;
664  }
665
666  // Returns the ProtoId at the specified index.
667  const ProtoId& GetProtoId(uint32_t idx) const {
668    DCHECK_LT(idx, NumProtoIds()) << GetLocation();
669    return proto_ids_[idx];
670  }
671
672  uint16_t GetIndexForProtoId(const ProtoId& proto_id) const {
673    CHECK_GE(&proto_id, proto_ids_) << GetLocation();
674    CHECK_LT(&proto_id, proto_ids_ + header_->proto_ids_size_) << GetLocation();
675    return &proto_id - proto_ids_;
676  }
677
678  // Looks up a proto id for a given return type and signature type list
679  const ProtoId* FindProtoId(uint16_t return_type_idx,
680                             const uint16_t* signature_type_idxs, uint32_t signature_length) const;
681  const ProtoId* FindProtoId(uint16_t return_type_idx,
682                             const std::vector<uint16_t>& signature_type_idxs) const {
683    return FindProtoId(return_type_idx, &signature_type_idxs[0], signature_type_idxs.size());
684  }
685
686  // Given a signature place the type ids into the given vector, returns true on success
687  bool CreateTypeList(const StringPiece& signature, uint16_t* return_type_idx,
688                      std::vector<uint16_t>* param_type_idxs) const;
689
690  // Create a Signature from the given string signature or return Signature::NoSignature if not
691  // possible.
692  const Signature CreateSignature(const StringPiece& signature) const;
693
694  // Returns the short form method descriptor for the given prototype.
695  const char* GetShorty(uint32_t proto_idx) const {
696    const ProtoId& proto_id = GetProtoId(proto_idx);
697    return StringDataByIdx(proto_id.shorty_idx_);
698  }
699
700  const TypeList* GetProtoParameters(const ProtoId& proto_id) const {
701    if (proto_id.parameters_off_ == 0) {
702      return NULL;
703    } else {
704      const byte* addr = begin_ + proto_id.parameters_off_;
705      return reinterpret_cast<const TypeList*>(addr);
706    }
707  }
708
709  const byte* GetEncodedStaticFieldValuesArray(const ClassDef& class_def) const {
710    if (class_def.static_values_off_ == 0) {
711      return 0;
712    } else {
713      return begin_ + class_def.static_values_off_;
714    }
715  }
716
717  static const TryItem* GetTryItems(const CodeItem& code_item, uint32_t offset);
718
719  // Get the base of the encoded data for the given DexCode.
720  static const byte* GetCatchHandlerData(const CodeItem& code_item, uint32_t offset) {
721    const byte* handler_data =
722        reinterpret_cast<const byte*>(GetTryItems(code_item, code_item.tries_size_));
723    return handler_data + offset;
724  }
725
726  // Find which try region is associated with the given address (ie dex pc). Returns -1 if none.
727  static int32_t FindTryItem(const CodeItem &code_item, uint32_t address);
728
729  // Find the handler offset associated with the given address (ie dex pc). Returns -1 if none.
730  static int32_t FindCatchHandlerOffset(const CodeItem &code_item, uint32_t address);
731
732  // Get the pointer to the start of the debugging data
733  const byte* GetDebugInfoStream(const CodeItem* code_item) const {
734    if (code_item->debug_info_off_ == 0) {
735      return NULL;
736    } else {
737      return begin_ + code_item->debug_info_off_;
738    }
739  }
740
741  // Callback for "new position table entry".
742  // Returning true causes the decoder to stop early.
743  typedef bool (*DexDebugNewPositionCb)(void* context, uint32_t address, uint32_t line_num);
744
745  // Callback for "new locals table entry". "signature" is an empty string
746  // if no signature is available for an entry.
747  typedef void (*DexDebugNewLocalCb)(void* context, uint16_t reg,
748                                     uint32_t start_address,
749                                     uint32_t end_address,
750                                     const char* name,
751                                     const char* descriptor,
752                                     const char* signature);
753
754  static bool LineNumForPcCb(void* context, uint32_t address, uint32_t line_num);
755
756  // Debug info opcodes and constants
757  enum {
758    DBG_END_SEQUENCE         = 0x00,
759    DBG_ADVANCE_PC           = 0x01,
760    DBG_ADVANCE_LINE         = 0x02,
761    DBG_START_LOCAL          = 0x03,
762    DBG_START_LOCAL_EXTENDED = 0x04,
763    DBG_END_LOCAL            = 0x05,
764    DBG_RESTART_LOCAL        = 0x06,
765    DBG_SET_PROLOGUE_END     = 0x07,
766    DBG_SET_EPILOGUE_BEGIN   = 0x08,
767    DBG_SET_FILE             = 0x09,
768    DBG_FIRST_SPECIAL        = 0x0a,
769    DBG_LINE_BASE            = -4,
770    DBG_LINE_RANGE           = 15,
771  };
772
773  struct LocalInfo {
774    LocalInfo()
775        : name_(NULL), descriptor_(NULL), signature_(NULL), start_address_(0), is_live_(false) {}
776
777    const char* name_;  // E.g., list
778    const char* descriptor_;  // E.g., Ljava/util/LinkedList;
779    const char* signature_;  // E.g., java.util.LinkedList<java.lang.Integer>
780    uint16_t start_address_;  // PC location where the local is first defined.
781    bool is_live_;  // Is the local defined and live.
782
783   private:
784    DISALLOW_COPY_AND_ASSIGN(LocalInfo);
785  };
786
787  struct LineNumFromPcContext {
788    LineNumFromPcContext(uint32_t address, uint32_t line_num)
789        : address_(address), line_num_(line_num) {}
790    uint32_t address_;
791    uint32_t line_num_;
792   private:
793    DISALLOW_COPY_AND_ASSIGN(LineNumFromPcContext);
794  };
795
796  void InvokeLocalCbIfLive(void* context, int reg, uint32_t end_address,
797                           LocalInfo* local_in_reg, DexDebugNewLocalCb local_cb) const {
798    if (local_cb != NULL && local_in_reg[reg].is_live_) {
799      local_cb(context, reg, local_in_reg[reg].start_address_, end_address,
800          local_in_reg[reg].name_, local_in_reg[reg].descriptor_,
801          local_in_reg[reg].signature_ != NULL ? local_in_reg[reg].signature_ : "");
802    }
803  }
804
805  // Determine the source file line number based on the program counter.
806  // "pc" is an offset, in 16-bit units, from the start of the method's code.
807  //
808  // Returns -1 if no match was found (possibly because the source files were
809  // compiled without "-g", so no line number information is present).
810  // Returns -2 for native methods (as expected in exception traces).
811  //
812  // This is used by runtime; therefore use art::Method not art::DexFile::Method.
813  int32_t GetLineNumFromPC(mirror::ArtMethod* method, uint32_t rel_pc) const
814      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
815
816  void DecodeDebugInfo(const CodeItem* code_item, bool is_static, uint32_t method_idx,
817                       DexDebugNewPositionCb position_cb, DexDebugNewLocalCb local_cb,
818                       void* context) const;
819
820  const char* GetSourceFile(const ClassDef& class_def) const {
821    if (class_def.source_file_idx_ == 0xffffffff) {
822      return NULL;
823    } else {
824      return StringDataByIdx(class_def.source_file_idx_);
825    }
826  }
827
828  int GetPermissions() const;
829
830  bool IsReadOnly() const;
831
832  bool EnableWrite() const;
833
834  bool DisableWrite() const;
835
836  const byte* Begin() const {
837    return begin_;
838  }
839
840  size_t Size() const {
841    return size_;
842  }
843
844  static std::string GetMultiDexClassesDexName(size_t number, const char* dex_location);
845
846  // Returns the canonical form of the given dex location.
847  //
848  // There are different flavors of "dex locations" as follows:
849  // the file name of a dex file:
850  //     The actual file path that the dex file has on disk.
851  // dex_location:
852  //     This acts as a key for the class linker to know which dex file to load.
853  //     It may correspond to either an old odex file or a particular dex file
854  //     inside an oat file. In the first case it will also match the file name
855  //     of the dex file. In the second case (oat) it will include the file name
856  //     and possibly some multidex annotation to uniquely identify it.
857  // canonical_dex_location:
858  //     the dex_location where it's file name part has been made canonical.
859  static std::string GetDexCanonicalLocation(const char* dex_location);
860
861 private:
862  // Opens a .dex file
863  static const DexFile* OpenFile(int fd, const char* location, bool verify, std::string* error_msg);
864
865  // Opens dex files from within a .jar, .zip, or .apk file
866  static bool OpenZip(int fd, const std::string& location, std::string* error_msg,
867                      std::vector<const DexFile*>* dex_files);
868
869  enum class ZipOpenErrorCode {  // private
870    kNoError,
871    kEntryNotFound,
872    kExtractToMemoryError,
873    kDexFileError,
874    kMakeReadOnlyError,
875    kVerifyError
876  };
877
878  // Opens .dex file from the entry_name in a zip archive. error_code is undefined when non-nullptr
879  // return.
880  static const DexFile* Open(const ZipArchive& zip_archive, const char* entry_name,
881                             const std::string& location, std::string* error_msg,
882                             ZipOpenErrorCode* error_code);
883
884  // Opens a .dex file at the given address backed by a MemMap
885  static const DexFile* OpenMemory(const std::string& location,
886                                   uint32_t location_checksum,
887                                   MemMap* mem_map,
888                                   std::string* error_msg);
889
890  // Opens a .dex file at the given address, optionally backed by a MemMap
891  static const DexFile* OpenMemory(const byte* dex_file,
892                                   size_t size,
893                                   const std::string& location,
894                                   uint32_t location_checksum,
895                                   MemMap* mem_map,
896                                   std::string* error_msg);
897
898  DexFile(const byte* base, size_t size,
899          const std::string& location,
900          uint32_t location_checksum,
901          MemMap* mem_map);
902
903  // Top-level initializer that calls other Init methods.
904  bool Init(std::string* error_msg);
905
906  // Returns true if the header magic and version numbers are of the expected values.
907  bool CheckMagicAndVersion(std::string* error_msg) const;
908
909  void DecodeDebugInfo0(const CodeItem* code_item, bool is_static, uint32_t method_idx,
910      DexDebugNewPositionCb position_cb, DexDebugNewLocalCb local_cb,
911      void* context, const byte* stream, LocalInfo* local_in_reg) const;
912
913  // Check whether a location denotes a multidex dex file. This is a very simple check: returns
914  // whether the string contains the separator character.
915  static bool IsMultiDexLocation(const char* location);
916
917  // Splits a multidex location at the last separator character. The second component is a pointer
918  // to the character after the separator. The first is a copy of the substring up to the separator.
919  //
920  // Note: It's the caller's job to free the first component of the returned pair.
921  // Bug 15313523: gcc/libc++ don't allow a unique_ptr for the first component
922  static std::pair<const char*, const char*> SplitMultiDexLocation(const char* location);
923
924
925  // The base address of the memory mapping.
926  const byte* const begin_;
927
928  // The size of the underlying memory allocation in bytes.
929  const size_t size_;
930
931  // Typically the dex file name when available, alternatively some identifying string.
932  //
933  // The ClassLinker will use this to match DexFiles the boot class
934  // path to DexCache::GetLocation when loading from an image.
935  const std::string location_;
936
937  const uint32_t location_checksum_;
938
939  // Manages the underlying memory allocation.
940  std::unique_ptr<MemMap> mem_map_;
941
942  // Points to the header section.
943  const Header* const header_;
944
945  // Points to the base of the string identifier list.
946  const StringId* const string_ids_;
947
948  // Points to the base of the type identifier list.
949  const TypeId* const type_ids_;
950
951  // Points to the base of the field identifier list.
952  const FieldId* const field_ids_;
953
954  // Points to the base of the method identifier list.
955  const MethodId* const method_ids_;
956
957  // Points to the base of the prototype identifier list.
958  const ProtoId* const proto_ids_;
959
960  // Points to the base of the class definition list.
961  const ClassDef* const class_defs_;
962};
963std::ostream& operator<<(std::ostream& os, const DexFile& dex_file);
964
965// Iterate over a dex file's ProtoId's paramters
966class DexFileParameterIterator {
967 public:
968  DexFileParameterIterator(const DexFile& dex_file, const DexFile::ProtoId& proto_id)
969      : dex_file_(dex_file), size_(0), pos_(0) {
970    type_list_ = dex_file_.GetProtoParameters(proto_id);
971    if (type_list_ != NULL) {
972      size_ = type_list_->Size();
973    }
974  }
975  bool HasNext() const { return pos_ < size_; }
976  void Next() { ++pos_; }
977  uint16_t GetTypeIdx() {
978    return type_list_->GetTypeItem(pos_).type_idx_;
979  }
980  const char* GetDescriptor() {
981    return dex_file_.StringByTypeIdx(GetTypeIdx());
982  }
983 private:
984  const DexFile& dex_file_;
985  const DexFile::TypeList* type_list_;
986  uint32_t size_;
987  uint32_t pos_;
988  DISALLOW_IMPLICIT_CONSTRUCTORS(DexFileParameterIterator);
989};
990
991// Abstract the signature of a method.
992class Signature {
993 public:
994  std::string ToString() const;
995
996  static Signature NoSignature() {
997    return Signature();
998  }
999
1000  bool operator==(const Signature& rhs) const;
1001  bool operator!=(const Signature& rhs) const {
1002    return !(*this == rhs);
1003  }
1004
1005  bool operator==(const StringPiece& rhs) const;
1006
1007 private:
1008  Signature(const DexFile* dex, const DexFile::ProtoId& proto) : dex_file_(dex), proto_id_(&proto) {
1009  }
1010
1011  Signature() : dex_file_(nullptr), proto_id_(nullptr) {
1012  }
1013
1014  friend class DexFile;
1015
1016  const DexFile* const dex_file_;
1017  const DexFile::ProtoId* const proto_id_;
1018};
1019std::ostream& operator<<(std::ostream& os, const Signature& sig);
1020
1021// Iterate and decode class_data_item
1022class ClassDataItemIterator {
1023 public:
1024  ClassDataItemIterator(const DexFile& dex_file, const byte* raw_class_data_item)
1025      : dex_file_(dex_file), pos_(0), ptr_pos_(raw_class_data_item), last_idx_(0) {
1026    ReadClassDataHeader();
1027    if (EndOfInstanceFieldsPos() > 0) {
1028      ReadClassDataField();
1029    } else if (EndOfVirtualMethodsPos() > 0) {
1030      ReadClassDataMethod();
1031    }
1032  }
1033  uint32_t NumStaticFields() const {
1034    return header_.static_fields_size_;
1035  }
1036  uint32_t NumInstanceFields() const {
1037    return header_.instance_fields_size_;
1038  }
1039  uint32_t NumDirectMethods() const {
1040    return header_.direct_methods_size_;
1041  }
1042  uint32_t NumVirtualMethods() const {
1043    return header_.virtual_methods_size_;
1044  }
1045  bool HasNextStaticField() const {
1046    return pos_ < EndOfStaticFieldsPos();
1047  }
1048  bool HasNextInstanceField() const {
1049    return pos_ >= EndOfStaticFieldsPos() && pos_ < EndOfInstanceFieldsPos();
1050  }
1051  bool HasNextDirectMethod() const {
1052    return pos_ >= EndOfInstanceFieldsPos() && pos_ < EndOfDirectMethodsPos();
1053  }
1054  bool HasNextVirtualMethod() const {
1055    return pos_ >= EndOfDirectMethodsPos() && pos_ < EndOfVirtualMethodsPos();
1056  }
1057  bool HasNext() const {
1058    return pos_ < EndOfVirtualMethodsPos();
1059  }
1060  inline void Next() {
1061    pos_++;
1062    if (pos_ < EndOfStaticFieldsPos()) {
1063      last_idx_ = GetMemberIndex();
1064      ReadClassDataField();
1065    } else if (pos_ == EndOfStaticFieldsPos() && NumInstanceFields() > 0) {
1066      last_idx_ = 0;  // transition to next array, reset last index
1067      ReadClassDataField();
1068    } else if (pos_ < EndOfInstanceFieldsPos()) {
1069      last_idx_ = GetMemberIndex();
1070      ReadClassDataField();
1071    } else if (pos_ == EndOfInstanceFieldsPos() && NumDirectMethods() > 0) {
1072      last_idx_ = 0;  // transition to next array, reset last index
1073      ReadClassDataMethod();
1074    } else if (pos_ < EndOfDirectMethodsPos()) {
1075      last_idx_ = GetMemberIndex();
1076      ReadClassDataMethod();
1077    } else if (pos_ == EndOfDirectMethodsPos() && NumVirtualMethods() > 0) {
1078      last_idx_ = 0;  // transition to next array, reset last index
1079      ReadClassDataMethod();
1080    } else if (pos_ < EndOfVirtualMethodsPos()) {
1081      last_idx_ = GetMemberIndex();
1082      ReadClassDataMethod();
1083    } else {
1084      DCHECK(!HasNext());
1085    }
1086  }
1087  uint32_t GetMemberIndex() const {
1088    if (pos_ < EndOfInstanceFieldsPos()) {
1089      return last_idx_ + field_.field_idx_delta_;
1090    } else {
1091      DCHECK_LT(pos_, EndOfVirtualMethodsPos());
1092      return last_idx_ + method_.method_idx_delta_;
1093    }
1094  }
1095  uint32_t GetMemberAccessFlags() const {
1096    if (pos_ < EndOfInstanceFieldsPos()) {
1097      return field_.access_flags_;
1098    } else {
1099      DCHECK_LT(pos_, EndOfVirtualMethodsPos());
1100      return method_.access_flags_;
1101    }
1102  }
1103  InvokeType GetMethodInvokeType(const DexFile::ClassDef& class_def) const {
1104    if (HasNextDirectMethod()) {
1105      if ((GetMemberAccessFlags() & kAccStatic) != 0) {
1106        return kStatic;
1107      } else {
1108        return kDirect;
1109      }
1110    } else {
1111      DCHECK_EQ(GetMemberAccessFlags() & kAccStatic, 0U);
1112      if ((class_def.access_flags_ & kAccInterface) != 0) {
1113        return kInterface;
1114      } else if ((GetMemberAccessFlags() & kAccConstructor) != 0) {
1115        return kSuper;
1116      } else {
1117        return kVirtual;
1118      }
1119    }
1120  }
1121  const DexFile::CodeItem* GetMethodCodeItem() const {
1122    return dex_file_.GetCodeItem(method_.code_off_);
1123  }
1124  uint32_t GetMethodCodeItemOffset() const {
1125    return method_.code_off_;
1126  }
1127  const byte* EndDataPointer() const {
1128    CHECK(!HasNext());
1129    return ptr_pos_;
1130  }
1131
1132 private:
1133  // A dex file's class_data_item is leb128 encoded, this structure holds a decoded form of the
1134  // header for a class_data_item
1135  struct ClassDataHeader {
1136    uint32_t static_fields_size_;  // the number of static fields
1137    uint32_t instance_fields_size_;  // the number of instance fields
1138    uint32_t direct_methods_size_;  // the number of direct methods
1139    uint32_t virtual_methods_size_;  // the number of virtual methods
1140  } header_;
1141
1142  // Read and decode header from a class_data_item stream into header
1143  void ReadClassDataHeader();
1144
1145  uint32_t EndOfStaticFieldsPos() const {
1146    return header_.static_fields_size_;
1147  }
1148  uint32_t EndOfInstanceFieldsPos() const {
1149    return EndOfStaticFieldsPos() + header_.instance_fields_size_;
1150  }
1151  uint32_t EndOfDirectMethodsPos() const {
1152    return EndOfInstanceFieldsPos() + header_.direct_methods_size_;
1153  }
1154  uint32_t EndOfVirtualMethodsPos() const {
1155    return EndOfDirectMethodsPos() + header_.virtual_methods_size_;
1156  }
1157
1158  // A decoded version of the field of a class_data_item
1159  struct ClassDataField {
1160    uint32_t field_idx_delta_;  // delta of index into the field_ids array for FieldId
1161    uint32_t access_flags_;  // access flags for the field
1162    ClassDataField() :  field_idx_delta_(0), access_flags_(0) {}
1163
1164   private:
1165    DISALLOW_COPY_AND_ASSIGN(ClassDataField);
1166  };
1167  ClassDataField field_;
1168
1169  // Read and decode a field from a class_data_item stream into field
1170  void ReadClassDataField();
1171
1172  // A decoded version of the method of a class_data_item
1173  struct ClassDataMethod {
1174    uint32_t method_idx_delta_;  // delta of index into the method_ids array for MethodId
1175    uint32_t access_flags_;
1176    uint32_t code_off_;
1177    ClassDataMethod() : method_idx_delta_(0), access_flags_(0), code_off_(0) {}
1178
1179   private:
1180    DISALLOW_COPY_AND_ASSIGN(ClassDataMethod);
1181  };
1182  ClassDataMethod method_;
1183
1184  // Read and decode a method from a class_data_item stream into method
1185  void ReadClassDataMethod();
1186
1187  const DexFile& dex_file_;
1188  size_t pos_;  // integral number of items passed
1189  const byte* ptr_pos_;  // pointer into stream of class_data_item
1190  uint32_t last_idx_;  // last read field or method index to apply delta to
1191  DISALLOW_IMPLICIT_CONSTRUCTORS(ClassDataItemIterator);
1192};
1193
1194class EncodedStaticFieldValueIterator {
1195 public:
1196  EncodedStaticFieldValueIterator(const DexFile& dex_file, Handle<mirror::DexCache>* dex_cache,
1197                                  Handle<mirror::ClassLoader>* class_loader,
1198                                  ClassLinker* linker, const DexFile::ClassDef& class_def)
1199      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
1200
1201  template<bool kTransactionActive>
1202  void ReadValueToField(mirror::ArtField* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
1203
1204  bool HasNext() { return pos_ < array_size_; }
1205
1206  void Next();
1207
1208  enum ValueType {
1209    kByte = 0x00,
1210    kShort = 0x02,
1211    kChar = 0x03,
1212    kInt = 0x04,
1213    kLong = 0x06,
1214    kFloat = 0x10,
1215    kDouble = 0x11,
1216    kString = 0x17,
1217    kType = 0x18,
1218    kField = 0x19,
1219    kMethod = 0x1a,
1220    kEnum = 0x1b,
1221    kArray = 0x1c,
1222    kAnnotation = 0x1d,
1223    kNull = 0x1e,
1224    kBoolean = 0x1f
1225  };
1226
1227 private:
1228  static const byte kEncodedValueTypeMask = 0x1f;  // 0b11111
1229  static const byte kEncodedValueArgShift = 5;
1230
1231  const DexFile& dex_file_;
1232  Handle<mirror::DexCache>* const dex_cache_;  // Dex cache to resolve literal objects.
1233  Handle<mirror::ClassLoader>* const class_loader_;  // ClassLoader to resolve types.
1234  ClassLinker* linker_;  // Linker to resolve literal objects.
1235  size_t array_size_;  // Size of array.
1236  size_t pos_;  // Current position.
1237  const byte* ptr_;  // Pointer into encoded data array.
1238  ValueType type_;  // Type of current encoded value.
1239  jvalue jval_;  // Value of current encoded value.
1240  DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedStaticFieldValueIterator);
1241};
1242std::ostream& operator<<(std::ostream& os, const EncodedStaticFieldValueIterator::ValueType& code);
1243
1244class CatchHandlerIterator {
1245  public:
1246    CatchHandlerIterator(const DexFile::CodeItem& code_item, uint32_t address);
1247
1248    CatchHandlerIterator(const DexFile::CodeItem& code_item,
1249                         const DexFile::TryItem& try_item);
1250
1251    explicit CatchHandlerIterator(const byte* handler_data) {
1252      Init(handler_data);
1253    }
1254
1255    uint16_t GetHandlerTypeIndex() const {
1256      return handler_.type_idx_;
1257    }
1258    uint32_t GetHandlerAddress() const {
1259      return handler_.address_;
1260    }
1261    void Next();
1262    bool HasNext() const {
1263      return remaining_count_ != -1 || catch_all_;
1264    }
1265    // End of this set of catch blocks, convenience method to locate next set of catch blocks
1266    const byte* EndDataPointer() const {
1267      CHECK(!HasNext());
1268      return current_data_;
1269    }
1270
1271  private:
1272    void Init(const DexFile::CodeItem& code_item, int32_t offset);
1273    void Init(const byte* handler_data);
1274
1275    struct CatchHandlerItem {
1276      uint16_t type_idx_;  // type index of the caught exception type
1277      uint32_t address_;  // handler address
1278    } handler_;
1279    const byte *current_data_;  // the current handler in dex file.
1280    int32_t remaining_count_;   // number of handlers not read.
1281    bool catch_all_;            // is there a handler that will catch all exceptions in case
1282                                // that all typed handler does not match.
1283};
1284
1285}  // namespace art
1286
1287#endif  // ART_RUNTIME_DEX_FILE_H_
1288