怎敢精——jvm.class文件格式

calssfile由字节流组成,最小单位是byte,8个字节,CLASS文件中通常都是16位,32位和64位,通过构造2个4个和8个连续字节来表示。

文中用u1 u2  u4分别表示1个,2个,4个8字节的无符号数

calssFile的简略格式如下

ClassFile{
    u4                magic;  //魔数
    u2                minor_version;  // 副版本号
    u2                major_version;  // 主版本号
    u2                constant_pool_count;  // 常量池计数器
    cp_info            constant_pool[constant_pool_count-1];  // 常量池
    u2                access_flags;  // 访问标志
    u2                this_class;  // 类索引
    u2                super_class;   // 父类索引
    u2                interface_count;  // 接口计数器
    u2                interface[interface_count];   // 接口表
    u2                fields_count;  // 字段计数器
    field_info        fields[fields_count]  // 字段表
    u2                methods_count  // 方法计数器
    method_info        mthods[methods_count]  // 方法表
    u2                attributes_count   // 属性计数器
    attribute_info    attributes[attributes_count]  // 属性表
}

猜你喜欢

转载自blog.csdn.net/a397525088/article/details/81670216