Class file Base

As opening in the ASM bytecode column, been thinking about is what kind of style about the bytecode and ASM, if want to understand the Java language technology behind the bytecode is in any case can bypass, and if only to study the bytecode is also pretty boring, as a programmer for these we can’t just write what point very afflictive, So I want to achieve the purpose of applying what I have learned through the linkage of bytecode + operation bytecode library

As Java developers, we all know that after we write code Java is compiled into class files, and class files can describe files in a structure similar to class.

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             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];
}
Copy the code

Vm specifications specify u1, U2, and U4 as unsigned integers of 1, 2, and 4 bytes. Cp_info, field_info, method_info, and attribute_info correspond to variable length sets (table) of the same data type. Each table has corresponding length fields constant_pool_count, interfaces_count, fields_count, methods_count, and attributes_count.

magic

Magic number, 4 bytes, the first 4 bytes of the class file, used by the virtual machine to verify the validity of the class file, if we modify the first 4 bytes of the class file running program will throw an exception. Java uses 0XCAFEBABE as the file identifier.

minor_version

Minor version number, 2 bytes, this value is 0

major_version

The major version number, 2 bytes, has a one-to-one value corresponding to the Java version, such as Java8 →52. Increases by 1 every time Java is released in a major release. The virtual machine loads the class file to check if the current environment is less than major_version and throws an exception if it is

constant_pool_count & constant_pool[]

Constant pool number, 2 bytes, constant pool, index 0 is reserved index, constants of Long and Double require 2 index bits temporarily, so maximum n – 1

A VM currently has 14 constant types:

type value
CONSTANT_Utf8_info 1
CONSTANT_Integer_info 3
CONSTANT_Float_info 4
CONSTANT_Long_info 5
CONSTANT_Double_info 6
CONSTANT_Class_info 7
CONSTANT_String_info 8
CONSTANT_Fieldref_info 9
CONSTANT_Methodref_info 10
CONSTANT_InterfaceMethodref_info 11
CONSTANT_NameAndType_info 12
CONSTANT_MethodHandle_info 15
CONSTANT_MethodType_info 16
CONSTANT_InvokeDynamic_info 18

CONSTANT_Utf8_info

CONSTANT_Utf8_info stores mutf-8 character string, tag type, value 1,1 byte. Length Indicates the length of the string, 2 bytes. Bytes actually stores string data. Because of the length size limit, the literal string of life in the program also has this size limit. According to the virtual machine specification, the literal string length can be up to 65535 bits in theory, but after testing the literal string length up to 65534 bits in practice, javac authors can count this as a Javac BUG if they do not set this mechanism for a specific reason

CONSTANT_Utf8_info {
    u1 tag;
    u2 length;
    u1 bytes[length];
}
Copy the code

CONSTANT_Integer_info

Tag value 3, bytes Store the value of the integer, 4 bytes

CONSTANT_Integer_info {
    u1 tag;
    u4 bytes;
}
Copy the code

CONSTANT_Float_info

Tag value 4, bytes Stores the value of a floating point number, 4 bytes

CONSTANT_Float_info {
    u1 tag;
    u4 bytes;
}
Copy the code

CONSTANT_Long_info

Tag value 5, high_bytes stores the higher 32 bits of Long’s data, low_bytes stores the lower 32 bits of Long’s data

CONSTANT_Long_info {
    u1 tag;
    u4 high_bytes;
    u4 low_bytes;
}
Copy the code

CONSTANT_Double_info

The tag value is 6. High_bytes stores the highest 32 bits of Double data, and low_bytes stores the lowest 32 bits of Double data

CONSTANT_Double_info {
    u1 tag;
    u4 high_bytes;
    u4 low_bytes;
}
Copy the code

CONSTANT_Class_info

The tag value is 7, name_index points to the index of type CONSTANT_Utf8_info in the constant pool, and the fully qualified name of the storage class

