รูปแบบไฟล์ปฏิบัติการ Dalvik

เอกสารนี้อธิบายโครงร่างและเนื้อหาของไฟล์ .dex ซึ่งใช้เพื่อเก็บชุดของคำจำกัดความของคลาสและข้อมูลเสริมที่เกี่ยวข้อง

คู่มือประเภท

ชื่อ คำอธิบาย
ไบต์ ลงชื่อเข้าใช้ 8 บิต
ubyte int ที่ไม่ได้ลงชื่อ 8 บิต
สั้น int แบบ 16 บิต, little-endian
ushort int ที่ไม่ได้ลงชื่อ 16 บิต, little-endian
int int แบบ 32 บิต, little-endian
uint int ที่ไม่ได้ลงชื่อ 32 บิต, little-endian
ยาว int แบบ 64 บิต, little-endian
อูหลง int ที่ไม่ได้ลงชื่อ 64 บิต, little-endian
sleb128 ลงนาม LEB128 ความยาวผันแปรได้ (ดูด้านล่าง)
uleb128 LEB128 ที่ไม่ได้ลงชื่อ ความยาวผันแปรได้ (ดูด้านล่าง)
uleb128p1 LEB128 ที่ไม่ได้ลงชื่อบวก 1 ความยาวผันแปรได้ (ดูด้านล่าง)

LEB128

LEB128 (" L ittle- E ndian B ase 128 ") คือการเข้ารหัสที่มีความยาวผันแปรได้สำหรับปริมาณจำนวนเต็มที่มีการลงชื่อหรือไม่ได้ลงนามโดยอำเภอใจ รูปแบบนี้ยืมมาจากข้อกำหนด DWARF3 ในไฟล์ .dex .dex ถูกใช้เพื่อเข้ารหัสปริมาณแบบ 32 บิตเท่านั้น

ค่าที่เข้ารหัส LEB128 แต่ละค่าประกอบด้วยหนึ่งถึงห้าไบต์ ซึ่งรวมกันแทนค่า 32 บิตเดียว แต่ละไบต์มีชุดบิตที่สำคัญที่สุด ยกเว้นไบต์สุดท้ายในลำดับ ซึ่งมีบิตที่ชัดเจนที่สุด เจ็ดบิตที่เหลือของแต่ละไบต์คือเพย์โหลด โดยมีปริมาณเจ็ดบิตที่มีนัยสำคัญน้อยที่สุดในไบต์แรก เจ็ดบิตถัดไปในไบต์ที่สอง และอื่นๆ ในกรณีของ LEB128 ที่ลงนาม ( sleb128 ) บิตเพย์โหลดที่สำคัญที่สุดของไบต์สุดท้ายในลำดับจะถูกขยายสัญญาณเพื่อสร้างค่าสุดท้าย ในกรณีที่ไม่ได้ลงนาม ( uleb128 ) บิตใดๆ ที่ไม่ได้แสดงไว้อย่างชัดเจนจะถูกตีความว่าเป็น 0

ไดอะแกรมระดับบิตของค่า LEB128 สองไบต์
ไบต์แรก ไบต์ที่สอง
1 บิต 6 บิต 5 บิต 4 บิต 3 บิต 2 บิต 1 บิต 0 0 บิต 13 บิต 12 บิต 11 บิต 10 บิต 9 บิต 8 บิต 7

ตัวแปร uleb128p1 ใช้เพื่อแสดงค่าที่ลงนาม โดยการแสดงเป็นค่า บวกหนึ่ง เข้ารหัสเป็น uleb128 สิ่งนี้ทำให้การเข้ารหัสของ -1 (หรือคิดอีกทางหนึ่งว่าเป็นค่าที่ไม่ได้ลงนาม 0xffffffff ) — แต่ไม่มีตัวเลขติดลบอื่น — ไบต์เดียว และมีประโยชน์ในกรณีที่ตัวเลขที่แสดงต้องไม่เป็นค่าลบหรือ -1 (หรือ 0xffffffff ) และในกรณีที่ไม่อนุญาตให้มีค่าลบอื่น ๆ (หรือในกรณีที่ไม่ต้องการค่าขนาดใหญ่ที่ไม่ได้ลงนาม)

นี่คือตัวอย่างบางส่วนของรูปแบบ:

ลำดับการเข้ารหัส ในฐานะที่เป็น sleb128 เป็น uleb128 เป็น uleb128p1
00 0 0 -1
01 1 1 0
7f -1 127 126
80 7f -128 16256 16255

รูปแบบไฟล์

ชื่อ รูปแบบ คำอธิบาย
หัวข้อ header_item ส่วนหัว
string_ids string_id_item[] รายการตัวระบุสตริง สิ่งเหล่านี้เป็นตัวระบุสำหรับสตริงทั้งหมดที่ใช้โดยไฟล์นี้ สำหรับการตั้งชื่อภายใน (เช่น ตัวอธิบายประเภท) หรือเป็นวัตถุคงที่ที่อ้างถึงโดยรหัส รายการนี้ต้องจัดเรียงตามเนื้อหาสตริง โดยใช้ค่าจุดรหัส UTF-16 (ไม่ใช่ในลักษณะที่คำนึงถึงสถานที่) และต้องไม่มีรายการที่ซ้ำกัน
type_ids type_id_item[] รายการตัวระบุประเภท สิ่งเหล่านี้เป็นตัวระบุสำหรับทุกประเภท (คลาส อาร์เรย์ หรือประเภทดั้งเดิม) ที่ไฟล์นี้อ้างอิงถึง ไม่ว่าจะกำหนดไว้ในไฟล์หรือไม่ก็ตาม รายการนี้ต้องจัดเรียงตามดัชนี string_id และต้องไม่มีรายการที่ซ้ำกัน
proto_ids proto_id_item[] รายการตัวระบุต้นแบบวิธีการ สิ่งเหล่านี้เป็นตัวระบุสำหรับต้นแบบทั้งหมดที่อ้างถึงโดยไฟล์นี้ รายการนี้ต้องจัดเรียงในลำดับหลักประเภทส่งคืน (ตามดัชนี type_id ) จากนั้นตามรายการ type_id รายการต้องไม่มีรายการที่ซ้ำกัน
field_ids field_id_item[] รายการตัวระบุฟิลด์ สิ่งเหล่านี้เป็นตัวระบุสำหรับฟิลด์ทั้งหมดที่อ้างถึงโดยไฟล์นี้ ไม่ว่าจะกำหนดไว้ในไฟล์หรือไม่ก็ตาม ต้องจัดเรียงรายการนี้ โดยที่ประเภทการกำหนด (ตามดัชนี type_id ) คือลำดับหลัก ชื่อฟิลด์ (โดยดัชนี string_id ) คือลำดับขั้นกลาง และประเภท (ตามดัชนี type_id ) คือลำดับรอง รายการต้องไม่มีรายการที่ซ้ำกัน
method_ids method_id_item[] รายการตัวระบุเมธอด สิ่งเหล่านี้เป็นตัวระบุสำหรับวิธีการทั้งหมดที่อ้างถึงโดยไฟล์นี้ ไม่ว่าจะกำหนดไว้ในไฟล์หรือไม่ก็ตาม ต้องจัดเรียงรายการนี้ โดยที่ประเภทการกำหนด (ตามดัชนี type_id ) เป็นลำดับหลัก ชื่อวิธี (โดยดัชนี string_id ) คือลำดับขั้นกลาง และวิธีการต้นแบบ (โดยดัชนี proto_id ) เป็นลำดับรอง รายการต้องไม่มีรายการที่ซ้ำกัน
class_defs class_def_item[] รายการคำจำกัดความของคลาส คลาสต้องได้รับคำสั่งเพื่อให้ superclass ของคลาสที่กำหนดและอินเตอร์เฟสที่นำไปใช้จะปรากฏในรายการก่อนหน้าคลาสที่อ้างอิง นอกจากนี้ คำจำกัดความของคลาสที่มีชื่อเดียวกันจะปรากฏในรายการมากกว่าหนึ่งครั้งไม่ถูกต้อง
call_site_ids call_site_id_item[] เรียกรายการตัวระบุไซต์ สิ่งเหล่านี้เป็นตัวระบุสำหรับไซต์การโทรทั้งหมดที่อ้างถึงโดยไฟล์นี้ ไม่ว่าจะกำหนดไว้ในไฟล์หรือไม่ก็ตาม รายการนี้ต้องเรียงลำดับจากน้อยไปมากจาก call_site_off
method_handles method_handle_item[] วิธีจัดการรายการ รายการของเมธอดทั้งหมดที่อ้างอิงถึงโดยไฟล์นี้ ไม่ว่าจะกำหนดไว้ในไฟล์หรือไม่ก็ตาม รายการนี้ไม่ได้จัดเรียงและอาจมีรายการซ้ำซึ่งจะสอดคล้องกับวิธีการจัดการอินสแตนซ์ที่แตกต่างกันตามหลักเหตุผล
ข้อมูล ยูไบต์[] พื้นที่ข้อมูล ซึ่งมีข้อมูลสนับสนุนทั้งหมดสำหรับตารางที่แสดงด้านบน รายการที่แตกต่างกันมีข้อกำหนดการจัดตำแหน่งที่แตกต่างกัน และไบต์การเติมจะถูกแทรกก่อนแต่ละรายการหากจำเป็นเพื่อให้ได้การจัดตำแหน่งที่เหมาะสม
link_data ยูไบต์[] ข้อมูลที่ใช้ในไฟล์ที่เชื่อมโยงแบบสแตติก รูปแบบของข้อมูลในส่วนนี้ไม่ได้ระบุไว้ในเอกสารนี้ ส่วนนี้ว่างเปล่าในไฟล์ที่ไม่ได้เชื่อมโยง และการใช้งานรันไทม์อาจใช้ส่วนนี้ตามที่เห็นสมควร

