What is GNU Classpath

GNU Classpath is an implementation of the essential core classes for the java programming language. It is a Free Software library for the GNU platform. It is an official GNU project with the FSF as custodian. And the GNU answer to what Richard Stallman described as The Java Trap. It is a project to make the freedom to share, study, modify and integrate available to all Free Software hackers wanting to use the java programming language. And it is a wonderful community of hackers having fun!

The main drivers of the project are providing users the freedom to tinker with the full system, pushing innovation by creating an architecture that makes people do new things, creating an environment where collaboration is the norm and just doing cool stuff together.

This has resulted in a large community of people (more than 100 individuals and companies have contributed significant work now) and projects (almost 30) all working together. Through these various people and projects GNU Classpath has been integrated nicely within the various GNU/Linux distributions which have started to provide Free Software written in the java programming language based on the GNU Classpath core classes.

Extending and enhancing the Free Software community

One of the attractive features of the GNU Classpath core library is that it supports a very rich set of facilities. It provides Free Software developers a reasonably well designed, object-oriented framework that covers most needs of a typical application. The support ranges from abstract data types to graphical user interfaces, from low-level network abstractions to remote method invocation with over-the-network class loading, from mathematical libraries to database access.

We think it is a nice extension to the rich Free Software environment that we already have. And if we manage to integrate all the good ideas (type-safety, modularity, object-oriented, rich core library, etc) nicely with the rest of the GNU system while maintaining compatibility with the java core libraries then we will reach more developers. Many people have already learned about the language and the standard library, by providing a free alternative we invite these people to join our community. And plenty of Free Software is already being written in the language. Just on SourceForge there are more than 12.000 Free Software projects. But there are certainly also arguments against it. Java has been over-hyped as a solution to everything, it has a bad reputation for wasting resources (cpu, memory), early implementations were slow, it looks like C/C++ and it doesn't integrate with any native platform. But we think we can (and have already) fix most of these issues while maintaining the good values.

Richard Stallman said in The GNU Manifesto about why GNU is compatible with Unix: "Unix is not my ideal, but it is not too bad. The essential features of Unix seem to be good ones, and I think I can fill in what Unix lacks without spoiling them. And a system compatible with Unix would be convenient for many other people to adopt." We hope that we have done the same with GNU Classpath. And that is why we make sure GNU Classpath is compatible with the core libraries for the java programming language.

The eco system, or write once, run where?

One of the cornerstones of the GNU system is the GNU Compiler Collection (GCC). GCC contains compilers, libraries and tools for a large number of programming languages such as C, C++, Objective-C, Fortran, Ada and java. The GCJ front end is combined with GNU Classpath as libgcj, the runtime library that provides threading, garbage collection and dynamic linking. So GCC provides a full free replacement for the java platform. One with some interesting properties because GCJ can used can be used in various modes to

The byte code interpreter is included as part of the libgcj runtime and can be used by programs to dynamically load and switch between interpreting byte code and executing natively compiled code on demand.

And although GCJ is a very robust implementation which has been ported to a lot of platforms we didn't stop there. GNU Classpath is also used with more traditional Just In Time (JIT) systems like Kaffe or Cacao; pure byte code interpreters like JamVM and SableVM; runtimes and compilers written completely in the java programming language like the IBM Jikes Research VM; JNode, a full Operating System written in the java programming language; real-time systems like OVM; Jupiter, a VM for multiprocessor clusters (128 CPU, Myrinet) and IKVM.NET, which translates java bytecode to the .NET Intermediate Language as used by Mono.

The collaboration of these very diverse projects on a common core library has made GNU Classpath a very robust and extensible library. It allows us to share the development load by have a common bug tracking system and test-suites. And it allows people to experiment and try out various (optimization) ideas in completely different environments.

Supporting diversity

