1.Class文件

Java Class文件结构定义如下:

u4 magic

u2 minor_version

u2 major_version

u2 contant_pool_count

cp_info contant_pool[contant_pool_count - 1]  // 常量池表

u2 access_flags

u2 this_class

u2 super_class

u2 interfaces_count

u2 interfaces[interfaces_count]

u2 fields_count

field_info fields[fields_count]  // 字段表

u2 methods_count

method_info methods[methods_count]  // 方法表

u2 attributes_count

attribute_info attributes[attributes_count]  // 属性表

 

常量池表项

表项名称

结构定义

备注

CONTANT_Class

{

u1 tag;

u2 class_name_index;

}

 

CONTANT_MethodRef

{

u1 tag;

u2 class_name_index;

u2 name_and_type_index;

}

 

CONTANT_FieldRef

CONTANT_InterfaceMethodRef

CONTANT_NameAndType

{

u1 tag;

u2 name_index;

u2 descriptor_index;

}

 

CONTANT_Integer

{

u1 tag;

u4 bytes;

}

 

CONTANT_Float

CONTANT_Long

{

u1 tag;

u2 high_bytes;

u2 low_bytes;

}

 

CONTANT_Double

CONTANT_Utf8

{

u1 tag;

u2 length;

u1 bytes[length];

}

 

 

field_info结构

{

u2 access_flags;

u2 name_index;

u2 descriptor_index;

u2 attributes_count;

attribute_info attributes[attribute_count];

}

 

method_info结构

{

u2 access_flags;

u2 name_index;

u2 descriptor_index;

u2 attributes_count;

attribute_info attributes[attribute_count];

}

 

attribute_info结构

{

u2 attribute_name_index;

u4 attribute_length;

u1 info[attribute_length];

}

 

注:

(1)以下属性用来修饰方法

Code属性

LineNumberTable属性

LocalVariableTable属性

Deprecated属性*

(2)以下属性用来修饰类

FileSource属性

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值