CONSTANT_Class_info {
    u1 tag;
    u2 name_index;
}
Copy the code

CONSTANT_String_info

Tag value 8, string_index points to the constant pool index of type CONSTANT_Utf8_info, which stores the true contents of the string

CONSTANT_String_info {
    u1 tag;
    u2 string_index;
}
Copy the code

CONSTANT_Fieldref_info

The tag value is 9. Class_index refers to the CONSTANT_Class_info index in the constant pool, indicating the class of the field. Name_and_type_index refers to the CONSTANT_NameAndType_info index in the constant pool, indicating the field name and type

CONSTANT_Fieldref_info {
    u1 tag;
    u2 class_index;
    u2 name_and_type_index;
}
Copy the code

CONSTANT_Methodref_info & CONSTANT_InterfaceMethodref_info

The CONSTANT_Methodref_info tag value is 10, and the CONSTANT_InterfaceMethodref_info tag value is 11. Class_index refers to the index of type CONSTANT_Class_info in the constant pool, indicating the class of the method. Name_and_type_index refers to the index of type CONSTANT_NameAndType_info in the constant pool, indicating the method name and signature

CONSTANT_Methodref_info {
    u1 tag;
    u2 class_index;
    u2 name_and_type_index;
}
Copy the code

CONSTANT_NameAndType_info

Tag value 12, name_index points to the constant pool index of type CONSTANT_Utf8_info, indicating the method name and field name. Descriptor_index points to the constant pool index of type CONSTANT_Utf8_info, indicating the field type and method signature

CONSTANT_NameAndType_info {
	u1 tag;
	u2 name_index;
	u2 descriptor_index;
}
Copy the code

CONSTANT_MethodHandle_info

Tag value 15, this structure represents the method handle, reference_KIND value 1~9, this value represents the kind of method handle

CONSTANT_MethodHandle_info {
	u1 tag;
	u1 reference_kind;
	u2 reference_index;
}
Copy the code

CONSTANT_MethodType_info

A tag value of 16 represents a method type

CONSTANT_MethodType_info {
	u1 tag;
	u2 descriptor_index;
}
Copy the code

CONSTANT_InvokeDynamic_info

Bootstrap_method_attr_index points to the index of the bootSTRap_method table, and name_AND_type_index represents the corresponding function generated by ASM after javAC

CONSTANT_InvokeDynamic_info {
    u1 tag;
    u2 bootstrap_method_attr_index;
    u2 name_and_type_index;
}
Copy the code

access_flags

Access tag bits, 2 bytes, tag class modifiers, these tags can be combined with each other, but there is a certain amount of mutual exclusion, if but in terms of value there is a very simple rule that the same bit is non-zero and the value is mutually exclusive. Here to give a word after reading the source code is not difficult to find quite a few libraries use hexadecimal to control state, thanks to this design, the combination of the condition and calibration can be through a very simple algorithm, in individual project can also try using hexadecimal achieve certain scene, experience the hexadecimal and bit operations with concise and efficient algorithm.

Access the tag The JVM specification meaning
ACC_PUBLIC 0x0001 Flag whether class public permissions are public
ACC_FINAL 0x0010 Marks whether a class is final
ACC_SUPER 0x0020 Has been abolished
ACC_INTERFACE 0x0200 Flag whether interface
ACC_ABSTRACT 0x0400 Flag whether the class is abstract
ACC_SYNTHETIC 0x1000 Flags whether it is a generated class
ACC_ANNOTATION 0x2000 Flag whether to annotate a class
ACC_ENUM 0x4000 Flag whether to enumerate classes

this_class

Refers to the index of type CONSTANT_Class_info in the constant pool, representing the fully qualified name of the class, 2 bytes

super_class

Refers to the index of type CONSTANT_Class_info in the constant pool, representing the fully qualified name of the parent class, 2 bytes

interfaces_count & interfaces[]

The number of interface tables is 2 bytes. The type of the table is CONSTANT_Class_info