The diversity of projects based on GNU Classpath make for some interesting engineering challenges. There are a couple of very different (sometimes conflicting) design goals. And the platform that needs to be integrated with the core libraries can be very diverse (from Posix, GNU and Gnome to the .net C# libraries or almost bare metal). This means you don't just need a vm interface between the runtime and the core class library. You also need a platform interface to deal with differences in threading, keeping track of time, timezones, i/o, network, differences in underlying gui toolkits or how a platform handles mime-types, etc.

To support this GNU Classpath has a delegate/facade pattern for various core or platform-dependent classes.

These VMClasses define a clear interface not just between the runtime and the core class library, but also signal were in the core class library there are platform-dependent hooks, or places for optimization. GNU Classpath comes with a full implementation of these classes for GNU/Posix-like systems with hooks to GTK+ (or Qt) for the (AWT) gui classes written in C and using the standard JNI interface. Different runtimes override some or even all of these to provide access to their own native platform layers.

Correctness, completeness and compatibility

One of the major focuses of the GNU Classpath project is expanding and using the free Mauve test suite for Compatibility, Completeness and Correctness checking. Various groups around GNU Classpath collaborate on the free software Mauve test suite which contains almost 50.000 core library tests. Mauve has various modules for testing core class library implementations, byte code verifiers, source to byte code and native code compiler tests. Mauve also contains the Wonka visual test suite and the Jacks Compiler Killer Suite. All these tests are continuously run on the development sources and carefully checked before each release to make sure no regressions occur. They can also be used to validate ports to new platforms.

The current release of GNU Classpath is 0.90. The packages supported are mostly those of 1.4. In the last year we added support for the Swing gui toolkit, Corba, a full JCE crypto provider, CUPS support for printing and ALSA support for sound. ImageIO and Graphics2D are two places that still need some work (integrating with the Cairo graphics library). Work on supporting the new 1.5 classes has already started on a separate branch. And we hope to have full 1.5 support in GNU Classpath by the end of this year. Most of the additional packages are already supported, most of the core library has been "genericized" on the branch, and there is a start of a new VM/Class interface for the generic and annotation reflection support. We also already have instrumentation and a VM interface for it. What is missing is sql.rowset support, text.html support and some of the newer ssl support, plus various new methods here and there, but all those don't need any exta runtime support. Things that need extra VM support are the new management (mx) and util.concurrency packages. There is a preliminary VM interface for the currency package already. Although one can use GDB for debugging we will also add support for JDWP to facilitate debugging with for example Eclipse.

GNU Classpath on your GNU/Linux Desktop

In the last couple of years various GNU/Linux distributions have started to bundle applications based on GNU Classpath. A very diverse set of applications and tools are now supported like office suites (OpenOffice), development environments (Eclipse), peer-to-peer applications (Azureus) and application servers (JOnAS and Tomcat).

For developers there are several full free development system available now in modern GNU/Linux distributions. You can use GCJ to compile your applications to fast (production quality) machine code, but as part of the critically important GCC suite, releases are not as frequent to allow more time for testing. So the latest stable release of gcc 4.1 is still based on an older GNU Classpath. Other runtimes that have more traditional interpreter/jit designs, like Kaffe, Cacao and JamVM do more rapid releases and sometimes include more advanced features earlier. And recent releases of Mono come with IKVM.NET and GNU Classpath included to make integration of .net and java easy. The Gnome platform now includes official java-gnome bindings for integration with all the desktop features. All these work with the Eclipse integrated development environment which makes application development a joy.

Our success has actually overwhelmed most GNU/Linux distributions which are now struggling with the number of new Free Software packages available. Take the eclipse development framework or the jonas application server for example.

Eclipse and Jonas package dependencies

ant-*, axis, bcel, classpathx-mail, eclipse-ecj, eclipse-rcp, gcc-java, gjdoc, gnu-crypto, jakarta-commons-*, java-1.4.2-gcj-compat, jessie, jsch, ldapjdk, libgcj, log4j, mx4j, tomcat5-*, wsdl4j, xml-commons-resolver, ...
avalon-framework, avalon-logkit, axis, bcel, carol, castor, classpathx-mail, eclipse-ecj, gjdoc, gnu-crypto, hsqldb, jakarta-commons-*, java-1.4.2-gcj-compat, jdom, jessie, jgroups, jonathan-core, jonathan-jeremie, joram, ldapjdk, libgcj, log4j, mx4j, objectweb-anttask, p6spy, struts, tomcat5-*, velocity, werken.xpath, wsdl4j, xdoclet, xjavadoc, xml-commons-resolver, ...

Both these program have been build upon existing Free Software packages which are all supported now through GNU Classpath. These programs use the easy combining of Free Software modules written in the java programming language to the extreme and both depend (in complex ways) on more than 50 sub-packages (only the most significant have been shown in the table above). This puts a lot of work on the shoulders of the packagers and reviewers. That is one of the reasons why JOnAS isn't in all the latest distributions yet. It takes too much time for the various package reviewers to digest the influx of new tools into their distribution.

One could say that we have succeeded in providing working code for a far range of existing Free Software projects written in the java programming language. The real challenge now is no longer producing working code (although help is still very much appreciated!). The applications that really matter do work on the free stack and are now included in the latest GNU/Linux distributions. The real problem now is the packaging and versioning of all that code. We are used to having pretty decent versioning and dependency control on GNU/Linux systems. That is not so in the traditional java world. The next challenge is sanely integrating the free java world with the GNU/Linux world. And finding a solution for the dependency and version problem that came with the liberation of all this cool new code. We are extremely happy that the major problem today is finding ways to sanely integrate and build the large and diverse set of Free Software that the community produced. And we hope your next Free Software project will be based on GNU Classpath and this rich set of libraries and tools build on top of it so that it will be included in your favorite GNU/Linux distribution in the future.

Thanks and future reading

GNU Classpath and all the projects around it would not be what it is today without the great and lively community it has. If you want to know more about it please visit the GNU Classpath home page. There is a list of stories about projects based on GNU Classpath. And you might enjoy the daily chatter of the various hackers on Planet Classpath.

For those interested in more technical details of the project there is the GNU Classpath Hacker Guide, the GNU Classpath Developers Wiki and the Runtime Integration Guide. And and (old) tutorial on Hacking VM Interface.

Hackers interested in using GNU Classpath for their own programs might want to check out the GNU Classpath class documentation and the GCJ manual.

The current status and a roadmap for most of the projects mentioned in this article can be found in Escaping the Java Trap: A practical road map to the Free Software and Open Source alternatives.

And please feel free to join our mailinglist and/or our irc channel #classpath on irc.gnu.org.