คำจำกัดความของ Bitfield, string และค่าคงที่

DEX_FILE_MAGIC

ฝังอยู่ใน header_item

อาร์เรย์/สตริงคงที่ DEX_FILE_MAGIC คือรายการของไบต์ที่ต้องปรากฏที่จุดเริ่มต้นของไฟล์ .dex เพื่อให้ระบบรู้จักไฟล์ดังกล่าว ค่ามีเจตนาประกอบด้วยการขึ้นบรรทัดใหม่ ( "\n" หรือ 0x0a ) และไบต์ว่าง ( "\0" หรือ 0x00 ) เพื่อช่วยในการตรวจหาความเสียหายบางรูปแบบ ค่านี้ยังเข้ารหัสหมายเลขเวอร์ชันของรูปแบบเป็นทศนิยมสามหลัก ซึ่งคาดว่าจะเพิ่มขึ้นอย่างซ้ำซากจำเจเมื่อเวลาผ่านไปในขณะที่รูปแบบพัฒนาขึ้น

ubyte[8] DEX_FILE_MAGIC = { 0x64 0x65 0x78 0x0a 0x30 0x33 0x39 0x00 }
                        = "dex\n039\0"

หมายเหตุ: เพิ่มการรองรับเวอร์ชัน 039 ของรูปแบบใน Android 9.0 ซึ่งเปิดตัว bytecodes ใหม่สองตัว const-method-handle และ const-method-type (มีอธิบายไว้ในตาราง สรุปชุดไบต์โค้ด ) ใน Android 10 เวอร์ชัน 039 ขยายรูปแบบไฟล์ DEX เพื่อรวมข้อมูล API ที่ซ่อนอยู่ซึ่งใช้ได้กับไฟล์ DEX บนเส้นทางคลาสบูตเท่านั้น

หมายเหตุ: เพิ่มการรองรับเวอร์ชัน 038 ของรูปแบบใน Android 8.0 รีลีส เวอร์ชัน 038 เพิ่ม bytecodes ใหม่ ( invoke-polymorphic และ invoke-custom ) และข้อมูลสำหรับการจัดการเมธอด

หมายเหตุ: เพิ่มการรองรับเวอร์ชัน 037 ของรูปแบบใน Android 7.0 รีลีส ก่อนหน้าเวอร์ชัน 037 Android เวอร์ชันส่วนใหญ่ใช้เวอร์ชัน 035 ของรูปแบบ ความแตกต่างเพียงอย่างเดียวระหว่างเวอร์ชัน 035 และ 037 คือการเพิ่มวิธีการเริ่มต้นและการปรับการ invoke

หมายเหตุ: มีการใช้รูปแบบเวอร์ชันก่อนหน้าอย่างน้อยสองสามเวอร์ชันในซอฟต์แวร์สาธารณะที่เผยแพร่อย่างกว้างขวาง ตัวอย่างเช่น เวอร์ชัน 009 ใช้สำหรับเวอร์ชัน M3 ของแพลตฟอร์ม Android (พฤศจิกายน–ธันวาคม 2550) และเวอร์ชัน 013 ใช้สำหรับเวอร์ชัน M5 ของแพลตฟอร์ม Android (กุมภาพันธ์–มีนาคม 2551) รูปแบบเวอร์ชันก่อนหน้าเหล่านี้แตกต่างอย่างมากจากเวอร์ชันที่อธิบายไว้ในเอกสารนี้ในหลายประการ

ENDIAN_CONSTANT และ REVERSE_ENDIAN_CONSTANT

ฝังอยู่ใน header_item

ค่าคงที่ ENDIAN_CONSTANT ใช้เพื่อระบุจุดสิ้นสุดของไฟล์ที่พบ แม้ว่ารูปแบบ .dex มาตรฐานจะเป็นแบบ little-endian แต่การใช้งานอาจเลือกที่จะทำการสลับไบต์ได้ หากการใช้งานพบส่วนหัวที่มี endian_tag เป็น REVERSE_ENDIAN_CONSTANT แทนที่จะเป็น ENDIAN_CONSTANT ก็จะรู้ว่าไฟล์ถูกสลับไบต์จากแบบฟอร์มที่คาดไว้

uint ENDIAN_CONSTANT = 0x12345678;
uint REVERSE_ENDIAN_CONSTANT = 0x78563412;

NO_INDEX

ฝังอยู่ใน class_def_item และ debug_info_item

ค่าคงที่ NO_INDEX ใช้เพื่อระบุว่าไม่มีค่าดัชนี

หมายเหตุ: ค่านี้ไม่ได้กำหนดเป็น 0 เนื่องจากโดยทั่วไปแล้วจะเป็นดัชนีที่ถูกต้อง

ค่าที่เลือกสำหรับ NO_INDEX สามารถแสดงเป็นไบต์เดียวในการเข้ารหัส uleb128p1

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

คำจำกัดความ access_flags

ฝังอยู่ใน class_def_item, encoded_field, encoded_method และ InnerClass

บิตฟิลด์ของแฟล็กเหล่านี้ใช้เพื่อระบุการเข้าถึงและคุณสมบัติโดยรวมของคลาสและสมาชิกคลาส

ชื่อ ค่า สำหรับคลาส (และคำอธิบายประกอบ InnerClass ) สำหรับฟิลด์ สำหรับวิธีการ
ACC_PUBLIC 0x1 public : มองเห็นได้ทุกที่ public : มองเห็นได้ทุกที่ public : มองเห็นได้ทุกที่
ACC_PRIVATE 0x2 * private : มองเห็นได้เฉพาะกับคลาสที่กำหนด private : มองเห็นได้เฉพาะกับคลาสที่กำหนด private : มองเห็นได้เฉพาะกับคลาสที่กำหนด
ACC_PROTECTED 0x4 * protected : มองเห็นได้ในแพ็คเกจและคลาสย่อย protected : มองเห็นได้ในแพ็คเกจและคลาสย่อย protected : มองเห็นได้ในแพ็คเกจและคลาสย่อย
ACC_STATIC 0x8 * static : ไม่ได้สร้างด้วยการอ้างอิง this ภายนอกstatic : โกลบอลเพื่อกำหนดคลาส static : ไม่รับอาร์กิวเมนต์ this
ACC_FINAL 0x10 final : ไม่สามารถจำแนกย่อยได้ final : ไม่เปลี่ยนรูปหลังการก่อสร้าง final : ไม่สามารถลบล้างได้
ACC_SYNCHRONIZED 0x20 synchronized : ล็อคที่เกี่ยวข้องได้รับโดยอัตโนมัติเมื่อมีการเรียกใช้เมธอดนี้

หมายเหตุ: ใช้ได้เฉพาะเมื่อตั้งค่า ACC_NATIVE ด้วย

ACC_VOLATILE 0x40 volatile : กฎการเข้าถึงพิเศษเพื่อช่วยในความปลอดภัยของเธรด
ACC_BRIDGE 0x40 วิธีบริดจ์เพิ่มโดยอัตโนมัติโดยคอมไพเลอร์เป็นบริดจ์ที่ปลอดภัยประเภท
ACC_TRANSIENT 0x80 transient : ไม่ถูกบันทึกโดยการทำให้เป็นอนุกรมเริ่มต้น
ACC_VARRGS 0x80 อาร์กิวเมนต์สุดท้ายควรถือเป็นอาร์กิวเมนต์ "ส่วนที่เหลือ" โดยคอมไพเลอร์
ACC_NATIVE 0x100 native : ใช้ในโค้ดเนทีฟ
ACC_INTERFACE 0x200 interface : คลาสนามธรรมที่นำไปใช้ได้หลายตัว
ACC_ABSTRACT 0x400 abstract : ไม่สามารถสร้างทันทีได้โดยตรง abstract : ไม่ได้ใช้งานโดยคลาสนี้
ACC_STRICT 0x800 strictfp : กฎที่เข้มงวดสำหรับเลขทศนิยม
ACC_SYNTHETIC 0x1000 ไม่ได้กำหนดโดยตรงในซอร์สโค้ด ไม่ได้กำหนดโดยตรงในซอร์สโค้ด ไม่ได้กำหนดโดยตรงในซอร์สโค้ด
ACC_ANNOTATION 0x2000 ประกาศเป็นคลาสคำอธิบายประกอบ
ACC_ENUM 0x4000 ประกาศเป็นประเภทที่แจกแจงแล้ว ประกาศเป็นค่าที่แจกแจงแล้ว
(ไม่ได้ใช้) 0x8000
ACC_CONSTRUCTOR 0x10000 วิธีการสร้าง (คลาสหรือตัวเริ่มต้นอินสแตนซ์)
ACC_DECLARED_
ซิงโครไนซ์
0x20000 ประกาศ synchronized