{
		u2               interfaces_count;
		interface_info   interfaces[interfaces_count];
}
Copy the code

fields_count & fields[]

The number of fields in a 2-byte field_info table that provides a complete description of fields in a class or interface. The table contains only fields declared by the class or interface, not fields in an inherited parent class or implemented interface.

{
		u2               fields_count;
		field_info fields[fields_count];
}

field_info {
    u2             access_flags; 
    u2             name_index;
    u2             descriptor_index;
    u2             attributes_count;
    attribute_info attributes[attributes_count];
}
Copy the code

field_info:

  • access_flags
tag value meaning
ACC_PUBLIC 0x0001 Marks whether the field is publick
ACC_PRIVATE 0x0002 Flag whether the field is private
ACC_PROTECTED 0x0004 Mark whether the field is protected
ACC_STATIC 0x0008 Flag whether the field is static
ACC_FINAL 0x0010 Flag whether the field is final
ACC_VOLATILE 0x0040 Flag whether the field is volatile
ACC_TRANSIENT 0x0080 Mark whether a field is transient. This is not often used. The marked field cannot be serialized
ACC_SYNTHETIC 0x1000 Mark the fields as synthetic, which are compiled by JavAC to generate the fields
ACC_ENUM 0x4000 Flag whether the field is enumerated
  • name_index

    Points to the CONSTANT_Utf8_info index in the constant pool and represents the field name

  • descriptor_index

    Points to the CONSTANT_Utf8_info index in the constant pool and represents the field description

  • attributes_count & attributes[]

    Attribute table, JVM specification convention field attribute structure is: Code_attribute, Exceptions_attribute, Synthetic_attribute, Signature_attribute, Deprecated_attribute, RuntimeVisibleAnnotatio Ns_attribute, RuntimeInvisibleAnnotations_attribute, RuntimeVisibleParameterAnnotations_attribute, RuntimeInvisibleParamete RAnnotations_attribute, AnnotationDefault_attribute

methods_count & methods[]

Method table number, 2 bytes, table of type method_info, provide a full description of class or interface method, if there is no set access_flags ACC_NATIVE | ACC_ABSTRACT provides the realization method of the instruction set, the method contains only class or interface declaration in the table, Does not contain methods contained in inherited parent classes or implemented interfaces.

{
		u2            methods_count;
		method_info   methods[methods_count];
}

method_info {
    u2             access_flags;
    u2             name_index;
    u2             descriptor_index;
    u2             attributes_count;
    attribute_info attributes[attributes_count];
}
Copy the code

Method_info:

  • access_flags
tag value meaning
ACC_PUBLIC 0x0001 Marks whether the method is publick
ACC_PRIVATE 0x0002 Flag whether the method is private
ACC_PROTECTED 0x0004 Mark whether the method is protected
ACC_STATIC 0x0008 Marks whether the method is static
ACC_FINAL 0x0010 Marks whether a method is final
ACC_SYNCHRONIZED 0x0020 Indicates whether the method is synchronized
ACC_BRIDGE 0x0040 Javac generated bridge method
ACC_VARARGS 0x0080 Flags whether a method has variable parameters
ACC_NATIVE 0x0100 Flag whether the method is native
ACC_ABSTRACT 0x0400 Whether the method is abstract
ACC_STRICT 0x0800 The float mode of the method after the tag is FP-strict
ACC_SYNTHETIC 0x1000 Javac generates method tags
  • name_index

    Point to the constant pool CONSTANT_Utf8_info index, said the special method name, |

  • descriptor_index

    Points to the CONSTANT_Utf8_info index in the constant pool, indicating the method signature,

  • attributes_count & attributes[]

    Attribute table, JVM specification convention method attribute structure is: Code_attribute, Exceptions_attribute, Synthetic_attribute, Signature_attribute, Deprecated_attribute, RuntimeVisibleAnnotatio Ns_attribute, RuntimeInvisibleAnnotations_attribute, RuntimeVisibleParameterAnnotations_attribute

