根據 JVM 規範的規定,Class文件格式採用一種類似C語言結構體的僞結構體存儲數據。這種僞結構只有兩種數據類型:無符號和表。
無符號
- 基本的數據類型,u1、u2、u3、u4分別代表1個字節,2個字節,4個字節,8個字節的無符號數
- 可以描述數字、索引引用、數量值或者按照UTF-8編碼構成字符串值
表
-
多個無符號數或者其他表作爲數據項構成的符合數據類型
-
默認情況,表都是以“_info”結尾
-
整個Class文件本質上就是一張表
類型 名稱 數量 u4 magic 1 u2 minor_version 1 u2 major_version 1 u2 constant_pool_count 1 cp_info constant_pool constant_pool_count-1 u2 access_flags 1 u2 this_class 1 u2 super_class 1 u2 Interfaces_count 1 u2 interfaces interfaces_count u2 fields_count 1 field_info fields 1 u2 methods_count 1 method_info methods methods_count u2 attributes_count 1 attribute_info attributes attributes_count