1. ryanwsmith
  2. APKinspector

Source

APKinspector / androguard / specs / dalvik / dex-format.html

The default branch has multiple heads

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
<title>.dex &mdash; Dalvik Executable Format</title>
<link rel=stylesheet href="dex-format.css">
</head>

<body>

<h1 class="title"><code>.dex</code> &mdash; Dalvik Executable Format</h1>
<p>Copyright &copy; 2007 The Android Open Source Project

<p>This document describes the layout and contents of <code>.dex</code>
files, which are used to hold a set of class definitions and their associated
adjunct data.</p>

<h1>Guide To Types</h1>

<table class="guide">
<thead>
<tr>
  <th>Name</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>byte</td>
  <td>8-bit signed int</td>
</tr>
<tr>
  <td>ubyte</td>
  <td>8-bit unsigned int</td>
</tr>
<tr>
  <td>short</td>
  <td>16-bit signed int, little-endian</td>
</tr>
<tr>
  <td>ushort</td>
  <td>16-bit unsigned int, little-endian</td>
</tr>
<tr>
  <td>int</td>
  <td>32-bit signed int, little-endian</td>
</tr>
<tr>
  <td>uint</td>
  <td>32-bit unsigned int, little-endian</td>
</tr>
<tr>
  <td>long</td>
  <td>64-bit signed int, little-endian</td>
</tr>
<tr>
  <td>ulong</td>
  <td>64-bit unsigned int, little-endian</td>
</tr>
<tr>
  <td>sleb128</td>
  <td>signed LEB128, variable-length (see below)</td>
</tr>
<tr>
  <td>uleb128</td>
  <td>unsigned LEB128, variable-length (see below)</td>
</tr>
<tr>
  <td>uleb128p1</td>
  <td>unsigned LEB128 plus <code>1</code>, variable-length (see below)</td>
</tr>
</tbody>
</table>

<h3>LEB128</h3>

<p>LEB128 ("<b>L</b>ittle-<b>E</b>ndian <b>B</b>ase <b>128</b>") is a
variable-length encoding for
arbitrary signed or unsigned integer quantities. The format was
borrowed from the <a href="http://dwarfstd.org/Dwarf3Std.php">DWARF3</a>
specification. In a <code>.dex</code> file, LEB128 is only ever used to
encode 32-bit quantities.</p>

<p>Each LEB128 encoded value consists of one to five
bytes, which together represent a single 32-bit value. Each
byte has its most significant bit set except for the final byte in the
sequence, which has its most significant bit clear. The remaining
seven bits of each byte are payload, with the least significant seven
bits of the quantity in the first byte, the next seven in the second
byte and so on. In the case of a signed LEB128 (<code>sleb128</code>),
the most significant payload bit of the final byte in the sequence is
sign-extended to produce the final value. In the unsigned case
(<code>uleb128</code>), any bits not explicitly represented are
interpreted as <code>0</code>.

<table class="leb128Bits">
<thead>
<tr><th colspan="16">Bitwise diagram of a two-byte LEB128 value</th></tr>
<tr>
  <th colspan="8">First byte</td>
  <th colspan="8">Second byte</td>
</tr>
</thead>
<tbody>
<tr>
  <td class="start1"><code>1</code></td>
  <td>bit<sub>6</sub></td>
  <td>bit<sub>5</sub></td>
  <td>bit<sub>4</sub></td>
  <td>bit<sub>3</sub></td>
  <td>bit<sub>2</sub></td>
  <td>bit<sub>1</sub></td>
  <td>bit<sub>0</sub></td>
  <td class="start2"><code>0</code></td>
  <td>bit<sub>13</sub></td>
  <td>bit<sub>12</sub></td>
  <td>bit<sub>11</sub></td>
  <td>bit<sub>10</sub></td>
  <td>bit<sub>9</sub></td>
  <td>bit<sub>8</sub></td>
  <td class="end2">bit<sub>7</sub></td>
</tr>
</tbody>
</table>

<p>The variant <code>uleb128p1</code> is used to represent a signed
value, where the representation is of the value <i>plus one</i> encoded
as a <code>uleb128</code>. This makes the encoding of <code>-1</code>
(alternatively thought of as the unsigned value <code>0xffffffff</code>)
&mdash; but no other negative number &mdash; a single byte, and is
useful in exactly those cases where the represented number must either
be non-negative or <code>-1</code> (or <code>0xffffffff</code>),
and where no other negative values are allowed (or where large unsigned
values are unlikely to be needed).</p>

<p>Here are some examples of the formats:</p>

<table class="leb128">
<thead>
<tr>
  <th>Encoded Sequence</th>
  <th>As <code>sleb128</code></th>
  <th>As <code>uleb128</code></th>
  <th>As <code>uleb128p1</code></th>
</tr>
</thead>
<tbody>
  <tr><td>00</td><td>0</td><td>0</td><td>-1</td></tr>
  <tr><td>01</td><td>1</td><td>1</td><td>0</td></tr>
  <tr><td>7f</td><td>-1</td><td>127</td><td>126</td></tr>
  <tr><td>80 7f</td><td>-128</td><td>16256</td><td>16255</td></tr>
</tbody>
</table>

<h1>Overall File Layout</h1>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>header</td>
  <td>header_item</td>
  <td>the header</td>
</tr>
<tr>
  <td>string_ids</td>
  <td>string_id_item[]</td>
  <td>string identifiers list. These are identifiers for all the strings
    used by this file, either for internal naming (e.g., type descriptors)
    or as constant objects referred to by code. This list must be sorted
    by string contents, using UTF-16 code point values (not in a
    locale-sensitive manner).
  </td>
</tr>
<tr>
  <td>type_ids</td>
  <td>type_id_item[]</td>
  <td>type identifiers list. These are identifiers for all types (classes,
    arrays, or primitive types) referred to by this file, whether defined
    in the file or not. This list must be sorted by <code>string_id</code>
    index.
  </td>
</tr>
<tr>
  <td>proto_ids</td>
  <td>proto_id_item[]</td>
  <td>method prototype identifiers list. These are identifiers for all
    prototypes referred to by this file. This list must be sorted in
    return-type (by <code>type_id</code> index) major order, and then
    by arguments (also by <code>type_id</code> index).
  </td>
</tr>
<tr>
  <td>field_ids</td>
  <td>field_id_item[]</td>
  <td>field identifiers list. These are identifiers for all fields
    referred to by this file, whether defined in the file or not. This
    list must be sorted, where the defining type (by <code>type_id</code>
    index) is the major order, field name (by <code>string_id</code> index)
    is the intermediate order, and type (by <code>type_id</code> index)
    is the minor order.
  </td>
</tr>
<tr>
  <td>method_ids</td>
  <td>method_id_item[]</td>
  <td>method identifiers list. These are identifiers for all methods
    referred to by this file, whether defined in the file or not. This
    list must be sorted, where the defining type (by <code>type_id</code>
    index) is the major order, method name (by <code>string_id</code>
    index) is the intermediate order, and method
    prototype (by <code>proto_id</code> index) is the minor order.
  </td>
</tr>
<tr>
  <td>class_defs</td>
  <td>class_def_item[]</td>
  <td>class definitions list. The classes must be ordered such that a given
    class's superclass and implemented interfaces appear in the
    list earlier than the referring class.
  </td>
</tr>
<tr>
  <td>data</td>
  <td>ubyte[]</td>
  <td>data area, containing all the support data for the tables listed above.
    Different items have different alignment requirements, and
    padding bytes are inserted before each item if necessary to achieve
    proper alignment.
  </td>
</tr>
<tr>
  <td>link_data</td>
  <td>ubyte[]</td>
  <td>data used in statically linked files. The format of the data in
    this section is left unspecified by this document;
    this section is empty in unlinked files, and runtime implementations
    may use it as they see fit.
  </td>
</tr>
</tbody>
</table>

<h1>Bitfield, String, and Constant Definitions</h1>

<h2><code>DEX_FILE_MAGIC</code></h2>
<h4>embedded in <code>header_item</code></h4>

<p>The constant array/string <code>DEX_FILE_MAGIC</code> is the list of
bytes that must appear at the beginning of a <code>.dex</code> file
in order for it to be recognized as such. The value intentionally
contains a newline (<code>"\n"</code> or <code>0x0a</code>) and a
null byte (<code>"\0"</code> or <code>0x00</code>) in order to help
in the detection of certain forms of corruption. The value also
encodes a format version number as three decimal digits, which is
expected to increase monotonically over time as the format evolves.</p>

<pre>
ubyte[8] DEX_FILE_MAGIC = { 0x64 0x65 0x78 0x0a 0x30 0x33 0x35 0x00 }
                        = "dex\n035\0"
</pre>

<p><b>Note:</b> At least a couple earlier versions of the format have
been used in widely-available public software releases. For example,
version <code>009</code> was used for the M3 releases of the
Android platform (November-December 2007),
and version <code>013</code> was used for the M5 releases of the Android
platform (February-March 2008). In several respects, these earlier versions
of the format differ significantly from the version described in this
document.</p>

<h2><code>ENDIAN_CONSTANT</code> and <code>REVERSE_ENDIAN_CONSTANT</code></h2>
<h4>embedded in <code>header_item</code></h4>

