The Field table (Field_info) is used to describe the variables declared in an interface or class. A field includes a class-level variable or an instance variable, but does not include a variable declared inside a method. The information describing a field is the scope of the field (the public,private,protected modifier), the class-level variable or the instance-level variable (static modifier), the variability (final), the concurrency visibility (volatile modifier, whether to force read and write from the main memory) ), whether serializable (transient modifier), field data type (base data type, object, array), field name. In this information, each modifier is a Boolean value, either has a modifier or is not, and is appropriate to use the flag bit to represent. When the field is named, the field is defined why the data type, these are not fixed, can only refer to constants in the constant pool to describe. The following is the final format of the field table.
The field modifier is placed in the Access_flags project, which is very similar to the class's Access_flags project, and is a U2 data type where you can set the flag bit and meaning as follows in the table:
The following Access_flags flags are two index values: Name_index and Descriptor_index. They are references to the constant pool, which represents the simple name of the field and the descriptor of the field. Now you need to explain the concept of "simple name", "descriptor" and the three special strings of "fully qualified name", which have appeared many times before.
Full-restricted name and simple name well understood, such as "Org/fenixsoft/clazz/testclass" is a class full-restricted name, just the class name in the "." Replaced with a "/", in order to make a continuous number of fully qualified names without confusion between the use of the end will generally add a ";" Number indicates the end of the fully qualified name. A simple name refers to a method or field name that does not have a type and parameter decoration.
Methods and field descriptors are more complex than fully qualified names and simple names. Descriptors are used to describe the data type of the field, the parameter list of the method (including quantity, type, and order), and the return value. According to the descriptor rules, the base data type (Byte,char,double,float,int,long,short,boolean) and the void type representing no return value are represented by a uppercase character, while the object type is represented by the character L plus the fully qualified name of the object. Such as:
For array types, each dimension uses a predecessor "[" character to describe a two-dimensional array defined as "java.lang.string[][]", which is recorded as: "[[Java/lang/string;", an Integer array "int[]" will be recorded as "[ I ".
When describing a method with a descriptor, the list of parameters is described in the order of the first parameter list, followed by the sequence of the returned values, within a set of parentheses "()" in the strict order of the parameters. If the method void Int () descriptor is: "() V", the Method java.lang.String toString () descriptor is: "() java/lang/string;"
The field table contains a fixed data item that ends at Descriptor_index, but after descriptor_index follows an attribute table collection for storing some extra information, the field can describe 0 of the most additional information in the attribute table. Fields inherited from a superclass or parent interface are not listed in the Field table collection, but it is possible to list fields that do not exist in the original Java code, such as in an inner class that, in order to maintain access to an external class, automatically adds a field to the external class instance. In addition, fields in the Java language cannot be overloaded, the data types of two fields, and modifiers, regardless of whether they are the same, must use a different name, but for field codes, if the descriptors of two fields are inconsistent, the names of the fields are legal.
In-depth understanding of Java Virtual Machine Notes---Field table collection