JVM -- Structure

Source: Internet
Author: User

Java System:

JDK (Java Development Kit) includes: Java programming language, Java virtual machine, and Java API class library.


Java Technical System: Java card (applets), Java me (Micro Edition), Java SE (Standard Edition), Java EE (Enterprise Edition ).

JVM structure concept:

Runtime data Zone)

JVM defines a set of runtime data regions that are used when JVM runs programs. Some regions are created when the JVM is started and destroyed when the JVM is disabled. Some regions are owned by each thread. Created when the thread starts and destroyed when the thread ends.

PC register (program counter register)

JVM supports multithreading. Each thread has its own PC register. If the thread is executing a Java method, this counter records the address of the Virtual Machine bytecode instruction being executed. If it is native, this counter value is undefined ).

JVM Stack
The VM stack describes the Memory Model of Java method execution. Each method creates a stack frame to store local variable tables, Operation stacks, and dynamic links, method exit and other information. The process of calling each method until the execution is completed corresponds to the process of a stack frame exiting the stack from the stack path in the VM stack. Stack local variables mainly store some basic types of variables (INT, short, long, byte, float, double, Boolean, char), object handle (reference type), and returnaddress type.

Native method stacks)

The local method stack plays a very similar role in the Virtual Machine stack. The difference is that the virtual machine stack executes Java method services for the virtual machine, and the local method stack is the native method service used by the virtual machine.

Java heap)
The JVM has a heap. All threads in the JVM share the heap. All class object instances and arrays are allocated to the stack. The JVM heap is created when the JVM is started. JVM provides a garbage collector to manage the heap. Objects on the stack do not need to be explicitly destroyed by programmers. The heap size can be fixed or increased as needed. The heap can be discontinuous.

Method Area)
All threads in the JVM share this region, which is used to store class information, constants, static variables that have been loaded by the virtual machine, even if the compiled code of the compiler and other data.

Runtime constant pool)

The runtime constant pool is part of the method area. In addition to the description information such as the version, field, method, and interface of the class file, the class file also contains the constant pool, which is used to store various literal quantities and symbol references generated during the compilation period, this part of content will be stored in the runtime constant pool of the method area after the class is loaded.

 

JVM StructureNote:

1. Each Java Virtual Machine instance has a method zone and a heap, which are shared by all threads in the VM instance.

2. When each thread is created, it will get its PC register and a java stack. No thread can access the PC register or java stack of another thread.


3. Data Type: basic type and reference type:


4. Method Area:

1) access to data in the method area is thread-safe.

2) The size of the method area does not need to be fixed, and the virtual machine can be dynamically adjusted according to application needs. The method area does not need to be continuous. The method area can be freely allocated in a heap (or even a virtual machine's own heap. Virtual machines allow users or programmers to specify the initial size and minimum and maximum size of the method area.

3) The method area can also be recycled.

4) information stored in the Method Area:

    • A fully qualified name for this type.
    • Fully Qualified name of the direct superclass of this type (unless this class is Java. Lang. object, it does not have a superclass)
    • Whether this type is a class type or an interface type.
    • This type of access modifier (public, abstract, or a subset of final)
    • An ordered list of all qualified names of any direct superinterfaces.
    • Constant pool of this type.
    • Field Information.
    • Method information.
    • All class (static) variables except constants.
    • A reference to class classloader.
    • A reference to the class.

5. execution engine

1) Every thread of the running Java program is an independent virtual machine execution engine instance.

2) The JVM instruction set is stack-centric rather than register-centric, making Java more convenient on machines with few registers or irregular registers.

 

PS:

1. The class allows the running program to access the information stored in the Method Area (and the reflection principle ).

2. arrays are real objects. Like other objects, arrays are always stored in the heap.

 

References:
Deep understanding of Java Virtual Machine

Deep Java Virtual Machine

From: http://blog.csdn.net/thomescai

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.