<p>The constant <code>ENDIAN_CONSTANT</code> is used to indicate the
endianness of the file in which it is found. Although the standard
<code>.dex</code> format is little-endian, implementations may choose
to perform byte-swapping. Should an implementation come across a
header whose <code>endian_tag</code> is <code>REVERSE_ENDIAN_CONSTANT</code>
instead of <code>ENDIAN_CONSTANT</code>, it would know that the file
has been byte-swapped from the expected form.</p>

<pre>
uint ENDIAN_CONSTANT = 0x12345678;
uint REVERSE_ENDIAN_CONSTANT = 0x78563412;
</pre>

<h2><code>NO_INDEX</code></h2>
<h4>embedded in <code>class_def_item</code> and
<code>debug_info_item</code></h4>

<p>The constant <code>NO_INDEX</code> is used to indicate that
an index value is absent.</p>

<p><b>Note:</b> This value isn't defined to be
<code>0</code>, because that is in fact typically a valid index.</p>

<p><b>Also Note:</b> The chosen value for <code>NO_INDEX</code> is
representable as a single byte in the <code>uleb128p1</code> encoding.</p>

<pre>
uint NO_INDEX = 0xffffffff;    // == -1 if treated as a signed int
</pre>

<h2><code>access_flags</code> Definitions</h2>
<h4>embedded in <code>class_def_item</code>,
<code>field_item</code>, <code>method_item</code>, and
<code>InnerClass</code></h4>

<p>Bitfields of these flags are used to indicate the accessibility and
overall properties of classes and class members.</p>

<table class="accessFlags">
<thead>
<tr>
  <th>Name</th>
  <th>Value</th>
  <th>For Classes (and <code>InnerClass</code> annotations)</th>
  <th>For Fields</th>
  <th>For Methods</th>
</tr>
</thead>
<tbody>
<tr>
  <td>ACC_PUBLIC</td>
  <td>0x1</td>
  <td><code>public</code>: visible everywhere</td>
  <td><code>public</code>: visible everywhere</td>
  <td><code>public</code>: visible everywhere</td>
</tr>
<tr>
  <td>ACC_PRIVATE</td>
  <td>0x2</td>
  <td><super>*</super>
    <code>private</code>: only visible to defining class
  </td>
  <td><code>private</code>: only visible to defining class</td>
  <td><code>private</code>: only visible to defining class</td>
</tr>
<tr>
  <td>ACC_PROTECTED</td>
  <td>0x4</td>
  <td><super>*</super>
    <code>protected</code>: visible to package and subclasses
  </td>
  <td><code>protected</code>: visible to package and subclasses</td>
  <td><code>protected</code>: visible to package and subclasses</td>
</tr>
<tr>
  <td>ACC_STATIC</td>
  <td>0x8</td>
  <td><super>*</super>
    <code>static</code>: is not constructed with an outer
    <code>this</code> reference</td>
  <td><code>static</code>: global to defining class</td>
  <td><code>static</code>: does not take a <code>this</code> argument</td>
</tr>
<tr>
  <td>ACC_FINAL</td>
  <td>0x10</td>
  <td><code>final</code>: not subclassable</td>
  <td><code>final</code>: immutable after construction</td>
  <td><code>final</code>: not overridable</td>
</tr>
<tr>
  <td>ACC_SYNCHRONIZED</td>
  <td>0x20</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><code>synchronized</code>: associated lock automatically acquired
    around call to this method. <b>Note:</b> This is only valid to set when
    <code>ACC_NATIVE</code> is also set.</td>
</tr>
<tr>
  <td>ACC_VOLATILE</td>
  <td>0x40</td>
  <td>&nbsp;</td>
  <td><code>volatile</code>: special access rules to help with thread
    safety</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>ACC_BRIDGE</td>
  <td>0x40</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>bridge method, added automatically by compiler as a type-safe
    bridge</td>
</tr>
<tr>
  <td>ACC_TRANSIENT</td>
  <td>0x80</td>
  <td>&nbsp;</td>
  <td><code>transient</code>: not to be saved by default serialization</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>ACC_VARARGS</td>
  <td>0x80</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>last argument should be treated as a "rest" argument by compiler</td>
</tr>
<tr>
  <td>ACC_NATIVE</td>
  <td>0x100</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><code>native</code>: implemented in native code</td>
</tr>
<tr>
  <td>ACC_INTERFACE</td>
  <td>0x200</td>
  <td><code>interface</code>: multiply-implementable abstract class</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>ACC_ABSTRACT</td>
  <td>0x400</td>
  <td><code>abstract</code>: not directly instantiable</td>
  <td>&nbsp;</td>
  <td><code>abstract</code>: unimplemented by this class</td>
</tr>
<tr>
  <td>ACC_STRICT</td>
  <td>0x800</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><code>strictfp</code>: strict rules for floating-point arithmetic</td>
</tr>
<tr>
  <td>ACC_SYNTHETIC</td>
  <td>0x1000</td>
  <td>not directly defined in source code</td>
  <td>not directly defined in source code</td>
  <td>not directly defined in source code</td>
</tr>
<tr>
  <td>ACC_ANNOTATION</td>
  <td>0x2000</td>
  <td>declared as an annotation class</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>ACC_ENUM</td>
  <td>0x4000</td>
  <td>declared as an enumerated type</td>
  <td>declared as an enumerated value</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td><i>(unused)</i></td>
  <td>0x8000</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>ACC_CONSTRUCTOR</td>
  <td>0x10000</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>constructor method (class or instance initializer)</td>
</tr>
<tr>
  <td>ACC_DECLARED_<br/>SYNCHRONIZED</td>
  <td>0x20000</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>declared <code>synchronized</code>. <b>Note:</b> This has no effect on
    execution (other than in reflection of this flag, per se).
  </td>
</tr>
</tbody>
</table>

<p><super>*</super> Only allowed on for <code>InnerClass</code> annotations,
and must not ever be on in a <code>class_def_item</code>.</p>

<h2>MUTF-8 (Modified UTF-8) Encoding</h2>

<p>As a concession to easier legacy support, the <code>.dex</code> format
encodes its string data in a de facto standard modified UTF-8 form, hereafter
referred to as MUTF-8. This form is identical to standard UTF-8, except:</p>

<ul>
  <li>Only the one-, two-, and three-byte encodings are used.</li>
  <li>Code points in the range <code>U+10000</code> &hellip;
    <code>U+10ffff</code> are encoded as a surrogate pair, each of
    which is represented as a three-byte encoded value.</li>
  <li>The code point <code>U+0000</code> is encoded in two-byte form.</li>
  <li>A plain null byte (value <code>0</code>) indicates the end of
    a string, as is the standard C language interpretation.</li>
</ul>

<p>The first two items above can be summarized as: MUTF-8
is an encoding format for UTF-16, instead of being a more direct
encoding format for Unicode characters.</p>

<p>The final two items above make it simultaneously possible to include
the code point <code>U+0000</code> in a string <i>and</i> still manipulate
it as a C-style null-terminated string.</p>

<p>However, the special encoding of <code>U+0000</code> means that, unlike
normal UTF-8, the result of calling the standard C function
<code>strcmp()</code> on a pair of MUTF-8 strings does not always
indicate the properly signed result of comparison of <i>unequal</i> strings.
When ordering (not just equality) is a concern, the most straightforward
way to compare MUTF-8 strings is to decode them character by character,
and compare the decoded values. (However, more clever implementations are
also possible.)</p>

<p>Please refer to <a href="http://unicode.org">The Unicode
Standard</a> for further information about character encoding.
MUTF-8 is actually closer to the (relatively less well-known) encoding
<a href="http://www.unicode.org/reports/tr26/">CESU-8</a> than to UTF-8
per se.</p>

<h2><code>encoded_value</code> Encoding</h2>
<h4>embedded in <code>annotation_element</code> and
<code>encoded_array_item</code></h4>

<p>An <code>encoded_value</code> is an encoded piece of (nearly)
arbitrary hierarchically structured data. The encoding is meant to
be both compact and straightforward to parse.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>(value_arg &lt;&lt; 5) | value_type</td>
  <td>ubyte</td>
  <td>byte indicating the type of the immediately subsequent
    <code>value</code> along
    with an optional clarifying argument in the high-order three bits.
    See below for the various <code>value</code> definitions.
    In most cases, <code>value_arg</code> encodes the length of
    the immediately-subsequent <code>value</code> in bytes, as
    <code>(size - 1)</code>, e.g., <code>0</code> means that
    the value requires one byte, and <code>7</code> means it requires
    eight bytes; however, there are exceptions as noted below.
  </td>
</tr>
<tr>
  <td>value</td>
  <td>ubyte[]</td>
  <td>bytes representing the value, variable in length and interpreted
    differently for different <code>value_type</code> bytes, though
    always little-endian. See the various value definitions below for
    details.
  </td>
</tr>
</tbody>
</table>

<h3>Value Formats</h3>

<table class="encodedValue">
<thead>
<tr>
  <th>Type Name</th>
  <th><code>value_type</code></th>
  <th><code>value_arg</code> Format</th>
  <th><code>value</code> Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>VALUE_BYTE</td>
  <td>0x00</td>
  <td><i>(none; must be <code>0</code>)</i></td>
  <td>ubyte[1]</td>
  <td>signed one-byte integer value</td>
</tr>
<tr>
  <td>VALUE_SHORT</td>
  <td>0x02</td>
  <td>size - 1 (0&hellip;1)</td>
  <td>ubyte[size]</td>
  <td>signed two-byte integer value, sign-extended</td>
