The Java Hotspot VM Series
I am excited to start working with the Java suite of tools and a lot of things I work with Java seems to be open source. Great. Apart from my regular professional work which involves writing some code to access databases, exposing services, web API's i am curious about how debugging works in java, primarily because, the first time i attempted to set up debugging for my project (a maven project) in IntelliJ IDEA Community Edition, i don't really had a clue, but when i kind of set it up, i can't wait getting my hands into the JVM.
is to customize the JVM to print the method names and parameters, during execution. This functionality is available via the JPDA (Java Platform Debug Architecture) but is not available for applications. An alternative way of doing this is using any framework, that injects hooks into your methods prologue and logs the details. The later approach will require that the programmer adds annotations to the source code all around and do things, which could even go to the extent that we need to add annotations to the application dependencies.
all that are JVM is not open source .!
There are a a lot of implementations of JVM, what that means is that JVM is a reference, a dictation of how a Java Runtime should be. Originally HotSpot is the name of the first reference implementation of the JVM, and hence that name is sometimes used in places replacing ~~JVM~~. are the list of implementations made against Hotspot. Almost all of them are a fork of the Hotspot VM. The most popular of them are the Sun JVM (Oracle JVM), IBM JVM, Dalvik VM (by Google for the Android OS), and ==OpenJDK==. For our experiment, we will use OpenJDK which is a community maintained project, primarily maintained by the folks in Oracle, but not restricted to.######Setup development environment
This document is a handy reference to setup environment for developing and debugging JDK. I mention JDK here because the JVM and JDK are all complementary repositories and the recommendation from the OpenJDK team. In short, if you follow the steps given below, you should be able to build a basic version of the Hotspot JVM and debug it.**Hardware requirements**
- Linux Ubuntu (x64) Trusty.
- Quad core processor (For faster build times a good processor configuration helps). With this configuration, my CPU usage is as shown below. You can see that during compilation it goes to 100% almost. It took ~10 minutes to compile entire JDK including Hotspot.
- At least 2 GB of ram, to avoid ICE's (Internal Compiler errors from g++ compiler). The more the better.
- Make sure you are up-to-date with your system by running the following command
sudo apt-get update
- Then install the following packages
sudo apt-get install g++ gcc automake libtools binutils make unzip zip openjdk-7-jdk libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev libcups2-dev libfreetype6-dev libasound2-dev mercurial
3.Now all your packages are setup. Let's clone the repository, and clone the entire forest, using the get_source.sh, script.
hg clone http://hg.openjdk.java.net/jdk8/jdk8 YourOpenJDKFolder cd YourOpenJDKFolder bash ./get_source.sh
You should have the following repositories in your "YourOpenJDKFolder"
|. (root)||common configure and makefile logic|
|hotspot||source code and make files for building the OpenJDK Hotspot Virtual Machine|
|langtools||source code for the OpenJDK javac and language tools|
|jdk||source code and make files for building the OpenJDK runtime libraries and misc files|
|jaxp||source code for the OpenJDK JAXP functionality|
|jaxws||source code for the OpenJDK JAX-WS functionality|
|corba||source code for the OpenJDK Corba functionality|
sudo bash ./configure --with-freetype-lib=/usr/lib/x86_64-linux-gnu/ --with-freetype-include=/usr/include/freetype2/
Note that in the above configure command we use explicit paths for FreeType library and include, since the default configure script assumes them to be in /usr/lib and apt-get installs them inside <arch> folder. Usually, a symlink exists but with this library it doesn't. So I have added it explicitly to configure command like. But if your system architecture is something else you should use that instead. But the basic idea it to use the folder which has libfreetype.so for "lib" and the folder with f2hbuild.h for "include".
Have a good time. I will choreograph the next post in this series meanwhile. Stay tuned. :-)