The Networking Group
The networking group is a set of developers interested in the design, implementation, and maintanence of the Java networking libraries.
The source code for the networking part of the the core libraries is spread over a few hundreds files making for a total of, approximately, 70,000 lines of code. 50,000 of these are java code, while the rest is native (i.e. C) code. While this is not massive, due to the tricky nature of cross-platform support, some guidance is needed before you take upon the the task of tinkering with that beast.
The networking source code resides mostly in these directories:
This is where the public API resides. You should get familiar with the 67 classes and interfaces. If you're not there yet, a good start would be in the javadoc of the java.net package.
This is where many of the protocol handlers are implemented, as well as some other service providers like the default proxy selector, the DNS name resolver and some other utility classes. In particular the protocol handlers used by java.net.URLConnection are located in the
This is one is a bit of a misnomer but this is for historical reasons. This where you'll find most of the native code responsible for linking with the native networking stack (sockets, ioctl, etc...). It actually covers both Solaris and Linux, thanks to quite a few #ifdefs. This is where you'd have to do most of the work to add support for another flavor of the Unix system.
This is where the windows native code resides. During its 12+ years of existence it had to support Windows 95, 98, 98SE, ME, NT4, 2000, XP, 2003 and, more recently, Vista. This explains the complexity of the code in there, since the networking library of these various versions of Windows changed very significantly from one version to another. If you see a very strange piece of code in there that you can't quite understand and seems pointless, don't be fooled, it's there for a reason.
Here, you'll find a few utility functions used by all platform specific native code implementation.
Building the networking libraries
First, be aware that the networking components have interdependencies with quite a few other parts of the JDK. Even more so, it's one the components at the foundations of the JDK, so always make sure you can rebuild everything from scratch after you've made changes.
Now, there are 2 areas where makefiles, and related files, are located:
If you go to any of these 2 subdirectories you can issue a
make command and quickly compile your changes in
Testing your changes
As a rule, unit tests, for new functionality, and regression tests for fixes are mandatory. Which means you should provide a unit test for pretty much any change you make. The test directories follow the same structure as the others:
Contains the unit and regression tests for the java.net package.
Contains the unit and regression tests for the sun.net package.
Not only should you write tests for your changes but you should
always run all the existing tests in these directories before
submitting them. Moreover, because of the dependencies, it is
highly recommend to also run the regression tests for the security
components since the networking code is highly sensitive to
security. These are located in
test/sun/security. Needless to say, if any of these
tests fails, then you should investigate and fix the issue, or back
out your changes.
Remember, there is no such thing as too much testing.
- Mailing lists