Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Run-Time Constant Pool and Method-Area in java

What is run-time constant pool and method-area in java.I read that JVM creates both of them but which one comes first in existence? Also what they contain? Any help will be greatly appreciated.

like image 659
Hello World Avatar asked Apr 07 '14 19:04

Hello World


People also ask

What is run-time constant pool in Java?

Constant Pool in Java. Simply put, a constant pool contains the constants that are needed to run the code of a specific class. Basically, it's a runtime data structure similar to the symbol table. It is a per-class or per-interface runtime representation in a Java class file.

What are runtime constants in Java?

A runtime constant is a value that is computed only while the program is running. If you run the same program more than once: A compile-time constant will have the same value each time the application is run. A runtime constant can have a different value each time the application is run.

What is method area in Java?

4. Method Area. The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process.

What is constant pool and non constant pool in Java?

Strings in Java are immutable in nature. This immutability is achieved through String Pool. String Pool in Java is a special storage space in Java heap memory. It is also known as String Constant Pool or String Intern Pool. Whenever a new string is created, JVM first checks the string pool.

What is runtime constant pool in Java?

Runtime Constant Pool A class file keeps all its symbolic references in one place, the constant pool. Each class file has a constant pool, and each class or interface loaded by the Java virtual machine has an internal version of its constant pool called the runtime constant pool.

What is the constant pool index of string pool in Java?

The constant pool table is indexed from 1 to constant_pool_count - 1. String intern pool. What is the String Pool in java? Advantages of string pool in java? When a string is created without using new operator and if it already exists in the pool, then instead of creating new string the existing string from the pool is returned.

What is constant pool in a class file?

A class file keeps all its symbolic references in one place, the constant pool. Each class file has a constant pool, and each class or interface loaded by the Java virtual machine has an internal version of its constant pool called the runtime constant pool .

What is a constant pool in Python?

Simply put, a constant pool contains the constants that are needed to run the code of a specific class. Basically, it's a runtime data structure similar to the symbol table.


1 Answers

As per the http://www.artima.com/insidejvm/ed2/jvm2.html

Method area

Some runtime data areas are shared among all of an application's threads and others are unique to individual threads. Each instance of the JVM has one method area and one heap. These areas are shared by all threads running inside the VM. When the VM loads a class file, it parses information about a type from the binary data contained in the class file. It places this type information into the method area.

Runtime Constant Pool

A class file keeps all its symbolic references in one place, the constant pool. Each class file has a constant pool, and each class or interface loaded by the Java virtual machine has an internal version of its constant pool called the runtime constant pool . The runtime constant pool is an implementation-specific data structure that maps to the constant pool in the class file. Thus, after a type is initially loaded, all the symbolic references from the type reside in the type's runtime constant pool.

like image 162
RRM Avatar answered Oct 14 '22 01:10

RRM