There are two main versions of JDK on the Internet. They are Oracle JDK and OpenJDK. Both of them are almost the same. OpenJDK is an open source version, which means that you can compile JDK from the source using your own machine. Oracle JDK use most of the same codes with OpenJDK except some commercial-oriented parts. In spite of very few differences, OpenJDK and Oracle JDK can be regarded as the same in sight of function, performance and actuating logic.
Most of OpenJDK source codes are based on Java and C++. To be more accurate, the source codes use Java more than C++. Therefore when you need to compile JDK from the source code, you should not only need GCC but also another basic JDK called “Bootstrap JDK”. The required version of the “Bootstrap JDK” is dependent on what version of the JDK source codes you are going to compile.
At the very first, I need to introduce two methods mentioned in this article:
- Native Method: The method written with other languages, which will not run on JVM when executing. Typically refers to method written in C/C++
- Java Method: The method written in Java, which will run on JVM and will be managed through kinds of JVM rules.
We go ahead to introduce five import memory areas in JVM:
- Programmer Counter Register: Java Virtual Machine(JVM) implements multithreading by assigning the processing time of a CPU(actually a core) to a threading in turn. Thus, JVM has to record current thread executive address before switching to another thread. In this way Program Counter Register is born. Each Program Counter’s memory is private to corresponding thread.
- Java Virtual Machine Stacks: This area is private too. It is used to serve for Java method, including method local variables, operation number stack, dynamic links, method entrance and exit address. We usually have two kinds of Java Virtual Machine Stack. One is fixed-size Java stack which has a prefixed memory limit. The other is extensible Java stack allowing extend the memory size to meet program demands.
- Native Method Stacks: This area is also private. It serves for Native method mentioned above. This area can vary largely from JVM to JVM. Some JVMs even put native stack and Java stack into one whole stack.
- Java Heap: This area is shared by all threads. Well-known Garbage Collected is used on this area therefore Java Heap also calls Garbage Collected Heap. This memory area is established when JVM starts. It’s only purpose is to store instances. The memory can be physically sporadic.
- Method Area: This area is shared by all threads. It is used for class information, constants, static variables and code segments after compilation. This area is outside the management of garbage collect policy.