Lines Matching full:code
19 <p>This document describes the layout and contents of <code>.dex</code>
75 <td>unsigned LEB128 plus <code>1</code>, variable-length (see below)</td>
86 specification. In a <code>.dex</code> file, LEB128 is only ever used to
95 byte and so on. In the case of a signed LEB128 (<code>sleb128</code>),
98 (<code>uleb128</code>), any bits not explicitly represented are
99 interpreted as <code>0</code>.
111 <td class="start1"><code>1</code></td>
119 <td class="start2"><code>0</code></td>
131 <p>The variant <code>uleb128p1</code> is used to represent a signed
133 as a <code>uleb128</code>. This makes the encoding of <code>-1</code>
134 (alternatively thought of as the unsigned value <code>0xffffffff</code>)
137 be non-negative or <code>-1</code> (or <code>0xffffffff</code>),
147 <th>As <code>sleb128</code></th>
148 <th>As <code>uleb128</code></th>
149 <th>As <code>uleb128p1</code></th>
181 or as constant objects referred to by code. This list must be sorted
182 by string contents, using UTF-16 code point values (not in a
191 in the file or not. This list must be sorted by <code>string_id</code>
200 return-type (by <code>type_id</code> index) major order, and then
201 by arguments (also by <code>type_id</code> index). The list must not
210 list must be sorted, where the defining type (by <code>type_id</code>
211 index) is the major order, field name (by <code>string_id</code> index)
212 is the intermediate order, and type (by <code>type_id</code> index)
221 list must be sorted, where the defining type (by <code>type_id</code>
222 index) is the major order, method name (by <code>string_id</code>
224 <code>proto_id</code> index) is the minor order. The list must not
264 <p>The constant array/string <code>DEX_FILE_MAGIC</code> is the list of
265 bytes that must appear at the beginning of a <code>.dex</code> file
267 contains a newline (<code>"\n"</code> or <code>0x0a</code>) and a
268 null byte (<code>"\0"</code> or <code>0x00</code>) in order to help
280 version <code>009</code> was used for the M3 releases of the
282 and version <code>013</code> was used for the M5 releases of the Android
287 <p class="note"><strong>Note:</strong> Support for version <code>037</code> of
289 versions of Android have used version <code>035</code> of the format. The only
290 difference between versions <code>035</code> and <code>037</code> is the
291 addition of default methods and the adjustment of the <code>invoke</code>
293 older versions of Android, Dex version <code>036</code> has been skipped.
294 Dex version <code>036</code> is not valid for any version of Android and never
300 <p>The constant <code>ENDIAN_CONSTANT</code> is used to indicate the
302 <code>.dex</code> format is little-endian, implementations may choose
304 header whose <code>endian_tag</code> is <code>REVERSE_ENDIAN_CONSTANT</code>
305 instead of <code>ENDIAN_CONSTANT</code>, it would know that the file
316 <p>The constant <code>NO_INDEX</code> is used to indicate that
320 <code>0</code>, because that is in fact typically a valid index.</p>
322 <p>The chosen value for <code>NO_INDEX</code> is
323 representable as a single byte in the <code>uleb128p1</code> encoding.</p>
341 <th>For Classes (and <code>InnerClass</code> annotations)</th>
350 <td><code>public</code>: visible everywhere</td>
351 <td><code>public</code>: visible everywhere</td>
352 <td><code>public</code>: visible everywhere</td>
358 <code>private</code>: only visible to defining class
360 <td><code>private</code>: only visible to defining class</td>
361 <td><code>private</code>: only visible to defining class</td>
367 <code>protected</code>: visible to package and subclasses
369 <td><code>protected</code>: visible to package and subclasses</td>
370 <td><code>protected</code>: visible to package and subclasses</td>
376 <code>static</code>: is not constructed with an outer
377 <code>this</code> reference</td>
378 <td><code>static</code>: global to defining class</td>
379 <td><code>static</code>: does not take a <code>this</code> argument</td>
384 <td><code>final</code>: not subclassable</td>
385 <td><code>final</code>: immutable after construction</td>
386 <td><code>final</code>: not overridable</td>
393 <td><code>synchronized</code>: associated lock automatically acquired
395 <code>ACC_NATIVE</code> is also set. </p></td>
401 <td><code>volatile</code>: special access rules to help with thread
417 <td><code>transient</code>: not to be saved by default serialization</td>
432 <td><code>native</code>: implemented in native code</td>
437 <td><code>interface</code>: multiply-implementable abstract class</td>
444 <td><code>abstract</code>: not directly instantiable</td>
446 <td><code>abstract</code>: unimplemented by this class</td>
453 <td><code>strictfp</code>: strict rules for floating-point arithmetic</td>
458 <td>not directly defined in source code</td>
459 <td>not directly defined in source code</td>
460 <td>not directly defined in source code</td>
495 <td>declared <code>synchronized</code>. <p class="note"><strong>Note:</strong> This has no effect on
502 <p><super>*</super> Only allowed on for <code>InnerClass</code> annotations,
503 and must not ever be on in a <code>class_def_item</code>.</p>
507 <p>As a concession to easier legacy support, the <code>.dex</code> format
513 <li>Code points in the range <code>U+10000</code> …
514 <code>U+10ffff</code> are encoded as a surrogate pair, each of
516 <li>The code point <code>U+0000</code> is encoded in two-byte form.</li>
517 code>0</code>) indicates the end of
526 the code point <code>U+0000</code> in a string <i>and</i> still manipulate
529 <p>However, the special encoding of <code>U+0000</code> means that, unlike
531 <code>strcmp()</code> on a pair of MUTF-8 strings does not always
547 <p>An <code>encoded_value</code> is an encoded piece of (nearly)
564 <code>value</code> along
566 See below for the various <code>value</code> definitions.
567 In most cases, <code>value_arg</code> encodes the length of
568 the immediately-subsequent <code>value</code> in bytes, as
569 <code>(size - 1)</code>, e.g., <code>0</code> means that
570 the value requires one byte, and <code>7</code> means it requires
578 differently for different <code>value_type</code> bytes, though
592 <th><code>value_type</code></th>
593 <th><code>value_arg</code> Format</th>
594 <th><code>value</code> Format</th>
602 <td><i>(none; must be <code>0</code>)</i></td>
659 the <code>string_ids</code> section and representing a string value
669 the <code>type_ids</code> section and representing a reflective
680 the <code>field_ids</code> section and representing a reflective
691 the <code>method_ids</code> section and representing a reflective
702 the <code>field_ids</code> section and representing the value of
709 <td><i>(none; must be <code>0</code>)</i></td>
712 "<code>encoded_array</code> format" below. The size
713 of the <code>value</code> is implicit in the encoding.
719 <td><i>(none; must be <code>0</code>)</i></td>
722 "<code>encoded_annotation</code> format" below. The size
723 of the <code>value</code> is implicit in the encoding.
729 <td><i>(none; must be <code>0</code>)</i></td>
731 <td><code>null</code> reference value</td>
738 <td>one-bit value; <code>0</code> for <code>false</code> and
739 <code>1</code> for <code>true</code>. The bit is represented in the
740 <code>value_arg</code>.
765 <td>a series of <code>size</code> <code>encoded_value</code> byte
801 <code>string_id</code> index.
822 <code>string_ids</code> section. The string must conform to the
836 <p>There are several kinds of item in a <code>.dex</code> file which
843 things. The <code>.dex</code> format allows a fair amount of latitude
846 specific low-ASCII symbols, and most non-ASCII code points that are not
847 control, space, or special characters. Note that surrogate code points
848 (in the range <code>U+d800</code> … <code>U+dfff</code>) are not
852 represented in a file as pairs of surrogate code points in the MUTF-8
865 <td><code>'A'</code> … <code>'Z'</code></td>
869 <td><code>'a'</code> … <code>'z'</code></td>
873 <td><code>'0'</code> … <code>'9'</code></td>
877 <td><code>'$'</code></td>
881 <td><code>'-'</code></td>
885 <td><code>'_'</code></td>
889 <td><code>U+00a1</code> … <code>U+1fff</code></td>
893 <td><code>U+2010</code> … <code>U+2027</code></td>
897 <td><code>U+2030</code> … <code>U+d7ff</code></td>
901 <td><code>U+e000</code> … <code>U+ffef</code></td>
905 <td><code>U+10000</code> … <code>U+10ffff</code></td>
923 <td><code>'<'</code> <i>SimpleName</i> <code>'>'</code></td>
942 <td>(<i>SimpleName</i> <code>'/'</code>)*</td>
950 primitives, classes, arrays, and <code>void</code>. See below for
957 <td><code>'V'</code></td>
971 <td>(<code>'['</code> * 1…255)
980 <td><code>'Z'</code></td>
984 <td><code>'B'</code></td>
988 <td><code>'S'</code></td>
992 <td><code>'C'</code></td>
996 <td><code>'I'</code></td>
1000 <td><code>'J'</code></td>
1004 <td><code>'F'</code></td>
1008 <td><code>'D'</code></td>
1012 <td><code>'L'</code> <i>FullClassName</i> <code>';'</code></td>
1022 all reference types are represented by a single <code>'L'</code> character.</p>
1034 <td><code>'V'</code></td>
1044 <td><code>'Z'</code></td>
1048 <td><code>'B'</code></td>
1052 <td><code>'S'</code></td>
1056 <td><code>'C'</code></td>
1060 <td><code>'I'</code></td>
1064 <td><code>'J'</code></td>
1068 <td><code>'F'</code></td>
1072 <td><code>'D'</code></td>
1076 <td><code>'L'</code></td>
1094 <td><code>void</code>; only valid for return types</td>
1098 <td><code>boolean</code></td>
1102 <td><code>byte</code></td>
1106 <td><code>short</code></td>
1110 <td><code>char</code></td>
1114 <td><code>int</code></td>
1118 <td><code>long</code></td>
1122 <td><code>float</code></td>
1126 <td><code>double</code></td>
1130 <td>the class <code><i>fully.qualified.Name</i></code></td>
1134 <td>array of <code><i>descriptor</i></code>, usable recursively for
1145 may appear in a <code>.dex</code> file.
1163 <td>magic value. See discussion above under "<code>DEX_FILE_MAGIC</code>"
1171 <code>magic</code> and this field); used to detect file corruption
1178 <code>magic</code>, <code>checksum</code>, and this field); used
1198 <td>endianness tag. See discussion above under "<code>ENDIAN_CONSTANT</code>
1199 and <code>REVERSE_ENDIAN_CONSTANT</code>" for more details.
1205 <td>size of the link section, or <code>0</code> if this file isn't
1212 <code>0</code> if <code>link_size == 0</code>. The offset, if non-zero,
1213 should be to an offset into the <code>link_data</code> section. The
1223 <code>0</code> if this file has no map. The offset, if non-zero,
1224 should be to an offset into the <code>data</code> section,
1225 and the data should be in the format specified by "<code>map_list</code>"
1238 <code>0</code> if <code>string_ids_size == 0</code> (admittedly a
1240 should be to the start of the <code>string_ids</code> section.
1252 <code>0</code> if <code>type_ids_size == 0</code> (admittedly a
1254 should be to the start of the <code>type_ids</code>
1267 <code>0</code> if <code>proto_ids_size == 0</code> (admittedly a
1269 should be to the start of the <code>proto_ids</code>
1282 <code>0</code> if <code>field_ids_size == 0</code>. The offset, if
1283 non-zero, should be to the start of the <code>field_ids</code>
1296 <code>0</code> if <code>method_ids_size == 0</code>. The offset, if
1297 non-zero, should be to the start of the <code>method_ids</code>
1309 <code>0</code> if <code>class_defs_size == 0</code> (admittedly a
1311 should be to the start of the <code>class_defs</code> section.
1317 <td>Size of <code>data</code> section in bytes. Must be an even
1324 <code>data</code> section.
1336 contains some redundancy with respect to the <code>header_item</code>
1341 <code>header</code> section must appear first, followed by a
1342 <code>string_ids</code> section, etc.). Additionally, the map entries must
1544 in the <code>data</code> section, and the data should be in the
1545 format specified by "<code>string_data_item</code>" below.
1568 <td>size of this string, in UTF-16 code units (which is the "string
1571 the <code>0</code> byte.)</td>
1576 <td>a series of MUTF-8 code units (a.k.a. octets, a.k.a. bytes)
1577 followed by a byte of value <code>0</code>. See
1581 (the encoded form of) UTF-16 surrogate code units (that is,
1582 <code>U+d800</code> … <code>U+dfff</code>)
1607 <td>index into the <code>string_ids</code> list for the descriptor
1631 <td>index into the <code>string_ids</code> list for the short-form
1640 <td>index into the <code>type_ids</code> list for the return type
1648 for this prototype, or <code>0</code> if this prototype has no
1650 <code>data</code> section, and the data there should be in the
1651 format specified by <code>"type_list"</code> below. Additionally, there
1652 should be no reference to the type <code>void</code> in the list.
1674 <td>index into the <code>type_ids</code> list for the definer of this
1681 <td>index into the <code>type_ids</code> list for the type of
1688 <td>index into the <code>string_ids</code> list for the name of this
1712 <td>index into the <code>type_ids</code> list for the definer of this
1719 <td>index into the <code>proto_ids</code> list for the prototype of
1726 <td>index into the <code>string_ids</code> list for the name of this
1750 <td>index into the <code>type_ids</code> list for this class.
1757 <td>access flags for the class (<code>public</code>, <code>final</code>,
1758 etc.). See "<code>access_flags</code> Definitions" for details.
1764 <td>index into the <code>type_ids</code> list for the superclass, or
1765 the constant value <code>NO_INDEX</code> if this class has no
1766 superclass (i.e., it is a root class such as <code>Object</code>).
1774 <code>0</code> if there are none. This offset
1775 should be in the <code>data</code> section, and the data
1777 "<code>type_list</code>" below. Each of the elements of the list
1785 <td>index into the <code>string_ids</code> list for the name of the
1787 or the special value <code>NO_INDEX</code> to represent a lack of
1788 this information. The <code>debug_info_item</code> of any given method
1797 for this class, or <code>0</code> if there are no annotations on
1799 <code>data</code> section, and the data there should be in
1800 the format specified by "<code>annotations_directory_item</code>" below,
1808 class data for this item, or <code>0</code> if there is no class
1811 <code>data</code> section, and the data there should be in the
1812 format specified by "<code>class_data_item</code>" below, with all
1820 values for <code>static</code> fields, or <code>0</code> if there
1821 are none (and all <code>static</code> fields are to be initialized with
1822 <code>0</code> or <code>null</code>). This offset should be in the
1823 <code>data</code> section, and the data there should be in the
1824 format specified by "<code>encoded_array_item</code>" below. The size
1825 of the array must be no larger than the number of <code>static</code>
1827 <code>static</code> fields in the same order as declared in the
1828 corresponding <code>field_list</code>. The type of each array
1831 <code>static</code> fields, then the leftover fields are initialized
1832 with a type-appropriate <code>0</code> or <code>null</code>.
1877 <code>field_idx</code> in increasing order.
1885 <code>field_idx</code> in increasing order.
1891 <td>the defined direct (any of <code>static</code>, <code>private</code>,
1894 <code>method_idx</code> in increasing order.
1900 <td>the defined virtual (none of <code>static</code>, <code>private</code>,
1904 methods must be sorted by <code>method_idx</code> in increasing order.
1910 <p class="note"><strong>Note:</strong> All elements' <code>field_id</code>s and
1911 <code>method_id</code>s must refer to the same defining class.</p>
1927 <td>index into the <code>field_ids</code> list for the identity of this
1936 <td>access flags for the field (<code>public</code>, <code>final</code>,
1937 etc.). See "<code>access_flags</code> Definitions" for details.
1957 <td>index into the <code>method_ids</code> list for the identity of this
1966 <td>access flags for the method (<code>public</code>, <code>final</code>,
1967 etc.). See "<code>access_flags</code> Definitions" for details.
1973 <td>offset from the start of the file to the code structure for this
1974 method, or <code>0</code> if this method is either <code>abstract</code>
1975 or <code>native</code>. The offset should be to a location in the
1976 <code>data</code> section. The format of the data is specified by
1977 "<code>code_item</code>" below.
2024 <td>index into the <code>type_ids</code> list</td>
2029 <h3 id="code-item">code_item</h3>
2046 <td>the number of registers used by this code</td>
2052 code is for</td>
2058 code for method invocation
2064 <td>the number of <code>try_item</code>s for this instance. If non-zero,
2065 then these appear as the <code>tries</code> array just after the
2066 <code>insns</code> in this instance.
2073 local variable info) sequence for this code, or <code>0</code> if
2075 to a location in the <code>data</code> section. The format of
2076 the data is specified by "<code>debug_info_item</code>" below.
2082 <td>size of the instructions list, in 16-bit code units</td>
2087 <td>actual array of bytecode. The format of code in an <code>insns</code>
2090 that though this is defined as an array of <code>ushort</code>, there
2093 <i>only</i> done on individual <code>ushort</code>s and not on the
2100 <td>two bytes of padding to make <code>tries</code> four-byte aligned.
2101 This element is only present if <code>tries_size</code> is non-zero
2102 and <code>insns_size</code> is odd.
2108 <td>array indicating where in the code exceptions are caught and
2111 present if <code>tries_size</code> is non-zero.
2118 handler addresses. Each <code>try_item</code> has a byte-wise offset
2120 <code>tries_size</code> is non-zero.
2140 <td>start address of the block of code covered by this entry. The address
2141 is a count of 16-bit code units to the start of the first covered
2148 <td>number of 16-bit code units covered by this entry. The last code
2149 unit covered (inclusive) is <code>start_addr + insn_count - 1</code>.
2156 <code>encoded_catch_hander_list</code> to the
2157 <code>encoded_catch_handler</code> for this entry. This must be an
2158 offset to the start of an <code>encoded_catch_handler</code>.
2205 by a catch-all handler. For example: A <code>size</code> of <code>0</code>
2207 A <code>size</code> of <code>2</code> means that there are two explicitly
2208 typed catches and no catch-all. And a <code>size</code> of <code>-1</code>
2215 <td>stream of <code>abs(size)</code> encoded items, one for each caught
2223 present if <code>size</code> is non-positive.
2243 <td>index into the <code>type_ids</code> list for the type of the
2260 <p>Each <code>debug_info_item</code> defines a DWARF3-inspired byte-coded
2263 <code>code_item</code>. The sequence begins with a variable-length
2266 with an <code>DBG_END_SEQUENCE</code> byte.</p>
2269 <code>address</code> register represents the instruction offset in the
2270 associated <code>insns_item</code> in 16-bit code units. The
2271 <code>address</code> register starts at <code>0</code> at the beginning of each
2272 <code>debug_info</code> sequence and must only monotonically increase.
2273 The <code>line</code> register represents what source line number
2277 <code>1</code>. The <code>source_file</code> register represents the
2279 the value of <code>source_file_idx</code> in <code>class_def_item</code>.
2280 The other two variables, <code>prologue_end</code> and
2281 <code>epilogue_begin</code>, are boolean flags (initialized to
2282 <code>false</code>) that indicate whether the next position emitted
2285 each register for the <code>DBG_RESTART_LOCAL</code> code.</p>
2301 <td>the initial value for the state machine's <code>line</code> register.
2309 one per method parameter, excluding an instance method's <code>this</code>,
2317 <code>NO_INDEX</code> indicates that no name
2325 <p>The byte code values are as follows:</p>
2343 <td>terminates a debug info sequence for a <code>code_item</code></td>
2349 <td><code>addr_diff</code>: amount to add to address register</td>
2356 <td><code>line_diff</code>: amount to change line register by</td>
2366 <td><code>register_num</code>: register that will contain local<br/>
2367 <code>name_idx</code>: string index of the name<br/>
2368 <code>type_idx</code>: type index of the type
2371 <code>name_idx</code> or <code>type_idx</code> may be
2372 <code>NO_INDEX</code> to indicate that that value is unknown.
2383 <td><code>register_num</code>: register that will contain local<br/>
2384 <code>name_idx</code>: string index of the name<br/>
2385 <code>type_idx</code>: type index of the type<br/>
2386 <code>sig_idx</code>: string index of the type signature
2389 Any of <code>name_idx</code>, <code>type_idx</code>, or
2390 <code>sig_idx</code> may be <code>NO_INDEX</code>
2391 to indicate that that value is unknown. (If <code>sig_idx</code> is
2392 <code>-1</code>, though, the same data could be represented more
2393 efficiently using the opcode <code>DBG_START_LOCAL</code>.)
2395 "<code>dalvik.annotation.Signature</code>" below for caveats about
2403 <td><code>register_num</code>: register that contained local</td>
2412 <td><code>register_num</code>: register to restart</td>
2423 <td>sets the <code>prologue_end</code> state machine register,
2426 a method breakpoint). The <code>prologue_end</code> register is
2427 cleared by any special (<code>>= 0x0a</code>) opcode.
2435 <td>sets the <code>epilogue_begin</code> state machine register,
2439 The <code>epilogue_begin</code> register is cleared by any special
2440 (<code>>= 0x0a</code>) opcode.
2447 <td><code>name_idx</code>: string index of source file name;
2448 <code>NO_INDEX</code> if unknown
2452 <code>code_item</code>
2462 <td>advances the <code>line</code> and <code>address</code> registers,
2463 emits a position entry, and clears <code>prologue_end</code> and
2464 <code>epilogue_begin</code>. See below for description.
2472 <p>Opcodes with values between <code>0x0a</code> and <code>0xff</code>
2473 (inclusive) move both the <code>line</code> and <code>address</code>
2506 on the class, or <code>0</code> if the class has no direct annotations.
2508 <code>data</code> section. The format of the data is specified
2509 by "<code>annotation_set_item</code>" below.
2531 be sorted in increasing order, by <code>field_idx</code>.
2538 be sorted in increasing order, by <code>method_idx</code>.
2545 list must be sorted in increasing order, by <code>method_idx</code>.
2551 <p class="note"><strong>Note:</strong> All elements' <code>field_id</code>s and
2552 <code>method_id</code>s must refer to the same defining class.</p>
2568 <td>index into the <code>field_ids</code> list for the identity of the
2576 the field. The offset should be to a location in the <code>data</code>
2578 "<code>annotation_set_item</code>" below.
2598 <td>index into the <code>method_ids</code> list for the identity of the
2607 <code>data</code> section. The format of the data is specified by
2608 "<code>annotation_set_item</code>" below.
2628 <td>index into the <code>method_ids</code> list for the identity of the
2637 <code>data</code> section. The format of the data is specified by
2638 "<code>annotation_set_ref_list</code>" below.
2686 or <code>0</code> if there are no annotations for this element.
2687 The offset, if non-zero, should be to a location in the <code>data</code>
2689 "<code>annotation_set_item</code>" below.
2719 by <code>type_idx</code>.
2740 The offset should be to a location in the <code>data</code> section,
2742 "<code>annotation_item</code>" below.
2772 "<code>encoded_annotation</code> format" under
2773 "<code>encoded_value</code> encoding" above.
2781 <p>These are the options for the <code>visibility</code> field in an
2782 <code>annotation_item</code>:</p>
2797 of other code)
2809 (and not to regular user code)
2833 by "<code>encoded_array</code> Format" under "<code>encoded_value</code>
2844 generally only accessed indirectly by client (non-system) code.</p>
2846 <p>System annotations are represented in <code>.dex</code> files as
2847 annotations with visibility set to <code>VISIBILITY_SYSTEM</code>.
2852 <p>An <code>AnnotationDefault</code> annotation is attached to each
2878 <p>An <code>EnclosingClass</code> annotation is attached to each class
2882 <code>InnerClass</code> annotation. Additionally, a class must not have
2883 both an <code>EnclosingClass</code> and an
2884 <code>EnclosingMethod</code> annotation.</p>
2906 <p>An <code>EnclosingMethod</code> annotation is attached to each class
2908 annotation must also have an <code>InnerClass</code> annotation.
2909 Additionally, a class must not have both an <code>EnclosingClass</code>
2910 and an <code>EnclosingMethod</code> annotation.</p>
2932 <p>An <code>InnerClass</code> annotation is attached to each class
2935 <code>EnclosingClass</code> annotation <i>or</i> an
2936 <code>EnclosingMethod</code> annotation.</p>
2952 <code>null</code>.
2969 <p>A <code>MemberClasses</code> annotation is attached to each class
2993 <p>A <code>Signature</code> annotation is attached to each class,
2995 than is representable by a <code>type_id_item</code>. The
2996 <code>.dex</code> format does not define the format for signatures; it
3008 a <code>Signature</code> annotation is defined as an <i>array</i> of
3013 tools that generate <code>.dex</code> files.</p>
3036 <p>A <code>Throws</code> annotation is attached to each method which is