หมายเหตุ: สิ่งนี้ไม่มีผลกระทบต่อการดำเนินการ (นอกเหนือจากการสะท้อนแฟล็กนี้ ต่อตัว)

* อนุญาตเฉพาะสำหรับคำอธิบายประกอบ InnerClass และต้องไม่เปิดใน class_def_item

การเข้ารหัส MUTF-8 (ดัดแปลง UTF-8)

เพื่อเป็นการยินยอมในการสนับสนุนแบบเดิมที่ง่ายขึ้น รูปแบบ .dex จะเข้ารหัสข้อมูลสตริงในรูปแบบ UTF-8 ที่แก้ไขโดยพฤตินัยมาตรฐาน ซึ่งต่อจากนี้จะเรียกว่า MUTF-8 แบบฟอร์มนี้เหมือนกับ UTF-8 มาตรฐาน ยกเว้น:

  • ใช้การเข้ารหัสแบบหนึ่ง สอง และสามไบต์เท่านั้น
  • รหัสชี้อยู่ในช่วง U+10000U+10ffff ถูกเข้ารหัสเป็นคู่ตัวแทน ซึ่งแต่ละค่าจะแสดงเป็นค่าที่เข้ารหัสแบบสามไบต์
  • จุดรหัส U+0000 ถูกเข้ารหัสในรูปแบบสองไบต์
  • null null ธรรมดา (value 0 ) ระบุจุดสิ้นสุดของสตริง เช่นเดียวกับการตีความภาษา C มาตรฐาน

สองรายการแรกข้างต้นสามารถสรุปได้ดังนี้: MUTF-8 เป็นรูปแบบการเข้ารหัสสำหรับ UTF-16 แทนที่จะเป็นรูปแบบการเข้ารหัสโดยตรงสำหรับอักขระ Unicode

สองรายการสุดท้ายด้านบนทำให้สามารถรวมจุดโค้ด U+0000 ลงในสตริงได้พร้อมๆ กัน และ ยังคงจัดการเป็นสตริงที่สิ้นสุดด้วยค่า null สไตล์ C

อย่างไรก็ตาม การเข้ารหัสแบบพิเศษของ U+0000 หมายความว่าไม่เหมือนกับ UTF-8 ปกติ ผลลัพธ์ของการเรียกใช้ฟังก์ชัน C มาตรฐาน strcmp() บนคู่ของสตริง MUTF-8 ไม่ได้ระบุผลลัพธ์ที่ลงนามอย่างถูกต้องของการเปรียบเทียบสตริงที่ ไม่เท่ากัน เสมอไป . เมื่อต้องสั่งซื้อ (ไม่ใช่แค่ความเท่าเทียมกัน) เป็นเรื่องที่ต้องกังวล วิธีที่ตรงไปตรงมาที่สุดในการเปรียบเทียบสตริง MUTF-8 คือการถอดรหัสอักขระทีละอักขระ และเปรียบเทียบค่าที่ถอดรหัส (อย่างไรก็ตาม การใช้งานที่ชาญฉลาดยิ่งขึ้นก็เป็นไปได้เช่นกัน)

โปรดดูที่ The Unicode Standard สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการเข้ารหัสอักขระ จริง ๆ แล้ว MUTF-8 นั้นใกล้เคียงกับการเข้ารหัส CESU-8 (ค่อนข้างเป็นที่รู้จักน้อย) มากกว่า UTF-8 ต่อตัว

encoded_value การเข้ารหัส

ฝังอยู่ใน annotation_element และ encoded_array_item

encoded_value คือส่วนที่เข้ารหัสของข้อมูลที่มีโครงสร้างแบบลำดับชั้น (เกือบ) โดยพลการ การเข้ารหัสมีจุดมุ่งหมายเพื่อให้มีขนาดกะทัดรัดและง่ายต่อการแยกวิเคราะห์

ชื่อ รูปแบบ คำอธิบาย
(value_arg << 5) | value_type ubyte byte ระบุประเภทของ value ที่ตามมาทันทีพร้อมกับอาร์กิวเมนต์การชี้แจงทางเลือกในสามบิตที่มีลำดับสูง ดูคำจำกัดความ value ต่างๆ ด้านล่าง ในกรณีส่วนใหญ่ value_arg เข้ารหัสความยาวของ value ที่ตามมาในทันทีเป็นไบต์ เช่น (size - 1) เช่น 0 หมายความว่าค่าต้องการหนึ่งไบต์ และ 7 หมายถึงต้องใช้แปดไบต์ อย่างไรก็ตาม มีข้อยกเว้นตามที่ระบุไว้ด้านล่าง
ค่า ยูไบต์[] ไบต์ที่แทนค่า ตัวแปรในความยาว และตีความต่างกันสำหรับไบต์ value_type ที่แตกต่างกัน แม้ว่าจะเป็น little-endian เสมอ ดูคำจำกัดความของค่าต่างๆ ด้านล่างสำหรับรายละเอียด

รูปแบบค่า