attributes_count & attributes[]

Attribute table number, 2 bytes, attribute is the most complex structure in addition to constant pool, here are a few more concerned about the introduction, others can be consulted through the document

Attribute structure

Attribute
ConstantValue
Code
StackMapTable
Exceptions
InnerClasses
EnclosingMethod
Synthetic
Signature
SourceFile
SourceDebugExtension
LineNumberTable
LocalVariableTable
LocalVariableTypeTable
Deprecated
RuntimeVisibleAnnotations
RuntimeInvisibleAnnotations
RuntimeVisibleParameterAnnotations
RuntimeInvisibleParameterAnnotations
AnnotationDefault
BootstrapMethods

ConstantValue_attribute

Constant field value

ConstantValue_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 constantvalue_index;
}
Copy the code

ConstantValue_attribute:

  • constantvalue_index

    Point to the constant pool CONSTANT_Long | CONSTANT_Float | CONSTANT_Double | CONSTANT_Integer | CONSTANT_String index, storage field initialized values

Code_attribute

A set of instructions representing a method and some additional auxiliary information

Code_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 max_stack;
    u2 max_locals;
    u4 code_length;
    u1 code[code_length];
    u2 exception_table_length;
    {   u2 start_pc;
        u2 end_pc;
        u2 handler_pc;
        u2 catch_type;
    } exception_table[exception_table_length];
    u2 attributes_count;
    attribute_info attributes[attributes_count];
}
Copy the code

Code_attribute:

  • max_stack

    The maximum depth of operand stack is confirmed at compile time, and the maximum length of operand stack can be calculated from the loading and unloading of instructions

  • max_locals

    Local variable table maximum, confirmed at compile time, but not simply by directly calculating the sum of variables used in the entire frame stack, but by the death of each variable’s life cycle to leave the following variable reuse bits to reduce the final size.

  • code_length & code[]

    Store method instruction set

  • exception_table_length & exception_table[]

    Stores exception tables associated with methods

    • start_pc

      Record the try index and catch the exception beginning

    • end_pc

      Log the normal end index, which indicates that the code try block executed properly

    • handler_pc

      Log the exception start index, which indicates that an exception of the catch_type type is thrown from the try block to the catch block

    • catch_type

      Record the exception type, pointing to the index of type CONSTANT_Class_info in the constant pool

StackMapTable_attribute

Consisting of multiple or zero frame stacks, each with an offset specified, this structure is designed to speed up the JVM. Because of the complexity of the design, it is recommended that we delegate authority to ASM when writing code through ASM

StackMapTable_attribute {
    u2              attribute_name_index;
    u4              attribute_length;
    u2              number_of_entries;
    stack_map_frame entries[number_of_entries];
}
Copy the code

Exceptions_attribute

Records which handled exceptions a method might throw

Exceptions_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 number_of_exceptions;
    u2 exception_index_table[number_of_exceptions];
}
Copy the code
  • number_of_exceptions & exception_index_table[]

    Exception table element type as the constant pool type as the CONSTANT_Class_info, the type must be a RuntimeException | Error subclasses * *

InnerClasses_attribute

Record inner and outer class relationships

InnerClasses_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 number_of_classes;
    {   u2 inner_class_info_index;
        u2 outer_class_info_index;
        u2 inner_name_index;
        u2 inner_class_access_flags;
    } classes[number_of_classes];
}
Copy the code
  • number_of_classes & classes[]
    • inner_class_info_index

      Points to an index of constant pool type CONSTANT_Class_info that represents an inner class

    • outer_class_info_index

      Points to an index of constant pool type CONSTANT_Class_info, representing the external class

    • inner_name_index

      Points to an index of constant pool type CONSTANT_Utf8_info that represents the fully qualified name of the inner class

    • inner_class_access_flags

      Inner class access tags

LineNumberTable_attribute