</tr>
<tr>
  <td>VALUE_CHAR</td>
  <td>0x03</td>
  <td>size - 1 (0&hellip;1)</td>
  <td>ubyte[size]</td>
  <td>unsigned two-byte integer value, zero-extended</td>
</tr>
<tr>
  <td>VALUE_INT</td>
  <td>0x04</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>signed four-byte integer value, sign-extended</td>
</tr>
<tr>
  <td>VALUE_LONG</td>
  <td>0x06</td>
  <td>size - 1 (0&hellip;7)</td>
  <td>ubyte[size]</td>
  <td>signed eight-byte integer value, sign-extended</td>
</tr>
<tr>
  <td>VALUE_FLOAT</td>
  <td>0x10</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>four-byte bit pattern, zero-extended <i>to the right</i>, and
    interpreted as an IEEE754 32-bit floating point value
  </td>
</tr>
<tr>
  <td>VALUE_DOUBLE</td>
  <td>0x11</td>
  <td>size - 1 (0&hellip;7)</td>
  <td>ubyte[size]</td>
  <td>eight-byte bit pattern, zero-extended <i>to the right</i>, and
    interpreted as an IEEE754 64-bit floating point value
  </td>
</tr>
<tr>
  <td>VALUE_STRING</td>
  <td>0x17</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>unsigned (zero-extended) four-byte integer value,
    interpreted as an index into
    the <code>string_ids</code> section and representing a string value
  </td>
</tr>
<tr>
  <td>VALUE_TYPE</td>
  <td>0x18</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>unsigned (zero-extended) four-byte integer value,
    interpreted as an index into
    the <code>type_ids</code> section and representing a reflective
    type/class value
  </td>
</tr>
<tr>
  <td>VALUE_FIELD</td>
  <td>0x19</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>unsigned (zero-extended) four-byte integer value,
    interpreted as an index into
    the <code>field_ids</code> section and representing a reflective
    field value
  </td>
</tr>
<tr>
  <td>VALUE_METHOD</td>
  <td>0x1a</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>unsigned (zero-extended) four-byte integer value,
    interpreted as an index into
    the <code>method_ids</code> section and representing a reflective
    method value
  </td>
</tr>
<tr>
  <td>VALUE_ENUM</td>
  <td>0x1b</td>
  <td>size - 1 (0&hellip;3)</td>
  <td>ubyte[size]</td>
  <td>unsigned (zero-extended) four-byte integer value,
    interpreted as an index into
    the <code>field_ids</code> section and representing the value of
    an enumerated type constant
  </td>
</tr>
<tr>
  <td>VALUE_ARRAY</td>
  <td>0x1c</td>
  <td><i>(none; must be <code>0</code>)</i></td>
  <td>encoded_array</td>
  <td>an array of values, in the format specified by
    "<code>encoded_array</code> Format" below. The size
    of the <code>value</code> is implicit in the encoding.
  </td>
</tr>
<tr>
  <td>VALUE_ANNOTATION</td>
  <td>0x1d</td>
  <td><i>(none; must be <code>0</code>)</i></td>
  <td>encoded_annotation</td>
  <td>a sub-annotation, in the format specified by
    "<code>encoded_annotation</code> Format" below. The size
    of the <code>value</code> is implicit in the encoding.
  </td>
</tr>
<tr>
  <td>VALUE_NULL</td>
  <td>0x1e</td>
  <td><i>(none; must be <code>0</code>)</i></td>
  <td><i>(none)</i></td>
  <td><code>null</code> reference value</td>
</tr>
<tr>
  <td>VALUE_BOOLEAN</td>
  <td>0x1f</td>
  <td>boolean (0&hellip;1)</td>
  <td><i>(none)</i></td>
  <td>one-bit value; <code>0</code> for <code>false</code> and
    <code>1</code> for <code>true</code>. The bit is represented in the
    <code>value_arg</code>.
  </td>
</tr>
</tbody>
</table>

<h3><code>encoded_array</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uleb128</td>
  <td>number of elements in the array</td>
</tr>
<tr>
  <td>values</td>
  <td>encoded_value[size]</td>
  <td>a series of <code>size</code> <code>encoded_value</code> byte
    sequences in the format specified by this section, concatenated
    sequentially.
  </td>
</tr>
</tbody>
</table>

<h3><code>encoded_annotation</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>type_idx</td>
  <td>uleb128</td>
  <td>type of the annotation. This must be a class (not array or primitive)
    type.
  </td>
</tr>
<tr>
  <td>size</td>
  <td>uleb128</td>
  <td>number of name-value mappings in this annotation</td>
</tr>
<tr>
  <td>elements</td>
  <td>annotation_element[size]</td>
  <td>elements of the annotataion, represented directly in-line (not as
    offsets). Elements must be sorted in increasing order by
    <code>string_id</code> index.
  </td>
</tr>
</tbody>
</table>

<h3><code>annotation_element</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>name_idx</td>
  <td>uleb128</td>
  <td>element name, represented as an index into the
    <code>string_ids</code> section. The string must conform to the
    syntax for <i>MemberName</i>, defined above.
  </td>
</tr>
<tr>
  <td>value</td>
  <td>encoded_value</td>
  <td>element value</td>
</tr>
</tbody>
</table>

<h2>String Syntax</h2>

<p>There are several kinds of item in a <code>.dex</code> file which
ultimately refer to a string. The following BNF-style definitions
indicate the acceptable syntax for these strings.</p>

<h3><i>SimpleName</i></h3>

<p>A <i>SimpleName</i> is the basis for the syntax of the names of other
things. The <code>.dex</code> format allows a fair amount of latitude
here (much more than most common source languages). In brief, a simple
name may consist of any low-ASCII alphabetic character or digit, a few
specific low-ASCII symbols, and most non-ASCII code points that are not
control, space, or special characters. Note that surrogate code points
(in the range <code>U+d800</code> &hellip; <code>U+dfff</code>) are not
considered valid name characters, per se, but Unicode supplemental
characters <i>are</i> valid (which are represented by the final
alternative of the rule for <i>SimpleNameChar</i>), and they should be
represented in a file as pairs of surrogate code points in the MUTF-8
encoding.</p>

<table class="bnf">
  <tr><td colspan="2" class="def"><i>SimpleName</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><i>SimpleNameChar</i> (<i>SimpleNameChar</i>)*</td>
  </tr>

  <tr><td colspan="2" class="def"><i>SimpleNameChar</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><code>'A'</code> &hellip; <code>'Z'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'a'</code> &hellip; <code>'z'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'0'</code> &hellip; <code>'9'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'$'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'-'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'_'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>U+00a1</code> &hellip; <code>U+1fff</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>U+2010</code> &hellip; <code>U+2027</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>U+2030</code> &hellip; <code>U+d7ff</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>U+e000</code> &hellip; <code>U+ffef</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>U+10000</code> &hellip; <code>U+10ffff</code></td>
  </tr>
</table>

<h3><i>MemberName</i></h3>
<h4>used by <code>field_id_item</code> and <code>method_id_item</code></h4>

<p>A <i>MemberName</i> is the name of a member of a class, members being
fields, methods, and inner classes.</p>

<table class="bnf">
  <tr><td colspan="2" class="def"><i>MemberName</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><i>SimpleName</i></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'&lt;'</code> <i>SimpleName</i> <code>'&gt;'</code></td>
  </tr>
</table>

<h3><i>FullClassName</i></h3>

<p>A <i>FullClassName</i> is a fully-qualified class name, including an
optional package specifier followed by a required name.</p>

<table class="bnf">
  <tr><td colspan="2" class="def"><i>FullClassName</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><i>OptionalPackagePrefix</i> <i>SimpleName</i></td>
  </tr>

  <tr><td colspan="2" class="def"><i>OptionalPackagePrefix</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td>(<i>SimpleName</i> <code>'/'</code>)*</td>
  </tr>
</table>

<h3><i>TypeDescriptor</i></h3>
<h4>used by <code>type_id_item</code></h4>

<p>A <i>TypeDescriptor</i> is the representation of any type, including
primitives, classes, arrays, and <code>void</code>. See below for
the meaning of the various versions.</p>

<table class="bnf">
  <tr><td colspan="2" class="def"><i>TypeDescriptor</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><code>'V'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><i>FieldTypeDescriptor</i></td>
  </tr>

  <tr><td colspan="2" class="def"><i>FieldTypeDescriptor</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><i>NonArrayFieldTypeDescriptor</i></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td>(<code>'['</code> * 1&hellip;255)
      <i>NonArrayFieldTypeDescriptor</i></td>
  </tr>

  <tr>
    <td colspan="2" class="def"><i>NonArrayFieldTypeDescriptor</i>&rarr;</td>
  </tr>
  <tr>
    <td/>
    <td><code>'Z'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'B'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'S'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'C'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'I'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'J'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'F'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'D'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'L'</code> <i>FullClassName</i> <code>';'</code></td>
  </tr>
</table>

<h3><i>ShortyDescriptor</i></h3>
<h4>used by <code>proto_id_item</code></h4>

<p>A <i>ShortyDescriptor</i> is the short form representation of a method
prototype, including return and parameter types, except that there is
no distinction between various reference (class or array) types. Instead,
all reference types are represented by a single <code>'L'</code> character.</p>

