1: magic number: 4 bytes, OxCAFEBABE which can help to recognize a java class file easily
2: minor_version and major_version: 4 bytes
for example,in java 2 platform the major_version is updated from 45 ro 46, and the minor_version depends on specifical platform and its version
3: constant_pool_count and constant_pool:
a constant pool includes the const field assiciated with class and interface. it will keep the titles such as String, final field, class name and method name. the first index of this list is 1, but the index 0 will be added into the contant_pool_count. so if you have 14 items in the pool the contant_pool_count will 15.
every entrance of the contant pool will start with a byte length which is used as a flag pointing out the type of the contant.
contant pool flag
CONSTANT_Utf8 1 Unicode String
CONSTANT_Integer 3 int
CONSTANT_Float 4 float
CONSTANT_Long 5 long
CONSTANT_Double 6 double
CONSTANT_Class 7 the reference to a class or an interface
CONSTANT_String 8 String value
CONSTANT_Fieldref 9 a field reference
CONSTANT_Methodref10 a method reference in this class
CONSTANT_InterfaceMethodref 11 a method reference defined in a interface
CONSTANT_NameAndType 12 a part reference to a field or method
the contant pool play a important role int the dynamic stage. the JVM will load a reference and analyse for the actual address.
4:access_flags: 2 bytes, it figures out this class file represents a class or a interface and what is its decoration.
ACC_PUBLIC 0X0001 public type class and interface
ACC_FINAL 0X0010 final type class
ACC_SUPER 0X0020 use the new sementeme of invokespecial class and interface
ACC_INTERFACE 0X0200 interface type interface
ACC_ABSTRACT 0X0400 abstract type interface and part of class
5: this_class; 2 bytes, it is a index to the contant pool,which entrance must be CONSTANT_Class_info. such table make up with two items, flag and name_index. the flag is a constant field holding a CONSTANT_Class vlaue. and the the name_index point to a entrance marked with CONSTANT_Utf8_info which is a list.
6:super_class: 2 bytes which point to a entrance in the constant pool containing the describtion of the super class, marked with CONSTANT_Class_info. due to the java.lang.Object class, this field will be set with 0.
7: interfaces_count and interfaces: an array of the interface or extending class a class implement, all the items contain a index to the constant pool. the order of the array depends on the orders of the implements subsentence and extends subsenetence.
8:fields_count and fields:
9:methods_count and methods
10: attributes_count and attributes: there are many attributes and it will appear in many place. for example the arrtibutes item in ClaaFile will contain the information about the class and interface.
ther are two attributes defined by JVM, SourceCode and InnerClasses. they will be contained in the attributes list in the ClassFile list.
2: minor_version and major_version: 4 bytes
for example,in java 2 platform the major_version is updated from 45 ro 46, and the minor_version depends on specifical platform and its version
3: constant_pool_count and constant_pool:
a constant pool includes the const field assiciated with class and interface. it will keep the titles such as String, final field, class name and method name. the first index of this list is 1, but the index 0 will be added into the contant_pool_count. so if you have 14 items in the pool the contant_pool_count will 15.
every entrance of the contant pool will start with a byte length which is used as a flag pointing out the type of the contant.
contant pool flag
CONSTANT_Utf8 1 Unicode String
CONSTANT_Integer 3 int
CONSTANT_Float 4 float
CONSTANT_Long 5 long
CONSTANT_Double 6 double
CONSTANT_Class 7 the reference to a class or an interface
CONSTANT_String 8 String value
CONSTANT_Fieldref 9 a field reference
CONSTANT_Methodref10 a method reference in this class
CONSTANT_InterfaceMethodref 11 a method reference defined in a interface
CONSTANT_NameAndType 12 a part reference to a field or method
the contant pool play a important role int the dynamic stage. the JVM will load a reference and analyse for the actual address.
4:access_flags: 2 bytes, it figures out this class file represents a class or a interface and what is its decoration.
ACC_PUBLIC 0X0001 public type class and interface
ACC_FINAL 0X0010 final type class
ACC_SUPER 0X0020 use the new sementeme of invokespecial class and interface
ACC_INTERFACE 0X0200 interface type interface
ACC_ABSTRACT 0X0400 abstract type interface and part of class
5: this_class; 2 bytes, it is a index to the contant pool,which entrance must be CONSTANT_Class_info. such table make up with two items, flag and name_index. the flag is a constant field holding a CONSTANT_Class vlaue. and the the name_index point to a entrance marked with CONSTANT_Utf8_info which is a list.
6:super_class: 2 bytes which point to a entrance in the constant pool containing the describtion of the super class, marked with CONSTANT_Class_info. due to the java.lang.Object class, this field will be set with 0.
7: interfaces_count and interfaces: an array of the interface or extending class a class implement, all the items contain a index to the constant pool. the order of the array depends on the orders of the implements subsentence and extends subsenetence.
8:fields_count and fields:
9:methods_count and methods
10: attributes_count and attributes: there are many attributes and it will appear in many place. for example the arrtibutes item in ClaaFile will contain the information about the class and interface.
ther are two attributes defined by JVM, SourceCode and InnerClasses. they will be contained in the attributes list in the ClassFile list.