Java constant pool

Source: Internet
Author: User

The constant pool is used in java to save a copy of data in the compiled class file that has been determined during the compilation period. It includes constants in classes, methods, and interfaces, as well as String constants, such as String
S = "java. The constant pool is a block in the heap memory.

In addition to the constant values of various basic types (such as int and long) and object types (such as String and array) defined in the Code, it also contains some symbolic references that appear in the form of text, such as fully qualified names of classes and interfaces, field names and descriptors, methods and names, and descriptors. The class file has 11 constant table types:
Constant table Type Flag value (1 byte) Description
CONSTANT_Utf8 1 Unicode string encoded by UTF-8
CONSTANT_Integer 3 Int-type Literal Value
CONSTANT_Float 4 Float-type Literal Value
CONSTANT_Long 5 Long Literal Value
CONSTANT_Double 6 Double Literal Value
CONSTANT_Class 7 Symbol reference for a class or interface
CONSTANT_String 8 Reference of String-type Literal Value
CONSTANT_Fieldref 9 Symbol reference for a field
CONSTANT_Methodref 10 Symbol reference for methods in a class
CONSTANT_InterfaceMethodref 11 Symbol reference of a method in an Interface
CONSTANT_NameAndType 12 References part of a field or Method
Eight basic types of packaging classes and object poolsIn java, most of the basic packaging classes implement the constant pool technology. These classes are Byte, Short, Integer, Long, Character, Boolean, the other two floating-point type packaging classes are not implemented. In addition, the object pool can be used only when the corresponding value is less than or equal to 127 for the five Integer packaging classes Byte, Short, Integer, Long, and Character. Reference: Baidu Baike-constant pool-http://baike.baidu.com/view/8680346.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.