<table class="bnf">
  <tr><td colspan="2" class="def"><i>ShortyDescriptor</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><i>ShortyReturnType</i> (<i>ShortyFieldType</i>)*</td>
  </tr>

  <tr><td colspan="2" class="def"><i>ShortyReturnType</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><code>'V'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><i>ShortyFieldType</i></td>
  </tr>

  <tr><td colspan="2" class="def"><i>ShortyFieldType</i> &rarr;</td></tr>
  <tr>
    <td/>
    <td><code>'Z'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'B'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'S'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'C'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'I'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'J'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'F'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'D'</code></td>
  </tr>
  <tr>
    <td class="bar">|</td>
    <td><code>'L'</code></td>
  </tr>
</table>

<h2><i>TypeDescriptor</i> Semantics</h2>

<p>This is the meaning of each of the variants of <i>TypeDescriptor</i>.</p>

<table class="descriptor">
<thead>
<tr>
  <th>Syntax</th>
  <th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
  <td>V</td>
  <td><code>void</code>; only valid for return types</td>
</tr>
<tr>
  <td>Z</td>
  <td><code>boolean</code></td>
</tr>
<tr>
  <td>B</td>
  <td><code>byte</code></td>
</tr>
<tr>
  <td>S</td>
  <td><code>short</code></td>
</tr>
<tr>
  <td>C</td>
  <td><code>char</code></td>
</tr>
<tr>
  <td>I</td>
  <td><code>int</code></td>
</tr>
<tr>
  <td>J</td>
  <td><code>long</code></td>
</tr>
<tr>
  <td>F</td>
  <td><code>float</code></td>
</tr>
<tr>
  <td>D</td>
  <td><code>double</code></td>
</tr>
<tr>
  <td>L<i>fully/qualified/Name</i>;</td>
  <td>the class <code><i>fully.qualified.Name</i></code></td>