Mark bytecode and source line numbers

LineNumberTable_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 line_number_table_length;
    {   u2 start_pc;
        u2 line_number;	
    } line_number_table[line_number_table_length];
}
Copy the code
  • line_number_table_length & line_number_table[]
    • start_pc

      Bytecode instruction

    • line_number

      The source code line number

LocalVariableTable_attribute

Recording method Local variable scale

LocalVariableTable_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 local_variable_table_length;
    {   u2 start_pc;
        u2 length;
        u2 name_index;
        u2 descriptor_index;
        u2 index;
    } local_variable_table[local_variable_table_length];
}
Copy the code
  • local_variable_table_length & local_variable_table[]
    • start_pc & length

      The range in which a record variable exists in the bytecode [start_PC, start_PC + length], that is, the key data in the record of the death of the variable’s life

    • name_index

      Points to an index of type CONSTANT_Utf8_info in the constant pool and represents the variable name

    • descriptor_index

      Points to the index of type CONSTANT_Utf8_info in the constant pool, representing the variable type signature

    • index

      The position of the variable in the frame stack local variable table. Note that Long and Double occupy two positions

LocalVariableTypeTable_attribute

This is similar to the LocalVariableTable_attribute record, except that it records signatures instead of descriptions

Deprecated_attribute

Indicates that a class, field, or method has been abolished

RuntimeVisibleAnnotations_attribute

Record runtime annotation information

RuntimeVisibleAnnotations_attribute {
    u2         attribute_name_index;
    u4         attribute_length;
    u2         num_annotations;
    annotation annotations[num_annotations];
}

annotation {
    u2 type_index;
    u2 num_element_value_pairs;
    {   u2            element_name_index;
        element_value value;
    } element_value_pairs[num_element_value_pairs];
}

element_value {
    u1 tag;
    union {
        u2 const_value_index;

        {   u2 type_name_index;
            u2 const_name_index;
        } enum_const_value;

        u2 class_info_index;

        annotation annotation_value;

        {   u2            num_values;
            element_value values[num_values];
        } array_value;
    } value;
}
Copy the code

annotation:

  • type_index

    Points to the index of type CONSTANT_Utf8_info in the constant pool, indicating the annotation description type

  • num_element_value_pairs & element_value_pairs[]

    • element_name_index

      Points to an index of type CONSTANT_Utf8_info in the constant pool, representing the annotation field description

    • value

      The element_value type describes the value of the annotation field

RuntimeInvisibleAnnotations_attribute

In RuntimeVisibleAnnotations_attribute similar, but can’t get annotation information through reflection

RuntimeVisibleParameterAnnotations_attribute

In RuntimeVisibleAnnotations_attribute similar, but their role in the method parameters

RuntimeInvisibleParameterAnnotations_attribute

In RuntimeInvisibleAnnotations_attribute similar, but their role in the method parameters

AnnotationDefault_attribute

Records the default value of the element represented by the structure

BootstrapMethods_attribute

Virtual machine to dynamic language lambda support implementation of the important structure, the description of invokedynamic instructions.

BootstrapMethods_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 num_bootstrap_methods;
    {   u2 bootstrap_method_ref;
        u2 num_bootstrap_arguments;
        u2 bootstrap_arguments[num_bootstrap_arguments];
    } bootstrap_methods[num_bootstrap_methods];
}
Copy the code
  • num_bootstrap_methods & bootstrap_methods
    • bootstrap_method_ref

      Points to an index of type CONSTANT_MethodHandle_info in the constant pool, representing a method handle

    • num_bootstrap_arguments & bootstrap_arguments[]

      The element points to CONSTANT_String_info, CONSTANT_Class_info, CONSTANT_Integer_info, CONSTANT_Long_info, CONSTANT_Float_info, and CONSTANT_D in the constant pool Ouble_info, CONSTANT_MethodHandle_info, CONSTANT_MethodType_info

