In this article, we'll explain how to get started with the Hotspot Java Virtual Machine and its implementation in the OPENJDK open source project--we'll start with two aspects, namely, the interaction of virtual machines and virtual machines with Java class libraries.
Hotspot Source Introduction
Let's first look at the JDK source code and the implementation of the relevant Java concepts it contains. There are two main ways to check the source code:
Modern Ides can attach Src.zip (in the $java_home directory) to access from the IDE
Use the OPENJDK source code and navigate to the file system
Both of these methods are useful, but it is important to have a comfortable way of doing it. OPENJDK's source code is stored in mercurial (a distributed version control system similar to the popular Git version control system). If you are unfamiliar with mercurial, you can view this free book titled "Version Control Example", which introduces the underlying content.
To check out the OPENJDK 7 source code, you need to install the mercurial command-line tool, and then execute the following command:
HG Clone Http://hg.openjdk.java.net/jdk7/jdk7 Jdk7_tl
This command generates a copy of the OpenJDK warehouse locally. The warehouse contains the underlying layout of the project, but it does not contain all the files-because the OPENJDK project is distributed in several sub warehouses.
After cloning is complete, the local warehouse should have something similar to the following:
ARIEL-2:JDK7_TL boxcat$ ls-l Total
664
-rw-r--r-- 1 boxcat staff 1503 12:54 c5/>-rw-r--r-- 1 Boxcat staff 19263 may 12:54 LICENSE
-rw-r--r-- 1 boxcat staff 16341 12:5 4 Makefile
-rw-r--r-- 1 boxcat staff 1808 may 12:54 README
-rw-r--r-- 1 boxcat staff 110836 1 4 May 12:54 readme-builds.html
-rw-r--r-- 1 boxcat staff 172135-May 12:54 Third_party_readme
Drwxr-xr-x Staff 408 boxcat 12:54 corba
-rwxr-xr-x 1 boxcat staff 1367 may 12:54 Get_sour ce.sh
drwxr-xr-x boxcat staff 476 12:55 hotspot drwxr-xr-x
boxcat Staff 646 may 12:54 JAXP drwxr-xr-x Boxcat Staff 646/May 12:55 Jaxws drwxr-xr-x boxcat staff 442 may 16:01 JDK
drwxr-xr-x Boxcat Staff 442 may 12:55 langtools drwxr-xr-x-
boxcat staff 612 may 12:54 Mak E
drwxr-xr-x 3boxcat staff 102 12:54 Test
Next, you should run the get_source.sh script, which is part of the original cloned content. The script populates the remainder of the project and clones all the files needed to build the openjdk.
In our in-depth and detailed introduction of the source code, we must have "do not fear platform source" belief. Developers often think that the JDK source code must be exciting and difficult to approach, but this is the core of the entire platform.
The JDK source code is fixed, well audited and tested, but not so inaccessible. In particular, these sources do not always contain the latest features of the Java language. So we often find within them the classes that are still not generic and use the original type.
For the JDK source code, there are several major warehouses you should be familiar with:
Jdk
This is where the class library exists. Almost all of the content is Java (the local method uses some C code). This is a very good starting point to learn the openjdk source in depth. The JDK classes are in the Jdk/src/share/classes directory.
Hotspot
Hotspot Virtual Machines--this is C + + and assembler code (and some Java based virtual machine development tools). These are very advanced, and if you're not a professional C + + developer then it's a bit hard to get started. We'll discuss some good ways to get started later in more detail.
Langtools
For those interested in compiler and tool development, you can find language and platform tools from here. Most of it is Java and C code-it's harder to learn than JDK code, but it's acceptable to most developers.
There are other warehouses, but they may be less important or unattractive to most developers, including CORBA, Jaxp, and Jaxws.
Building OPENJDK
Oracle has recently started a project to make a comprehensive overhaul of OPENJDK and simplifies the build process. This project, known as "Build-dev", is now complete and is the standard way to build openjdk. For many users who use unix-based systems, the build process is now as simple as installing a compiler and a "boot jdk" and then running three commands:
./configure make
images
If you want to get more information related to building your own opensdk, then the ADOPTOPENJDK program (created by the Java Community in London) is a good starting point-a community of more than 100 grassroots developers who work on warning cleanup, Small bug fixes and OpenJDK 8 for major open source project compatibility testing projects.