</tr>
<tr>
  <td>[<i>descriptor</i></td>
  <td>array of <code><i>descriptor</i></code>, usable recursively for
    arrays-of-arrays, though it is invalid to have more than 255
    dimensions.
  </td>
</tr>
</tbody>
</table>

<h1>Items and Related Structures</h1>

<p>This section includes definitions for each of the top-level items that
may appear in a <code>.dex</code> file.

<h2><code>header_item</code></h2>
<h4>appears in the <code>header</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>magic</td>
  <td>ubyte[8] = DEX_FILE_MAGIC</td>
  <td>magic value. See discussion above under "<code>DEX_FILE_MAGIC</code>"
    for more details.
  </td>
</tr>
<tr>
  <td>checksum</td>
  <td>uint</td>
  <td>adler32 checksum of the rest of the file (everything but
    <code>magic</code> and this field); used to detect file corruption
  </td>
</tr>
<tr>
  <td>signature</td>
  <td>ubyte[20]</td>
  <td>SHA-1 signature (hash) of the rest of the file (everything but
    <code>magic</code>, <code>checksum</code>, and this field); used
    to uniquely identify files
  </td>
</tr>
<tr>
  <td>file_size</td>
  <td>uint</td>
  <td>size of the entire file (including the header), in bytes
</tr>
<tr>
  <td>header_size</td>
  <td>uint = 0x70</td>
  <td>size of the header (this entire section), in bytes. This allows for at
    least a limited amount of backwards/forwards compatibility without
    invalidating the format.
  </td>
</tr>
<tr>
  <td>endian_tag</td>
  <td>uint = ENDIAN_CONSTANT</td>
  <td>endianness tag. See discussion above under "<code>ENDIAN_CONSTANT</code>
    and <code>REVERSE_ENDIAN_CONSTANT</code>" for more details.
  </td>
</tr>
<tr>
  <td>link_size</td>
  <td>uint</td>
  <td>size of the link section, or <code>0</code> if this file isn't
    statically linked</td>
</tr>
<tr>
  <td>link_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the link section, or
    <code>0</code> if <code>link_size == 0</code>. The offset, if non-zero,
    should be to an offset into the <code>link_data</code> section. The
    format of the data pointed at is left unspecified by this document;
    this header field (and the previous) are left as hooks for use by
    runtime implementations.
  </td>
</tr>
<tr>
  <td>map_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the map item, or
    <code>0</code> if this file has no map. The offset, if non-zero,
    should be to an offset into the <code>data</code> section,
    and the data should be in the format specified by "<code>map_list</code>"
    below.
  </td>
</tr>
<tr>
  <td>string_ids_size</td>
  <td>uint</td>
  <td>count of strings in the string identifiers list</td>
</tr>
<tr>
  <td>string_ids_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the string identifiers list, or
    <code>0</code> if <code>string_ids_size == 0</code> (admittedly a
    strange edge case). The offset, if non-zero,
    should be to the start of the <code>string_ids</code> section.
  </td>
</tr>
<tr>
  <td>type_ids_size</td>
  <td>uint</td>
  <td>count of elements in the type identifiers list</td>
</tr>
<tr>
  <td>type_ids_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the type identifiers list, or
    <code>0</code> if <code>type_ids_size == 0</code> (admittedly a
    strange edge case). The offset, if non-zero,
    should be to the start of the <code>type_ids</code>
    section.
  </td>
</tr>
<tr>
  <td>proto_ids_size</td>
  <td>uint</td>
  <td>count of elements in the prototype identifiers list</td>
</tr>
<tr>
  <td>proto_ids_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the prototype identifiers list, or
    <code>0</code> if <code>proto_ids_size == 0</code> (admittedly a
    strange edge case). The offset, if non-zero,
    should be to the start of the <code>proto_ids</code>
    section.
  </td>
</tr>
<tr>
  <td>field_ids_size</td>
  <td>uint</td>
  <td>count of elements in the field identifiers list</td>
</tr>
<tr>
  <td>field_ids_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the field identifiers list, or
    <code>0</code> if <code>field_ids_size == 0</code>. The offset, if
    non-zero, should be to the start of the <code>field_ids</code>
    section.</td>
</td>
</tr>
<tr>
  <td>method_ids_size</td>
  <td>uint</td>
  <td>count of elements in the method identifiers list</td>
</tr>
<tr>
  <td>method_ids_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the method identifiers list, or
    <code>0</code> if <code>method_ids_size == 0</code>. The offset, if
    non-zero, should be to the start of the <code>method_ids</code>
    section.</td>
</tr>
<tr>
  <td>class_defs_size</td>
  <td>uint</td>
  <td>count of elements in the class definitions list</td>
</tr>
<tr>
  <td>class_defs_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the class definitions list, or
    <code>0</code> if <code>class_defs_size == 0</code> (admittedly a
    strange edge case). The offset, if non-zero,
    should be to the start of the <code>class_defs</code> section.
  </td>
</tr>
<tr>
  <td>data_size</td>
  <td>uint</td>
  <td>Size of <code>data</code> section in bytes. Must be an even
    multiple of sizeof(uint).</td>
</tr>
<tr>
  <td>data_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the start of the 
   <code>data</code> section.
  </td>
</tr>
</tbody>
</table>

<h2><code>map_list</code></h2>
<h4>appears in the <code>data</code> section</h4>
<h4>referenced from <code>header_item</code></h4>
<h4>alignment: 4 bytes</h4>

<p>This is a list of the entire contents of a file, in order. It
contains some redundancy with respect to the <code>header_item</code>
but is intended to be an easy form to use to iterate over an entire
file. A given type may appear at most once in a map, but there is no
restriction on what order types may appear in, other than the
restrictions implied by the rest of the format (e.g., a
<code>header</code> section must appear first, followed by a
<code>string_ids</code> section, etc.). Additionally, the map entries must
be ordered by initial offset and must not overlap.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uint</td>
  <td>size of the list, in entries</td>
</tr>
<tr>
  <td>list</td>
  <td>map_item[size]</td>
  <td>elements of the list</td>
</tr>
</tbody>
</table>

<h3><code>map_item</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>type</td>
  <td>ushort</td>
  <td>type of the items; see table below</td>
</tr>
<tr>
  <td>unused</td>
  <td>ushort</td>
  <td><i>(unused)</i></td>
</tr>
<tr>
  <td>size</td>
  <td>uint</td>
  <td>count of the number of items to be found at the indicated offset</td>
</tr>
<tr>
  <td>offset</td>
  <td>uint</td>
  <td>offset from the start of the file to the items in question</td>
</tr>
</tbody>
</table>


<h3>Type Codes</h3>

<table class="typeCodes">
<thead>
<tr>
  <th>Item Type</th>
  <th>Constant</th>
  <th>Value</th>
  <th>Item Size In Bytes</th>
</tr>
</thead>
<tbody>
<tr>
  <td>header_item</td>
  <td>TYPE_HEADER_ITEM</td>
  <td>0x0000</td>
  <td>0x70</td>
</tr>
<tr>
  <td>string_id_item</td>
  <td>TYPE_STRING_ID_ITEM</td>
  <td>0x0001</td>
  <td>0x04</td>
</tr>
<tr>
  <td>type_id_item</td>
  <td>TYPE_TYPE_ID_ITEM</td>
  <td>0x0002</td>
  <td>0x04</td>
</tr>
<tr>
  <td>proto_id_item</td>
  <td>TYPE_PROTO_ID_ITEM</td>
  <td>0x0003</td>
  <td>0x0c</td>
</tr>
<tr>
  <td>field_id_item</td>
  <td>TYPE_FIELD_ID_ITEM</td>
  <td>0x0004</td>
  <td>0x08</td>
</tr>
<tr>
  <td>method_id_item</td>
  <td>TYPE_METHOD_ID_ITEM</td>
  <td>0x0005</td>
  <td>0x08</td>
</tr>
<tr>
  <td>class_def_item</td>
  <td>TYPE_CLASS_DEF_ITEM</td>
  <td>0x0006</td>
  <td>0x20</td>
</tr>
<tr>
  <td>map_list</td>
  <td>TYPE_MAP_LIST</td>
  <td>0x1000</td>
  <td>4 + (item.size * 12)</td>
</tr>
<tr>
  <td>type_list</td>
  <td>TYPE_TYPE_LIST</td>
  <td>0x1001</td>
  <td>4 + (item.size * 2)</td>
</tr>
<tr>
  <td>annotation_set_ref_list</td>
  <td>TYPE_ANNOTATION_SET_REF_LIST</td>
  <td>0x1002</td>
  <td>4 + (item.size * 4)</td>
</tr>
<tr>
  <td>annotation_set_item</td>
  <td>TYPE_ANNOTATION_SET_ITEM</td>
  <td>0x1003</td>
  <td>4 + (item.size * 4)</td>
</tr>
<tr>
  <td>class_data_item</td>
  <td>TYPE_CLASS_DATA_ITEM</td>
  <td>0x2000</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>code_item</td>
  <td>TYPE_CODE_ITEM</td>
  <td>0x2001</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>string_data_item</td>
  <td>TYPE_STRING_DATA_ITEM</td>
  <td>0x2002</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>debug_info_item</td>
  <td>TYPE_DEBUG_INFO_ITEM</td>
  <td>0x2003</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>annotation_item</td>
  <td>TYPE_ANNOTATION_ITEM</td>
  <td>0x2004</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>encoded_array_item</td>
  <td>TYPE_ENCODED_ARRAY_ITEM</td>
  <td>0x2005</td>
  <td><i>implicit; must parse</i></td>
</tr>
<tr>
  <td>annotations_directory_item</td>
  <td>TYPE_ANNOTATIONS_DIRECTORY_ITEM</td>
  <td>0x2006</td>
  <td><i>implicit; must parse</i></td>
</tr>
</tbody>
</table>


<h2><code>string_id_item</code></h2>
<h4>appears in the <code>string_ids</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>string_data_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the string data for this
    item. The offset should be to a location
    in the <code>data</code> section, and the data should be in the
    format specified by "<code>string_data_item</code>" below.
    There is no alignment requirement for the offset.
  </td>
</tr>
</tbody>
</table>

<h2><code>string_data_item</code></h2>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: none (byte-aligned)</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>utf16_size</td>
  <td>uleb128</td>
  <td>size of this string, in UTF-16 code units (which is the "string
    length" in many systems). That is, this is the decoded length of
    the string. (The encoded length is implied by the position of
    the <code>0</code> byte.)</td>
</tr>
<tr>
  <td>data</td>
  <td>ubyte[]</td>
  <td>a series of MUTF-8 code units (a.k.a. octets, a.k.a. bytes)
    followed by a byte of value <code>0</code>. See 
    "MUTF-8 (Modified UTF-8) Encoding" above for details and
    discussion about the data format.
    <p><b>Note:</b> It is acceptable to have a string which includes
    (the encoded form of) UTF-16 surrogate code units (that is,
    <code>U+d800</code> &hellip; <code>U+dfff</code>)
    either in isolation or out-of-order with respect to the usual
    encoding of Unicode into UTF-16. It is up to higher-level uses of
    strings to reject such invalid encodings, if appropriate.</p>
  </td>
</tr>
</tbody>
</table>

<h2><code>type_id_item</code></h2>
<h4>appears in the <code>type_ids</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>descriptor_idx</td>
  <td>uint</td>
  <td>index into the <code>string_ids</code> list for the descriptor
    string of this type. The string must conform to the syntax for
    <i>TypeDescriptor</i>, defined above.
  </td>
</tr>
</tbody>
</table>

<h2><code>proto_id_item</code></h2>
<h4>appears in the <code>proto_ids</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>shorty_idx</td>
  <td>uint</td>
  <td>index into the <code>string_ids</code> list for the short-form
    descriptor string of this prototype. The string must conform to the
    syntax for <i>ShortyDescriptor</i>, defined above, and must correspond
    to the return type and parameters of this item.
  </td>
</tr>
<tr>
  <td>return_type_idx</td>
  <td>uint</td>
  <td>index into the <code>type_ids</code> list for the return type
    of this prototype
  </td>
</tr>
<tr>
  <td>parameters_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of parameter types
    for this prototype, or <code>0</code> if this prototype has no
    parameters. This offset, if non-zero, should be in the
    <code>data</code> section, and the data there should be in the
    format specified by <code>"type_list"</code> below. Additionally, there
    should be no reference to the type <code>void</code> in the list.
  </td>
</tr>
</tbody>
</table>

<h2><code>field_id_item</code></h2>
<h4>appears in the <code>field_ids</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>class_idx</td>
  <td>ushort</td>
  <td>index into the <code>type_ids</code> list for the definer of this
    field. This must be a class type, and not an array or primitive type.
  </td>
</tr>
<tr>
  <td>type_idx</td>
  <td>ushort</td>
  <td>index into the <code>type_ids</code> list for the type of
    this field
  </td>
</tr>
<tr>
  <td>name_idx</td>
  <td>uint</td>
  <td>index into the <code>string_ids</code> list for the name of this
    field. The string must conform to the syntax for <i>MemberName</i>,
    defined above.
  </td>
</tr>
</tbody>
</table>

<h2><code>method_id_item</code></h2>
<h4>appears in the <code>method_ids</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>class_idx</td>
  <td>ushort</td>
  <td>index into the <code>type_ids</code> list for the definer of this
    method. This must be a class or array type, and not a primitive type.
  </td>
</tr>
<tr>
  <td>proto_idx</td>
  <td>ushort</td>
  <td>index into the <code>proto_ids</code> list for the prototype of
    this method
  </td>
</tr>
<tr>
  <td>name_idx</td>
  <td>uint</td>
  <td>index into the <code>string_ids</code> list for the name of this
    method. The string must conform to the syntax for <i>MemberName</i>,
    defined above.
  </td>
</tr>
</tbody>
</table>

<h2><code>class_def_item</code></h2>
<h4>appears in the <code>class_defs</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>class_idx</td>
  <td>uint</td>
  <td>index into the <code>type_ids</code> list for this class.
    This must be a class type, and not an array or primitive type.
  </td>
</tr>
<tr>
  <td>access_flags</td>
  <td>uint</td>
  <td>access flags for the class (<code>public</code>, <code>final</code>,
    etc.). See "<code>access_flags</code> Definitions" for details.
  </td>
</tr>
<tr>
  <td>superclass_idx</td>
  <td>uint</td>
  <td>index into the <code>type_ids</code> list for the superclass, or
    the constant value <code>NO_INDEX</code> if this class has no
    superclass (i.e., it is a root class such as <code>Object</code>).
    If present, this must be a class type, and not an array or primitive type.
  </td>
</tr>
<tr>
  <td>interfaces_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of interfaces, or
    <code>0</code> if there are none. This offset
    should be in the <code>data</code> section, and the data
    there should be in the format specified by
    "<code>type_list</code>" below. Each of the elements of the list
    must be a class type (not an array or primitive type), and there
    must not be any duplicates.
  </td>
</tr>
<tr>
  <td>source_file_idx</td>
  <td>uint</td>
  <td>index into the <code>string_ids</code> list for the name of the
    file containing the original source for (at least most of) this class,
    or the special value <code>NO_INDEX</code> to represent a lack of
    this information. The <code>debug_info_item</code> of any given method
    may override this source file, but the expectation is that most classes
    will only come from one source file.
  </td>
</tr>
<tr>
  <td>annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the annotations structure
    for this class, or <code>0</code> if there are no annotations on
    this class. This offset, if non-zero, should be in the
    <code>data</code> section, and the data there should be in
    the format specified by "<code>annotations_directory_item</code>" below,
    with all items referring to this class as the definer.
  </td>
</tr>
<tr>
  <td>class_data_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the associated
    class data for this item, or <code>0</code> if there is no class
    data for this class. (This may be the case, for example, if this class
    is a marker interface.) The offset, if non-zero, should be in the
    <code>data</code> section, and the data there should be in the
    format specified by "<code>class_data_item</code>" below, with all
    items referring to this class as the definer.
  </td>
</tr>
<tr>
  <td>static_values_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of initial
    values for <code>static</code> fields, or <code>0</code> if there
    are none (and all <code>static</code> fields are to be initialized with
    <code>0</code> or <code>null</code>). This offset should be in the
    <code>data</code> section, and the data there should be in the
    format specified by "<code>encoded_array_item</code>" below. The size
    of the array must be no larger than the number of <code>static</code>
    fields declared by this class, and the elements correspond to the
    <code>static</code> fields in the same order as declared in the
    corresponding <code>field_list</code>. The type of each array
    element must match the declared type of its corresponding field.
    If there are fewer elements in the array than there are
    <code>static</code> fields, then the leftover fields are initialized
    with a type-appropriate <code>0</code> or <code>null</code>.
  </td>
</tr>
</tbody>
</table>

<h2><code>class_data_item</code></h2>
<h4>referenced from <code>class_def_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: none (byte-aligned)</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>static_fields_size</td>
  <td>uleb128</td>
  <td>the number of static fields defined in this item</td>
</tr>
<tr>
  <td>instance_fields_size</td>
  <td>uleb128</td>
  <td>the number of instance fields defined in this item</td>
</tr>
<tr>
  <td>direct_methods_size</td>
  <td>uleb128</td>
  <td>the number of direct methods defined in this item</td>
</tr>
<tr>
  <td>virtual_methods_size</td>
  <td>uleb128</td>
  <td>the number of virtual methods defined in this item</td>
</tr>
<tr>
  <td>static_fields</td>
  <td>encoded_field[static_fields_size]</td>
  <td>the defined static fields, represented as a sequence of
    encoded elements. The fields must be sorted by
    <code>field_idx</code> in increasing order.
  </td>
</tr>
<tr>
  <td>instance_fields</td>
  <td>encoded_field[instance_fields_size]</td>
  <td>the defined instance fields, represented as a sequence of
    encoded elements. The fields must be sorted by
    <code>field_idx</code> in increasing order.
  </td>
</tr>
<tr>
  <td>direct_methods</td>
  <td>encoded_method[direct_methods_size]</td>
  <td>the defined direct (any of <code>static</code>, <code>private</code>,
    or constructor) methods, represented as a sequence of
    encoded elements. The methods must be sorted by
    <code>method_idx</code> in increasing order.
  </td>
</tr>
<tr>
  <td>virtual_methods</td>
  <td>encoded_method[virtual_methods_size]</td>
  <td>the defined virtual (none of <code>static</code>, <code>private</code>,
    or constructor) methods, represented as a sequence of
    encoded elements. This list should <i>not</i> include inherited
    methods unless overridden by the class that this item represents. The
    methods must be sorted by <code>method_idx</code> in increasing order.
  </td>
</tr>
</tbody>
</table>

<p><b>Note:</b> All elements' <code>field_id</code>s and 
<code>method_id</code>s must refer to the same defining class.</p>

<h3><code>encoded_field</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>field_idx_diff</td>
  <td>uleb128</td>
  <td>index into the <code>field_ids</code> list for the identity of this
    field (includes the name and descriptor), represented as a difference
    from the index of previous element in the list. The index of the
    first element in a list is represented directly.
  </td>
</tr>
<tr>
  <td>access_flags</td>
  <td>uleb128</td>
  <td>access flags for the field (<code>public</code>, <code>final</code>,
    etc.). See "<code>access_flags</code> Definitions" for details.
  </td>
</tr>
</tbody>
</table>

<h3><code>encoded_method</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>method_idx_diff</td>
  <td>uleb128</td>
  <td>index into the <code>method_ids</code> list for the identity of this
    method (includes the name and descriptor), represented as a difference
    from the index of previous element in the list. The index of the
    first element in a list is represented directly.
  </td>
</tr>
<tr>
  <td>access_flags</td>
  <td>uleb128</td>
  <td>access flags for the method (<code>public</code>, <code>final</code>,
    etc.). See "<code>access_flags</code> Definitions" for details.
  </td>
</tr>
<tr>
  <td>code_off</td>
  <td>uleb128</td>
  <td>offset from the start of the file to the code structure for this
    method, or <code>0</code> if this method is either <code>abstract</code>
    or <code>native</code>. The offset should be to a location in the
    <code>data</code> section. The format of the data is specified by
    "<code>code_item</code>" below.
  </td>
</tr>
</tbody>
</table>

<h2><code>type_list</code></h2>
<h4>referenced from <code>class_def_item</code> and
<code>proto_id_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uint</td>
  <td>size of the list, in entries</td>
</tr>
<tr>
  <td>list</td>
  <td>type_item[size]</td>
  <td>elements of the list</td>
</tr>
</tbody>
</table>

<h3><code>type_item</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>type_idx</td>
  <td>ushort</td>
  <td>index into the <code>type_ids</code> list</td>
</tr>
</tbody>
</table>

<h2><code>code_item</code></h2>
<h4>referenced from <code>method_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>registers_size</td>
  <td>ushort</td>
  <td>the number of registers used by this code</td>
</tr>
<tr>
  <td>ins_size</td>
  <td>ushort</td>
  <td>the number of words of incoming arguments to the method that this
    code is for</td>
</tr>
<tr>
  <td>outs_size</td>
  <td>ushort</td>
  <td>the number of words of outgoing argument space required by this
    code for method invocation
  </td>
</tr>
<tr>
  <td>tries_size</td>
  <td>ushort</td>
  <td>the number of <code>try_item</code>s for this instance. If non-zero,
    then these appear as the <code>tries</code> array just after the
    <code>insns</code> in this instance.
  </td>
</tr>
<tr>
  <td>debug_info_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the debug info (line numbers + 
    local variable info) sequence for this code, or <code>0</code> if 
    there simply is no information. The offset, if non-zero, should be 
    to a location in the <code>data</code> section. The format of 
    the data is specified by "<code>debug_info_item</code>" below.
  </td>
</tr>
<tr>
  <td>insns_size</td>
  <td>uint</td>
  <td>size of the instructions list, in 16-bit code units</td>
</tr>
<tr>
  <td>insns</td>
  <td>ushort[insns_size]</td>
  <td>actual array of bytecode. The format of code in an <code>insns</code>
    array is specified by the companion document
    <a href="dalvik-bytecode.html">"Bytecode for the Dalvik VM"</a>. Note
    that though this is defined as an array of <code>ushort</code>, there
    are some internal structures that prefer four-byte alignment. Also,
    if this happens to be in an endian-swapped file, then the swapping is
    <i>only</i> done on individual <code>ushort</code>s and not on the
    larger internal structures.
  </td>
</tr>
<tr>
  <td>padding</td>
  <td>ushort <i>(optional)</i> = 0</td>
  <td>two bytes of padding to make <code>tries</code> four-byte aligned.
    This element is only present if <code>tries_size</code> is non-zero
    and <code>insns_size</code> is odd.
  </td>
</tr>
<tr>
  <td>tries</td>
  <td>try_item[tries_size] <i>(optional)</i></td>
  <td>array indicating where in the code exceptions may be caught and
    how to handle them. Elements of the array must be non-overlapping in
    range and in order from low to high address. This element is only
    present if <code>tries_size</code> is non-zero.
  </td>
</tr>
<tr>
  <td>handlers</td>
  <td>encoded_catch_handler_list <i>(optional)</i></td>
  <td>bytes representing a list of lists of catch types and associated
    handler addresses. Each <code>try_item</code> has a byte-wise offset
    into this structure. This element is only present if
    <code>tries_size</code> is non-zero.
  </td>
</tr>
</tbody>
</table>

<h3><code>try_item</code> Format </h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>start_addr</td>
  <td>uint</td>
  <td>start address of the block of code covered by this entry. The address
    is a count of 16-bit code units to the start of the first covered
    instruction.
  </td>
</tr>
<tr>
  <td>insn_count</td>
  <td>ushort</td>
  <td>number of 16-bit code units covered by this entry. The last code
    unit covered (inclusive) is <code>start_addr + insn_count - 1</code>.
  </td>
</tr>
<tr>
  <td>handler_off</td>
  <td>ushort</td>
  <td>offset in bytes from the start of the associated encoded handler data
    to the <code>catch_handler_item</code> for this entry
  </td>
</tr>
</tbody>
</table>

<h3><code>encoded_catch_handler_list</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uleb128</td>
  <td>size of this list, in entries</td>
</tr>
<tr>
  <td>list</td>
  <td>encoded_catch_handler[handlers_size]</td>
  <td>actual list of handler lists, represented directly (not as offsets),
    and concatenated sequentially</td>
</tr>
</tbody>
</table>

<h3><code>encoded_catch_handler</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>sleb128</td>
  <td>number of catch types in this list. If non-positive, then this is
    the negative of the number of catch types, and the catches are followed
    by a catch-all handler. For example: A <code>size</code> of <code>0</code>
    means that there is a catch-all but no explicitly typed catches.
    A <code>size</code> of <code>2</code> means that there are two explicitly
    typed catches and no catch-all. And a <code>size</code> of <code>-1</code>
    means that there is one typed catch along with a catch-all.
  </td>
</tr>
<tr>
  <td>handlers</td>
  <td>encoded_type_addr_pair[abs(size)]</td>
  <td>stream of <code>abs(size)</code> encoded items, one for each caught
    type, in the order that the types should be tested.
  </td>
</tr>
<tr>
  <td>catch_all_addr</td>
  <td>uleb128 <i>(optional)</i></td>
  <td>bytecode address of the catch-all handler. This element is only
    present if <code>size</code> is non-positive.
  </td>
</tr>
</tbody>
</table>

<h3><code>encoded_type_addr_pair</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>type_idx</td>
  <td>uleb128</td>
  <td>index into the <code>type_ids</code> list for the type of the
    exception to catch
  </td>
</tr>
<tr>
  <td>addr</td>
  <td>uleb128</td>
  <td>bytecode address of the associated exception handler</td>
</tr>
</tbody>
</table>

<h2><code>debug_info_item</code></h2>
<h4>referenced from <code>code_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: none (byte-aligned)</h4>

<p>Each <code>debug_info_item</code> defines a DWARF3-inspired byte-coded
state machine that, when interpreted, emits the positions
table and (potentially) the local variable information for a
<code>code_item</code>. The sequence begins with a variable-length
header (the length of which depends on the number of method
parameters), is followed by the state machine bytecodes, and ends
with an <code>DBG_END_SEQUENCE</code> byte.</p>

<p>The state machine consists of five registers. The
<code>address</code> register represents the instruction offset in the
associated <code>insns_item</code> in 16-bit code units. The
<code>address</code> register starts at <code>0</code> at the beginning of each
<code>debug_info</code> sequence and may only monotonically increase.
The <code>line</code> register represents what source line number
should be associated with the next positions table entry emitted by
the state machine. It is initialized in the sequence header, and may
change in positive or negative directions but must never be less than
<code>1</code>. The <code>source_file</code> register represents the 
source file that the line number entries refer to. It is initialized to
the value of <code>source_file_idx</code> in <code>class_def_item</code>.
The other two variables, <code>prologue_end</code> and
<code>epilogue_begin</code>, are boolean flags (initialized to
<code>false</code>) that indicate whether the next position emitted
should be considered a method prologue or epilogue. The state machine
must also track the name and type of the last local variable live in
each register for the <code>DBG_RESTART_LOCAL</code> code.</p>

<p>The header is as follows:</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
 <td>line_start</td>
 <td>uleb128</td>
 <td>the initial value for the state machine's <code>line</code> register. 
    Does not represent an actual positions entry.
 </td>
</tr>
<tr>
 <td>parameters_size</td>
 <td>uleb128</td>
 <td>the number of parameter names that are encoded. There should be
   one per method parameter, excluding an instance method's <code>this</code>,
   if any.
 </td>
</tr>
<tr>
 <td>parameter_names</td>
 <td>uleb128p1[parameters_size]</td>
 <td>string index of the method parameter name. An encoded value of
   <code>NO_INDEX</code> indicates that no name
   is available for the associated parameter. The type descriptor
   and signature are implied from the method descriptor and signature.
 </td>
</tr>
</tbody>
</table>

<p>The byte code values are as follows:</p>

<table class="debugByteCode">
<thead>
<tr>
  <th>Name</th>
  <th>Value</th>
  <th>Format</th>
  <th>Arguments</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>DBG_END_SEQUENCE</td>
  <td>0x00</td>
  <td></td>
  <td><i>(none)</i></td>
  <td>terminates a debug info sequence for a <code>code_item</code></td>
</tr>
<tr>
  <td>DBG_ADVANCE_PC</td>
  <td>0x01</td>
  <td>uleb128&nbsp;addr_diff</td>
  <td><code>addr_diff</code>: amount to add to address register</td>
  <td>advances the address register without emitting a positions entry</td>
</tr>
<tr>
  <td>DBG_ADVANCE_LINE</td>
  <td>0x02</td>
  <td>sleb128&nbsp;line_diff</td>
  <td><code>line_diff</code>: amount to change line register by</td>
  <td>advances the line register without emitting a positions entry</td>
</tr>
<tr>
  <td>DBG_START_LOCAL</td>
  <td>0x03</td>
  <td>uleb128&nbsp;register_num<br/>
    uleb128p1&nbsp;name_idx<br/>
    uleb128p1&nbsp;type_idx
  </td>
  <td><code>register_num</code>: register that will contain local<br/>
    <code>name_idx</code>: string index of the name<br/>
    <code>type_idx</code>: type index of the type
  </td>
  <td>introduces a local variable at the current address. Either 
    <code>name_idx</code> or <code>type_idx</code> may be
    <code>NO_INDEX</code> to indicate that that value is unknown.
  </td>
</tr>
<tr>
  <td>DBG_START_LOCAL_EXTENDED</td>
  <td>0x04</td>
  <td>uleb128&nbsp;register_num<br/>
    uleb128p1&nbsp;name_idx<br/>
    uleb128p1&nbsp;type_idx<br/>
    uleb128p1&nbsp;sig_idx
  </td> 
  <td><code>register_num</code>: register that will contain local<br/>
    <code>name_idx</code>: string index of the name<br/>
    <code>type_idx</code>: type index of the type<br/>
    <code>sig_idx</code>: string index of the type signature
  </td>
  <td>introduces a local with a type signature at the current address.
    Any of <code>name_idx</code>, <code>type_idx</code>, or
    <code>sig_idx</code> may be <code>NO_INDEX</code>
    to indicate that that value is unknown. (If <code>sig_idx</code> is
    <code>-1</code>, though, the same data could be represented more
    efficiently using the opcode <code>DBG_START_LOCAL</code>.)
    <p><b>Note:</b> See the discussion under
    "<code>dalvik.annotation.Signature</code>" below for caveats about
    handling signatures.</p>
  </td>
</tr>
<tr>
  <td>DBG_END_LOCAL</td>
  <td>0x05</td>
  <td>uleb128&nbsp;register_num</td>
  <td><code>register_num</code>: register that contained local</td>
  <td>marks a currently-live local variable as out of scope at the current 
    address
  </td>
</tr>
<tr>
  <td>DBG_RESTART_LOCAL</td>
  <td>0x06</td>
  <td>uleb128&nbsp;register_num</td>
  <td><code>register_num</code>: register to restart</td>
  <td>re-introduces a local variable at the current address. The name
    and type are the same as the last local that was live in the specified
    register.
  </td>
</tr>
<tr>
  <td>DBG_SET_PROLOGUE_END</td>
  <td>0x07</td>
  <td></td>
  <td><i>(none)</i></td>
  <td>sets the <code>prologue_end</code> state machine register, 
    indicating that the next position entry that is added should be 
    considered the end of a method prologue (an appropriate place for 
    a method breakpoint). The <code>prologue_end</code> register is
    cleared by any special (<code>&gt;= 0x0a</code>) opcode.
  </td>
</tr>
<tr>
  <td>DBG_SET_EPILOGUE_BEGIN</td>
  <td>0x08</td>
  <td></td>
  <td><i>(none)</i></td>
  <td>sets the <code>epilogue_begin</code> state machine register, 
    indicating that the next position entry that is added should be 
    considered the beginning of a method epilogue (an appropriate place 
    to suspend execution before method exit).
    The <code>epilogue_begin</code> register is cleared by any special
    (<code>&gt;= 0x0a</code>) opcode.
  </td>
</tr>
<tr>
  <td>DBG_SET_FILE</td>
  <td>0x09</td>
  <td>uleb128p1&nbsp;name_idx</td> 
  <td><code>name_idx</code>: string index of source file name;
    <code>NO_INDEX</code> if unknown
  </td>
  <td>indicates that all subsequent line number entries make reference to this
    source file name, instead of the default name specified in
    <code>code_item</code>
  </td>
</tr>
<tr>
  <td><i>Special Opcodes</i></td>
  <!-- When updating the range below, make sure to search for other 
  instances of 0x0a in this section. -->
  <td>0x0a&hellip;0xff</td>
  <td></td>
  <td><i>(none)</i></td>
  <td>advances the <code>line</code> and <code>address</code> registers,
    emits a position entry, and clears <code>prologue_end</code> and
    <code>epilogue_begin</code>. See below for description.
  </td>
</tr>
</tbody>
</table>

<h3>Special Opcodes</h3>

<p>Opcodes with values between <code>0x0a</code> and <code>0xff</code>
(inclusive) move both the <code>line</code> and <code>address</code>
registers by a small amount and then emit a new position table entry.
The formula for the increments are as follows:</p>

<pre>
DBG_FIRST_SPECIAL = 0x0a  // the smallest special opcode
DBG_LINE_BASE   = -4      // the smallest line number increment
DBG_LINE_RANGE  = 15      // the number of line increments represented

adjusted_opcode = opcode - DBG_FIRST_SPECIAL

line += DBG_LINE_BASE + (adjusted_opcode % DBG_LINE_RANGE)
address += (adjusted_opcode / DBG_LINE_RANGE)
</pre>

<h2><code>annotations_directory_item</code></h2>
<h4>referenced from <code>class_def_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>class_annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the annotations made directly
    on the class, or <code>0</code> if the class has no direct annotations.
    The offset, if non-zero, should be to a location in the
    <code>data</code> section. The format of the data is specified
    by "<code>annotation_set_item</code>" below.
  </td>
</tr>
<tr>
  <td>fields_size</td>
  <td>uint</td>
  <td>count of fields annotated by this item</td>
</tr>
<tr>
  <td>annotated_methods_size</td>
  <td>uint</td>
  <td>count of methods annotated by this item</td>
</tr>
<tr>
  <td>annotated_parameters_size</td>
  <td>uint</td>
  <td>count of method parameter lists annotated by this item</td>
</tr>
<tr>
  <td>field_annotations</td>
  <td>field_annotation[fields_size] <i>(optional)</i></td>
  <td>list of associated field annotations. The elements of the list must
    be sorted in increasing order, by <code>field_idx</code>.
  </td>
</tr>
<tr>
  <td>method_annotations</td>
  <td>method_annotation[methods_size] <i>(optional)</i></td>
  <td>list of associated method annotations. The elements of the list must
    be sorted in increasing order, by <code>method_idx</code>.
  </td>
</tr>
<tr>
  <td>parameter_annotations</td>
  <td>parameter_annotation[parameters_size] <i>(optional)</i></td>
  <td>list of associated method parameter annotations. The elements of the
    list must be sorted in increasing order, by <code>method_idx</code>.
  </td>
</tr>
</tbody>
</table>

<p><b>Note:</b> All elements' <code>field_id</code>s and 
<code>method_id</code>s must refer to the same defining class.</p>

<h3><code>field_annotation</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>field_idx</td>
  <td>uint</td>
  <td>index into the <code>field_ids</code> list for the identity of the
    field being annotated
  </td>
</tr>
<tr>
  <td>annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of annotations for
    the field. The offset should be to a location in the <code>data</code>
    section. The format of the data is specified by
    "<code>annotation_set_item</code>" below.
  </td>
</tr>
</tbody>
</table>

<h3><code>method_annotation</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>method_idx</td>
  <td>uint</td>
  <td>index into the <code>method_ids</code> list for the identity of the
    method being annotated
  </td>
</tr>
<tr>
  <td>annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of annotations for
    the method. The offset should be to a location in the
    <code>data</code> section. The format of the data is specified by
    "<code>annotation_set_item</code>" below.
  </td>
</tr>
</tbody>
</table>

<h3><code>parameter_annotation</code> Format</h2>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>method_idx</td>
  <td>uint</td>
  <td>index into the <code>method_ids</code> list for the identity of the
    method whose parameters are being annotated
  </td>
</tr>
<tr>
  <td>annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the list of annotations for
    the method parameters. The offset should be to a location in the
    <code>data</code> section. The format of the data is specified by
    "<code>annotation_set_ref_list</code>" below.
  </td>
</tr>
</tbody>
</table>

<h2><code>annotation_set_ref_list</code></h2>
<h4>referenced from <code>parameter_annotations_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uint</td>
  <td>size of the list, in entries</td>
</tr>
<tr>
  <td>list</td>
  <td>annotation_set_ref_item[size]</td>
  <td>elements of the list</td>
</tr>
</tbody>
</table>

<h3><code>annotation_set_ref_item</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>annotations_off</td>
  <td>uint</td>
  <td>offset from the start of the file to the referenced annotation set
    or <code>0</code> if there are no annotations for this element.
    The offset, if non-zero, should be to a location in the <code>data</code>
    section. The format of the data is specified by
    "<code>annotation_set_item</code>" below.
  </td>
</tr>
</tbody>
</table>

<h2><code>annotation_set_item</code></h2>
<h4>referenced from <code>annotations_directory_item</code>,
<code>field_annotations_item</code>,
<code>method_annotations_item</code>, and
<code>annotation_set_ref_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: 4 bytes</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>size</td>
  <td>uint</td>
  <td>size of the set, in entries</td>
</tr>
<tr>
  <td>entries</td>
  <td>annotation_off_item[size]</td>
  <td>elements of the set. The elements must be sorted in increasing order,
    by <code>type_idx</code>.
  </td>
</tr>
</tbody>
</table>

<h3><code>annotation_off_item</code> Format</h3>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>annotation_off</td>
  <td>uint</td>
  <td>offset from the start of the file to an annotation.
    The offset should be to a location in the <code>data</code> section,
    and the format of the data at that location is specified by
    "<code>annotation_item</code>" below.
  </td>
</tr>
</tbody>
</table>


<h2><code>annotation_item</code></h2>
<h4>referenced from <code>annotation_set_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: none (byte-aligned)</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>visibility</td>
  <td>ubyte</td>
  <td>intended visibility of this annotation (see below)</td>
</tr>
<tr>
  <td>annotation</td>
  <td>encoded_annotation</td>
  <td>encoded annotation contents, in the format described by
    "<code>encoded_annotation</code> Format" under
    "<code>encoded_value</code> Encoding" above.
  </td>
</tr>
</tbody>
</table>

<h3>Visibility values</h3>

<p>These are the options for the <code>visibility</code> field in an
<code>annotation_item</code>:</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Value</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>VISIBILITY_BUILD</td>
  <td>0x00</td>
  <td>intended only to be visible at build time (e.g., during compilation
    of other code)
  </td>
</tr>
<tr>
  <td>VISIBILITY_RUNTIME</td>
  <td>0x01</td>
  <td>intended to visible at runtime</td>
</tr>
<tr>
  <td>VISIBILITY_SYSTEM</td>
  <td>0x02</td>
  <td>intended to visible at runtime, but only to the underlying system
    (and not to regular user code)
  </td>
</tr>
</tbody>
</table>

<h2><code>encoded_array_item</code></h2>
<h4>referenced from <code>class_def_item</code></h4>
<h4>appears in the <code>data</code> section</h4>
<h4>alignment: none (byte-aligned)</h4>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>encoded_array</td>
  <td>bytes representing the encoded array value, in the format specified
    by "<code>encoded_array</code> Format" under "<code>encoded_value</code>
    Encoding" above.
  </td>
</tr>
</tbody>
</table>

<h1>System Annotations</h1>

<p>System annotations are used to represent various pieces of reflective
information about classes (and methods and fields). This information is
generally only accessed indirectly by client (non-system) code.</p>

<p>System annotations are represented in <code>.dex</code> files as
annotations with visibility set to <code>VISIBILITY_SYSTEM</code>.

<h2><code>dalvik.annotation.AnnotationDefault</code></h2>
<h4>appears on methods in annotation interfaces</h4>

<p>An <code>AnnotationDefault</code> annotation is attached to each
annotation interface which wishes to indicate default bindings.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>Annotation</td>
  <td>the default bindings for this annotation, represented as an annotation
    of this type. The annotation need not include all names defined by the
    annotation; missing names simply do not have defaults.
  </td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.EnclosingClass</code></h2>
<h4>appears on classes</h4>

<p>An <code>EnclosingClass</code> annotation is attached to each class
which is either defined as a member of another class, per se, or is
anonymous but not defined within a method body (e.g., a synthetic
inner class). Every class that has this annotation must also have an
<code>InnerClass</code> annotation. Additionally, a class may not have
both an <code>EnclosingClass</code> and an
<code>EnclosingMethod</code> annotation.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>Class</td>
  <td>the class which most closely lexically scopes this class</td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.EnclosingMethod</code></h2>
<h4>appears on classes</h4>

<p>An <code>EnclosingMethod</code> annotation is attached to each class
which is defined inside a method body. Every class that has this
annotation must also have an <code>InnerClass</code> annotation.
Additionally, a class may not have both an <code>EnclosingClass</code>
and an <code>EnclosingMethod</code> annotation.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>Method</td>
  <td>the method which most closely lexically scopes this class</td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.InnerClass</code></h2>
<h4>appears on classes</h4>

<p>An <code>InnerClass</code> annotation is attached to each class
which is defined in the lexical scope of another class's definition.
Any class which has this annotation must also have <i>either</i> an
<code>EnclosingClass</code> annotation <i>or</i> an
<code>EnclosingMethod</code> annotation.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>name</td>
  <td>String</td>
  <td>the originally declared simple name of this class (not including any
    package prefix). If this class is anonymous, then the name is
    <code>null</code>.
  </td>
</tr>
<tr>
  <td>accessFlags</td>
  <td>int</td>
  <td>the originally declared access flags of the class (which may differ
    from the effective flags because of a mismatch between the execution
    models of the source language and target virtual machine)
  </td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.MemberClasses</code></h2>
<h4>appears on classes</h4>

<p>A <code>MemberClasses</code> annotation is attached to each class
which declares member classes. (A member class is a direct inner class
that has a name.)</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>Class[]</td>
  <td>array of the member classes</td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.Signature</code></h2>
<h4>appears on classes, fields, and methods</h4>

<p>A <code>Signature</code> annotation is attached to each class,
field, or method which is defined in terms of a more complicated type
than is representable by a <code>type_id_item</code>. The
<code>.dex</code> format does not define the format for signatures; it
is merely meant to be able to represent whatever signatures a source
language requires for successful implementation of that language's
semantics. As such, signatures are not generally parsed (or verified)
by virtual machine implementations. The signatures simply get handed
off to higher-level APIs and tools (such as debuggers). Any use of a
signature, therefore, should be written so as not to make any
assumptions about only receiving valid signatures, explicitly guarding
itself against the possibility of coming across a syntactically
invalid signature.</p>

<p>Because signature strings tend to have a lot of duplicated content,
a <code>Signature</code> annotation is defined as an <i>array</i> of
strings, where duplicated elements naturally refer to the same
underlying data, and the signature is taken to be the concatenation of
all the strings in the array. There are no rules about how to pull
apart a signature into separate strings; that is entirely up to the
tools that generate <code>.dex</code> files.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>String[]</td>
  <td>the signature of this class or member, as an array of strings that
    is to be concatenated together</td>
</tr>
</tbody>
</table>

<h2><code>dalvik.annotation.Throws</code></h2>
<h4>appears on methods</h4>

<p>A <code>Throws</code> annotation is attached to each method which is
declared to throw one or more exception types.</p>

<table class="format">
<thead>
<tr>
  <th>Name</th>
  <th>Format</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>value</td>
  <td>Class[]</td>
  <td>the array of exception types thrown</td>
</tr>
</tbody>
</table>

</body>
</html>