Understanding the structure of a class file is also the beginning of the bytecode-related content.

Each character in hexadecimal system is equal to 0.5 bytes. One character in hexadecimal system can represent 0~15 bytes. When converting binary 242^424,1 byte is equal to 8 bits. So we derive the memory footprint in hexadecimal.

The starting The end of the Occupied byte size describe
0, 0 0, 3 4 U2 (CAFEBABE): Magic number: 0XCAFEBABE
0, 4 0, 5 2 U2 (0000): Minor version number: 0
0, 6 0, 7 2 U2 (0034) Major version: 0034 52 Java8
0, 8 0, 9 2 U2 (0022): Constant pool size: 0022 34 The maximum number of constant pools is 33
0,A 0,E 5 u1(0A):tag 10 CONSTANT_Methodref

U2 (0006): Indicates the owning class name index 6

U2 (0014): Method name and signature index 20
0,F 1, 3 5 u1(09):tag CONSTANT_Fieldref

U2 (0015): Indicates the owning class name index 21

U2 (0016): Field name and type index 22
1, 4 1, 6 3 u1(08):tag CONSTANT_String

U2 (0017): string index 23
1, 7 1,B 5 u1(0A):tag 10 CONSTANT_Methodref

U2 (0018): Indicates the owning class name index 24

U2 (0019): Method name and signature index 25
1,C 1,E 3 u1(07):tag CONSTANT_Class

U2 (001A): Class fully qualified name index 26
1,F 2, 1 3 u1(07):tag CONSTANT_Class

U2 (001B): Class fully qualified name index 27
2, 2 2,A 9 u1(01):tag CONSTANT_Utf8

U2 (0006): The value contains 6 characters

3C 69 6E 69 74 3E
2,B 3, 0 6 u1(01):tag CONSTANT_Utf8

U2 (0003): The value contains 3 characters

(28 29 56)()V
3, 1 3, 7 9 u1(01):tag CONSTANT_Utf8

U2 (0004): The value contains 4 characters

Content :(43 6F 64 65)Code
3, 8 4, 9 18 u1(01):tag CONSTANT_Utf8

U2 (000F): The value contains 15 characters

Contents :(4C 69 6E 65 4E 75 6D 62 65 72 54 61 62 6C 65)LineNumberTable
4,A 5,E 21 u1(01):tag CONSTANT_Utf8

U2 (0012): The value contains 18 characters

4C 6F 63 61 6C 56 61 72 69 61 62 6C 65 54 61 62 6C 65)LocalVariableTable
5,F 6, 5 7 u1(01):tag CONSTANT_Utf8

U2 (0004): The value contains 4 characters

Content :(74 68 69 73)this
6, 6 7, 4 15 u1(01):tag CONSTANT_Utf8

U2 (000C): The value contains 12 characters

Content :(4C 48 65 6C 6C 6F 57 6F 72 6C 64 3B)LHelloWorld;
7, 5 7,B 7 u1(01):tag CONSTANT_Utf8

U2 (0004): The value contains 4 characters

6D 61 69 6E)main
7,C 9, 4 25 u1(01):tag CONSTANT_Utf8

U2 (0016): The value contains 22 characters