พิมพ์ชื่อ value_type value_arg รูปแบบ รูปแบบ value คำอธิบาย
VALUE_BYTE 0x00 (ไม่มี ต้องเป็น 0 ) ยูไบต์[1] เซ็นชื่อค่าจำนวนเต็มหนึ่งไบต์
VALUE_SHORT 0x02 ขนาด - 1 (0…1) ยูไบต์[ขนาด] ค่าจำนวนเต็มสองไบต์ที่ลงนามแล้ว, ขยายเครื่องหมาย
VALUE_CHAR 0x03 ขนาด - 1 (0…1) ยูไบต์[ขนาด] ค่าจำนวนเต็มสองไบต์ที่ไม่ได้ลงนาม ขยายเป็นศูนย์
VALUE_INT 0x04 ขนาด - 1 (0…3) ยูไบต์[ขนาด] เซ็นชื่อค่าจำนวนเต็มสี่ไบต์, ขยายเครื่องหมาย
VALUE_LONG 0x06 ขนาด - 1 (0…7) ยูไบต์[ขนาด] เซ็นชื่อค่าจำนวนเต็มแปดไบต์, ขยายเครื่องหมาย
VALUE_FLOAT 0x10 ขนาด - 1 (0…3) ยูไบต์[ขนาด] รูปแบบบิตสี่ไบต์ ขยายเป็นศูนย์ ไปทางขวา และตีความว่าเป็นค่าทศนิยม 32 บิต IEEE754
VALUE_DOUBLE 0x11 ขนาด - 1 (0…7) ยูไบต์[ขนาด] รูปแบบบิตแปดไบต์ ขยายเป็นศูนย์ ไปทางขวา และตีความว่าเป็นค่าทศนิยม 64 บิต IEEE754
VALUE_METHOD_TYPE 0x15 ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงชื่อ (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน proto_ids และแสดงค่าประเภทเมธอด
VALUE_METHOD_HANDLE 0x16 ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงชื่อ (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน method_handles และแสดงค่าของวิธีจัดการ
VALUE_STRING 0x17 ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงนาม (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน string_ids และแสดงค่าสตริง
VALUE_TYPE 0x18 ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงชื่อ (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน type_ids และแสดงค่าประเภท/คลาสสะท้อนแสง
VALUE_FIELD 0x19 ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงชื่อ (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน field_ids และแสดงค่าฟิลด์สะท้อนแสง
VALUE_METHOD 0x1a ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงนาม (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน method_ids และแสดงค่าวิธีการสะท้อนแสง
VALUE_ENUM 0x1b ขนาด - 1 (0…3) ยูไบต์[ขนาด] ค่าจำนวนเต็มสี่ไบต์ที่ไม่ได้ลงนาม (ขยายเป็นศูนย์) ตีความว่าเป็นดัชนีในส่วน field_ids และแสดงค่าของค่าคงที่ประเภทที่แจกแจง
VALUE_ARRAY 0x1c (ไม่มี ต้องเป็น 0 ) encoded_array อาร์เรย์ของค่าในรูปแบบที่ระบุโดย " encoded_array format" ด้านล่าง ขนาดของ value เป็นนัยในการเข้ารหัส
VALUE_ANNOTATION 0x1d (ไม่มี ต้องเป็น 0 ) encoded_annotation คำอธิบายประกอบย่อยในรูปแบบที่ระบุโดย " รูปแบบ encoded_annotation " ด้านล่าง ขนาดของ value เป็นนัยในการเข้ารหัส
VALUE_NULL 0x1e (ไม่มี ต้องเป็น 0 ) (ไม่มี) ค่าอ้างอิง null
VALUE_BOOLEAN 0x1f บูลีน (0…1) (ไม่มี) ค่าหนึ่งบิต 0 สำหรับ false และ 1 สำหรับ true บิตจะแสดงในค่า value_arg

encoded_array รูปแบบ

ชื่อ รูปแบบ คำอธิบาย
ขนาด uleb128 จำนวนองค์ประกอบในอาร์เรย์
ค่า encoded_value[ขนาด] ชุดของ size ลำดับไบต์ encoded_value ในรูปแบบที่ระบุโดยส่วนนี้ ต่อกันตามลำดับ

encoded_annotation รูปแบบ

ชื่อ รูปแบบ คำอธิบาย
type_idx uleb128 ประเภทของคำอธิบายประกอบ ต้องเป็นประเภทคลาส (ไม่ใช่ประเภทอาร์เรย์หรือพื้นฐาน)
ขนาด uleb128 จำนวนการแมปชื่อ-ค่าในคำอธิบายประกอบนี้
องค์ประกอบ คำอธิบายประกอบ_องค์ประกอบ[ขนาด] องค์ประกอบของคำอธิบายประกอบ ซึ่งแสดงโดยตรงในบรรทัด (ไม่ใช่เป็นออฟเซ็ต) ต้องจัดเรียงองค์ประกอบตามลำดับที่เพิ่มขึ้นตามดัชนี string_id

รูปแบบคำอธิบายประกอบ_องค์ประกอบ

ชื่อ รูปแบบ คำอธิบาย
name_idx uleb128 ชื่อองค์ประกอบ ซึ่งแสดงเป็นดัชนีในส่วน string_ids สตริงต้องสอดคล้องกับไวยากรณ์สำหรับ MemberName ที่กำหนดไว้ข้างต้น
ค่า encoded_value ค่าองค์ประกอบ

ไวยากรณ์สตริง

มีรายการหลายประเภทในไฟล์ .dex ซึ่งท้ายที่สุดจะอ้างถึงสตริง คำจำกัดความรูปแบบ BNF ต่อไปนี้ระบุไวยากรณ์ที่ยอมรับได้สำหรับสตริงเหล่านี้

SimpleName

SimpleName เป็นพื้นฐานสำหรับไวยากรณ์ของชื่อของสิ่งอื่น รูปแบบ .dex อนุญาตให้ใช้ละติจูดที่นี่ (มากกว่าภาษาต้นฉบับทั่วไปส่วนใหญ่) โดยสังเขป ชื่ออย่างง่ายประกอบด้วยอักขระหรือตัวเลขที่เป็นตัวอักษร ASCII ต่ำ สัญลักษณ์ ASCII ต่ำบางตัว และจุดรหัสที่ไม่ใช่ ASCII ส่วนใหญ่ซึ่งไม่ได้ควบคุม เว้นวรรค หรืออักขระพิเศษ เริ่มตั้งแต่เวอร์ชัน 040 รูปแบบนี้อนุญาตให้ใช้อักขระเว้นวรรคเพิ่มเติมได้ (หมวด Unicode Zs ) โปรดทราบว่าจุดรหัสตัวแทน (ในช่วง U+d800 d800 … U+dfff ) ไม่ถือว่าเป็นอักขระชื่อที่ถูกต้อง ต่อ se แต่อักขระเสริม Unicode นั้น ถูกต้อง (ซึ่งแสดงโดยทางเลือกสุดท้ายของกฎสำหรับ SimpleNameChar ) และพวกมัน ควรแสดงในไฟล์เป็นคู่ของรหัสตัวแทนในการเข้ารหัส MUTF-8

SimpleName
SimpleNameChar ( SimpleNameChar )*
SimpleNameChar
'A''Z'
| 'a''z'
| '0''9'
| ' ' ตั้งแต่รุ่น DEX 040
| '$'
| '-'
| '_'
| U+00a0 ตั้งแต่รุ่น DEX 040
| U+00a1U+1fff
| U+2000U+200a ตั้งแต่รุ่น DEX 040
| U+2010U+2027
| U+202f ตั้งแต่รุ่น DEX 040
| U+2030U+d7ff
| U+e000U+ffef
| U+10000U+10ffff

ชื่อสมาชิก

ใช้โดย field_id_item และ method_id_item

MemberName คือชื่อของสมาชิกของคลาส สมาชิกเป็นฟิลด์ เมธอด และคลาสภายใน

ชื่อสมาชิก
SimpleName
| '<' ชื่อง่าย '>'

ชื่อเต็มคลาส

FullClassName คือชื่อคลาสที่มีคุณสมบัติครบถ้วน รวมถึงตัวระบุแพ็คเกจที่เป็นตัวเลือกตามด้วยชื่อที่ต้องการ

ชื่อเต็ม
OptionalPackagePrefix SimpleName
OptionalPackagePrefix
( ชื่อง่าย '/' )*

ประเภทคำอธิบาย

ใช้โดย type_id_item

TypeDescriptor เป็นตัวแทนประเภทใดก็ได้ รวมถึง primitives, คลาส, อาร์เรย์ และ void ดูความหมายของเวอร์ชันต่างๆ ด้านล่าง

TypeDescriptor
'V'
| FieldTypeDescriptor
FieldTypeDescriptor
NonArrayFieldTypeDescriptor
| ( '[' * 1…255) NonArrayFieldTypeDescriptor
NonArrayFieldTypeDescriptor
'Z'
| 'B'
| 'S'
| 'C'
| 'I'
| 'J'
| 'F'
| 'D'
| 'L' FullClassName ';'

ShortyDescriptor

ใช้โดย proto_id_item

ShortyDescriptor คือการแสดงรูปแบบสั้น ๆ ของต้นแบบวิธีการ ซึ่งรวมถึงประเภทการส่งคืนและพารามิเตอร์ ยกเว้นว่าไม่มีความแตกต่างระหว่างประเภทการอ้างอิง (คลาสหรืออาร์เรย์) ต่างๆ ประเภทการอ้างอิงทั้งหมดจะแสดงด้วยอักขระ 'L' ตัวเดียวแทน

ShortyDescriptor
ShortyReturnType ( ShortyFieldType )*
ShortyReturnType
'V'
| ShortyFieldType
ShortyFieldType
'Z'
| 'B'
| 'S'
| 'C'
| 'I'
| 'J'
| 'F'
| 'D'
| 'L'

TypeDescriptor Semantics

นี่คือความหมายของแต่ละตัวแปรของ TypeDescriptor

ไวยากรณ์ ความหมาย
วี void ; ใช้ได้กับประเภทการคืนสินค้าเท่านั้น
Z boolean
บี byte
short
char
ฉัน int
เจ long
F float
ดี double
L เต็ม/มีคุณสมบัติ/ชื่อ ; คลาส fully.qualified.Name
[ คำอธิบาย array of descriptor ใช้งานได้แบบเรียกซ้ำสำหรับ arrays-of-array แม้ว่าจะไม่ถูกต้องหากมีมากกว่า 255 มิติ

รายการและโครงสร้างที่เกี่ยวข้อง

ส่วนนี้มีคำจำกัดความสำหรับแต่ละรายการระดับบนสุดที่อาจปรากฏในไฟล์ .dex

header_item

ปรากฏในส่วนหัว

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
มายากล ยูไบต์[8] = DEX_FILE_MAGIC ค่าเวทย์มนตร์ ดูการสนทนาด้านบนภายใต้ " DEX_FILE_MAGIC " สำหรับรายละเอียดเพิ่มเติม
เช็คซัม uint adler32 checksum ของไฟล์ที่เหลือ (ทุกอย่างยกเว้น magic และฟิลด์นี้); ใช้ในการตรวจหาความเสียหายของไฟล์
ลายเซ็น ยูไบต์[20] ลายเซ็น SHA-1 (แฮช) ของไฟล์ที่เหลือ (ทุกอย่างยกเว้น magic , checksum และฟิลด์นี้); ใช้เพื่อระบุไฟล์โดยเฉพาะ
file_size uint ขนาดของไฟล์ทั้งหมด (รวมถึงส่วนหัว) ในหน่วยไบต์
header_size uint = 0x70 ขนาดของส่วนหัว (ทั้งส่วนนี้) ในหน่วยไบต์ วิธีนี้อนุญาตให้ใช้ความเข้ากันได้แบบย้อนกลับ/ไปข้างหน้าอย่างน้อยในจำนวนที่จำกัดโดยไม่ทำให้รูปแบบเป็นโมฆะ
endian_tag uint = ENDIAN_CONSTANT แท็ก endianness ดูการสนทนาด้านบนภายใต้ " ENDIAN_CONSTANT และ REVERSE_ENDIAN_CONSTANT " สำหรับรายละเอียดเพิ่มเติม
link_size uint ขนาดของส่วนลิงก์ หรือ 0 หากไฟล์นี้ไม่ได้ลิงก์แบบคงที่
link_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์ไปยังส่วนลิงก์ หรือ 0 ถ้า link_size == 0 ค่าออฟเซ็ต หากไม่ใช่ศูนย์ ควรเป็นค่าออฟเซ็ตในส่วน link_data รูปแบบของข้อมูลที่ชี้ไปที่ไม่ถูกระบุโดยเอกสารนี้ ฟิลด์ส่วนหัวนี้ (และก่อนหน้านี้) เหลือไว้เป็น hook สำหรับใช้งานโดยการใช้งานรันไทม์
map_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์ไปยังรายการแผนที่ ออฟเซ็ต ซึ่งต้องไม่เป็นศูนย์ ควรเป็นออฟเซ็ตในส่วน data และข้อมูลควรอยู่ในรูปแบบที่ระบุโดย " map_list " ด้านล่าง
string_ids_size uint จำนวนสตริงในรายการตัวระบุสตริง
string_ids_off uint offset จากจุดเริ่มต้นของไฟล์ไปยังรายการ string identifiers หรือ 0 if string_ids_size == 0 (เป็นที่ยอมรับว่าเป็น case edge ที่แปลกประหลาด) ออฟเซ็ต หากไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน string_ids
type_ids_size uint จำนวนองค์ประกอบในรายการตัวระบุประเภท ไม่เกิน 65535
type_ids_off uint ออฟเซ็ตตั้งแต่เริ่มต้นของไฟล์จนถึงรายการตัวระบุประเภทหรือ 0 ถ้า type_ids_size == 0 (เป็นที่ยอมรับว่าเป็นตัวพิมพ์เล็กที่มีขอบแปลก) ออฟเซ็ต หากไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน type_ids
proto_ids_size uint จำนวนองค์ประกอบในรายการตัวระบุต้นแบบ มากสุด 65535
proto_ids_off uint ออฟเซ็ตตั้งแต่เริ่มต้นของไฟล์ไปยังรายการตัวระบุต้นแบบ หรือ 0 ถ้า proto_ids_size == 0 (ยอมรับว่าเป็นเคสขอบแปลก) ค่าชดเชย หากไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน proto_ids
field_ids_size uint จำนวนองค์ประกอบในรายการตัวระบุฟิลด์
field_ids_off uint offset จากจุดเริ่มต้นของไฟล์ไปยังรายการ field identifiers หรือ 0 if field_ids_size == 0 ค่าออฟเซ็ต หากไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน field_ids
method_ids_size uint จำนวนองค์ประกอบในรายการตัวระบุเมธอด
method_ids_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์ไปยังรายการตัวระบุเมธอด หรือ 0 ถ้า method_ids_size == 0 ออฟเซ็ต ถ้าไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน method_ids
class_defs_size uint การนับองค์ประกอบในรายการคำจำกัดความของคลาส
class_defs_off uint ออฟเซ็ตตั้งแต่เริ่มต้นของไฟล์จนถึงรายการคำจำกัดความของคลาส หรือ 0 ถ้า class_defs_size == 0 (ถือเป็นกรณีขอบแปลก) ออฟเซ็ต ถ้าไม่ใช่ศูนย์ ควรอยู่ที่จุดเริ่มต้นของส่วน class_defs
data_size uint ขนาดของส่วน data เป็นไบต์ ต้องเป็นทวีคูณของ sizeof(uint)
data_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์จนถึงจุดเริ่มต้นของส่วน data

map_list

ปรากฏในส่วนข้อมูล

อ้างอิงจาก header_item

การจัดตำแหน่ง: 4 ไบต์

นี่คือรายการเนื้อหาทั้งหมดของไฟล์ตามลำดับ มีความซ้ำซ้อนบางอย่างเกี่ยวกับ header_item แต่มีวัตถุประสงค์เพื่อให้เป็นรูปแบบที่ใช้งานง่ายเพื่อทำซ้ำในไฟล์ทั้งหมด ประเภทที่กำหนดจะต้องปรากฏอย่างมากที่สุดครั้งเดียวในแผนที่ แต่ไม่มีข้อจำกัดว่าประเภทคำสั่งใดที่อาจปรากฏในนั้น นอกเหนือจากข้อจำกัดที่บอกเป็นนัยโดยรูปแบบที่เหลือ (เช่น header ต้องปรากฏก่อน ตามด้วย string_ids ส่วน เป็นต้น) นอกจากนี้ รายการแผนที่ต้องเรียงลำดับตามออฟเซ็ตเริ่มต้นและต้องไม่ทับซ้อนกัน

ชื่อ รูปแบบ คำอธิบาย
ขนาด uint ขนาดของรายการในรายการ
รายการ map_item[ขนาด] องค์ประกอบของรายการ

map_item รูปแบบ

ชื่อ รูปแบบ คำอธิบาย
พิมพ์ ushort ประเภทของรายการ; ดูตารางด้านล่าง
ไม่ได้ใช้ ushort (ไม่ได้ใช้)
ขนาด uint นับจำนวนรายการที่จะพบที่ออฟเซ็ตที่ระบุ
offset uint ออฟเซ็ตจากจุดเริ่มต้นของไฟล์ไปยังรายการที่เป็นปัญหา

พิมพ์รหัส

ประเภทรายการ คงที่ ค่า ขนาดรายการเป็นไบต์
header_item TYPE_HEADER_ITEM 0x0000 0x70
string_id_item TYPE_STRING_ID_ITEM 0x0001 0x04
type_id_item TYPE_TYPE_ID_ITEM 0x0002 0x04
proto_id_item TYPE_PROTO_ID_ITEM 0x0003 0x0c
field_id_item TYPE_FIELD_ID_ITEM 0x0004 0x08
method_id_item TYPE_METHOD_ID_ITEM 0x0005 0x08
class_def_item TYPE_CLASS_DEF_ITEM 0x0006 0x20
call_site_id_item TYPE_CALL_SITE_ID_ITEM 0x0007 0x04
method_handle_item TYPE_METHOD_HANDLE_ITEM 0x0008 0x08
map_list TYPE_MAP_LIST 0x1000 4 + (รายการขนาด * 12)
type_list TYPE_TYPE_LIST 0x1001 4 + (รายการขนาด * 2)
annotation_set_ref_list TYPE_ANNOTATION_SET_REF_LIST 0x1002 4 + (รายการขนาด * 4)
annotation_set_item TYPE_ANNOTATION_SET_ITEM 0x1003 4 + (รายการขนาด * 4)
class_data_item TYPE_CLASS_DATA_ITEM 0x2000 โดยปริยาย; ต้องแยกวิเคราะห์
code_item TYPE_CODE_ITEM 0x2001 โดยปริยาย; ต้องแยกวิเคราะห์
string_data_item TYPE_STRING_DATA_ITEM 0x2002 โดยปริยาย; ต้องแยกวิเคราะห์
debug_info_item TYPE_DEBUG_INFO_ITEM 0x2003 โดยปริยาย; ต้องแยกวิเคราะห์
annotation_item TYPE_ANNOTATION_ITEM 0x2004 โดยปริยาย; ต้องแยกวิเคราะห์
encoded_array_item TYPE_ENCODED_ARRAY_ITEM 0x2005 โดยปริยาย; ต้องแยกวิเคราะห์
annotations_directory_item TYPE_ANNOTATIONS_DIRECTORY_ITEM 0x2006 โดยปริยาย; ต้องแยกวิเคราะห์
hiddenapi_class_data_item TYPE_HIDDENAPI_CLASS_DATA_ITEM 0xF000 โดยปริยาย; ต้องแยกวิเคราะห์

string_id_item

ปรากฏในส่วน string_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
string_data_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์เป็นข้อมูลสตริงสำหรับรายการนี้ ออฟเซ็ตควรเป็นตำแหน่งในส่วน data และข้อมูลควรอยู่ในรูปแบบที่ระบุโดย " string_data_item " ด้านล่าง ไม่มีข้อกำหนดการจัดตำแหน่งสำหรับออฟเซ็ต

string_data_item

ปรากฏในส่วนข้อมูล

การจัดตำแหน่ง: ไม่มี (จัดตำแหน่งแบบไบต์)

ชื่อ รูปแบบ คำอธิบาย
utf16_size uleb128 ขนาดของสตริงนี้ ในหน่วยโค้ด UTF-16 (ซึ่งก็คือ "ความยาวสตริง" ในหลายระบบ) นั่นคือนี่คือความยาวถอดรหัสของสตริง (ความยาวที่เข้ารหัสแสดงโดยตำแหน่งของ 0 ไบต์)
ข้อมูล ยูไบต์[] ชุดของหน่วยโค้ด MUTF-8 (aka octets หรือ aka bytes) ตามด้วยค่าไบต์ 0 ดู "การเข้ารหัส MUTF-8 (ดัดแปลง UTF-8)" ด้านบนสำหรับรายละเอียดและการอภิปรายเกี่ยวกับรูปแบบข้อมูล

หมายเหตุ: เป็นที่ยอมรับได้ที่จะมีสตริงซึ่งรวมถึง (รูปแบบที่เข้ารหัสของ) หน่วยรหัสตัวแทน UTF-16 (นั่นคือ U+d800 d800 … U+dfff ) ทั้งแบบแยกส่วนหรือไม่อยู่ในลำดับที่เกี่ยวข้องกับการเข้ารหัสปกติ ของ Unicode เป็น UTF-16 ขึ้นอยู่กับการใช้สตริงในระดับที่สูงขึ้นเพื่อปฏิเสธการเข้ารหัสที่ไม่ถูกต้องดังกล่าว หากเหมาะสม

type_id_item

ปรากฏในส่วน type_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
descriptor_idx uint ดัชนีลงในรายการ string_ids สำหรับสตริงอธิบายประเภทนี้ สตริงต้องสอดคล้องกับไวยากรณ์สำหรับ TypeDescriptor ที่กำหนดไว้ข้างต้น

proto_id_item

ปรากฏในส่วน proto_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
shorty_idx uint ดัชนีลงในรายการ string_ids สำหรับสตริงตัวอธิบายแบบสั้นของต้นแบบนี้ สตริงต้องสอดคล้องกับไวยากรณ์ของ ShortyDescriptor ซึ่งกำหนดไว้ข้างต้น และต้องสอดคล้องกับประเภทการส่งคืนและพารามิเตอร์ของรายการนี้
return_type_idx uint ดัชนีลงในรายการ type_ids สำหรับประเภทการส่งคืนของต้นแบบนี้
พารามิเตอร์_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์จนถึงรายการประเภทพารามิเตอร์สำหรับต้นแบบนี้ หรือ 0 หากต้นแบบนี้ไม่มีพารามิเตอร์ ออฟเซ็ตนี้ หากไม่ใช่ศูนย์ ควรอยู่ในส่วน data และข้อมูลควรมีอยู่ในรูปแบบที่ระบุโดย "type_list" ด้านล่าง นอกจากนี้ ไม่ควรมีการอ้างอิงถึงประเภท void ในรายการ

field_id_item

ปรากฏในส่วน field_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
class_idx ushort ดัชนีลงในรายการ type_ids สำหรับผู้กำหนดของฟิลด์นี้ ต้องเป็นประเภทคลาส ไม่ใช่อาร์เรย์หรือประเภทดั้งเดิม
type_idx ushort ดัชนีลงในรายการ type_ids สำหรับประเภทของฟิลด์นี้
name_idx uint ดัชนีลงในรายการ string_ids สำหรับชื่อของฟิลด์นี้ สตริงต้องสอดคล้องกับไวยากรณ์สำหรับ MemberName ที่กำหนดไว้ข้างต้น

method_id_item

ปรากฏในส่วน method_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
class_idx ushort ดัชนีลงในรายการ type_ids สำหรับผู้กำหนดเมธอดนี้ ต้องเป็นประเภทคลาสหรืออาร์เรย์ ไม่ใช่ประเภทพื้นฐาน
proto_idx ushort ดัชนีลงในรายการ proto_ids สำหรับต้นแบบของวิธีนี้
name_idx uint ดัชนีลงในรายการ string_ids สำหรับชื่อของเมธอดนี้ สตริงต้องสอดคล้องกับไวยากรณ์สำหรับ MemberName ที่กำหนดไว้ข้างต้น

class_def_item

ปรากฏในหมวด class_defs

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
class_idx uint ดัชนีลงในรายการ type_ids สำหรับคลาสนี้ ต้องเป็นประเภทคลาส ไม่ใช่อาร์เรย์หรือประเภทดั้งเดิม
access_flags uint แฟล็กการเข้าถึงสำหรับคลาส ( public , final , ฯลฯ ) ดู "คำจำกัดความ access_flags " สำหรับรายละเอียด
superclass_idx uint ดัชนีลงในรายการ type_ids สำหรับซูเปอร์คลาส หรือค่าคงที่ NO_INDEX หากคลาสนี้ไม่มีซูเปอร์คลาส (กล่าวคือ เป็นคลาสรูท เช่น Object ) หากมี ต้องเป็นประเภทคลาส ไม่ใช่อาร์เรย์หรือประเภทดั้งเดิม
interfaces_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์จนถึงรายการอินเตอร์เฟส หรือ 0 หากไม่มี ออฟเซ็ตนี้ควรอยู่ในส่วน data และข้อมูลควรมีอยู่ในรูปแบบที่ระบุโดย " type_list " ด้านล่าง องค์ประกอบแต่ละรายการของรายการจะต้องเป็นประเภทคลาส (ไม่ใช่อาร์เรย์หรือประเภทดั้งเดิม) และต้องไม่ซ้ำกัน
source_file_idx uint ดัชนีลงในรายการ string_ids สำหรับชื่อของไฟล์ที่มีแหล่งที่มาดั้งเดิมสำหรับคลาสนี้ (อย่างน้อยที่สุด) หรือค่าพิเศษ NO_INDEX เพื่อแสดงถึงการขาดข้อมูลนี้ debug_info_item ของวิธีการใด ๆ ที่กำหนดอาจแทนที่ไฟล์ต้นฉบับนี้ แต่ความคาดหวังก็คือคลาสส่วนใหญ่จะมาจากไฟล์ต้นทางเดียวเท่านั้น
annotations_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์จนถึงโครงสร้างคำอธิบายประกอบสำหรับคลาสนี้ หรือ 0 หากไม่มีคำอธิบายประกอบในคลาสนี้ ออฟเซ็ตนี้ หากไม่ใช่ศูนย์ ควรอยู่ในส่วน data และข้อมูลควรมีอยู่ในรูปแบบที่ระบุโดย " annotations_directory_item " ด้านล่าง โดยมีรายการทั้งหมดที่อ้างถึงคลาสนี้เป็นตัวกำหนด
class_data_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์เป็นข้อมูลคลาสที่เกี่ยวข้องสำหรับรายการนี้ หรือ 0 หากไม่มีข้อมูลคลาสสำหรับคลาสนี้ (อาจเป็นกรณีนี้ ตัวอย่างเช่น ถ้าคลาสนี้เป็นอินเทอร์เฟซตัวทำเครื่องหมาย) ออฟเซ็ต หากไม่ใช่ศูนย์ ควรอยู่ในส่วน data และข้อมูลควรมีในรูปแบบที่ระบุโดย " class_data_item " ด้านล่าง โดยมีรายการทั้งหมดที่อ้างถึงคลาสนี้เป็นตัวกำหนด
static_values_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์จนถึงรายการค่าเริ่มต้นสำหรับฟิลด์ส static หรือ 0 หากไม่มี (และฟิลด์ส static ทั้งหมดจะต้องเริ่มต้นด้วย 0 หรือ null ) ออฟเซ็ตนี้ควรอยู่ในส่วน data และข้อมูลควรอยู่ในรูปแบบที่ระบุโดย " encoded_array_item " ด้านล่าง ขนาดของอาร์เรย์ต้องไม่มากกว่าจำนวนฟิลด์ส static ประกาศโดยคลาสนี้ และอิลิเมนต์จะสอดคล้องกับฟิลด์ส static ในลำดับเดียวกับที่ประกาศใน field_list ที่สอดคล้องกัน ประเภทขององค์ประกอบอาร์เรย์แต่ละรายการต้องตรงกับประเภทที่ประกาศของฟิลด์ที่เกี่ยวข้อง หากมีองค์ประกอบในอาร์เรย์น้อยกว่าฟิลด์ส static ฟิลด์ที่เหลือจะถูกเริ่มต้นด้วย 0 หรือ null ที่เหมาะสมกับประเภท

call_site_id_item

ปรากฏในส่วน call_site_ids

การจัดตำแหน่ง: 4 ไบต์

ชื่อ รูปแบบ คำอธิบาย
call_site_off uint ออฟเซ็ตตั้งแต่เริ่มต้นไฟล์เพื่อเรียกข้อกำหนดไซต์ ออฟเซ็ตควรอยู่ในส่วนข้อมูล และข้อมูลควรมีอยู่ในรูปแบบที่ระบุโดย "call_site_item" ด้านล่าง

call_site_item

ปรากฏในส่วนข้อมูล

การจัดตำแหน่ง: ไม่มี (จัดตำแหน่งไบต์)

call_site_item เป็น encoded_array_item ซึ่งมีองค์ประกอบที่สอดคล้องกับอาร์กิวเมนต์ที่ให้ไว้กับเมธอดตัวเชื่อมโยงบูตสแตรป อาร์กิวเมนต์สามข้อแรกคือ:

  1. ตัวจัดการเมธอดที่แสดงเมธอดตัวเชื่อมโยงบูตสแตรป (VALUE_METHOD_HANDLE)
  2. ชื่อเมธอดที่ตัวเชื่อมโยงบูตสแตรปควรแก้ไข (VALUE_STRING)
  3. ประเภทเมธอดที่สอดคล้องกับประเภทของชื่อเมธอดที่จะแก้ไข (VALUE_METHOD_TYPE)

Any additional arguments are constant values passed to the bootstrap linker method. These arguments are passed in order and without any type conversions.

The method handle representing the bootstrap linker method must have return type java.lang.invoke.CallSite . The first three parameter types are:

  1. java.lang.invoke.Lookup
  2. java.lang.String
  3. java.lang.invoke.MethodType

The parameter types of any additional arguments are determined from their constant values.

method_handle_item

appears in the method_handles section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
method_handle_type ushort type of the method handle; see table below
unused ushort (unused)
field_or_method_id ushort Field or method id depending on whether the method handle type is an accessor or a method invoker
unused ushort (unused)

Method Handle Type Codes

Constant ค่า คำอธิบาย
METHOD_HANDLE_TYPE_STATIC_PUT 0x00 Method handle is a static field setter (accessor)
METHOD_HANDLE_TYPE_STATIC_GET 0x01 Method handle is a static field getter (accessor)
METHOD_HANDLE_TYPE_INSTANCE_PUT 0x02 Method handle is an instance field setter (accessor)
METHOD_HANDLE_TYPE_INSTANCE_GET 0x03 Method handle is an instance field getter (accessor)
METHOD_HANDLE_TYPE_INVOKE_STATIC 0x04 Method handle is a static method invoker
METHOD_HANDLE_TYPE_INVOKE_INSTANCE 0x05 Method handle is an instance method invoker
METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR 0x06 Method handle is a constructor method invoker
METHOD_HANDLE_TYPE_INVOKE_DIRECT 0x07 Method handle is a direct method invoker
METHOD_HANDLE_TYPE_INVOKE_INTERFACE 0x08 Method handle is an interface method invoker

class_data_item

referenced from class_def_item

appears in the data section

alignment: none (byte-aligned)

Name รูปแบบ คำอธิบาย
static_fields_size uleb128 the number of static fields defined in this item
instance_fields_size uleb128 the number of instance fields defined in this item
direct_methods_size uleb128 the number of direct methods defined in this item
virtual_methods_size uleb128 the number of virtual methods defined in this item
static_fields encoded_field[static_fields_size] the defined static fields, represented as a sequence of encoded elements. The fields must be sorted by field_idx in increasing order.
instance_fields encoded_field[instance_fields_size] the defined instance fields, represented as a sequence of encoded elements. The fields must be sorted by field_idx in increasing order.
direct_methods encoded_method[direct_methods_size] the defined direct (any of static , private , or constructor) methods, represented as a sequence of encoded elements. The methods must be sorted by method_idx in increasing order.
virtual_methods encoded_method[virtual_methods_size] the defined virtual (none of static , private , or constructor) methods, represented as a sequence of encoded elements. This list should not include inherited methods unless overridden by the class that this item represents. The methods must be sorted by method_idx in increasing order. The method_idx of a virtual method must not be the same as any direct method.

Note: All elements' field_id s and method_id s must refer to the same defining class.

encoded_field format

Name รูปแบบ คำอธิบาย
field_idx_diff uleb128 index into the field_ids 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.
access_flags uleb128 access flags for the field ( public , final , etc.). See " access_flags Definitions" for details.

encoded_method format

Name รูปแบบ คำอธิบาย
method_idx_diff uleb128 index into the method_ids 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.
access_flags uleb128 access flags for the method ( public , final , etc.). See " access_flags Definitions" for details.
code_off uleb128 offset from the start of the file to the code structure for this method, or 0 if this method is either abstract or native . The offset should be to a location in the data section. The format of the data is specified by " code_item " below.

type_list

referenced from class_def_item and proto_id_item

appears in the data section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
size uint size of the list, in entries
list type_item[size] elements of the list

type_item format

Name รูปแบบ คำอธิบาย
type_idx ushort index into the type_ids list

code_item

referenced from encoded_method

appears in the data section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
registers_size ushort the number of registers used by this code
ins_size ushort the number of words of incoming arguments to the method that this code is for
outs_size ushort the number of words of outgoing argument space required by this code for method invocation
tries_size ushort the number of try_item s for this instance. If non-zero, then these appear as the tries array just after the insns in this instance.
debug_info_off uint offset from the start of the file to the debug info (line numbers + local variable info) sequence for this code, or 0 if there simply is no information. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " debug_info_item " below.
insns_size uint size of the instructions list, in 16-bit code units
insns ushort[insns_size] actual array of bytecode. The format of code in an insns array is specified by the companion document Dalvik bytecode . Note that though this is defined as an array of ushort , 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 only done on individual ushort s and not on the larger internal structures.
padding ushort (optional) = 0 two bytes of padding to make tries four-byte aligned. This element is only present if tries_size is non-zero and insns_size is odd.
tries try_item[tries_size] (optional) array indicating where in the code exceptions are 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 tries_size is non-zero.
handlers encoded_catch_handler_list (optional) bytes representing a list of lists of catch types and associated handler addresses. Each try_item has a byte-wise offset into this structure. This element is only present if tries_size is non-zero.

try_item format

Name รูปแบบ คำอธิบาย
start_addr uint 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.
insn_count ushort number of 16-bit code units covered by this entry. The last code unit covered (inclusive) is start_addr + insn_count - 1 .
handler_off ushort offset in bytes from the start of the associated encoded_catch_hander_list to the encoded_catch_handler for this entry. This must be an offset to the start of an encoded_catch_handler .

encoded_catch_handler_list format

Name รูปแบบ คำอธิบาย
size uleb128 size of this list, in entries
list encoded_catch_handler[handlers_size] actual list of handler lists, represented directly (not as offsets), and concatenated sequentially

encoded_catch_handler format

Name รูปแบบ คำอธิบาย
size sleb128 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 size of 0 means that there is a catch-all but no explicitly typed catches. A size of 2 means that there are two explicitly typed catches and no catch-all. And a size of -1 means that there is one typed catch along with a catch-all.
handlers encoded_type_addr_pair[abs(size)] stream of abs(size) encoded items, one for each caught type, in the order that the types should be tested.
catch_all_addr uleb128 (optional) bytecode address of the catch-all handler. This element is only present if size is non-positive.

encoded_type_addr_pair format

Name รูปแบบ คำอธิบาย
type_idx uleb128 index into the type_ids list for the type of the exception to catch
addr uleb128 bytecode address of the associated exception handler

debug_info_item

referenced from code_item

appears in the data section

alignment: none (byte-aligned)

Each debug_info_item defines a DWARF3-inspired byte-coded state machine that, when interpreted, emits the positions table and (potentially) the local variable information for a code_item . 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 DBG_END_SEQUENCE byte.

The state machine consists of five registers. The address register represents the instruction offset in the associated insns_item in 16-bit code units. The address register starts at 0 at the beginning of each debug_info sequence and must only monotonically increase. The line 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 1 . The source_file register represents the source file that the line number entries refer to. It is initialized to the value of source_file_idx in class_def_item . The other two variables, prologue_end and epilogue_begin , are boolean flags (initialized to false ) 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 DBG_RESTART_LOCAL code.

The header is as follows:

Name รูปแบบ คำอธิบาย
line_start uleb128 the initial value for the state machine's line register. Does not represent an actual positions entry.
parameters_size uleb128 the number of parameter names that are encoded. There should be one per method parameter, excluding an instance method's this , if any.
parameter_names uleb128p1[parameters_size] string index of the method parameter name. An encoded value of NO_INDEX indicates that no name is available for the associated parameter. The type descriptor and signature are implied from the method descriptor and signature.

The byte code values are as follows:

Name ค่า รูปแบบ Arguments คำอธิบาย
DBG_END_SEQUENCE 0x00 (none) terminates a debug info sequence for a code_item
DBG_ADVANCE_PC 0x01 uleb128 addr_diff addr_diff : amount to add to address register advances the address register without emitting a positions entry
DBG_ADVANCE_LINE 0x02 sleb128 line_diff line_diff : amount to change line register by advances the line register without emitting a positions entry
DBG_START_LOCAL 0x03 uleb128 register_num
uleb128p1 name_idx
uleb128p1 type_idx
register_num : register that will contain local
name_idx : string index of the name
type_idx : type index of the type
introduces a local variable at the current address. Either name_idx or type_idx may be NO_INDEX to indicate that that value is unknown.
DBG_START_LOCAL_EXTENDED 0x04 uleb128 register_num
uleb128p1 name_idx
uleb128p1 type_idx
uleb128p1 sig_idx
register_num : register that will contain local
name_idx : string index of the name
type_idx : type index of the type
sig_idx : string index of the type signature
introduces a local with a type signature at the current address. Any of name_idx , type_idx , or sig_idx may be NO_INDEX to indicate that that value is unknown. (If sig_idx is -1 , though, the same data could be represented more efficiently using the opcode DBG_START_LOCAL .)

Note: See the discussion under " dalvik.annotation.Signature " below for caveats about handling signatures.

DBG_END_LOCAL 0x05 uleb128 register_num register_num : register that contained local marks a currently-live local variable as out of scope at the current address
DBG_RESTART_LOCAL 0x06 uleb128 register_num register_num : register to restart 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.
DBG_SET_PROLOGUE_END 0x07 (none) sets the prologue_end 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 prologue_end register is cleared by any special ( >= 0x0a ) opcode.
DBG_SET_EPILOGUE_BEGIN 0x08 (none) sets the epilogue_begin 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 epilogue_begin register is cleared by any special ( >= 0x0a ) opcode.
DBG_SET_FILE 0x09 uleb128p1 name_idx name_idx : string index of source file name; NO_INDEX if unknown indicates that all subsequent line number entries make reference to this source file name, instead of the default name specified in code_item
Special Opcodes 0x0a…0xff (none) advances the line and address registers, emits a position entry, and clears prologue_end and epilogue_begin . See below for description.

Special opcodes

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

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)

annotations_directory_item

referenced from class_def_item

appears in the data section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
class_annotations_off uint offset from the start of the file to the annotations made directly on the class, or 0 if the class has no direct annotations. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " annotation_set_item " below.
fields_size uint count of fields annotated by this item
annotated_methods_size uint count of methods annotated by this item
annotated_parameters_size uint count of method parameter lists annotated by this item
field_annotations field_annotation[fields_size] (optional) list of associated field annotations. The elements of the list must be sorted in increasing order, by field_idx .
method_annotations method_annotation[methods_size] (optional) list of associated method annotations. The elements of the list must be sorted in increasing order, by method_idx .
parameter_annotations parameter_annotation[parameters_size] (optional) list of associated method parameter annotations. The elements of the list must be sorted in increasing order, by method_idx .

Note: All elements' field_id s and method_id s must refer to the same defining class.

field_annotation format

Name รูปแบบ คำอธิบาย
field_idx uint index into the field_ids list for the identity of the field being annotated
annotations_off uint offset from the start of the file to the list of annotations for the field. The offset should be to a location in the data section. The format of the data is specified by " annotation_set_item " below.

method_annotation format

Name รูปแบบ คำอธิบาย
method_idx uint index into the method_ids list for the identity of the method being annotated
annotations_off uint offset from the start of the file to the list of annotations for the method. The offset should be to a location in the data section. The format of the data is specified by " annotation_set_item " below.

parameter_annotation format

Name รูปแบบ คำอธิบาย
method_idx uint index into the method_ids list for the identity of the method whose parameters are being annotated
annotations_off uint 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 data section. The format of the data is specified by " annotation_set_ref_list " below.

annotation_set_ref_list

referenced from parameter_annotations_item

appears in the data section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
size uint size of the list, in entries
list annotation_set_ref_item[size] elements of the list

annotation_set_ref_item format

Name รูปแบบ คำอธิบาย
annotations_off uint offset from the start of the file to the referenced annotation set or 0 if there are no annotations for this element. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " annotation_set_item " below.

annotation_set_item

referenced from annotations_directory_item, field_annotations_item, method_annotations_item, and annotation_set_ref_item

appears in the data section

alignment: 4 bytes

Name รูปแบบ คำอธิบาย
size uint size of the set, in entries
entries annotation_off_item[size] elements of the set. The elements must be sorted in increasing order, by type_idx .

annotation_off_item format

Name รูปแบบ คำอธิบาย
annotation_off uint offset from the start of the file to an annotation. The offset should be to a location in the data section, and the format of the data at that location is specified by " annotation_item " below.

annotation_item

referenced from annotation_set_item

appears in the data section

alignment: none (byte-aligned)

Name รูปแบบ คำอธิบาย
visibility ubyte intended visibility of this annotation (see below)
annotation encoded_annotation encoded annotation contents, in the format described by " encoded_annotation format" under " encoded_value encoding" above.

Visibility values

These are the options for the visibility field in an annotation_item :

Name ค่า คำอธิบาย
VISIBILITY_BUILD 0x00 intended only to be visible at build time (eg, during compilation of other code)
VISIBILITY_RUNTIME 0x01 intended to visible at runtime
VISIBILITY_SYSTEM 0x02 intended to visible at runtime, but only to the underlying system (and not to regular user code)

encoded_array_item

referenced from class_def_item

appears in the data section

alignment: none (byte-aligned)

Name รูปแบบ คำอธิบาย
value encoded_array bytes representing the encoded array value, in the format specified by " encoded_array Format" under " encoded_value Encoding" above.

hiddenapi_class_data_item

This section contains data on restricted interfaces used by each class.

Note: The hidden API feature was introduced in Android 10.0 and is only applicable to the DEX files of classes in the boot class path. The list of flags described below may be extended in the future releases of Android. For more information, see restrictions on non-SDK interfaces .

Name รูปแบบ คำอธิบาย
size uint total size of the section
offsets uint[] array of offsets indexed by class_idx . A zero array entry at index class_idx means that either there is no data for this class_idx , or all hidden API flags are zero. Otherwise the array entry is non-zero and contains an offset from the beginning of the section to an array of hidden API flags for this class_idx .
flags uleb128[] concatenated arrays of hidden API flags for each class. Possible flag values are described in the table below. Flags are encoded in the same order as fields and methods are encoded in class data.

Restriction flag types:

Name ค่า คำอธิบาย
whitelist 0 Interfaces that can be freely used and are supported as part of the officially documented Android framework Package Index .
greylist 1 Non-SDK interfaces that can be used regardless of the application's target API level .
blacklist 2 Non-SDK interfaces that cannot be used regardless of the application's target API level . Accessing one of these interfaces causes a runtime error .
greylist‑max‑o 3 Non-SDK interfaces that can be used for Android 8.x and below unless they are restricted.
greylist‑max‑p 4 Non-SDK interfaces that can be used for Android 9.x unless they are restricted.
greylist‑max‑q 5 Non-SDK interfaces that can be used for Android 10.x unless they are restricted.
greylist‑max‑r 6 Non-SDK interfaces that can be used for Android 11.x unless they are restricted.

System annotations

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.

System annotations are represented in .dex files as annotations with visibility set to VISIBILITY_SYSTEM .

dalvik.annotation.AnnotationDefault

appears on methods in annotation interfaces

An AnnotationDefault annotation is attached to each annotation interface which wishes to indicate default bindings.

Name รูปแบบ คำอธิบาย
value Annotation 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.

dalvik.annotation.EnclosingClass

appears on classes

An EnclosingClass 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 (eg, a synthetic inner class). Every class that has this annotation must also have an InnerClass annotation. Additionally, a class must not have both an EnclosingClass and an EnclosingMethod annotation.

Name รูปแบบ คำอธิบาย
value Class the class which most closely lexically scopes this class

dalvik.annotation.EnclosingMethod

appears on classes

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

Name รูปแบบ คำอธิบาย
value Method the method which most closely lexically scopes this class

dalvik.annotation.InnerClass

appears on classes

An InnerClass 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 either an EnclosingClass annotation or an EnclosingMethod annotation.

Name รูปแบบ คำอธิบาย
name String the originally declared simple name of this class (not including any package prefix). If this class is anonymous, then the name is null .
accessFlags int 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)

dalvik.annotation.MemberClasses

appears on classes

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

Name รูปแบบ คำอธิบาย
value Class[] array of the member classes

dalvik.annotation.MethodParameters

appears on methods

Note: This annotation was added after Android 7.1. Its presence on earlier Android releases will be ignored.

A MethodParameters annotation is optional and can be used to provide parameter metadata such as parameter names and modifiers.

The annotation can be omitted from a method or constructor safely when the parameter metadata is not required at runtime. java.lang.reflect.Parameter.isNamePresent() can be used to check whether metadata is present for a parameter, and the associated reflection methods such as java.lang.reflect.Parameter.getName() will fall back to default behavior at runtime if the information is not present.

When including parameter metadata, compilers must include information for generated classes such as enums, since the parameter metadata includes whether or not a parameter is synthetic or mandated.

A MethodParameters annotation describes only individual method parameters. Therefore, compilers may omit the annotation entirely for constructors and methods that have no parameters, for the sake of code-size and runtime efficiency.

The arrays documented below must be the same size as for the method_id_item dex structure associated with the method, otherwise a java.lang.reflect.MalformedParametersException will be thrown at runtime.

That is: method_id_item.proto_idx -> proto_id_item.parameters_off -> type_list.size must be the same as names().length and accessFlags().length .

Because MethodParameters describes all formal method parameters, even those not explicitly or implicitly declared in source code, the size of the arrays may differ from the Signature or other metadata information that is based only on explicit parameters declared in source code. MethodParameters will also not include any information about type annotation receiver parameters that do not exist in the actual method signature.

Name รูปแบบ คำอธิบาย
names String[] The names of formal parameters for the associated method. The array must not be null but must be empty if there are no formal parameters. A value in the array must be null if the formal parameter with that index has no name.
If parameter name strings are empty or contain '.', ';', '[' or '/' then a java.lang.reflect.MalformedParametersException will be thrown at runtime.
accessFlags int[] The access flags of the formal parameters for the associated method. The array must not be null but must be empty if there are no formal parameters.
The value is a bit mask with the following values:
  • 0x0010 : final, the parameter was declared final
  • 0x1000 : synthetic, the parameter was introduced by the compiler
  • 0x8000 : mandated, the parameter is synthetic but also implied by the language specification
If any bits are set outside of this set then a java.lang.reflect.MalformedParametersException will be thrown at runtime.

dalvik.annotation.Signature

appears on classes, fields, and methods

A Signature annotation is attached to each class, field, or method which is defined in terms of a more complicated type than is representable by a type_id_item . The .dex 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.

Because signature strings tend to have a lot of duplicated content, a Signature annotation is defined as an array 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 .dex files.

Name รูปแบบ คำอธิบาย
value String[] the signature of this class or member, as an array of strings that is to be concatenated together

dalvik.annotation.Throws

appears on methods

A Throws annotation is attached to each method which is declared to throw one or more exception types.

Name รูปแบบ คำอธิบาย
value Class[] the array of exception types thrown