« Remote access “life... | Main | Final Mercurial... »

OpenJDK Mercurial repositories are open

Nov 02 2007, 17:26 MSK |  [  Java  ]

Finally, we have the Mercurial repositories of JDK7 out in the open. They are still EXPERIMENTAL (yeah, in capitals), which means that these repositories (and their clones) are going to become invalid (totally unrelated to the repositories which would be used) in a couple of weeks, but you can still try to set up your environment and development process (if any) using them. Again, please don't do any real work on the clones of these repositories, the changesets you'd have probably would be useless when these repositories become officially open.

Here is a short instruction to get started with hacking the JDK. I assume that you have Mercurial set up. The build instructions here should work for Debian GNU/Linux (this is what I use on my laptop), however I don't promise anything :-) It should be relatively easy to do the same thing on Ubuntu (I doubt there are any differences other than the available package names/versions). It may require more work on other flavors of Linux. Still, if you have some problem building the JDK, you can ask me and I'll try to help you investigate (and, hopefully, fix) the problem.

Prerequisites

I'll assume that you have the following things set up and working:

  • JDK 6
  • Mercurial
  • GCC (>= 4.0)
  • Ant (>= 1.6.3)
  • FindBugs (>= 1.1)
  • GNU make
  • …and lots of other required libraries (see the README files for more info)

Getting the sources

Create the directory where you're going to have your repositories.

/home/ivan/work% mkdir openjdk
/home/ivan/work% cd openjdk

If you have the newer Mercurial with the forest extension, you can simply do

/home/ivan/work/openjdk% hg fclone http://hg.openjdk.java.net/jdk7/MASTER/
but if you don't, just follow the instructions below.

First, clone the master repository

/home/ivan/work/openjdk% hg clone http://hg.openjdk.java.net/jdk7/MASTER/

Clone all the other repositories into the MASTER repository:

/home/ivan/work/openjdk% cd MASTER
/home/ivan/work/openjdk/MASTER% for i in corba hotspot jaxp jaxws jdk langtools; hg clone http://hg.openjdk.java.net/jdk7/MASTER/$i/

After getting the sources, download the binary plugs from the OpenJDK download site and install them (run java -jar <downloaded-plugs-jar>) into some directory (I installed them in openjdk directory which I created above).

GCC 4.2 peculiarities

Now, if you are going to use GCC 4.2 or newer to build the JDK, you'll need to apply the patch to the HotSpot source before you continue. GCC 4.2 is more pedantic than the older ones and doesn't allow one to cast literal strings to char *, now you can only cast to const char * (which makes a lot of sense if you want to minimize the possibility of having nasty bugs which are hard to track). However the patch is a bit hackish: I use const_cast in a couple of places because it is the quickest and least intrusive fix I can provide there. This compilation issue should be addressed separately in JDK7 code-base (maybe in next build?).

First, download the patch, say, to /tmp/const_strings.patch. Now you have two choices: either use patch tool to apply the patch to the hotspot sources

/home/ivan/work/openjdk/MASTER/hotspot% patch -p1 < /tmp/const_strings.patch
or use the Mercurial Queues (the preferred way)
/home/ivan/work/openjdk/MASTER/hotspot% hg qinit
/home/ivan/work/openjdk/MASTER/hotspot% hg qimport /tmp/const_strings.patch
/home/ivan/work/openjdk/MASTER/hotspot% hg qpush const_strings.patch
You can read more about Mercurial Queues in this excellent tutorial (I suggest reading the other chapters too).

Setting up the environment

Build scripts use some environment variables to figure out what tools to use, where the JDK is, how many build threads should work concurrently, etc. You can either export these environment variables manually (like it is shown below) or create a script which sets the variables and executes the GNU make.

Here is what I did manually in shell:

% export LANG=C
% export ANT_HOME=/usr/share/ant 
% export FINDBUGS_HOME=~/work/findbugs-1.2.1 
% export ALT_BINARY_PLUGS_PATH=~/work/openjdk/openjdk-binary-plugs
% export ALT_BOOTDIR=/usr/local/java/jdk1.6.0
Fix the paths according to where you have the things installed. Then run make sanity and inspect the log. Fix the variables, run make sanity. Fix again, … I think you got it.

Although it isn't immediately clear from make sanity output and from the README files, you'd need to export one more variable: ALT_JDK_IMPORT_PATH, and according to the Glossary for JDK builds it should point to the path with a recent build of the same version of JDK we are building. Actually, it is a bug in the corba build files, and hopefully it would be fixed when the repositories are officially rolled out.

Building the JDK

Run make and go have a lunch :-)

Oh, you might want to have a tea first, just to be able to fix some minor problem that breaks the build in your case.

For reference: it took ~ 55 minutes to build the JDK on my 2Ghz laptop. The build directory size is 1.1Gb, although it may take more than that during the build (I didn't bother to measure).

Post-scriptum

Kudos to Kelly O'Hair and the JDK team, the build process now is very easy compared to what we had a little more than a year ago.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed