Fields set of tables
Field tables set is the set of tables of several fields.
Table field (field_info) used to describe variables declared in the class or interface to, a field (field) comprises a class instance variables and class variables level, but does not include local variables declared inside method.
1. Information contained
- Scope field (public, private, protected modifier).
- It is an instance variable or class variable (static modifier).
- Variability (final).
- Concurrent visibility (volatile modifier, whether to force from the main memory read and write).
- It can be serialized (transient modifier).
- Field data type (basic types, objects, arrays).
- Field Name
The above information, each modifier is a Boolean value, or there is a modifier, or not, fit in a flag. Field Name, type is not fixed, can only be used to describe the constant in the constant pool.
Table 2. Structure field (field_info) Composition
Access flag (access_flags), name index (name_index), description Index (descriptor_index), a collection of attribute table
3. Case
public class TestConstant {
private final int a = 10;
private final int b = 10;
private int c = 11;
private int d = 11;
private long e = -11111110005514L;
private long f = -11111110005514L;
private double g = 10.4557848D;
private double h = 10.4557848D;
private String y = "JVM";
private String j = "JVM";
}
Immediately after the interface index is a collection of fields of the table
Number of fields: 0x000A (corresponding to the decimal value 10), the number of fields is 10.
Table 4. Field set Case
It can be learned
- Field access flags: 0x0012 = (0x0002 + 0x00010), the modifier field is private + final.
- Field Name: 0x0013 (corresponding to decimal 19), 19, pointing to the name field constant pool is a.
- Field Data Type: 0x0014 (corresponding to decimal 20), 20, corresponding to the constant pool types directed to int.
- Counter attribute table: 0x0001 (corresponding to decimal 1), there is a corresponding property table.
- 属性表名称索引:0x0015(对应的十进制为21),指向常量池的21,ConstantValue。
- 属性长度:0x0002,因此该属性的的ConstantValue类型,固定值为2.
- 常量值索引:0x0016(对应的十进制为22),指向常量池的22,对应的字段值为10。
依次类推