|
|
Subscribe / Log in / New account

Piecing together free java

November 20, 2007

This article was contributed by Mark Wielaard

The libre-java movement got a huge boost on November 13 2006, "Java Liberation Day". On that day, Sun announced its intent to distribute all the source code for their implementations of Java Standard Edition (SE, code name OpenJDK), Enterprise Edition (EE, code name Glassfish) and Micro Edition (ME, code name PhoneME) as free software. All are licensed under the GPL, using the classpath exception clause for selected libraries.

Sun went out of its way to make its commitment to the GPL, with everything it implies, very clear in an extensive FAQ. Two things, unrelated to source code, are reserved: the specification and certification of Java is reserved for the JCP (Java Community Process), while Sun controls the usage of the Java(TM) trademark. Everybody is free to run, copy, distribute, study, change, share and improve the source code for any purpose as long as they follow the tit-for-tat, share-alike, copyleft rules of the GPL for all the code they release.

Sun not only contacted big Free Software names, like Richard Stallman and Eben Moglen, before the event, the company also made sure that the existing libre-java communities knew about the plans before it all hit the press. Jonathan Schwartz, the Sun CEO, himself explicitly reached out to the existing GNU Classpath, GCJ and Kaffe communities with an offer to collaborate with the developers making libre-java on GNU/Linux a reality. The Sun OpenJDK engineers came to the Fosdem conference to have a DevJam and share their ideas with the existing libre-java communities.

