The doubt of java constant Pool

After the

1.Java class file is compiled, there will be a class constant pool
2. During class loading, the class constant pool is loaded into the runtime constant pool

so does this runtime pool have one for each class, or does all classes share one?
in JAVA8, is this runtime constant pool in the heap area or in metaspace?
what is the relationship between the runtime constant pool and the global string constant pool, and where is the global string constant pool?

May.27,2022

  • the runtime constant pool is globally shared, and the class constant pool is determined when the class file is compiled;
  • after the virtual machine loads the Class, it puts the data from the class constant pool into the runtime pool.
  • String constant pool location:

    • jdk1.6: permanent generation (method area)
    • jdk1.7: heap memory
    • jdk1.8: Metaspace

I suggest you take a look at the Java8 Virtual Machine Specification, which has the answers you need. There is an electronic version of books


the runtime constant pool stores all kinds of literals and symbolic references (as the run changes the symbolic references used into direct references), each class has one, not a shared
string constant pool is a StringTable (which can be understood as weak HashMap), a String reference is stored, and the globally shared
these two pools are not the same thing at all!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c2d9-2ba6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c2d9-2ba6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?