2005-09-25

Java source differences between Unix and Win32

I explained in a recent post that java.io.FileDescriptor on Win32 has different Java source to the same class on Unix. Despite the fact that it's a public class. I didn't know this was allowed, and was interested to find out where else it occurs.

To this end, I decompressed src.zip from Java 1.5 on both Win32 and Linux, and did a recursive diff(1) of the two trees. Here is a complete list of the differences:

  • First up is java.io.FileDescriptor, which I talked about already.

  • There are the package-private classes UnixFileSystem, Win32FileSystem, and WinNTFileSystem, all implementations of the package-private FileSystem abstract class. This seems fine.

  • There are various java.lang.CharacterDataX classes, generated by scripts during the build process. They contain comments showing that the builds were done at different times, and that the command-line arguments differed, but the classes themselves are identical. And anyway, these too are package-private.

  • java.lang.ProcessEnvironment and java.lang.ProcessImpl differ, but again they're package-private classes. I'm not sure why they don't follow the UnixProcessEnvironment/Win32ProcessEnvironment pattern, though.

  • java.lang.Terminator (again package-private) doesn't register a signal handler for SIGHUP on Win32. This is implemented by copying the class and removing a line rather than by run-time test.

  • java.lang.UnixProcess isn't included in the Win32 src.zip.

  • java.util.prefs contains different package-private classes on Unix and Win32.


It's not Java source, but there's also the launcher's java_md.c and java_md.h files ("_md" being Sun's convention for naming files containing machine-dependent source). And that's it.

So it's only java.io.FileDescriptor that seems dodgy. That's a relief.