1. 程式人生 > >[一]class 檔案淺析 .class檔案格式詳解 欄位方法屬性常量池欄位 class檔案屬性表 資料型別 資料結構

[一]class 檔案淺析 .class檔案格式詳解 欄位方法屬性常量池欄位 class檔案屬性表 資料型別 資料結構

ClassFile {
u4 magic;//唯一作用是確定這個檔案是否為一個能被虛擬機器所接受的class檔案。魔數值固定為0xCAFEBABE,不會改變
u2 minor_version;//唯一作用是確定這個檔案是否為一個能被虛擬機器所接受的class檔案。魔數值固定為0xCAFEBABE,不會改變
u2 major_version;//主版本號
u2 constant_pool_count;//常量池計數  值等於常量池表中的成員個數加1
cp_info constant_pool[constant_pool_count-1];//常量池 1~ constant_pool_count-1 為索引
u2 access_flags;
//訪問標誌以及型別資訊 u2 this_class;//當前類索引 指向常量池中一個CONSTANT_Class_info u2 super_class;//父類索引 0 或者指向常量池中一個CONSTANT_Class_info u2 interfaces_count;//直接超介面數量 u2 interfaces[interfaces_count];//介面表 u2 fields_count;//欄位個數 static類變數或者非sttic的例項變數 不包括繼承的 field_info fields[fields_count];//欄位表 u2 methods_count;//方法個數 所有方法 但不包括繼承而來的
method_info methods[methods_count];//方法表 u2 attributes_count;//屬性個數 attribute_info attributes[attributes_count];/屬性表 }