Content :(28 5B 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 29 56)([Ljava/lang/String;)V
9, 5 9,B 7 u1(01):tag CONSTANT_Utf8

U2 (0004): The value contains 4 characters

Contents :(61 72 67 73)args
9,C B0, 1 22 u1(01):tag CONSTANT_Utf8

U2 (0013): The value contains 19 characters

Contents :(5B 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B)[Ljava/lang/String;
2 B0, B0,E 13 u1(01):tag CONSTANT_Utf8

U2 (000A): The value contains 10 characters

Content :(53 6F 75 72 63 65 46 69 6C 65)SourceFile
B0,F D0, 0 18 u1(01):tag CONSTANT_Utf8

U2 (000F): The value contains 15 characters

Helloworld.java (48 65 6C 6C 6F 57 6F 72 6C 64 2E 6A 61 76 61
D0, 1 D0, 5 5 u1(0C):CONSTANT_NameAndType

U2 (00 07): Name index 7

U2 (00 08): Description index 8
D0, 6 D0, 8 3 u1(07):tag CONSTANT_Class

U2 (00 1C): Class fully qualified name index 28
D0, 9 D0,D 5 u1(0C):CONSTANT_NameAndType

U2 (001D): name index 29

U2 (00 1E): Description index 30
D0,E E0,B 14 u1(01):tag CONSTANT_Utf8

U2 (00 0B): The value contains 11 characters

68 65 6C 6C 6F 20 77 6F 72 6C 64
E0,C E0,E 3 u1(07):tag CONSTANT_Class

U2 (00 1F): Class fully qualified name index 31
E0,F F0, 3 5 u1(0C):CONSTANT_NameAndType

U2 (00 20): Name index 32

U2 (00 21): Description index 33
F0, 4 100, 0 13 u1(01):tag CONSTANT_Utf8

U2 (00 0A): The value contains 10 characters

Content :(48 65 6C 6C 6F 57 6F 72 6C 64)HelloWorld
100, 1 110, 3 19 u1(01):tag CONSTANT_Utf8

U2 (00 10): The value contains 16 characters

(6A 61 76 61 2F 6C 61 6E 67 2F 4F 62 6A 65 63 74) Java /lang/Object
110, 120, 6 19 u1(01):tag CONSTANT_Utf8

U2 (00 10): The value contains 16 characters

(6A 61 76 61 2F 6C 61 6E 67 2F 53 79 73 74 65 6D) Java /lang/System
120, 7 120,C 6 u1(01):tag CONSTANT_Utf8

U2 (00 03): The value contains 3 characters

(6F 75 74) Out
120,D 140, 24 u1(01):tag CONSTANT_Utf8

U2 (00 15): The value contains 21 characters

(4C 6A 61 76 61 2F 69 6F 2F 50 72 69 6E 74 53 74 72 65 61 6D 3B)Ljava/ IO /PrintStream;
140, 5 150,A 22 u1(01):tag CONSTANT_Utf8

U2 (00 13): The value contains 19 characters

6A 61 76 61 2F 69 6F 2F 50 72 69 6E 74 53 74 72 65 61 6D Java/IO /PrintStream
150,B 160, 10 u1(01):tag CONSTANT_Utf8

U2 (00 07): The value contains 7 characters

(70 72 69 6E 74 6C 6E)println
160, 5 170,C 24 u1(01):tag CONSTANT_Utf8

U2 (00 15): The value contains 21 characters

(28 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 29 56)(Ljava/lang/String) V
170,D 170,E 2 U2 (00 21): Access tag ACC_PUBLIC
170,F 180, 0 2 U2 (00 05): Class fully qualified name, constant pool index 5
180, 1 180, 2 U2 (00 06): Superclass class fully qualified name, constant pool index 6
180, 3 180, 2 U2 (00 00): the number of interface tables is 0
180, 5 180, 6 2 U2 (00 00): number of members 0
180, 7 180, 2 U2 (00 02): Method table Quantity 2
180, 9 end U2 (00 01): Method access identifier ACC_PUBLIC

U2 (00 07): Method class index 7

U2 (00 08): Method description index 8

U2 (00 01): Number of method attributes 1

U2 (00 09): Attribute name index 9

U4 (00 00 00 2F): The property contains 47 bytes

u2(00 01):max_stack1

u2(00 01):max_locals1

U4 (00 00 00 05): instruction set number of bytes 5

.

At this point, there are not many HelloWorld class files on the way to analyze (I am not familiar with the way, the property table is almost a complete mess, hahahahahahaha), which is also the first step of the long march, with the understanding of the structure of the class file, it is easy to understand the design behind ASM framework. So the next article is ASM compared to the class file analysis study