Sun couldn't liberate all the code at once, but did so in stages for anything it could get all the rights to over the last year. At the same time, Sun has been slowly opening up the internal development process and switching to a public repository for all the code (Kelly O'Hair keeps a blog that is a great case study for moving a large project to Mercurial). Currently all code for Glassfish and phoneME have been released, while about 96% of the OpenJDK code base is available (almost all the parts not released yet are because Sun couldn't get the rights from some third party). Rich Sands gives a great overview of how all this looked from inside Sun in his one year retrospective on java liberation day.

Meanwhile, an effort called IcedTea was started to put OpenJDK into GNU/Linux distributions by moving it quickly towards that 100% free software line. As Andrew Haley explained during the official announcement, it is an experimental build tree that tries to stay close to the OpenJDK upstream but does not contain any non-free proprietary blobs. Those pieces are either stubbed out or replaced with code from GNU Classpath. IcedTea can be built using only free software. In particular, you can use GCJ for the first build phase to bootstrap those parts that depend on a working java compiler and runtime. It can be easily built on a modern GNU/Linux distribution with a simple ./configure && make; or at least that is the theory. It builds out of the box on Fedora 7 or 8. For Debian and Gentoo some additional steps are still needed.

Because OpenJDK didn't have a open bug database and (until recently) a source code repository, IcedTea has an open public bugtracker and a mercurial repository. All discussions about the code are done on the public OpenJDK distro-pkg-dev mailing list.

IcedTea is what most GNU/Linux distributions ship now for x86 and x86_64 in addition to GCJ for other architectures. IcedTea also adds some things that make things easier for distribution packagers. It adds patches so that the runtime and core libraries link to system shared libraries, like zlib and libjpeg, which should make security updates simpler. It adds support for using things like the system wide tzdata files for the TimeZone utility classes. It also supports using the system installed certificate authority files for security related checks as used in the ssl network classes. Thomas Fitzsimmons, who helped with the above items, keeps a Packager's Wishlist for OpenJDK.

IcedTea also contains some bug fixes from people who submitted patches to the OpenJDK upstream, which haven't been accepted yet, to give them a wider testing audience. Others have offered alternative backends for existing packages that make java applications integrate better in a GNU/Linux system. An example is the GConf backend for the java.util.prefs package by Mario Torre, which he ported from GNU Classpath.

Lastly, IcedTea is a testbed for porting OpenJDK to other architectures beyond the currently supported x86, x86_64 and sparc. There are two different approaches. The first is to start with the Hotspot C++ Interpreter. HotSpot is the runtime of OpenJDK and actually contains another byte code interpreter by default, the Template Interpreter which is a bit harder to port. After requests from the community, Sun also released its older C++ based interpreter to help the porting effort. Gary Benson recently made a breakthrough and got that working for PowerPC (both 32 and 64 bit). He wrote a guide to porting IcedTea that will hopefully help people porting to other architectures. Of course the interpreter alone is slow, but the benefit is that you get a full system up and running that is similar to the existing architectures with full support for all features. The next step is to add support for the HotSpot just-in-time (JIT) compilers, which will be a lot of work.

Another approach is taken by the Cacao team who are working on replacing the whole HotSpot runtime with a libjvm.so based on the Cacao JITs, but reusing all of the core libraries. This now works for s390 and powerpc. Cacao also supports alpha, arm and mips, so this is an interesting path for getting a faster port. You will have to replace all of the Hotspot runtime to get it. The Cacao VM is still missing some features, like annotations and full debugging support.

There are some other interesting developments around former GNU Classpath-based projects that are now experimenting with combining their code and the new OpenJDK and/or PhoneME projects. Dalibor Topic worked on a Google Summer of Code project to make the OpenJDK javac compiler a source-to-bytecode front end for the GCJ native compiler. The MIDPath project combines elements of SE and ME, plus different backends (SDL, FB, AWT, X11, Gtk+ and Qt) to provide access to MIDP2, a mobile devices standard used on many phones for various platforms. JaLiMo provides all of the above packaged for the Maemo and OpenMoko platforms. JNode is a full operating system written in java that is now built upon a hybrid of OpenJDK and GNU Classpath libraries. There is also the IKVM project that is providing a java implementation, translation and interoperability framework for .net implementations like Mono.

With all this one could safely say that The Java Trap has been dismantled. But even with some replacements from GNU Classpath, IcedTea/OpenJDK is still missing some small parts. The java.sound implementation isn't complete, but Sun released the parts so it could. The Java Management Extensions (JMX) implementation is missing SNMP support. Applets are currently supported through gcjwebplugin, which has the benefit that there is finally a 64-bit plugin, but it is still missing LiveConnect (Java/JavaScript integration). And finally there is no support yet for Java Network Launch Protocol (JNLP aka Java Web Start), although there is netx, which might be added to IcedTea soon.

So when you put all the above together, what Java version do we get? Officially what the GNU/Linux distributions ship now isn't Java(TM) since it isn't certified. And IcedTea comes with the following warning:

IcedTea is derived from OpenJDK, Sun's open-source implementation of the Java SE platform. At this time the build from which IcedTea was constructed corresponds to an early build (b21) of JDK 7. When JDK 7 is complete it will implement the Java SE 7 Platform Specification. Work on that specification is underway, but far from final. Any APIs in the JDK 7 implementation, whether new or old, are therefore subject to minor adjustments, major revisions, or even outright removal between now and the time that the Java SE 7 Platform Specification is finalized. Please take these facts into account before depending upon IcedTea.

Red Hat has recently signed the OpenJDK Community TCK License Agreement. This gives them access to the test suite that determines whether an implementation that is derived from the OpenJDK project complies with the Java SE 6 specification. This will cover the binary releases that they ship (while the source code will of course still be available under the GPL). This agreement does, however, contain an NDA which prevents talking about how compatible the current code is. The test compatibility kit itself is still proprietary, so it will be hard to work together with the community at large on this.

One year after Java Liberation Day modern GNU/Linux distributions are starting to ship with a more complete free java-like stack than ever before, but there are still some small loose ends to tie up. It was a learning experience for all communities involved as suddenly the whole free java ecosystem changed. There was certainly a lot of frustration about the speed with which things opened up. On the other side, there was frustration with the fact that shipping something purely-free seemed more important than compatibility. But Sun consistently kept its promises about opening up. The existing libre-java communities learned to respect and take advantage of the now free reference implementation of the code that they worked so hard to replace over the last decade. Now the fruits of collaboration and reusing each others code is materializing. In less than another year, it will be common to have a full, free, java stack, either SE, ME or EE, wherever you find GNU/Linux running.

[ Mark Wielaard has been doing libre-java development since 1999. He is also the maintainer of GNU Classpath. He is currently employed as an engineer by Red Hat on non-java related projects. ]

Index entries for this article
GuestArticlesWielaard, Mark


to post comments

C++ interpreter

Posted Nov 21, 2007 14:17 UTC (Wed) by gbenson (guest, #38086) [Link] (1 responses)

“Sun also released its older C++ based interpreter to help the porting effort”

The C++ interpreter is actually the newer of the two. The template interpreter is the original and is written entirely in assembler, so a port to a new platform involves (amongst other things) writing individual implementations of each of the 200 or so bytecodes. The C++ interpreter has these bytecode implementations in C++ so it's much easier to bring up on a new platform. It was originally written to port Java 1.4.2 to ia64 (ia64 assembly is “special”).

*** Cacao ***

Posted Nov 22, 2007 21:36 UTC (Thu) by thebohemian (guest, #38715) [Link]

AFAIK cacao supports annotations. I asked twisti about this some time back.

Debugging (JMVTI) and split verification is what it lacks.

However I am working on the latter for my diploma thesis :)

Piecing together free java

Posted Nov 21, 2007 14:25 UTC (Wed) by rfunk (subscriber, #4054) [Link] (1 responses)

This meta-package in Debian/ubuntu looks intriguing.....

free-java-sdk - Complete Java SDK environment consisting of free Java tools

Piecing together free java

Posted Nov 22, 2007 20:06 UTC (Thu) by robilad (guest, #27163) [Link]

Almost ... it's jikes based, and jikes seems dormant at the moment, so it doesn't actually
support the Java language constructs introduced a few years ago, that are necessary, for
example, for bootstrapping GNU Classpath these days.

Piecing together free java

Posted Nov 21, 2007 14:54 UTC (Wed) by arekm (guest, #4846) [Link] (5 responses)

Isn't some java *already* required to even bootstrap icetea? AFAIK the asnwer is "yes" so this
isn't so easy as just ./configure && make. It's much harder. You need to have that "first"
java.

Piecing together free java

Posted Nov 21, 2007 15:18 UTC (Wed) by mjw (subscriber, #16740) [Link] (4 responses)

You have to have GCJ http://gcc.gnu.org/java installed already yes, that is what IcedTea
relies on. But that is availably on most GNU/Linux distros since a couple of years.

Piecing together free java

Posted Nov 21, 2007 16:33 UTC (Wed) by nix (subscriber, #2304) [Link] (1 responses)

Well, you need a 1.5-capable GCJ, which isn't as old as a couple of years :) but anyone can
get it out of the appropriate branch or (if daring) from GCC SVN HEAD (although using the GCC
in SVN HEAD without appropriate genuflections can, I understand, cause ifrits to emerge from
your machine for entirely innocent technical reasons).

Piecing together free java

Posted Nov 21, 2007 17:32 UTC (Wed) by arekm (guest, #4846) [Link]

Yeah, I just tried it and it failed with gcc 4.2.2 gcj (1.4.2). So bootstraping icedtea
requires unreleased gcj :-(

Piecing together free java

Posted Nov 21, 2007 16:56 UTC (Wed) by drag (guest, #31333) [Link] (1 responses)

Yep. 

If you have OpenOffice.org installed from your distribution's package management systems then
more then likely you have GCJ installed. Redhat put a lot of effort into both with the goal of
getting OO.org (and other popular java-based apps) out of the 'Java Trap' and such, if I
remember correctly.

Piecing together free java

Posted Nov 21, 2007 19:47 UTC (Wed) by mjw (subscriber, #16740) [Link]

Yes, Red Hat has been very supportive of all the libre-java efforts. This is also why on Fedora 7 or 8 things just work and build out of the box. But with some small tweaks, as documented on the IcedTea Wiki FAQ, Debian and Gentoo systems can also bootstrap things now. In fact icedtea.classpath.org runs Debian and has a Debian sid chroot in which IcedTea is regularly bootstrapped with the system installed GCJ.

Thank You

Posted Nov 21, 2007 20:56 UTC (Wed) by tmarble (guest, #37983) [Link]

Mark:

Thank you for helping Sun grok Java in the Free Software world!

--Tom

Piecing together free java

Posted Nov 22, 2007 18:10 UTC (Thu) by kleptog (subscriber, #1183) [Link]

While I'm glad is finally usable on free systems, I can't help wondering how the world would
have looked it if this had been done two or more years ago...


Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds