Road JVM learning

Byte code class file format (one byte is equal to 8, -128 to 127)

The first 4 bytes: Magic Magic, 0xCAFEBABE (1991 Nian java development team is determined by the key members of Patrick Naughton, interesting name, on behalf of Baristas Coffee, easy to remember, hexadecimal data, need to be converted to decimal)

The first 5678 bytes: 56 represents the minor version number, 78 indicates the major version number. 45 starts from the java version number, such as Class JDK1.0 executable file of 45.0 ~ 45.65535.

 

Incidentally: strictly defined for the virtual machine byte code class file format, data types, such as class file includes a number of free characters and tables (i.e. tables have no character number of the logic composition).

      Runtime constant pool:

        class file constant pool every constant is a type of table, the table vary in different versions of the JDK, JDK1.6 in a total of 14 species (all types of signs and description see "in-depth understanding of java virtual machine" 169 table 6-3 pages),

        In JDK1.7 added three kinds (CONSTANT_METHODHandle_info, CONSTANT_MethodType_info, CONSTSNT_InvokeDynamic_info),

        Each type has its own table structure (all types of signs and description see "in-depth understanding of java virtual machine" on page 172 Table 6-6), as CONSTANT_Class_info type and CONSTANT_UTF8_info type structure:

CONSTANT_Class_info constants of structure
Types of name Quantity
U1 (representing the number of characters represents one byte) tag 1
U2 (representing the number of characters represented by 2 bytes) name_index 1

        

CONSYANT_UTF8_info
Types of name Quantity
u1 tag 1
u2 length 1
u1 bytes length

        

        Constants pool comprises:. 1 java of literals (including basic data types and the literal string literal reference data types) 2.  References (including the method name, field name, full name of the class or interface defined).

 

        For the name of the class or interface, methods, variables stored in the name of this type of constant constant pool, and certainly table type (because each pool is a constant constant table type, are ending _info). But CONSTANT_UTF8_info type, which is the length u2, which is 2 bytes,

        The maximum length is 65535 (64KB), if the name of java in more than 64KB English characters will not compile.

        

Guess you like

Origin www.cnblogs.com/zhushaolong/p/11294854.html